2022-02-28 08:54:33 -05:00
|
|
|
/**
|
|
|
|
* @param {WysiwygConfigOptions} options
|
|
|
|
* @return {String}
|
|
|
|
*/
|
|
|
|
export function getPrimaryToolbar(options) {
|
|
|
|
const textDirPlugins = options.textDirection === 'rtl' ? 'ltr rtl' : '';
|
|
|
|
|
|
|
|
const toolbar = [
|
|
|
|
'undo redo',
|
2022-07-17 13:33:03 -04:00
|
|
|
'styles',
|
2022-02-28 08:54:33 -05:00
|
|
|
'bold italic underline forecolor backcolor formatoverflow',
|
|
|
|
'alignleft aligncenter alignright alignjustify',
|
2022-03-22 10:03:20 -04:00
|
|
|
'bullist numlist listoverflow',
|
2022-02-28 08:54:33 -05:00
|
|
|
textDirPlugins,
|
|
|
|
'link table imagemanager-insert insertoverflow',
|
2023-04-18 17:20:02 -04:00
|
|
|
'code about fullscreen',
|
2022-02-28 08:54:33 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
return toolbar.filter(row => Boolean(row)).join(' | ');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
|
|
|
function registerPrimaryToolbarGroups(editor) {
|
|
|
|
editor.ui.registry.addGroupToolbarButton('formatoverflow', {
|
|
|
|
icon: 'more-drawer',
|
|
|
|
tooltip: 'More',
|
2023-04-18 17:20:02 -04:00
|
|
|
items: 'strikethrough superscript subscript inlinecode removeformat',
|
2022-02-28 08:54:33 -05:00
|
|
|
});
|
|
|
|
editor.ui.registry.addGroupToolbarButton('listoverflow', {
|
|
|
|
icon: 'more-drawer',
|
|
|
|
tooltip: 'More',
|
2023-04-18 17:20:02 -04:00
|
|
|
items: 'tasklist outdent indent',
|
2022-02-28 08:54:33 -05:00
|
|
|
});
|
|
|
|
editor.ui.registry.addGroupToolbarButton('insertoverflow', {
|
|
|
|
icon: 'more-drawer',
|
|
|
|
tooltip: 'More',
|
2023-04-18 17:20:02 -04:00
|
|
|
items: 'customhr codeeditor drawio media details',
|
2022-02-28 08:54:33 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
|
|
|
function registerLinkContextToolbar(editor) {
|
|
|
|
editor.ui.registry.addContextToolbar('linkcontexttoolbar', {
|
|
|
|
predicate(node) {
|
|
|
|
return node.closest('a') !== null;
|
|
|
|
},
|
|
|
|
position: 'node',
|
|
|
|
scope: 'node',
|
2023-04-18 17:20:02 -04:00
|
|
|
items: 'link unlink openlink',
|
2022-02-28 08:54:33 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-18 08:37:50 -04:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
|
|
|
function registerImageContextToolbar(editor) {
|
|
|
|
editor.ui.registry.addContextToolbar('imagecontexttoolbar', {
|
|
|
|
predicate(node) {
|
|
|
|
return node.closest('img') !== null;
|
|
|
|
},
|
|
|
|
position: 'node',
|
|
|
|
scope: 'node',
|
2023-04-18 17:20:02 -04:00
|
|
|
items: 'image',
|
2022-07-18 08:37:50 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-28 08:54:33 -05:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
2023-04-19 05:46:13 -04:00
|
|
|
export function registerAdditionalToolbars(editor) {
|
2022-02-28 08:54:33 -05:00
|
|
|
registerPrimaryToolbarGroups(editor);
|
|
|
|
registerLinkContextToolbar(editor);
|
2022-07-18 08:37:50 -04:00
|
|
|
registerImageContextToolbar(editor);
|
2023-04-18 17:20:02 -04:00
|
|
|
}
|