@novaprose/tinymce-compat 0.7.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.
Files changed (240) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +2 -0
  3. package/dist/ai-XVSDIIQI.js +127 -0
  4. package/dist/ai-XVSDIIQI.js.map +1 -0
  5. package/dist/dialog-3UZZZW6Y.js +300 -0
  6. package/dist/dialog-3UZZZW6Y.js.map +1 -0
  7. package/dist/index.cjs +1325 -409
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +92 -45
  10. package/dist/index.d.ts +92 -45
  11. package/dist/index.js +821 -366
  12. package/dist/index.js.map +1 -1
  13. package/dist/novaprose.css +320 -544
  14. package/dist/tinymce-chunks/a11ychecker-fe78c552.js +2 -0
  15. package/dist/tinymce-chunks/a11ychecker-fe78c552.js.map +7 -0
  16. package/dist/tinymce-chunks/accordion-ui-4272c63b.js +2 -0
  17. package/dist/tinymce-chunks/accordion-ui-4272c63b.js.map +7 -0
  18. package/dist/tinymce-chunks/advcode-840793ca.js +2 -0
  19. package/dist/tinymce-chunks/advcode-840793ca.js.map +7 -0
  20. package/dist/tinymce-chunks/advcode-editor-37bc0a02.js +26 -0
  21. package/dist/tinymce-chunks/advcode-editor-37bc0a02.js.map +7 -0
  22. package/dist/tinymce-chunks/advlist-67b98670.js +2 -0
  23. package/dist/tinymce-chunks/{advlist-7a360f16.js.map → advlist-67b98670.js.map} +2 -2
  24. package/dist/tinymce-chunks/advtable-ui-db2e667d.js +2 -0
  25. package/dist/tinymce-chunks/advtable-ui-db2e667d.js.map +7 -0
  26. package/dist/tinymce-chunks/ai-e0658729.js +6 -0
  27. package/dist/tinymce-chunks/ai-e0658729.js.map +7 -0
  28. package/dist/tinymce-chunks/ai2-ddf912a7.js +34 -0
  29. package/dist/tinymce-chunks/ai2-ddf912a7.js.map +7 -0
  30. package/dist/tinymce-chunks/anchor-ui-da0966bb.js +2 -0
  31. package/dist/tinymce-chunks/anchor-ui-da0966bb.js.map +7 -0
  32. package/dist/tinymce-chunks/autocorrect-907e1296.js +3 -0
  33. package/dist/tinymce-chunks/autocorrect-907e1296.js.map +7 -0
  34. package/dist/tinymce-chunks/autolink-897e8650.js +2 -0
  35. package/dist/tinymce-chunks/{autolink-7e2e7be2.js.map → autolink-897e8650.js.map} +2 -2
  36. package/dist/tinymce-chunks/autoresize-f8a4a52a.js +2 -0
  37. package/dist/tinymce-chunks/autoresize-f8a4a52a.js.map +7 -0
  38. package/dist/tinymce-chunks/autosave-60381295.js +2 -0
  39. package/dist/tinymce-chunks/autosave-60381295.js.map +7 -0
  40. package/dist/tinymce-chunks/bash-f3f8783a.js +2 -0
  41. package/dist/tinymce-chunks/bash-f3f8783a.js.map +7 -0
  42. package/dist/tinymce-chunks/c-8e3b278b.js +2 -0
  43. package/dist/tinymce-chunks/c-8e3b278b.js.map +7 -0
  44. package/dist/tinymce-chunks/casechange-8ad6a2c3.js +6 -0
  45. package/dist/tinymce-chunks/casechange-8ad6a2c3.js.map +7 -0
  46. package/dist/tinymce-chunks/charmap-5deb524c.js +2 -0
  47. package/dist/tinymce-chunks/charmap-5deb524c.js.map +7 -0
  48. package/dist/tinymce-chunks/checklist-5a0c95d3.js +2 -0
  49. package/dist/tinymce-chunks/checklist-5a0c95d3.js.map +7 -0
  50. package/dist/tinymce-chunks/codesample-b91dcd91.js +4 -0
  51. package/dist/tinymce-chunks/codesample-b91dcd91.js.map +7 -0
  52. package/dist/tinymce-chunks/comments-panel-152e9cbe.js +2 -0
  53. package/dist/tinymce-chunks/comments-panel-152e9cbe.js.map +7 -0
  54. package/dist/tinymce-chunks/core-f5b3fd3e.js +4 -0
  55. package/dist/tinymce-chunks/core-f5b3fd3e.js.map +7 -0
  56. package/dist/tinymce-chunks/cpp-525b2c81.js +2 -0
  57. package/dist/tinymce-chunks/cpp-525b2c81.js.map +7 -0
  58. package/dist/tinymce-chunks/csharp-b95db858.js +2 -0
  59. package/dist/tinymce-chunks/csharp-b95db858.js.map +7 -0
  60. package/dist/tinymce-chunks/css-bb736f0c.js +2 -0
  61. package/dist/tinymce-chunks/css-bb736f0c.js.map +7 -0
  62. package/dist/tinymce-chunks/de-eb649701.js +2 -0
  63. package/dist/tinymce-chunks/de-eb649701.js.map +7 -0
  64. package/dist/tinymce-chunks/dialog-126a0355.js +2 -0
  65. package/dist/tinymce-chunks/dialog-126a0355.js.map +7 -0
  66. package/dist/tinymce-chunks/diff-02578ed2.js +2 -0
  67. package/dist/tinymce-chunks/diff-02578ed2.js.map +7 -0
  68. package/dist/tinymce-chunks/directionality-185b3810.js +2 -0
  69. package/dist/tinymce-chunks/{directionality-60dba768.js.map → directionality-185b3810.js.map} +2 -2
  70. package/dist/tinymce-chunks/dockerfile-ff44475c.js +2 -0
  71. package/dist/tinymce-chunks/dockerfile-ff44475c.js.map +7 -0
  72. package/dist/tinymce-chunks/draghandle-a1d99987.js +4 -0
  73. package/dist/tinymce-chunks/draghandle-a1d99987.js.map +7 -0
  74. package/dist/tinymce-chunks/editimage-36199bc6.js +2 -0
  75. package/dist/tinymce-chunks/editimage-36199bc6.js.map +7 -0
  76. package/dist/tinymce-chunks/email-1926dd8a.js +62 -0
  77. package/dist/tinymce-chunks/email-1926dd8a.js.map +7 -0
  78. package/dist/tinymce-chunks/email2-e9c49586.js +2 -0
  79. package/dist/tinymce-chunks/email2-e9c49586.js.map +7 -0
  80. package/dist/tinymce-chunks/emoticons-a5ab437d.js +2 -0
  81. package/dist/tinymce-chunks/emoticons-a5ab437d.js.map +7 -0
  82. package/dist/tinymce-chunks/es-b9c95169.js +2 -0
  83. package/dist/tinymce-chunks/es-b9c95169.js.map +7 -0
  84. package/dist/tinymce-chunks/exportpdf-0c6647bc.js +2 -0
  85. package/dist/tinymce-chunks/exportpdf-0c6647bc.js.map +7 -0
  86. package/dist/tinymce-chunks/exportword-8a03f24d.js +2 -0
  87. package/dist/tinymce-chunks/exportword-8a03f24d.js.map +7 -0
  88. package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js +2 -0
  89. package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js.map +7 -0
  90. package/dist/tinymce-chunks/form-dialog-9eb62199.js +2 -0
  91. package/dist/tinymce-chunks/form-dialog-9eb62199.js.map +7 -0
  92. package/dist/tinymce-chunks/formatpainter-cbeeffa7.js +2 -0
  93. package/dist/tinymce-chunks/formatpainter-cbeeffa7.js.map +7 -0
  94. package/dist/tinymce-chunks/fr-724ffe36.js +2 -0
  95. package/dist/tinymce-chunks/fr-724ffe36.js.map +7 -0
  96. package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js +2 -0
  97. package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js.map +7 -0
  98. package/dist/tinymce-chunks/go-14612282.js +2 -0
  99. package/dist/tinymce-chunks/go-14612282.js.map +7 -0
  100. package/dist/tinymce-chunks/graphql-032121b4.js +2 -0
  101. package/dist/tinymce-chunks/graphql-032121b4.js.map +7 -0
  102. package/dist/tinymce-chunks/history-diff-a0db052c.js +2 -0
  103. package/dist/tinymce-chunks/history-diff-a0db052c.js.map +7 -0
  104. package/dist/tinymce-chunks/importcss-28610ab5.js +3 -0
  105. package/dist/tinymce-chunks/importcss-28610ab5.js.map +7 -0
  106. package/dist/tinymce-chunks/importword-ec0b2213.js +2 -0
  107. package/dist/tinymce-chunks/importword-ec0b2213.js.map +7 -0
  108. package/dist/tinymce-chunks/index-330c7726.js +5 -0
  109. package/dist/tinymce-chunks/index-330c7726.js.map +7 -0
  110. package/dist/tinymce-chunks/index2-610900bb.js +2 -0
  111. package/dist/tinymce-chunks/index2-610900bb.js.map +7 -0
  112. package/dist/tinymce-chunks/insertdatetime-a48ee6e0.js +2 -0
  113. package/dist/tinymce-chunks/{insertdatetime-e0dbcf63.js.map → insertdatetime-a48ee6e0.js.map} +2 -2
  114. package/dist/tinymce-chunks/it-f4816bbc.js +2 -0
  115. package/dist/tinymce-chunks/it-f4816bbc.js.map +7 -0
  116. package/dist/tinymce-chunks/java-e051279c.js +2 -0
  117. package/dist/tinymce-chunks/java-e051279c.js.map +7 -0
  118. package/dist/tinymce-chunks/javascript-d7a6fb3d.js +2 -0
  119. package/dist/tinymce-chunks/javascript-d7a6fb3d.js.map +7 -0
  120. package/dist/tinymce-chunks/json-08c0b631.js +2 -0
  121. package/dist/tinymce-chunks/json-08c0b631.js.map +7 -0
  122. package/dist/tinymce-chunks/kotlin-b34d5ff2.js +3 -0
  123. package/dist/tinymce-chunks/kotlin-b34d5ff2.js.map +7 -0
  124. package/dist/tinymce-chunks/linkchecker-820845fd.js +2 -0
  125. package/dist/tinymce-chunks/linkchecker-820845fd.js.map +7 -0
  126. package/dist/tinymce-chunks/lua-9b0ae20a.js +2 -0
  127. package/dist/tinymce-chunks/lua-9b0ae20a.js.map +7 -0
  128. package/dist/tinymce-chunks/markdown-5698ebec.js +34 -0
  129. package/dist/tinymce-chunks/markdown-5698ebec.js.map +7 -0
  130. package/dist/tinymce-chunks/markdown2-943bcf90.js +2 -0
  131. package/dist/tinymce-chunks/markdown2-943bcf90.js.map +7 -0
  132. package/dist/tinymce-chunks/math-ui-1b57f7eb.js +2 -0
  133. package/dist/tinymce-chunks/math-ui-1b57f7eb.js.map +7 -0
  134. package/dist/tinymce-chunks/media-ui-de819f11.js +2 -0
  135. package/dist/tinymce-chunks/media-ui-de819f11.js.map +7 -0
  136. package/dist/tinymce-chunks/mediaembed-ui-7be11324.js +2 -0
  137. package/dist/tinymce-chunks/mediaembed-ui-7be11324.js.map +7 -0
  138. package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js +2 -0
  139. package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js.map +7 -0
  140. package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js +2 -0
  141. package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js.map +7 -0
  142. package/dist/tinymce-chunks/nonbreaking-f15226ad.js +2 -0
  143. package/dist/tinymce-chunks/{nonbreaking-49bdb0d2.js.map → nonbreaking-f15226ad.js.map} +2 -2
  144. package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js +2 -0
  145. package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js.map +7 -0
  146. package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js +2 -0
  147. package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js.map +7 -0
  148. package/dist/tinymce-chunks/pagelayout-ui-01757669.js +2 -0
  149. package/dist/tinymce-chunks/pagelayout-ui-01757669.js.map +7 -0
  150. package/dist/tinymce-chunks/paste-office-d6821891.js +3 -0
  151. package/dist/tinymce-chunks/paste-office-d6821891.js.map +7 -0
  152. package/dist/tinymce-chunks/permanentpen-fc96f445.js +2 -0
  153. package/dist/tinymce-chunks/permanentpen-fc96f445.js.map +7 -0
  154. package/dist/tinymce-chunks/php-6b723470.js +3 -0
  155. package/dist/tinymce-chunks/php-6b723470.js.map +7 -0
  156. package/dist/tinymce-chunks/powershell-e6c3fdb8.js +2 -0
  157. package/dist/tinymce-chunks/powershell-e6c3fdb8.js.map +7 -0
  158. package/dist/tinymce-chunks/print-86762549.js +27 -0
  159. package/dist/tinymce-chunks/print-86762549.js.map +7 -0
  160. package/dist/tinymce-chunks/pt-BR-abebbb34.js +2 -0
  161. package/dist/tinymce-chunks/pt-BR-abebbb34.js.map +7 -0
  162. package/dist/tinymce-chunks/python-a20cacce.js +2 -0
  163. package/dist/tinymce-chunks/python-a20cacce.js.map +7 -0
  164. package/dist/tinymce-chunks/quickbars-35c87c0e.js +2 -0
  165. package/dist/tinymce-chunks/{quickbars-d937e10a.js.map → quickbars-35c87c0e.js.map} +3 -3
  166. package/dist/tinymce-chunks/revisionhistory-741dfb24.js +2 -0
  167. package/dist/tinymce-chunks/revisionhistory-741dfb24.js.map +7 -0
  168. package/dist/tinymce-chunks/ru-f1d19f4f.js +2 -0
  169. package/dist/tinymce-chunks/ru-f1d19f4f.js.map +7 -0
  170. package/dist/tinymce-chunks/ruby-93c325c7.js +2 -0
  171. package/dist/tinymce-chunks/ruby-93c325c7.js.map +7 -0
  172. package/dist/tinymce-chunks/rust-d80fbab5.js +2 -0
  173. package/dist/tinymce-chunks/rust-d80fbab5.js.map +7 -0
  174. package/dist/tinymce-chunks/save-a65e56cd.js +2 -0
  175. package/dist/tinymce-chunks/save-a65e56cd.js.map +7 -0
  176. package/dist/tinymce-chunks/scss-7cffeb15.js +2 -0
  177. package/dist/tinymce-chunks/scss-7cffeb15.js.map +7 -0
  178. package/dist/tinymce-chunks/search-bar-3ea04183.js +3 -0
  179. package/dist/tinymce-chunks/search-bar-3ea04183.js.map +7 -0
  180. package/dist/tinymce-chunks/spellchecker-91509fc1.js +6 -0
  181. package/dist/tinymce-chunks/spellchecker-91509fc1.js.map +7 -0
  182. package/dist/tinymce-chunks/sql-eeac1a81.js +2 -0
  183. package/dist/tinymce-chunks/sql-eeac1a81.js.map +7 -0
  184. package/dist/tinymce-chunks/suggestions-panel-c29362cf.js +2 -0
  185. package/dist/tinymce-chunks/suggestions-panel-c29362cf.js.map +7 -0
  186. package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js +2 -0
  187. package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js.map +7 -0
  188. package/dist/tinymce-chunks/swift-2b081f3e.js +2 -0
  189. package/dist/tinymce-chunks/swift-2b081f3e.js.map +7 -0
  190. package/dist/tinymce-chunks/table-4d43f60d.js +2 -0
  191. package/dist/tinymce-chunks/table-4d43f60d.js.map +7 -0
  192. package/dist/tinymce-chunks/table-dialogs-0445847c.js +2 -0
  193. package/dist/tinymce-chunks/table-dialogs-0445847c.js.map +7 -0
  194. package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js +2 -0
  195. package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js.map +7 -0
  196. package/dist/tinymce-chunks/temml-d637f801.js +97 -0
  197. package/dist/tinymce-chunks/temml-d637f801.js.map +7 -0
  198. package/dist/tinymce-chunks/template-b522c8ed.js +2 -0
  199. package/dist/tinymce-chunks/template-b522c8ed.js.map +7 -0
  200. package/dist/tinymce-chunks/typescript-fa085d66.js +2 -0
  201. package/dist/tinymce-chunks/typescript-fa085d66.js.map +7 -0
  202. package/dist/tinymce-chunks/typography-469ce11a.js +3 -0
  203. package/dist/tinymce-chunks/typography-469ce11a.js.map +7 -0
  204. package/dist/tinymce-chunks/visualblocks-8b7cba25.js +2 -0
  205. package/dist/tinymce-chunks/{visualblocks-58c88e5d.js.map → visualblocks-8b7cba25.js.map} +2 -2
  206. package/dist/tinymce-chunks/visualchars-7cda4c00.js +2 -0
  207. package/dist/tinymce-chunks/visualchars-7cda4c00.js.map +7 -0
  208. package/dist/tinymce-chunks/xml-77617a8f.js +2 -0
  209. package/dist/tinymce-chunks/xml-77617a8f.js.map +7 -0
  210. package/dist/tinymce-chunks/yaml-5bb3ad37.js +2 -0
  211. package/dist/tinymce-chunks/yaml-5bb3ad37.js.map +7 -0
  212. package/dist/tinymce.global.js +34 -27
  213. package/dist/tinymce.global.js.map +4 -4
  214. package/dist/tinymce.licenses.txt +1094 -0
  215. package/package.json +2 -2
  216. package/dist/tinymce-chunks/advlist-7a360f16.js +0 -2
  217. package/dist/tinymce-chunks/autolink-7e2e7be2.js +0 -2
  218. package/dist/tinymce-chunks/autoresize-d6c9537b.js +0 -2
  219. package/dist/tinymce-chunks/autoresize-d6c9537b.js.map +0 -7
  220. package/dist/tinymce-chunks/autosave-4fd46720.js +0 -2
  221. package/dist/tinymce-chunks/autosave-4fd46720.js.map +0 -7
  222. package/dist/tinymce-chunks/charmap-4b14307a.js +0 -2
  223. package/dist/tinymce-chunks/charmap-4b14307a.js.map +0 -7
  224. package/dist/tinymce-chunks/comments-panel-37cba890.js +0 -2
  225. package/dist/tinymce-chunks/comments-panel-37cba890.js.map +0 -7
  226. package/dist/tinymce-chunks/directionality-60dba768.js +0 -2
  227. package/dist/tinymce-chunks/emoticons-7e6da0b6.js +0 -2
  228. package/dist/tinymce-chunks/emoticons-7e6da0b6.js.map +0 -7
  229. package/dist/tinymce-chunks/form-dialog-9cde0ef7.js +0 -2
  230. package/dist/tinymce-chunks/form-dialog-9cde0ef7.js.map +0 -7
  231. package/dist/tinymce-chunks/insertdatetime-e0dbcf63.js +0 -2
  232. package/dist/tinymce-chunks/nonbreaking-49bdb0d2.js +0 -2
  233. package/dist/tinymce-chunks/paste-office-a38659d6.js +0 -3
  234. package/dist/tinymce-chunks/paste-office-a38659d6.js.map +0 -7
  235. package/dist/tinymce-chunks/quickbars-d937e10a.js +0 -2
  236. package/dist/tinymce-chunks/revisionhistory-d6306426.js +0 -2
  237. package/dist/tinymce-chunks/revisionhistory-d6306426.js.map +0 -7
  238. package/dist/tinymce-chunks/table-80284f6f.js +0 -2
  239. package/dist/tinymce-chunks/table-80284f6f.js.map +0 -7
  240. 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 { createEditor, registerHtmlRules } from "@novaprose/core";
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",
@@ -105,9 +108,181 @@ var IGNORED = /* @__PURE__ */ new Set([
105
108
  "quickbars_insert_toolbar",
106
109
  "mentions_fetch",
107
110
  "tinycomments_author",
108
- "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"
109
223
  ]);
