diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js index 1225ed1bd09e1c15a180add95bfcc417ade7c8d2..559a37ea74af8a32d426514111ee17b4e7e5436e 100644 --- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js +++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js @@ -5,7 +5,8 @@ class IsolatedNote extends DocumentNode {} IsolatedNote.define({ 'type': 'isolated-note', 'parentNoteId': { - type: 'string' + type: 'string', + optional: true }, 'index': { type: 'number', @@ -13,5 +14,4 @@ IsolatedNote.define({ }, content: 'text' }) - export default IsolatedNote diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteHTMLConverter.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteHTMLConverter.js index 590f37d0b350d01d884d4c9103228cb53fa01ae4..c286907f23ee7412004f6e80310e92b4bd29a94b 100644 --- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteHTMLConverter.js +++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteHTMLConverter.js @@ -3,7 +3,13 @@ export default { tagName: 'isolated-note', import: function (el, node, converter) { - console.log('imported nodes', node) node.content = converter.annotatedText(el, [node.id, 'content']) + node.parentNoteId = el.attr('data-parent-id') + }, + export: function (node, el, converter) { + el.append( + converter.annotatedText([node.id, 'content']) + ) + el.setAttribute('data-parent-id', node.parentNoteId) } } diff --git a/app/components/SimpleEditor/panes/Notes/Notes.js b/app/components/SimpleEditor/panes/Notes/Notes.js index 829a4f6094e867b6f686ed154c2d78850242b3e1..927d81fb7fa3aee1baae9ba56c7222d785d8432a 100644 --- a/app/components/SimpleEditor/panes/Notes/Notes.js +++ b/app/components/SimpleEditor/panes/Notes/Notes.js @@ -100,16 +100,13 @@ class Notes extends Component { const configurator = new Configurator().import(config) const exporter = new SimpleExporter(configurator.config) - forEach(notes.main, function (mainNote) { - forEach(notes.mini, function (miniNote) { + forEach(notes.main, function (mainNote, indexmain) { + forEach(notes.mini, function (miniNote, indexmini) { if (miniNote.parentNoteId === mainNote.id) { - console.log(exporter.createElement(miniNote)) - // console.log(exportedNode) - // const exportedNode = exporter.convertNode(miniNote) - // console.log('sdlkfjslfkjsfdlkj', exporter.annotatedText(exportedNode.getTextPath())) + const exportedNode = exporter.convertNode(miniNote) this.context.editorSession.transaction(function (tx, args) { const path = [mainNote.id, 'note-content'] - tx.set(path, 'exportedNode.outerHTML') + tx.set(path, exportedNode.outerHTML) }) } }.bind(this)) diff --git a/app/components/SimpleEditor/panes/Notes/NotesProvider.js b/app/components/SimpleEditor/panes/Notes/NotesProvider.js index 7f04639f470822d3f0cc7ddd3aec434fb6cf1d7e..ef2bca1e4cf05f7c7c78b04f99a0c1083e8dd4c8 100644 --- a/app/components/SimpleEditor/panes/Notes/NotesProvider.js +++ b/app/components/SimpleEditor/panes/Notes/NotesProvider.js @@ -27,7 +27,7 @@ class NotesProvider extends TOCProvider { // console.log(entriesMain, entriesMini) const entries = { main: entriesMain, - mini: entriesMini + mini: notesMini } if (entriesMini && entriesMain.length < entriesMini.length) { @@ -69,7 +69,6 @@ class NotesProvider extends TOCProvider { let rootEl = this.config.miniEditorContext.editor.el notes = _.map(notes, function (note) { - console.log('noteeee', note) const element = Component.unwrap(rootEl.find('p[data-path="' + note.id + '.content"]')) // removes a <br> insterted at the end by inline node // const text = element.innerHTML.slice(0, -4) @@ -94,7 +93,7 @@ class NotesProvider extends TOCProvider { createNodeData (note) { return { 'type': 'isolated-note', - 'content': '', + 'path': '', 'parentNoteId': note.id } }