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

Comments are saved in the isolated note

parent 6975abe0
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ class CommentComponent extends AnnotationComponent { ...@@ -10,7 +10,7 @@ class CommentComponent extends AnnotationComponent {
const { node } = this.props const { node } = this.props
const active = node.active const active = node.active
var el = $$('span') var el = $$('comment')
.attr('data-id', this.props.node.id) .attr('data-id', this.props.node.id)
.addClass(this.getClassNames()) .addClass(this.getClassNames())
......
...@@ -17,13 +17,6 @@ class Notes extends Component { ...@@ -17,13 +17,6 @@ class Notes extends Component {
didMount () { didMount () {
const provider = this.getProvider() const provider = this.getProvider()
this.context.editorSession.onUpdate('document', this.onNotesUpdated, this) this.context.editorSession.onUpdate('document', this.onNotesUpdated, this)
const notes = provider.computeEntries()
for (var i = 0; i < notes.main.length; i++) {
provider.createIsolatedNote(notes.main[i])
}
provider.config.miniEditorSession.onUpdate('document', this.saveNotes, this) provider.config.miniEditorSession.onUpdate('document', this.saveNotes, this)
} }
...@@ -78,7 +71,16 @@ class Notes extends Component { ...@@ -78,7 +71,16 @@ class Notes extends Component {
const importer = configurator.createImporter('html') const importer = configurator.createImporter('html')
const doc = importer.importDocument('') const provider = this.getProvider()
const notes = provider.computeEntries()
let noteContent = ''
for (var i = 0; i < notes.main.length; i++) {
noteContent += notes.main[i]['note-content']
}
const doc = importer.importDocument(noteContent)
const editorSession = new EditorSession(doc, { const editorSession = new EditorSession(doc, {
configurator: configurator configurator: configurator
......
...@@ -62,23 +62,17 @@ class NotesProvider extends TOCProvider { ...@@ -62,23 +62,17 @@ 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
notes = _.map(notes, function (note) { notes = _.map(notes, function (note) {
// const blockId = note.path[0] const element = document.querySelector('p[data-path="' + note.id + '.content"]')
// const blockPosition = container.getPosition(blockId) const noteContent = '<isolated-note data-id="' + note.id + '" data-type="isolated-note">' + element.innerHTML + '</isolated-note>'
// const nodePosition = note.start.offset
return { return {
id: note.id, id: note.id,
content: note.content, content: noteContent,
parentNoteId: note.parentNoteId parentNoteId: note.parentNoteId
// blockPosition: blockPosition,
// nodePosition: nodePosition,
// node: note
} }
}) })
return notes return notes
// return _.sortBy(notes, ['blockPosition', 'nodePosition'])
} }
showNote (note) { showNote (note) {
......
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