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 {
// use toc:updated to avoid rewriting TOCProvider's this.handleDocumentChange
didMount () {
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) {
......@@ -63,23 +70,10 @@ class Notes extends Component {
_initMiniEditor (tx) {
const configurator = new Configurator().import(config)
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, {
configurator: configurator
......@@ -95,8 +89,6 @@ class Notes extends Component {
const notes = provider.computeEntries()
let self = this
console.log('notes', notes)
forEach(notes.main, function (mainNote) {
forEach(notes.mini, function (miniNote) {
if (miniNote.parentNoteId === mainNote.id) {
......@@ -107,8 +99,6 @@ class Notes extends Component {
}
})
})
// this.context.editor.rerender()
console.log('notes after', notes)
return new Promise(function (resolve, reject) {
resolve()
})
......
......@@ -23,7 +23,7 @@ class NotesProvider extends TOCProvider {
const entriesMain = this.sortNodes(notesMain)
const entriesMini = this.sortNodesMini(notesMini)
console.log(entriesMain, entriesMini)
// console.log(entriesMain, entriesMini)
const entries = {
main: entriesMain,
mini: entriesMini
......@@ -61,10 +61,7 @@ class NotesProvider extends TOCProvider {
let notes = _.clone(nodes)
if (this.config.miniEditorSession === '') return
const doc = this.config.miniEditorSession.document
const container = doc.get('body')
// console.log(notes)
// const doc = this.config.miniEditorSession.document
notes = _.map(notes, function (note) {
// const blockId = note.path[0]
// const blockPosition = container.getPosition(blockId)
......@@ -84,8 +81,6 @@ class NotesProvider extends TOCProvider {
}
createShowNote (note) {
console.log('in provider', note)
console.log('this', this)
if (note['note-content'] !== '') {
console.log('empty')
......@@ -106,18 +101,9 @@ class NotesProvider extends TOCProvider {
createIsolatedNote (note) {
let self = this
let node = {}
console.log('this', this)
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)
// console.log('nodeData', nodeData)
node = tx.insertBlockNode(nodeData)
console.log('node', node)
tx.insertBlockNode(nodeData)
})
}
......
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