]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/toolbars.js
Added ability to escape role "External Auth ID" commas
[bookstack] / resources / js / wysiwyg / toolbars.js
1 /**
2  * @param {WysiwygConfigOptions} options
3  * @return {String}
4  */
5 export function getPrimaryToolbar(options) {
6     const textDirPlugins = options.textDirection === 'rtl' ? 'ltr rtl' : '';
7
8     const toolbar = [
9         'undo redo',
10         'styleselect',
11         'bold italic underline forecolor backcolor formatoverflow',
12         'alignleft aligncenter alignright alignjustify',
13         'bullist numlist listoverflow',
14         textDirPlugins,
15         'link table imagemanager-insert insertoverflow',
16         'code about fullscreen'
17     ];
18
19     return toolbar.filter(row => Boolean(row)).join(' | ');
20 }
21
22 /**
23  * @param {Editor} editor
24  */
25 function registerPrimaryToolbarGroups(editor) {
26     editor.ui.registry.addGroupToolbarButton('formatoverflow', {
27         icon: 'more-drawer',
28         tooltip: 'More',
29         items: 'strikethrough superscript subscript inlinecode removeformat'
30     });
31     editor.ui.registry.addGroupToolbarButton('listoverflow', {
32         icon: 'more-drawer',
33         tooltip: 'More',
34         items: 'tasklist outdent indent'
35     });
36     editor.ui.registry.addGroupToolbarButton('insertoverflow', {
37         icon: 'more-drawer',
38         tooltip: 'More',
39         items: 'hr codeeditor drawio media details'
40     });
41 }
42
43 /**
44  * @param {Editor} editor
45  */
46 function registerLinkContextToolbar(editor) {
47     editor.ui.registry.addContextToolbar('linkcontexttoolbar', {
48         predicate(node) {
49             return node.closest('a') !== null;
50         },
51         position: 'node',
52         scope: 'node',
53         items: 'link unlink openlink'
54     });
55 }
56
57 /**
58  * @param {Editor} editor
59  * @param {WysiwygConfigOptions} options
60  */
61 export function registerAdditionalToolbars(editor, options) {
62     registerPrimaryToolbarGroups(editor);
63     registerLinkContextToolbar(editor);
64 }