110
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
+ }
111
286
  function parseFormats(value) {
112
287
  if (typeof value !== "string") return void 0;
113
288
  return value.split(";").map((item) => item.trim()).filter(Boolean).map((item) => {
@@ -190,6 +365,23 @@ function toStyleFormats(value) {
190
365
  return spec ? [{ title, ...spec }] : [];
191
366
  });
192
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
+ }
193
385
  function mapOptions(config) {
194
386
  const unknown = Object.keys(config).filter((key) => !IGNORED.has(key));
195
387
  const plugins = [];
@@ -200,11 +392,18 @@ function mapOptions(config) {
200
392
  if (isPluginRegistered(target)) plugins.push(target);
201
393
  else missingPlugins.push(name);
202
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
+ }
203
401
  const options = { plugins };
204
402
  if (config.toolbar === false) options.toolbar = false;
205
403
  else if (Array.isArray(config.toolbar)) options.toolbar = config.toolbar.join(" | ");
206
404
  else if (typeof config.toolbar === "string") options.toolbar = config.toolbar;
207
405
  if (config.menubar !== void 0) options.menubar = config.menubar;
406
+ if (config.text_patterns === false) options.textPatterns = false;
208
407
  if (typeof config.statusbar === "boolean") options.statusbar = config.statusbar;
209
408
  if (typeof config.placeholder === "string") options.placeholder = config.placeholder;
210
409
  if (config.readonly === true) options.editable = false;
@@ -244,10 +443,8 @@ function mapOptions(config) {
244
443
  options.blockFormats = blocks.map(({ label, value }) => ({ label, block: value.toLowerCase() })).filter((f) => known.includes(f.block));
245
444
  }
246
445
  if (typeof config.language === "string") options.language = config.language.replace("_", "-");
247
- 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") {
248
447
  options.toolbarMode = config.toolbar_mode;
249
- } else if (config.toolbar_mode === "floating" || config.toolbar_mode === "scrolling") {
250
- options.toolbarMode = "sliding";
251
448
  }
252
449
  if (config.inline === true) options.mode = "inline";
253
450
  if (config.paste_as_text === true) options.pasteAsText = true;
@@ -329,6 +526,232 @@ function mapOptions(config) {
329
526
  }
330
527
  };
