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

disable editor's context menu when switch preview is using right click

This commit is contained in:
Baptiste Augrain
2018-11-25 17:09:54 +01:00
parent a6eddb5798
commit d95d282f39
3 changed files with 14 additions and 6 deletions

View File

@@ -65,12 +65,16 @@ export default class CodeEditor extends React.Component {
this.scrollToLineHandeler = this.scrollToLine.bind(this) this.scrollToLineHandeler = this.scrollToLine.bind(this)
this.formatTable = () => this.handleFormatTable() this.formatTable = () => this.handleFormatTable()
if (props.switchPreview !== 'RIGHTCLICK') {
this.contextMenuHandler = function (editor, event) { this.contextMenuHandler = function (editor, event) {
const menu = buildEditorContextMenu(editor, event) const menu = buildEditorContextMenu(editor, event)
if (menu != null) { if (menu != null) {
setTimeout(() => menu.popup(remote.getCurrentWindow()), 30) setTimeout(() => menu.popup(remote.getCurrentWindow()), 30)
} }
} }
}
this.editorActivityHandler = () => this.handleEditorActivity() this.editorActivityHandler = () => this.handleEditorActivity()
this.turndownService = new TurndownService() this.turndownService = new TurndownService()
@@ -137,7 +141,7 @@ export default class CodeEditor extends React.Component {
} }
componentDidMount () { componentDidMount () {
const { rulers, enableRulers } = this.props const { rulers, enableRulers, switchPreview } = this.props
const expandSnippet = this.expandSnippet.bind(this) const expandSnippet = this.expandSnippet.bind(this)
eventEmitter.on('line:jump', this.scrollToLineHandeler) eventEmitter.on('line:jump', this.scrollToLineHandeler)
@@ -241,7 +245,9 @@ export default class CodeEditor extends React.Component {
this.editor.on('blur', this.blurHandler) this.editor.on('blur', this.blurHandler)
this.editor.on('change', this.changeHandler) this.editor.on('change', this.changeHandler)
this.editor.on('paste', this.pasteHandler) this.editor.on('paste', this.pasteHandler)
if (switchPreview !== 'RIGHTCLICK') {
this.editor.on('contextmenu', this.contextMenuHandler) this.editor.on('contextmenu', this.contextMenuHandler)
}
eventEmitter.on('top:search', this.searchHandler) eventEmitter.on('top:search', this.searchHandler)
eventEmitter.emit('code:init') eventEmitter.emit('code:init')

View File

@@ -278,6 +278,7 @@ class MarkdownEditor extends React.Component {
onChange={(e) => this.handleChange(e)} onChange={(e) => this.handleChange(e)}
onBlur={(e) => this.handleBlur(e)} onBlur={(e) => this.handleBlur(e)}
spellCheck={config.editor.spellcheck} spellCheck={config.editor.spellcheck}
switchPreview={config.editor.switchPreview}
/> />
<MarkdownPreview styleName={this.state.status === 'PREVIEW' <MarkdownPreview styleName={this.state.status === 'PREVIEW'
? 'preview' ? 'preview'

View File

@@ -172,6 +172,7 @@ class MarkdownSplitEditor extends React.Component {
onChange={this.handleOnChange.bind(this)} onChange={this.handleOnChange.bind(this)}
onScroll={this.handleScroll.bind(this)} onScroll={this.handleScroll.bind(this)}
spellCheck={config.editor.spellcheck} spellCheck={config.editor.spellcheck}
switchPreview={config.editor.switchPreview}
/> />
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} > <div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
<div styleName='slider-hitbox' /> <div styleName='slider-hitbox' />