2 * TinyMCE version 6.6.2 (2023-08-09)
8 const Cell = initial => {
22 var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
24 const fireVisualBlocks = (editor, state) => {
25 editor.dispatch('VisualBlocks', { state });
28 const toggleVisualBlocks = (editor, pluginUrl, enabledState) => {
29 const dom = editor.dom;
30 dom.toggleClass(editor.getBody(), 'mce-visualblocks');
31 enabledState.set(!enabledState.get());
32 fireVisualBlocks(editor, enabledState.get());
35 const register$2 = (editor, pluginUrl, enabledState) => {
36 editor.addCommand('mceVisualBlocks', () => {
37 toggleVisualBlocks(editor, pluginUrl, enabledState);
41 const option = name => editor => editor.options.get(name);
42 const register$1 = editor => {
43 const registerOption = editor.options.register;
44 registerOption('visualblocks_default_state', {
49 const isEnabledByDefault = option('visualblocks_default_state');
51 const setup = (editor, pluginUrl, enabledState) => {
52 editor.on('PreviewFormats AfterPreviewFormats', e => {
53 if (enabledState.get()) {
54 editor.dom.toggleClass(editor.getBody(), 'mce-visualblocks', e.type === 'afterpreviewformats');
57 editor.on('init', () => {
58 if (isEnabledByDefault(editor)) {
59 toggleVisualBlocks(editor, pluginUrl, enabledState);
64 const toggleActiveState = (editor, enabledState) => api => {
65 api.setActive(enabledState.get());
66 const editorEventCallback = e => api.setActive(e.state);
67 editor.on('VisualBlocks', editorEventCallback);
68 return () => editor.off('VisualBlocks', editorEventCallback);
70 const register = (editor, enabledState) => {
71 const onAction = () => editor.execCommand('mceVisualBlocks');
72 editor.ui.registry.addToggleButton('visualblocks', {
74 tooltip: 'Show blocks',
76 onSetup: toggleActiveState(editor, enabledState)
78 editor.ui.registry.addToggleMenuItem('visualblocks', {
82 onSetup: toggleActiveState(editor, enabledState)
87 global.add('visualblocks', (editor, pluginUrl) => {
89 const enabledState = Cell(false);
90 register$2(editor, pluginUrl, enabledState);
91 register(editor, enabledState);
92 setup(editor, pluginUrl, enabledState);