331
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;
332
755
  if (Object.keys(pluginOptions).length) options.pluginOptions = pluginOptions;
333
756
  return { options, unknown, missingPlugins };
334
757
  }
@@ -336,307 +759,50 @@ function mapOptions(config) {
336
759
  // src/editor.ts
337
760
  import {
338
761
  getStyle,
339
- HTMLSerializer,
340
762
  icons,
763
+ prettyHTML,
341
764
  setStyle
342
765
  } from "@novaprose/core";
343
-
344
- // src/dialog.ts
345
- var uid = 0;
346
- var nextId = () => `nova-compat-field-${++uid}`;
347
- function el(tag, className, text) {
348
- const node = document.createElement(tag);
349
- if (className) node.className = className;
350
- if (text !== void 0) node.textContent = text;
351
- return node;
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;
352
772
  }
353
- function safeHtml(html) {
354
- const template = document.createElement("template");
355
- template.innerHTML = html;
356
- template.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach((node) => node.remove());
357
- template.content.querySelectorAll("*").forEach((node) => {
358
- for (const attr of [...node.attributes]) {
359
- const value = attr.value.trim().toLowerCase();
360
- if (attr.name.startsWith("on") || /^(javascript|vbscript|data):/.test(value)) {
361
- node.removeAttribute(attr.name);
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 });
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);
612
782
  },
613
- redial: (next) => {
614
- api.close();
615
- Object.assign(api, reopen(next));
616
- }
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);
617
789
  };
