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

fix read only mode glitches

parent 5e93bbbc
No related branches found
No related tags found
No related merge requests found
...@@ -185,14 +185,19 @@ class Editor extends ProseEditor { ...@@ -185,14 +185,19 @@ class Editor extends ProseEditor {
_renderToolbarLeft ($$) { _renderToolbarLeft ($$) {
let commandStates = this.commandManager.getCommandStates() let commandStates = this.commandManager.getCommandStates()
return $$('div').addClass('se-toolbar-wrapper').append(
$$(Toolbar, { return $$('div')
commandStates: commandStates, .addClass('se-toolbar-wrapper')
trackChanges: this.props.trackChanges, .append(
trackChangesView: this.state.trackChangesView, $$(Toolbar, {
toolGroups: ['text'] commandStates: commandStates,
}).ref('toolbarLeft') trackChanges: this.props.trackChanges,
) trackChangesView: this.state.trackChangesView,
toolGroups: ['text']
}
)
.ref('toolbarLeft')
)
} }
_renderEditor ($$) { _renderEditor ($$) {
......
...@@ -34,8 +34,10 @@ class LeftSwitchTextTypeTool extends Tool { ...@@ -34,8 +34,10 @@ class LeftSwitchTextTypeTool extends Tool {
el.append(item) el.append(item)
}.bind(this)) }.bind(this))
if (this.props.currentTextType && if ((this.props.currentTextType &&
this.props.currentTextType.name === 'container-selection') { this.props.currentTextType.name === 'container-selection') ||
this.isReadOnlyMode()
) {
el.addClass('sm-disabled') el.addClass('sm-disabled')
} }
...@@ -50,9 +52,21 @@ class LeftSwitchTextTypeTool extends Tool { ...@@ -50,9 +52,21 @@ class LeftSwitchTextTypeTool extends Tool {
handleClick (e) { handleClick (e) {
e.preventDefault() e.preventDefault()
if (this.isReadOnlyMode()) return
this.executeCommand(e.currentTarget.dataset.type) this.executeCommand(e.currentTarget.dataset.type)
} }
getSurface () {
return this.context.surfaceManager.getSurface('body')
}
// TODO -- review how the side toolbar gets disabled
isReadOnlyMode () {
const surface = this.getSurface()
if (!surface) return true // HACK
return surface.isReadOnlyMode()
}
} }
LeftSwitchTextTypeTool.command = 'switch-text-type' LeftSwitchTextTypeTool.command = 'switch-text-type'
......
...@@ -4,9 +4,8 @@ class NoteTool extends AnnotationTool { ...@@ -4,9 +4,8 @@ class NoteTool extends AnnotationTool {
renderButton ($$) { renderButton ($$) {
const el = super.renderButton($$) const el = super.renderButton($$)
// TODO -- either delete or re-introduce const readOnly = this.isSurfaceReadOnly()
// const readOnly = this.isSurfaceReadOnly() if (readOnly === true) el.attr('disabled', 'true')
// if (readOnly === true) el.attr('disabled', 'true')
return el return el
} }
......
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