@editora/core 1.0.3 → 1.0.5

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 (131) hide show
  1. package/README.md +34 -0
  2. package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
  3. package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
  4. package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
  5. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
  6. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
  7. package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-B263UI8O.mjs} +624 -473
  8. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +384 -0
  9. package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
  10. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
  11. package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
  12. package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
  13. package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
  14. package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
  15. package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
  16. package/dist/HistoryPlugin.native-TDnVMsEO.mjs +257 -0
  17. package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
  18. package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
  19. package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
  20. package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
  21. package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
  22. package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
  23. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +419 -0
  24. package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
  25. package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
  26. package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
  27. package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
  28. package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
  29. package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
  30. package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
  31. package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
  32. package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
  33. package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
  34. package/dist/core.css +1 -1
  35. package/dist/editora.min.js +31 -29
  36. package/dist/editora.umd.js +31 -29
  37. package/dist/index-CqWQFb3D.js +10 -0
  38. package/dist/index-OwnkG39N.mjs +2227 -0
  39. package/dist/index.cjs.js +14 -18
  40. package/dist/index.esm.js +204 -521
  41. package/dist/plugin-loader.js +26 -26
  42. package/dist/webcomponent-core.js +1286 -295
  43. package/dist/webcomponent-core.min.css +1 -1
  44. package/dist/webcomponent-core.min.js +111 -78
  45. package/dist/webcomponent.cjs.js +1 -1
  46. package/dist/webcomponent.esm.js +1 -1
  47. package/dist/webcomponent.js +1252 -261
  48. package/dist/webcomponent.min.css +1 -1
  49. package/dist/webcomponent.min.js +3552 -2037
  50. package/index.d.ts +355 -0
  51. package/package.json +21 -18
  52. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
  53. package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
  54. package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
  55. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
  56. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
  57. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
  58. package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
  59. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
  60. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
  61. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
  62. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
  63. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
  64. package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
  65. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
  66. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
  67. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
  68. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
  69. package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
  70. package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
  71. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
  72. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
  73. package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
  74. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
  75. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
  76. package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
  77. package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
  78. package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
  79. package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
  80. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
  81. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
  82. package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
  83. package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
  84. package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
  85. package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
  86. package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
  87. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
  88. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
  89. package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
  90. package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
  91. package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
  92. package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
  93. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
  94. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
  95. package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
  96. package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
  97. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
  98. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
  99. package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
  100. package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
  101. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
  102. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
  103. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
  104. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
  105. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
  106. package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
  107. package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
  108. package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
  109. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
  110. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
  111. package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
  112. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
  113. package/dist/documentManager-irzj9n3V.mjs.map +0 -1
  114. package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
  115. package/dist/editora.min.js.map +0 -1
  116. package/dist/editora.umd.js.map +0 -1
  117. package/dist/index-BF5RBhL9.js +0 -4
  118. package/dist/index-BF5RBhL9.js.map +0 -1
  119. package/dist/index-BPsf460l.mjs +0 -1243
  120. package/dist/index-BPsf460l.mjs.map +0 -1
  121. package/dist/index.cjs.js.map +0 -1
  122. package/dist/index.es-CuicffkQ.mjs.map +0 -1
  123. package/dist/index.esm.js.map +0 -1
  124. package/dist/plugin-loader.js.map +0 -1
  125. package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
  126. package/dist/webcomponent-core.js.map +0 -1
  127. package/dist/webcomponent-core.min.js.map +0 -1
  128. package/dist/webcomponent.cjs.js.map +0 -1
  129. package/dist/webcomponent.esm.js.map +0 -1
  130. package/dist/webcomponent.js.map +0 -1
  131. package/dist/webcomponent.min.js.map +0 -1
@@ -0,0 +1,578 @@
1
+ import S from "./purify.es-CKpwg8Tk.mjs";
2
+ let a = null, d = null, s = null, o = null, u = "", g = "", f = "insert";
3
+ const M = [
4
+ {
5
+ id: "formal-letter",
6
+ name: "Formal Letter",
7
+ category: "Letters",
8
+ description: "Professional business letter template",
9
+ html: `<p><strong>{{ Company Name }}</strong></p>
10
+ <p>{{ Today }}</p>
11
+ <p>Dear {{ first_name }} {{ last_name }},</p>
12
+ <p>I hope this letter finds you well. [Your letter content here]</p>
13
+ <p>Thank you for your time and consideration.</p>
14
+ <p>Sincerely,<br>Your Name</p>`
15
+ },
16
+ {
17
+ id: "meeting-notes",
18
+ name: "Meeting Notes",
19
+ category: "Notes",
20
+ description: "Template for meeting notes with attendees and action items",
21
+ html: `<h2>Meeting Notes - {{ today }}</h2>
22
+ <p><strong>Attendees:</strong> [List attendees]</p>
23
+ <p><strong>Agenda:</strong></p>
24
+ <ul>
25
+ <li>[Item 1]</li>
26
+ <li>[Item 2]</li>
27
+ <li>[Item 3]</li>
28
+ </ul>
29
+ <p><strong>Action Items:</strong></p>
30
+ <ul>
31
+ <li>[Owner]: [Task] - [Due Date]</li>
32
+ </ul>
33
+ <p><strong>Next Meeting:</strong> [Date]</p>`
34
+ },
35
+ {
36
+ id: "proposal",
37
+ name: "Project Proposal",
38
+ category: "Business",
39
+ description: "Structured project proposal template",
40
+ html: `<h1>Project Proposal</h1>
41
+ <h2>Executive Summary</h2>
42
+ <p>[Summary of the proposal]</p>
43
+ <h2>Objectives</h2>
44
+ <ul>
45
+ <li>[Objective 1]</li>
46
+ <li>[Objective 2]</li>
47
+ </ul>
48
+ <h2>Scope</h2>
49
+ <p>[Project scope details]</p>
50
+ <h2>Timeline</h2>
51
+ <p>[Project timeline]</p>
52
+ <h2>Budget</h2>
53
+ <p>[Budget details]</p>
54
+ <h2>Contact</h2>
55
+ <p>{{ first_name }} {{ last_name }}<br>{{ email }}<br>{{ phone }}</p>`
56
+ },
57
+ {
58
+ id: "faq",
59
+ name: "FAQ Template",
60
+ category: "Documentation",
61
+ description: "FAQ document structure",
62
+ html: `<h1>Frequently Asked Questions</h1>
63
+ <h2>General Questions</h2>
64
+ <h3>Q: What is this about?</h3>
65
+ <p>A: [Answer here]</p>
66
+ <h3>Q: Who should use this?</h3>
67
+ <p>A: [Answer here]</p>
68
+ <h2>Technical Questions</h2>
69
+ <h3>Q: How do I get started?</h3>
70
+ <p>A: [Answer here]</p>
71
+ <h3>Q: What are the requirements?</h3>
72
+ <p>A: [Answer here]</p>`
73
+ }
74
+ ];
75
+ let b = [...M];
76
+ const w = () => b, O = (t) => b.filter((e) => e.category === t), E = () => {
77
+ const t = new Set(b.map((e) => e.category));
78
+ return Array.from(t);
79
+ }, R = (t) => {
80
+ const e = t.toLowerCase();
81
+ return b.filter(
82
+ (r) => {
83
+ var n, c;
84
+ return r.name.toLowerCase().includes(e) || ((n = r.description) == null ? void 0 : n.toLowerCase().includes(e)) || ((c = r.tags) == null ? void 0 : c.some((m) => m.toLowerCase().includes(e)));
85
+ }
86
+ );
87
+ }, C = (t) => S.sanitize(t, {
88
+ ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
89
+ ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
90
+ }), Q = (t) => b.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (b.push(t), !0), F = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
91
+ function D(t) {
92
+ d = document.createElement("div"), d.className = "rte-dialog-overlay", N(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => p()), a = document.createElement("div"), a.className = "rte-dialog rte-template-dialog", a.addEventListener("click", (r) => r.stopPropagation());
93
+ const e = E();
94
+ e.length > 0 && !u && (u = e[0]), v(), d.appendChild(a), document.body.appendChild(d), z();
95
+ }
96
+ const H = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
97
+ const t = window.getSelection();
98
+ if (!t || t.rangeCount === 0) return null;
99
+ const e = t.anchorNode, r = e instanceof HTMLElement ? e : e == null ? void 0 : e.parentElement;
100
+ return (r == null ? void 0 : r.closest(
101
+ ".rte-content, .editora-content"
102
+ )) || null;
103
+ }, N = (t) => {
104
+ const e = t || L();
105
+ return e ? !!e.closest(H) : !1;
106
+ };
107
+ function v() {
108
+ if (!a) return;
109
+ const t = E(), e = T();
110
+ a.innerHTML = `
111
+ <div class="rte-dialog-header">
112
+ <h2>Insert Template</h2>
113
+ <button class="rte-dialog-close" aria-label="Close">✕</button>
114
+ </div>
115
+
116
+ <div class="rte-dialog-body">
117
+ <!-- Search -->
118
+ <input
119
+ type="text"
120
+ placeholder="Search templates..."
121
+ value="${g}"
122
+ class="rte-input rte-template-search"
123
+ aria-label="Search templates"
124
+ />
125
+
126
+ <!-- Category Tabs -->
127
+ <div class="rte-tabs">
128
+ ${t.map((r) => `
129
+ <button class="rte-tab ${u === r ? "active" : ""}" data-category="${r}">
130
+ ${r}
131
+ </button>
132
+ `).join("")}
133
+ </div>
134
+
135
+ <!-- Template List -->
136
+ <div class="rte-template-list">
137
+ ${e.length > 0 ? e.map((r) => `
138
+ <div
139
+ class="rte-template-item ${(o == null ? void 0 : o.id) === r.id ? "selected" : ""}"
140
+ data-template-id="${r.id}"
141
+ >
142
+ <div class="template-name">${r.name}</div>
143
+ ${r.description ? `<div class="template-description">${r.description}</div>` : ""}
144
+ </div>
145
+ `).join("") : '<div class="rte-empty-state">No templates found</div>'}
146
+ </div>
147
+
148
+ <!-- Preview -->
149
+ ${o ? `
150
+ <div class="rte-template-preview">
151
+ <strong>Preview:</strong>
152
+ <div class="template-preview-content">${o.html}</div>
153
+ </div>
154
+ ` : ""}
155
+
156
+ <!-- Insert Mode Toggle -->
157
+ <div class="rte-insert-mode">
158
+ <label>
159
+ <input type="radio" name="insertMode" value="insert" ${f === "insert" ? "checked" : ""} />
160
+ Insert at cursor
161
+ </label>
162
+ <label>
163
+ <input type="radio" name="insertMode" value="replace" ${f === "replace" ? "checked" : ""} />
164
+ Replace document
165
+ </label>
166
+ </div>
167
+ </div>
168
+
169
+ <div class="rte-dialog-footer">
170
+ <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
171
+ <button class="rte-button-primary rte-insert-btn" ${o ? "" : "disabled"}>
172
+ ${f === "insert" ? "Insert" : "Replace"}
173
+ </button>
174
+ </div>
175
+ `, V();
176
+ }
177
+ function $() {
178
+ if (!a) return;
179
+ a.innerHTML = `
180
+ <div class="rte-dialog-header">
181
+ <h2>Replace Document?</h2>
182
+ </div>
183
+ <div class="rte-dialog-body">
184
+ <p>This will replace your current document content. Continue?</p>
185
+ </div>
186
+ <div class="rte-dialog-footer">
187
+ <button class="rte-button-secondary rte-cancel-warning-btn">Cancel</button>
188
+ <button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
189
+ </div>
190
+ `;
191
+ const t = a.querySelector(".rte-cancel-warning-btn"), e = a.querySelector(".rte-confirm-replace-btn");
192
+ t == null || t.addEventListener("click", () => v()), e == null || e.addEventListener("click", () => j());
193
+ }
194
+ function T() {
195
+ const t = w();
196
+ return g.trim() ? R(g) : u ? t.filter((e) => e.category === u) : t;
197
+ }
198
+ function V() {
199
+ if (!a) return;
200
+ const t = a.querySelector(".rte-dialog-close");
201
+ t == null || t.addEventListener("click", () => p());
202
+ const e = a.querySelector(".rte-cancel-btn");
203
+ e == null || e.addEventListener("click", () => p());
204
+ const r = a.querySelector(".rte-insert-btn");
205
+ r == null || r.addEventListener("click", () => y());
206
+ const n = a.querySelector(".rte-template-search");
207
+ n == null || n.addEventListener("input", (l) => {
208
+ g = l.target.value, k();
209
+ }), n == null || n.addEventListener("keydown", (l) => {
210
+ l.key === "Enter" && o ? y() : l.key === "Escape" && p();
211
+ }), a.querySelectorAll(".rte-tab").forEach((l) => {
212
+ l.addEventListener("click", () => {
213
+ const i = l.getAttribute("data-category");
214
+ i && (u = i, g = "", k());
215
+ });
216
+ }), a.querySelectorAll(".rte-template-item").forEach((l) => {
217
+ l.addEventListener("click", () => {
218
+ const i = l.getAttribute("data-template-id");
219
+ if (i) {
220
+ const h = w().find((x) => x.id === i);
221
+ h && (o = h, v());
222
+ }
223
+ }), l.addEventListener("dblclick", () => {
224
+ const i = l.getAttribute("data-template-id");
225
+ if (i) {
226
+ const h = w().find((x) => x.id === i);
227
+ h && (o = h, y());
228
+ }
229
+ });
230
+ }), a.querySelectorAll('input[name="insertMode"]').forEach((l) => {
231
+ l.addEventListener("change", (i) => {
232
+ f = i.target.value, v();
233
+ });
234
+ });
235
+ }
236
+ function k() {
237
+ const t = T();
238
+ t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, v();
239
+ }
240
+ function y() {
241
+ var t;
242
+ if (o)
243
+ if (f === "replace") {
244
+ let e = null;
245
+ if (s) {
246
+ let r = s.startContainer;
247
+ for (; r && r !== document.body; ) {
248
+ if (r.nodeType === Node.ELEMENT_NODE) {
249
+ const n = r;
250
+ if (n.getAttribute("contenteditable") === "true") {
251
+ e = n;
252
+ break;
253
+ }
254
+ }
255
+ r = r.parentNode;
256
+ }
257
+ }
258
+ if (e || (e = document.querySelector('[contenteditable="true"]')), (t = e == null ? void 0 : e.innerHTML) != null && t.trim()) {
259
+ $();
260
+ return;
261
+ }
262
+ A(o), p();
263
+ } else
264
+ q(o), p();
265
+ }
266
+ function j() {
267
+ o && (A(o), p());
268
+ }
269
+ function q(t) {
270
+ if (s) {
271
+ const m = window.getSelection();
272
+ m && (m.removeAllRanges(), m.addRange(s));
273
+ }
274
+ const e = window.getSelection();
275
+ if (!e || e.rangeCount === 0) return;
276
+ const r = e.getRangeAt(0), n = document.createRange().createContextualFragment(C(t.html));
277
+ r.deleteContents(), r.insertNode(n);
278
+ const c = document.createRange();
279
+ c.setStartAfter(r.endContainer), c.collapse(!0), e.removeAllRanges(), e.addRange(c);
280
+ }
281
+ function A(t) {
282
+ let e = null;
283
+ if (s) {
284
+ let r = s.startContainer;
285
+ for (; r && r !== document.body; ) {
286
+ if (r.nodeType === Node.ELEMENT_NODE) {
287
+ const n = r;
288
+ if (n.getAttribute("contenteditable") === "true") {
289
+ e = n;
290
+ break;
291
+ }
292
+ }
293
+ r = r.parentNode;
294
+ }
295
+ }
296
+ e || (e = document.querySelector('[contenteditable="true"]')), e && (e.innerHTML = C(t.html), e.dispatchEvent(new Event("input", { bubbles: !0 })));
297
+ }
298
+ function p() {
299
+ d && (d.remove(), d = null), a = null, s = null, g = "";
300
+ }
301
+ function I(t) {
302
+ const e = window.getSelection();
303
+ e && e.rangeCount > 0 ? s = e.getRangeAt(0).cloneRange() : s = null;
304
+ const r = T();
305
+ r.length > 0 && !o && (o = r[0]);
306
+ const n = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : L();
307
+ D(n);
308
+ }
309
+ function z() {
310
+ if (typeof document == "undefined") return;
311
+ const t = "template-plugin-dialog-styles";
312
+ if (document.getElementById(t)) return;
313
+ const e = document.createElement("style");
314
+ e.id = t, e.textContent = `
315
+ .rte-dialog-overlay {
316
+ --rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);
317
+ --rte-tmpl-dialog-bg: #fff;
318
+ --rte-tmpl-dialog-text: #101828;
319
+ --rte-tmpl-border: #d6dbe4;
320
+ --rte-tmpl-subtle-bg: #f7f9fc;
321
+ --rte-tmpl-subtle-hover: #eef2f7;
322
+ --rte-tmpl-muted-text: #5f6b7d;
323
+ --rte-tmpl-accent: #1976d2;
324
+ --rte-tmpl-accent-strong: #1565c0;
325
+ --rte-tmpl-ring: rgba(31, 117, 254, 0.18);
326
+ position: fixed;
327
+ top: 0;
328
+ left: 0;
329
+ right: 0;
330
+ bottom: 0;
331
+ background-color: var(--rte-tmpl-overlay-bg);
332
+ backdrop-filter: blur(2px);
333
+ display: flex;
334
+ align-items: center;
335
+ justify-content: center;
336
+ z-index: 10000;
337
+ padding: 16px;
338
+ box-sizing: border-box;
339
+ }
340
+ .rte-dialog-overlay.rte-ui-theme-dark {
341
+ --rte-tmpl-overlay-bg: rgba(2, 8, 20, 0.72);
342
+ --rte-tmpl-dialog-bg: #202938;
343
+ --rte-tmpl-dialog-text: #e8effc;
344
+ --rte-tmpl-border: #49566c;
345
+ --rte-tmpl-subtle-bg: #2a3444;
346
+ --rte-tmpl-subtle-hover: #344256;
347
+ --rte-tmpl-muted-text: #a5b1c5;
348
+ --rte-tmpl-accent: #58a6ff;
349
+ --rte-tmpl-accent-strong: #4598f4;
350
+ --rte-tmpl-ring: rgba(88, 166, 255, 0.22);
351
+ }
352
+ .rte-template-dialog {
353
+ background: var(--rte-tmpl-dialog-bg);
354
+ color: var(--rte-tmpl-dialog-text);
355
+ border: 1px solid var(--rte-tmpl-border);
356
+ border-radius: 12px;
357
+ box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
358
+ width: 600px;
359
+ max-height: 700px;
360
+ display: flex;
361
+ flex-direction: column;
362
+ overflow: hidden;
363
+ }
364
+ .rte-dialog-header {
365
+ display: flex;
366
+ justify-content: space-between;
367
+ align-items: center;
368
+ padding: 16px 20px;
369
+ border-bottom: 1px solid var(--rte-tmpl-border);
370
+ background: linear-gradient(180deg, rgba(127, 154, 195, 0.08) 0%, rgba(127, 154, 195, 0) 100%);
371
+ }
372
+ .rte-dialog-header h2 {
373
+ margin: 0;
374
+ font-size: 18px;
375
+ font-weight: 600;
376
+ color: var(--rte-tmpl-dialog-text);
377
+ }
378
+ .rte-dialog-close {
379
+ background: none;
380
+ border: none;
381
+ font-size: 24px;
382
+ cursor: pointer;
383
+ color: var(--rte-tmpl-muted-text);
384
+ padding: 0;
385
+ width: 32px;
386
+ height: 32px;
387
+ display: flex;
388
+ align-items: center;
389
+ justify-content: center;
390
+ border-radius: 8px;
391
+ transition: background-color 0.16s ease, color 0.16s ease;
392
+ }
393
+ .rte-dialog-close:hover {
394
+ background-color: var(--rte-tmpl-subtle-hover);
395
+ color: var(--rte-tmpl-dialog-text);
396
+ }
397
+ .rte-dialog-body {
398
+ padding: 20px;
399
+ flex: 1;
400
+ overflow-y: auto;
401
+ }
402
+ .rte-input {
403
+ width: 100%;
404
+ padding: 8px 12px;
405
+ border: 1px solid var(--rte-tmpl-border);
406
+ border-radius: 4px;
407
+ font-size: 14px;
408
+ box-sizing: border-box;
409
+ background: var(--rte-tmpl-subtle-bg);
410
+ color: var(--rte-tmpl-dialog-text);
411
+ }
412
+ .rte-input:focus {
413
+ outline: none;
414
+ border-color: var(--rte-tmpl-accent);
415
+ }
416
+ .rte-tabs {
417
+ display: flex;
418
+ gap: 8px;
419
+ margin-top: 12px;
420
+ border-bottom: 1px solid var(--rte-tmpl-border);
421
+ padding-bottom: 8px;
422
+ }
423
+ .rte-tab {
424
+ padding: 6px 12px;
425
+ border: none;
426
+ background: none;
427
+ cursor: pointer;
428
+ font-size: 14px;
429
+ color: var(--rte-tmpl-muted-text);
430
+ border-bottom: 2px solid transparent;
431
+ transition: all 0.2s;
432
+ }
433
+ .rte-tab:hover {
434
+ color: var(--rte-tmpl-dialog-text);
435
+ }
436
+ .rte-tab.active {
437
+ color: var(--rte-tmpl-accent);
438
+ border-bottom-color: var(--rte-tmpl-accent);
439
+ font-weight: 600;
440
+ }
441
+ .rte-template-list {
442
+ border: 1px solid var(--rte-tmpl-border);
443
+ border-radius: 4px;
444
+ max-height: 250px;
445
+ overflow-y: auto;
446
+ margin: 12px 0;
447
+ background: var(--rte-tmpl-subtle-bg);
448
+ }
449
+ .rte-template-item {
450
+ padding: 12px;
451
+ border-bottom: 1px solid var(--rte-tmpl-border);
452
+ cursor: pointer;
453
+ transition: background-color 0.2s;
454
+ background: none;
455
+ }
456
+ .rte-template-item:last-child {
457
+ border-bottom: none;
458
+ }
459
+ .rte-template-item:hover,
460
+ .rte-template-item.selected {
461
+ background-color: var(--rte-tmpl-subtle-hover);
462
+ }
463
+ .template-name {
464
+ font-weight: 600;
465
+ color: var(--rte-tmpl-dialog-text);
466
+ margin-bottom: 4px;
467
+ }
468
+ .template-description {
469
+ font-size: 12px;
470
+ color: var(--rte-tmpl-muted-text);
471
+ }
472
+ .rte-template-preview {
473
+ padding: 12px;
474
+ background-color: var(--rte-tmpl-subtle-bg);
475
+ border: 1px solid var(--rte-tmpl-border);
476
+ border-radius: 4px;
477
+ margin-top: 12px;
478
+ max-height: 200px;
479
+ overflow-y: auto;
480
+ }
481
+ .template-preview-content {
482
+ font-size: 13px;
483
+ line-height: 1.5;
484
+ margin-top: 8px;
485
+ }
486
+ .template-preview-content * {
487
+ margin: 4px 0;
488
+ }
489
+ .rte-insert-mode {
490
+ margin-top: 12px;
491
+ padding: 12px;
492
+ background-color: var(--rte-tmpl-subtle-bg);
493
+ border-radius: 4px;
494
+ display: flex;
495
+ gap: 16px;
496
+ }
497
+ .rte-insert-mode label {
498
+ display: flex;
499
+ align-items: center;
500
+ cursor: pointer;
501
+ font-size: 14px;
502
+ }
503
+ .rte-insert-mode input {
504
+ margin-right: 6px;
505
+ cursor: pointer;
506
+ }
507
+ .rte-empty-state {
508
+ padding: 40px;
509
+ text-align: center;
510
+ color: var(--rte-tmpl-muted-text);
511
+ font-size: 14px;
512
+ }
513
+ .rte-dialog-footer {
514
+ padding: 16px 20px;
515
+ border-top: 1px solid var(--rte-tmpl-border);
516
+ background: var(--rte-tmpl-subtle-bg);
517
+ display: flex;
518
+ justify-content: flex-end;
519
+ gap: 12px;
520
+ }
521
+ .rte-button-primary {
522
+ padding: 8px 16px;
523
+ border: none;
524
+ border-radius: 4px;
525
+ font-size: 14px;
526
+ cursor: pointer;
527
+ background-color: var(--rte-tmpl-accent);
528
+ color: white;
529
+ transition: all 0.2s;
530
+ }
531
+ .rte-button-primary:hover:not([disabled]) {
532
+ background-color: var(--rte-tmpl-accent-strong);
533
+ }
534
+ .rte-button-primary[disabled] {
535
+ opacity: 0.5;
536
+ cursor: not-allowed;
537
+ }
538
+ .rte-button-secondary {
539
+ padding: 8px 16px;
540
+ border: 1px solid var(--rte-tmpl-border);
541
+ border-radius: 4px;
542
+ font-size: 14px;
543
+ cursor: pointer;
544
+ background-color: var(--rte-tmpl-subtle-bg);
545
+ color: var(--rte-tmpl-dialog-text);
546
+ transition: all 0.2s;
547
+ }
548
+ .rte-button-secondary:hover {
549
+ background-color: var(--rte-tmpl-subtle-hover);
550
+ }
551
+ `, document.head.appendChild(e);
552
+ }
553
+ const W = () => ({
554
+ name: "template",
555
+ toolbar: [
556
+ {
557
+ label: "Template",
558
+ command: "insertTemplate",
559
+ icon: '<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'
560
+ }
561
+ ],
562
+ commands: {
563
+ insertTemplate: (t, e) => (I(e), !0)
564
+ },
565
+ keymap: {}
566
+ });
567
+ export {
568
+ M as PREDEFINED_TEMPLATES,
569
+ W as TemplatePlugin,
570
+ Q as addCustomTemplate,
571
+ w as getAllTemplates,
572
+ E as getTemplateCategories,
573
+ O as getTemplatesByCategory,
574
+ C as sanitizeTemplate,
575
+ R as searchTemplates,
576
+ F as validateTemplate
577
+ };
578
+ //# sourceMappingURL=TemplatePlugin.native-4lKEm-WY.mjs.map
@@ -0,0 +1,108 @@
1
+ const a = ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "LI", "BLOCKQUOTE", "PRE", "TD", "TH"];
2
+ function f(n) {
3
+ let t = n;
4
+ if (t.nodeType === Node.ELEMENT_NODE) {
5
+ const e = t;
6
+ if (a.includes(e.tagName))
7
+ return e;
8
+ }
9
+ for (; t; ) {
10
+ if (t.nodeType === Node.ELEMENT_NODE) {
11
+ const e = t;
12
+ if (a.includes(e.tagName))
13
+ return e;
14
+ if (e.hasAttribute("contenteditable"))
15
+ return null;
16
+ }
17
+ t = t.parentNode;
18
+ }
19
+ return null;
20
+ }
21
+ function h(n) {
22
+ const t = [], e = f(n.startContainer), i = f(n.endContainer);
23
+ if (!e && !i) return t;
24
+ if (n.collapsed)
25
+ return e && t.push(e), t;
26
+ if (e === i)
27
+ e && t.push(e);
28
+ else {
29
+ let o = e;
30
+ const s = /* @__PURE__ */ new Set();
31
+ for (e && (t.push(e), s.add(e)); o && o !== i && !s.has(i); ) {
32
+ let r = o.nextElementSibling;
33
+ for (; r; ) {
34
+ if (a.includes(r.tagName)) {
35
+ o = r, s.has(o) || (t.push(o), s.add(o));
36
+ break;
37
+ }
38
+ r = r.nextElementSibling;
39
+ }
40
+ if (!r) break;
41
+ }
42
+ i && !t.includes(i) && t.push(i);
43
+ }
44
+ return t;
45
+ }
46
+ function E(n) {
47
+ const t = n.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? n.commonAncestorContainer : n.commonAncestorContainer.parentElement;
48
+ return t ? t.closest(".rte-content, .editora-content") || t.closest('[contenteditable="true"]') : null;
49
+ }
50
+ function m(n, t) {
51
+ if (!n || t === n.innerHTML) return;
52
+ const e = window.execEditorCommand || window.executeEditorCommand;
53
+ if (typeof e == "function")
54
+ try {
55
+ e("recordDomTransaction", n, t, n.innerHTML);
56
+ } catch (i) {
57
+ }
58
+ }
59
+ const p = (n) => {
60
+ var u;
61
+ if (!n || !["left", "center", "right", "justify"].includes(n)) return !1;
62
+ const e = window.getSelection();
63
+ if (!e || e.rangeCount === 0) return !1;
64
+ const i = e.getRangeAt(0).cloneRange(), o = E(i), s = (o == null ? void 0 : o.innerHTML) || "", r = h(i);
65
+ if (r.length > 0)
66
+ r.forEach((l) => {
67
+ l && (l.style.textAlign = n);
68
+ }), e.removeAllRanges(), e.addRange(i), m(o, s), o && o.dispatchEvent(new Event("input", { bubbles: !0 }));
69
+ else
70
+ try {
71
+ const l = document.createElement("div");
72
+ l.style.textAlign = n;
73
+ const g = i.extractContents();
74
+ l.appendChild(g), i.insertNode(l);
75
+ const d = document.createRange();
76
+ d.selectNodeContents(l), e.removeAllRanges(), e.addRange(d);
77
+ const c = l.closest(".rte-content, .editora-content") || l.closest('[contenteditable="true"]');
78
+ m(c || o, s), (c || o) && ((u = c || o) == null || u.dispatchEvent(new Event("input", { bubbles: !0 })));
79
+ } catch (l) {
80
+ return console.error("Failed to wrap content for alignment:", l), !1;
81
+ }
82
+ return !0;
83
+ }, b = () => ({
84
+ name: "textAlignment",
85
+ toolbar: [
86
+ {
87
+ label: "Text Alignment",
88
+ command: "setTextAlignment",
89
+ type: "inline-menu",
90
+ options: [
91
+ { label: "Left", value: "left" },
92
+ { label: "Center", value: "center" },
93
+ { label: "Right", value: "right" },
94
+ { label: "Justify", value: "justify" }
95
+ ],
96
+ icon: '<svg width="24" height="24" focusable="false"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"></path></svg>'
97
+ }
98
+ ],
99
+ commands: {
100
+ setTextAlignment: p
101
+ },
102
+ keymap: {}
103
+ });
104
+ export {
105
+ b as TextAlignmentPlugin,
106
+ p as setTextAlignmentCommand
107
+ };
108
+ //# sourceMappingURL=TextAlignmentPlugin.native-sM_1s00t.mjs.map