1 |
efrain |
1 |
/**
|
|
|
2 |
* TinyMCE version 6.8.3 (2024-02-08)
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
5 |
(function () {
|
|
|
6 |
'use strict';
|
|
|
7 |
|
|
|
8 |
const Cell = initial => {
|
|
|
9 |
let value = initial;
|
|
|
10 |
const get = () => {
|
|
|
11 |
return value;
|
|
|
12 |
};
|
|
|
13 |
const set = v => {
|
|
|
14 |
value = v;
|
|
|
15 |
};
|
|
|
16 |
return {
|
|
|
17 |
get,
|
|
|
18 |
set
|
|
|
19 |
};
|
|
|
20 |
};
|
|
|
21 |
|
|
|
22 |
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
23 |
|
|
|
24 |
const fireVisualBlocks = (editor, state) => {
|
|
|
25 |
editor.dispatch('VisualBlocks', { state });
|
|
|
26 |
};
|
|
|
27 |
|
|
|
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());
|
|
|
33 |
};
|
|
|
34 |
|
|
|
35 |
const register$2 = (editor, pluginUrl, enabledState) => {
|
|
|
36 |
editor.addCommand('mceVisualBlocks', () => {
|
|
|
37 |
toggleVisualBlocks(editor, pluginUrl, enabledState);
|
|
|
38 |
});
|
|
|
39 |
};
|
|
|
40 |
|
|
|
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', {
|
|
|
45 |
processor: 'boolean',
|
|
|
46 |
default: false
|
|
|
47 |
});
|
|
|
48 |
};
|
|
|
49 |
const isEnabledByDefault = option('visualblocks_default_state');
|
|
|
50 |
|
|
|
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');
|
|
|
55 |
}
|
|
|
56 |
});
|
|
|
57 |
editor.on('init', () => {
|
|
|
58 |
if (isEnabledByDefault(editor)) {
|
|
|
59 |
toggleVisualBlocks(editor, pluginUrl, enabledState);
|
|
|
60 |
}
|
|
|
61 |
});
|
|
|
62 |
};
|
|
|
63 |
|
|
|
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);
|
|
|
69 |
};
|
|
|
70 |
const register = (editor, enabledState) => {
|
|
|
71 |
const onAction = () => editor.execCommand('mceVisualBlocks');
|
|
|
72 |
editor.ui.registry.addToggleButton('visualblocks', {
|
|
|
73 |
icon: 'visualblocks',
|
|
|
74 |
tooltip: 'Show blocks',
|
|
|
75 |
onAction,
|
|
|
76 |
onSetup: toggleActiveState(editor, enabledState)
|
|
|
77 |
});
|
|
|
78 |
editor.ui.registry.addToggleMenuItem('visualblocks', {
|
|
|
79 |
text: 'Show blocks',
|
|
|
80 |
icon: 'visualblocks',
|
|
|
81 |
onAction,
|
|
|
82 |
onSetup: toggleActiveState(editor, enabledState)
|
|
|
83 |
});
|
|
|
84 |
};
|
|
|
85 |
|
|
|
86 |
var Plugin = () => {
|
|
|
87 |
global.add('visualblocks', (editor, pluginUrl) => {
|
|
|
88 |
register$1(editor);
|
|
|
89 |
const enabledState = Cell(false);
|
|
|
90 |
register$2(editor, pluginUrl, enabledState);
|
|
|
91 |
register(editor, enabledState);
|
|
|
92 |
setup(editor, pluginUrl, enabledState);
|
|
|
93 |
});
|
|
|
94 |
};
|
|
|
95 |
|
|
|
96 |
Plugin();
|
|
|
97 |
|
|
|
98 |
})();
|