diff --git a/app/components/SimpleEditor/elements/note/NoteComponent.js b/app/components/SimpleEditor/elements/note/NoteComponent.js index fef234eff61fc0426b193692fe5c596f60c50bc9..b295ffabde1e6ab23e625ff1d9c917acadf631a7 100644 --- a/app/components/SimpleEditor/elements/note/NoteComponent.js +++ b/app/components/SimpleEditor/elements/note/NoteComponent.js @@ -7,15 +7,14 @@ class NoteComponent extends Component { didMount () { // TODO -- this disables the toolbar // TODO -- unload listener on dispose - // TODO -- this gets registered once for each note -- fix + // TODO -- this gets registered once for each note -- to fix use didUpdate + // this should only call disableTools this.context.editorSession.onUpdate('', this.noteSelected, this) } render ($$) { const noteContent = this.props.node['note-content'] - // TODO -- why note??? - // const el = $$('note') const el = $$('span') .attr('note-content', noteContent) .addClass('sc-note') @@ -26,9 +25,13 @@ class NoteComponent extends Component { // TODO -- should this maybe be the provider's job? noteSelected () { + // TODO -- we already have the note id in the props const selected = this.getSelection() if (get(selected, 'node.type') !== 'note') return + // this shouldn't be here + // it should just be called when the selection updates + // not on click of the note component this.disableTools(selected) const provider = this.getProvider() @@ -41,11 +44,14 @@ class NoteComponent extends Component { disableTools () { const commandStates = this.getCommandStates() + // TODO -- this uses the same code as the fn in container editor + // use the fn from there each(keys(commandStates), (key) => { - const allowed = ['comment', 'redo', 'save', 'switch-text-type', 'undo', 'note'] + const allowed = ['comment', 'redo', 'save', 'switch-text-type', 'undo'] if (!includes(allowed, key)) commandStates[key].disabled = true }) + // TODO -- do we need the rerender here?? this.rerender() } @@ -62,6 +68,8 @@ class NoteComponent extends Component { sel, { type: 'note' } ) + + // TODO -- scrap all below const note = notes[0] let show = false if (typeof note !== 'undefined') {