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:
Dan Brown 2022-10-15 15:47:34 +01:00
parent 6adc642d2f
commit 0269f5122e
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 18 additions and 0 deletions

View File

@ -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);
});

View File

@ -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',