Skip to content
Snippets Groups Projects
Commit 95e79954 authored by john's avatar john
Browse files

keep notes in read-only mode, but disable editing them

parent c459b3df
No related branches found
No related tags found
No related merge requests found
...@@ -90,7 +90,7 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -90,7 +90,7 @@ class ContainerEditor extends SubstanceContainerEditor {
const commandStates = this.getCommandStates() const commandStates = this.getCommandStates()
each(keys(commandStates), key => { each(keys(commandStates), key => {
const allowed = ['comment', 'save', 'undo', 'redo'] const allowed = ['comment', 'note', 'save', 'undo', 'redo']
if (!includes(allowed, key)) commandStates[key].disabled = true if (!includes(allowed, key)) commandStates[key].disabled = true
}) })
} }
......
...@@ -9,20 +9,29 @@ class EditNoteTool extends Tool { ...@@ -9,20 +9,29 @@ class EditNoteTool extends Tool {
const selected = this.getSelection() const selected = this.getSelection()
if (!selected.node) return el if (!selected.node) return el
const disabled = this.isEditorReadOnly()
// TODO -- on this.getLabel add a label to package and call it save note // TODO -- on this.getLabel add a label to package and call it save note
const icon = $$(Icon, { icon: 'fa-save' }) const icon = $$(Icon, { icon: 'fa-save' })
.addClass('sc-save-icon') .addClass('sc-save-icon')
const save = $$('div').addClass('sc-save-area').append(icon).on('click', this.saveNote)
el.append( const save = $$('div')
$$('div').addClass('sc-edit-note-tool-container').append( .addClass('sc-save-area')
.append(icon)
.on('click', this.saveNote)
const noteTool = $$('div')
.addClass('sc-edit-note-tool-container')
.append(
$$(PromptTextArea, { $$(PromptTextArea, {
disabled: disabled,
path: [selected.node.id, 'note-content'], path: [selected.node.id, 'note-content'],
placeholder: 'Type your note here' placeholder: 'Type your note here'
}), })
save
) )
) if (!disabled) noteTool.append(save)
el.append(noteTool)
// to properly adjust text area height depending on text // to properly adjust text area height depending on text
this.setTextAreaHeight() this.setTextAreaHeight()
...@@ -86,6 +95,16 @@ class EditNoteTool extends Tool { ...@@ -86,6 +95,16 @@ class EditNoteTool extends Tool {
} }
}) })
} }
getSurface () {
const surfaceManager = this.context.surfaceManager
return surfaceManager.getFocusedSurface()
}
isEditorReadOnly () {
const surface = this.getSurface()
return surface.isReadOnlyMode()
}
} }
EditNoteTool.type = 'edit-note' EditNoteTool.type = 'edit-note'
......
...@@ -4,20 +4,24 @@ import { Component } from 'substance' ...@@ -4,20 +4,24 @@ import { Component } from 'substance'
class TextArea extends Component { class TextArea extends Component {
render ($$) { render ($$) {
const { disabled, path, placeholder, rows } = this.props
const documentSession = this.context.documentSession const documentSession = this.context.documentSession
const doc = documentSession.getDocument() const doc = documentSession.getDocument()
const val = doc.get(this.props.path) const val = doc.get(path)
const el = $$('textarea') const el = $$('textarea')
.attr({ .attr({
rows: this.props.rows || '1',
// cols: this.props.columns || '40', // cols: this.props.columns || '40',
placeholder: this.props.placeholder || 'Type your text here' placeholder: placeholder || 'Type your text here',
rows: rows || '1'
}) })
.addClass('se-note-textarea') .addClass('se-note-textarea')
.append(val) .append(val)
.on('keyup', this.textAreaAdjust) .on('keyup', this.textAreaAdjust)
if (disabled) el.attr('disabled', 'true')
return el return el
} }
......
...@@ -56,5 +56,9 @@ $red: #591818; ...@@ -56,5 +56,9 @@ $red: #591818;
overflow: hidden; overflow: hidden;
resize: none; resize: none;
width: 310px; width: 310px;
&[disabled] {
border-right: 0;
}
} }
} }
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