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