mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04: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:
parent
6adc642d2f
commit
0269f5122e
@ -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);
|
||||
});
|
||||
|
@ -66,6 +66,7 @@ return [
|
||||
'insert_link_title' => 'Insert/Edit Link',
|
||||
'insert_horizontal_line' => 'Insert horizontal line',
|
||||
'insert_code_block' => 'Insert code block',
|
||||
'edit_code_block' => 'Edit code block',
|
||||
'insert_drawing' => 'Insert/edit drawing',
|
||||
'drawing_manager' => 'Drawing manager',
|
||||
'insert_media' => 'Insert/edit media',
|
||||
|
Loading…
Reference in New Issue
Block a user