@@ -2,6 +2,7 @@ import {register as registerShortcuts} from "./shortcuts";
2
2
import { listen as listenForCommonEvents } from "./common-events" ;
3
3
import { scrollToQueryString } from "./scrolling" ;
4
4
import { listenForDragAndPaste } from "./drop-paste-handling" ;
5
+ import { getPrimaryToolbar , registerAdditionalToolbars } from "./toolbars" ;
5
6
6
7
import { getPlugin as getCodeeditorPlugin } from "./plugin-codeeditor" ;
7
8
import { getPlugin as getDrawioPlugin } from "./plugin-drawio" ;
@@ -58,48 +59,6 @@ function file_picker_callback(callback, value, meta) {
58
59
59
60
}
60
61
61
- /**
62
- * @param {WysiwygConfigOptions } options
63
- * @return {{toolbar: string, groupButtons: Object<string, Object>} }
64
- */
65
- function buildToolbar ( options ) {
66
- const textDirPlugins = options . textDirection === 'rtl' ? 'ltr rtl' : '' ;
67
-
68
- const groupButtons = {
69
- formatoverflow : {
70
- icon : 'more-drawer' ,
71
- tooltip : 'More' ,
72
- items : 'strikethrough superscript subscript inlinecode removeformat'
73
- } ,
74
- listoverflow : {
75
- icon : 'more-drawer' ,
76
- tooltip : 'More' ,
77
- items : 'outdent indent'
78
- } ,
79
- insertoverflow : {
80
- icon : 'more-drawer' ,
81
- tooltip : 'More' ,
82
- items : 'hr codeeditor drawio media details'
83
- }
84
- } ;
85
-
86
- const toolbar = [
87
- 'undo redo' ,
88
- 'styleselect' ,
89
- 'bold italic underline forecolor backcolor formatoverflow' ,
90
- 'alignleft aligncenter alignright alignjustify' ,
91
- 'bullist numlist listoverflow' ,
92
- textDirPlugins ,
93
- 'link table imagemanager-insert insertoverflow' ,
94
- 'code about fullscreen'
95
- ] ;
96
-
97
- return {
98
- toolbar : toolbar . filter ( row => Boolean ( row ) ) . join ( ' | ' ) ,
99
- groupButtons,
100
- } ;
101
- }
102
-
103
62
/**
104
63
* @param {WysiwygConfigOptions } options
105
64
* @return {string }
@@ -218,8 +177,6 @@ export function build(options) {
218
177
219
178
// Set language
220
179
window . tinymce . addI18n ( options . language , options . translationMap ) ;
221
- // Build toolbar content
222
- const { toolbar, groupButtons : toolBarGroupButtons } = buildToolbar ( options ) ;
223
180
224
181
// BookStack Version
225
182
const version = document . querySelector ( 'script[src*="/dist/app.js"]' ) . getAttribute ( 'src' ) . split ( '?version=' ) [ 1 ] ;
@@ -261,7 +218,7 @@ export function build(options) {
261
218
plugins : gatherPlugins ( options ) ,
262
219
imagetools_toolbar : 'imageoptions' ,
263
220
contextmenu : false ,
264
- toolbar : toolbar ,
221
+ toolbar : getPrimaryToolbar ( options ) ,
265
222
content_style : getContentStyle ( options ) ,
266
223
style_formats,
267
224
style_formats_merge : false ,
@@ -281,9 +238,7 @@ export function build(options) {
281
238
head . innerHTML += fetchCustomHeadContent ( ) ;
282
239
} ,
283
240
setup ( editor ) {
284
- for ( const [ key , config ] of Object . entries ( toolBarGroupButtons ) ) {
285
- editor . ui . registry . addGroupToolbarButton ( key , config ) ;
286
- }
241
+ registerAdditionalToolbars ( editor , options ) ;
287
242
getSetupCallback ( options ) ( editor ) ;
288
243
} ,
289
244
} ;
0 commit comments