1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* TinyMCE version 6.3.2 (2023-02-22)
*/
(function () {
'use strict';
const Cell = initial => {
let value = initial;
const get = () => {
return value;
};
const set = v => {
value = v;
};
return {
get,
set
};
};
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
const fireVisualBlocks = (editor, state) => {
editor.dispatch('VisualBlocks', { state });
};
const toggleVisualBlocks = (editor, pluginUrl, enabledState) => {
const dom = editor.dom;
dom.toggleClass(editor.getBody(), 'mce-visualblocks');
enabledState.set(!enabledState.get());
fireVisualBlocks(editor, enabledState.get());
};
const register$2 = (editor, pluginUrl, enabledState) => {
editor.addCommand('mceVisualBlocks', () => {
toggleVisualBlocks(editor, pluginUrl, enabledState);
});
};
const option = name => editor => editor.options.get(name);
const register$1 = editor => {
const registerOption = editor.options.register;
registerOption('visualblocks_default_state', {
processor: 'boolean',
default: false
});
};
const isEnabledByDefault = option('visualblocks_default_state');
const setup = (editor, pluginUrl, enabledState) => {
editor.on('PreviewFormats AfterPreviewFormats', e => {
if (enabledState.get()) {
editor.dom.toggleClass(editor.getBody(), 'mce-visualblocks', e.type === 'afterpreviewformats');
}
});
editor.on('init', () => {
if (isEnabledByDefault(editor)) {
toggleVisualBlocks(editor, pluginUrl, enabledState);
}
});
};
const toggleActiveState = (editor, enabledState) => api => {
api.setActive(enabledState.get());
const editorEventCallback = e => api.setActive(e.state);
editor.on('VisualBlocks', editorEventCallback);
return () => editor.off('VisualBlocks', editorEventCallback);
};
const register = (editor, enabledState) => {
const onAction = () => editor.execCommand('mceVisualBlocks');
editor.ui.registry.addToggleButton('visualblocks', {
icon: 'visualblocks',
tooltip: 'Show blocks',
onAction,
onSetup: toggleActiveState(editor, enabledState)
});
editor.ui.registry.addToggleMenuItem('visualblocks', {
text: 'Show blocks',
icon: 'visualblocks',
onAction,
onSetup: toggleActiveState(editor, enabledState)
});
};
var Plugin = () => {
global.add('visualblocks', (editor, pluginUrl) => {
register$1(editor);
const enabledState = Cell(false);
register$2(editor, pluginUrl, enabledState);
register(editor, enabledState);
setup(editor, pluginUrl, enabledState);
});
};
Plugin();
})();