618
- if (spec.initialData) api.setData(spec.initialData);
619
- if (currentTab) api.showTab(currentTab);
620
- handle = editor.ui.openDialog({
621
- title: spec.title,
622
- body,
623
- ...submit ? { submitLabel: submit.text } : {},
624
- ...spec.size === "large" ? { size: "large" } : {},
625
- onSubmit: () => {
626
- spec.onSubmit?.(api);
627
- return closedByApi;
790
+ return {
791
+ getData: () => real ? real.getData() : { ...data },
792
+ setData: (next) => {
793
+ if (real) real.setData(next);
794
+ else data = { ...data, ...next };
628
795
  },
629
- onClose: () => {
630
- if (!closedByApi) spec.onCancel?.(api);
631
- spec.onClose?.();
632
- }
633
- });
634
- return api;
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
+ };
635
805
  }
636
-
637
- // src/editor.ts
638
- import { AllSelection, NodeSelection, TextSelection } from "prosemirror-state";
639
- var serializer = new HTMLSerializer();
640
806
  var COMMANDS = {
641
807
  bold: "bold",
642
808
  italic: "italic",
@@ -659,6 +825,69 @@ var COMMANDS = {
659
825
  inserthorizontalrule: "horizontalRule",
660
826
  mceblockquote: "blockquote"
661
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
+ ]);
662
891
  var FORMAT_BLOCKS = {
663
892
  p: "paragraph",
664
893
  h1: "h1",
@@ -790,7 +1019,7 @@ function buttonApi(compat) {
790
1019
  enabled = value;
791
1020
  compat.core.updateUI();
792
1021
  },
793
- // Совместимость со старыми версиями API.
1022
+ // Compatibility with older versions of the API.
794
1023
  isDisabled: () => !enabled,
795
1024
  setDisabled: (value) => {
796
1025
  enabled = !value;
@@ -804,6 +1033,11 @@ var CompatEditor = class {
804
1033
  core;
805
1034
  targetElm;
806
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 = {};
807
1041
  initialized = false;
808
1042
  removed = false;
809
1043
  handlers = /* @__PURE__ */ new Map();
@@ -814,25 +1048,29 @@ var CompatEditor = class {
814
1048
  this.targetElm = target;
815
1049
  this.id = id;
816
1050
  this.settings = settings;
1051
+ setTimeout(() => void loadDialogs().catch(() => {
1052
+ }), 0);
817
1053
  }
818
- // ---------- содержимое ----------
1054
+ // ---------- content ----------
819
1055
  getContent(args = {}) {
820
1056
  const event = { format: args.format ?? "html", content: "" };
821
- 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);
822
1060
  this.fire("GetContent", event);
823
1061
  return event.content;
824
1062
  }
825
1063
  setContent(content, args = {}) {
826
1064
  const event = { content, ...args };
827
1065
  this.fire("BeforeSetContent", event);
828
- this.core.setContent(event.content);
1066
+ this.core.setContent(event.content, { fullPage: args.fullpagehtml !== false });
829
1067
  this.fire("SetContent", event);
830
1068
  return event.content;
831
1069
  }
832
1070
  /**
833
- * Вставить HTML на место выделения. Блоки (<p>, списки, таблицы) — отдельными блоками (абзац
834
- * разрезается), строчное содержимое — в текущую строку. Разбор — схемой редактора: те же проверки
835
- * ссылок и разметки, что при загрузке содержимого.
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.
836
1074
  */
837
1075
  insertContent(content) {
838
1076
  this.core.insertContent(content);
@@ -861,10 +1099,11 @@ var CompatEditor = class {
861
1099
  getWin() {
862
1100
  return this.core.root.ownerDocument.defaultView;
863
1101
  }
864
- // ---------- команды ----------
865
- /** Значение команды: ToggleSidebar — имя открытой боковой панели. */
1102
+ // ---------- commands ----------
1103
+ /** The value of a command: for ToggleSidebar and ToggleView, the name of the open one. */
866
1104
  queryCommandValue(command) {
867
1105
  if (command.toLowerCase() === "togglesidebar") return this.core.ui.sidebar.active ?? "";
1106
+ if (command.toLowerCase() === "toggleview") return this.core.ui.view.active ?? "";
868
1107
  return "";
869
1108
  }
870
1109
  execCommand(command, _ui, value) {
@@ -877,12 +1116,56 @@ var CompatEditor = class {
877
1116
  } else if (name === "mceinsertcontent" || name === "inserthtml") {
878
1117
  this.insertContent(String(value ?? ""));
879
1118
  done = true;
1119
+ } else if (name === "toggleview") {
1120
+ this.core.ui.view.toggle(String(value ?? ""));
1121
+ done = true;
880
1122
  } else if (name === "togglesidebar") {
881
1123
  void this.core.ui.sidebar.toggle(String(value ?? ""));
882
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;
883
1136
  } else if (name === "mcesetcontent") {
884
1137
  this.setContent(String(value ?? ""));
885
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
+ }
886
1169
  } else if (name === "selectall") {
887
1170
  const { state, dispatch } = this.core.view;
888
1171
  dispatch(state.tr.setSelection(new AllSelection(state.doc)));
@@ -899,19 +1182,97 @@ var CompatEditor = class {
899
1182
  if (done) this.fire("ExecCommand", { command, ui: _ui, value });
900
1183
  return done;
901
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
+ }
902
1258
  queryCommandState(command) {
903
- const name = COMMANDS[command.toLowerCase()];
904
- return name ? this.core.isActive(name) : false;
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;
905
1266
  }
906
1267
  queryCommandSupported(command) {
907
1268
  const name = command.toLowerCase();
908
- 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);
909
1270
  }
910
1271
  commands = /* @__PURE__ */ new Map();
911
1272
  addCommand(name, callback) {
912
1273
  this.commands.set(name.toLowerCase(), callback);
913
1274
  }
914
- // ---------- события ----------
1275
+ // ---------- events ----------
915
1276
  on(names, handler, prepend = false) {
916
1277
  for (const name of names.toLowerCase().split(/\s+/).filter(Boolean)) {
917
1278
  const set = this.handlers.get(name) ?? /* @__PURE__ */ new Set();
@@ -949,7 +1310,7 @@ var CompatEditor = class {
949
1310
  }
950
1311
  return payload;
951
1312
  }
952
- /** DOM-событие текста (keydown, click…) — обработчикам передаётся само событие браузера. */
1313
+ /** A DOM event of the text (keydown, click…): handlers get the browser's event itself. */
953
1314
  fireNative(name, event) {
954
1315
  for (const handler of [...this.handlers.get(name) ?? []]) {
955
1316
  try {
@@ -959,18 +1320,18 @@ var CompatEditor = class {
959
1320
  }
960
1321
  }
961
1322
  }
962
- /** Иконка для кнопок по имени (tinymce.IconManager / editor.ui.registry.addIcon). */
1323
+ /** An icon for buttons by name (tinymce.IconManager / editor.ui.registry.addIcon). */
963
1324
  static registerIcon(name, svg) {
964
1325
  customIcons.set(name, svg);
965
1326
  }
966
- /** Новое имя fire в последних версиях API. */
1327
+ /** The newer name of fire in recent versions of the API. */
967
1328
  dispatch(name, event) {
968
1329
  return this.fire(name, event);
969
1330
  }
970
1331
  hasEventListeners(name) {
971
1332
  return (this.handlers.get(name.toLowerCase())?.size ?? 0) > 0;
972
1333
  }
973
- // ---------- состояние ----------
1334
+ // ---------- state ----------
974
1335
  isDirty() {
975
1336
  return this.dirty;
976
1337
  }
@@ -979,7 +1340,7 @@ var CompatEditor = class {
979
1340
  this.dirty = state;
980
1341
  if (changed && state) this.fire("Dirty");
981
1342
  }
982
- /** Записать содержимое в исходный <textarea> (как при отправке формы). */
1343
+ /** Write the content into the original <textarea> (as on form submit). */
983
1344
  save() {
984
1345
  const content = this.getContent();
985
1346
  const event = this.fire("SaveContent", { content });
@@ -1040,44 +1401,35 @@ var CompatEditor = class {
1040
1401
  },
1041
1402
  ignore: (callback) => callback()
1042
1403
  };
1404
+ /** TinyMCE's editor.selection, on top of the core's editor.selection. */
1043
1405
  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
- },
1406
+ getContent: (args = {}) => args.format === "text" ? this.core.selection.getText() : this.core.selection.getHTML(),
1050
1407
  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
- },
1408
+ getNode: () => this.core.selection.getNode() ?? this.core.view.dom,
1056
1409
  getStart: () => this.selection.getNode(),
1057
1410
  getEnd: () => this.selection.getNode(),
1058
- isCollapsed: () => this.core.view.state.selection.empty,
1059
- collapse: (toStart = false) => {
1060
- const { state, dispatch } = this.core.view;
1061
- const pos = toStart ? state.selection.from : state.selection.to;
1062
- dispatch(state.tr.setSelection(TextSelection.near(state.doc.resolve(pos))));
1063
- },
1064
- /** Курсор в узел 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). */
1065
1414
  setCursorLocation: (node, offset = 0) => {
1066
- const { view } = this.core;
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))));
1415
+ if (node) this.core.selection.setCursorLocation(node, offset);
1070
1416
  },
