From f83220f5d2745b6bfeddc9234ae817f629dfdeac Mon Sep 17 00:00:00 2001 From: Alexandros Georgantas <alexgeorg86@gmail.com> Date: Tue, 25 Apr 2017 13:07:26 +0300 Subject: [PATCH] Isolated notes now extend substance's isolatednodecomponent --- .../SimpleEditor/elements/isolatedNote/IsolatedNote.js | 2 ++ .../elements/isolatedNote/IsolatedNoteComponent.js | 9 +++++---- .../elements/isolatedNote/IsolatedNotePackage.js | 1 - app/components/SimpleEditor/notesEditor/NotesEditor.js | 6 +++--- app/components/SimpleEditor/panes/Notes/Notes.js | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js index 559a37e..d56e33c 100644 --- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js +++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNote.js @@ -14,4 +14,6 @@ IsolatedNote.define({ }, content: 'text' }) +IsolatedNote.mode = 'focused' +IsolatedNote.unblocked = true export default IsolatedNote diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js index 0ad0e0f..2332bb8 100644 --- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js +++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js @@ -1,15 +1,16 @@ -import { BlockNodeComponent } from 'substance' +import { IsolatedNodeComponent } from 'substance' import TextPropertyEditor from './TextPropertyEditor' -class IsolatedNoteComponent extends BlockNodeComponent { +class IsolatedNoteComponent extends IsolatedNodeComponent { render ($$) { let el = $$('div').addClass('sc-entity') + el.attr('data-id', this.props.node.id) el.append( $$(TextPropertyEditor, { path: [this.props.node.id, 'content'], - disabled: this.context.editor.props.disabled, + disabled: this.props.disabled, tagName: 'p', - multiLine: true + multiLine: false }).ref('noteContentEditor-' + this.props.node.id)) return el diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNotePackage.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNotePackage.js index 9aa292f..e64f681 100644 --- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNotePackage.js +++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNotePackage.js @@ -3,7 +3,6 @@ import IsolatedNoteComponent from './IsolatedNoteComponent' import IsolatedNoteHTMLConverter from './IsolatedNoteHTMLConverter' import IsolatedNoteCommand from './IsolatedNoteCommand' import IsolatedNoteTool from './IsolatedNoteTool' -// import {InsertInlineNodeCommand} from 'substance' export default { name: 'isolated-note', diff --git a/app/components/SimpleEditor/notesEditor/NotesEditor.js b/app/components/SimpleEditor/notesEditor/NotesEditor.js index b83bd26..304c73f 100644 --- a/app/components/SimpleEditor/notesEditor/NotesEditor.js +++ b/app/components/SimpleEditor/notesEditor/NotesEditor.js @@ -152,20 +152,20 @@ class NotesEditor extends ProseEditor { const selection = this.editorSession.getSelection() if (selection.start && selection.start.offset === 0 && selection.end.offset === 0) { this.editorSession.setSelection(null) + this.context.editorSession.setSelection(null) } - + const exporter = new SimpleExporter(this.props.configurator.config) const convertedNode = exporter.convertNode(isolatedNote) this.context.editorSession.transaction(function (tx, args) { const path = [isolatedNote.parentNoteId, 'note-content'] - tx.set(path, convertedNode.outerHTML) + tx.set(path, convertedNode.innerHTML) }) } findNote () { const selection = this.editorSession.getSelection() if (!selection.end) return - const isolatedNoteId = selection.end.path[0] const isolatedNote = this.editorSession.document.get(isolatedNoteId) return this.saveNote(isolatedNote) diff --git a/app/components/SimpleEditor/panes/Notes/Notes.js b/app/components/SimpleEditor/panes/Notes/Notes.js index 99a6d1b..7acbdd5 100644 --- a/app/components/SimpleEditor/panes/Notes/Notes.js +++ b/app/components/SimpleEditor/panes/Notes/Notes.js @@ -59,7 +59,7 @@ class Notes extends Component { for (var i = 0; i < notes.length; i++) { let isolatedNoteElement = exporter.createElement('isolated-note') - isolatedNoteElement.setAttribute('parent-note-id', notes[i].id) + isolatedNoteElement.setAttribute('data-parent-id', notes[i].id) isolatedNoteElement.innerHTML = notes[i]['note-content'] noteContent += isolatedNoteElement.outerHTML } -- GitLab