Skip to content
Snippets Groups Projects
Commit 2f2973fc authored by chris's avatar chris
Browse files

add overlay file

parent 84065136
No related branches found
No related tags found
No related merge requests found
import { ProseEditorOverlayTools, documentHelpers } from 'substance'
import { each, includes, keys } from 'lodash'
class Overlay extends ProseEditorOverlayTools {
render ($$) {
const surface = this.getSurface()
const session = this.context.documentSession
const sel = session.getSelection()
const comment = documentHelpers.getPropertyAnnotationsForSelection(
session.getDocument(),
sel,
{ type: 'commnent' }
)
if (surface && surface.props.canNotEdit && typeof comment[0] === 'undefined') {
const commandStates = this.context.commandManager.getCommandStates()
each(keys(commandStates), (key) => {
const allowed = ['comment', 'save']
if (!includes(allowed, key)) commandStates[key].disabled = true
})
}
let el = $$('div').addClass(this.getClassNames())
let activeTools = this.getActiveTools()
if (activeTools.length > 0) {
let toolsEl = $$('div').addClass('se-active-tools')
activeTools.forEach(tool => {
toolsEl.append(
$$(tool.Class, tool.toolProps).ref(tool.toolProps.name)
)
})
el.append(toolsEl)
}
return el
}
getSurface () {
const surfaceManager = this.context.surfaceManager
return surfaceManager.getSurface('body')
}
getClassNames () {
return 'sc-prose-editor-overlay-tools'
}
}
export default Overlay
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