mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
add doublick handler for MarkdownPreview to turn off preview mode
This commit is contained in:
@@ -44,18 +44,23 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDoubleClick (e) {
|
||||||
|
this.props.onDoubleClick(e)
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let isEmpty = this.props.content.trim().length === 0
|
let isEmpty = this.props.content.trim().length === 0
|
||||||
let content = isEmpty
|
let content = isEmpty
|
||||||
? '(Empty content)'
|
? '(Empty content)'
|
||||||
: this.props.content
|
: this.props.content
|
||||||
return (
|
return (
|
||||||
<div className={'MarkdownPreview' + (this.props.className != null ? ' ' + this.props.className : '') + (isEmpty ? ' empty' : '')} dangerouslySetInnerHTML={{__html: ' ' + markdown(content)}}/>
|
<div onDoubleClick={e => this.handleDoubleClick(e)} className={'MarkdownPreview' + (this.props.className != null ? ' ' + this.props.className : '') + (isEmpty ? ' empty' : '')} dangerouslySetInnerHTML={{__html: ' ' + markdown(content)}}/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkdownPreview.propTypes = {
|
MarkdownPreview.propTypes = {
|
||||||
|
onDoubleClick: PropTypes.func,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
content: PropTypes.string
|
content: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,6 +264,12 @@ export default class ArticleDetail extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePreviewButtonDoubleClick (e) {
|
||||||
|
this.setState({
|
||||||
|
previewMode: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { folders, status, tags, activeArticle, modified, user } = this.props
|
let { folders, status, tags, activeArticle, modified, user } = this.props
|
||||||
if (activeArticle == null) return this.renderEmpty()
|
if (activeArticle == null) return this.renderEmpty()
|
||||||
@@ -354,7 +360,7 @@ export default class ArticleDetail extends React.Component {
|
|||||||
{status.isTutorialOpen ? modeSelectTutorialElement : null}
|
{status.isTutorialOpen ? modeSelectTutorialElement : null}
|
||||||
|
|
||||||
{this.state.previewMode
|
{this.state.previewMode
|
||||||
? <MarkdownPreview ref='preview' content={this.state.article.content}/>
|
? <MarkdownPreview ref='preview' onDoubleClick={e => this.handlePreviewButtonDoubleClick(e)} content={this.state.article.content}/>
|
||||||
: (<CodeEditor
|
: (<CodeEditor
|
||||||
ref='code'
|
ref='code'
|
||||||
onChange={(e, value) => this.handleContentChange(e, value)}
|
onChange={(e, value) => this.handleContentChange(e, value)}
|
||||||
|
|||||||
Reference in New Issue
Block a user