Improve context menu
This commit is contained in:
parent
0ab065bf72
commit
1a06f0cb43
|
@ -9,7 +9,6 @@ import search from './search';
|
|||
import createPageSearch from './fuse';
|
||||
import util from './util';
|
||||
import Mustache from 'mustache';
|
||||
import 'jquery-contextmenu';
|
||||
import getCaretCoordinates from './caret-position'
|
||||
import moment from 'moment'
|
||||
import mermaid from 'mermaid'
|
||||
|
@ -22,7 +21,7 @@ import 'prismjs/components/prism-perl'
|
|||
import 'prismjs/components/prism-css'
|
||||
import 'prismjs/components/prism-markup-templating'
|
||||
import 'prismjs/components/prism-jq'
|
||||
|
||||
import menu from './menu.js'
|
||||
import './styles.scss'
|
||||
|
||||
moment.locale('nl')
|
||||
|
@ -450,19 +449,8 @@ if (holder) {
|
|||
renderGraphs();
|
||||
})
|
||||
})
|
||||
$.contextMenu({
|
||||
selector: '.marker',
|
||||
items: {
|
||||
copy: {
|
||||
name: 'Copy',
|
||||
callback: function (key, opt) {
|
||||
editor.copy(this).then(result => {
|
||||
console.log(result)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
menu.connectContextMenu(editor)
|
||||
}
|
||||
|
||||
let timeout = null;
|
||||
|
|
44
editor/src/menu.js
Normal file
44
editor/src/menu.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import $ from 'jquery'
|
||||
import 'jquery-contextmenu'
|
||||
|
||||
function buildContextMenu(editor, store) {
|
||||
return function (triggeringElement, event) {
|
||||
return {
|
||||
items: {
|
||||
createNewPage: {
|
||||
name: 'Create page from item',
|
||||
callback: function (key, opt) {
|
||||
console.log('Create page from item', key, opt)
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
name: 'Copy',
|
||||
callback: function (key, opt) {
|
||||
editor.copy(this, {recursive: true}).then(result => {
|
||||
console.log(result)
|
||||
})
|
||||
}
|
||||
},
|
||||
copyLine: {
|
||||
name: 'Copy line',
|
||||
callback: function (key, opt) {
|
||||
editor.copy(this, {recursive: false}).then(result => {
|
||||
console.log(result)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function connectContextMenu(editor) {
|
||||
$.contextMenu({
|
||||
selector: '.marker',
|
||||
build: buildContextMenu(editor),
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
connectContextMenu: connectContextMenu
|
||||
}
|
Loading…
Reference in New Issue
Block a user