Skip to content
Snippets Groups Projects
Commit 88bb685e authored by chris's avatar chris Committed by john
Browse files

isolated node created for first note and saved

parent a891f078
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,13 @@ class Notes extends Component { ...@@ -17,6 +17,13 @@ class Notes extends Component {
// use toc:updated to avoid rewriting TOCProvider's this.handleDocumentChange // use toc:updated to avoid rewriting TOCProvider's this.handleDocumentChange
didMount () { didMount () {
this.context.editorSession.onUpdate('document', this.onNotesUpdated, this) this.context.editorSession.onUpdate('document', this.onNotesUpdated, this)
const provider = this.getProvider()
const notes = provider.computeEntries()
for (var i = 0; i < notes.main.length; i++) {
provider.createIsolatedNote(notes.main[i])
}
} }
initResize (e) { initResize (e) {
...@@ -63,23 +70,10 @@ class Notes extends Component { ...@@ -63,23 +70,10 @@ class Notes extends Component {
_initMiniEditor (tx) { _initMiniEditor (tx) {
const configurator = new Configurator().import(config) const configurator = new Configurator().import(config)
configurator.addImporter('html', Importer) configurator.addImporter('html', Importer)
console.log('tx', tx)
const importer = configurator.createImporter('html')
const provider = this.getProvider()
const notes = provider.computeEntries()
let nontesContent = ''
if (this.context.notesProvider.config.miniEditorSession !== '') {
for (var i = 0; i < notes.main.length; i++) {
console.log('old', provider)
console.log('createIsolated', provider.createIsolatedNote(notes.main[i]))
nontesContent += provider.createIsolatedNote(notes.main[i])
}
}
const importer = configurator.createImporter('html')
const doc = importer.importDocument(notesContent) const doc = importer.importDocument('')
const editorSession = new EditorSession(doc, { const editorSession = new EditorSession(doc, {
configurator: configurator configurator: configurator
...@@ -95,8 +89,6 @@ class Notes extends Component { ...@@ -95,8 +89,6 @@ class Notes extends Component {
const notes = provider.computeEntries() const notes = provider.computeEntries()
let self = this let self = this
console.log('notes', notes)
forEach(notes.main, function (mainNote) { forEach(notes.main, function (mainNote) {
forEach(notes.mini, function (miniNote) { forEach(notes.mini, function (miniNote) {
if (miniNote.parentNoteId === mainNote.id) { if (miniNote.parentNoteId === mainNote.id) {
...@@ -107,8 +99,6 @@ class Notes extends Component { ...@@ -107,8 +99,6 @@ class Notes extends Component {
} }
}) })
}) })
// this.context.editor.rerender()
console.log('notes after', notes)
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
resolve() resolve()
}) })
......
...@@ -23,7 +23,7 @@ class NotesProvider extends TOCProvider { ...@@ -23,7 +23,7 @@ class NotesProvider extends TOCProvider {
const entriesMain = this.sortNodes(notesMain) const entriesMain = this.sortNodes(notesMain)
const entriesMini = this.sortNodesMini(notesMini) const entriesMini = this.sortNodesMini(notesMini)
console.log(entriesMain, entriesMini) // console.log(entriesMain, entriesMini)
const entries = { const entries = {
main: entriesMain, main: entriesMain,
mini: entriesMini mini: entriesMini
...@@ -61,10 +61,7 @@ class NotesProvider extends TOCProvider { ...@@ -61,10 +61,7 @@ class NotesProvider extends TOCProvider {
let notes = _.clone(nodes) let notes = _.clone(nodes)
if (this.config.miniEditorSession === '') return if (this.config.miniEditorSession === '') return
const doc = this.config.miniEditorSession.document // const doc = this.config.miniEditorSession.document
const container = doc.get('body')
// console.log(notes)
notes = _.map(notes, function (note) { notes = _.map(notes, function (note) {
// const blockId = note.path[0] // const blockId = note.path[0]
// const blockPosition = container.getPosition(blockId) // const blockPosition = container.getPosition(blockId)
...@@ -84,8 +81,6 @@ class NotesProvider extends TOCProvider { ...@@ -84,8 +81,6 @@ class NotesProvider extends TOCProvider {
} }
createShowNote (note) { createShowNote (note) {
console.log('in provider', note)
console.log('this', this)
if (note['note-content'] !== '') { if (note['note-content'] !== '') {
console.log('empty') console.log('empty')
...@@ -106,18 +101,9 @@ class NotesProvider extends TOCProvider { ...@@ -106,18 +101,9 @@ class NotesProvider extends TOCProvider {
createIsolatedNote (note) { createIsolatedNote (note) {
let self = this let self = this
let node = {}
console.log('this', this)
this.config.miniEditorSession.transaction(function (tx) { this.config.miniEditorSession.transaction(function (tx) {
var container = tx.get('body')
// console.log('container', container)
// var textType = tx.getSchema().getDefaultTextType()
// console.log('tx', tx)
let nodeData = self.createNodeData(tx, note) let nodeData = self.createNodeData(tx, note)
// console.log('nodeData', nodeData) tx.insertBlockNode(nodeData)
node = tx.insertBlockNode(nodeData)
console.log('node', node)
}) })
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment