@richscripts/richtexteditor 2.4.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 (184) hide show
  1. package/README.md +360 -0
  2. package/admin/index.d.ts +100 -0
  3. package/admin/index.js +94 -0
  4. package/angular/component.ts +284 -0
  5. package/angular/index.d.ts +80 -0
  6. package/angular/index.ts +24 -0
  7. package/headless/index.d.ts +65 -0
  8. package/headless/index.js +272 -0
  9. package/index.d.ts +1412 -0
  10. package/integrations/shared.d.ts +138 -0
  11. package/integrations/shared.js +5182 -0
  12. package/package.json +130 -0
  13. package/react/index.d.ts +104 -0
  14. package/react/index.js +310 -0
  15. package/richtexteditor/CHANGELOG.md +1876 -0
  16. package/richtexteditor/all_plugins.js +31125 -0
  17. package/richtexteditor/all_plugins.min.js +78 -0
  18. package/richtexteditor/lang/rte-lang-af.js +193 -0
  19. package/richtexteditor/lang/rte-lang-ar.js +193 -0
  20. package/richtexteditor/lang/rte-lang-bg.js +193 -0
  21. package/richtexteditor/lang/rte-lang-bn.js +193 -0
  22. package/richtexteditor/lang/rte-lang-bs.js +193 -0
  23. package/richtexteditor/lang/rte-lang-ca.js +193 -0
  24. package/richtexteditor/lang/rte-lang-cs.js +193 -0
  25. package/richtexteditor/lang/rte-lang-cy.js +193 -0
  26. package/richtexteditor/lang/rte-lang-da.js +193 -0
  27. package/richtexteditor/lang/rte-lang-de.js +193 -0
  28. package/richtexteditor/lang/rte-lang-el.js +193 -0
  29. package/richtexteditor/lang/rte-lang-en.js +6 -0
  30. package/richtexteditor/lang/rte-lang-es.js +193 -0
  31. package/richtexteditor/lang/rte-lang-et.js +193 -0
  32. package/richtexteditor/lang/rte-lang-fa.js +193 -0
  33. package/richtexteditor/lang/rte-lang-fi.js +193 -0
  34. package/richtexteditor/lang/rte-lang-fil.js +193 -0
  35. package/richtexteditor/lang/rte-lang-fj.js +193 -0
  36. package/richtexteditor/lang/rte-lang-fr.js +193 -0
  37. package/richtexteditor/lang/rte-lang-ga.js +193 -0
  38. package/richtexteditor/lang/rte-lang-gu.js +193 -0
  39. package/richtexteditor/lang/rte-lang-he.js +193 -0
  40. package/richtexteditor/lang/rte-lang-hi.js +193 -0
  41. package/richtexteditor/lang/rte-lang-hr.js +193 -0
  42. package/richtexteditor/lang/rte-lang-ht.js +193 -0
  43. package/richtexteditor/lang/rte-lang-hu.js +193 -0
  44. package/richtexteditor/lang/rte-lang-id.js +193 -0
  45. package/richtexteditor/lang/rte-lang-is.js +193 -0
  46. package/richtexteditor/lang/rte-lang-it.js +193 -0
  47. package/richtexteditor/lang/rte-lang-ja.js +193 -0
  48. package/richtexteditor/lang/rte-lang-kn.js +193 -0
  49. package/richtexteditor/lang/rte-lang-ko.js +193 -0
  50. package/richtexteditor/lang/rte-lang-lt.js +193 -0
  51. package/richtexteditor/lang/rte-lang-lv.js +193 -0
  52. package/richtexteditor/lang/rte-lang-mg.js +193 -0
  53. package/richtexteditor/lang/rte-lang-mi.js +193 -0
  54. package/richtexteditor/lang/rte-lang-ml.js +193 -0
  55. package/richtexteditor/lang/rte-lang-mr.js +193 -0
  56. package/richtexteditor/lang/rte-lang-ms.js +193 -0
  57. package/richtexteditor/lang/rte-lang-mt.js +193 -0
  58. package/richtexteditor/lang/rte-lang-mww.js +193 -0
  59. package/richtexteditor/lang/rte-lang-nb.js +193 -0
  60. package/richtexteditor/lang/rte-lang-nl.js +193 -0
  61. package/richtexteditor/lang/rte-lang-otq.js +193 -0
  62. package/richtexteditor/lang/rte-lang-pa.js +193 -0
  63. package/richtexteditor/lang/rte-lang-pl.js +193 -0
  64. package/richtexteditor/lang/rte-lang-pt-pt.js +193 -0
  65. package/richtexteditor/lang/rte-lang-pt.js +193 -0
  66. package/richtexteditor/lang/rte-lang-ro.js +193 -0
  67. package/richtexteditor/lang/rte-lang-ru.js +193 -0
  68. package/richtexteditor/lang/rte-lang-sk.js +193 -0
  69. package/richtexteditor/lang/rte-lang-sl.js +193 -0
  70. package/richtexteditor/lang/rte-lang-sm.js +193 -0
  71. package/richtexteditor/lang/rte-lang-sr-Cyrl.js +193 -0
  72. package/richtexteditor/lang/rte-lang-sr-Latn.js +193 -0
  73. package/richtexteditor/lang/rte-lang-sv.js +193 -0
  74. package/richtexteditor/lang/rte-lang-sw.js +193 -0
  75. package/richtexteditor/lang/rte-lang-ta.js +193 -0
  76. package/richtexteditor/lang/rte-lang-te.js +193 -0
  77. package/richtexteditor/lang/rte-lang-th.js +193 -0
  78. package/richtexteditor/lang/rte-lang-tlh-Latn.js +193 -0
  79. package/richtexteditor/lang/rte-lang-tlh-Piqd.js +193 -0
  80. package/richtexteditor/lang/rte-lang-to.js +193 -0
  81. package/richtexteditor/lang/rte-lang-tr.js +193 -0
  82. package/richtexteditor/lang/rte-lang-ty.js +193 -0
  83. package/richtexteditor/lang/rte-lang-uk.js +193 -0
  84. package/richtexteditor/lang/rte-lang-ur.js +193 -0
  85. package/richtexteditor/lang/rte-lang-vi.js +193 -0
  86. package/richtexteditor/lang/rte-lang-yua.js +193 -0
  87. package/richtexteditor/lang/rte-lang-zh-Hans.js +193 -0
  88. package/richtexteditor/lang/rte-lang-zh-Hant.js +193 -0
  89. package/richtexteditor/lang/rte-lang.js +1 -0
  90. package/richtexteditor/plugins/-combine-plugin.txt +2 -0
  91. package/richtexteditor/plugins/-combine-plugins.bat +20 -0
  92. package/richtexteditor/plugins/a11yenhance.js +90 -0
  93. package/richtexteditor/plugins/accessibilitychecker.js +579 -0
  94. package/richtexteditor/plugins/aitoolkit.css +15830 -0
  95. package/richtexteditor/plugins/aitoolkit.js +19171 -0
  96. package/richtexteditor/plugins/all_plugins.js +31125 -0
  97. package/richtexteditor/plugins/all_plugins.min.js +78 -0
  98. package/richtexteditor/plugins/autoembed.js +174 -0
  99. package/richtexteditor/plugins/blocktypes.js +175 -0
  100. package/richtexteditor/plugins/bookmarkcard.js +226 -0
  101. package/richtexteditor/plugins/charlimit.js +195 -0
  102. package/richtexteditor/plugins/comments.js +672 -0
  103. package/richtexteditor/plugins/contentminimap.js +369 -0
  104. package/richtexteditor/plugins/crdt-engine.js +8905 -0
  105. package/richtexteditor/plugins/crdt-engine.min.js +5 -0
  106. package/richtexteditor/plugins/dialoga11y.js +174 -0
  107. package/richtexteditor/plugins/dictation.js +268 -0
  108. package/richtexteditor/plugins/documentimport.js +369 -0
  109. package/richtexteditor/plugins/documentoutline.js +341 -0
  110. package/richtexteditor/plugins/emailtoolkit.js +165 -0
  111. package/richtexteditor/plugins/emojiautocomplete.js +241 -0
  112. package/richtexteditor/plugins/foldheadings.js +181 -0
  113. package/richtexteditor/plugins/ghostcomplete.js +297 -0
  114. package/richtexteditor/plugins/html2pdf.js +158 -0
  115. package/richtexteditor/plugins/imageeditor.js +159 -0
  116. package/richtexteditor/plugins/insertcode.js +319 -0
  117. package/richtexteditor/plugins/insertemoji.js +229 -0
  118. package/richtexteditor/plugins/insertgallery.js +362 -0
  119. package/richtexteditor/plugins/inserttemplate.js +261 -0
  120. package/richtexteditor/plugins/localdraft.js +213 -0
  121. package/richtexteditor/plugins/markdownexport.js +110 -0
  122. package/richtexteditor/plugins/mathdialog.js +153 -0
  123. package/richtexteditor/plugins/mentionplugin.js +534 -0
  124. package/richtexteditor/plugins/mermaiddiagram.js +294 -0
  125. package/richtexteditor/plugins/readabilitystats.js +148 -0
  126. package/richtexteditor/plugins/readaloud.js +243 -0
  127. package/richtexteditor/plugins/restrictedediting.js +208 -0
  128. package/richtexteditor/plugins/revisionhistory.js +670 -0
  129. package/richtexteditor/plugins/samples/insertcode_v1.js +76 -0
  130. package/richtexteditor/plugins/slashcommand.js +705 -0
  131. package/richtexteditor/plugins/smartchips.js +250 -0
  132. package/richtexteditor/plugins/spellcheck.js +181 -0
  133. package/richtexteditor/plugins/todolist.js +137 -0
  134. package/richtexteditor/plugins/trackedchanges.js +658 -0
  135. package/richtexteditor/plugins/tui.image-editor/fabric.min.js +8 -0
  136. package/richtexteditor/plugins/tui.image-editor/note.txt +5 -0
  137. package/richtexteditor/plugins/tui.image-editor/svg/icon-a.svg +235 -0
  138. package/richtexteditor/plugins/tui.image-editor/svg/icon-b.svg +224 -0
  139. package/richtexteditor/plugins/tui.image-editor/svg/icon-c.svg +224 -0
  140. package/richtexteditor/plugins/tui.image-editor/svg/icon-d.svg +224 -0
  141. package/richtexteditor/plugins/tui.image-editor/tui-code-snippet.min.js +7 -0
  142. package/richtexteditor/plugins/tui.image-editor/tui-color-picker.min.css +6 -0
  143. package/richtexteditor/plugins/tui.image-editor/tui-color-picker.min.js +7 -0
  144. package/richtexteditor/plugins/tui.image-editor/tui-image-editor.min.css +7 -0
  145. package/richtexteditor/plugins/tui.image-editor/tui-image-editor.min.js +15 -0
  146. package/richtexteditor/plugins/typewriter.js +203 -0
  147. package/richtexteditor/plugins/wordexport.js +0 -0
  148. package/richtexteditor/plugins/yjscollab.js +693 -0
  149. package/richtexteditor/plugins/zz_richtextbox_dialog_style.js +335 -0
  150. package/richtexteditor/rte-config.js +933 -0
  151. package/richtexteditor/rte.js +943 -0
  152. package/richtexteditor/rte_mobile.css +234 -0
  153. package/richtexteditor/rte_theme_default.css +4819 -0
  154. package/richtexteditor/runtime/colorpicker_more_ns.htm +2613 -0
  155. package/richtexteditor/runtime/help.htm +162 -0
  156. package/richtexteditor/runtime/images/1x1.gif +0 -0
  157. package/richtexteditor/runtime/images/cpie_Color.cur +0 -0
  158. package/richtexteditor/runtime/images/cpie_GradientPositionDark.gif +0 -0
  159. package/richtexteditor/runtime/images/cpie_GradientPositionLight.gif +0 -0
  160. package/richtexteditor/runtime/images/cpie_VerticalPosition.gif +0 -0
  161. package/richtexteditor/runtime/images/cpie_WebSafe.gif +0 -0
  162. package/richtexteditor/runtime/images/cpie_gradients.png +0 -0
  163. package/richtexteditor/runtime/images/cpns_Color.cur +0 -0
  164. package/richtexteditor/runtime/images/cpns_ColorSpace1.png +0 -0
  165. package/richtexteditor/runtime/images/cpns_ColorSpace2.png +0 -0
  166. package/richtexteditor/runtime/images/cpns_GradientPositionDark.gif +0 -0
  167. package/richtexteditor/runtime/images/cpns_GradientPositionLight.gif +0 -0
  168. package/richtexteditor/runtime/images/cpns_Vertical1.png +0 -0
  169. package/richtexteditor/runtime/images/cpns_Vertical2.png +0 -0
  170. package/richtexteditor/runtime/images/cpns_VerticalPosition.gif +0 -0
  171. package/richtexteditor/runtime/images/cpns_WebSafe.gif +0 -0
  172. package/richtexteditor/runtime/images/cpns_gradients.png +0 -0
  173. package/richtexteditor/runtime/images/cpns_hue2.png +0 -0
  174. package/richtexteditor/runtime/images/formbn.gif +0 -0
  175. package/richtexteditor/runtime/images/multiclavier.gif +0 -0
  176. package/richtexteditor/runtime/richtexteditor_content.css +362 -0
  177. package/richtexteditor/runtime/richtexteditor_preview.css +302 -0
  178. package/richtexteditor/runtime/richtexteditor_preview.js +1 -0
  179. package/server/index.d.ts +21 -0
  180. package/server/index.js +23 -0
  181. package/svelte/index.d.ts +19 -0
  182. package/svelte/index.js +59 -0
  183. package/vue/index.d.ts +94 -0
  184. package/vue/index.js +291 -0
@@ -0,0 +1,195 @@
1
+ if (!window.RTE_DefaultConfig) window.RTE_DefaultConfig = {};
2
+
3
+ // 2026-06-09 Character / word limit enforcement. The built-in statistics readout
4
+ // DISPLAYS counts; this ENFORCES a maximum (comment boxes, form fields, social
5
+ // limits) — blocks typing past the cap, truncates over-long pastes, and shows a
6
+ // live "remaining" counter that turns red near/over the limit. Library-free.
7
+ //
8
+ // API:
9
+ // editor.getCharCount() -> number (characters, no markup)
10
+ // editor.getWordCount() -> number
11
+ // editor.getRemainingChars() -> number | null (null when no maxLength set)
12
+ // editor.isOverLimit() -> boolean
13
+ // Events: fires editor "charlimit" with { chars, words, overChars, overWords }.
14
+ // Config:
15
+ // config.maxLength = 0 // max characters (0 / unset = no limit)
16
+ // config.maxWords = 0 // max words (0 / unset = no limit)
17
+ // config.charLimitEnforce = true // block input past the limit
18
+ // config.charLimitShowCounter = true // show the floating counter
19
+ RTE_DefaultConfig.plugin_charlimit = RTE_Plugin_CharLimit;
20
+
21
+ function RTE_Plugin_CharLimit() {
22
+ var obj = this;
23
+ var config, editor, counterEl = null;
24
+
25
+ obj.PluginName = "CharLimit";
26
+
27
+ obj.InitConfig = function (argconfig) { config = argconfig; };
28
+
29
+ obj.InitEditor = function (argeditor) {
30
+ editor = argeditor;
31
+
32
+ editor.getCharCount = function () { return countChars(); };
33
+ editor.getWordCount = function () { return countWords(); };
34
+ editor.getRemainingChars = function () { return maxChars() ? Math.max(0, maxChars() - countChars()) : null; };
35
+ editor.isOverLimit = function () {
36
+ return (maxChars() && countChars() > maxChars()) || (maxWords() && countWords() > maxWords());
37
+ };
38
+
39
+ if (!maxChars() && !maxWords()) return; // dormant unless a limit is configured
40
+
41
+ // The iframe editable may not exist at InitEditor time — bind setup now
42
+ // AND on "created", with an idempotency guard so we never double-bind.
43
+ setup();
44
+ try { editor.attachEvent("created", setup); } catch (e) {}
45
+ try { editor.attachEvent("ready", setup); } catch (e) {}
46
+ try { editor.attachEvent("aftersethtml", function () { setup(); refresh(); }); } catch (e) {}
47
+ // The editor may rebuild the iframe (new document) after init/created; a
48
+ // couple of deferred retries bind the FINAL document once it stabilizes
49
+ // (the idempotency guard makes re-runs cheap no-ops).
50
+ if (typeof setTimeout === "function") { setTimeout(setup, 0); setTimeout(setup, 300); }
51
+ };
52
+
53
+ function setup() {
54
+ // Bind on the iframe DOCUMENT (not the body): the editor recreates the
55
+ // editable body on init / setHTMLCode, which would orphan body-level
56
+ // listeners. The document is stable; capture-phase catches body events.
57
+ var doc = editor.getDocument && editor.getDocument();
58
+ if (!doc || doc.__rteCharLimitBound) { mountCounter(); refresh(); return; }
59
+ doc.__rteCharLimitBound = true;
60
+ if (config.charLimitEnforce !== false) {
61
+ doc.addEventListener("beforeinput", onBeforeInput, true);
62
+ doc.addEventListener("paste", onPaste, true);
63
+ }
64
+ doc.addEventListener("input", function () { refresh(); }, true);
65
+ mountCounter();
66
+ refresh();
67
+ }
68
+
69
+ function maxChars() { var n = parseInt(config.maxLength, 10); return n > 0 ? n : 0; }
70
+ function maxWords() { var n = parseInt(config.maxWords, 10); return n > 0 ? n : 0; }
71
+
72
+ function plainText() {
73
+ try {
74
+ var ed = editor.getEditable();
75
+ return ed ? (ed.innerText || ed.textContent || "") : "";
76
+ } catch (e) { return ""; }
77
+ }
78
+ function countChars() { return plainText().replace(/\r\n/g, "\n").length; }
79
+ function countWords() { var t = plainText().trim(); return t ? t.split(/\s+/).length : 0; }
80
+
81
+ function onBeforeInput(e) {
82
+ var t = e.inputType || "";
83
+ var isInsert = t === "insertText" || t === "insertReplacementText" ||
84
+ t === "insertCompositionText" || t === "insertParagraph" || t === "insertLineBreak";
85
+ if (!isInsert) return; // deletes / formatting always allowed
86
+ var addLen = t === "insertParagraph" || t === "insertLineBreak" ? 1 : ((e.data || "").length || 0);
87
+ // Allow if it shrinks/replaces a selection that frees room — approximate by
88
+ // checking current count; if already at/over the char cap, block inserts.
89
+ if (maxChars()) {
90
+ var cur = countChars();
91
+ if (cur >= maxChars() || cur + addLen > maxChars()) {
92
+ // Permit replacing a selection (net change may be <= 0).
93
+ if (!hasSelection() || cur + addLen > maxChars() + selectionLength()) { e.preventDefault(); flash(); return; }
94
+ }
95
+ }
96
+ if (maxWords() && t !== "insertParagraph" && countWords() >= maxWords() && /\s$/.test(e.data || " ")) {
97
+ // block starting a NEW word past the word cap
98
+ if (countWords() >= maxWords()) { e.preventDefault(); flash(); return; }
99
+ }
100
+ }
101
+
102
+ function onPaste(e) {
103
+ if (!maxChars()) return;
104
+ var remaining = maxChars() - countChars() + selectionLength();
105
+ if (remaining <= 0) { e.preventDefault(); flash(); return; }
106
+ var cd = e.clipboardData || window.clipboardData;
107
+ if (!cd) return;
108
+ var text = "";
109
+ try { text = cd.getData("text/plain") || ""; } catch (er) { return; }
110
+ if (text.length > remaining) {
111
+ // Truncate the paste to what fits.
112
+ e.preventDefault();
113
+ var fit = text.slice(0, remaining);
114
+ try { if (typeof editor.insertHTML === "function") editor.insertHTML(escapeHtml(fit).replace(/\n/g, "<br>")); }
115
+ catch (e2) {}
116
+ flash();
117
+ }
118
+ }
119
+
120
+ function hasSelection() {
121
+ try { var s = editor.getSelection(); return s && s.rangeCount > 0 && !s.isCollapsed; } catch (e) { return false; }
122
+ }
123
+ function selectionLength() {
124
+ try { var s = editor.getSelection(); return s && !s.isCollapsed ? (s.toString() || "").length : 0; } catch (e) { return 0; }
125
+ }
126
+
127
+ function escapeHtml(s) { return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); }
128
+
129
+ function mountCounter() {
130
+ if (config.charLimitShowCounter === false) return;
131
+ if (counterEl && counterEl.parentNode) return;
132
+ var host = findHost();
133
+ if (!host) return;
134
+ injectStyles(host.ownerDocument);
135
+ counterEl = host.ownerDocument.createElement("div");
136
+ counterEl.className = "rte-charlimit-counter";
137
+ counterEl.setAttribute("aria-live", "polite");
138
+ host.appendChild(counterEl);
139
+ }
140
+
141
+ function findHost() {
142
+ try {
143
+ // The iframe lives in the MAIN document inside a positioned wrapper —
144
+ // the right place for an absolutely-positioned overlay counter.
145
+ var ifr = editor.iframe || (editor.getDocument && editor.getDocument().defaultView && editor.getDocument().defaultView.frameElement);
146
+ if (ifr) {
147
+ var w = ifr.parentNode;
148
+ while (w && w.nodeType === 1) {
149
+ var cs = (w.ownerDocument.defaultView || window).getComputedStyle(w);
150
+ if (cs && cs.position !== "static") return w;
151
+ if (w.className && typeof w.className === "string" && /rte[_-](outer|container|wrapper)/i.test(w.className)) {
152
+ try { if (cs && cs.position === "static") w.style.position = "relative"; } catch (e) {}
153
+ return w;
154
+ }
155
+ w = w.parentNode;
156
+ }
157
+ if (ifr.parentNode) { try { ifr.parentNode.style.position = ifr.parentNode.style.position || "relative"; } catch (e) {} return ifr.parentNode; }
158
+ }
159
+ return null;
160
+ } catch (e) { return null; }
161
+ }
162
+
163
+ function injectStyles(doc) {
164
+ if (doc.querySelector("style[data-rte-charlimit]")) return;
165
+ var st = doc.createElement("style");
166
+ st.setAttribute("data-rte-charlimit", "1");
167
+ st.textContent = ".rte-charlimit-counter{position:absolute;right:10px;bottom:6px;z-index:5;font:11px -apple-system,Segoe UI,sans-serif;color:#64748b;background:rgba(255,255,255,.85);padding:1px 7px;border-radius:9px;pointer-events:none}" +
168
+ ".rte-charlimit-counter.is-near{color:#b45309}.rte-charlimit-counter.is-over{color:#dc2626;font-weight:600}";
169
+ (doc.head || doc.documentElement).appendChild(st);
170
+ }
171
+
172
+ function refresh() {
173
+ var chars = countChars(), words = countWords();
174
+ var overChars = maxChars() ? Math.max(0, chars - maxChars()) : 0;
175
+ var overWords = maxWords() ? Math.max(0, words - maxWords()) : 0;
176
+ if (counterEl) {
177
+ var txt = "";
178
+ if (maxChars()) txt = chars + " / " + maxChars();
179
+ else if (maxWords()) txt = words + " / " + maxWords() + " words";
180
+ counterEl.textContent = txt;
181
+ counterEl.classList.remove("is-near", "is-over");
182
+ if ((maxChars() && chars > maxChars()) || (maxWords() && words > maxWords())) counterEl.classList.add("is-over");
183
+ else if ((maxChars() && chars >= maxChars() * 0.9) || (maxWords() && words >= maxWords() * 0.9)) counterEl.classList.add("is-near");
184
+ }
185
+ try { if (typeof editor.fireEvent === "function") editor.fireEvent("charlimit", { chars: chars, words: words, overChars: overChars, overWords: overWords }); } catch (e) {}
186
+ }
187
+
188
+ function flash() {
189
+ if (!counterEl) return;
190
+ counterEl.classList.add("is-over");
191
+ try {
192
+ counterEl.animate([{ transform: "translateX(0)" }, { transform: "translateX(-3px)" }, { transform: "translateX(3px)" }, { transform: "translateX(0)" }], { duration: 160 });
193
+ } catch (e) {}
194
+ }
195
+ }