1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Enable to show the lock icon only the Editor state is CODE

This commit is contained in:
asmsuechan
2017-02-11 17:52:11 +09:00
parent 74ee6ae6ce
commit 672d409bf2
2 changed files with 18 additions and 6 deletions

View File

@@ -26,15 +26,22 @@ class MarkdownNoteDetail extends React.Component {
title: '',
content: ''
}, props.note),
isCODE: false,
locked: false
}
this.dispatchTimer = null
this.showLockButton = () => this.handleShowLockButton()
}
focus () {
this.refs.content.focus()
}
componentDidMount () {
ee.on('topbar:lock', this.showLockButton)
}
componentWillReceiveProps (nextProps) {
if (nextProps.note.key !== this.props.note.key && !this.isMovingNote) {
if (this.saveQueue != null) this.saveNow()
@@ -51,6 +58,10 @@ class MarkdownNoteDetail extends React.Component {
if (this.saveQueue != null) this.saveNow()
}
componentDidUnmount () {
ee.off('topbar:lock', this.showLockButton)
}
findTitle (value) {
let splitted = value.split('\n')
let title = null
@@ -215,6 +226,10 @@ class MarkdownNoteDetail extends React.Component {
if (e.keyCode === 27) this.handleDeleteCancelButtonClick(e)
}
handleShowLockButton () {
this.setState({isCODE: !this.state.isCODE})
}
render () {
let { data, config } = this.props
let { note } = this.state
@@ -247,10 +262,8 @@ class MarkdownNoteDetail extends React.Component {
</div>
<div styleName='info-right'>
{(() => {
// TODO: get a state of MarkdownEditor somehow
const editorStatus='CODE'
let faClassName=`fa ${this.toggleLockButton()}`
if (editorStatus === 'CODE') {
if (this.state.isCODE) {
return(
<button styleName='info-right-button'
onClick={(e) => this.handleLockButtonClick(e)}