@novaprose/tinymce-compat 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/ai-XVSDIIQI.js +127 -0
- package/dist/ai-XVSDIIQI.js.map +1 -0
- package/dist/dialog-3UZZZW6Y.js +300 -0
- package/dist/dialog-3UZZZW6Y.js.map +1 -0
- package/dist/index.cjs +1351 -397
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -48
- package/dist/index.d.ts +109 -48
- package/dist/index.js +856 -363
- package/dist/index.js.map +1 -1
- package/dist/novaprose.css +440 -508
- package/dist/tinymce-chunks/a11ychecker-fe78c552.js +2 -0
- package/dist/tinymce-chunks/a11ychecker-fe78c552.js.map +7 -0
- package/dist/tinymce-chunks/accordion-ui-4272c63b.js +2 -0
- package/dist/tinymce-chunks/accordion-ui-4272c63b.js.map +7 -0
- package/dist/tinymce-chunks/advcode-840793ca.js +2 -0
- package/dist/tinymce-chunks/advcode-840793ca.js.map +7 -0
- package/dist/tinymce-chunks/advcode-editor-37bc0a02.js +26 -0
- package/dist/tinymce-chunks/advcode-editor-37bc0a02.js.map +7 -0
- package/dist/tinymce-chunks/advlist-67b98670.js +2 -0
- package/dist/tinymce-chunks/advlist-67b98670.js.map +7 -0
- package/dist/tinymce-chunks/advtable-ui-db2e667d.js +2 -0
- package/dist/tinymce-chunks/advtable-ui-db2e667d.js.map +7 -0
- package/dist/tinymce-chunks/ai-e0658729.js +6 -0
- package/dist/tinymce-chunks/ai-e0658729.js.map +7 -0
- package/dist/tinymce-chunks/ai2-ddf912a7.js +34 -0
- package/dist/tinymce-chunks/ai2-ddf912a7.js.map +7 -0
- package/dist/tinymce-chunks/anchor-ui-da0966bb.js +2 -0
- package/dist/tinymce-chunks/anchor-ui-da0966bb.js.map +7 -0
- package/dist/tinymce-chunks/autocorrect-907e1296.js +3 -0
- package/dist/tinymce-chunks/autocorrect-907e1296.js.map +7 -0
- package/dist/tinymce-chunks/autolink-897e8650.js +2 -0
- package/dist/tinymce-chunks/autolink-897e8650.js.map +7 -0
- package/dist/tinymce-chunks/autoresize-f8a4a52a.js +2 -0
- package/dist/tinymce-chunks/autoresize-f8a4a52a.js.map +7 -0
- package/dist/tinymce-chunks/autosave-60381295.js +2 -0
- package/dist/tinymce-chunks/autosave-60381295.js.map +7 -0
- package/dist/tinymce-chunks/bash-f3f8783a.js +2 -0
- package/dist/tinymce-chunks/bash-f3f8783a.js.map +7 -0
- package/dist/tinymce-chunks/c-8e3b278b.js +2 -0
- package/dist/tinymce-chunks/c-8e3b278b.js.map +7 -0
- package/dist/tinymce-chunks/casechange-8ad6a2c3.js +6 -0
- package/dist/tinymce-chunks/casechange-8ad6a2c3.js.map +7 -0
- package/dist/tinymce-chunks/charmap-5deb524c.js +2 -0
- package/dist/tinymce-chunks/charmap-5deb524c.js.map +7 -0
- package/dist/tinymce-chunks/checklist-5a0c95d3.js +2 -0
- package/dist/tinymce-chunks/checklist-5a0c95d3.js.map +7 -0
- package/dist/tinymce-chunks/codesample-b91dcd91.js +4 -0
- package/dist/tinymce-chunks/codesample-b91dcd91.js.map +7 -0
- package/dist/tinymce-chunks/comments-panel-152e9cbe.js +2 -0
- package/dist/tinymce-chunks/comments-panel-152e9cbe.js.map +7 -0
- package/dist/tinymce-chunks/core-f5b3fd3e.js +4 -0
- package/dist/tinymce-chunks/core-f5b3fd3e.js.map +7 -0
- package/dist/tinymce-chunks/cpp-525b2c81.js +2 -0
- package/dist/tinymce-chunks/cpp-525b2c81.js.map +7 -0
- package/dist/tinymce-chunks/csharp-b95db858.js +2 -0
- package/dist/tinymce-chunks/csharp-b95db858.js.map +7 -0
- package/dist/tinymce-chunks/css-bb736f0c.js +2 -0
- package/dist/tinymce-chunks/css-bb736f0c.js.map +7 -0
- package/dist/tinymce-chunks/de-eb649701.js +2 -0
- package/dist/tinymce-chunks/de-eb649701.js.map +7 -0
- package/dist/tinymce-chunks/dialog-126a0355.js +2 -0
- package/dist/tinymce-chunks/dialog-126a0355.js.map +7 -0
- package/dist/tinymce-chunks/diff-02578ed2.js +2 -0
- package/dist/tinymce-chunks/diff-02578ed2.js.map +7 -0
- package/dist/tinymce-chunks/directionality-185b3810.js +2 -0
- package/dist/tinymce-chunks/directionality-185b3810.js.map +7 -0
- package/dist/tinymce-chunks/dockerfile-ff44475c.js +2 -0
- package/dist/tinymce-chunks/dockerfile-ff44475c.js.map +7 -0
- package/dist/tinymce-chunks/draghandle-a1d99987.js +4 -0
- package/dist/tinymce-chunks/draghandle-a1d99987.js.map +7 -0
- package/dist/tinymce-chunks/editimage-36199bc6.js +2 -0
- package/dist/tinymce-chunks/editimage-36199bc6.js.map +7 -0
- package/dist/tinymce-chunks/email-1926dd8a.js +62 -0
- package/dist/tinymce-chunks/email-1926dd8a.js.map +7 -0
- package/dist/tinymce-chunks/email2-e9c49586.js +2 -0
- package/dist/tinymce-chunks/email2-e9c49586.js.map +7 -0
- package/dist/tinymce-chunks/emoticons-a5ab437d.js +2 -0
- package/dist/tinymce-chunks/emoticons-a5ab437d.js.map +7 -0
- package/dist/tinymce-chunks/es-b9c95169.js +2 -0
- package/dist/tinymce-chunks/es-b9c95169.js.map +7 -0
- package/dist/tinymce-chunks/exportpdf-0c6647bc.js +2 -0
- package/dist/tinymce-chunks/exportpdf-0c6647bc.js.map +7 -0
- package/dist/tinymce-chunks/exportword-8a03f24d.js +2 -0
- package/dist/tinymce-chunks/exportword-8a03f24d.js.map +7 -0
- package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js +2 -0
- package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js.map +7 -0
- package/dist/tinymce-chunks/form-dialog-9eb62199.js +2 -0
- package/dist/tinymce-chunks/form-dialog-9eb62199.js.map +7 -0
- package/dist/tinymce-chunks/formatpainter-cbeeffa7.js +2 -0
- package/dist/tinymce-chunks/formatpainter-cbeeffa7.js.map +7 -0
- package/dist/tinymce-chunks/fr-724ffe36.js +2 -0
- package/dist/tinymce-chunks/fr-724ffe36.js.map +7 -0
- package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js +2 -0
- package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js.map +7 -0
- package/dist/tinymce-chunks/go-14612282.js +2 -0
- package/dist/tinymce-chunks/go-14612282.js.map +7 -0
- package/dist/tinymce-chunks/graphql-032121b4.js +2 -0
- package/dist/tinymce-chunks/graphql-032121b4.js.map +7 -0
- package/dist/tinymce-chunks/history-diff-a0db052c.js +2 -0
- package/dist/tinymce-chunks/history-diff-a0db052c.js.map +7 -0
- package/dist/tinymce-chunks/importcss-28610ab5.js +3 -0
- package/dist/tinymce-chunks/importcss-28610ab5.js.map +7 -0
- package/dist/tinymce-chunks/importword-ec0b2213.js +2 -0
- package/dist/tinymce-chunks/importword-ec0b2213.js.map +7 -0
- package/dist/tinymce-chunks/index-330c7726.js +5 -0
- package/dist/tinymce-chunks/index-330c7726.js.map +7 -0
- package/dist/tinymce-chunks/index2-610900bb.js +2 -0
- package/dist/tinymce-chunks/index2-610900bb.js.map +7 -0
- package/dist/tinymce-chunks/insertdatetime-a48ee6e0.js +2 -0
- package/dist/tinymce-chunks/insertdatetime-a48ee6e0.js.map +7 -0
- package/dist/tinymce-chunks/it-f4816bbc.js +2 -0
- package/dist/tinymce-chunks/it-f4816bbc.js.map +7 -0
- package/dist/tinymce-chunks/java-e051279c.js +2 -0
- package/dist/tinymce-chunks/java-e051279c.js.map +7 -0
- package/dist/tinymce-chunks/javascript-d7a6fb3d.js +2 -0
- package/dist/tinymce-chunks/javascript-d7a6fb3d.js.map +7 -0
- package/dist/tinymce-chunks/json-08c0b631.js +2 -0
- package/dist/tinymce-chunks/json-08c0b631.js.map +7 -0
- package/dist/tinymce-chunks/kotlin-b34d5ff2.js +3 -0
- package/dist/tinymce-chunks/kotlin-b34d5ff2.js.map +7 -0
- package/dist/tinymce-chunks/linkchecker-820845fd.js +2 -0
- package/dist/tinymce-chunks/linkchecker-820845fd.js.map +7 -0
- package/dist/tinymce-chunks/lua-9b0ae20a.js +2 -0
- package/dist/tinymce-chunks/lua-9b0ae20a.js.map +7 -0
- package/dist/tinymce-chunks/markdown-5698ebec.js +34 -0
- package/dist/tinymce-chunks/markdown-5698ebec.js.map +7 -0
- package/dist/tinymce-chunks/markdown2-943bcf90.js +2 -0
- package/dist/tinymce-chunks/markdown2-943bcf90.js.map +7 -0
- package/dist/tinymce-chunks/math-ui-1b57f7eb.js +2 -0
- package/dist/tinymce-chunks/math-ui-1b57f7eb.js.map +7 -0
- package/dist/tinymce-chunks/media-ui-de819f11.js +2 -0
- package/dist/tinymce-chunks/media-ui-de819f11.js.map +7 -0
- package/dist/tinymce-chunks/mediaembed-ui-7be11324.js +2 -0
- package/dist/tinymce-chunks/mediaembed-ui-7be11324.js.map +7 -0
- package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js +2 -0
- package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js.map +7 -0
- package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js +2 -0
- package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js.map +7 -0
- package/dist/tinymce-chunks/nonbreaking-f15226ad.js +2 -0
- package/dist/tinymce-chunks/nonbreaking-f15226ad.js.map +7 -0
- package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js +2 -0
- package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js.map +7 -0
- package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js +2 -0
- package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js.map +7 -0
- package/dist/tinymce-chunks/pagelayout-ui-01757669.js +2 -0
- package/dist/tinymce-chunks/pagelayout-ui-01757669.js.map +7 -0
- package/dist/tinymce-chunks/paste-office-d6821891.js +3 -0
- package/dist/tinymce-chunks/paste-office-d6821891.js.map +7 -0
- package/dist/tinymce-chunks/permanentpen-fc96f445.js +2 -0
- package/dist/tinymce-chunks/permanentpen-fc96f445.js.map +7 -0
- package/dist/tinymce-chunks/php-6b723470.js +3 -0
- package/dist/tinymce-chunks/php-6b723470.js.map +7 -0
- package/dist/tinymce-chunks/powershell-e6c3fdb8.js +2 -0
- package/dist/tinymce-chunks/powershell-e6c3fdb8.js.map +7 -0
- package/dist/tinymce-chunks/print-86762549.js +27 -0
- package/dist/tinymce-chunks/print-86762549.js.map +7 -0
- package/dist/tinymce-chunks/pt-BR-abebbb34.js +2 -0
- package/dist/tinymce-chunks/pt-BR-abebbb34.js.map +7 -0
- package/dist/tinymce-chunks/python-a20cacce.js +2 -0
- package/dist/tinymce-chunks/python-a20cacce.js.map +7 -0
- package/dist/tinymce-chunks/quickbars-35c87c0e.js +2 -0
- package/dist/tinymce-chunks/quickbars-35c87c0e.js.map +7 -0
- package/dist/tinymce-chunks/revisionhistory-741dfb24.js +2 -0
- package/dist/tinymce-chunks/revisionhistory-741dfb24.js.map +7 -0
- package/dist/tinymce-chunks/ru-f1d19f4f.js +2 -0
- package/dist/tinymce-chunks/ru-f1d19f4f.js.map +7 -0
- package/dist/tinymce-chunks/ruby-93c325c7.js +2 -0
- package/dist/tinymce-chunks/ruby-93c325c7.js.map +7 -0
- package/dist/tinymce-chunks/rust-d80fbab5.js +2 -0
- package/dist/tinymce-chunks/rust-d80fbab5.js.map +7 -0
- package/dist/tinymce-chunks/save-a65e56cd.js +2 -0
- package/dist/tinymce-chunks/save-a65e56cd.js.map +7 -0
- package/dist/tinymce-chunks/scss-7cffeb15.js +2 -0
- package/dist/tinymce-chunks/scss-7cffeb15.js.map +7 -0
- package/dist/tinymce-chunks/search-bar-3ea04183.js +3 -0
- package/dist/tinymce-chunks/search-bar-3ea04183.js.map +7 -0
- package/dist/tinymce-chunks/spellchecker-91509fc1.js +6 -0
- package/dist/tinymce-chunks/spellchecker-91509fc1.js.map +7 -0
- package/dist/tinymce-chunks/sql-eeac1a81.js +2 -0
- package/dist/tinymce-chunks/sql-eeac1a81.js.map +7 -0
- package/dist/tinymce-chunks/suggestions-panel-c29362cf.js +2 -0
- package/dist/tinymce-chunks/suggestions-panel-c29362cf.js.map +7 -0
- package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js +2 -0
- package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js.map +7 -0
- package/dist/tinymce-chunks/swift-2b081f3e.js +2 -0
- package/dist/tinymce-chunks/swift-2b081f3e.js.map +7 -0
- package/dist/tinymce-chunks/table-4d43f60d.js +2 -0
- package/dist/tinymce-chunks/table-4d43f60d.js.map +7 -0
- package/dist/tinymce-chunks/table-dialogs-0445847c.js +2 -0
- package/dist/tinymce-chunks/table-dialogs-0445847c.js.map +7 -0
- package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js +2 -0
- package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js.map +7 -0
- package/dist/tinymce-chunks/temml-d637f801.js +97 -0
- package/dist/tinymce-chunks/temml-d637f801.js.map +7 -0
- package/dist/tinymce-chunks/template-b522c8ed.js +2 -0
- package/dist/tinymce-chunks/template-b522c8ed.js.map +7 -0
- package/dist/tinymce-chunks/typescript-fa085d66.js +2 -0
- package/dist/tinymce-chunks/typescript-fa085d66.js.map +7 -0
- package/dist/tinymce-chunks/typography-469ce11a.js +3 -0
- package/dist/tinymce-chunks/typography-469ce11a.js.map +7 -0
- package/dist/tinymce-chunks/visualblocks-8b7cba25.js +2 -0
- package/dist/tinymce-chunks/visualblocks-8b7cba25.js.map +7 -0
- package/dist/tinymce-chunks/visualchars-7cda4c00.js +2 -0
- package/dist/tinymce-chunks/visualchars-7cda4c00.js.map +7 -0
- package/dist/tinymce-chunks/xml-77617a8f.js +2 -0
- package/dist/tinymce-chunks/xml-77617a8f.js.map +7 -0
- package/dist/tinymce-chunks/yaml-5bb3ad37.js +2 -0
- package/dist/tinymce-chunks/yaml-5bb3ad37.js.map +7 -0
- package/dist/tinymce.global.js +36 -29
- package/dist/tinymce.global.js.map +7 -1
- package/dist/tinymce.licenses.txt +1094 -0
- package/package.json +11 -6
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
6
16
|
var __export = (target, all) => {
|
|
7
17
|
for (var name in all)
|
|
8
18
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -13,9 +23,464 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
23
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
24
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
25
|
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
|
|
38
|
+
// nova-raw-css:/home/runner/work/novaprose/novaprose/packages/tinymce-compat/src/dialog.css?raw
|
|
39
|
+
var dialog_default;
|
|
40
|
+
var init_dialog = __esm({
|
|
41
|
+
"nova-raw-css:/home/runner/work/novaprose/novaprose/packages/tinymce-compat/src/dialog.css?raw"() {
|
|
42
|
+
dialog_default = ".nova-compat-dialog{display:flex;flex-direction:column;gap:12px}.nova-compat-tabs{display:flex;gap:2px;border-bottom:1px solid var(--nova-border)}.nova-compat-tab{padding:6px 10px;border:0;border-bottom:2px solid transparent;background:none;color:var(--nova-muted);font:inherit;cursor:pointer}.nova-compat-tab[aria-selected=true]{border-bottom-color:var(--nova-accent);color:var(--nova-fg);font-weight:600}.nova-compat-tab:focus-visible{outline:2px solid var(--nova-focus);outline-offset:-2px}.nova-compat-tabpanel{display:flex;flex-direction:column;gap:12px}.nova-compat-tabpanel[hidden]{display:none}.nova-compat-grid{display:grid;gap:10px}.nova-compat-group{display:flex;flex-direction:column;gap:8px}.nova-compat-actions{display:flex;flex-wrap:wrap;gap:8px}.nova-compat-alert{margin:0;padding:8px 10px;border-radius:var(--nova-radius-sm);background:var(--nova-active);color:var(--nova-fg)}.nova-compat-alert.is-warn{background:var(--nova-warning-bg)}.nova-compat-alert.is-error{background:var(--nova-danger-bg);color:var(--nova-danger)}.nova-compat-alert.is-success{background:var(--nova-success-bg)}.nova-compat-html{line-height:1.5;overflow-wrap:anywhere}";
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/dialog.ts
|
|
47
|
+
var dialog_exports = {};
|
|
48
|
+
__export(dialog_exports, {
|
|
49
|
+
openSpecDialog: () => openSpecDialog
|
|
50
|
+
});
|
|
51
|
+
function el(tag, className, text) {
|
|
52
|
+
const node = document.createElement(tag);
|
|
53
|
+
if (className) node.className = className;
|
|
54
|
+
if (text !== void 0) node.textContent = text;
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
function safeHtml(html) {
|
|
58
|
+
const template = document.createElement("template");
|
|
59
|
+
template.innerHTML = html;
|
|
60
|
+
template.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach((node) => node.remove());
|
|
61
|
+
template.content.querySelectorAll("*").forEach((node) => {
|
|
62
|
+
for (const attr of [...node.attributes]) {
|
|
63
|
+
const value = attr.value.trim().toLowerCase();
|
|
64
|
+
if (attr.name.startsWith("on") || /^(javascript|vbscript|data):/.test(value)) {
|
|
65
|
+
node.removeAttribute(attr.name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return template.content;
|
|
70
|
+
}
|
|
71
|
+
function openSpecDialog(editor, spec, reopen) {
|
|
72
|
+
editor.ui.addStyles("nova-compat-dialog", dialog_default);
|
|
73
|
+
const controls = /* @__PURE__ */ new Map();
|
|
74
|
+
const tabs = /* @__PURE__ */ new Map();
|
|
75
|
+
let currentTab = "";
|
|
76
|
+
let closedByApi = false;
|
|
77
|
+
let handle = null;
|
|
78
|
+
const notifyChange = (name) => spec.onChange?.(api, { name });
|
|
79
|
+
function field(item, input) {
|
|
80
|
+
const id = nextId();
|
|
81
|
+
input.id = id;
|
|
82
|
+
const wrap = el("div", "nova-field");
|
|
83
|
+
if (item.label) {
|
|
84
|
+
const label = el("label", "nova-label", item.label);
|
|
85
|
+
label.htmlFor = id;
|
|
86
|
+
wrap.append(label);
|
|
87
|
+
}
|
|
88
|
+
wrap.append(input);
|
|
89
|
+
return wrap;
|
|
90
|
+
}
|
|
91
|
+
function render(item) {
|
|
92
|
+
const name = item.name ?? "";
|
|
93
|
+
const enabled = item.enabled !== false && item.disabled !== true;
|
|
94
|
+
switch (item.type) {
|
|
95
|
+
case "input":
|
|
96
|
+
case "urlinput":
|
|
97
|
+
case "colorinput": {
|
|
98
|
+
const input = el("input", "nova-input");
|
|
99
|
+
input.type = item.type === "colorinput" ? "color" : item.type === "urlinput" ? "url" : "text";
|
|
100
|
+
if (item.inputMode) input.inputMode = item.inputMode;
|
|
101
|
+
if (item.placeholder) input.placeholder = item.placeholder;
|
|
102
|
+
input.disabled = !enabled;
|
|
103
|
+
input.addEventListener("input", () => notifyChange(name));
|
|
104
|
+
if (name) {
|
|
105
|
+
controls.set(name, {
|
|
106
|
+
// urlinput keeps { value }, the others a string.
|
|
107
|
+
get: () => item.type === "urlinput" ? { value: input.value } : input.value,
|
|
108
|
+
set: (value) => {
|
|
109
|
+
input.value = String(
|
|
110
|
+
item.type === "urlinput" && value && typeof value === "object" ? value.value ?? "" : value ?? ""
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
focus: () => input.focus(),
|
|
114
|
+
setEnabled: (on) => input.disabled = !on
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return field(item, input);
|
|
118
|
+
}
|
|
119
|
+
case "textarea": {
|
|
120
|
+
const input = el("textarea", "nova-input");
|
|
121
|
+
input.rows = item.maximized ? 10 : 4;
|
|
122
|
+
if (item.placeholder) input.placeholder = item.placeholder;
|
|
123
|
+
input.disabled = !enabled;
|
|
124
|
+
input.addEventListener("input", () => notifyChange(name));
|
|
125
|
+
if (name) {
|
|
126
|
+
controls.set(name, {
|
|
127
|
+
get: () => input.value,
|
|
128
|
+
set: (value) => input.value = String(value ?? ""),
|
|
129
|
+
focus: () => input.focus(),
|
|
130
|
+
setEnabled: (on) => input.disabled = !on
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return field(item, input);
|
|
134
|
+
}
|
|
135
|
+
case "checkbox": {
|
|
136
|
+
const input = el("input", "nova-checkbox");
|
|
137
|
+
input.type = "checkbox";
|
|
138
|
+
input.id = nextId();
|
|
139
|
+
input.disabled = !enabled;
|
|
140
|
+
input.addEventListener("change", () => notifyChange(name));
|
|
141
|
+
const label = el("label", void 0, item.label ?? "");
|
|
142
|
+
label.htmlFor = input.id;
|
|
143
|
+
if (name) {
|
|
144
|
+
controls.set(name, {
|
|
145
|
+
get: () => input.checked,
|
|
146
|
+
set: (value) => input.checked = Boolean(value),
|
|
147
|
+
focus: () => input.focus(),
|
|
148
|
+
setEnabled: (on) => input.disabled = !on
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const wrap = el("div", "nova-field nova-field-inline");
|
|
152
|
+
wrap.append(input, label);
|
|
153
|
+
return wrap;
|
|
154
|
+
}
|
|
155
|
+
case "selectbox":
|
|
156
|
+
case "listbox": {
|
|
157
|
+
const select = el("select", "nova-input nova-select");
|
|
158
|
+
for (const option of item.items ?? []) {
|
|
159
|
+
const node = el("option", void 0, option.text);
|
|
160
|
+
node.value = option.value;
|
|
161
|
+
select.append(node);
|
|
162
|
+
}
|
|
163
|
+
select.disabled = !enabled;
|
|
164
|
+
select.addEventListener("change", () => notifyChange(name));
|
|
165
|
+
if (name) {
|
|
166
|
+
controls.set(name, {
|
|
167
|
+
get: () => select.value,
|
|
168
|
+
set: (value) => select.value = String(value ?? ""),
|
|
169
|
+
focus: () => select.focus(),
|
|
170
|
+
setEnabled: (on) => select.disabled = !on
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return field(item, select);
|
|
174
|
+
}
|
|
175
|
+
case "button": {
|
|
176
|
+
const button = el(
|
|
177
|
+
"button",
|
|
178
|
+
item.primary || item.buttonType === "primary" ? "nova-button nova-button-primary" : "nova-button",
|
|
179
|
+
item.text ?? ""
|
|
180
|
+
);
|
|
181
|
+
button.type = "button";
|
|
182
|
+
button.disabled = !enabled;
|
|
183
|
+
button.addEventListener("click", () => spec.onAction?.(api, { name }));
|
|
184
|
+
if (name) {
|
|
185
|
+
controls.set(name, {
|
|
186
|
+
get: () => void 0,
|
|
187
|
+
set: () => {
|
|
188
|
+
},
|
|
189
|
+
focus: () => button.focus(),
|
|
190
|
+
setEnabled: (on) => button.disabled = !on
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return button;
|
|
194
|
+
}
|
|
195
|
+
case "htmlpanel": {
|
|
196
|
+
const panel = el("div", "nova-compat-html");
|
|
197
|
+
panel.append(safeHtml(item.html ?? ""));
|
|
198
|
+
return panel;
|
|
199
|
+
}
|
|
200
|
+
case "alertbanner": {
|
|
201
|
+
const banner = el("p", `nova-compat-alert is-${item.level ?? "info"}`, item.text ?? "");
|
|
202
|
+
banner.setAttribute("role", item.level === "error" ? "alert" : "status");
|
|
203
|
+
return banner;
|
|
204
|
+
}
|
|
205
|
+
case "label": {
|
|
206
|
+
const group = el("div", "nova-compat-group");
|
|
207
|
+
group.append(el("p", "nova-label", item.label ?? ""));
|
|
208
|
+
for (const child of item.items ?? []) {
|
|
209
|
+
const node = render(child);
|
|
210
|
+
if (node) group.append(node);
|
|
211
|
+
}
|
|
212
|
+
return group;
|
|
213
|
+
}
|
|
214
|
+
case "grid":
|
|
215
|
+
case "bar": {
|
|
216
|
+
const grid = el("div", "nova-compat-grid");
|
|
217
|
+
const columns = item.type === "bar" ? item.items?.length ?? 1 : item.columns === "auto" ? 2 : item.columns ?? 2;
|
|
218
|
+
grid.style.gridTemplateColumns = `repeat(${Number(columns) || 2}, minmax(0, 1fr))`;
|
|
219
|
+
for (const child of item.items ?? []) {
|
|
220
|
+
const node = render(child);
|
|
221
|
+
if (node) grid.append(node);
|
|
222
|
+
}
|
|
223
|
+
return grid;
|
|
224
|
+
}
|
|
225
|
+
default:
|
|
226
|
+
console.warn(`[nova] tinymce-compat: dialog component "${item.type}" is not supported yet`);
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const body = el("div", "nova-compat-dialog nova-form");
|
|
231
|
+
if (spec.body.type === "tabpanel") {
|
|
232
|
+
const tabList = el("div", "nova-compat-tabs");
|
|
233
|
+
tabList.setAttribute("role", "tablist");
|
|
234
|
+
body.append(tabList);
|
|
235
|
+
spec.body.tabs.forEach((tab, index) => {
|
|
236
|
+
const name = tab.name ?? tab.title;
|
|
237
|
+
const button = el("button", "nova-compat-tab", tab.title);
|
|
238
|
+
button.type = "button";
|
|
239
|
+
button.setAttribute("role", "tab");
|
|
240
|
+
const panel = el("div", "nova-compat-tabpanel");
|
|
241
|
+
panel.setAttribute("role", "tabpanel");
|
|
242
|
+
for (const item of tab.items) {
|
|
243
|
+
const node = render(item);
|
|
244
|
+
if (node) panel.append(node);
|
|
245
|
+
}
|
|
246
|
+
button.addEventListener("click", () => api.showTab(name));
|
|
247
|
+
tabs.set(name, { button, panel });
|
|
248
|
+
tabList.append(button);
|
|
249
|
+
body.append(panel);
|
|
250
|
+
if (index === 0) currentTab = name;
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
for (const item of spec.body.items) {
|
|
254
|
+
const node = render(item);
|
|
255
|
+
if (node) body.append(node);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const buttons = spec.buttons ?? [];
|
|
259
|
+
const submit = buttons.find((b) => b.type === "submit");
|
|
260
|
+
const custom = buttons.filter((b) => b.type === "custom");
|
|
261
|
+
if (custom.length) {
|
|
262
|
+
const row = el("div", "nova-compat-actions");
|
|
263
|
+
for (const b of custom) {
|
|
264
|
+
const button = el(
|
|
265
|
+
"button",
|
|
266
|
+
b.primary ? "nova-button nova-button-primary" : "nova-button",
|
|
267
|
+
b.text
|
|
268
|
+
);
|
|
269
|
+
button.type = "button";
|
|
270
|
+
button.disabled = b.enabled === false;
|
|
271
|
+
button.addEventListener("click", () => spec.onAction?.(api, { name: b.name ?? b.text }));
|
|
272
|
+
if (b.name) {
|
|
273
|
+
controls.set(b.name, {
|
|
274
|
+
get: () => void 0,
|
|
275
|
+
set: () => {
|
|
276
|
+
},
|
|
277
|
+
focus: () => button.focus(),
|
|
278
|
+
setEnabled: (on) => button.disabled = !on
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
row.append(button);
|
|
282
|
+
}
|
|
283
|
+
body.append(row);
|
|
284
|
+
}
|
|
285
|
+
const api = {
|
|
286
|
+
getData: () => {
|
|
287
|
+
const data = {};
|
|
288
|
+
controls.forEach((control, name) => {
|
|
289
|
+
const value = control.get();
|
|
290
|
+
if (value !== void 0) data[name] = value;
|
|
291
|
+
});
|
|
292
|
+
return data;
|
|
293
|
+
},
|
|
294
|
+
setData: (data) => {
|
|
295
|
+
for (const [name, value] of Object.entries(data)) controls.get(name)?.set(value);
|
|
296
|
+
},
|
|
297
|
+
close: () => {
|
|
298
|
+
closedByApi = true;
|
|
299
|
+
handle?.close();
|
|
300
|
+
},
|
|
301
|
+
block: () => handle?.setBusy(true),
|
|
302
|
+
unblock: () => handle?.setBusy(false),
|
|
303
|
+
focus: (name) => controls.get(name)?.focus(),
|
|
304
|
+
disable: (name) => controls.get(name)?.setEnabled(false),
|
|
305
|
+
enable: (name) => controls.get(name)?.setEnabled(true),
|
|
306
|
+
showTab: (name) => {
|
|
307
|
+
if (!tabs.has(name)) return;
|
|
308
|
+
const old = currentTab;
|
|
309
|
+
currentTab = name;
|
|
310
|
+
tabs.forEach(({ button, panel }, key) => {
|
|
311
|
+
const on = key === name;
|
|
312
|
+
button.setAttribute("aria-selected", String(on));
|
|
313
|
+
button.tabIndex = on ? 0 : -1;
|
|
314
|
+
panel.hidden = !on;
|
|
315
|
+
});
|
|
316
|
+
if (old && old !== name) spec.onTabChange?.(api, { newTabName: name, oldTabName: old });
|
|
317
|
+
},
|
|
318
|
+
redial: (next) => {
|
|
319
|
+
api.close();
|
|
320
|
+
Object.assign(api, reopen(next));
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
if (spec.initialData) api.setData(spec.initialData);
|
|
324
|
+
if (currentTab) api.showTab(currentTab);
|
|
325
|
+
handle = editor.ui.openDialog({
|
|
326
|
+
title: spec.title,
|
|
327
|
+
body,
|
|
328
|
+
...submit ? { submitLabel: submit.text } : {},
|
|
329
|
+
...spec.size === "large" ? { size: "large" } : {},
|
|
330
|
+
onSubmit: () => {
|
|
331
|
+
spec.onSubmit?.(api);
|
|
332
|
+
return closedByApi;
|
|
333
|
+
},
|
|
334
|
+
onClose: () => {
|
|
335
|
+
if (!closedByApi) spec.onCancel?.(api);
|
|
336
|
+
spec.onClose?.();
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
return api;
|
|
340
|
+
}
|
|
341
|
+
var uid, nextId;
|
|
342
|
+
var init_dialog2 = __esm({
|
|
343
|
+
"src/dialog.ts"() {
|
|
344
|
+
"use strict";
|
|
345
|
+
init_dialog();
|
|
346
|
+
uid = 0;
|
|
347
|
+
nextId = () => `nova-compat-field-${++uid}`;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// src/ai.ts
|
|
352
|
+
var ai_exports = {};
|
|
353
|
+
__export(ai_exports, {
|
|
354
|
+
htmlToText: () => htmlToText,
|
|
355
|
+
tinyAiRequest: () => tinyAiRequest,
|
|
356
|
+
toTinyRequest: () => toTinyRequest
|
|
357
|
+
});
|
|
358
|
+
function thread(messages) {
|
|
359
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
360
|
+
const events = [];
|
|
361
|
+
messages.forEach((message, index) => {
|
|
362
|
+
const answer = messages[index + 1];
|
|
363
|
+
if (message.role !== "user" || answer?.role !== "assistant") return;
|
|
364
|
+
events.push({
|
|
365
|
+
eventUid: `nova-ai-${events.length + 1}`,
|
|
366
|
+
timestamp,
|
|
367
|
+
request: { prompt: message.text, query: message.text, context: "", system: [] },
|
|
368
|
+
response: { type: "string", data: answer.text }
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
return events;
|
|
372
|
+
}
|
|
373
|
+
function toTinyRequest(request) {
|
|
374
|
+
const context = request.text || (request.action === "chat" ? request.document : "") || (request.action === "complete" ? request.before : "");
|
|
375
|
+
return {
|
|
376
|
+
prompt: request.prompt,
|
|
377
|
+
query: request.instruction,
|
|
378
|
+
context,
|
|
379
|
+
thread: thread(request.messages ?? []),
|
|
380
|
+
system: [...request.rules ?? []]
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function htmlToText(html) {
|
|
384
|
+
const body = new DOMParser().parseFromString(html, "text/html").body;
|
|
385
|
+
const paragraphs = [];
|
|
386
|
+
let line = "";
|
|
387
|
+
const flush = () => {
|
|
388
|
+
const text = line.replace(/[^\S\n]+/g, " ").replace(/ ?\n ?/g, "\n").trim();
|
|
389
|
+
if (text) paragraphs.push(text);
|
|
390
|
+
line = "";
|
|
391
|
+
};
|
|
392
|
+
const walk = (node) => {
|
|
393
|
+
for (const child of Array.from(node.childNodes)) {
|
|
394
|
+
if (child.nodeType === 3) line += (child.textContent ?? "").replace(/\s+/g, " ");
|
|
395
|
+
else if (child.nodeName === "BR") line += "\n";
|
|
396
|
+
else if (child.nodeType === 1 && child.nodeName !== "SCRIPT" && child.nodeName !== "STYLE") {
|
|
397
|
+
const block = BLOCKS2.test(child.nodeName);
|
|
398
|
+
if (block) flush();
|
|
399
|
+
walk(child);
|
|
400
|
+
if (block) flush();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
walk(body);
|
|
405
|
+
flush();
|
|
406
|
+
return paragraphs.join("\n\n");
|
|
407
|
+
}
|
|
408
|
+
function tinyAiRequest(handler, fire) {
|
|
409
|
+
return (request) => {
|
|
410
|
+
const tiny = toTinyRequest(request);
|
|
411
|
+
const queue = [];
|
|
412
|
+
let whole = "";
|
|
413
|
+
let finished = false;
|
|
414
|
+
let failure;
|
|
415
|
+
let wake = null;
|
|
416
|
+
const notify = () => {
|
|
417
|
+
const resume = wake;
|
|
418
|
+
wake = null;
|
|
419
|
+
resume?.();
|
|
420
|
+
};
|
|
421
|
+
const push = (text) => {
|
|
422
|
+
if (finished || text === null || text === void 0) return;
|
|
423
|
+
const piece = String(text);
|
|
424
|
+
whole += piece;
|
|
425
|
+
queue.push(piece);
|
|
426
|
+
notify();
|
|
427
|
+
};
|
|
428
|
+
const finish = (error) => {
|
|
429
|
+
if (finished) return;
|
|
430
|
+
finished = true;
|
|
431
|
+
failure = error;
|
|
432
|
+
notify();
|
|
433
|
+
};
|
|
434
|
+
const settle = (work) => {
|
|
435
|
+
work.then(
|
|
436
|
+
() => finish(),
|
|
437
|
+
(error) => finish(error ?? new Error("The AI request failed"))
|
|
438
|
+
);
|
|
439
|
+
return work.then(
|
|
440
|
+
() => void 0,
|
|
441
|
+
() => void 0
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
const respondWith = {
|
|
445
|
+
string: (callback) => settle(Promise.resolve().then(async () => push(await callback(request.signal)))),
|
|
446
|
+
stream: (callback) => settle(Promise.resolve().then(() => callback(request.signal, (message) => push(message))))
|
|
447
|
+
};
|
|
448
|
+
request.signal.addEventListener("abort", () => finish(), { once: true });
|
|
449
|
+
fire("AIRequest", { request: tiny });
|
|
450
|
+
try {
|
|
451
|
+
handler(tiny, respondWith);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
finish(error);
|
|
454
|
+
}
|
|
455
|
+
const html = request.action !== "edit";
|
|
456
|
+
return (async function* () {
|
|
457
|
+
let buffered = false;
|
|
458
|
+
for (; ; ) {
|
|
459
|
+
while (queue.length) {
|
|
460
|
+
const piece = queue.shift();
|
|
461
|
+
if (html && !buffered && /^\s*</.test(whole)) buffered = true;
|
|
462
|
+
if (!buffered) yield piece;
|
|
463
|
+
}
|
|
464
|
+
if (finished) break;
|
|
465
|
+
await new Promise((resolve) => wake = resolve);
|
|
466
|
+
}
|
|
467
|
+
if (request.signal.aborted) return;
|
|
468
|
+
if (failure !== void 0) {
|
|
469
|
+
fire("AIError", { error: failure });
|
|
470
|
+
throw failure instanceof Error ? failure : new Error(String(failure));
|
|
471
|
+
}
|
|
472
|
+
if (buffered) yield htmlToText(whole);
|
|
473
|
+
fire("AIResponse", { response: whole });
|
|
474
|
+
})();
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
var BLOCKS2;
|
|
478
|
+
var init_ai = __esm({
|
|
479
|
+
"src/ai.ts"() {
|
|
480
|
+
"use strict";
|
|
481
|
+
BLOCKS2 = /^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|UL|OL|TABLE|SECTION|ARTICLE|HEADER|FOOTER)$/;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
19
484
|
|
|
20
485
|
// src/index.ts
|
|
21
486
|
var src_exports = {};
|
|
@@ -27,6 +492,7 @@ __export(src_exports, {
|
|
|
27
492
|
});
|
|
28
493
|
module.exports = __toCommonJS(src_exports);
|
|
29
494
|
var import_core3 = require("@novaprose/core");
|
|
495
|
+
var import_html_rules = require("@novaprose/core/html-rules");
|
|
30
496
|
|
|
31
497
|
// src/options.ts
|
|
32
498
|
var import_core = require("@novaprose/core");
|
|
@@ -36,7 +502,6 @@ var BUILT_IN = /* @__PURE__ */ new Set([
|
|
|
36
502
|
"image",
|
|
37
503
|
"table",
|
|
38
504
|
"code",
|
|
39
|
-
"codesample",
|
|
40
505
|
"preview",
|
|
41
506
|
"searchreplace",
|
|
42
507
|
"fullscreen",
|
|
@@ -51,12 +516,12 @@ var BUILT_IN = /* @__PURE__ */ new Set([
|
|
|
51
516
|
"tabfocus",
|
|
52
517
|
"textpattern",
|
|
53
518
|
"imagetools",
|
|
54
|
-
"powerpaste"
|
|
55
|
-
"importcss",
|
|
56
|
-
"accordion"
|
|
519
|
+
"powerpaste"
|
|
57
520
|
]);
|
|
58
521
|
var RENAMED = {
|
|
59
|
-
tinycomments: "comments"
|
|
522
|
+
tinycomments: "comments",
|
|
523
|
+
tinymcespellchecker: "spellchecker",
|
|
524
|
+
inlinecss: "email"
|
|
60
525
|
};
|
|
61
526
|
var IGNORED = /* @__PURE__ */ new Set([
|
|
62
527
|
"selector",
|
|
@@ -112,6 +577,9 @@ var IGNORED = /* @__PURE__ */ new Set([
|
|
|
112
577
|
"paste_postprocess",
|
|
113
578
|
"invalid_elements",
|
|
114
579
|
"valid_elements",
|
|
580
|
+
"directionality",
|
|
581
|
+
"extended_valid_elements",
|
|
582
|
+
"custom_elements",
|
|
115
583
|
"valid_styles",
|
|
116
584
|
"toolbar_mode",
|
|
117
585
|
"toolbar_sticky",
|
|
@@ -126,9 +594,181 @@ var IGNORED = /* @__PURE__ */ new Set([
|
|
|
126
594
|
"quickbars_insert_toolbar",
|
|
127
595
|
"mentions_fetch",
|
|
128
596
|
"tinycomments_author",
|
|
129
|
-
"tinycomments_author_name"
|
|
597
|
+
"tinycomments_author_name",
|
|
598
|
+
"codesample_languages",
|
|
599
|
+
"details_initial_state",
|
|
600
|
+
"details_serialized_state",
|
|
601
|
+
"tableofcontents_class",
|
|
602
|
+
"tableofcontents_depth",
|
|
603
|
+
"tableofcontents_header",
|
|
604
|
+
"tableofcontents_orderedlist",
|
|
605
|
+
"tableofcontents_includeheader",
|
|
606
|
+
// Highlighting is our own (highlight.js, lazy); Prism on the site's page isn't needed for it.
|
|
607
|
+
"codesample_global_prismjs",
|
|
608
|
+
"casechange_title_case_minors",
|
|
609
|
+
"permanentpen_properties",
|
|
610
|
+
"visualchars_default_state",
|
|
611
|
+
// save_* are wired in index.ts: the callbacks get the TinyMCE-style editor.
|
|
612
|
+
"save_enablewhendirty",
|
|
613
|
+
"save_onsavecallback",
|
|
614
|
+
"save_oncancelcallback",
|
|
615
|
+
"importcss_append",
|
|
616
|
+
"importcss_file_filter",
|
|
617
|
+
"importcss_selector_filter",
|
|
618
|
+
"importcss_groups",
|
|
619
|
+
"importcss_exclusive",
|
|
620
|
+
"importcss_selector_converter",
|
|
621
|
+
"templates",
|
|
622
|
+
// tinymcespellchecker: the checking goes through your service (spellchecker_languagetool_url or
|
|
623
|
+
// spellchecker_check, NovaProse's own options); Tiny's spellchecker_rpc_url is not used.
|
|
624
|
+
"spellchecker_active",
|
|
625
|
+
"spellchecker_language",
|
|
626
|
+
"spellchecker_languages",
|
|
627
|
+
"spellchecker_ignore_list",
|
|
628
|
+
"spellchecker_dialog",
|
|
629
|
+
"content_language",
|
|
630
|
+
"spellchecker_languagetool_url",
|
|
631
|
+
"spellchecker_check",
|
|
632
|
+
// a11ychecker: the level, ignored rules, decorative images, the alt length, a filter. HTML 5 is
|
|
633
|
+
// always checked, and there is no "more info" link.
|
|
634
|
+
"a11ychecker_level",
|
|
635
|
+
"a11ychecker_ignored_rules",
|
|
636
|
+
"a11ychecker_allow_decorative_images",
|
|
637
|
+
"a11y_advanced_options",
|
|
638
|
+
"a11ychecker_alt_text_max_length",
|
|
639
|
+
"a11ychecker_filter_issue",
|
|
640
|
+
"a11ychecker_html_version",
|
|
641
|
+
"a11ychecker_issue_url_callback",
|
|
642
|
+
// ai: ai_request is wired in index.ts (its events go to the TinyMCE-style editor); ai_shortcuts
|
|
643
|
+
// becomes the quick actions.
|
|
644
|
+
"ai_request",
|
|
645
|
+
"ai_shortcuts",
|
|
646
|
+
// inlinecss → the email plugin: the filters of what is put inline.
|
|
647
|
+
"inlinecss_selector_filter",
|
|
648
|
+
"inlinecss_file_filter",
|
|
649
|
+
// linkchecker: the service address (a server that answers our protocol, see the link checker
|
|
650
|
+
// guide) and preprocess; the highlight's look comes from the theme's CSS variables.
|
|
651
|
+
"linkchecker_service_url",
|
|
652
|
+
"linkchecker_preprocess",
|
|
653
|
+
"linkchecker_content_css",
|
|
654
|
+
// pageembed: the sizes (classes) and inline styles; the wrapper keeps TinyMCE's class.
|
|
655
|
+
"tiny_pageembed_classes",
|
|
656
|
+
"tiny_pageembed_inline_styles",
|
|
657
|
+
// fullpagehtml: what a page that doesn't say gets (doctype, title, encoding, body style), and
|
|
658
|
+
// whether the source code view shows the whole page.
|
|
659
|
+
"fullpagehtml_default_doctype",
|
|
660
|
+
"fullpagehtml_default_title",
|
|
661
|
+
"fullpagehtml_default_encoding",
|
|
662
|
+
"fullpagehtml_default_body_style",
|
|
663
|
+
"fullpagehtml_hide_in_source_view",
|
|
664
|
+
// mediaembed: the service address (a server that answers our protocol, see the embeds guide),
|
|
665
|
+
// the widest a card gets and inline styles; cards keep TinyMCE's summary card classes.
|
|
666
|
+
"mediaembed_service_url",
|
|
667
|
+
"mediaembed_max_width",
|
|
668
|
+
"mediaembed_inline_styles",
|
|
669
|
+
// advtable: your series for the numbers column (their generators give each row's value).
|
|
670
|
+
"advtable_value_series",
|
|
671
|
+
// advcode: the code laid out on open, getContent laid out too (index.ts); the code editor opens
|
|
672
|
+
// in a dialog with a full screen button, so advcode_inline isn't needed.
|
|
673
|
+
"advcode_prettify_editor",
|
|
674
|
+
"advcode_prettify_getcontent",
|
|
675
|
+
"advcode_inline",
|
|
676
|
+
// view_show and sidebar_show: opened when the editor is ready (index.ts).
|
|
677
|
+
"view_show",
|
|
678
|
+
"sidebar_show",
|
|
679
|
+
// editimage: the toolbar, the hosts with cookies, your way to fetch an image (editimage_fetch_image
|
|
680
|
+
// gets an <img>). Images are read with CORS, so the CORS host list, the proxy and the upload timeout
|
|
681
|
+
// aren't needed: fetchImage goes through your server instead.
|
|
682
|
+
"editimage_toolbar",
|
|
683
|
+
"editimage_credentials_hosts",
|
|
684
|
+
"editimage_fetch_image",
|
|
685
|
+
"editimage_cors_hosts",
|
|
686
|
+
"editimage_proxy",
|
|
687
|
+
"editimage_proxy_service_url",
|
|
688
|
+
"editimage_upload_timeout",
|
|
689
|
+
// autocorrect: corrections run in the browser, so Tiny's service address isn't needed.
|
|
690
|
+
"autocorrect_autocorrect",
|
|
691
|
+
"autocorrect_capitalize",
|
|
692
|
+
"autocorrect_service_url",
|
|
693
|
+
// typography: the language, the languages of the menu, the rules (Typograf rule ids), tags left alone.
|
|
694
|
+
"typography_default_lang",
|
|
695
|
+
"typography_langs",
|
|
696
|
+
"typography_rules",
|
|
697
|
+
"typography_ignore",
|
|
698
|
+
// text_patterns: false turns the patterns off; a list (and text_patterns_lookup) is TinyMCE's
|
|
699
|
+
// patterns, run through this editor's formatter and execCommand (index.ts).
|
|
700
|
+
"text_patterns",
|
|
701
|
+
"text_patterns_lookup",
|
|
702
|
+
"template_replace_values",
|
|
703
|
+
"template_preview_replace_values",
|
|
704
|
+
"template_selected_content_classes",
|
|
705
|
+
"template_cdate_classes",
|
|
706
|
+
"template_mdate_classes",
|
|
707
|
+
"template_cdate_format",
|
|
708
|
+
"template_mdate_format"
|
|
130
709
|
]);
|
|
131
710
|
var list = (value) => (Array.isArray(value) ? value.join(" ") : String(value ?? "")).split(/[\s,]+/).filter(Boolean);
|
|
711
|
+
function activePlugins(config, has) {
|
|
712
|
+
return list(config.plugins).filter((name) => BUILT_IN.has(name) || has(RENAMED[name] ?? name));
|
|
713
|
+
}
|
|
714
|
+
function typographyRule(id) {
|
|
715
|
+
if (/\/dash\//.test(id)) return "dashes";
|
|
716
|
+
if (/^common\/punctuation\/(quote|apostrophe)$/.test(id)) return "quotes";
|
|
717
|
+
if (id === "common/punctuation/hellip") return "ellipsis";
|
|
718
|
+
if (id === "common/punctuation/delDoublePunctuation" || id.startsWith("common/space/"))
|
|
719
|
+
return "spaces";
|
|
720
|
+
if (id === "common/symbols/arrow") return "arrows";
|
|
721
|
+
if (id.startsWith("common/symbols/")) return "symbols";
|
|
722
|
+
if (id === "common/number/fraction") return "fractions";
|
|
723
|
+
if (id.startsWith("common/number/")) return "math";
|
|
724
|
+
if (id.startsWith("common/nbsp/")) return "nbsp";
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
var TYPOGRAPHY_TAGS = {
|
|
728
|
+
code: ["code", "code_block"],
|
|
729
|
+
pre: ["code_block"],
|
|
730
|
+
a: ["link"],
|
|
731
|
+
strong: ["bold"],
|
|
732
|
+
b: ["bold"],
|
|
733
|
+
em: ["italic"],
|
|
734
|
+
i: ["italic"],
|
|
735
|
+
blockquote: ["blockquote"]
|
|
736
|
+
};
|
|
737
|
+
function typographyOptions(config) {
|
|
738
|
+
const out = {};
|
|
739
|
+
const lang = config.typography_default_lang;
|
|
740
|
+
const first = Array.isArray(lang) ? lang[0] : lang;
|
|
741
|
+
if (typeof first === "string" && first) out.language = first.replace(/_/g, "-");
|
|
742
|
+
const langs = config.typography_langs;
|
|
743
|
+
const codes = Array.isArray(langs) ? langs : langs && typeof langs === "object" ? Object.keys(langs) : [];
|
|
744
|
+
const languages = codes.filter((c) => typeof c === "string").map((c) => c.replace(/_/g, "-"));
|
|
745
|
+
if (languages.length) out.languages = languages;
|
|
746
|
+
if (Array.isArray(config.typography_rules)) {
|
|
747
|
+
const on = new Set(
|
|
748
|
+
config.typography_rules.map((id) => typeof id === "string" ? typographyRule(id) : null)
|
|
749
|
+
);
|
|
750
|
+
out.rules = Object.fromEntries(
|
|
751
|
+
[
|
|
752
|
+
"quotes",
|
|
753
|
+
"dashes",
|
|
754
|
+
"ellipsis",
|
|
755
|
+
"symbols",
|
|
756
|
+
"arrows",
|
|
757
|
+
"math",
|
|
758
|
+
"fractions",
|
|
759
|
+
"spaces",
|
|
760
|
+
"nbsp"
|
|
761
|
+
].map((rule) => [rule, on.has(rule)])
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
if (Array.isArray(config.typography_ignore)) {
|
|
765
|
+
const ignore = config.typography_ignore.flatMap(
|
|
766
|
+
(tag) => typeof tag === "string" ? TYPOGRAPHY_TAGS[tag.toLowerCase().replace(/\[.*$/, "")] ?? [] : []
|
|
767
|
+
);
|
|
768
|
+
if (ignore.length) out.ignore = [...new Set(ignore)];
|
|
769
|
+
}
|
|
770
|
+
return out;
|
|
771
|
+
}
|
|
132
772
|
function parseFormats(value) {
|
|
133
773
|
if (typeof value !== "string") return void 0;
|
|
134
774
|
return value.split(";").map((item) => item.trim()).filter(Boolean).map((item) => {
|
|
@@ -211,6 +851,23 @@ function toStyleFormats(value) {
|
|
|
211
851
|
return spec ? [{ title, ...spec }] : [];
|
|
212
852
|
});
|
|
213
853
|
}
|
|
854
|
+
function toAiShortcuts(value) {
|
|
855
|
+
return value.flatMap((item) => {
|
|
856
|
+
if (!item || typeof item !== "object") return [];
|
|
857
|
+
const raw = item;
|
|
858
|
+
const title = typeof raw.title === "string" ? raw.title : "";
|
|
859
|
+
if (!title) return [];
|
|
860
|
+
if (Array.isArray(raw.subprompts)) return [{ title, items: toAiShortcuts(raw.subprompts) }];
|
|
861
|
+
if (typeof raw.prompt !== "string") return [];
|
|
862
|
+
return [
|
|
863
|
+
{
|
|
864
|
+
title,
|
|
865
|
+
prompt: raw.prompt,
|
|
866
|
+
...typeof raw.selection === "boolean" ? { selection: raw.selection } : {}
|
|
867
|
+
}
|
|
868
|
+
];
|
|
869
|
+
});
|
|
870
|
+
}
|
|
214
871
|
function mapOptions(config) {
|
|
215
872
|
const unknown = Object.keys(config).filter((key) => !IGNORED.has(key));
|
|
216
873
|
const plugins = [];
|
|
@@ -221,11 +878,18 @@ function mapOptions(config) {
|
|
|
221
878
|
if ((0, import_core.isPluginRegistered)(target)) plugins.push(target);
|
|
222
879
|
else missingPlugins.push(name);
|
|
223
880
|
}
|
|
881
|
+
if (plugins.includes("ai") && !plugins.includes("suggestions")) {
|
|
882
|
+
plugins.splice(plugins.indexOf("ai"), 0, "suggestions");
|
|
883
|
+
}
|
|
884
|
+
if (plugins.includes("mediaembed") && !plugins.includes("media")) {
|
|
885
|
+
plugins.splice(plugins.indexOf("mediaembed"), 0, "media");
|
|
886
|
+
}
|
|
224
887
|
const options = { plugins };
|
|
225
888
|
if (config.toolbar === false) options.toolbar = false;
|
|
226
889
|
else if (Array.isArray(config.toolbar)) options.toolbar = config.toolbar.join(" | ");
|
|
227
890
|
else if (typeof config.toolbar === "string") options.toolbar = config.toolbar;
|
|
228
891
|
if (config.menubar !== void 0) options.menubar = config.menubar;
|
|
892
|
+
if (config.text_patterns === false) options.textPatterns = false;
|
|
229
893
|
if (typeof config.statusbar === "boolean") options.statusbar = config.statusbar;
|
|
230
894
|
if (typeof config.placeholder === "string") options.placeholder = config.placeholder;
|
|
231
895
|
if (config.readonly === true) options.editable = false;
|
|
@@ -265,10 +929,8 @@ function mapOptions(config) {
|
|
|
265
929
|
options.blockFormats = blocks.map(({ label, value }) => ({ label, block: value.toLowerCase() })).filter((f) => known.includes(f.block));
|
|
266
930
|
}
|
|
267
931
|
if (typeof config.language === "string") options.language = config.language.replace("_", "-");
|
|
268
|
-
if (config.toolbar_mode === "sliding" || config.toolbar_mode === "wrap") {
|
|
932
|
+
if (config.toolbar_mode === "floating" || config.toolbar_mode === "sliding" || config.toolbar_mode === "scrolling" || config.toolbar_mode === "wrap") {
|
|
269
933
|
options.toolbarMode = config.toolbar_mode;
|
|
270
|
-
} else if (config.toolbar_mode === "floating" || config.toolbar_mode === "scrolling") {
|
|
271
|
-
options.toolbarMode = "sliding";
|
|
272
934
|
}
|
|
273
935
|
if (config.inline === true) options.mode = "inline";
|
|
274
936
|
if (config.paste_as_text === true) options.pasteAsText = true;
|
|
@@ -283,6 +945,11 @@ function mapOptions(config) {
|
|
|
283
945
|
if (typeof config.invalid_elements === "string")
|
|
284
946
|
options.invalidElements = config.invalid_elements;
|
|
285
947
|
if (typeof config.valid_elements === "string") options.validElements = config.valid_elements;
|
|
948
|
+
if (typeof config.extended_valid_elements === "string")
|
|
949
|
+
options.extendedValidElements = config.extended_valid_elements;
|
|
950
|
+
if (typeof config.custom_elements === "string") options.customElements = config.custom_elements;
|
|
951
|
+
if (config.directionality === "rtl" || config.directionality === "ltr")
|
|
952
|
+
options.direction = config.directionality;
|
|
286
953
|
if (config.valid_styles) options.validStyles = config.valid_styles;
|
|
287
954
|
const fonts = parseFormats(config.font_family_formats);
|
|
288
955
|
if (fonts) options.fontFamilies = fonts;
|
|
@@ -311,343 +978,312 @@ function mapOptions(config) {
|
|
|
311
978
|
}
|
|
312
979
|
options.filePicker = ({ type, value }) => new Promise(
|
|
313
980
|
(resolve) => pick((url, meta = {}) => resolve({ url, ...meta }), value, {
|
|
314
|
-
filetype: type,
|
|
315
|
-
fieldname: "src"
|
|
316
|
-
})
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
const pluginOptions = {};
|
|
320
|
-
if (config.autosave_interval || config.autosave_retention || config.autosave_prefix) {
|
|
321
|
-
const seconds = (value) => parseInt(String(value), 10);
|
|
322
|
-
pluginOptions.autosave = {
|
|
323
|
-
...config.autosave_interval ? { delay: seconds(config.autosave_interval) * 1e3 } : {},
|
|
324
|
-
...config.autosave_retention ? { retention: seconds(config.autosave_retention) } : {},
|
|
325
|
-
...config.autosave_prefix ? { key: String(config.autosave_prefix) } : {}
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
if (config.quickbars_selection_toolbar !== void 0 || config.quickbars_insert_toolbar !== void 0) {
|
|
329
|
-
pluginOptions.quickbars = {
|
|
330
|
-
...config.quickbars_selection_toolbar !== void 0 ? { selection: config.quickbars_selection_toolbar } : {},
|
|
331
|
-
...config.quickbars_insert_toolbar !== void 0 ? { insert: config.quickbars_insert_toolbar } : {}
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
if (typeof config.mentions_fetch === "function") {
|
|
335
|
-
const fetch = config.mentions_fetch;
|
|
336
|
-
pluginOptions.mentions = {
|
|
337
|
-
fetch: (term) => new Promise((resolve) => fetch({ term }, resolve))
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
if (config.tinycomments_author) {
|
|
341
|
-
pluginOptions.comments = {
|
|
342
|
-
author: {
|
|
343
|
-
id: String(config.tinycomments_author),
|
|
344
|
-
name: String(config.tinycomments_author_name ?? config.tinycomments_author)
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
if (Object.keys(pluginOptions).length) options.pluginOptions = pluginOptions;
|
|
349
|
-
return { options, unknown, missingPlugins };
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// src/editor.ts
|
|
353
|
-
var import_core2 = require("@novaprose/core");
|
|
354
|
-
|
|
355
|
-
// src/dialog.ts
|
|
356
|
-
var uid = 0;
|
|
357
|
-
var nextId = () => `nova-compat-field-${++uid}`;
|
|
358
|
-
function el(tag, className, text) {
|
|
359
|
-
const node = document.createElement(tag);
|
|
360
|
-
if (className) node.className = className;
|
|
361
|
-
if (text !== void 0) node.textContent = text;
|
|
362
|
-
return node;
|
|
363
|
-
}
|
|
364
|
-
function safeHtml(html) {
|
|
365
|
-
const template = document.createElement("template");
|
|
366
|
-
template.innerHTML = html;
|
|
367
|
-
template.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach((node) => node.remove());
|
|
368
|
-
template.content.querySelectorAll("*").forEach((node) => {
|
|
369
|
-
for (const attr of [...node.attributes]) {
|
|
370
|
-
const value = attr.value.trim().toLowerCase();
|
|
371
|
-
if (attr.name.startsWith("on") || /^(javascript|vbscript|data):/.test(value)) {
|
|
372
|
-
node.removeAttribute(attr.name);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
return template.content;
|
|
377
|
-
}
|
|
378
|
-
function openSpecDialog(editor, spec, reopen) {
|
|
379
|
-
const controls = /* @__PURE__ */ new Map();
|
|
380
|
-
const tabs = /* @__PURE__ */ new Map();
|
|
381
|
-
let currentTab = "";
|
|
382
|
-
let closedByApi = false;
|
|
383
|
-
let handle = null;
|
|
384
|
-
const notifyChange = (name) => spec.onChange?.(api, { name });
|
|
385
|
-
function field(item, input) {
|
|
386
|
-
const id = nextId();
|
|
387
|
-
input.id = id;
|
|
388
|
-
const wrap = el("div", "nova-field");
|
|
389
|
-
if (item.label) {
|
|
390
|
-
const label = el("label", "nova-label", item.label);
|
|
391
|
-
label.htmlFor = id;
|
|
392
|
-
wrap.append(label);
|
|
393
|
-
}
|
|
394
|
-
wrap.append(input);
|
|
395
|
-
return wrap;
|
|
396
|
-
}
|
|
397
|
-
function render(item) {
|
|
398
|
-
const name = item.name ?? "";
|
|
399
|
-
const enabled = item.enabled !== false && item.disabled !== true;
|
|
400
|
-
switch (item.type) {
|
|
401
|
-
case "input":
|
|
402
|
-
case "urlinput":
|
|
403
|
-
case "colorinput": {
|
|
404
|
-
const input = el("input", "nova-input");
|
|
405
|
-
input.type = item.type === "colorinput" ? "color" : item.type === "urlinput" ? "url" : "text";
|
|
406
|
-
if (item.inputMode) input.inputMode = item.inputMode;
|
|
407
|
-
if (item.placeholder) input.placeholder = item.placeholder;
|
|
408
|
-
input.disabled = !enabled;
|
|
409
|
-
input.addEventListener("input", () => notifyChange(name));
|
|
410
|
-
if (name) {
|
|
411
|
-
controls.set(name, {
|
|
412
|
-
// urlinput хранит { value }, остальные — строку.
|
|
413
|
-
get: () => item.type === "urlinput" ? { value: input.value } : input.value,
|
|
414
|
-
set: (value) => {
|
|
415
|
-
input.value = String(
|
|
416
|
-
item.type === "urlinput" && value && typeof value === "object" ? value.value ?? "" : value ?? ""
|
|
417
|
-
);
|
|
418
|
-
},
|
|
419
|
-
focus: () => input.focus(),
|
|
420
|
-
setEnabled: (on) => input.disabled = !on
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
return field(item, input);
|
|
424
|
-
}
|
|
425
|
-
case "textarea": {
|
|
426
|
-
const input = el("textarea", "nova-input");
|
|
427
|
-
input.rows = item.maximized ? 10 : 4;
|
|
428
|
-
if (item.placeholder) input.placeholder = item.placeholder;
|
|
429
|
-
input.disabled = !enabled;
|
|
430
|
-
input.addEventListener("input", () => notifyChange(name));
|
|
431
|
-
if (name) {
|
|
432
|
-
controls.set(name, {
|
|
433
|
-
get: () => input.value,
|
|
434
|
-
set: (value) => input.value = String(value ?? ""),
|
|
435
|
-
focus: () => input.focus(),
|
|
436
|
-
setEnabled: (on) => input.disabled = !on
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
return field(item, input);
|
|
440
|
-
}
|
|
441
|
-
case "checkbox": {
|
|
442
|
-
const input = el("input", "nova-checkbox");
|
|
443
|
-
input.type = "checkbox";
|
|
444
|
-
input.id = nextId();
|
|
445
|
-
input.disabled = !enabled;
|
|
446
|
-
input.addEventListener("change", () => notifyChange(name));
|
|
447
|
-
const label = el("label", void 0, item.label ?? "");
|
|
448
|
-
label.htmlFor = input.id;
|
|
449
|
-
if (name) {
|
|
450
|
-
controls.set(name, {
|
|
451
|
-
get: () => input.checked,
|
|
452
|
-
set: (value) => input.checked = Boolean(value),
|
|
453
|
-
focus: () => input.focus(),
|
|
454
|
-
setEnabled: (on) => input.disabled = !on
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
const wrap = el("div", "nova-field nova-field-inline");
|
|
458
|
-
wrap.append(input, label);
|
|
459
|
-
return wrap;
|
|
460
|
-
}
|
|
461
|
-
case "selectbox":
|
|
462
|
-
case "listbox": {
|
|
463
|
-
const select = el("select", "nova-input nova-select");
|
|
464
|
-
for (const option of item.items ?? []) {
|
|
465
|
-
const node = el("option", void 0, option.text);
|
|
466
|
-
node.value = option.value;
|
|
467
|
-
select.append(node);
|
|
468
|
-
}
|
|
469
|
-
select.disabled = !enabled;
|
|
470
|
-
select.addEventListener("change", () => notifyChange(name));
|
|
471
|
-
if (name) {
|
|
472
|
-
controls.set(name, {
|
|
473
|
-
get: () => select.value,
|
|
474
|
-
set: (value) => select.value = String(value ?? ""),
|
|
475
|
-
focus: () => select.focus(),
|
|
476
|
-
setEnabled: (on) => select.disabled = !on
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
return field(item, select);
|
|
480
|
-
}
|
|
481
|
-
case "button": {
|
|
482
|
-
const button = el(
|
|
483
|
-
"button",
|
|
484
|
-
item.primary || item.buttonType === "primary" ? "nova-button nova-button-primary" : "nova-button",
|
|
485
|
-
item.text ?? ""
|
|
486
|
-
);
|
|
487
|
-
button.type = "button";
|
|
488
|
-
button.disabled = !enabled;
|
|
489
|
-
button.addEventListener("click", () => spec.onAction?.(api, { name }));
|
|
490
|
-
if (name) {
|
|
491
|
-
controls.set(name, {
|
|
492
|
-
get: () => void 0,
|
|
493
|
-
set: () => {
|
|
494
|
-
},
|
|
495
|
-
focus: () => button.focus(),
|
|
496
|
-
setEnabled: (on) => button.disabled = !on
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
return button;
|
|
500
|
-
}
|
|
501
|
-
case "htmlpanel": {
|
|
502
|
-
const panel = el("div", "nova-compat-html");
|
|
503
|
-
panel.append(safeHtml(item.html ?? ""));
|
|
504
|
-
return panel;
|
|
505
|
-
}
|
|
506
|
-
case "alertbanner": {
|
|
507
|
-
const banner = el("p", `nova-compat-alert is-${item.level ?? "info"}`, item.text ?? "");
|
|
508
|
-
banner.setAttribute("role", item.level === "error" ? "alert" : "status");
|
|
509
|
-
return banner;
|
|
510
|
-
}
|
|
511
|
-
case "label": {
|
|
512
|
-
const group = el("div", "nova-compat-group");
|
|
513
|
-
group.append(el("p", "nova-label", item.label ?? ""));
|
|
514
|
-
for (const child of item.items ?? []) {
|
|
515
|
-
const node = render(child);
|
|
516
|
-
if (node) group.append(node);
|
|
517
|
-
}
|
|
518
|
-
return group;
|
|
519
|
-
}
|
|
520
|
-
case "grid":
|
|
521
|
-
case "bar": {
|
|
522
|
-
const grid = el("div", "nova-compat-grid");
|
|
523
|
-
const columns = item.type === "bar" ? item.items?.length ?? 1 : item.columns === "auto" ? 2 : item.columns ?? 2;
|
|
524
|
-
grid.style.gridTemplateColumns = `repeat(${Number(columns) || 2}, minmax(0, 1fr))`;
|
|
525
|
-
for (const child of item.items ?? []) {
|
|
526
|
-
const node = render(child);
|
|
527
|
-
if (node) grid.append(node);
|
|
528
|
-
}
|
|
529
|
-
return grid;
|
|
530
|
-
}
|
|
531
|
-
default:
|
|
532
|
-
console.warn(`[nova] tinymce-compat: dialog component "${item.type}" is not supported yet`);
|
|
533
|
-
return null;
|
|
534
|
-
}
|
|
981
|
+
filetype: type,
|
|
982
|
+
fieldname: "src"
|
|
983
|
+
})
|
|
984
|
+
);
|
|
535
985
|
}
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
986
|
+
const pluginOptions = {};
|
|
987
|
+
if (config.autosave_interval || config.autosave_retention || config.autosave_prefix) {
|
|
988
|
+
const seconds = (value) => parseInt(String(value), 10);
|
|
989
|
+
pluginOptions.autosave = {
|
|
990
|
+
...config.autosave_interval ? { delay: seconds(config.autosave_interval) * 1e3 } : {},
|
|
991
|
+
...config.autosave_retention ? { retention: seconds(config.autosave_retention) } : {},
|
|
992
|
+
...config.autosave_prefix ? { key: String(config.autosave_prefix) } : {}
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
if (config.quickbars_selection_toolbar !== void 0 || config.quickbars_insert_toolbar !== void 0) {
|
|
996
|
+
pluginOptions.quickbars = {
|
|
997
|
+
...config.quickbars_selection_toolbar !== void 0 ? { selection: config.quickbars_selection_toolbar } : {},
|
|
998
|
+
...config.quickbars_insert_toolbar !== void 0 ? { insert: config.quickbars_insert_toolbar } : {}
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
if (typeof config.mentions_fetch === "function") {
|
|
1002
|
+
const fetch = config.mentions_fetch;
|
|
1003
|
+
pluginOptions.mentions = {
|
|
1004
|
+
fetch: (term) => new Promise((resolve) => fetch({ term }, resolve))
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
if (config.tinycomments_author) {
|
|
1008
|
+
pluginOptions.comments = {
|
|
1009
|
+
author: {
|
|
1010
|
+
id: String(config.tinycomments_author),
|
|
1011
|
+
name: String(config.tinycomments_author_name ?? config.tinycomments_author)
|
|
551
1012
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
if (Array.isArray(config.codesample_languages)) {
|
|
1016
|
+
const languages = config.codesample_languages.flatMap((item) => {
|
|
1017
|
+
const { text, value } = item ?? {};
|
|
1018
|
+
return typeof value === "string" && value ? [{ value, label: typeof text === "string" && text ? text : value }] : [];
|
|
557
1019
|
});
|
|
558
|
-
|
|
559
|
-
for (const item of spec.body.items) {
|
|
560
|
-
const node = render(item);
|
|
561
|
-
if (node) body.append(node);
|
|
562
|
-
}
|
|
1020
|
+
pluginOptions.codesample = { languages };
|
|
563
1021
|
}
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
1022
|
+
const detailsState = (value) => value === "inherited" || value === "collapsed" || value === "expanded" ? value : void 0;
|
|
1023
|
+
if (config.details_initial_state || config.details_serialized_state) {
|
|
1024
|
+
pluginOptions.accordion = {
|
|
1025
|
+
...detailsState(config.details_initial_state) ? { initialState: detailsState(config.details_initial_state) } : {},
|
|
1026
|
+
...detailsState(config.details_serialized_state) ? { serializedState: detailsState(config.details_serialized_state) } : {}
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
if (list(config.plugins).includes("tableofcontents")) {
|
|
1030
|
+
pluginOptions.tableofcontents = {
|
|
1031
|
+
className: typeof config.tableofcontents_class === "string" ? config.tableofcontents_class : "mce-toc",
|
|
1032
|
+
titleTag: typeof config.tableofcontents_header === "string" ? config.tableofcontents_header : "h2",
|
|
1033
|
+
...config.tableofcontents_depth !== void 0 ? { depth: Number(config.tableofcontents_depth) } : {},
|
|
1034
|
+
...config.tableofcontents_orderedlist ? { orderedList: true } : {},
|
|
1035
|
+
...config.tableofcontents_includeheader === false ? { title: "" } : {}
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
if (Array.isArray(config.casechange_title_case_minors)) {
|
|
1039
|
+
pluginOptions.casechange = {
|
|
1040
|
+
titleCaseMinors: config.casechange_title_case_minors.map(String)
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
if (config.permanentpen_properties && typeof config.permanentpen_properties === "object") {
|
|
1044
|
+
pluginOptions.permanentpen = { properties: { ...config.permanentpen_properties } };
|
|
1045
|
+
}
|
|
1046
|
+
if (config.visualchars_default_state === true) pluginOptions.visualchars = { default: true };
|
|
1047
|
+
const importcss = Object.fromEntries(
|
|
1048
|
+
[
|
|
1049
|
+
["append", config.importcss_append],
|
|
1050
|
+
["fileFilter", config.importcss_file_filter],
|
|
1051
|
+
["selectorFilter", config.importcss_selector_filter],
|
|
1052
|
+
["groups", config.importcss_groups],
|
|
1053
|
+
["exclusive", config.importcss_exclusive],
|
|
1054
|
+
["converter", config.importcss_selector_converter]
|
|
1055
|
+
].filter(([, value]) => value !== void 0)
|
|
1056
|
+
);
|
|
1057
|
+
if (Object.keys(importcss).length) pluginOptions.importcss = importcss;
|
|
1058
|
+
const templates = config.templates;
|
|
1059
|
+
const template = Object.fromEntries(
|
|
1060
|
+
[
|
|
1061
|
+
[
|
|
1062
|
+
"templates",
|
|
1063
|
+
typeof templates === "function" ? () => new Promise(
|
|
1064
|
+
(resolve) => templates(resolve)
|
|
1065
|
+
) : templates
|
|
1066
|
+
],
|
|
1067
|
+
["values", config.template_replace_values],
|
|
1068
|
+
["previewValues", config.template_preview_replace_values],
|
|
1069
|
+
["selectedContentClasses", config.template_selected_content_classes],
|
|
1070
|
+
["creationDateClasses", config.template_cdate_classes],
|
|
1071
|
+
["modifiedDateClasses", config.template_mdate_classes],
|
|
1072
|
+
["creationDateFormat", config.template_cdate_format],
|
|
1073
|
+
["modifiedDateFormat", config.template_mdate_format]
|
|
1074
|
+
].filter(([, value]) => value !== void 0)
|
|
1075
|
+
);
|
|
1076
|
+
if (Object.keys(template).length) pluginOptions.template = template;
|
|
1077
|
+
const spellchecker = {};
|
|
1078
|
+
if (typeof config.spellchecker_active === "boolean")
|
|
1079
|
+
spellchecker.active = config.spellchecker_active;
|
|
1080
|
+
const spellLanguage = config.content_language ?? config.spellchecker_language;
|
|
1081
|
+
if (typeof spellLanguage === "string" && spellLanguage)
|
|
1082
|
+
spellchecker.language = spellLanguage.replace(/_/g, "-");
|
|
1083
|
+
if (typeof config.spellchecker_languages === "string") {
|
|
1084
|
+
spellchecker.languages = config.spellchecker_languages.split(",").map((pair) => pair.split("=")).filter(
|
|
1085
|
+
(pair) => pair.length === 2 && !!pair[0].trim() && !!pair[1].trim()
|
|
1086
|
+
).map(([name, code]) => ({ name: name.trim(), code: code.trim().replace(/_/g, "-") }));
|
|
1087
|
+
}
|
|
1088
|
+
const ignore = config.spellchecker_ignore_list;
|
|
1089
|
+
const ignored = Array.isArray(ignore) ? ignore : ignore && typeof ignore === "object" ? Object.values(ignore).flatMap((words) => Array.isArray(words) ? words : []) : [];
|
|
1090
|
+
if (ignored.length)
|
|
1091
|
+
spellchecker.ignore = ignored.filter((w) => typeof w === "string");
|
|
1092
|
+
if (typeof config.spellchecker_check === "function")
|
|
1093
|
+
spellchecker.check = config.spellchecker_check;
|
|
1094
|
+
if (typeof config.spellchecker_languagetool_url === "string")
|
|
1095
|
+
spellchecker.languageTool = { url: config.spellchecker_languagetool_url };
|
|
1096
|
+
if (Object.keys(spellchecker).length) pluginOptions.spellchecker = spellchecker;
|
|
1097
|
+
if (list(config.plugins).includes("a11ychecker")) {
|
|
1098
|
+
const a11y = {
|
|
1099
|
+
allowDecorativeImages: (config.a11ychecker_allow_decorative_images ?? config.a11y_advanced_options) === true
|
|
1100
|
+
};
|
|
1101
|
+
if (typeof config.a11ychecker_level === "string") {
|
|
1102
|
+
a11y.level = config.a11ychecker_level.toLowerCase();
|
|
588
1103
|
}
|
|
589
|
-
|
|
1104
|
+
if (typeof config.a11ychecker_ignored_rules === "string") {
|
|
1105
|
+
a11y.ignoredRules = config.a11ychecker_ignored_rules.split(",").map((rule) => rule.trim()).filter(Boolean);
|
|
1106
|
+
}
|
|
1107
|
+
if (typeof config.a11ychecker_alt_text_max_length === "number") {
|
|
1108
|
+
a11y.altTextMaxLength = config.a11ychecker_alt_text_max_length;
|
|
1109
|
+
}
|
|
1110
|
+
const filter = config.a11ychecker_filter_issue;
|
|
1111
|
+
if (typeof filter === "function") {
|
|
1112
|
+
a11y.filterIssue = (issue) => filter({
|
|
1113
|
+
...issue,
|
|
1114
|
+
id: issue.rule,
|
|
1115
|
+
contentID: issue.text
|
|
1116
|
+
}) !== false;
|
|
1117
|
+
}
|
|
1118
|
+
pluginOptions.a11ychecker = a11y;
|
|
590
1119
|
}
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
1120
|
+
const aiShortcuts = config.ai_shortcuts;
|
|
1121
|
+
if (aiShortcuts === false || Array.isArray(aiShortcuts) && !aiShortcuts.length) {
|
|
1122
|
+
pluginOptions.ai = { shortcuts: false };
|
|
1123
|
+
} else if (Array.isArray(aiShortcuts)) {
|
|
1124
|
+
pluginOptions.ai = { shortcuts: toAiShortcuts(aiShortcuts) };
|
|
1125
|
+
}
|
|
1126
|
+
const email = {};
|
|
1127
|
+
if (["string", "function"].includes(typeof config.inlinecss_selector_filter) || config.inlinecss_selector_filter instanceof RegExp)
|
|
1128
|
+
email.selectorFilter = config.inlinecss_selector_filter;
|
|
1129
|
+
if (["string", "function"].includes(typeof config.inlinecss_file_filter) || config.inlinecss_file_filter instanceof RegExp)
|
|
1130
|
+
email.fileFilter = config.inlinecss_file_filter;
|
|
1131
|
+
if (Object.keys(email).length) pluginOptions.email = email;
|
|
1132
|
+
const autocorrect = {};
|
|
1133
|
+
if (typeof config.autocorrect_autocorrect === "boolean")
|
|
1134
|
+
autocorrect.autocorrect = config.autocorrect_autocorrect;
|
|
1135
|
+
if (typeof config.autocorrect_capitalize === "boolean")
|
|
1136
|
+
autocorrect.capitalize = config.autocorrect_capitalize;
|
|
1137
|
+
if (Object.keys(autocorrect).length) pluginOptions.autocorrect = autocorrect;
|
|
1138
|
+
const linkchecker = {};
|
|
1139
|
+
if (typeof config.linkchecker_service_url === "string")
|
|
1140
|
+
linkchecker.serviceUrl = config.linkchecker_service_url;
|
|
1141
|
+
const preprocess = config.linkchecker_preprocess;
|
|
1142
|
+
if (typeof preprocess === "function") {
|
|
1143
|
+
linkchecker.preprocess = (url) => {
|
|
1144
|
+
const out = preprocess({ url });
|
|
1145
|
+
return typeof out?.url === "string" ? out.url : url;
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
if (Object.keys(linkchecker).length) pluginOptions.linkchecker = linkchecker;
|
|
1149
|
+
if (plugins.includes("pageembed")) {
|
|
1150
|
+
const classes = config.tiny_pageembed_classes;
|
|
1151
|
+
pluginOptions.pageembed = {
|
|
1152
|
+
className: "tiny-pageembed",
|
|
1153
|
+
sizes: Array.isArray(classes) ? classes.filter(
|
|
1154
|
+
(size) => !!size && typeof size.value === "string"
|
|
1155
|
+
).map((size) => ({
|
|
1156
|
+
value: size.value,
|
|
1157
|
+
...typeof size.text === "string" ? { text: size.text } : {}
|
|
1158
|
+
})) : ["21by9", "16by9", "4by3", "1by1"].map((ratio) => ({
|
|
1159
|
+
value: `tiny-pageembed--${ratio}`
|
|
1160
|
+
})),
|
|
1161
|
+
inlineStyles: config.tiny_pageembed_inline_styles === true
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
if (plugins.includes("fullpagehtml")) {
|
|
1165
|
+
const fullpagehtml = {};
|
|
1166
|
+
const pick = (option, key) => {
|
|
1167
|
+
if (typeof config[option] === "string") fullpagehtml[key] = config[option];
|
|
1168
|
+
};
|
|
1169
|
+
pick("fullpagehtml_default_doctype", "doctype");
|
|
1170
|
+
pick("fullpagehtml_default_title", "title");
|
|
1171
|
+
pick("fullpagehtml_default_encoding", "encoding");
|
|
1172
|
+
pick("fullpagehtml_default_body_style", "bodyStyle");
|
|
1173
|
+
if (config.fullpagehtml_hide_in_source_view === true) fullpagehtml.hideInSourceView = true;
|
|
1174
|
+
if (Object.keys(fullpagehtml).length) pluginOptions.fullpagehtml = fullpagehtml;
|
|
1175
|
+
}
|
|
1176
|
+
if (plugins.includes("mediaembed")) {
|
|
1177
|
+
const mediaembed = {
|
|
1178
|
+
className: "ephox-summary-card",
|
|
1179
|
+
inlineStyles: config.mediaembed_inline_styles === true
|
|
1180
|
+
};
|
|
1181
|
+
if (typeof config.mediaembed_service_url === "string" && config.mediaembed_service_url)
|
|
1182
|
+
mediaembed.serviceUrl = config.mediaembed_service_url;
|
|
1183
|
+
const maxWidth = Number(config.mediaembed_max_width);
|
|
1184
|
+
if (config.mediaembed_max_width !== void 0 && Number.isFinite(maxWidth))
|
|
1185
|
+
mediaembed.maxWidth = maxWidth;
|
|
1186
|
+
pluginOptions.mediaembed = mediaembed;
|
|
1187
|
+
}
|
|
1188
|
+
const valueSeries = config.advtable_value_series;
|
|
1189
|
+
if (plugins.includes("advtable") && valueSeries && typeof valueSeries === "object") {
|
|
1190
|
+
const series = {};
|
|
1191
|
+
for (const [name, def] of Object.entries(valueSeries)) {
|
|
1192
|
+
const { title, generator } = def ?? {};
|
|
1193
|
+
if (typeof title !== "string" || typeof generator !== "function") continue;
|
|
1194
|
+
let prev;
|
|
1195
|
+
series[name] = {
|
|
1196
|
+
title,
|
|
1197
|
+
value: (index) => {
|
|
1198
|
+
if (index === 0) prev = void 0;
|
|
1199
|
+
const info = {
|
|
1200
|
+
sectionType: "tbody",
|
|
1201
|
+
cellType: "td",
|
|
1202
|
+
getRowType: () => "body",
|
|
1203
|
+
classes: [],
|
|
1204
|
+
direction: "column",
|
|
1205
|
+
prev
|
|
1206
|
+
};
|
|
1207
|
+
const out = generator(
|
|
1208
|
+
info,
|
|
1209
|
+
index,
|
|
1210
|
+
0
|
|
1211
|
+
);
|
|
1212
|
+
prev = out;
|
|
1213
|
+
const value = out?.value;
|
|
1214
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : void 0;
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
627
1217
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
if (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
1218
|
+
if (Object.keys(series).length) pluginOptions.advtable = { series };
|
|
1219
|
+
}
|
|
1220
|
+
if (plugins.includes("editimage")) {
|
|
1221
|
+
const editimage = {};
|
|
1222
|
+
if (typeof config.editimage_toolbar === "string") editimage.toolbar = config.editimage_toolbar;
|
|
1223
|
+
if (Array.isArray(config.editimage_credentials_hosts))
|
|
1224
|
+
editimage.credentialsHosts = config.editimage_credentials_hosts.filter(
|
|
1225
|
+
(host) => typeof host === "string"
|
|
1226
|
+
);
|
|
1227
|
+
const fetchImage = config.editimage_fetch_image;
|
|
1228
|
+
if (typeof fetchImage === "function") {
|
|
1229
|
+
editimage.fetchImage = (src) => {
|
|
1230
|
+
const img = document.createElement("img");
|
|
1231
|
+
img.src = src;
|
|
1232
|
+
return fetchImage(img);
|
|
1233
|
+
};
|
|
643
1234
|
}
|
|
644
|
-
|
|
645
|
-
|
|
1235
|
+
if (Object.keys(editimage).length) pluginOptions.editimage = editimage;
|
|
1236
|
+
}
|
|
1237
|
+
if (plugins.includes("advcode") && typeof config.advcode_prettify_editor === "boolean")
|
|
1238
|
+
pluginOptions.advcode = { prettify: config.advcode_prettify_editor };
|
|
1239
|
+
const typography = typographyOptions(config);
|
|
1240
|
+
if (Object.keys(typography).length) pluginOptions.typography = typography;
|
|
1241
|
+
if (Object.keys(pluginOptions).length) options.pluginOptions = pluginOptions;
|
|
1242
|
+
return { options, unknown, missingPlugins };
|
|
646
1243
|
}
|
|
647
1244
|
|
|
648
1245
|
// src/editor.ts
|
|
1246
|
+
var import_core2 = require("@novaprose/core");
|
|
649
1247
|
var import_prosemirror_state = require("prosemirror-state");
|
|
650
|
-
var
|
|
1248
|
+
var dialogs = null;
|
|
1249
|
+
var dialogsLoading = null;
|
|
1250
|
+
function loadDialogs() {
|
|
1251
|
+
dialogsLoading ??= Promise.resolve().then(() => (init_dialog2(), dialog_exports)).then((module2) => dialogs = module2);
|
|
1252
|
+
return dialogsLoading;
|
|
1253
|
+
}
|
|
1254
|
+
function openDialog(core, spec, reopen) {
|
|
1255
|
+
if (dialogs) return dialogs.openSpecDialog(core, spec, reopen);
|
|
1256
|
+
let real = null;
|
|
1257
|
+
let data = { ...spec.initialData ?? {} };
|
|
1258
|
+
const queue = [];
|
|
1259
|
+
void loadDialogs().then(
|
|
1260
|
+
(module2) => {
|
|
1261
|
+
real = module2.openSpecDialog(core, { ...spec, initialData: data }, reopen);
|
|
1262
|
+
for (const call of queue.splice(0)) call(real);
|
|
1263
|
+
},
|
|
1264
|
+
(error) => console.error("[nova] windowManager: could not load dialogs", error)
|
|
1265
|
+
);
|
|
1266
|
+
const later = (method) => (...args) => {
|
|
1267
|
+
const call = (api) => api[method](...args);
|
|
1268
|
+
if (real) call(real);
|
|
1269
|
+
else queue.push(call);
|
|
1270
|
+
};
|
|
1271
|
+
return {
|
|
1272
|
+
getData: () => real ? real.getData() : { ...data },
|
|
1273
|
+
setData: (next) => {
|
|
1274
|
+
if (real) real.setData(next);
|
|
1275
|
+
else data = { ...data, ...next };
|
|
1276
|
+
},
|
|
1277
|
+
close: later("close"),
|
|
1278
|
+
block: later("block"),
|
|
1279
|
+
unblock: later("unblock"),
|
|
1280
|
+
focus: later("focus"),
|
|
1281
|
+
disable: later("disable"),
|
|
1282
|
+
enable: later("enable"),
|
|
1283
|
+
showTab: later("showTab"),
|
|
1284
|
+
redial: later("redial")
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
651
1287
|
var COMMANDS = {
|
|
652
1288
|
bold: "bold",
|
|
653
1289
|
italic: "italic",
|
|
@@ -670,6 +1306,69 @@ var COMMANDS = {
|
|
|
670
1306
|
inserthorizontalrule: "horizontalRule",
|
|
671
1307
|
mceblockquote: "blockquote"
|
|
672
1308
|
};
|
|
1309
|
+
var PLUGIN_COMMANDS = {
|
|
1310
|
+
mcelowercase: "lowercase",
|
|
1311
|
+
mceuppercase: "uppercase",
|
|
1312
|
+
mcetitlecase: "titlecase",
|
|
1313
|
+
mcetoggleformatpainter: "formatpainter",
|
|
1314
|
+
mcetogglepermanentpen: "permanentpen",
|
|
1315
|
+
mceconfigurepermanentpen: "configurepermanentpen",
|
|
1316
|
+
mcevisualchars: "visualchars",
|
|
1317
|
+
mcesave: "save",
|
|
1318
|
+
mcecancel: "cancel",
|
|
1319
|
+
mcetemplate: "template",
|
|
1320
|
+
mceinsertfootnote: "footnotes",
|
|
1321
|
+
mceupdatefootnotes: "footnotesupdate",
|
|
1322
|
+
mcespellcheckdialog: "spellcheckdialog",
|
|
1323
|
+
mcetypography: "typography",
|
|
1324
|
+
mcecodeeditor: "code",
|
|
1325
|
+
mceimagerotateleft: "rotateleft",
|
|
1326
|
+
mceimagerotateright: "rotateright",
|
|
1327
|
+
mceimageflipvertical: "flipv",
|
|
1328
|
+
mceimagefliphorizontal: "fliph",
|
|
1329
|
+
mceeditimage: "editimage",
|
|
1330
|
+
mcefullpagehtmlproperties: "fullpagehtml"
|
|
1331
|
+
};
|
|
1332
|
+
var SPELLCHECK_COMMANDS = /* @__PURE__ */ new Set([
|
|
1333
|
+
"mcespellcheckenable",
|
|
1334
|
+
"mcespellcheckdisable",
|
|
1335
|
+
"mcespellcheckupdate",
|
|
1336
|
+
"mcespellcheckdialogclose"
|
|
1337
|
+
]);
|
|
1338
|
+
var ADVTABLE_COMMANDS = {
|
|
1339
|
+
mceadvancedtablesort: () => ({ command: "dialog" }),
|
|
1340
|
+
mcesorttablebycolumnasc: () => ({ command: "sort", value: { by: "column", direction: "asc" } }),
|
|
1341
|
+
mcesorttablebycolumndesc: () => ({
|
|
1342
|
+
command: "sort",
|
|
1343
|
+
value: { by: "column", direction: "desc" }
|
|
1344
|
+
}),
|
|
1345
|
+
mcesorttablebyrowasc: () => ({ command: "sort", value: { by: "row", direction: "asc" } }),
|
|
1346
|
+
mcesorttablebyrowdesc: () => ({ command: "sort", value: { by: "row", direction: "desc" } }),
|
|
1347
|
+
// { sortby: 'row' | 'column', roworcol: '0', sort: 'table' | 'selection' | …, order }
|
|
1348
|
+
mcesorttableadvanced: (value) => {
|
|
1349
|
+
const v = value && typeof value === "object" ? value : {};
|
|
1350
|
+
const index = Number(v.roworcol);
|
|
1351
|
+
return {
|
|
1352
|
+
command: "sort",
|
|
1353
|
+
value: {
|
|
1354
|
+
by: v.sortby === "row" ? "row" : "column",
|
|
1355
|
+
...Number.isInteger(index) && index >= 0 ? { index } : {},
|
|
1356
|
+
direction: v.order === "descending" ? "desc" : "asc",
|
|
1357
|
+
scope: v.sort === "selection" ? "selection" : "table"
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
},
|
|
1361
|
+
mcetabletoggleseries: (value) => ({
|
|
1362
|
+
command: "series",
|
|
1363
|
+
value: value?.name
|
|
1364
|
+
})
|
|
1365
|
+
};
|
|
1366
|
+
var ACCORDION_COMMANDS = /* @__PURE__ */ new Set([
|
|
1367
|
+
"insertaccordion",
|
|
1368
|
+
"removeaccordion",
|
|
1369
|
+
"toggleaccordion",
|
|
1370
|
+
"toggleallaccordions"
|
|
1371
|
+
]);
|
|
673
1372
|
var FORMAT_BLOCKS = {
|
|
674
1373
|
p: "paragraph",
|
|
675
1374
|
h1: "h1",
|
|
@@ -801,7 +1500,7 @@ function buttonApi(compat) {
|
|
|
801
1500
|
enabled = value;
|
|
802
1501
|
compat.core.updateUI();
|
|
803
1502
|
},
|
|
804
|
-
//
|
|
1503
|
+
// Compatibility with older versions of the API.
|
|
805
1504
|
isDisabled: () => !enabled,
|
|
806
1505
|
setDisabled: (value) => {
|
|
807
1506
|
enabled = !value;
|
|
@@ -815,6 +1514,11 @@ var CompatEditor = class {
|
|
|
815
1514
|
core;
|
|
816
1515
|
targetElm;
|
|
817
1516
|
settings;
|
|
1517
|
+
/**
|
|
1518
|
+
* The plugins by their TinyMCE names (`editor.plugins.lists`): the listed ones that work here, and
|
|
1519
|
+
* what your own plugins return. inlinecss has `getContent()`: the content with its styles inline.
|
|
1520
|
+
*/
|
|
1521
|
+
plugins = {};
|
|
818
1522
|
initialized = false;
|
|
819
1523
|
removed = false;
|
|
820
1524
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -825,25 +1529,29 @@ var CompatEditor = class {
|
|
|
825
1529
|
this.targetElm = target;
|
|
826
1530
|
this.id = id;
|
|
827
1531
|
this.settings = settings;
|
|
1532
|
+
setTimeout(() => void loadDialogs().catch(() => {
|
|
1533
|
+
}), 0);
|
|
828
1534
|
}
|
|
829
|
-
// ----------
|
|
1535
|
+
// ---------- content ----------
|
|
830
1536
|
getContent(args = {}) {
|
|
831
1537
|
const event = { format: args.format ?? "html", content: "" };
|
|
832
|
-
event.content = event.format === "text" ? this.core.getText() : this.core.getHTML();
|
|
1538
|
+
event.content = event.format === "text" ? this.core.getText() : this.core.getHTML({ fullPage: args.fullpagehtml !== false });
|
|
1539
|
+
const prettify = args.prettify === true || this.settings.advcode_prettify_getcontent === true && this.core.hasPlugin("advcode");
|
|
1540
|
+
if (prettify && event.format !== "text") event.content = (0, import_core2.prettyHTML)(event.content);
|
|
833
1541
|
this.fire("GetContent", event);
|
|
834
1542
|
return event.content;
|
|
835
1543
|
}
|
|
836
1544
|
setContent(content, args = {}) {
|
|
837
1545
|
const event = { content, ...args };
|
|
838
1546
|
this.fire("BeforeSetContent", event);
|
|
839
|
-
this.core.setContent(event.content);
|
|
1547
|
+
this.core.setContent(event.content, { fullPage: args.fullpagehtml !== false });
|
|
840
1548
|
this.fire("SetContent", event);
|
|
841
1549
|
return event.content;
|
|
842
1550
|
}
|
|
843
1551
|
/**
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
*
|
|
1552
|
+
* Insert HTML in place of the selection. Blocks (<p>, lists, tables) go in as separate blocks (the
|
|
1553
|
+
* paragraph is split), inline content into the current line. Parsed by the editor's schema: the
|
|
1554
|
+
* same link and markup checks as when content is loaded.
|
|
847
1555
|
*/
|
|
848
1556
|
insertContent(content) {
|
|
849
1557
|
this.core.insertContent(content);
|
|
@@ -872,7 +1580,13 @@ var CompatEditor = class {
|
|
|
872
1580
|
getWin() {
|
|
873
1581
|
return this.core.root.ownerDocument.defaultView;
|
|
874
1582
|
}
|
|
875
|
-
// ----------
|
|
1583
|
+
// ---------- commands ----------
|
|
1584
|
+
/** The value of a command: for ToggleSidebar and ToggleView, the name of the open one. */
|
|
1585
|
+
queryCommandValue(command) {
|
|
1586
|
+
if (command.toLowerCase() === "togglesidebar") return this.core.ui.sidebar.active ?? "";
|
|
1587
|
+
if (command.toLowerCase() === "toggleview") return this.core.ui.view.active ?? "";
|
|
1588
|
+
return "";
|
|
1589
|
+
}
|
|
876
1590
|
execCommand(command, _ui, value) {
|
|
877
1591
|
const name = command.toLowerCase();
|
|
878
1592
|
let done = false;
|
|
@@ -883,9 +1597,56 @@ var CompatEditor = class {
|
|
|
883
1597
|
} else if (name === "mceinsertcontent" || name === "inserthtml") {
|
|
884
1598
|
this.insertContent(String(value ?? ""));
|
|
885
1599
|
done = true;
|
|
1600
|
+
} else if (name === "toggleview") {
|
|
1601
|
+
this.core.ui.view.toggle(String(value ?? ""));
|
|
1602
|
+
done = true;
|
|
1603
|
+
} else if (name === "togglesidebar") {
|
|
1604
|
+
void this.core.ui.sidebar.toggle(String(value ?? ""));
|
|
1605
|
+
done = true;
|
|
1606
|
+
} else if ((name === "mceaidialog" || name === "mceaidialogclose") && this.core.hasPlugin("ai")) {
|
|
1607
|
+
const options = value && typeof value === "object" ? value : {};
|
|
1608
|
+
const detail = {
|
|
1609
|
+
...typeof options.prompt === "string" ? { prompt: options.prompt } : {},
|
|
1610
|
+
...options.generate === true ? { generate: true } : {},
|
|
1611
|
+
...options.display === false ? { display: false } : {}
|
|
1612
|
+
};
|
|
1613
|
+
this.core.root.dispatchEvent(
|
|
1614
|
+
name === "mceaidialog" ? new CustomEvent("nova-ai-dialog", { detail }) : new CustomEvent("nova-ai-dialog-close")
|
|
1615
|
+
);
|
|
1616
|
+
done = true;
|
|
886
1617
|
} else if (name === "mcesetcontent") {
|
|
887
1618
|
this.setContent(String(value ?? ""));
|
|
888
1619
|
done = true;
|
|
1620
|
+
} else if (name === "mceinserttoc" || name === "mceupdatetoc") {
|
|
1621
|
+
const control = this.core.ui.registry.get(
|
|
1622
|
+
name === "mceinserttoc" ? "tableofcontents" : "tableofcontentsupdate"
|
|
1623
|
+
);
|
|
1624
|
+
if (control?.type === "button") {
|
|
1625
|
+
control.onAction(this.core);
|
|
1626
|
+
done = true;
|
|
1627
|
+
}
|
|
1628
|
+
} else if (ADVTABLE_COMMANDS[name] && this.core.hasPlugin("advtable")) {
|
|
1629
|
+
this.core.root.dispatchEvent(
|
|
1630
|
+
new CustomEvent("nova-advtable", { detail: ADVTABLE_COMMANDS[name](value) })
|
|
1631
|
+
);
|
|
1632
|
+
done = true;
|
|
1633
|
+
} else if (ACCORDION_COMMANDS.has(name)) {
|
|
1634
|
+
done = this.accordionCommand(name, value);
|
|
1635
|
+
} else if (name === "mceinserttemplate" && this.core.hasPlugin("template")) {
|
|
1636
|
+
this.core.root.dispatchEvent(
|
|
1637
|
+
new CustomEvent("nova-insert-template", { detail: String(value ?? "") })
|
|
1638
|
+
);
|
|
1639
|
+
done = true;
|
|
1640
|
+
} else if (SPELLCHECK_COMMANDS.has(name) && this.core.hasPlugin("spellchecker")) {
|
|
1641
|
+
done = this.spellcheckCommand(name);
|
|
1642
|
+
} else if (PLUGIN_COMMANDS[name] || name === "mcetogglestickyformatpainter") {
|
|
1643
|
+
done = this.pluginCommand(name);
|
|
1644
|
+
} else if (name === "codesample") {
|
|
1645
|
+
const button = this.core.ui.registry.get("codesample");
|
|
1646
|
+
if (button?.type === "button") {
|
|
1647
|
+
button.onAction(this.core);
|
|
1648
|
+
done = true;
|
|
1649
|
+
}
|
|
889
1650
|
} else if (name === "selectall") {
|
|
890
1651
|
const { state, dispatch } = this.core.view;
|
|
891
1652
|
dispatch(state.tr.setSelection(new import_prosemirror_state.AllSelection(state.doc)));
|
|
@@ -902,19 +1663,97 @@ var CompatEditor = class {
|
|
|
902
1663
|
if (done) this.fire("ExecCommand", { command, ui: _ui, value });
|
|
903
1664
|
return done;
|
|
904
1665
|
}
|
|
1666
|
+
/**
|
|
1667
|
+
* InsertAccordion / RemoveAccordion — like the accordion button (inside one, remove the frame;
|
|
1668
|
+
* otherwise insert); ToggleAccordion / ToggleAllAccordions — value true expands, false collapses,
|
|
1669
|
+
* no value toggles. Collapsing is a view, not an edit: it doesn't go into the undo history.
|
|
1670
|
+
*/
|
|
1671
|
+
spellcheckCommand(name) {
|
|
1672
|
+
if (name === "mcespellcheckdialogclose") {
|
|
1673
|
+
this.core.ui.closeOverlays();
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
if (name === "mcespellcheckupdate") return true;
|
|
1677
|
+
const toggle = this.core.ui.registry.get("spellchecker");
|
|
1678
|
+
if (!toggle) return false;
|
|
1679
|
+
const on = !!toggle.isActive?.(this.core);
|
|
1680
|
+
if (name === "mcespellcheckenable" !== on) toggle.onAction(this.core);
|
|
1681
|
+
return true;
|
|
1682
|
+
}
|
|
1683
|
+
accordionCommand(name, value) {
|
|
1684
|
+
const { view } = this.core;
|
|
1685
|
+
const { state } = view;
|
|
1686
|
+
const $from = state.selection.$from;
|
|
1687
|
+
let around = null;
|
|
1688
|
+
for (let depth = $from.depth; depth > 0 && !around; depth--) {
|
|
1689
|
+
const node = $from.node(depth);
|
|
1690
|
+
if (node.type.name === "details") {
|
|
1691
|
+
around = { pos: $from.before(depth), open: node.attrs.open !== false };
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if (name === "insertaccordion" || name === "removeaccordion") {
|
|
1695
|
+
if (name === "removeaccordion" !== !!around) return false;
|
|
1696
|
+
const button = this.core.ui.registry.get("accordion");
|
|
1697
|
+
if (button?.type !== "button") return false;
|
|
1698
|
+
button.onAction(this.core);
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
const all = [];
|
|
1702
|
+
if (name === "toggleaccordion") {
|
|
1703
|
+
if (around) all.push(around);
|
|
1704
|
+
} else {
|
|
1705
|
+
state.doc.descendants((node, pos) => {
|
|
1706
|
+
if (node.type.name === "details") all.push({ pos, open: node.attrs.open !== false });
|
|
1707
|
+
return !node.isTextblock;
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
if (!all.length) return false;
|
|
1711
|
+
const open = typeof value === "boolean" ? value : !all.every((d) => d.open);
|
|
1712
|
+
const tr = state.tr;
|
|
1713
|
+
for (const details of all) tr.setNodeAttribute(details.pos, "open", open);
|
|
1714
|
+
view.dispatch(tr.setMeta("addToHistory", false));
|
|
1715
|
+
return true;
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* A command of casechange, formatpainter or permanentpen: like its menu item or button.
|
|
1719
|
+
* mceToggleStickyFormatPainter turns the painter on to stay (a double click on the button), or off.
|
|
1720
|
+
*/
|
|
1721
|
+
pluginCommand(name) {
|
|
1722
|
+
const { registry } = this.core.ui;
|
|
1723
|
+
if (name === "mcetogglestickyformatpainter") {
|
|
1724
|
+
const painter = registry.get("formatpainter");
|
|
1725
|
+
const item2 = registry.getMenuItem("formatpainter");
|
|
1726
|
+
if (painter?.type !== "button" || !item2) return false;
|
|
1727
|
+
if (item2.isActive?.(this.core)) item2.onAction(this.core);
|
|
1728
|
+
else {
|
|
1729
|
+
painter.onAction(this.core);
|
|
1730
|
+
painter.onAction(this.core);
|
|
1731
|
+
}
|
|
1732
|
+
return true;
|
|
1733
|
+
}
|
|
1734
|
+
const item = registry.getMenuItem(PLUGIN_COMMANDS[name]);
|
|
1735
|
+
if (!item || name !== "mcesave" && item.isEnabled?.(this.core) === false) return false;
|
|
1736
|
+
item.onAction(this.core);
|
|
1737
|
+
return true;
|
|
1738
|
+
}
|
|
905
1739
|
queryCommandState(command) {
|
|
906
|
-
const
|
|
907
|
-
|
|
1740
|
+
const lower = command.toLowerCase();
|
|
1741
|
+
const name = COMMANDS[lower];
|
|
1742
|
+
if (name) return this.core.isActive(name);
|
|
1743
|
+
if (lower === "mcetoggleformatpainter" || lower === "mcetogglepermanentpen") {
|
|
1744
|
+
return !!this.core.ui.registry.getMenuItem(PLUGIN_COMMANDS[lower])?.isActive?.(this.core);
|
|
1745
|
+
}
|
|
1746
|
+
return false;
|
|
908
1747
|
}
|
|
909
1748
|
queryCommandSupported(command) {
|
|
910
1749
|
const name = command.toLowerCase();
|
|
911
|
-
return name in COMMANDS || ["formatblock", "mceinsertcontent", "mcesetcontent"].includes(name) || this.commands.has(name);
|
|
1750
|
+
return name in COMMANDS || ["formatblock", "mceinsertcontent", "mcesetcontent"].includes(name) || name in PLUGIN_COMMANDS && !!this.core.ui.registry.getMenuItem(PLUGIN_COMMANDS[name]) || name === "mcetogglestickyformatpainter" && this.core.ui.registry.has("formatpainter") || SPELLCHECK_COMMANDS.has(name) && this.core.hasPlugin("spellchecker") || (name === "mceaidialog" || name === "mceaidialogclose") && this.core.hasPlugin("ai") || this.commands.has(name);
|
|
912
1751
|
}
|
|
913
1752
|
commands = /* @__PURE__ */ new Map();
|
|
914
1753
|
addCommand(name, callback) {
|
|
915
1754
|
this.commands.set(name.toLowerCase(), callback);
|
|
916
1755
|
}
|
|
917
|
-
// ----------
|
|
1756
|
+
// ---------- events ----------
|
|
918
1757
|
on(names, handler, prepend = false) {
|
|
919
1758
|
for (const name of names.toLowerCase().split(/\s+/).filter(Boolean)) {
|
|
920
1759
|
const set = this.handlers.get(name) ?? /* @__PURE__ */ new Set();
|
|
@@ -952,7 +1791,7 @@ var CompatEditor = class {
|
|
|
952
1791
|
}
|
|
953
1792
|
return payload;
|
|
954
1793
|
}
|
|
955
|
-
/** DOM
|
|
1794
|
+
/** A DOM event of the text (keydown, click…): handlers get the browser's event itself. */
|
|
956
1795
|
fireNative(name, event) {
|
|
957
1796
|
for (const handler of [...this.handlers.get(name) ?? []]) {
|
|
958
1797
|
try {
|
|
@@ -962,18 +1801,18 @@ var CompatEditor = class {
|
|
|
962
1801
|
}
|
|
963
1802
|
}
|
|
964
1803
|
}
|
|
965
|
-
/**
|
|
1804
|
+
/** An icon for buttons by name (tinymce.IconManager / editor.ui.registry.addIcon). */
|
|
966
1805
|
static registerIcon(name, svg) {
|
|
967
1806
|
customIcons.set(name, svg);
|
|
968
1807
|
}
|
|
969
|
-
/**
|
|
1808
|
+
/** The newer name of fire in recent versions of the API. */
|
|
970
1809
|
dispatch(name, event) {
|
|
971
1810
|
return this.fire(name, event);
|
|
972
1811
|
}
|
|
973
1812
|
hasEventListeners(name) {
|
|
974
1813
|
return (this.handlers.get(name.toLowerCase())?.size ?? 0) > 0;
|
|
975
1814
|
}
|
|
976
|
-
// ----------
|
|
1815
|
+
// ---------- state ----------
|
|
977
1816
|
isDirty() {
|
|
978
1817
|
return this.dirty;
|
|
979
1818
|
}
|
|
@@ -982,7 +1821,7 @@ var CompatEditor = class {
|
|
|
982
1821
|
this.dirty = state;
|
|
983
1822
|
if (changed && state) this.fire("Dirty");
|
|
984
1823
|
}
|
|
985
|
-
/**
|
|
1824
|
+
/** Write the content into the original <textarea> (as on form submit). */
|
|
986
1825
|
save() {
|
|
987
1826
|
const content = this.getContent();
|
|
988
1827
|
const event = this.fire("SaveContent", { content });
|
|
@@ -1043,44 +1882,35 @@ var CompatEditor = class {
|
|
|
1043
1882
|
},
|
|
1044
1883
|
ignore: (callback) => callback()
|
|
1045
1884
|
};
|
|
1885
|
+
/** TinyMCE's editor.selection, on top of the core's editor.selection. */
|
|
1046
1886
|
selection = {
|
|
1047
|
-
getContent: (args = {}) =>
|
|
1048
|
-
const { state } = this.core.view;
|
|
1049
|
-
const { from, to } = state.selection;
|
|
1050
|
-
if (args.format === "text") return state.doc.textBetween(from, to, "\n");
|
|
1051
|
-
return serializer.serializeFragment(state.selection.content().content);
|
|
1052
|
-
},
|
|
1887
|
+
getContent: (args = {}) => args.format === "text" ? this.core.selection.getText() : this.core.selection.getHTML(),
|
|
1053
1888
|
setContent: (content) => this.insertContent(content),
|
|
1054
|
-
getNode: () =>
|
|
1055
|
-
const { from } = this.core.view.state.selection;
|
|
1056
|
-
const { node } = this.core.view.domAtPos(from);
|
|
1057
|
-
return node instanceof Element ? node : node.parentElement;
|
|
1058
|
-
},
|
|
1889
|
+
getNode: () => this.core.selection.getNode() ?? this.core.view.dom,
|
|
1059
1890
|
getStart: () => this.selection.getNode(),
|
|
1060
1891
|
getEnd: () => this.selection.getNode(),
|
|
1061
|
-
isCollapsed: () => this.core.
|
|
1062
|
-
collapse: (toStart = false) =>
|
|
1063
|
-
|
|
1064
|
-
const pos = toStart ? state.selection.from : state.selection.to;
|
|
1065
|
-
dispatch(state.tr.setSelection(import_prosemirror_state.TextSelection.near(state.doc.resolve(pos))));
|
|
1066
|
-
},
|
|
1067
|
-
/** Курсор в узел DOM редактора (по умолчанию — в начало). */
|
|
1892
|
+
isCollapsed: () => this.core.selection.isCollapsed(),
|
|
1893
|
+
collapse: (toStart = false) => this.core.selection.collapse(toStart),
|
|
1894
|
+
/** Put the cursor in a DOM node of the editor (at its start by default). */
|
|
1068
1895
|
setCursorLocation: (node, offset = 0) => {
|
|
1069
|
-
|
|
1070
|
-
if (!node || !view.dom.contains(node)) return;
|
|
1071
|
-
const pos = view.posAtDOM(node, offset);
|
|
1072
|
-
view.dispatch(view.state.tr.setSelection(import_prosemirror_state.TextSelection.near(view.state.doc.resolve(pos))));
|
|
1896
|
+
if (node) this.core.selection.setCursorLocation(node, offset);
|
|
1073
1897
|
},
|
|
1074
|
-
/**
|
|
1075
|
-
select: (node, content = false) =>
|
|
1898
|
+
/** Select an element: content = true — only its content. */
|
|
1899
|
+
select: (node, content = false) => this.core.selection.select(node, content),
|
|
1900
|
+
/** The selection as a DOM Range. */
|
|
1901
|
+
getRng: () => this.core.selection.getDOMRange(),
|
|
1902
|
+
/** Select a DOM Range of the editing area. */
|
|
1903
|
+
setRng: (range) => {
|
|
1076
1904
|
const { view } = this.core;
|
|
1077
|
-
if (!view.dom.contains(
|
|
1078
|
-
const from = view.posAtDOM(
|
|
1079
|
-
const to = view.posAtDOM(
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1905
|
+
if (!range || !view.dom.contains(range.startContainer)) return;
|
|
1906
|
+
const from = view.posAtDOM(range.startContainer, range.startOffset);
|
|
1907
|
+
const to = view.dom.contains(range.endContainer) ? view.posAtDOM(range.endContainer, range.endOffset) : from;
|
|
1908
|
+
this.core.selection.setRange(from, to);
|
|
1909
|
+
},
|
|
1910
|
+
/** Remember the selection; moveToBookmark() puts it back, wherever later changes moved it. */
|
|
1911
|
+
getBookmark: () => this.core.selection.getBookmark(),
|
|
1912
|
+
moveToBookmark: (bookmark) => this.core.selection.moveToBookmark(bookmark),
|
|
1913
|
+
scrollIntoView: () => this.core.selection.scrollIntoView()
|
|
1084
1914
|
};
|
|
1085
1915
|
notificationManager = {
|
|
1086
1916
|
open: (args) => this.core.ui.notify({
|
|
@@ -1117,9 +1947,9 @@ var CompatEditor = class {
|
|
|
1117
1947
|
onClose: () => callback?.(confirmed)
|
|
1118
1948
|
});
|
|
1119
1949
|
},
|
|
1120
|
-
open: (spec) =>
|
|
1950
|
+
open: (spec) => openDialog(this.core, spec, (next) => this.windowManager.open(next))
|
|
1121
1951
|
};
|
|
1122
|
-
/** editor.ui.registry —
|
|
1952
|
+
/** editor.ui.registry — buttons and menu items in TinyMCE format on top of the NovaProse registry. */
|
|
1123
1953
|
ui = {
|
|
1124
1954
|
registry: {
|
|
1125
1955
|
addIcon: (name, svg) => {
|
|
@@ -1155,8 +1985,8 @@ var CompatEditor = class {
|
|
|
1155
1985
|
});
|
|
1156
1986
|
},
|
|
1157
1987
|
/**
|
|
1158
|
-
*
|
|
1159
|
-
* position: 'node' (
|
|
1988
|
+
* A context toolbar: predicate(node) gets the element at the cursor, items are toolbar buttons.
|
|
1989
|
+
* position: 'node' (above the element) or 'selection'/'line' (at the selection).
|
|
1160
1990
|
*/
|
|
1161
1991
|
addContextToolbar: (name, spec) => {
|
|
1162
1992
|
this.core.ui.registry.addContextToolbar(name, {
|
|
@@ -1169,6 +1999,41 @@ var CompatEditor = class {
|
|
|
1169
1999
|
}
|
|
1170
2000
|
});
|
|
1171
2001
|
},
|
|
2002
|
+
/**
|
|
2003
|
+
* A sidebar: onSetup(api) draws the content into api.element() (once), onShow/onHide run when it
|
|
2004
|
+
* is shown or hidden. A toggle button named after the sidebar is for the toolbar; ToggleSidebar is the command.
|
|
2005
|
+
*/
|
|
2006
|
+
addSidebar: (name, spec) => {
|
|
2007
|
+
let element = null;
|
|
2008
|
+
const api = { element: () => element };
|
|
2009
|
+
const icon = resolveIcon(spec.icon);
|
|
2010
|
+
this.core.ui.registry.addSidebar(name, {
|
|
2011
|
+
title: spec.tooltip ?? name,
|
|
2012
|
+
...icon ? { icon } : {},
|
|
2013
|
+
render: (container) => {
|
|
2014
|
+
element = container;
|
|
2015
|
+
const cleanup = spec.onSetup?.(api);
|
|
2016
|
+
return typeof cleanup === "function" ? cleanup : void 0;
|
|
2017
|
+
},
|
|
2018
|
+
onShow: () => spec.onShow?.(api),
|
|
2019
|
+
onHide: () => spec.onHide?.(api)
|
|
2020
|
+
});
|
|
2021
|
+
},
|
|
2022
|
+
/**
|
|
2023
|
+
* A view in place of the editor: buttons at its top, onShow/onHide get api.getContainer(), where it
|
|
2024
|
+
* draws; ToggleView is the command.
|
|
2025
|
+
*/
|
|
2026
|
+
addView: (name, spec) => {
|
|
2027
|
+
this.core.ui.registry.addView(name, {
|
|
2028
|
+
buttons: (Array.isArray(spec.buttons) ? spec.buttons : []).filter((button) => typeof button?.text === "string").map((button) => ({
|
|
2029
|
+
text: button.text,
|
|
2030
|
+
buttonType: button.buttonType === "primary" ? "primary" : "secondary",
|
|
2031
|
+
onAction: () => button.onAction?.()
|
|
2032
|
+
})),
|
|
2033
|
+
...spec.onShow ? { onShow: spec.onShow } : {},
|
|
2034
|
+
...spec.onHide ? { onHide: spec.onHide } : {}
|
|
2035
|
+
});
|
|
2036
|
+
},
|
|
1172
2037
|
addContextForm: () => {
|
|
1173
2038
|
console.warn("[nova] tinymce-compat: addContextForm is not supported yet");
|
|
1174
2039
|
},
|
|
@@ -1197,9 +2062,9 @@ var CompatEditor = class {
|
|
|
1197
2062
|
}
|
|
1198
2063
|
}
|
|
1199
2064
|
/**
|
|
1200
|
-
* editor.dom —
|
|
1201
|
-
*
|
|
1202
|
-
* formatter
|
|
2065
|
+
* editor.dom — what makes sense on top of a document model: finding and reading. The text's DOM
|
|
2066
|
+
* can't be changed directly (the editor redraws it from the model); use setContent, insertContent
|
|
2067
|
+
* or formatter for edits — such calls log a warning.
|
|
1203
2068
|
*/
|
|
1204
2069
|
dom = {
|
|
1205
2070
|
select: (selector, scope) => [
|
|
@@ -1235,7 +2100,7 @@ var CompatEditor = class {
|
|
|
1235
2100
|
textarea.innerHTML = html;
|
|
1236
2101
|
return textarea.value;
|
|
1237
2102
|
},
|
|
1238
|
-
/**
|
|
2103
|
+
/** A new (not inserted) element: attributes via setAttribute, the content as text. */
|
|
1239
2104
|
create: (tag, attrs = {}, text) => {
|
|
1240
2105
|
const node = document.createElement(tag);
|
|
1241
2106
|
for (const [name, value] of Object.entries(attrs)) {
|
|
@@ -1252,8 +2117,8 @@ var CompatEditor = class {
|
|
|
1252
2117
|
remove: () => warnDom("remove")
|
|
1253
2118
|
};
|
|
1254
2119
|
/**
|
|
1255
|
-
* editor.formatter —
|
|
1256
|
-
*
|
|
2120
|
+
* editor.formatter — the built-in TinyMCE formats: apply/remove/toggle/match. Your own formats
|
|
2121
|
+
* (register) are not supported yet.
|
|
1257
2122
|
*/
|
|
1258
2123
|
formatter = {
|
|
1259
2124
|
apply: (name, vars = {}) => this.applyFormat(name, vars, "apply"),
|
|
@@ -1334,7 +2199,7 @@ var CompatEditor = class {
|
|
|
1334
2199
|
}
|
|
1335
2200
|
console.warn(`[nova] tinymce-compat: format "${name}" is not supported yet`);
|
|
1336
2201
|
}
|
|
1337
|
-
/**
|
|
2202
|
+
/** Remove the editor and restore the original element (like editor.remove()). */
|
|
1338
2203
|
remove() {
|
|
1339
2204
|
if (this.removed) return;
|
|
1340
2205
|
this.fire("remove");
|
|
@@ -1363,6 +2228,7 @@ function warnOnce(message) {
|
|
|
1363
2228
|
var counter = 0;
|
|
1364
2229
|
var px = (value) => typeof value === "number" ? `${value}px` : String(value);
|
|
1365
2230
|
function createTinymce() {
|
|
2231
|
+
(0, import_core3.registerHtmlRules)(import_html_rules.htmlRules);
|
|
1366
2232
|
const all = [];
|
|
1367
2233
|
const plugins = /* @__PURE__ */ new Map();
|
|
1368
2234
|
let active = null;
|
|
@@ -1393,15 +2259,76 @@ function createTinymce() {
|
|
|
1393
2259
|
settings.__wrapper = host;
|
|
1394
2260
|
}
|
|
1395
2261
|
let compat;
|
|
2262
|
+
const tinyPattern = (raw) => {
|
|
2263
|
+
const p = raw;
|
|
2264
|
+
if (!p || typeof p.start !== "string") return null;
|
|
2265
|
+
if (typeof p.replacement === "string") return { start: p.start, replacement: p.replacement };
|
|
2266
|
+
const formats = (Array.isArray(p.format) ? p.format : [p.format]).filter(
|
|
2267
|
+
(f) => typeof f === "string"
|
|
2268
|
+
);
|
|
2269
|
+
const cmd = typeof p.cmd === "string" ? p.cmd : null;
|
|
2270
|
+
if (!cmd && !formats.length) return null;
|
|
2271
|
+
return {
|
|
2272
|
+
start: p.start,
|
|
2273
|
+
...typeof p.end === "string" && p.end ? { end: p.end } : {},
|
|
2274
|
+
...p.trigger === "enter" ? { trigger: "enter" } : {},
|
|
2275
|
+
value: p.value,
|
|
2276
|
+
command: (_editor, value) => {
|
|
2277
|
+
if (cmd) compat.execCommand(cmd, false, value);
|
|
2278
|
+
else for (const format of formats) compat.formatter.apply(format);
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
};
|
|
2282
|
+
if (Array.isArray(config.text_patterns)) {
|
|
2283
|
+
options.textPatterns = config.text_patterns.map(tinyPattern);
|
|
2284
|
+
}
|
|
2285
|
+
const lookup = config.text_patterns_lookup;
|
|
2286
|
+
if (typeof lookup === "function") {
|
|
2287
|
+
options.textPatternsLookup = (context) => {
|
|
2288
|
+
const extra = lookup(context);
|
|
2289
|
+
return Array.isArray(extra) ? extra.map(tinyPattern) : [];
|
|
2290
|
+
};
|
|
2291
|
+
if (!options.textPatterns) options.textPatterns = [];
|
|
2292
|
+
}
|
|
2293
|
+
const onSave = config.save_onsavecallback;
|
|
2294
|
+
const onCancel = config.save_oncancelcallback;
|
|
2295
|
+
const save = {
|
|
2296
|
+
...config.save_enablewhendirty !== void 0 ? { enableWhenDirty: config.save_enablewhendirty !== false } : {},
|
|
2297
|
+
...typeof onSave === "function" ? {
|
|
2298
|
+
onSave: () => {
|
|
2299
|
+
compat.save();
|
|
2300
|
+
return onSave(compat);
|
|
2301
|
+
}
|
|
2302
|
+
} : {},
|
|
2303
|
+
...typeof onCancel === "function" ? { onCancel: () => onCancel(compat) } : {}
|
|
2304
|
+
};
|
|
2305
|
+
const aiRequest = config.ai_request;
|
|
2306
|
+
const ai = typeof aiRequest === "function" ? {
|
|
2307
|
+
...options.pluginOptions?.ai,
|
|
2308
|
+
async *request(request) {
|
|
2309
|
+
const { tinyAiRequest: tinyAiRequest2 } = await Promise.resolve().then(() => (init_ai(), ai_exports));
|
|
2310
|
+
yield* tinyAiRequest2(
|
|
2311
|
+
aiRequest,
|
|
2312
|
+
(name, event) => compat?.fire(name, event)
|
|
2313
|
+
)(request);
|
|
2314
|
+
}
|
|
2315
|
+
} : null;
|
|
2316
|
+
const pluginOptions = {
|
|
2317
|
+
...options.pluginOptions,
|
|
2318
|
+
...Object.keys(save).length ? { save } : {},
|
|
2319
|
+
...ai ? { ai } : {}
|
|
2320
|
+
};
|
|
1396
2321
|
const core = (0, import_core3.createEditor)({
|
|
1397
2322
|
...options,
|
|
2323
|
+
...Object.keys(pluginOptions).length ? { pluginOptions } : {},
|
|
1398
2324
|
element: host,
|
|
1399
2325
|
content: initial,
|
|
1400
2326
|
setup: (editor) => {
|
|
1401
2327
|
compat = new CompatEditor(editor, target, id, settings);
|
|
1402
2328
|
for (const name of custom) {
|
|
1403
2329
|
try {
|
|
1404
|
-
plugins.get(name)(compat, "");
|
|
2330
|
+
const api2 = plugins.get(name)(compat, "");
|
|
2331
|
+
compat.plugins[name] = api2 && typeof api2 === "object" ? api2 : {};
|
|
1405
2332
|
} catch (error) {
|
|
1406
2333
|
console.error(`[nova] tinymce-compat: plugin "${name}" failed`, error);
|
|
1407
2334
|
}
|
|
@@ -1447,6 +2374,14 @@ function createTinymce() {
|
|
|
1447
2374
|
]) {
|
|
1448
2375
|
core.view.dom.addEventListener(name, (event) => compat.fireNative(name, event));
|
|
1449
2376
|
}
|
|
2377
|
+
core.root.addEventListener("nova-ai-dialogopen", () => compat.fire("AIDialogOpen"));
|
|
2378
|
+
core.root.addEventListener("nova-ai-dialogclose", () => compat.fire("AIDialogClose"));
|
|
2379
|
+
core.root.addEventListener("nova-autocorrect-toggle", (event) => {
|
|
2380
|
+
const { feature, on } = event.detail;
|
|
2381
|
+
compat.fire(
|
|
2382
|
+
(feature === "capitalize" ? "Capitalize" : "Autocorrect") + (on ? "Start" : "End")
|
|
2383
|
+
);
|
|
2384
|
+
});
|
|
1450
2385
|
const form = isTextarea ? target.form : target.closest("form");
|
|
1451
2386
|
form?.addEventListener("submit", () => compat.save());
|
|
1452
2387
|
compat.on("remove", () => {
|
|
@@ -1458,9 +2393,22 @@ function createTinymce() {
|
|
|
1458
2393
|
active ??= compat;
|
|
1459
2394
|
await core.ready;
|
|
1460
2395
|
if (compat.removed) return compat;
|
|
2396
|
+
for (const name of activePlugins(config, (plugin) => core.hasPlugin(plugin)))
|
|
2397
|
+
compat.plugins[name] ??= {};
|
|
2398
|
+
if (compat.plugins.inlinecss) {
|
|
2399
|
+
compat.plugins.inlinecss.getContent = async () => {
|
|
2400
|
+
compat.fire("InlineCSS");
|
|
2401
|
+
const { emailHTML } = await import("@novaprose/core/email");
|
|
2402
|
+
return { html: await emailHTML(core, { document: false }) };
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
1461
2405
|
compat.initialized = true;
|
|
1462
2406
|
compat.fire("init");
|
|
1463
2407
|
config.init_instance_callback?.(compat);
|
|
2408
|
+
if (typeof config.view_show === "string" && config.view_show)
|
|
2409
|
+
core.ui.view.show(config.view_show);
|
|
2410
|
+
else if (typeof config.sidebar_show === "string" && config.sidebar_show)
|
|
2411
|
+
void core.ui.sidebar.show(config.sidebar_show);
|
|
1464
2412
|
return compat;
|
|
1465
2413
|
}
|
|
1466
2414
|
const api = {
|
|
@@ -1479,6 +2427,12 @@ function createTinymce() {
|
|
|
1479
2427
|
(resolve) => document.addEventListener("DOMContentLoaded", resolve, { once: true })
|
|
1480
2428
|
);
|
|
1481
2429
|
}
|
|
2430
|
+
if (typeof config.language === "string") {
|
|
2431
|
+
await (0, import_core3.loadLanguage)(config.language.replace("_", "-")).catch((error) => {
|
|
2432
|
+
console.warn("[nova] tinymce-compat: language pack failed to load", error);
|
|
2433
|
+
return false;
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
1482
2436
|
const targets = config.target ? [config.target] : config.selector ? [...document.querySelectorAll(config.selector)] : [];
|
|
1483
2437
|
if (!targets.length) warnOnce(`no elements match "${config.selector ?? ""}"`);
|
|
1484
2438
|
const editors = [];
|