Skip to content

Commit

Permalink
Merge pull request #2643 from daiyam/fix-contextmenu
Browse files Browse the repository at this point in the history
fix editor's context menu
  • Loading branch information
Rokt33r authored Dec 12, 2018
2 parents d70d3b4 + d95d282 commit e706ec0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ export default class CodeEditor extends React.Component {
this.scrollToLineHandeler = this.scrollToLine.bind(this)

this.formatTable = () => this.handleFormatTable()
this.contextMenuHandler = function (editor, event) {
const menu = buildEditorContextMenu(editor, event)
if (menu != null) {
setTimeout(() => menu.popup(remote.getCurrentWindow()), 30)

if (props.switchPreview !== 'RIGHTCLICK') {
this.contextMenuHandler = function (editor, event) {
const menu = buildEditorContextMenu(editor, event)
if (menu != null) {
setTimeout(() => menu.popup(remote.getCurrentWindow()), 30)
}
}
}

this.editorActivityHandler = () => this.handleEditorActivity()

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

componentDidMount () {
const { rulers, enableRulers } = this.props
const { rulers, enableRulers, switchPreview } = this.props
const expandSnippet = this.expandSnippet.bind(this)
eventEmitter.on('line:jump', this.scrollToLineHandeler)

Expand Down Expand Up @@ -241,7 +245,9 @@ export default class CodeEditor extends React.Component {
this.editor.on('blur', this.blurHandler)
this.editor.on('change', this.changeHandler)
this.editor.on('paste', this.pasteHandler)
this.editor.on('contextmenu', this.contextMenuHandler)
if (switchPreview !== 'RIGHTCLICK') {
this.editor.on('contextmenu', this.contextMenuHandler)
}
eventEmitter.on('top:search', this.searchHandler)

eventEmitter.emit('code:init')
Expand Down
1 change: 1 addition & 0 deletions browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class MarkdownEditor extends React.Component {
onChange={(e) => this.handleChange(e)}
onBlur={(e) => this.handleBlur(e)}
spellCheck={config.editor.spellcheck}
switchPreview={config.editor.switchPreview}
/>
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
? 'preview'
Expand Down
1 change: 1 addition & 0 deletions browser/components/MarkdownSplitEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class MarkdownSplitEditor extends React.Component {
onChange={this.handleOnChange.bind(this)}
onScroll={this.handleScroll.bind(this)}
spellCheck={config.editor.spellcheck}
switchPreview={config.editor.switchPreview}
/>
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
<div styleName='slider-hitbox' />
Expand Down

0 comments on commit e706ec0

Please sign in to comment.