1071
- /** Выделить элемент: content = true — только его содержимое. */
1072
- 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) => {
1073
1423
  const { view } = this.core;
1074
- if (!view.dom.contains(node)) return;
1075
- const from = view.posAtDOM(node, 0);
1076
- const to = view.posAtDOM(node, node.childNodes.length);
1077
- const { doc } = view.state;
1078
- const selection = !content && node instanceof HTMLImageElement ? NodeSelection.create(doc, Math.max(0, from - (doc.resolve(from).nodeAfter ? 0 : 1))) : TextSelection.between(doc.resolve(from), doc.resolve(to));
1079
- view.dispatch(view.state.tr.setSelection(selection));
1080
- }
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()
1081
1433
  };
1082
1434
  notificationManager = {
1083
1435
  open: (args) => this.core.ui.notify({
@@ -1114,9 +1466,9 @@ var CompatEditor = class {
1114
1466
  onClose: () => callback?.(confirmed)
1115
1467
  });
1116
1468
  },
1117
- open: (spec) => openSpecDialog(this.core, spec, (next) => this.windowManager.open(next))
1469
+ open: (spec) => openDialog(this.core, spec, (next) => this.windowManager.open(next))
1118
1470
  };
1119
- /** editor.ui.registry — кнопки и пункты меню в формате TinyMCE поверх реестра NovaProse. */
1471
+ /** editor.ui.registry — buttons and menu items in TinyMCE format on top of the NovaProse registry. */
1120
1472
  ui = {
1121
1473
  registry: {
1122
1474
  addIcon: (name, svg) => {
@@ -1152,8 +1504,8 @@ var CompatEditor = class {
1152
1504
  });
1153
1505
  },
1154
1506
  /**
1155
- * Контекстная панель: predicate(node) получает элемент под курсором, items — кнопки тулбара.
1156
- * position: 'node' (над элементом) или 'selection'/'line' (у выделения).
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).
1157
1509
  */
1158
1510
  addContextToolbar: (name, spec) => {
1159
1511
  this.core.ui.registry.addContextToolbar(name, {
@@ -1167,8 +1519,8 @@ var CompatEditor = class {
1167
1519
  });
1168
1520
  },
1169
1521
  /**
1170
- * Боковая панель: onSetup(api) рисует содержимое в api.element() (один раз), onShow/onHide —
1171
- * при показе. Кнопка-переключатель с именем панели — для toolbar; ToggleSidebar — командой.
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.
1172
1524
  */
1173
1525
  addSidebar: (name, spec) => {
1174
1526
  let element = null;
@@ -1186,6 +1538,21 @@ var CompatEditor = class {
1186
1538
  onHide: () => spec.onHide?.(api)
1187
1539
  });
1188
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
+ },
1189
1556
  addContextForm: () => {
1190
1557
  console.warn("[nova] tinymce-compat: addContextForm is not supported yet");
1191
1558
  },
@@ -1214,9 +1581,9 @@ var CompatEditor = class {
1214
1581
  }
1215
1582
  }
