mirror of
https://github.com/abort-retry-ignore/joplock.git
synced 2026-08-19 21:54:33 +00:00
Some checks are pending
Build and push Joplock image / build-and-push (push) Waiting to run
Squash-merge of the `tinymce` branch: replaces the previous editor with a dual-mode setup backed by the hidden #note-body textarea. - Rendered mode = TinyMCE 8 (persistent singleton over #tinymce-slot), markdown round-trip via Turndown (tinymceToMarkdown). - Markdown mode = CodeMirror 6 mounted in #cm-host (initCM/getCM/ cmSyncToTA/cmSetVal/mountMarkdownEditor); codemirror.min.js loaded before app.js. Full-screen CM6 code modal + language picker. - Code highlighting: hljs in preview/markdown, Prism (codesample) in rendered mode. Text expander + AI prose completion wired for both modes: - Text triggers expand in CM6 and in TinyMCE. - AI-action triggers and Ctrl/Cmd-Space run prose completion; in rendered mode the completion is offered in the same accept/dismiss popup as markdown mode (Enter/Tab insert, Esc discard), positioned at the iframe caret, inserted as DOM text nodes and synced to #note-body. Uploads: upload modal + direct drag/paste into TinyMCE and CM6, admin maxUploadMb limit with fast 413 pre-check, dropped images get a trailing blank line, upload-reload sync. Also included: per-user spellcheck toggle, runtime-toggleable debug logging, settings-page Esc dismiss, separate render/markdown font sizes, persisted editor mode, blank-line/image-spacing fixes across mode switches. Tests: cm6MarkdownMode, expanderRuntime, appRuntime, markdownToolbarClicks unit suites (558 total, all passing) + playwright specs (desktop, ai-rendered live provider E2E, upload-reload, resource-lifecycle).
106 lines
3.3 KiB
JavaScript
106 lines
3.3 KiB
JavaScript
/**
|
|
* TinyMCE version 8.6.0 (2026-06-03)
|
|
*/
|
|
|
|
(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) => {
|
|
// Prevents the visualblocks from being presented in the preview of formats when that is computed
|
|
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();
|
|
/** *****
|
|
* DO NOT EXPORT ANYTHING
|
|
*
|
|
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
*******/
|
|
|
|
})();
|