@novaprose/tinymce-compat 0.7.0 → 0.9.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 +1 -1
- 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 +1335 -409
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -45
- package/dist/index.d.ts +92 -45
- package/dist/index.js +831 -366
- package/dist/index.js.map +1 -1
- package/dist/novaprose.css +376 -550
- 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-7a360f16.js.map → advlist-67b98670.js.map} +2 -2
- 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-7e2e7be2.js.map → autolink-897e8650.js.map} +2 -2
- 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-21549c7e.js +2 -0
- package/dist/tinymce-chunks/de-21549c7e.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-60dba768.js.map → directionality-185b3810.js.map} +2 -2
- 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-1de93a3f.js +2 -0
- package/dist/tinymce-chunks/es-1de93a3f.js.map +7 -0
- package/dist/tinymce-chunks/exportpdf-1dfcbddc.js +2 -0
- package/dist/tinymce-chunks/exportpdf-1dfcbddc.js.map +7 -0
- package/dist/tinymce-chunks/exportword-ad95abb4.js +2 -0
- package/dist/tinymce-chunks/exportword-ad95abb4.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-6fbcca9f.js +2 -0
- package/dist/tinymce-chunks/fr-6fbcca9f.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-d6c2636a.js +2 -0
- package/dist/tinymce-chunks/importword-d6c2636a.js.map +7 -0
- package/dist/tinymce-chunks/index-a1feed69.js +5 -0
- package/dist/tinymce-chunks/index-a1feed69.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-e0dbcf63.js.map → insertdatetime-a48ee6e0.js.map} +2 -2
- package/dist/tinymce-chunks/it-ca70815f.js +2 -0
- package/dist/tinymce-chunks/it-ca70815f.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-49bdb0d2.js.map → nonbreaking-f15226ad.js.map} +2 -2
- 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-4e8e9cb7.js +3 -0
- package/dist/tinymce-chunks/paste-office-4e8e9cb7.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-f6958ec0.js +2 -0
- package/dist/tinymce-chunks/pt-BR-f6958ec0.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-d937e10a.js.map → quickbars-35c87c0e.js.map} +3 -3
- package/dist/tinymce-chunks/revisionhistory-741dfb24.js +2 -0
- package/dist/tinymce-chunks/revisionhistory-741dfb24.js.map +7 -0
- package/dist/tinymce-chunks/ru-982f3476.js +2 -0
- package/dist/tinymce-chunks/ru-982f3476.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-1c8ef2ee.js +3 -0
- package/dist/tinymce-chunks/search-bar-1c8ef2ee.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-58c88e5d.js.map → visualblocks-8b7cba25.js.map} +2 -2
- 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 +34 -27
- package/dist/tinymce.global.js.map +4 -4
- package/dist/tinymce.licenses.txt +1094 -0
- package/package.json +2 -2
- package/dist/tinymce-chunks/advlist-7a360f16.js +0 -2
- package/dist/tinymce-chunks/autolink-7e2e7be2.js +0 -2
- package/dist/tinymce-chunks/autoresize-d6c9537b.js +0 -2
- package/dist/tinymce-chunks/autoresize-d6c9537b.js.map +0 -7
- package/dist/tinymce-chunks/autosave-4fd46720.js +0 -2
- package/dist/tinymce-chunks/autosave-4fd46720.js.map +0 -7
- package/dist/tinymce-chunks/charmap-4b14307a.js +0 -2
- package/dist/tinymce-chunks/charmap-4b14307a.js.map +0 -7
- package/dist/tinymce-chunks/comments-panel-37cba890.js +0 -2
- package/dist/tinymce-chunks/comments-panel-37cba890.js.map +0 -7
- package/dist/tinymce-chunks/directionality-60dba768.js +0 -2
- package/dist/tinymce-chunks/emoticons-7e6da0b6.js +0 -2
- package/dist/tinymce-chunks/emoticons-7e6da0b6.js.map +0 -7
- package/dist/tinymce-chunks/form-dialog-9cde0ef7.js +0 -2
- package/dist/tinymce-chunks/form-dialog-9cde0ef7.js.map +0 -7
- package/dist/tinymce-chunks/insertdatetime-e0dbcf63.js +0 -2
- package/dist/tinymce-chunks/nonbreaking-49bdb0d2.js +0 -2
- package/dist/tinymce-chunks/paste-office-a38659d6.js +0 -3
- package/dist/tinymce-chunks/paste-office-a38659d6.js.map +0 -7
- package/dist/tinymce-chunks/quickbars-d937e10a.js +0 -2
- package/dist/tinymce-chunks/revisionhistory-d6306426.js +0 -2
- package/dist/tinymce-chunks/revisionhistory-d6306426.js.map +0 -7
- package/dist/tinymce-chunks/table-80284f6f.js +0 -2
- package/dist/tinymce-chunks/table-80284f6f.js.map +0 -7
- package/dist/tinymce-chunks/visualblocks-58c88e5d.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createEditor,
|
|
4
|
+
loadLanguage,
|
|
5
|
+
registerHtmlRules
|
|
6
|
+
} from "@novaprose/core";
|
|
3
7
|
import { htmlRules } from "@novaprose/core/html-rules";
|
|
4
8
|
|
|
5
9
|
// src/options.ts
|
|
@@ -12,7 +16,6 @@ var BUILT_IN = /* @__PURE__ */ new Set([
|
|
|
12
16
|
"image",
|
|
13
17
|
"table",
|
|
14
18
|
"code",
|
|
15
|
-
"codesample",
|
|
16
19
|
"preview",
|
|
17
20
|
"searchreplace",
|
|
18
21
|
"fullscreen",
|
|
@@ -27,12 +30,12 @@ var BUILT_IN = /* @__PURE__ */ new Set([
|
|
|
27
30
|
"tabfocus",
|
|
28
31
|
"textpattern",
|
|
29
32
|
"imagetools",
|
|
30
|
-
"powerpaste"
|
|
31
|
-
"importcss",
|
|
32
|
-
"accordion"
|
|
33
|
+
"powerpaste"
|
|
33
34
|
]);
|
|
34
35
|
var RENAMED = {
|
|
35
|
-
tinycomments: "comments"
|
|
36
|
+
tinycomments: "comments",
|
|
37
|
+
tinymcespellchecker: "spellchecker",
|
|
38
|
+
inlinecss: "email"
|
|
36
39
|
};
|
|
37
40
|
var IGNORED = /* @__PURE__ */ new Set([
|
|
38
41
|
"selector",
|
|
@@ -94,6 +97,9 @@ var IGNORED = /* @__PURE__ */ new Set([
|
|
|
94
97
|
"valid_styles",
|
|
95
98
|
"toolbar_mode",
|
|
96
99
|
"toolbar_sticky",
|
|
100
|
+
"toolbar_sticky_offset",
|
|
101
|
+
"content_language",
|
|
102
|
+
"content_langs",
|
|
97
103
|
"font_family_formats",
|
|
98
104
|
"font_size_formats",
|
|
99
105
|
"line_height_formats",
|
|
@@ -105,9 +111,180 @@ var IGNORED = /* @__PURE__ */ new Set([
|
|
|
105
111
|
"quickbars_insert_toolbar",
|
|
106
112
|
"mentions_fetch",
|
|
107
113
|
"tinycomments_author",
|
|
108
|
-
"tinycomments_author_name"
|
|
114
|
+
"tinycomments_author_name",
|
|
115
|
+
"codesample_languages",
|
|
116
|
+
"details_initial_state",
|
|
117
|
+
"details_serialized_state",
|
|
118
|
+
"tableofcontents_class",
|
|
119
|
+
"tableofcontents_depth",
|
|
120
|
+
"tableofcontents_header",
|
|
121
|
+
"tableofcontents_orderedlist",
|
|
122
|
+
"tableofcontents_includeheader",
|
|
123
|
+
// Highlighting is our own (highlight.js, lazy); Prism on the site's page isn't needed for it.
|
|
124
|
+
"codesample_global_prismjs",
|
|
125
|
+
"casechange_title_case_minors",
|
|
126
|
+
"permanentpen_properties",
|
|
127
|
+
"visualchars_default_state",
|
|
128
|
+
// save_* are wired in index.ts: the callbacks get the TinyMCE-style editor.
|
|
129
|
+
"save_enablewhendirty",
|
|
130
|
+
"save_onsavecallback",
|
|
131
|
+
"save_oncancelcallback",
|
|
132
|
+
"importcss_append",
|
|
133
|
+
"importcss_file_filter",
|
|
134
|
+
"importcss_selector_filter",
|
|
135
|
+
"importcss_groups",
|
|
136
|
+
"importcss_exclusive",
|
|
137
|
+
"importcss_selector_converter",
|
|
138
|
+
"templates",
|
|
139
|
+
// tinymcespellchecker: the checking goes through your service (spellchecker_languagetool_url or
|
|
140
|
+
// spellchecker_check, NovaProse's own options); Tiny's spellchecker_rpc_url is not used.
|
|
141
|
+
"spellchecker_active",
|
|
142
|
+
"spellchecker_language",
|
|
143
|
+
"spellchecker_languages",
|
|
144
|
+
"spellchecker_ignore_list",
|
|
145
|
+
"spellchecker_dialog",
|
|
146
|
+
"spellchecker_languagetool_url",
|
|
147
|
+
"spellchecker_check",
|
|
148
|
+
// a11ychecker: the level, ignored rules, decorative images, the alt length, a filter. HTML 5 is
|
|
149
|
+
// always checked, and there is no "more info" link.
|
|
150
|
+
"a11ychecker_level",
|
|
151
|
+
"a11ychecker_ignored_rules",
|
|
152
|
+
"a11ychecker_allow_decorative_images",
|
|
153
|
+
"a11y_advanced_options",
|
|
154
|
+
"a11ychecker_alt_text_max_length",
|
|
155
|
+
"a11ychecker_filter_issue",
|
|
156
|
+
"a11ychecker_html_version",
|
|
157
|
+
"a11ychecker_issue_url_callback",
|
|
158
|
+
// ai: ai_request is wired in index.ts (its events go to the TinyMCE-style editor); ai_shortcuts
|
|
159
|
+
// becomes the quick actions.
|
|
160
|
+
"ai_request",
|
|
161
|
+
"ai_shortcuts",
|
|
162
|
+
// inlinecss → the email plugin: the filters of what is put inline.
|
|
163
|
+
"inlinecss_selector_filter",
|
|
164
|
+
"inlinecss_file_filter",
|
|
165
|
+
// linkchecker: the service address (a server that answers our protocol, see the link checker
|
|
166
|
+
// guide) and preprocess; the highlight's look comes from the theme's CSS variables.
|
|
167
|
+
"linkchecker_service_url",
|
|
168
|
+
"linkchecker_preprocess",
|
|
169
|
+
"linkchecker_content_css",
|
|
170
|
+
// pageembed: the sizes (classes) and inline styles; the wrapper keeps TinyMCE's class.
|
|
171
|
+
"tiny_pageembed_classes",
|
|
172
|
+
"tiny_pageembed_inline_styles",
|
|
173
|
+
// fullpagehtml: what a page that doesn't say gets (doctype, title, encoding, body style), and
|
|
174
|
+
// whether the source code view shows the whole page.
|
|
175
|
+
"fullpagehtml_default_doctype",
|
|
176
|
+
"fullpagehtml_default_title",
|
|
177
|
+
"fullpagehtml_default_encoding",
|
|
178
|
+
"fullpagehtml_default_body_style",
|
|
179
|
+
"fullpagehtml_hide_in_source_view",
|
|
180
|
+
// mediaembed: the service address (a server that answers our protocol, see the embeds guide),
|
|
181
|
+
// the widest a card gets and inline styles; cards keep TinyMCE's summary card classes.
|
|
182
|
+
"mediaembed_service_url",
|
|
183
|
+
"mediaembed_max_width",
|
|
184
|
+
"mediaembed_inline_styles",
|
|
185
|
+
// advtable: your series for the numbers column (their generators give each row's value).
|
|
186
|
+
"advtable_value_series",
|
|
187
|
+
// advcode: the code laid out on open, getContent laid out too (index.ts); the code editor opens
|
|
188
|
+
// in a dialog with a full screen button, so advcode_inline isn't needed.
|
|
189
|
+
"advcode_prettify_editor",
|
|
190
|
+
"advcode_prettify_getcontent",
|
|
191
|
+
"advcode_inline",
|
|
192
|
+
// view_show and sidebar_show: opened when the editor is ready (index.ts).
|
|
193
|
+
"view_show",
|
|
194
|
+
"sidebar_show",
|
|
195
|
+
// editimage: the toolbar, the hosts with cookies, your way to fetch an image (editimage_fetch_image
|
|
196
|
+
// gets an <img>). Images are read with CORS, so the CORS host list, the proxy and the upload timeout
|
|
197
|
+
// aren't needed: fetchImage goes through your server instead.
|
|
198
|
+
"editimage_toolbar",
|
|
199
|
+
"editimage_credentials_hosts",
|
|
200
|
+
"editimage_fetch_image",
|
|
201
|
+
"editimage_cors_hosts",
|
|
202
|
+
"editimage_proxy",
|
|
203
|
+
"editimage_proxy_service_url",
|
|
204
|
+
"editimage_upload_timeout",
|
|
205
|
+
// autocorrect: corrections run in the browser, so Tiny's service address isn't needed.
|
|
206
|
+
"autocorrect_autocorrect",
|
|
207
|
+
"autocorrect_capitalize",
|
|
208
|
+
"autocorrect_service_url",
|
|
209
|
+
// typography: the language, the languages of the menu, the rules (Typograf rule ids), tags left alone.
|
|
210
|
+
"typography_default_lang",
|
|
211
|
+
"typography_langs",
|
|
212
|
+
"typography_rules",
|
|
213
|
+
"typography_ignore",
|
|
214
|
+
// text_patterns: false turns the patterns off; a list (and text_patterns_lookup) is TinyMCE's
|
|
215
|
+
// patterns, run through this editor's formatter and execCommand (index.ts).
|
|
216
|
+
"text_patterns",
|
|
217
|
+
"text_patterns_lookup",
|
|
218
|
+
"template_replace_values",
|
|
219
|
+
"template_preview_replace_values",
|
|
220
|
+
"template_selected_content_classes",
|
|
221
|
+
"template_cdate_classes",
|
|
222
|
+
"template_mdate_classes",
|
|
223
|
+
"template_cdate_format",
|
|
224
|
+
"template_mdate_format"
|
|
109
225
|
]);
|
|
110
226
|
var list = (value) => (Array.isArray(value) ? value.join(" ") : String(value ?? "")).split(/[\s,]+/).filter(Boolean);
|
|
227
|
+
function activePlugins(config, has) {
|
|
228
|
+
return list(config.plugins).filter((name) => BUILT_IN.has(name) || has(RENAMED[name] ?? name));
|
|
229
|
+
}
|
|
230
|
+
function typographyRule(id) {
|
|
231
|
+
if (/\/dash\//.test(id)) return "dashes";
|
|
232
|
+
if (/^common\/punctuation\/(quote|apostrophe)$/.test(id)) return "quotes";
|
|
233
|
+
if (id === "common/punctuation/hellip") return "ellipsis";
|
|
234
|
+
if (id === "common/punctuation/delDoublePunctuation" || id.startsWith("common/space/"))
|
|
235
|
+
return "spaces";
|
|
236
|
+
if (id === "common/symbols/arrow") return "arrows";
|
|
237
|
+
if (id.startsWith("common/symbols/")) return "symbols";
|
|
238
|
+
if (id === "common/number/fraction") return "fractions";
|
|
239
|
+
if (id.startsWith("common/number/")) return "math";
|
|
240
|
+
if (id.startsWith("common/nbsp/")) return "nbsp";
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
var TYPOGRAPHY_TAGS = {
|
|
244
|
+
code: ["code", "code_block"],
|
|
245
|
+
pre: ["code_block"],
|
|
246
|
+
a: ["link"],
|
|
247
|
+
strong: ["bold"],
|
|
248
|
+
b: ["bold"],
|
|
249
|
+
em: ["italic"],
|
|
250
|
+
i: ["italic"],
|
|
251
|
+
blockquote: ["blockquote"]
|
|
252
|
+
};
|
|
253
|
+
function typographyOptions(config) {
|
|
254
|
+
const out = {};
|
|
255
|
+
const lang = config.typography_default_lang;
|
|
256
|
+
const first = Array.isArray(lang) ? lang[0] : lang;
|
|
257
|
+
if (typeof first === "string" && first) out.language = first.replace(/_/g, "-");
|
|
258
|
+
const langs = config.typography_langs;
|
|
259
|
+
const codes = Array.isArray(langs) ? langs : langs && typeof langs === "object" ? Object.keys(langs) : [];
|
|
260
|
+
const languages = codes.filter((c) => typeof c === "string").map((c) => c.replace(/_/g, "-"));
|
|
261
|
+
if (languages.length) out.languages = languages;
|
|
262
|
+
if (Array.isArray(config.typography_rules)) {
|
|
263
|
+
const on = new Set(
|
|
264
|
+
config.typography_rules.map((id) => typeof id === "string" ? typographyRule(id) : null)
|
|
265
|
+
);
|
|
266
|
+
out.rules = Object.fromEntries(
|
|
267
|
+
[
|
|
268
|
+
"quotes",
|
|
269
|
+
"dashes",
|
|
270
|
+
"ellipsis",
|
|
271
|
+
"symbols",
|
|
272
|
+
"arrows",
|
|
273
|
+
"math",
|
|
274
|
+
"fractions",
|
|
275
|
+
"spaces",
|
|
276
|
+
"nbsp"
|
|
277
|
+
].map((rule) => [rule, on.has(rule)])
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (Array.isArray(config.typography_ignore)) {
|
|
281
|
+
const ignore = config.typography_ignore.flatMap(
|
|
282
|
+
(tag) => typeof tag === "string" ? TYPOGRAPHY_TAGS[tag.toLowerCase().replace(/\[.*$/, "")] ?? [] : []
|
|
283
|
+
);
|
|
284
|
+
if (ignore.length) out.ignore = [...new Set(ignore)];
|
|
285
|
+
}
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
111
288
|
function parseFormats(value) {
|
|
112
289
|
if (typeof value !== "string") return void 0;
|
|
113
290
|
return value.split(";").map((item) => item.trim()).filter(Boolean).map((item) => {
|
|
@@ -190,6 +367,23 @@ function toStyleFormats(value) {
|
|
|
190
367
|
return spec ? [{ title, ...spec }] : [];
|
|
191
368
|
});
|
|
192
369
|
}
|
|
370
|
+
function toAiShortcuts(value) {
|
|
371
|
+
return value.flatMap((item) => {
|
|
372
|
+
if (!item || typeof item !== "object") return [];
|
|
373
|
+
const raw = item;
|
|
374
|
+
const title = typeof raw.title === "string" ? raw.title : "";
|
|
375
|
+
if (!title) return [];
|
|
376
|
+
if (Array.isArray(raw.subprompts)) return [{ title, items: toAiShortcuts(raw.subprompts) }];
|
|
377
|
+
if (typeof raw.prompt !== "string") return [];
|
|
378
|
+
return [
|
|
379
|
+
{
|
|
380
|
+
title,
|
|
381
|
+
prompt: raw.prompt,
|
|
382
|
+
...typeof raw.selection === "boolean" ? { selection: raw.selection } : {}
|
|
383
|
+
}
|
|
384
|
+
];
|
|
385
|
+
});
|
|
386
|
+
}
|
|
193
387
|
function mapOptions(config) {
|
|
194
388
|
const unknown = Object.keys(config).filter((key) => !IGNORED.has(key));
|
|
195
389
|
const plugins = [];
|
|
@@ -200,11 +394,18 @@ function mapOptions(config) {
|
|
|
200
394
|
if (isPluginRegistered(target)) plugins.push(target);
|
|
201
395
|
else missingPlugins.push(name);
|
|
202
396
|
}
|
|
397
|
+
if (plugins.includes("ai") && !plugins.includes("suggestions")) {
|
|
398
|
+
plugins.splice(plugins.indexOf("ai"), 0, "suggestions");
|
|
399
|
+
}
|
|
400
|
+
if (plugins.includes("mediaembed") && !plugins.includes("media")) {
|
|
401
|
+
plugins.splice(plugins.indexOf("mediaembed"), 0, "media");
|
|
402
|
+
}
|
|
203
403
|
const options = { plugins };
|
|
204
404
|
if (config.toolbar === false) options.toolbar = false;
|
|
205
405
|
else if (Array.isArray(config.toolbar)) options.toolbar = config.toolbar.join(" | ");
|
|
206
406
|
else if (typeof config.toolbar === "string") options.toolbar = config.toolbar;
|
|
207
407
|
if (config.menubar !== void 0) options.menubar = config.menubar;
|
|
408
|
+
if (config.text_patterns === false) options.textPatterns = false;
|
|
208
409
|
if (typeof config.statusbar === "boolean") options.statusbar = config.statusbar;
|
|
209
410
|
if (typeof config.placeholder === "string") options.placeholder = config.placeholder;
|
|
210
411
|
if (config.readonly === true) options.editable = false;
|
|
@@ -244,10 +445,16 @@ function mapOptions(config) {
|
|
|
244
445
|
options.blockFormats = blocks.map(({ label, value }) => ({ label, block: value.toLowerCase() })).filter((f) => known.includes(f.block));
|
|
245
446
|
}
|
|
246
447
|
if (typeof config.language === "string") options.language = config.language.replace("_", "-");
|
|
247
|
-
if (config.
|
|
448
|
+
if (typeof config.content_language === "string" && config.content_language)
|
|
449
|
+
options.contentLanguage = config.content_language.replace(/_/g, "-");
|
|
450
|
+
options.contentLangs = Array.isArray(config.content_langs) ? config.content_langs.flatMap((entry) => {
|
|
451
|
+
const { code, title } = entry ?? {};
|
|
452
|
+
return typeof code === "string" ? [{ code, ...typeof title === "string" ? { title } : {} }] : [];
|
|
453
|
+
}) : [];
|
|
454
|
+
if (typeof config.toolbar_sticky_offset === "number")
|
|
455
|
+
options.toolbarStickyOffset = config.toolbar_sticky_offset;
|
|
456
|
+
if (config.toolbar_mode === "floating" || config.toolbar_mode === "sliding" || config.toolbar_mode === "scrolling" || config.toolbar_mode === "wrap") {
|
|
248
457
|
options.toolbarMode = config.toolbar_mode;
|
|
249
|
-
} else if (config.toolbar_mode === "floating" || config.toolbar_mode === "scrolling") {
|
|
250
|
-
options.toolbarMode = "sliding";
|
|
251
458
|
}
|
|
252
459
|
if (config.inline === true) options.mode = "inline";
|
|
253
460
|
if (config.paste_as_text === true) options.pasteAsText = true;
|
|
@@ -329,6 +536,232 @@ function mapOptions(config) {
|
|
|
329
536
|
}
|
|
330
537
|
};
|
|
331
538
|
}
|
|
539
|
+
if (Array.isArray(config.codesample_languages)) {
|
|
540
|
+
const languages = config.codesample_languages.flatMap((item) => {
|
|
541
|
+
const { text, value } = item ?? {};
|
|
542
|
+
return typeof value === "string" && value ? [{ value, label: typeof text === "string" && text ? text : value }] : [];
|
|
543
|
+
});
|
|
544
|
+
pluginOptions.codesample = { languages };
|
|
545
|
+
}
|
|
546
|
+
const detailsState = (value) => value === "inherited" || value === "collapsed" || value === "expanded" ? value : void 0;
|
|
547
|
+
if (config.details_initial_state || config.details_serialized_state) {
|
|
548
|
+
pluginOptions.accordion = {
|
|
549
|
+
...detailsState(config.details_initial_state) ? { initialState: detailsState(config.details_initial_state) } : {},
|
|
550
|
+
...detailsState(config.details_serialized_state) ? { serializedState: detailsState(config.details_serialized_state) } : {}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
if (list(config.plugins).includes("tableofcontents")) {
|
|
554
|
+
pluginOptions.tableofcontents = {
|
|
555
|
+
className: typeof config.tableofcontents_class === "string" ? config.tableofcontents_class : "mce-toc",
|
|
556
|
+
titleTag: typeof config.tableofcontents_header === "string" ? config.tableofcontents_header : "h2",
|
|
557
|
+
...config.tableofcontents_depth !== void 0 ? { depth: Number(config.tableofcontents_depth) } : {},
|
|
558
|
+
...config.tableofcontents_orderedlist ? { orderedList: true } : {},
|
|
559
|
+
...config.tableofcontents_includeheader === false ? { title: "" } : {}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (Array.isArray(config.casechange_title_case_minors)) {
|
|
563
|
+
pluginOptions.casechange = {
|
|
564
|
+
titleCaseMinors: config.casechange_title_case_minors.map(String)
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
if (config.permanentpen_properties && typeof config.permanentpen_properties === "object") {
|
|
568
|
+
pluginOptions.permanentpen = { properties: { ...config.permanentpen_properties } };
|
|
569
|
+
}
|
|
570
|
+
if (config.visualchars_default_state === true) pluginOptions.visualchars = { default: true };
|
|
571
|
+
const importcss = Object.fromEntries(
|
|
572
|
+
[
|
|
573
|
+
["append", config.importcss_append],
|
|
574
|
+
["fileFilter", config.importcss_file_filter],
|
|
575
|
+
["selectorFilter", config.importcss_selector_filter],
|
|
576
|
+
["groups", config.importcss_groups],
|
|
577
|
+
["exclusive", config.importcss_exclusive],
|
|
578
|
+
["converter", config.importcss_selector_converter]
|
|
579
|
+
].filter(([, value]) => value !== void 0)
|
|
580
|
+
);
|
|
581
|
+
if (Object.keys(importcss).length) pluginOptions.importcss = importcss;
|
|
582
|
+
const templates = config.templates;
|
|
583
|
+
const template = Object.fromEntries(
|
|
584
|
+
[
|
|
585
|
+
[
|
|
586
|
+
"templates",
|
|
587
|
+
typeof templates === "function" ? () => new Promise(
|
|
588
|
+
(resolve) => templates(resolve)
|
|
589
|
+
) : templates
|
|
590
|
+
],
|
|
591
|
+
["values", config.template_replace_values],
|
|
592
|
+
["previewValues", config.template_preview_replace_values],
|
|
593
|
+
["selectedContentClasses", config.template_selected_content_classes],
|
|
594
|
+
["creationDateClasses", config.template_cdate_classes],
|
|
595
|
+
["modifiedDateClasses", config.template_mdate_classes],
|
|
596
|
+
["creationDateFormat", config.template_cdate_format],
|
|
597
|
+
["modifiedDateFormat", config.template_mdate_format]
|
|
598
|
+
].filter(([, value]) => value !== void 0)
|
|
599
|
+
);
|
|
600
|
+
if (Object.keys(template).length) pluginOptions.template = template;
|
|
601
|
+
const spellchecker = {};
|
|
602
|
+
if (typeof config.spellchecker_active === "boolean")
|
|
603
|
+
spellchecker.active = config.spellchecker_active;
|
|
604
|
+
const spellLanguage = config.content_language ?? config.spellchecker_language;
|
|
605
|
+
if (typeof spellLanguage === "string" && spellLanguage)
|
|
606
|
+
spellchecker.language = spellLanguage.replace(/_/g, "-");
|
|
607
|
+
if (typeof config.spellchecker_languages === "string") {
|
|
608
|
+
spellchecker.languages = config.spellchecker_languages.split(",").map((pair) => pair.split("=")).filter(
|
|
609
|
+
(pair) => pair.length === 2 && !!pair[0].trim() && !!pair[1].trim()
|
|
610
|
+
).map(([name, code]) => ({ name: name.trim(), code: code.trim().replace(/_/g, "-") }));
|
|
611
|
+
}
|
|
612
|
+
const ignore = config.spellchecker_ignore_list;
|
|
613
|
+
const ignored = Array.isArray(ignore) ? ignore : ignore && typeof ignore === "object" ? Object.values(ignore).flatMap((words) => Array.isArray(words) ? words : []) : [];
|
|
614
|
+
if (ignored.length)
|
|
615
|
+
spellchecker.ignore = ignored.filter((w) => typeof w === "string");
|
|
616
|
+
if (typeof config.spellchecker_check === "function")
|
|
617
|
+
spellchecker.check = config.spellchecker_check;
|
|
618
|
+
if (typeof config.spellchecker_languagetool_url === "string")
|
|
619
|
+
spellchecker.languageTool = { url: config.spellchecker_languagetool_url };
|
|
620
|
+
if (Object.keys(spellchecker).length) pluginOptions.spellchecker = spellchecker;
|
|
621
|
+
if (list(config.plugins).includes("a11ychecker")) {
|
|
622
|
+
const a11y = {
|
|
623
|
+
allowDecorativeImages: (config.a11ychecker_allow_decorative_images ?? config.a11y_advanced_options) === true
|
|
624
|
+
};
|
|
625
|
+
if (typeof config.a11ychecker_level === "string") {
|
|
626
|
+
a11y.level = config.a11ychecker_level.toLowerCase();
|
|
627
|
+
}
|
|
628
|
+
if (typeof config.a11ychecker_ignored_rules === "string") {
|
|
629
|
+
a11y.ignoredRules = config.a11ychecker_ignored_rules.split(",").map((rule) => rule.trim()).filter(Boolean);
|
|
630
|
+
}
|
|
631
|
+
if (typeof config.a11ychecker_alt_text_max_length === "number") {
|
|
632
|
+
a11y.altTextMaxLength = config.a11ychecker_alt_text_max_length;
|
|
633
|
+
}
|
|
634
|
+
const filter = config.a11ychecker_filter_issue;
|
|
635
|
+
if (typeof filter === "function") {
|
|
636
|
+
a11y.filterIssue = (issue) => filter({
|
|
637
|
+
...issue,
|
|
638
|
+
id: issue.rule,
|
|
639
|
+
contentID: issue.text
|
|
640
|
+
}) !== false;
|
|
641
|
+
}
|
|
642
|
+
pluginOptions.a11ychecker = a11y;
|
|
643
|
+
}
|
|
644
|
+
const aiShortcuts = config.ai_shortcuts;
|
|
645
|
+
if (aiShortcuts === false || Array.isArray(aiShortcuts) && !aiShortcuts.length) {
|
|
646
|
+
pluginOptions.ai = { shortcuts: false };
|
|
647
|
+
} else if (Array.isArray(aiShortcuts)) {
|
|
648
|
+
pluginOptions.ai = { shortcuts: toAiShortcuts(aiShortcuts) };
|
|
649
|
+
}
|
|
650
|
+
const email = {};
|
|
651
|
+
if (["string", "function"].includes(typeof config.inlinecss_selector_filter) || config.inlinecss_selector_filter instanceof RegExp)
|
|
652
|
+
email.selectorFilter = config.inlinecss_selector_filter;
|
|
653
|
+
if (["string", "function"].includes(typeof config.inlinecss_file_filter) || config.inlinecss_file_filter instanceof RegExp)
|
|
654
|
+
email.fileFilter = config.inlinecss_file_filter;
|
|
655
|
+
if (Object.keys(email).length) pluginOptions.email = email;
|
|
656
|
+
const autocorrect = {};
|
|
657
|
+
if (typeof config.autocorrect_autocorrect === "boolean")
|
|
658
|
+
autocorrect.autocorrect = config.autocorrect_autocorrect;
|
|
659
|
+
if (typeof config.autocorrect_capitalize === "boolean")
|
|
660
|
+
autocorrect.capitalize = config.autocorrect_capitalize;
|
|
661
|
+
if (Object.keys(autocorrect).length) pluginOptions.autocorrect = autocorrect;
|
|
662
|
+
const linkchecker = {};
|
|
663
|
+
if (typeof config.linkchecker_service_url === "string")
|
|
664
|
+
linkchecker.serviceUrl = config.linkchecker_service_url;
|
|
665
|
+
const preprocess = config.linkchecker_preprocess;
|
|
666
|
+
if (typeof preprocess === "function") {
|
|
667
|
+
linkchecker.preprocess = (url) => {
|
|
668
|
+
const out = preprocess({ url });
|
|
669
|
+
return typeof out?.url === "string" ? out.url : url;
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
if (Object.keys(linkchecker).length) pluginOptions.linkchecker = linkchecker;
|
|
673
|
+
if (plugins.includes("pageembed")) {
|
|
674
|
+
const classes = config.tiny_pageembed_classes;
|
|
675
|
+
pluginOptions.pageembed = {
|
|
676
|
+
className: "tiny-pageembed",
|
|
677
|
+
sizes: Array.isArray(classes) ? classes.filter(
|
|
678
|
+
(size) => !!size && typeof size.value === "string"
|
|
679
|
+
).map((size) => ({
|
|
680
|
+
value: size.value,
|
|
681
|
+
...typeof size.text === "string" ? { text: size.text } : {}
|
|
682
|
+
})) : ["21by9", "16by9", "4by3", "1by1"].map((ratio) => ({
|
|
683
|
+
value: `tiny-pageembed--${ratio}`
|
|
684
|
+
})),
|
|
685
|
+
inlineStyles: config.tiny_pageembed_inline_styles === true
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
if (plugins.includes("fullpagehtml")) {
|
|
689
|
+
const fullpagehtml = {};
|
|
690
|
+
const pick = (option, key) => {
|
|
691
|
+
if (typeof config[option] === "string") fullpagehtml[key] = config[option];
|
|
692
|
+
};
|
|
693
|
+
pick("fullpagehtml_default_doctype", "doctype");
|
|
694
|
+
pick("fullpagehtml_default_title", "title");
|
|
695
|
+
pick("fullpagehtml_default_encoding", "encoding");
|
|
696
|
+
pick("fullpagehtml_default_body_style", "bodyStyle");
|
|
697
|
+
if (config.fullpagehtml_hide_in_source_view === true) fullpagehtml.hideInSourceView = true;
|
|
698
|
+
if (Object.keys(fullpagehtml).length) pluginOptions.fullpagehtml = fullpagehtml;
|
|
699
|
+
}
|
|
700
|
+
if (plugins.includes("mediaembed")) {
|
|
701
|
+
const mediaembed = {
|
|
702
|
+
className: "ephox-summary-card",
|
|
703
|
+
inlineStyles: config.mediaembed_inline_styles === true
|
|
704
|
+
};
|
|
705
|
+
if (typeof config.mediaembed_service_url === "string" && config.mediaembed_service_url)
|
|
706
|
+
mediaembed.serviceUrl = config.mediaembed_service_url;
|
|
707
|
+
const maxWidth = Number(config.mediaembed_max_width);
|
|
708
|
+
if (config.mediaembed_max_width !== void 0 && Number.isFinite(maxWidth))
|
|
709
|
+
mediaembed.maxWidth = maxWidth;
|
|
710
|
+
pluginOptions.mediaembed = mediaembed;
|
|
711
|
+
}
|
|
712
|
+
const valueSeries = config.advtable_value_series;
|
|
713
|
+
if (plugins.includes("advtable") && valueSeries && typeof valueSeries === "object") {
|
|
714
|
+
const series = {};
|
|
715
|
+
for (const [name, def] of Object.entries(valueSeries)) {
|
|
716
|
+
const { title, generator } = def ?? {};
|
|
717
|
+
if (typeof title !== "string" || typeof generator !== "function") continue;
|
|
718
|
+
let prev;
|
|
719
|
+
series[name] = {
|
|
720
|
+
title,
|
|
721
|
+
value: (index) => {
|
|
722
|
+
if (index === 0) prev = void 0;
|
|
723
|
+
const info = {
|
|
724
|
+
sectionType: "tbody",
|
|
725
|
+
cellType: "td",
|
|
726
|
+
getRowType: () => "body",
|
|
727
|
+
classes: [],
|
|
728
|
+
direction: "column",
|
|
729
|
+
prev
|
|
730
|
+
};
|
|
731
|
+
const out = generator(
|
|
732
|
+
info,
|
|
733
|
+
index,
|
|
734
|
+
0
|
|
735
|
+
);
|
|
736
|
+
prev = out;
|
|
737
|
+
const value = out?.value;
|
|
738
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : void 0;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
if (Object.keys(series).length) pluginOptions.advtable = { series };
|
|
743
|
+
}
|
|
744
|
+
if (plugins.includes("editimage")) {
|
|
745
|
+
const editimage = {};
|
|
746
|
+
if (typeof config.editimage_toolbar === "string") editimage.toolbar = config.editimage_toolbar;
|
|
747
|
+
if (Array.isArray(config.editimage_credentials_hosts))
|
|
748
|
+
editimage.credentialsHosts = config.editimage_credentials_hosts.filter(
|
|
749
|
+
(host) => typeof host === "string"
|
|
750
|
+
);
|
|
751
|
+
const fetchImage = config.editimage_fetch_image;
|
|
752
|
+
if (typeof fetchImage === "function") {
|
|
753
|
+
editimage.fetchImage = (src) => {
|
|
754
|
+
const img = document.createElement("img");
|
|
755
|
+
img.src = src;
|
|
756
|
+
return fetchImage(img);
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
if (Object.keys(editimage).length) pluginOptions.editimage = editimage;
|
|
760
|
+
}
|
|
761
|
+
if (plugins.includes("advcode") && typeof config.advcode_prettify_editor === "boolean")
|
|
762
|
+
pluginOptions.advcode = { prettify: config.advcode_prettify_editor };
|
|
763
|
+
const typography = typographyOptions(config);
|
|
764
|
+
if (Object.keys(typography).length) pluginOptions.typography = typography;
|
|
332
765
|
if (Object.keys(pluginOptions).length) options.pluginOptions = pluginOptions;
|
|
333
766
|
return { options, unknown, missingPlugins };
|
|
334
767
|
}
|
|
@@ -336,307 +769,50 @@ function mapOptions(config) {
|
|
|
336
769
|
// src/editor.ts
|
|
337
770
|
import {
|
|
338
771
|
getStyle,
|
|
339
|
-
HTMLSerializer,
|
|
340
772
|
icons,
|
|
773
|
+
prettyHTML,
|
|
341
774
|
setStyle
|
|
342
775
|
} from "@novaprose/core";
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (className) node.className = className;
|
|
350
|
-
if (text !== void 0) node.textContent = text;
|
|
351
|
-
return node;
|
|
776
|
+
import { AllSelection } from "prosemirror-state";
|
|
777
|
+
var dialogs = null;
|
|
778
|
+
var dialogsLoading = null;
|
|
779
|
+
function loadDialogs() {
|
|
780
|
+
dialogsLoading ??= import("./dialog-3UZZZW6Y.js").then((module) => dialogs = module);
|
|
781
|
+
return dialogsLoading;
|
|
352
782
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
return template.content;
|
|
366
|
-
}
|
|
367
|
-
function openSpecDialog(editor, spec, reopen) {
|
|
368
|
-
const controls = /* @__PURE__ */ new Map();
|
|
369
|
-
const tabs = /* @__PURE__ */ new Map();
|
|
370
|
-
let currentTab = "";
|
|
371
|
-
let closedByApi = false;
|
|
372
|
-
let handle = null;
|
|
373
|
-
const notifyChange = (name) => spec.onChange?.(api, { name });
|
|
374
|
-
function field(item, input) {
|
|
375
|
-
const id = nextId();
|
|
376
|
-
input.id = id;
|
|
377
|
-
const wrap = el("div", "nova-field");
|
|
378
|
-
if (item.label) {
|
|
379
|
-
const label = el("label", "nova-label", item.label);
|
|
380
|
-
label.htmlFor = id;
|
|
381
|
-
wrap.append(label);
|
|
382
|
-
}
|
|
383
|
-
wrap.append(input);
|
|
384
|
-
return wrap;
|
|
385
|
-
}
|
|
386
|
-
function render(item) {
|
|
387
|
-
const name = item.name ?? "";
|
|
388
|
-
const enabled = item.enabled !== false && item.disabled !== true;
|
|
389
|
-
switch (item.type) {
|
|
390
|
-
case "input":
|
|
391
|
-
case "urlinput":
|
|
392
|
-
case "colorinput": {
|
|
393
|
-
const input = el("input", "nova-input");
|
|
394
|
-
input.type = item.type === "colorinput" ? "color" : item.type === "urlinput" ? "url" : "text";
|
|
395
|
-
if (item.inputMode) input.inputMode = item.inputMode;
|
|
396
|
-
if (item.placeholder) input.placeholder = item.placeholder;
|
|
397
|
-
input.disabled = !enabled;
|
|
398
|
-
input.addEventListener("input", () => notifyChange(name));
|
|
399
|
-
if (name) {
|
|
400
|
-
controls.set(name, {
|
|
401
|
-
// urlinput хранит { value }, остальные — строку.
|
|
402
|
-
get: () => item.type === "urlinput" ? { value: input.value } : input.value,
|
|
403
|
-
set: (value) => {
|
|
404
|
-
input.value = String(
|
|
405
|
-
item.type === "urlinput" && value && typeof value === "object" ? value.value ?? "" : value ?? ""
|
|
406
|
-
);
|
|
407
|
-
},
|
|
408
|
-
focus: () => input.focus(),
|
|
409
|
-
setEnabled: (on) => input.disabled = !on
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
return field(item, input);
|
|
413
|
-
}
|
|
414
|
-
case "textarea": {
|
|
415
|
-
const input = el("textarea", "nova-input");
|
|
416
|
-
input.rows = item.maximized ? 10 : 4;
|
|
417
|
-
if (item.placeholder) input.placeholder = item.placeholder;
|
|
418
|
-
input.disabled = !enabled;
|
|
419
|
-
input.addEventListener("input", () => notifyChange(name));
|
|
420
|
-
if (name) {
|
|
421
|
-
controls.set(name, {
|
|
422
|
-
get: () => input.value,
|
|
423
|
-
set: (value) => input.value = String(value ?? ""),
|
|
424
|
-
focus: () => input.focus(),
|
|
425
|
-
setEnabled: (on) => input.disabled = !on
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
return field(item, input);
|
|
429
|
-
}
|
|
430
|
-
case "checkbox": {
|
|
431
|
-
const input = el("input", "nova-checkbox");
|
|
432
|
-
input.type = "checkbox";
|
|
433
|
-
input.id = nextId();
|
|
434
|
-
input.disabled = !enabled;
|
|
435
|
-
input.addEventListener("change", () => notifyChange(name));
|
|
436
|
-
const label = el("label", void 0, item.label ?? "");
|
|
437
|
-
label.htmlFor = input.id;
|
|
438
|
-
if (name) {
|
|
439
|
-
controls.set(name, {
|
|
440
|
-
get: () => input.checked,
|
|
441
|
-
set: (value) => input.checked = Boolean(value),
|
|
442
|
-
focus: () => input.focus(),
|
|
443
|
-
setEnabled: (on) => input.disabled = !on
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
const wrap = el("div", "nova-field nova-field-inline");
|
|
447
|
-
wrap.append(input, label);
|
|
448
|
-
return wrap;
|
|
449
|
-
}
|
|
450
|
-
case "selectbox":
|
|
451
|
-
case "listbox": {
|
|
452
|
-
const select = el("select", "nova-input nova-select");
|
|
453
|
-
for (const option of item.items ?? []) {
|
|
454
|
-
const node = el("option", void 0, option.text);
|
|
455
|
-
node.value = option.value;
|
|
456
|
-
select.append(node);
|
|
457
|
-
}
|
|
458
|
-
select.disabled = !enabled;
|
|
459
|
-
select.addEventListener("change", () => notifyChange(name));
|
|
460
|
-
if (name) {
|
|
461
|
-
controls.set(name, {
|
|
462
|
-
get: () => select.value,
|
|
463
|
-
set: (value) => select.value = String(value ?? ""),
|
|
464
|
-
focus: () => select.focus(),
|
|
465
|
-
setEnabled: (on) => select.disabled = !on
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
return field(item, select);
|
|
469
|
-
}
|
|
470
|
-
case "button": {
|
|
471
|
-
const button = el(
|
|
472
|
-
"button",
|
|
473
|
-
item.primary || item.buttonType === "primary" ? "nova-button nova-button-primary" : "nova-button",
|
|
474
|
-
item.text ?? ""
|
|
475
|
-
);
|
|
476
|
-
button.type = "button";
|
|
477
|
-
button.disabled = !enabled;
|
|
478
|
-
button.addEventListener("click", () => spec.onAction?.(api, { name }));
|
|
479
|
-
if (name) {
|
|
480
|
-
controls.set(name, {
|
|
481
|
-
get: () => void 0,
|
|
482
|
-
set: () => {
|
|
483
|
-
},
|
|
484
|
-
focus: () => button.focus(),
|
|
485
|
-
setEnabled: (on) => button.disabled = !on
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
return button;
|
|
489
|
-
}
|
|
490
|
-
case "htmlpanel": {
|
|
491
|
-
const panel = el("div", "nova-compat-html");
|
|
492
|
-
panel.append(safeHtml(item.html ?? ""));
|
|
493
|
-
return panel;
|
|
494
|
-
}
|
|
495
|
-
case "alertbanner": {
|
|
496
|
-
const banner = el("p", `nova-compat-alert is-${item.level ?? "info"}`, item.text ?? "");
|
|
497
|
-
banner.setAttribute("role", item.level === "error" ? "alert" : "status");
|
|
498
|
-
return banner;
|
|
499
|
-
}
|
|
500
|
-
case "label": {
|
|
501
|
-
const group = el("div", "nova-compat-group");
|
|
502
|
-
group.append(el("p", "nova-label", item.label ?? ""));
|
|
503
|
-
for (const child of item.items ?? []) {
|
|
504
|
-
const node = render(child);
|
|
505
|
-
if (node) group.append(node);
|
|
506
|
-
}
|
|
507
|
-
return group;
|
|
508
|
-
}
|
|
509
|
-
case "grid":
|
|
510
|
-
case "bar": {
|
|
511
|
-
const grid = el("div", "nova-compat-grid");
|
|
512
|
-
const columns = item.type === "bar" ? item.items?.length ?? 1 : item.columns === "auto" ? 2 : item.columns ?? 2;
|
|
513
|
-
grid.style.gridTemplateColumns = `repeat(${Number(columns) || 2}, minmax(0, 1fr))`;
|
|
514
|
-
for (const child of item.items ?? []) {
|
|
515
|
-
const node = render(child);
|
|
516
|
-
if (node) grid.append(node);
|
|
517
|
-
}
|
|
518
|
-
return grid;
|
|
519
|
-
}
|
|
520
|
-
default:
|
|
521
|
-
console.warn(`[nova] tinymce-compat: dialog component "${item.type}" is not supported yet`);
|
|
522
|
-
return null;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
const body = el("div", "nova-compat-dialog nova-form");
|
|
526
|
-
if (spec.body.type === "tabpanel") {
|
|
527
|
-
const tabList = el("div", "nova-compat-tabs");
|
|
528
|
-
tabList.setAttribute("role", "tablist");
|
|
529
|
-
body.append(tabList);
|
|
530
|
-
spec.body.tabs.forEach((tab, index) => {
|
|
531
|
-
const name = tab.name ?? tab.title;
|
|
532
|
-
const button = el("button", "nova-compat-tab", tab.title);
|
|
533
|
-
button.type = "button";
|
|
534
|
-
button.setAttribute("role", "tab");
|
|
535
|
-
const panel = el("div", "nova-compat-tabpanel");
|
|
536
|
-
panel.setAttribute("role", "tabpanel");
|
|
537
|
-
for (const item of tab.items) {
|
|
538
|
-
const node = render(item);
|
|
539
|
-
if (node) panel.append(node);
|
|
540
|
-
}
|
|
541
|
-
button.addEventListener("click", () => api.showTab(name));
|
|
542
|
-
tabs.set(name, { button, panel });
|
|
543
|
-
tabList.append(button);
|
|
544
|
-
body.append(panel);
|
|
545
|
-
if (index === 0) currentTab = name;
|
|
546
|
-
});
|
|
547
|
-
} else {
|
|
548
|
-
for (const item of spec.body.items) {
|
|
549
|
-
const node = render(item);
|
|
550
|
-
if (node) body.append(node);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
const buttons = spec.buttons ?? [];
|
|
554
|
-
const submit = buttons.find((b) => b.type === "submit");
|
|
555
|
-
const custom = buttons.filter((b) => b.type === "custom");
|
|
556
|
-
if (custom.length) {
|
|
557
|
-
const row = el("div", "nova-compat-actions");
|
|
558
|
-
for (const b of custom) {
|
|
559
|
-
const button = el(
|
|
560
|
-
"button",
|
|
561
|
-
b.primary ? "nova-button nova-button-primary" : "nova-button",
|
|
562
|
-
b.text
|
|
563
|
-
);
|
|
564
|
-
button.type = "button";
|
|
565
|
-
button.disabled = b.enabled === false;
|
|
566
|
-
button.addEventListener("click", () => spec.onAction?.(api, { name: b.name ?? b.text }));
|
|
567
|
-
if (b.name) {
|
|
568
|
-
controls.set(b.name, {
|
|
569
|
-
get: () => void 0,
|
|
570
|
-
set: () => {
|
|
571
|
-
},
|
|
572
|
-
focus: () => button.focus(),
|
|
573
|
-
setEnabled: (on) => button.disabled = !on
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
row.append(button);
|
|
577
|
-
}
|
|
578
|
-
body.append(row);
|
|
579
|
-
}
|
|
580
|
-
const api = {
|
|
581
|
-
getData: () => {
|
|
582
|
-
const data = {};
|
|
583
|
-
controls.forEach((control, name) => {
|
|
584
|
-
const value = control.get();
|
|
585
|
-
if (value !== void 0) data[name] = value;
|
|
586
|
-
});
|
|
587
|
-
return data;
|
|
588
|
-
},
|
|
589
|
-
setData: (data) => {
|
|
590
|
-
for (const [name, value] of Object.entries(data)) controls.get(name)?.set(value);
|
|
591
|
-
},
|
|
592
|
-
close: () => {
|
|
593
|
-
closedByApi = true;
|
|
594
|
-
handle?.close();
|
|
595
|
-
},
|
|
596
|
-
block: () => handle?.setBusy(true),
|
|
597
|
-
unblock: () => handle?.setBusy(false),
|
|
598
|
-
focus: (name) => controls.get(name)?.focus(),
|
|
599
|
-
disable: (name) => controls.get(name)?.setEnabled(false),
|
|
600
|
-
enable: (name) => controls.get(name)?.setEnabled(true),
|
|
601
|
-
showTab: (name) => {
|
|
602
|
-
if (!tabs.has(name)) return;
|
|
603
|
-
const old = currentTab;
|
|
604
|
-
currentTab = name;
|
|
605
|
-
tabs.forEach(({ button, panel }, key) => {
|
|
606
|
-
const on = key === name;
|
|
607
|
-
button.setAttribute("aria-selected", String(on));
|
|
608
|
-
button.tabIndex = on ? 0 : -1;
|
|
609
|
-
panel.hidden = !on;
|
|
610
|
-
});
|
|
611
|
-
if (old && old !== name) spec.onTabChange?.(api, { newTabName: name, oldTabName: old });
|
|
783
|
+
function openDialog(core, spec, reopen) {
|
|
784
|
+
if (dialogs) return dialogs.openSpecDialog(core, spec, reopen);
|
|
785
|
+
let real = null;
|
|
786
|
+
let data = { ...spec.initialData ?? {} };
|
|
787
|
+
const queue = [];
|
|
788
|
+
void loadDialogs().then(
|
|
789
|
+
(module) => {
|
|
790
|
+
real = module.openSpecDialog(core, { ...spec, initialData: data }, reopen);
|
|
791
|
+
for (const call of queue.splice(0)) call(real);
|
|
612
792
|
},
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
793
|
+
(error) => console.error("[nova] windowManager: could not load dialogs", error)
|
|
794
|
+
);
|
|
795
|
+
const later = (method) => (...args) => {
|
|
796
|
+
const call = (api) => api[method](...args);
|
|
797
|
+
if (real) call(real);
|
|
798
|
+
else queue.push(call);
|
|
617
799
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
...submit ? { submitLabel: submit.text } : {},
|
|
624
|
-
...spec.size === "large" ? { size: "large" } : {},
|
|
625
|
-
onSubmit: () => {
|
|
626
|
-
spec.onSubmit?.(api);
|
|
627
|
-
return closedByApi;
|
|
800
|
+
return {
|
|
801
|
+
getData: () => real ? real.getData() : { ...data },
|
|
802
|
+
setData: (next) => {
|
|
803
|
+
if (real) real.setData(next);
|
|
804
|
+
else data = { ...data, ...next };
|
|
628
805
|
},
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
806
|
+
close: later("close"),
|
|
807
|
+
block: later("block"),
|
|
808
|
+
unblock: later("unblock"),
|
|
809
|
+
focus: later("focus"),
|
|
810
|
+
disable: later("disable"),
|
|
811
|
+
enable: later("enable"),
|
|
812
|
+
showTab: later("showTab"),
|
|
813
|
+
redial: later("redial")
|
|
814
|
+
};
|
|
635
815
|
}
|
|
636
|
-
|
|
637
|
-
// src/editor.ts
|
|
638
|
-
import { AllSelection, NodeSelection, TextSelection } from "prosemirror-state";
|
|
639
|
-
var serializer = new HTMLSerializer();
|
|
640
816
|
var COMMANDS = {
|
|
641
817
|
bold: "bold",
|
|
642
818
|
italic: "italic",
|
|
@@ -659,6 +835,69 @@ var COMMANDS = {
|
|
|
659
835
|
inserthorizontalrule: "horizontalRule",
|
|
660
836
|
mceblockquote: "blockquote"
|
|
661
837
|
};
|
|
838
|
+
var PLUGIN_COMMANDS = {
|
|
839
|
+
mcelowercase: "lowercase",
|
|
840
|
+
mceuppercase: "uppercase",
|
|
841
|
+
mcetitlecase: "titlecase",
|
|
842
|
+
mcetoggleformatpainter: "formatpainter",
|
|
843
|
+
mcetogglepermanentpen: "permanentpen",
|
|
844
|
+
mceconfigurepermanentpen: "configurepermanentpen",
|
|
845
|
+
mcevisualchars: "visualchars",
|
|
846
|
+
mcesave: "save",
|
|
847
|
+
mcecancel: "cancel",
|
|
848
|
+
mcetemplate: "template",
|
|
849
|
+
mceinsertfootnote: "footnotes",
|
|
850
|
+
mceupdatefootnotes: "footnotesupdate",
|
|
851
|
+
mcespellcheckdialog: "spellcheckdialog",
|
|
852
|
+
mcetypography: "typography",
|
|
853
|
+
mcecodeeditor: "code",
|
|
854
|
+
mceimagerotateleft: "rotateleft",
|
|
855
|
+
mceimagerotateright: "rotateright",
|
|
856
|
+
mceimageflipvertical: "flipv",
|
|
857
|
+
mceimagefliphorizontal: "fliph",
|
|
858
|
+
mceeditimage: "editimage",
|
|
859
|
+
mcefullpagehtmlproperties: "fullpagehtml"
|
|
860
|
+
};
|
|
861
|
+
var SPELLCHECK_COMMANDS = /* @__PURE__ */ new Set([
|
|
862
|
+
"mcespellcheckenable",
|
|
863
|
+
"mcespellcheckdisable",
|
|
864
|
+
"mcespellcheckupdate",
|
|
865
|
+
"mcespellcheckdialogclose"
|
|
866
|
+
]);
|
|
867
|
+
var ADVTABLE_COMMANDS = {
|
|
868
|
+
mceadvancedtablesort: () => ({ command: "dialog" }),
|
|
869
|
+
mcesorttablebycolumnasc: () => ({ command: "sort", value: { by: "column", direction: "asc" } }),
|
|
870
|
+
mcesorttablebycolumndesc: () => ({
|
|
871
|
+
command: "sort",
|
|
872
|
+
value: { by: "column", direction: "desc" }
|
|
873
|
+
}),
|
|
874
|
+
mcesorttablebyrowasc: () => ({ command: "sort", value: { by: "row", direction: "asc" } }),
|
|
875
|
+
mcesorttablebyrowdesc: () => ({ command: "sort", value: { by: "row", direction: "desc" } }),
|
|
876
|
+
// { sortby: 'row' | 'column', roworcol: '0', sort: 'table' | 'selection' | …, order }
|
|
877
|
+
mcesorttableadvanced: (value) => {
|
|
878
|
+
const v = value && typeof value === "object" ? value : {};
|
|
879
|
+
const index = Number(v.roworcol);
|
|
880
|
+
return {
|
|
881
|
+
command: "sort",
|
|
882
|
+
value: {
|
|
883
|
+
by: v.sortby === "row" ? "row" : "column",
|
|
884
|
+
...Number.isInteger(index) && index >= 0 ? { index } : {},
|
|
885
|
+
direction: v.order === "descending" ? "desc" : "asc",
|
|
886
|
+
scope: v.sort === "selection" ? "selection" : "table"
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
},
|
|
890
|
+
mcetabletoggleseries: (value) => ({
|
|
891
|
+
command: "series",
|
|
892
|
+
value: value?.name
|
|
893
|
+
})
|
|
894
|
+
};
|
|
895
|
+
var ACCORDION_COMMANDS = /* @__PURE__ */ new Set([
|
|
896
|
+
"insertaccordion",
|
|
897
|
+
"removeaccordion",
|
|
898
|
+
"toggleaccordion",
|
|
899
|
+
"toggleallaccordions"
|
|
900
|
+
]);
|
|
662
901
|
var FORMAT_BLOCKS = {
|
|
663
902
|
p: "paragraph",
|
|
664
903
|
h1: "h1",
|
|
@@ -790,7 +1029,7 @@ function buttonApi(compat) {
|
|
|
790
1029
|
enabled = value;
|
|
791
1030
|
compat.core.updateUI();
|
|
792
1031
|
},
|
|
793
|
-
//
|
|
1032
|
+
// Compatibility with older versions of the API.
|
|
794
1033
|
isDisabled: () => !enabled,
|
|
795
1034
|
setDisabled: (value) => {
|
|
796
1035
|
enabled = !value;
|
|
@@ -804,6 +1043,11 @@ var CompatEditor = class {
|
|
|
804
1043
|
core;
|
|
805
1044
|
targetElm;
|
|
806
1045
|
settings;
|
|
1046
|
+
/**
|
|
1047
|
+
* The plugins by their TinyMCE names (`editor.plugins.lists`): the listed ones that work here, and
|
|
1048
|
+
* what your own plugins return. inlinecss has `getContent()`: the content with its styles inline.
|
|
1049
|
+
*/
|
|
1050
|
+
plugins = {};
|
|
807
1051
|
initialized = false;
|
|
808
1052
|
removed = false;
|
|
809
1053
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -814,25 +1058,29 @@ var CompatEditor = class {
|
|
|
814
1058
|
this.targetElm = target;
|
|
815
1059
|
this.id = id;
|
|
816
1060
|
this.settings = settings;
|
|
1061
|
+
setTimeout(() => void loadDialogs().catch(() => {
|
|
1062
|
+
}), 0);
|
|
817
1063
|
}
|
|
818
|
-
// ----------
|
|
1064
|
+
// ---------- content ----------
|
|
819
1065
|
getContent(args = {}) {
|
|
820
1066
|
const event = { format: args.format ?? "html", content: "" };
|
|
821
|
-
event.content = event.format === "text" ? this.core.getText() : this.core.getHTML();
|
|
1067
|
+
event.content = event.format === "text" ? this.core.getText() : this.core.getHTML({ fullPage: args.fullpagehtml !== false });
|
|
1068
|
+
const prettify = args.prettify === true || this.settings.advcode_prettify_getcontent === true && this.core.hasPlugin("advcode");
|
|
1069
|
+
if (prettify && event.format !== "text") event.content = prettyHTML(event.content);
|
|
822
1070
|
this.fire("GetContent", event);
|
|
823
1071
|
return event.content;
|
|
824
1072
|
}
|
|
825
1073
|
setContent(content, args = {}) {
|
|
826
1074
|
const event = { content, ...args };
|
|
827
1075
|
this.fire("BeforeSetContent", event);
|
|
828
|
-
this.core.setContent(event.content);
|
|
1076
|
+
this.core.setContent(event.content, { fullPage: args.fullpagehtml !== false });
|
|
829
1077
|
this.fire("SetContent", event);
|
|
830
1078
|
return event.content;
|
|
831
1079
|
}
|
|
832
1080
|
/**
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
1081
|
+
* Insert HTML in place of the selection. Blocks (<p>, lists, tables) go in as separate blocks (the
|
|
1082
|
+
* paragraph is split), inline content into the current line. Parsed by the editor's schema: the
|
|
1083
|
+
* same link and markup checks as when content is loaded.
|
|
836
1084
|
*/
|
|
837
1085
|
insertContent(content) {
|
|
838
1086
|
this.core.insertContent(content);
|
|
@@ -861,10 +1109,11 @@ var CompatEditor = class {
|
|
|
861
1109
|
getWin() {
|
|
862
1110
|
return this.core.root.ownerDocument.defaultView;
|
|
863
1111
|
}
|
|
864
|
-
// ----------
|
|
865
|
-
/**
|
|
1112
|
+
// ---------- commands ----------
|
|
1113
|
+
/** The value of a command: for ToggleSidebar and ToggleView, the name of the open one. */
|
|
866
1114
|
queryCommandValue(command) {
|
|
867
1115
|
if (command.toLowerCase() === "togglesidebar") return this.core.ui.sidebar.active ?? "";
|
|
1116
|
+
if (command.toLowerCase() === "toggleview") return this.core.ui.view.active ?? "";
|
|
868
1117
|
return "";
|
|
869
1118
|
}
|
|
870
1119
|
execCommand(command, _ui, value) {
|
|
@@ -877,12 +1126,56 @@ var CompatEditor = class {
|
|
|
877
1126
|
} else if (name === "mceinsertcontent" || name === "inserthtml") {
|
|
878
1127
|
this.insertContent(String(value ?? ""));
|
|
879
1128
|
done = true;
|
|
1129
|
+
} else if (name === "toggleview") {
|
|
1130
|
+
this.core.ui.view.toggle(String(value ?? ""));
|
|
1131
|
+
done = true;
|
|
880
1132
|
} else if (name === "togglesidebar") {
|
|
881
1133
|
void this.core.ui.sidebar.toggle(String(value ?? ""));
|
|
882
1134
|
done = true;
|
|
1135
|
+
} else if ((name === "mceaidialog" || name === "mceaidialogclose") && this.core.hasPlugin("ai")) {
|
|
1136
|
+
const options = value && typeof value === "object" ? value : {};
|
|
1137
|
+
const detail = {
|
|
1138
|
+
...typeof options.prompt === "string" ? { prompt: options.prompt } : {},
|
|
1139
|
+
...options.generate === true ? { generate: true } : {},
|
|
1140
|
+
...options.display === false ? { display: false } : {}
|
|
1141
|
+
};
|
|
1142
|
+
this.core.root.dispatchEvent(
|
|
1143
|
+
name === "mceaidialog" ? new CustomEvent("nova-ai-dialog", { detail }) : new CustomEvent("nova-ai-dialog-close")
|
|
1144
|
+
);
|
|
1145
|
+
done = true;
|
|
883
1146
|
} else if (name === "mcesetcontent") {
|
|
884
1147
|
this.setContent(String(value ?? ""));
|
|
885
1148
|
done = true;
|
|
1149
|
+
} else if (name === "mceinserttoc" || name === "mceupdatetoc") {
|
|
1150
|
+
const control = this.core.ui.registry.get(
|
|
1151
|
+
name === "mceinserttoc" ? "tableofcontents" : "tableofcontentsupdate"
|
|
1152
|
+
);
|
|
1153
|
+
if (control?.type === "button") {
|
|
1154
|
+
control.onAction(this.core);
|
|
1155
|
+
done = true;
|
|
1156
|
+
}
|
|
1157
|
+
} else if (ADVTABLE_COMMANDS[name] && this.core.hasPlugin("advtable")) {
|
|
1158
|
+
this.core.root.dispatchEvent(
|
|
1159
|
+
new CustomEvent("nova-advtable", { detail: ADVTABLE_COMMANDS[name](value) })
|
|
1160
|
+
);
|
|
1161
|
+
done = true;
|
|
1162
|
+
} else if (ACCORDION_COMMANDS.has(name)) {
|
|
1163
|
+
done = this.accordionCommand(name, value);
|
|
1164
|
+
} else if (name === "mceinserttemplate" && this.core.hasPlugin("template")) {
|
|
1165
|
+
this.core.root.dispatchEvent(
|
|
1166
|
+
new CustomEvent("nova-insert-template", { detail: String(value ?? "") })
|
|
1167
|
+
);
|
|
1168
|
+
done = true;
|
|
1169
|
+
} else if (SPELLCHECK_COMMANDS.has(name) && this.core.hasPlugin("spellchecker")) {
|
|
1170
|
+
done = this.spellcheckCommand(name);
|
|
1171
|
+
} else if (PLUGIN_COMMANDS[name] || name === "mcetogglestickyformatpainter") {
|
|
1172
|
+
done = this.pluginCommand(name);
|
|
1173
|
+
} else if (name === "codesample") {
|
|
1174
|
+
const button = this.core.ui.registry.get("codesample");
|
|
1175
|
+
if (button?.type === "button") {
|
|
1176
|
+
button.onAction(this.core);
|
|
1177
|
+
done = true;
|
|
1178
|
+
}
|
|
886
1179
|
} else if (name === "selectall") {
|
|
887
1180
|
const { state, dispatch } = this.core.view;
|
|
888
1181
|
dispatch(state.tr.setSelection(new AllSelection(state.doc)));
|
|
@@ -899,19 +1192,97 @@ var CompatEditor = class {
|
|
|
899
1192
|
if (done) this.fire("ExecCommand", { command, ui: _ui, value });
|
|
900
1193
|
return done;
|
|
901
1194
|
}
|
|
1195
|
+
/**
|
|
1196
|
+
* InsertAccordion / RemoveAccordion — like the accordion button (inside one, remove the frame;
|
|
1197
|
+
* otherwise insert); ToggleAccordion / ToggleAllAccordions — value true expands, false collapses,
|
|
1198
|
+
* no value toggles. Collapsing is a view, not an edit: it doesn't go into the undo history.
|
|
1199
|
+
*/
|
|
1200
|
+
spellcheckCommand(name) {
|
|
1201
|
+
if (name === "mcespellcheckdialogclose") {
|
|
1202
|
+
this.core.ui.closeOverlays();
|
|
1203
|
+
return true;
|
|
1204
|
+
}
|
|
1205
|
+
if (name === "mcespellcheckupdate") return true;
|
|
1206
|
+
const toggle = this.core.ui.registry.get("spellchecker");
|
|
1207
|
+
if (!toggle) return false;
|
|
1208
|
+
const on = !!toggle.isActive?.(this.core);
|
|
1209
|
+
if (name === "mcespellcheckenable" !== on) toggle.onAction(this.core);
|
|
1210
|
+
return true;
|
|
1211
|
+
}
|
|
1212
|
+
accordionCommand(name, value) {
|
|
1213
|
+
const { view } = this.core;
|
|
1214
|
+
const { state } = view;
|
|
1215
|
+
const $from = state.selection.$from;
|
|
1216
|
+
let around = null;
|
|
1217
|
+
for (let depth = $from.depth; depth > 0 && !around; depth--) {
|
|
1218
|
+
const node = $from.node(depth);
|
|
1219
|
+
if (node.type.name === "details") {
|
|
1220
|
+
around = { pos: $from.before(depth), open: node.attrs.open !== false };
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (name === "insertaccordion" || name === "removeaccordion") {
|
|
1224
|
+
if (name === "removeaccordion" !== !!around) return false;
|
|
1225
|
+
const button = this.core.ui.registry.get("accordion");
|
|
1226
|
+
if (button?.type !== "button") return false;
|
|
1227
|
+
button.onAction(this.core);
|
|
1228
|
+
return true;
|
|
1229
|
+
}
|
|
1230
|
+
const all = [];
|
|
1231
|
+
if (name === "toggleaccordion") {
|
|
1232
|
+
if (around) all.push(around);
|
|
1233
|
+
} else {
|
|
1234
|
+
state.doc.descendants((node, pos) => {
|
|
1235
|
+
if (node.type.name === "details") all.push({ pos, open: node.attrs.open !== false });
|
|
1236
|
+
return !node.isTextblock;
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
if (!all.length) return false;
|
|
1240
|
+
const open = typeof value === "boolean" ? value : !all.every((d) => d.open);
|
|
1241
|
+
const tr = state.tr;
|
|
1242
|
+
for (const details of all) tr.setNodeAttribute(details.pos, "open", open);
|
|
1243
|
+
view.dispatch(tr.setMeta("addToHistory", false));
|
|
1244
|
+
return true;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* A command of casechange, formatpainter or permanentpen: like its menu item or button.
|
|
1248
|
+
* mceToggleStickyFormatPainter turns the painter on to stay (a double click on the button), or off.
|
|
1249
|
+
*/
|
|
1250
|
+
pluginCommand(name) {
|
|
1251
|
+
const { registry } = this.core.ui;
|
|
1252
|
+
if (name === "mcetogglestickyformatpainter") {
|
|
1253
|
+
const painter = registry.get("formatpainter");
|
|
1254
|
+
const item2 = registry.getMenuItem("formatpainter");
|
|
1255
|
+
if (painter?.type !== "button" || !item2) return false;
|
|
1256
|
+
if (item2.isActive?.(this.core)) item2.onAction(this.core);
|
|
1257
|
+
else {
|
|
1258
|
+
painter.onAction(this.core);
|
|
1259
|
+
painter.onAction(this.core);
|
|
1260
|
+
}
|
|
1261
|
+
return true;
|
|
1262
|
+
}
|
|
1263
|
+
const item = registry.getMenuItem(PLUGIN_COMMANDS[name]);
|
|
1264
|
+
if (!item || name !== "mcesave" && item.isEnabled?.(this.core) === false) return false;
|
|
1265
|
+
item.onAction(this.core);
|
|
1266
|
+
return true;
|
|
1267
|
+
}
|
|
902
1268
|
queryCommandState(command) {
|
|
903
|
-
const
|
|
904
|
-
|
|
1269
|
+
const lower = command.toLowerCase();
|
|
1270
|
+
const name = COMMANDS[lower];
|
|
1271
|
+
if (name) return this.core.isActive(name);
|
|
1272
|
+
if (lower === "mcetoggleformatpainter" || lower === "mcetogglepermanentpen") {
|
|
1273
|
+
return !!this.core.ui.registry.getMenuItem(PLUGIN_COMMANDS[lower])?.isActive?.(this.core);
|
|
1274
|
+
}
|
|
1275
|
+
return false;
|
|
905
1276
|
}
|
|
906
1277
|
queryCommandSupported(command) {
|
|
907
1278
|
const name = command.toLowerCase();
|
|
908
|
-
return name in COMMANDS || ["formatblock", "mceinsertcontent", "mcesetcontent"].includes(name) || this.commands.has(name);
|
|
1279
|
+
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);
|
|
909
1280
|
}
|
|
910
1281
|
commands = /* @__PURE__ */ new Map();
|
|
911
1282
|
addCommand(name, callback) {
|
|
912
1283
|
this.commands.set(name.toLowerCase(), callback);
|
|
913
1284
|
}
|
|
914
|
-
// ----------
|
|
1285
|
+
// ---------- events ----------
|
|
915
1286
|
on(names, handler, prepend = false) {
|
|
916
1287
|
for (const name of names.toLowerCase().split(/\s+/).filter(Boolean)) {
|
|
917
1288
|
const set = this.handlers.get(name) ?? /* @__PURE__ */ new Set();
|
|
@@ -949,7 +1320,7 @@ var CompatEditor = class {
|
|
|
949
1320
|
}
|
|
950
1321
|
return payload;
|
|
951
1322
|
}
|
|
952
|
-
/** DOM
|
|
1323
|
+
/** A DOM event of the text (keydown, click…): handlers get the browser's event itself. */
|
|
953
1324
|
fireNative(name, event) {
|
|
954
1325
|
for (const handler of [...this.handlers.get(name) ?? []]) {
|
|
955
1326
|
try {
|
|
@@ -959,18 +1330,18 @@ var CompatEditor = class {
|
|
|
959
1330
|
}
|
|
960
1331
|
}
|
|
961
1332
|
}
|
|
962
|
-
/**
|
|
1333
|
+
/** An icon for buttons by name (tinymce.IconManager / editor.ui.registry.addIcon). */
|
|
963
1334
|
static registerIcon(name, svg) {
|
|
964
1335
|
customIcons.set(name, svg);
|
|
965
1336
|
}
|
|
966
|
-
/**
|
|
1337
|
+
/** The newer name of fire in recent versions of the API. */
|
|
967
1338
|
dispatch(name, event) {
|
|
968
1339
|
return this.fire(name, event);
|
|
969
1340
|
}
|
|
970
1341
|
hasEventListeners(name) {
|
|
971
1342
|
return (this.handlers.get(name.toLowerCase())?.size ?? 0) > 0;
|
|
972
1343
|
}
|
|
973
|
-
// ----------
|
|
1344
|
+
// ---------- state ----------
|
|
974
1345
|
isDirty() {
|
|
975
1346
|
return this.dirty;
|
|
976
1347
|
}
|
|
@@ -979,7 +1350,7 @@ var CompatEditor = class {
|
|
|
979
1350
|
this.dirty = state;
|
|
980
1351
|
if (changed && state) this.fire("Dirty");
|
|
981
1352
|
}
|
|
982
|
-
/**
|
|
1353
|
+
/** Write the content into the original <textarea> (as on form submit). */
|
|
983
1354
|
save() {
|
|
984
1355
|
const content = this.getContent();
|
|
985
1356
|
const event = this.fire("SaveContent", { content });
|
|
@@ -1040,44 +1411,35 @@ var CompatEditor = class {
|
|
|
1040
1411
|
},
|
|
1041
1412
|
ignore: (callback) => callback()
|
|
1042
1413
|
};
|
|
1414
|
+
/** TinyMCE's editor.selection, on top of the core's editor.selection. */
|
|
1043
1415
|
selection = {
|
|
1044
|
-
getContent: (args = {}) =>
|
|
1045
|
-
const { state } = this.core.view;
|
|
1046
|
-
const { from, to } = state.selection;
|
|
1047
|
-
if (args.format === "text") return state.doc.textBetween(from, to, "\n");
|
|
1048
|
-
return serializer.serializeFragment(state.selection.content().content);
|
|
1049
|
-
},
|
|
1416
|
+
getContent: (args = {}) => args.format === "text" ? this.core.selection.getText() : this.core.selection.getHTML(),
|
|
1050
1417
|
setContent: (content) => this.insertContent(content),
|
|
1051
|
-
getNode: () =>
|
|
1052
|
-
const { from } = this.core.view.state.selection;
|
|
1053
|
-
const { node } = this.core.view.domAtPos(from);
|
|
1054
|
-
return node instanceof Element ? node : node.parentElement;
|
|
1055
|
-
},
|
|
1418
|
+
getNode: () => this.core.selection.getNode() ?? this.core.view.dom,
|
|
1056
1419
|
getStart: () => this.selection.getNode(),
|
|
1057
1420
|
getEnd: () => this.selection.getNode(),
|
|
1058
|
-
isCollapsed: () => this.core.
|
|
1059
|
-
collapse: (toStart = false) =>
|
|
1060
|
-
|
|
1061
|
-
const pos = toStart ? state.selection.from : state.selection.to;
|
|
1062
|
-
dispatch(state.tr.setSelection(TextSelection.near(state.doc.resolve(pos))));
|
|
1063
|
-
},
|
|
1064
|
-
/** Курсор в узел DOM редактора (по умолчанию — в начало). */
|
|
1421
|
+
isCollapsed: () => this.core.selection.isCollapsed(),
|
|
1422
|
+
collapse: (toStart = false) => this.core.selection.collapse(toStart),
|
|
1423
|
+
/** Put the cursor in a DOM node of the editor (at its start by default). */
|
|
1065
1424
|
setCursorLocation: (node, offset = 0) => {
|
|
1066
|
-
|
|
1067
|
-
if (!node || !view.dom.contains(node)) return;
|
|
1068
|
-
const pos = view.posAtDOM(node, offset);
|
|
1069
|
-
view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(pos))));
|
|
1425
|
+
if (node) this.core.selection.setCursorLocation(node, offset);
|
|
1070
1426
|
},
|
|
1071
|
-
/**
|
|
1072
|
-
select: (node, content = false) =>
|
|
1427
|
+
/** Select an element: content = true — only its content. */
|
|
1428
|
+
select: (node, content = false) => this.core.selection.select(node, content),
|
|
1429
|
+
/** The selection as a DOM Range. */
|
|
1430
|
+
getRng: () => this.core.selection.getDOMRange(),
|
|
1431
|
+
/** Select a DOM Range of the editing area. */
|
|
1432
|
+
setRng: (range) => {
|
|
1073
1433
|
const { view } = this.core;
|
|
1074
|
-
if (!view.dom.contains(
|
|
1075
|
-
const from = view.posAtDOM(
|
|
1076
|
-
const to = view.posAtDOM(
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1434
|
+
if (!range || !view.dom.contains(range.startContainer)) return;
|
|
1435
|
+
const from = view.posAtDOM(range.startContainer, range.startOffset);
|
|
1436
|
+
const to = view.dom.contains(range.endContainer) ? view.posAtDOM(range.endContainer, range.endOffset) : from;
|
|
1437
|
+
this.core.selection.setRange(from, to);
|
|
1438
|
+
},
|
|
1439
|
+
/** Remember the selection; moveToBookmark() puts it back, wherever later changes moved it. */
|
|
1440
|
+
getBookmark: () => this.core.selection.getBookmark(),
|
|
1441
|
+
moveToBookmark: (bookmark) => this.core.selection.moveToBookmark(bookmark),
|
|
1442
|
+
scrollIntoView: () => this.core.selection.scrollIntoView()
|
|
1081
1443
|
};
|
|
1082
1444
|
notificationManager = {
|
|
1083
1445
|
open: (args) => this.core.ui.notify({
|
|
@@ -1114,9 +1476,9 @@ var CompatEditor = class {
|
|
|
1114
1476
|
onClose: () => callback?.(confirmed)
|
|
1115
1477
|
});
|
|
1116
1478
|
},
|
|
1117
|
-
open: (spec) =>
|
|
1479
|
+
open: (spec) => openDialog(this.core, spec, (next) => this.windowManager.open(next))
|
|
1118
1480
|
};
|
|
1119
|
-
/** editor.ui.registry —
|
|
1481
|
+
/** editor.ui.registry — buttons and menu items in TinyMCE format on top of the NovaProse registry. */
|
|
1120
1482
|
ui = {
|
|
1121
1483
|
registry: {
|
|
1122
1484
|
addIcon: (name, svg) => {
|
|
@@ -1152,8 +1514,8 @@ var CompatEditor = class {
|
|
|
1152
1514
|
});
|
|
1153
1515
|
},
|
|
1154
1516
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
* position: 'node' (
|
|
1517
|
+
* A context toolbar: predicate(node) gets the element at the cursor, items are toolbar buttons.
|
|
1518
|
+
* position: 'node' (above the element) or 'selection'/'line' (at the selection).
|
|
1157
1519
|
*/
|
|
1158
1520
|
addContextToolbar: (name, spec) => {
|
|
1159
1521
|
this.core.ui.registry.addContextToolbar(name, {
|
|
@@ -1167,8 +1529,8 @@ var CompatEditor = class {
|
|
|
1167
1529
|
});
|
|
1168
1530
|
},
|
|
1169
1531
|
/**
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1532
|
+
* A sidebar: onSetup(api) draws the content into api.element() (once), onShow/onHide run when it
|
|
1533
|
+
* is shown or hidden. A toggle button named after the sidebar is for the toolbar; ToggleSidebar is the command.
|
|
1172
1534
|
*/
|
|
1173
1535
|
addSidebar: (name, spec) => {
|
|
1174
1536
|
let element = null;
|
|
@@ -1186,6 +1548,21 @@ var CompatEditor = class {
|
|
|
1186
1548
|
onHide: () => spec.onHide?.(api)
|
|
1187
1549
|
});
|
|
1188
1550
|
},
|
|
1551
|
+
/**
|
|
1552
|
+
* A view in place of the editor: buttons at its top, onShow/onHide get api.getContainer(), where it
|
|
1553
|
+
* draws; ToggleView is the command.
|
|
1554
|
+
*/
|
|
1555
|
+
addView: (name, spec) => {
|
|
1556
|
+
this.core.ui.registry.addView(name, {
|
|
1557
|
+
buttons: (Array.isArray(spec.buttons) ? spec.buttons : []).filter((button) => typeof button?.text === "string").map((button) => ({
|
|
1558
|
+
text: button.text,
|
|
1559
|
+
buttonType: button.buttonType === "primary" ? "primary" : "secondary",
|
|
1560
|
+
onAction: () => button.onAction?.()
|
|
1561
|
+
})),
|
|
1562
|
+
...spec.onShow ? { onShow: spec.onShow } : {},
|
|
1563
|
+
...spec.onHide ? { onHide: spec.onHide } : {}
|
|
1564
|
+
});
|
|
1565
|
+
},
|
|
1189
1566
|
addContextForm: () => {
|
|
1190
1567
|
console.warn("[nova] tinymce-compat: addContextForm is not supported yet");
|
|
1191
1568
|
},
|
|
@@ -1214,9 +1591,9 @@ var CompatEditor = class {
|
|
|
1214
1591
|
}
|
|
1215
1592
|
}
|
|
1216
1593
|
/**
|
|
1217
|
-
* editor.dom —
|
|
1218
|
-
*
|
|
1219
|
-
* formatter
|
|
1594
|
+
* editor.dom — what makes sense on top of a document model: finding and reading. The text's DOM
|
|
1595
|
+
* can't be changed directly (the editor redraws it from the model); use setContent, insertContent
|
|
1596
|
+
* or formatter for edits — such calls log a warning.
|
|
1220
1597
|
*/
|
|
1221
1598
|
dom = {
|
|
1222
1599
|
select: (selector, scope) => [
|
|
@@ -1252,7 +1629,7 @@ var CompatEditor = class {
|
|
|
1252
1629
|
textarea.innerHTML = html;
|
|
1253
1630
|
return textarea.value;
|
|
1254
1631
|
},
|
|
1255
|
-
/**
|
|
1632
|
+
/** A new (not inserted) element: attributes via setAttribute, the content as text. */
|
|
1256
1633
|
create: (tag, attrs = {}, text) => {
|
|
1257
1634
|
const node = document.createElement(tag);
|
|
1258
1635
|
for (const [name, value] of Object.entries(attrs)) {
|
|
@@ -1269,8 +1646,8 @@ var CompatEditor = class {
|
|
|
1269
1646
|
remove: () => warnDom("remove")
|
|
1270
1647
|
};
|
|
1271
1648
|
/**
|
|
1272
|
-
* editor.formatter —
|
|
1273
|
-
*
|
|
1649
|
+
* editor.formatter — the built-in TinyMCE formats: apply/remove/toggle/match. Your own formats
|
|
1650
|
+
* (register) are not supported yet.
|
|
1274
1651
|
*/
|
|
1275
1652
|
formatter = {
|
|
1276
1653
|
apply: (name, vars = {}) => this.applyFormat(name, vars, "apply"),
|
|
@@ -1351,7 +1728,7 @@ var CompatEditor = class {
|
|
|
1351
1728
|
}
|
|
1352
1729
|
console.warn(`[nova] tinymce-compat: format "${name}" is not supported yet`);
|
|
1353
1730
|
}
|
|
1354
|
-
/**
|
|
1731
|
+
/** Remove the editor and restore the original element (like editor.remove()). */
|
|
1355
1732
|
remove() {
|
|
1356
1733
|
if (this.removed) return;
|
|
1357
1734
|
this.fire("remove");
|
|
@@ -1411,15 +1788,76 @@ function createTinymce() {
|
|
|
1411
1788
|
settings.__wrapper = host;
|
|
1412
1789
|
}
|
|
1413
1790
|
let compat;
|
|
1791
|
+
const tinyPattern = (raw) => {
|
|
1792
|
+
const p = raw;
|
|
1793
|
+
if (!p || typeof p.start !== "string") return null;
|
|
1794
|
+
if (typeof p.replacement === "string") return { start: p.start, replacement: p.replacement };
|
|
1795
|
+
const formats = (Array.isArray(p.format) ? p.format : [p.format]).filter(
|
|
1796
|
+
(f) => typeof f === "string"
|
|
1797
|
+
);
|
|
1798
|
+
const cmd = typeof p.cmd === "string" ? p.cmd : null;
|
|
1799
|
+
if (!cmd && !formats.length) return null;
|
|
1800
|
+
return {
|
|
1801
|
+
start: p.start,
|
|
1802
|
+
...typeof p.end === "string" && p.end ? { end: p.end } : {},
|
|
1803
|
+
...p.trigger === "enter" ? { trigger: "enter" } : {},
|
|
1804
|
+
value: p.value,
|
|
1805
|
+
command: (_editor, value) => {
|
|
1806
|
+
if (cmd) compat.execCommand(cmd, false, value);
|
|
1807
|
+
else for (const format of formats) compat.formatter.apply(format);
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
if (Array.isArray(config.text_patterns)) {
|
|
1812
|
+
options.textPatterns = config.text_patterns.map(tinyPattern);
|
|
1813
|
+
}
|
|
1814
|
+
const lookup = config.text_patterns_lookup;
|
|
1815
|
+
if (typeof lookup === "function") {
|
|
1816
|
+
options.textPatternsLookup = (context) => {
|
|
1817
|
+
const extra = lookup(context);
|
|
1818
|
+
return Array.isArray(extra) ? extra.map(tinyPattern) : [];
|
|
1819
|
+
};
|
|
1820
|
+
if (!options.textPatterns) options.textPatterns = [];
|
|
1821
|
+
}
|
|
1822
|
+
const onSave = config.save_onsavecallback;
|
|
1823
|
+
const onCancel = config.save_oncancelcallback;
|
|
1824
|
+
const save = {
|
|
1825
|
+
...config.save_enablewhendirty !== void 0 ? { enableWhenDirty: config.save_enablewhendirty !== false } : {},
|
|
1826
|
+
...typeof onSave === "function" ? {
|
|
1827
|
+
onSave: () => {
|
|
1828
|
+
compat.save();
|
|
1829
|
+
return onSave(compat);
|
|
1830
|
+
}
|
|
1831
|
+
} : {},
|
|
1832
|
+
...typeof onCancel === "function" ? { onCancel: () => onCancel(compat) } : {}
|
|
1833
|
+
};
|
|
1834
|
+
const aiRequest = config.ai_request;
|
|
1835
|
+
const ai = typeof aiRequest === "function" ? {
|
|
1836
|
+
...options.pluginOptions?.ai,
|
|
1837
|
+
async *request(request) {
|
|
1838
|
+
const { tinyAiRequest } = await import("./ai-XVSDIIQI.js");
|
|
1839
|
+
yield* tinyAiRequest(
|
|
1840
|
+
aiRequest,
|
|
1841
|
+
(name, event) => compat?.fire(name, event)
|
|
1842
|
+
)(request);
|
|
1843
|
+
}
|
|
1844
|
+
} : null;
|
|
1845
|
+
const pluginOptions = {
|
|
1846
|
+
...options.pluginOptions,
|
|
1847
|
+
...Object.keys(save).length ? { save } : {},
|
|
1848
|
+
...ai ? { ai } : {}
|
|
1849
|
+
};
|
|
1414
1850
|
const core = createEditor({
|
|
1415
1851
|
...options,
|
|
1852
|
+
...Object.keys(pluginOptions).length ? { pluginOptions } : {},
|
|
1416
1853
|
element: host,
|
|
1417
1854
|
content: initial,
|
|
1418
1855
|
setup: (editor) => {
|
|
1419
1856
|
compat = new CompatEditor(editor, target, id, settings);
|
|
1420
1857
|
for (const name of custom) {
|
|
1421
1858
|
try {
|
|
1422
|
-
plugins.get(name)(compat, "");
|
|
1859
|
+
const api2 = plugins.get(name)(compat, "");
|
|
1860
|
+
compat.plugins[name] = api2 && typeof api2 === "object" ? api2 : {};
|
|
1423
1861
|
} catch (error) {
|
|
1424
1862
|
console.error(`[nova] tinymce-compat: plugin "${name}" failed`, error);
|
|
1425
1863
|
}
|
|
@@ -1465,6 +1903,14 @@ function createTinymce() {
|
|
|
1465
1903
|
]) {
|
|
1466
1904
|
core.view.dom.addEventListener(name, (event) => compat.fireNative(name, event));
|
|
1467
1905
|
}
|
|
1906
|
+
core.root.addEventListener("nova-ai-dialogopen", () => compat.fire("AIDialogOpen"));
|
|
1907
|
+
core.root.addEventListener("nova-ai-dialogclose", () => compat.fire("AIDialogClose"));
|
|
1908
|
+
core.root.addEventListener("nova-autocorrect-toggle", (event) => {
|
|
1909
|
+
const { feature, on } = event.detail;
|
|
1910
|
+
compat.fire(
|
|
1911
|
+
(feature === "capitalize" ? "Capitalize" : "Autocorrect") + (on ? "Start" : "End")
|
|
1912
|
+
);
|
|
1913
|
+
});
|
|
1468
1914
|
const form = isTextarea ? target.form : target.closest("form");
|
|
1469
1915
|
form?.addEventListener("submit", () => compat.save());
|
|
1470
1916
|
compat.on("remove", () => {
|
|
@@ -1476,9 +1922,22 @@ function createTinymce() {
|
|
|
1476
1922
|
active ??= compat;
|
|
1477
1923
|
await core.ready;
|
|
1478
1924
|
if (compat.removed) return compat;
|
|
1925
|
+
for (const name of activePlugins(config, (plugin) => core.hasPlugin(plugin)))
|
|
1926
|
+
compat.plugins[name] ??= {};
|
|
1927
|
+
if (compat.plugins.inlinecss) {
|
|
1928
|
+
compat.plugins.inlinecss.getContent = async () => {
|
|
1929
|
+
compat.fire("InlineCSS");
|
|
1930
|
+
const { emailHTML } = await import("@novaprose/core/email");
|
|
1931
|
+
return { html: await emailHTML(core, { document: false }) };
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1479
1934
|
compat.initialized = true;
|
|
1480
1935
|
compat.fire("init");
|
|
1481
1936
|
config.init_instance_callback?.(compat);
|
|
1937
|
+
if (typeof config.view_show === "string" && config.view_show)
|
|
1938
|
+
core.ui.view.show(config.view_show);
|
|
1939
|
+
else if (typeof config.sidebar_show === "string" && config.sidebar_show)
|
|
1940
|
+
void core.ui.sidebar.show(config.sidebar_show);
|
|
1482
1941
|
return compat;
|
|
1483
1942
|
}
|
|
1484
1943
|
const api = {
|
|
@@ -1497,6 +1956,12 @@ function createTinymce() {
|
|
|
1497
1956
|
(resolve) => document.addEventListener("DOMContentLoaded", resolve, { once: true })
|
|
1498
1957
|
);
|
|
1499
1958
|
}
|
|
1959
|
+
if (typeof config.language === "string") {
|
|
1960
|
+
await loadLanguage(config.language.replace("_", "-")).catch((error) => {
|
|
1961
|
+
console.warn("[nova] tinymce-compat: language pack failed to load", error);
|
|
1962
|
+
return false;
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1500
1965
|
const targets = config.target ? [config.target] : config.selector ? [...document.querySelectorAll(config.selector)] : [];
|
|
1501
1966
|
if (!targets.length) warnOnce(`no elements match "${config.selector ?? ""}"`);
|
|
1502
1967
|
const editors = [];
|