Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit d95d282

Browse files
committed
disable editor's context menu when switch preview is using right click
1 parent a6eddb5 commit d95d282

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

browser/components/CodeEditor.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ export default class CodeEditor extends React.Component {
6565
this.scrollToLineHandeler = this.scrollToLine.bind(this)
6666

6767
this.formatTable = () => this.handleFormatTable()
68-
this.contextMenuHandler = function (editor, event) {
69-
const menu = buildEditorContextMenu(editor, event)
70-
if (menu != null) {
71-
setTimeout(() => menu.popup(remote.getCurrentWindow()), 30)
68+
69+
if (props.switchPreview !== 'RIGHTCLICK') {
70+
this.contextMenuHandler = function (editor, event) {
71+
const menu = buildEditorContextMenu(editor, event)
72+
if (menu != null) {
73+
setTimeout(() => menu.popup(remote.getCurrentWindow()), 30)
74+
}
7275
}
7376
}
77+
7478
this.editorActivityHandler = () => this.handleEditorActivity()
7579

7680
this.turndownService = new TurndownService()
@@ -137,7 +141,7 @@ export default class CodeEditor extends React.Component {
137141
}
138142

139143
componentDidMount () {
140-
const { rulers, enableRulers } = this.props
144+
const { rulers, enableRulers, switchPreview } = this.props
141145
const expandSnippet = this.expandSnippet.bind(this)
142146
eventEmitter.on('line:jump', this.scrollToLineHandeler)
143147

@@ -241,7 +245,9 @@ export default class CodeEditor extends React.Component {
241245
this.editor.on('blur', this.blurHandler)
242246
this.editor.on('change', this.changeHandler)
243247
this.editor.on('paste', this.pasteHandler)
244-
this.editor.on('contextmenu', this.contextMenuHandler)
248+
if (switchPreview !== 'RIGHTCLICK') {
249+
this.editor.on('contextmenu', this.contextMenuHandler)
250+
}
245251
eventEmitter.on('top:search', this.searchHandler)
246252

247253
eventEmitter.emit('code:init')

browser/components/MarkdownEditor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class MarkdownEditor extends React.Component {
278278
onChange={(e) => this.handleChange(e)}
279279
onBlur={(e) => this.handleBlur(e)}
280280
spellCheck={config.editor.spellcheck}
281+
switchPreview={config.editor.switchPreview}
281282
/>
282283
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
283284
? 'preview'

browser/components/MarkdownSplitEditor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class MarkdownSplitEditor extends React.Component {
172172
onChange={this.handleOnChange.bind(this)}
173173
onScroll={this.handleScroll.bind(this)}
174174
spellCheck={config.editor.spellcheck}
175+
switchPreview={config.editor.switchPreview}
175176
/>
176177
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
177178
<div styleName='slider-hitbox' />

0 commit comments

Comments
 (0)