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