Skip to content
Snippets Groups Projects
Commit 477e2464 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

selection around notes does not open tooltip

parent f1963032
No related branches found
No related tags found
No related merge requests found
import { each, includes, keys } from 'lodash' import { each, includes, keys } from 'lodash'
import { documentHelpers, Tool, ProseEditorConfigurator as Configurator, import {
EditorSession } from 'substance' documentHelpers,
EditorSession,
ProseEditorConfigurator as Configurator,
Tool
} from 'substance'
import MiniEditor from '../../miniEditor/miniEditor' import MiniEditor from '../../miniEditor/miniEditor'
import config from '../../miniEditor/config' import config from '../../miniEditor/config'
...@@ -8,7 +12,6 @@ import Importer from '../../SimpleEditorImporter' ...@@ -8,7 +12,6 @@ import Importer from '../../SimpleEditorImporter'
import SimpleExporter from '../../SimpleEditorExporter' import SimpleExporter from '../../SimpleEditorExporter'
class EditNoteTool extends Tool { class EditNoteTool extends Tool {
constructor (props) { constructor (props) {
super(props) super(props)
this.saveNote = this.saveNote.bind(this) this.saveNote = this.saveNote.bind(this)
...@@ -16,12 +19,16 @@ class EditNoteTool extends Tool { ...@@ -16,12 +19,16 @@ class EditNoteTool extends Tool {
render ($$) { render ($$) {
const miniEditorSession = this._initMiniEditor() const miniEditorSession = this._initMiniEditor()
let el = $$('div').addClass('sc-edit-note-tool')
const selected = this.getSelection() const selected = this.getSelection()
let el = $$('div').addClass('sc-edit-note-tool')
if (!selected.node) return el if (!selected.node) return el
el.append($$(MiniEditor, { el.append($$(MiniEditor, {
editorSession: miniEditorSession editorSession: miniEditorSession
})) }))
return el return el
} }
...@@ -87,18 +94,29 @@ class EditNoteTool extends Tool { ...@@ -87,18 +94,29 @@ class EditNoteTool extends Tool {
const session = this.context.editorSession const session = this.context.editorSession
const sel = session.getSelection() const sel = session.getSelection()
const note = documentHelpers.getPropertyAnnotationsForSelection( const notes = documentHelpers.getPropertyAnnotationsForSelection(
session.getDocument(), session.getDocument(),
sel, sel,
{ type: 'note' } { 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 // 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 { return {
node: note[0] node: note
} }
} else { } else {
return { return {
......
$gray: #eee; $gray: #eee;
$red: #591818; $red: #591818;
// .hidden {
// display: none;
// }
.sc-prose-editor { .sc-prose-editor {
counter-reset: note; counter-reset: note;
.sm-note {
display: inline-block;
}
.sc-note { .sc-note {
color: $red; color: $red;
display: inline-block; // TODO -- is this correct? display: block;
font-weight: bold; font-weight: bold;
user-select: initial;
} }
.sc-note::after { .sc-note::after {
......
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