1216
1583
  /**
1217
- * editor.dom — то, что имеет смысл поверх модели документа: поиск и чтение. Менять DOM текста
1218
- * напрямую нельзя (редактор перерисует его из модели) — для правок есть setContent/insertContent/
1219
- * 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.
1220
1587
  */
1221
1588
  dom = {
1222
1589
  select: (selector, scope) => [
@@ -1252,7 +1619,7 @@ var CompatEditor = class {
1252
1619
  textarea.innerHTML = html;
1253
1620
  return textarea.value;
1254
1621
  },
1255
- /** Новый (не вставленный) элемент: атрибуты — через setAttribute, содержимое — текстом. */
1622
+ /** A new (not inserted) element: attributes via setAttribute, the content as text. */
1256
1623
  create: (tag, attrs = {}, text) => {
1257
1624
  const node = document.createElement(tag);
1258
1625
  for (const [name, value] of Object.entries(attrs)) {
@@ -1269,8 +1636,8 @@ var CompatEditor = class {
1269
1636
  remove: () => warnDom("remove")
1270
1637
  };
1271
1638
  /**
1272
- * editor.formatter — встроенные форматы TinyMCE: apply/remove/toggle/match.
1273
- * Свои форматы (register) пока не поддержаны.
1639
+ * editor.formatter — the built-in TinyMCE formats: apply/remove/toggle/match. Your own formats
1640
+ * (register) are not supported yet.
1274
1641
  */
1275
1642
  formatter = {
1276
1643
  apply: (name, vars = {}) => this.applyFormat(name, vars, "apply"),
@@ -1351,7 +1718,7 @@ var CompatEditor = class {
1351
1718
  }
1352
1719
  console.warn(`[nova] tinymce-compat: format "${name}" is not supported yet`);
1353
1720
  }
1354
- /** Убрать редактор и вернуть исходный элемент (как editor.remove()). */
1721
+ /** Remove the editor and restore the original element (like editor.remove()). */
1355
1722
  remove() {
1356
1723
  if (this.removed) return;
1357
1724
  this.fire("remove");
@@ -1411,15 +1778,76 @@ function createTinymce() {
1411
1778
  settings.__wrapper = host;
1412
1779
  }
1413
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
+ };
1414
1840
  const core = createEditor({
1415
1841
  ...options,
1842
+ ...Object.keys(pluginOptions).length ? { pluginOptions } : {},
1416
1843
  element: host,
1417
1844
  content: initial,
1418
1845
  setup: (editor) => {
1419
1846
  compat = new CompatEditor(editor, target, id, settings);
1420
1847
  for (const name of custom) {
1421
1848
  try {
1422
- plugins.get(name)(compat, "");
1849
+ const api2 = plugins.get(name)(compat, "");
1850
+ compat.plugins[name] = api2 && typeof api2 === "object" ? api2 : {};
1423
1851
  } catch (error) {
1424
1852
  console.error(`[nova] tinymce-compat: plugin "${name}" failed`, error);
1425
1853
  }
@@ -1465,6 +1893,14 @@ function createTinymce() {
1465
1893
  ]) {
1466
1894
  core.view.dom.addEventListener(name, (event) => compat.fireNative(name, event));
1467
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
+ });
1468
1904
  const form = isTextarea ? target.form : target.closest("form");
1469
1905
  form?.addEventListener("submit", () => compat.save());
1470
1906
  compat.on("remove", () => {
@@ -1476,9 +1912,22 @@ function createTinymce() {
1476
1912
  active ??= compat;
1477
1913
  await core.ready;
1478
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
+ }
1479
1924
  compat.initialized = true;
1480
1925
  compat.fire("init");
1481
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);
1482
1931
  return compat;
1483
1932
  }
1484
1933
  const api = {
@@ -1497,6 +1946,12 @@ function createTinymce() {
1497
1946
  (resolve) => document.addEventListener("DOMContentLoaded", resolve, { once: true })
1498
1947
  );
1499
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
+ }
1500
1955
  const targets = config.target ? [config.target] : config.selector ? [...document.querySelectorAll(config.selector)] : [];
1501
1956
  if (!targets.length) warnOnce(`no elements match "${config.selector ?? ""}"`);
1502
1957
  const editors = [];