joplock/public/tinymce/plugins/save/plugin.min.js
igor 9fe3409b1c
Some checks are pending
Build and push Joplock image / build-and-push (push) Waiting to run
feat(editor): dual-mode editor — CodeMirror 6 markdown + TinyMCE 8 rendered
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).
2026-07-06 17:00:57 +12:00

1 line
No EOL
1.5 KiB
JavaScript

!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const o=e=>"function"==typeof e;var t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),n=tinymce.util.Tools.resolve("tinymce.util.Tools");const a=e=>o=>o.options.get(e),c=a("save_enablewhendirty"),i=a("save_onsavecallback"),s=a("save_oncancelcallback"),r=(e,o)=>{e.notificationManager.open({text:o,type:"error"})},l=e=>o=>{const t=()=>{o.setEnabled(!c(e)||e.isDirty())};return t(),e.on("NodeChange dirty",t),()=>e.off("NodeChange dirty",t)};e.add("save",e=>{(e=>{const o=e.options.register;o("save_enablewhendirty",{processor:"boolean",default:!0}),o("save_onsavecallback",{processor:"function"}),o("save_oncancelcallback",{processor:"function"})})(e),(e=>{e.ui.registry.addButton("save",{icon:"save",tooltip:"Save",enabled:!1,onAction:()=>e.execCommand("mceSave"),onSetup:l(e),shortcut:"Meta+S"}),e.ui.registry.addButton("cancel",{icon:"cancel",tooltip:"Cancel",enabled:!1,onAction:()=>e.execCommand("mceCancel"),onSetup:l(e)}),e.addShortcut("Meta+S","","mceSave")})(e),(e=>{e.addCommand("mceSave",()=>{(e=>{const n=t.DOM.getParent(e.id,"form");if(c(e)&&!e.isDirty())return;e.save();const a=i(e);if(o(a))return a.call(e,e),void e.nodeChanged();n?(e.setDirty(!1),n.onsubmit&&!n.onsubmit()||("function"==typeof n.submit?n.submit():r(e,"Error: Form submit field collision.")),e.nodeChanged()):r(e,"Error: No form element found.")})(e)}),e.addCommand("mceCancel",()=>{(e=>{const t=n.trim(e.startContent),a=s(e);o(a)?a.call(e,e):e.resetContent(t)})(e)})})(e)})}();