Add copying of list-items
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7084cfad14
commit
936de7fd8b
5
editor/package-lock.json
generated
5
editor/package-lock.json
generated
|
@ -1374,6 +1374,11 @@
|
|||
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=",
|
||||
"dev": true
|
||||
},
|
||||
"copy-text-to-clipboard": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-2.2.0.tgz",
|
||||
"integrity": "sha512-WRvoIdnTs1rgPMkgA2pUOa/M4Enh2uzCwdKsOMYNAJiz/4ZvEJgmbF4OmninPmlFdAWisfeh0tH+Cpf7ni3RqQ=="
|
||||
},
|
||||
"core-js": {
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"axios": "^0.19.0",
|
||||
"bulma": "^0.7.5",
|
||||
"clipboard": "^2.0.6",
|
||||
"copy-text-to-clipboard": "^2.2.0",
|
||||
"css-loader": "^3.2.0",
|
||||
"extract-text-webpack-plugin": "^3.0.2",
|
||||
"file-loader": "^6.0.0",
|
||||
|
|
|
@ -1,41 +1,46 @@
|
|||
import $ from 'jquery'
|
||||
import 'jquery-contextmenu'
|
||||
import copy from 'copy-text-to-clipboard'
|
||||
|
||||
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 renderTree(tree)
|
||||
{
|
||||
if (!tree) return []
|
||||
return _.flatMapDeep(tree, (item) => [
|
||||
_.repeat(" ", item.indented) + item.text,
|
||||
renderTree(item.children),
|
||||
])
|
||||
}
|
||||
|
||||
function connectContextMenu(editor) {
|
||||
$.contextMenu({
|
||||
selector: '.marker',
|
||||
build: buildContextMenu(editor),
|
||||
items: {
|
||||
createNewPage: {
|
||||
name: 'Create page from item',
|
||||
callback: function (key, opt) {
|
||||
console.log('Create page from item', key, opt)
|
||||
},
|
||||
className: 'action-new-page'
|
||||
},
|
||||
copy: {
|
||||
name: 'Copy',
|
||||
callback: function (key, opt) {
|
||||
editor.copy(this, {recursive: true}).then(result => {
|
||||
copy(renderTree(result).join("\n"))
|
||||
})
|
||||
},
|
||||
className: 'action-copy'
|
||||
},
|
||||
copyLine: {
|
||||
name: 'Copy line',
|
||||
callback: function (key, opt) {
|
||||
editor.copy(this, {recursive: false}).then(result => {
|
||||
copy(result.text)
|
||||
})
|
||||
},
|
||||
className: 'action-copy-line'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user