mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-10 13:43:38 +08:00
Added wysiwyg code block edit tooltip
For easier editing access on mobile devices where previous doubleclick does not work so well. For #2815
This commit is contained in:
@ -153,6 +153,14 @@ function register(editor, url) {
|
||||
}
|
||||
});
|
||||
|
||||
editor.ui.registry.addButton('editcodeeditor', {
|
||||
tooltip: 'Edit code block',
|
||||
icon: 'edit-block',
|
||||
onAction() {
|
||||
editor.execCommand('codeeditor');
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand('codeeditor', () => {
|
||||
const selectedNode = editor.selection.getNode();
|
||||
const doc = selectedNode.ownerDocument;
|
||||
@ -208,6 +216,15 @@ function register(editor, url) {
|
||||
});
|
||||
});
|
||||
|
||||
editor.ui.registry.addContextToolbar('codeeditor', {
|
||||
predicate: function (node) {
|
||||
return node.nodeName.toLowerCase() === 'code-block';
|
||||
},
|
||||
items: 'editcodeeditor',
|
||||
position: 'node',
|
||||
scope: 'node'
|
||||
});
|
||||
|
||||
editor.on('PreInit', () => {
|
||||
defineCodeBlockCustomElement(editor);
|
||||
});
|
||||
|
Reference in New Issue
Block a user