feat: tinymce
This commit is contained in:
7
static/tinymce/plugins/visualblocks/index.js
Normal file
7
static/tinymce/plugins/visualblocks/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
// Exports the "visualblocks" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/visualblocks')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/visualblocks'
|
||||
require('./plugin.js');
|
||||
100
static/tinymce/plugins/visualblocks/plugin.js
Normal file
100
static/tinymce/plugins/visualblocks/plugin.js
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
* TinyMCE version 7.7.2 (2025-03-19)
|
||||
*/
|
||||
|
||||
(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),
|
||||
context: 'any'
|
||||
});
|
||||
editor.ui.registry.addToggleMenuItem('visualblocks', {
|
||||
text: 'Show blocks',
|
||||
icon: 'visualblocks',
|
||||
onAction,
|
||||
onSetup: toggleActiveState(editor, enabledState),
|
||||
context: 'any'
|
||||
});
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
})();
|
||||
4
static/tinymce/plugins/visualblocks/plugin.min.js
vendored
Normal file
4
static/tinymce/plugins/visualblocks/plugin.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* TinyMCE version 7.7.2 (2025-03-19)
|
||||
*/
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const o=(t,o,e)=>{t.dom.toggleClass(t.getBody(),"mce-visualblocks"),e.set(!e.get()),((t,o)=>{t.dispatch("VisualBlocks",{state:o})})(t,e.get())},e=t=>t.options.get("visualblocks_default_state");const s=(t,o)=>e=>{e.setActive(o.get());const s=t=>e.setActive(t.state);return t.on("VisualBlocks",s),()=>t.off("VisualBlocks",s)};t.add("visualblocks",((t,l)=>{(t=>{(0,t.options.register)("visualblocks_default_state",{processor:"boolean",default:!1})})(t);const a=(()=>{let t=!1;return{get:()=>t,set:o=>{t=o}}})();((t,e,s)=>{t.addCommand("mceVisualBlocks",(()=>{o(t,0,s)}))})(t,0,a),((t,o)=>{const e=()=>t.execCommand("mceVisualBlocks");t.ui.registry.addToggleButton("visualblocks",{icon:"visualblocks",tooltip:"Show blocks",onAction:e,onSetup:s(t,o),context:"any"}),t.ui.registry.addToggleMenuItem("visualblocks",{text:"Show blocks",icon:"visualblocks",onAction:e,onSetup:s(t,o),context:"any"})})(t,a),((t,s,l)=>{t.on("PreviewFormats AfterPreviewFormats",(o=>{l.get()&&t.dom.toggleClass(t.getBody(),"mce-visualblocks","afterpreviewformats"===o.type)})),t.on("init",(()=>{e(t)&&o(t,0,l)}))})(t,0,a)}))}();
|
||||
Reference in New Issue
Block a user