diff --git a/app/components/SimpleEditor/elements/note/EditNoteTool.js b/app/components/SimpleEditor/elements/note/EditNoteTool.js index 34a4777823249f0156bf84cbd5bfe606213f7fba..0d4569d285573d2fa1cfe56e5e9581a0e253ccef 100644 --- a/app/components/SimpleEditor/elements/note/EditNoteTool.js +++ b/app/components/SimpleEditor/elements/note/EditNoteTool.js @@ -1,6 +1,10 @@ import { each, includes, keys } from 'lodash' -import { documentHelpers, Tool, ProseEditorConfigurator as Configurator, - EditorSession } from 'substance' +import { + documentHelpers, + EditorSession, + ProseEditorConfigurator as Configurator, + Tool +} from 'substance' import MiniEditor from '../../miniEditor/miniEditor' import config from '../../miniEditor/config' @@ -8,7 +12,6 @@ import Importer from '../../SimpleEditorImporter' import SimpleExporter from '../../SimpleEditorExporter' class EditNoteTool extends Tool { - constructor (props) { super(props) this.saveNote = this.saveNote.bind(this) @@ -16,12 +19,16 @@ class EditNoteTool extends Tool { render ($$) { const miniEditorSession = this._initMiniEditor() - let el = $$('div').addClass('sc-edit-note-tool') const selected = this.getSelection() + + let el = $$('div').addClass('sc-edit-note-tool') + if (!selected.node) return el + el.append($$(MiniEditor, { editorSession: miniEditorSession })) + return el } @@ -87,18 +94,29 @@ class EditNoteTool extends Tool { const session = this.context.editorSession const sel = session.getSelection() - const note = documentHelpers.getPropertyAnnotationsForSelection( + const notes = documentHelpers.getPropertyAnnotationsForSelection( session.getDocument(), sel, { type: 'note' } ) + const note = notes[0] + let show = false + + if (typeof note !== 'undefined') { + if ((sel.start.offset === note.start.offset && + sel.end.offset === note.end.offset)) { + show = true + } + } + // disable when larger selection that just includes a note as well - const selectionLength = (sel.end.offset - sel.start.offset === 1) + // const selectionLength = (sel.end.offset - sel.start.offset === 1) + // if (sel.end.offset - sel.) - if (typeof note[0] !== 'undefined' && selectionLength) { + if (show) { return { - node: note[0] + node: note } } else { return { diff --git a/app/components/SimpleEditor/elements/note/note.scss b/app/components/SimpleEditor/elements/note/note.scss index fb665bad00eb8e45e56b8cd2f7161e2158d7207f..5e54d1c6ec6e2cdb69e55f5909740bcef04bf76b 100644 --- a/app/components/SimpleEditor/elements/note/note.scss +++ b/app/components/SimpleEditor/elements/note/note.scss @@ -1,15 +1,18 @@ $gray: #eee; $red: #591818; -// .hidden { -// display: none; -// } + .sc-prose-editor { counter-reset: note; + .sm-note { + display: inline-block; + } + .sc-note { color: $red; - display: inline-block; // TODO -- is this correct? + display: block; font-weight: bold; + user-select: initial; } .sc-note::after {