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

Merged in notes-read-only (pull request #8)

fix: disable notes from toolbar in read only mode
parents 3789fe67 e5e33651
No related branches found
No related tags found
No related merge requests found
...@@ -48,10 +48,12 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -48,10 +48,12 @@ class ContainerEditor extends SubstanceContainerEditor {
} }
didMount () { didMount () {
// TODO -- replace with super
Surface.prototype.didMount.apply(this, arguments) Surface.prototype.didMount.apply(this, arguments)
this.container.on('nodes:changed', this.onContainerChange, this) this.container.on('nodes:changed', this.onContainerChange, this)
if (this.isEmpty()) this.createText()
if (this.isEmpty()) this.createText()
if (this.isReadOnlyMode()) this.addTargetToLinks() if (this.isReadOnlyMode()) this.addTargetToLinks()
} }
......
import { isUndefined } from 'lodash'
import { AnnotationTool } from 'substance' import { AnnotationTool } from 'substance'
class NoteTool extends AnnotationTool {} class NoteTool extends AnnotationTool {
renderButton ($$) {
const el = super.renderButton($$)
const readOnly = this.isSurfaceReadOnly()
if (!isUndefined(readOnly)) el.attr('disabled', 'true')
return el
}
getSurface () {
const surfaceManager = this.context.surfaceManager
const containerId = this.context.controller.props.containerId
return surfaceManager.getSurface(containerId)
}
isSurfaceReadOnly () {
const surface = this.getSurface()
if (!surface) return
return surface.isReadOnlyMode()
}
}
NoteTool.type = 'note' NoteTool.type = 'note'
......
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