@aeriz/wysiwyg 1.0.5 → 2.0.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 (129) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +82 -573
  3. package/angular/README.md +10 -4
  4. package/angular/aeriz-editor.directive.ts +40 -18
  5. package/dist/adapters/jquery.cjs +1 -1
  6. package/dist/adapters/jquery.js +14 -14
  7. package/dist/adapters/shared.cjs +1 -1
  8. package/dist/adapters/shared.js +59 -56
  9. package/dist/adapters/vue.cjs +1 -1
  10. package/dist/adapters/vue.js +64 -56
  11. package/dist/adapters/vue2.cjs +1 -1
  12. package/dist/adapters/vue2.js +24 -17
  13. package/dist/adapters/wc.cjs +1 -1
  14. package/dist/adapters/wc.js +108 -72
  15. package/dist/aeriz-wysiwyg-adapter.js +24 -32
  16. package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
  17. package/dist/aeriz-wysiwyg-highlight.js +964 -0
  18. package/dist/aeriz-wysiwyg-highlight.min.js +5 -0
  19. package/dist/aeriz-wysiwyg-jquery.js +25 -32
  20. package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
  21. package/dist/aeriz-wysiwyg-wc.js +80 -43
  22. package/dist/aeriz-wysiwyg-wc.min.js +1 -1
  23. package/dist/aeriz-wysiwyg.cjs +3525 -1744
  24. package/dist/aeriz-wysiwyg.css +2104 -1904
  25. package/dist/aeriz-wysiwyg.esm.js +3525 -1744
  26. package/dist/aeriz-wysiwyg.esm.min.js +4840 -3581
  27. package/dist/aeriz-wysiwyg.js +3525 -1744
  28. package/dist/aeriz-wysiwyg.min.cjs +51 -46
  29. package/dist/aeriz-wysiwyg.min.css +1 -1
  30. package/dist/aeriz-wysiwyg.min.js +51 -46
  31. package/dist/highlight.cjs +5 -0
  32. package/dist/highlight.js +895 -0
  33. package/dist/server.cjs +24 -19
  34. package/dist/server.js +612 -251
  35. package/dist-types/adapters/shared.d.ts +0 -8
  36. package/dist-types/adapters/shared.d.ts.map +1 -1
  37. package/dist-types/adapters/vue.d.ts +62 -21
  38. package/dist-types/adapters/vue.d.ts.map +1 -1
  39. package/dist-types/adapters/vue2.d.ts +33 -14
  40. package/dist-types/adapters/vue2.d.ts.map +1 -1
  41. package/dist-types/adapters/wc.d.ts +15 -6
  42. package/dist-types/adapters/wc.d.ts.map +1 -1
  43. package/dist-types/cjs/adapters/shared.d.cts +0 -8
  44. package/dist-types/cjs/adapters/vue.d.cts +62 -21
  45. package/dist-types/cjs/adapters/vue2.d.cts +33 -14
  46. package/dist-types/cjs/adapters/wc.d.cts +15 -6
  47. package/dist-types/cjs/core/AerizEditor.d.cts +204 -48
  48. package/dist-types/cjs/core/AerizViewer.d.cts +7 -0
  49. package/dist-types/cjs/core/block-meta.d.cts +40 -0
  50. package/dist-types/cjs/core/block-tracker.d.cts +64 -0
  51. package/dist-types/cjs/core/blocks.d.cts +39 -4
  52. package/dist-types/cjs/core/fonts.d.cts +33 -46
  53. package/dist-types/cjs/core/history.d.cts +28 -10
  54. package/dist-types/cjs/core/html-to-blocks.d.cts +10 -0
  55. package/dist-types/cjs/core/i18n.d.cts +44 -0
  56. package/dist-types/cjs/core/import-html.d.cts +0 -13
  57. package/dist-types/cjs/core/insert-fragment.d.cts +21 -0
  58. package/dist-types/cjs/core/paste-clean.d.cts +36 -0
  59. package/dist-types/cjs/core/sanitize-dom.d.cts +21 -0
  60. package/dist-types/cjs/core/sanitize-html.d.cts +8 -0
  61. package/dist-types/cjs/core/sanitize-policy.d.cts +22 -0
  62. package/dist-types/cjs/core/selection.d.cts +5 -0
  63. package/dist-types/cjs/core/table-grid.d.cts +87 -0
  64. package/dist-types/cjs/core/table-ops.d.cts +2 -22
  65. package/dist-types/cjs/highlight/index.d.cts +5 -0
  66. package/dist-types/cjs/index.d.cts +19 -11
  67. package/dist-types/cjs/server/index.d.cts +4 -5
  68. package/dist-types/cjs/types/index.d.cts +63 -15
  69. package/dist-types/cjs/ui/Toolbar.d.cts +10 -0
  70. package/dist-types/cjs/ui/doc-tools.d.cts +58 -0
  71. package/dist-types/cjs/ui/popovers.d.cts +14 -25
  72. package/dist-types/core/AerizEditor.d.ts +204 -48
  73. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  74. package/dist-types/core/AerizViewer.d.ts +7 -0
  75. package/dist-types/core/AerizViewer.d.ts.map +1 -1
  76. package/dist-types/core/block-meta.d.ts +40 -0
  77. package/dist-types/core/block-meta.d.ts.map +1 -1
  78. package/dist-types/core/block-policy.d.ts.map +1 -1
  79. package/dist-types/core/block-tracker.d.ts +64 -0
  80. package/dist-types/core/block-tracker.d.ts.map +1 -0
  81. package/dist-types/core/blocks.d.ts +39 -4
  82. package/dist-types/core/blocks.d.ts.map +1 -1
  83. package/dist-types/core/fonts.d.ts +33 -46
  84. package/dist-types/core/fonts.d.ts.map +1 -1
  85. package/dist-types/core/history.d.ts +28 -10
  86. package/dist-types/core/history.d.ts.map +1 -1
  87. package/dist-types/core/html-mini.d.ts.map +1 -1
  88. package/dist-types/core/html-to-blocks.d.ts +10 -0
  89. package/dist-types/core/html-to-blocks.d.ts.map +1 -0
  90. package/dist-types/core/i18n.d.ts +44 -0
  91. package/dist-types/core/i18n.d.ts.map +1 -1
  92. package/dist-types/core/import-html.d.ts +0 -13
  93. package/dist-types/core/import-html.d.ts.map +1 -1
  94. package/dist-types/core/import-markdown.d.ts.map +1 -1
  95. package/dist-types/core/insert-fragment.d.ts +21 -0
  96. package/dist-types/core/insert-fragment.d.ts.map +1 -0
  97. package/dist-types/core/markdown-export.d.ts.map +1 -1
  98. package/dist-types/core/paste-clean.d.ts +36 -0
  99. package/dist-types/core/paste-clean.d.ts.map +1 -0
  100. package/dist-types/core/render-string.d.ts.map +1 -1
  101. package/dist-types/core/sanitize-dom.d.ts +21 -0
  102. package/dist-types/core/sanitize-dom.d.ts.map +1 -0
  103. package/dist-types/core/sanitize-html.d.ts +8 -0
  104. package/dist-types/core/sanitize-html.d.ts.map +1 -0
  105. package/dist-types/core/sanitize-policy.d.ts +22 -0
  106. package/dist-types/core/sanitize-policy.d.ts.map +1 -0
  107. package/dist-types/core/selection.d.ts +5 -0
  108. package/dist-types/core/selection.d.ts.map +1 -1
  109. package/dist-types/core/snapshot.d.ts.map +1 -1
  110. package/dist-types/core/table-grid.d.ts +87 -0
  111. package/dist-types/core/table-grid.d.ts.map +1 -0
  112. package/dist-types/core/table-ops.d.ts +2 -22
  113. package/dist-types/core/table-ops.d.ts.map +1 -1
  114. package/dist-types/highlight/index.d.ts +5 -0
  115. package/dist-types/highlight/index.d.ts.map +1 -0
  116. package/dist-types/index.d.ts +19 -11
  117. package/dist-types/index.d.ts.map +1 -1
  118. package/dist-types/server/index.d.ts +4 -5
  119. package/dist-types/server/index.d.ts.map +1 -1
  120. package/dist-types/types/index.d.ts +63 -15
  121. package/dist-types/types/index.d.ts.map +1 -1
  122. package/dist-types/ui/Toolbar.d.ts +10 -0
  123. package/dist-types/ui/Toolbar.d.ts.map +1 -1
  124. package/dist-types/ui/doc-tools.d.ts +58 -0
  125. package/dist-types/ui/doc-tools.d.ts.map +1 -0
  126. package/dist-types/ui/icons.d.ts.map +1 -1
  127. package/dist-types/ui/popovers.d.ts +14 -25
  128. package/dist-types/ui/popovers.d.ts.map +1 -1
  129. package/package.json +70 -5
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
- function Z(e) {
1
+ function J(e) {
2
2
  return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : e < 1024 * 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(1)} MB` : `${(e / 1024 / 1024 / 1024).toFixed(1)} GB`;
3
3
  }
4
- function X(e, t) {
4
+ function Q(e, t) {
5
5
  if (e) {
6
6
  const n = e.lastIndexOf(".");
7
7
  if (n > 0 && n < e.length - 1)
@@ -9,18 +9,18 @@ function X(e, t) {
9
9
  }
10
10
  return t ? (t.split("/").pop() ?? "").toUpperCase() : "";
11
11
  }
12
- function U(e) {
12
+ function H(e) {
13
13
  try {
14
14
  return new URL(e).hostname;
15
15
  } catch {
16
16
  return "";
17
17
  }
18
18
  }
19
- function J(e) {
20
- const t = U(e);
19
+ function ee(e) {
20
+ const t = H(e);
21
21
  return t ? `https://www.google.com/s2/favicons?domain=${encodeURIComponent(t)}&sz=64` : "";
22
22
  }
23
- const Q = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>', ee = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>', te = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", N = "https://www.youtube-nocookie.com/embed/", ne = "파일", re = "data-block-id", ie = /[​-‍]/g, oe = [
23
+ const te = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>', ne = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>', re = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", R = "https://www.youtube-nocookie.com/embed/", ie = "파일", oe = "data-block-id", se = /[​-‍]/g, ae = [
24
24
  "id",
25
25
  "class",
26
26
  "dir",
@@ -47,12 +47,12 @@ const Q = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-wid
47
47
  "small",
48
48
  "span"
49
49
  ]);
50
- function se(e) {
50
+ function le(e) {
51
51
  if (!e) return "div";
52
52
  const t = e.toLowerCase();
53
53
  return ce.has(t) ? t : "div";
54
54
  }
55
- function ae(...e) {
55
+ function ue(...e) {
56
56
  const t = /* @__PURE__ */ new Set();
57
57
  for (const n of e)
58
58
  if (n)
@@ -60,44 +60,70 @@ function ae(...e) {
60
60
  r && t.add(r);
61
61
  return [...t].join(" ");
62
62
  }
63
- const le = "aw-task-list", ue = "data-checked", de = /* @__PURE__ */ new Set([
63
+ const de = "aw-task-list", fe = "data-checked", pe = ["note", "tip", "warning", "danger"], ge = "aw-callout", me = "aw-callout-";
64
+ function U(e) {
65
+ return pe.find((n) => n === e) ?? "note";
66
+ }
67
+ const he = "aw-toggle-summary", $e = "aw-toggle-body", we = /* @__PURE__ */ new Set([
64
68
  "http:",
65
69
  "https:",
66
70
  "mailto:",
67
71
  "tel:",
68
72
  "ftp:",
69
73
  "sms:"
70
- ]), fe = /* @__PURE__ */ new Set([
74
+ ]), be = /* @__PURE__ */ new Set([
71
75
  "http:",
72
76
  "https:",
73
77
  "blob:"
74
- ]), pe = /^data:image\/[a-z0-9.+-]+[,;]/i;
75
- function H(e) {
76
- return e.replace($e, "");
77
- }
78
- const $e = new RegExp("[\\u0000-\\u0020\\u007f]", "g");
78
+ ]), Se = /^data:image\/[a-z0-9.+-]+[,;]/i;
79
79
  function q(e) {
80
+ return e.replace(ke, "");
81
+ }
82
+ const ke = new RegExp("[\\u0000-\\u0020\\u007f]", "g");
83
+ function G(e) {
80
84
  const t = /^([a-z][a-z0-9+.-]*):/i.exec(e);
81
85
  return t && t[1] ? `${t[1].toLowerCase()}:` : null;
82
86
  }
83
- function C(e) {
87
+ function x(e) {
84
88
  if (!e) return "";
85
89
  const t = e.trim();
86
90
  if (!t) return "";
87
- const n = q(H(t));
88
- return n === null || de.has(n) ? t : "";
91
+ const n = G(q(t));
92
+ return n === null || we.has(n) ? t : "";
89
93
  }
90
- function T(e) {
94
+ function y(e) {
91
95
  if (!e) return "";
92
96
  const t = e.trim();
93
97
  if (!t) return "";
94
- const n = H(t), r = q(n);
95
- return r === null ? t : r === "data:" ? pe.test(n) ? t : "" : fe.has(r) ? t : "";
98
+ const n = q(t), r = G(n);
99
+ return r === null ? t : r === "data:" ? Se.test(n) ? t : "" : be.has(r) ? t : "";
96
100
  }
97
101
  function D(e) {
98
102
  return e && /^[A-Za-z0-9_-]{6,20}$/.test(e) ? e : "";
99
103
  }
100
- const W = /* @__PURE__ */ new Set([
104
+ function ye(e) {
105
+ return /^on/i.test(e);
106
+ }
107
+ const Ae = /* @__PURE__ */ new Set([
108
+ "srcdoc",
109
+ "formaction",
110
+ "action",
111
+ "xlink:href",
112
+ "ping"
113
+ ]);
114
+ function Te(e) {
115
+ return Ae.has(e.toLowerCase());
116
+ }
117
+ function _e(e) {
118
+ const t = e.split(",");
119
+ for (const n of t) {
120
+ const r = n.trim().split(/\s+/)[0] ?? "";
121
+ if (r !== "" && !y(r))
122
+ return !1;
123
+ }
124
+ return !0;
125
+ }
126
+ const P = /* @__PURE__ */ new Set([
101
127
  "area",
102
128
  "base",
103
129
  "br",
@@ -112,14 +138,14 @@ const W = /* @__PURE__ */ new Set([
112
138
  "source",
113
139
  "track",
114
140
  "wbr"
115
- ]), me = /* @__PURE__ */ new Set(["script", "style"]), ge = /* @__PURE__ */ new Map([
141
+ ]), ve = /* @__PURE__ */ new Set(["script", "style"]), Ee = /* @__PURE__ */ new Map([
116
142
  ["li", /* @__PURE__ */ new Set(["li"])],
117
143
  ["p", /* @__PURE__ */ new Set(["p", "div", "ul", "ol", "blockquote", "pre", "table", "h1", "h2", "h3", "h4", "h5", "h6"])],
118
144
  ["td", /* @__PURE__ */ new Set(["td", "th", "tr"])],
119
145
  ["th", /* @__PURE__ */ new Set(["td", "th", "tr"])],
120
146
  ["tr", /* @__PURE__ */ new Set(["tr"])],
121
147
  ["option", /* @__PURE__ */ new Set(["option"])]
122
- ]), he = {
148
+ ]), xe = {
123
149
  amp: "&",
124
150
  lt: "<",
125
151
  gt: ">",
@@ -150,122 +176,122 @@ const W = /* @__PURE__ */ new Set([
150
176
  laquo: "«",
151
177
  raquo: "»"
152
178
  };
153
- function y(e) {
179
+ function T(e) {
154
180
  return e.includes("&") ? e.replace(
155
181
  /&(#[Xx][0-9A-Fa-f]+|#\d+|[A-Za-z][A-Za-z0-9]{1,31});/g,
156
182
  (t, n) => {
157
183
  if (n.charCodeAt(0) === 35) {
158
- const i = n[1] === "x" || n[1] === "X", o = i ? n.slice(2) : n.slice(1), c = Number.parseInt(o, i ? 16 : 10);
159
- if (!Number.isFinite(c) || c < 0 || c > 1114111 || c >= 55296 && c <= 57343) return t;
184
+ const i = n[1] === "x" || n[1] === "X", o = i ? n.slice(2) : n.slice(1), s = Number.parseInt(o, i ? 16 : 10);
185
+ if (!Number.isFinite(s) || s < 0 || s > 1114111 || s >= 55296 && s <= 57343) return t;
160
186
  try {
161
- return String.fromCodePoint(c);
187
+ return String.fromCodePoint(s);
162
188
  } catch {
163
189
  return t;
164
190
  }
165
191
  }
166
- return he[n.toLowerCase()] ?? t;
192
+ return xe[n.toLowerCase()] ?? t;
167
193
  }
168
194
  ) : e;
169
195
  }
170
- function g(e) {
196
+ function $(e) {
171
197
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
172
198
  }
173
- function f(e) {
174
- return g(e).replace(/"/g, "&quot;");
199
+ function p(e) {
200
+ return $(e).replace(/"/g, "&quot;");
175
201
  }
176
- function be(e) {
202
+ function Le(e) {
177
203
  const t = {}, n = /([^\s/=>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
178
204
  let r;
179
205
  for (; (r = n.exec(e)) !== null; ) {
180
206
  const i = r[1];
181
207
  if (!i) continue;
182
208
  const o = r[2] ?? r[3] ?? r[4] ?? "";
183
- t[i.toLowerCase()] = y(o);
209
+ t[i.toLowerCase()] = T(o);
184
210
  }
185
211
  return t;
186
212
  }
187
- function S(e) {
213
+ function k(e) {
188
214
  const t = [], n = [], r = () => {
189
- const a = n[n.length - 1];
190
- return a ? a.children : t;
191
- }, i = (a) => {
192
- if (a.length === 0) return;
193
- const s = r(), u = s[s.length - 1];
194
- u && u.type === "text" ? u.value += a : s.push({ type: "text", value: a });
195
- }, o = (a) => {
196
- var s;
215
+ const c = n[n.length - 1];
216
+ return c ? c.children : t;
217
+ }, i = (c) => {
218
+ if (c.length === 0) return;
219
+ const a = r(), u = a[a.length - 1];
220
+ u && u.type === "text" ? u.value += c : a.push({ type: "text", value: c });
221
+ }, o = (c) => {
222
+ var a;
197
223
  for (let u = n.length - 1; u >= 0; u--)
198
- if (((s = n[u]) == null ? void 0 : s.tag) === a) {
224
+ if (((a = n[u]) == null ? void 0 : a.tag) === c) {
199
225
  n.length = u;
200
226
  return;
201
227
  }
202
228
  };
203
- let c = 0;
204
- for (; c < e.length; ) {
205
- const a = e.indexOf("<", c);
206
- if (a < 0) {
207
- i(y(e.slice(c)));
229
+ let s = 0;
230
+ for (; s < e.length; ) {
231
+ const c = e.indexOf("<", s);
232
+ if (c < 0) {
233
+ i(T(e.slice(s)));
208
234
  break;
209
235
  }
210
- if (a > c && i(y(e.slice(c, a))), e.startsWith("<!--", a)) {
211
- const m = e.indexOf("-->", a + 4);
212
- c = m < 0 ? e.length : m + 3;
236
+ if (c > s && i(T(e.slice(s, c))), e.startsWith("<!--", c)) {
237
+ const m = e.indexOf("-->", c + 4);
238
+ s = m < 0 ? e.length : m + 3;
213
239
  continue;
214
240
  }
215
- if (e.startsWith("<!", a) || e.startsWith("<?", a)) {
216
- const m = e.indexOf(">", a + 2);
217
- c = m < 0 ? e.length : m + 1;
241
+ if (e.startsWith("<!", c) || e.startsWith("<?", c)) {
242
+ const m = e.indexOf(">", c + 2);
243
+ s = m < 0 ? e.length : m + 1;
218
244
  continue;
219
245
  }
220
- const s = e.indexOf(">", a + 1);
221
- if (s < 0) {
222
- i(y(e.slice(a)));
246
+ const a = e.indexOf(">", c + 1);
247
+ if (a < 0) {
248
+ i(T(e.slice(c)));
223
249
  break;
224
250
  }
225
- const u = e.slice(a + 1, s);
226
- if (c = s + 1, u.startsWith("/")) {
251
+ const u = e.slice(c + 1, a);
252
+ if (s = a + 1, u.startsWith("/")) {
227
253
  const m = u.slice(1).trim().toLowerCase();
228
254
  m && o(m);
229
255
  continue;
230
256
  }
231
257
  const d = /^([A-Za-z][^\s/>]*)/.exec(u);
232
258
  if (!d || !d[1]) {
233
- i(y(e.slice(a, c)));
259
+ i(T(e.slice(c, s)));
234
260
  continue;
235
261
  }
236
- const l = d[1].toLowerCase(), $ = u.slice(d[1].length), h = /\/\s*$/.test($), p = be(h ? $.replace(/\/\s*$/, "") : $);
237
- if (me.has(l)) {
238
- const m = new RegExp(`</${l}\\s*>`, "i"), Y = e.slice(c), I = m.exec(Y);
239
- c = I ? c + I.index + I[0].length : e.length;
262
+ const l = d[1].toLowerCase(), f = u.slice(d[1].length), w = /\/\s*$/.test(f), g = Le(w ? f.replace(/\/\s*$/, "") : f);
263
+ if (ve.has(l)) {
264
+ const m = new RegExp(`</${l}\\s*>`, "i"), X = e.slice(s), I = m.exec(X);
265
+ s = I ? s + I.index + I[0].length : e.length;
240
266
  continue;
241
267
  }
242
268
  const A = n[n.length - 1];
243
269
  if (A) {
244
- const m = ge.get(A.tag);
270
+ const m = Ee.get(A.tag);
245
271
  m != null && m.has(l) && n.pop();
246
272
  }
247
- const z = { type: "element", tag: l, attrs: p, children: [] };
248
- r().push(z), !h && !W.has(l) && n.push(z);
273
+ const j = { type: "element", tag: l, attrs: g, children: [] };
274
+ r().push(j), !w && !P.has(l) && n.push(j);
249
275
  }
250
276
  return t;
251
277
  }
252
- function M(e) {
278
+ function N(e) {
253
279
  let t = "";
254
280
  for (const n of e) {
255
281
  if (n.type === "text") {
256
- t += g(n.value);
282
+ t += $(n.value);
257
283
  continue;
258
284
  }
259
- const r = Object.entries(n.attrs).map(([i, o]) => o === "" ? ` ${i}` : ` ${i}="${f(o)}"`).join("");
260
- if (W.has(n.tag)) {
285
+ const r = Object.entries(n.attrs).map(([i, o]) => o === "" ? ` ${i}` : ` ${i}="${p(o)}"`).join("");
286
+ if (P.has(n.tag)) {
261
287
  t += `<${n.tag}${r}>`;
262
288
  continue;
263
289
  }
264
- t += `<${n.tag}${r}>${M(n.children)}</${n.tag}>`;
290
+ t += `<${n.tag}${r}>${N(n.children)}</${n.tag}>`;
265
291
  }
266
292
  return t;
267
293
  }
268
- function R(e) {
294
+ function O(e) {
269
295
  let t = "";
270
296
  for (const n of e) {
271
297
  if (n.type === "text") {
@@ -277,15 +303,16 @@ function R(e) {
277
303
  `;
278
304
  continue;
279
305
  }
280
- t += R(n.children);
306
+ t += O(n.children);
281
307
  }
282
308
  return t;
283
309
  }
284
- const ke = /* @__PURE__ */ new Set([
310
+ const Ce = /* @__PURE__ */ new Set([
285
311
  "address",
286
312
  "article",
287
313
  "aside",
288
314
  "blockquote",
315
+ "details",
289
316
  "div",
290
317
  "dd",
291
318
  "dl",
@@ -310,6 +337,7 @@ const ke = /* @__PURE__ */ new Set([
310
337
  "p",
311
338
  "pre",
312
339
  "section",
340
+ "summary",
313
341
  "table",
314
342
  "tbody",
315
343
  "td",
@@ -319,7 +347,7 @@ const ke = /* @__PURE__ */ new Set([
319
347
  "tr",
320
348
  "ul"
321
349
  ]);
322
- function x(e) {
350
+ function L(e) {
323
351
  let t = "";
324
352
  for (const n of e) {
325
353
  if (n.type === "text") {
@@ -331,10 +359,10 @@ function x(e) {
331
359
  `;
332
360
  continue;
333
361
  }
334
- const r = ke.has(n.tag);
362
+ const r = Ce.has(n.tag);
335
363
  r && t !== "" && !t.endsWith(`
336
364
  `) && (t += `
337
- `), t += x(n.children), r && !t.endsWith(`
365
+ `), t += L(n.children), r && !t.endsWith(`
338
366
  `) && (t += `
339
367
  `);
340
368
  }
@@ -345,12 +373,341 @@ function _(e, t) {
345
373
  (n) => n.type === "element" && n.tag === t
346
374
  );
347
375
  }
348
- const Ue = 1;
349
- function we(e) {
376
+ function W(e, t) {
377
+ for (const n of e) {
378
+ if (n.type !== "element") continue;
379
+ if (n.tag === t) return n;
380
+ const r = W(n.children, t);
381
+ if (r) return r;
382
+ }
383
+ return null;
384
+ }
385
+ const Ie = /* @__PURE__ */ new Set([
386
+ "script",
387
+ "style",
388
+ "template",
389
+ "noscript",
390
+ "noembed",
391
+ "noframes",
392
+ "xmp",
393
+ "plaintext",
394
+ "object",
395
+ "embed",
396
+ "applet",
397
+ "frame",
398
+ "frameset",
399
+ "base",
400
+ "link",
401
+ "meta",
402
+ "title",
403
+ "head",
404
+ "form",
405
+ "input",
406
+ "button",
407
+ "textarea",
408
+ "select",
409
+ "option",
410
+ "optgroup",
411
+ "datalist",
412
+ "output",
413
+ "portal",
414
+ "param",
415
+ "math",
416
+ "foreignobject",
417
+ "use",
418
+ "animate",
419
+ "animatemotion",
420
+ "animatetransform",
421
+ "set",
422
+ "image",
423
+ "audio",
424
+ "video",
425
+ "source",
426
+ "track",
427
+ "canvas",
428
+ "dialog",
429
+ "slot"
430
+ ]), Re = /* @__PURE__ */ new Set([
431
+ // 문단 · 구조
432
+ "p",
433
+ "div",
434
+ "span",
435
+ "br",
436
+ "hr",
437
+ "h1",
438
+ "h2",
439
+ "h3",
440
+ "h4",
441
+ "h5",
442
+ "h6",
443
+ "blockquote",
444
+ "pre",
445
+ "code",
446
+ "section",
447
+ "article",
448
+ "aside",
449
+ "header",
450
+ "footer",
451
+ "main",
452
+ "nav",
453
+ "address",
454
+ "figure",
455
+ "figcaption",
456
+ "details",
457
+ "summary",
458
+ "center",
459
+ "fieldset",
460
+ "legend",
461
+ // 목록
462
+ "ul",
463
+ "ol",
464
+ "li",
465
+ "dl",
466
+ "dt",
467
+ "dd",
468
+ // 인라인 서식
469
+ "a",
470
+ "b",
471
+ "strong",
472
+ "i",
473
+ "em",
474
+ "u",
475
+ "s",
476
+ "strike",
477
+ "del",
478
+ "ins",
479
+ "mark",
480
+ "small",
481
+ "big",
482
+ "sub",
483
+ "sup",
484
+ "kbd",
485
+ "samp",
486
+ "var",
487
+ "q",
488
+ "cite",
489
+ "abbr",
490
+ "dfn",
491
+ "time",
492
+ "bdi",
493
+ "bdo",
494
+ "wbr",
495
+ "ruby",
496
+ "rt",
497
+ "rp",
498
+ "font",
499
+ "label",
500
+ // 표
501
+ "table",
502
+ "caption",
503
+ "colgroup",
504
+ "col",
505
+ "thead",
506
+ "tbody",
507
+ "tfoot",
508
+ "tr",
509
+ "td",
510
+ "th",
511
+ // 미디어
512
+ "img",
513
+ "picture",
514
+ "iframe",
515
+ // 아이콘용 SVG (파일 첨부 카드 등)
516
+ "svg",
517
+ "g",
518
+ "path",
519
+ "line",
520
+ "polyline",
521
+ "polygon",
522
+ "circle",
523
+ "ellipse",
524
+ "rect",
525
+ "desc"
526
+ ]);
527
+ function Ne(e) {
528
+ const t = e.toLowerCase();
529
+ return Ie.has(t) ? "drop" : Re.has(t) ? "keep" : "unwrap";
530
+ }
531
+ const Oe = /* @__PURE__ */ new Set([
532
+ "class",
533
+ "style",
534
+ "title",
535
+ "lang",
536
+ "dir",
537
+ "role",
538
+ "contenteditable",
539
+ "spellcheck",
540
+ "translate",
541
+ "hidden"
542
+ ]), Me = {
543
+ a: /* @__PURE__ */ new Set(["href", "target", "rel", "download", "hreflang"]),
544
+ img: /* @__PURE__ */ new Set(["src", "srcset", "sizes", "alt", "width", "height", "loading", "decoding"]),
545
+ iframe: /* @__PURE__ */ new Set(["src", "allow", "allowfullscreen", "frameborder", "referrerpolicy", "loading", "width", "height"]),
546
+ table: /* @__PURE__ */ new Set(["border", "cellpadding", "cellspacing", "width", "summary", "align", "bgcolor"]),
547
+ td: /* @__PURE__ */ new Set(["colspan", "rowspan", "headers", "scope", "width", "height", "align", "valign", "bgcolor", "nowrap"]),
548
+ th: /* @__PURE__ */ new Set(["colspan", "rowspan", "headers", "scope", "abbr", "width", "height", "align", "valign", "bgcolor", "nowrap"]),
549
+ tr: /* @__PURE__ */ new Set(["align", "valign", "bgcolor", "height"]),
550
+ col: /* @__PURE__ */ new Set(["span", "width"]),
551
+ colgroup: /* @__PURE__ */ new Set(["span", "width"]),
552
+ ol: /* @__PURE__ */ new Set(["start", "type", "reversed"]),
553
+ ul: /* @__PURE__ */ new Set(["type"]),
554
+ li: /* @__PURE__ */ new Set(["value", "type"]),
555
+ details: /* @__PURE__ */ new Set(["open"]),
556
+ time: /* @__PURE__ */ new Set(["datetime"]),
557
+ blockquote: /* @__PURE__ */ new Set(["cite"]),
558
+ q: /* @__PURE__ */ new Set(["cite"]),
559
+ del: /* @__PURE__ */ new Set(["cite", "datetime"]),
560
+ ins: /* @__PURE__ */ new Set(["cite", "datetime"]),
561
+ font: /* @__PURE__ */ new Set(["color", "face", "size"]),
562
+ p: /* @__PURE__ */ new Set(["align"]),
563
+ div: /* @__PURE__ */ new Set(["align"]),
564
+ h1: /* @__PURE__ */ new Set(["align"]),
565
+ h2: /* @__PURE__ */ new Set(["align"]),
566
+ h3: /* @__PURE__ */ new Set(["align"]),
567
+ h4: /* @__PURE__ */ new Set(["align"]),
568
+ h5: /* @__PURE__ */ new Set(["align"]),
569
+ h6: /* @__PURE__ */ new Set(["align"]),
570
+ svg: /* @__PURE__ */ new Set(["viewbox", "width", "height", "fill", "stroke", "stroke-width", "stroke-linecap", "stroke-linejoin", "xmlns", "preserveaspectratio", "focusable"])
571
+ }, je = /* @__PURE__ */ new Set([
572
+ "d",
573
+ "points",
574
+ "x",
575
+ "y",
576
+ "x1",
577
+ "x2",
578
+ "y1",
579
+ "y2",
580
+ "cx",
581
+ "cy",
582
+ "r",
583
+ "rx",
584
+ "ry",
585
+ "width",
586
+ "height",
587
+ "fill",
588
+ "stroke",
589
+ "stroke-width",
590
+ "stroke-linecap",
591
+ "stroke-linejoin",
592
+ "stroke-dasharray",
593
+ "opacity",
594
+ "fill-rule",
595
+ "clip-rule",
596
+ "transform"
597
+ ]), Be = /* @__PURE__ */ new Set([
598
+ "g",
599
+ "path",
600
+ "line",
601
+ "polyline",
602
+ "polygon",
603
+ "circle",
604
+ "ellipse",
605
+ "rect"
606
+ ]), ze = /^(?:data|aria)-[a-z0-9_.:-]+$/;
607
+ function K(e, t, n) {
608
+ var r;
609
+ return ye(t) || Te(t) ? null : t === "style" ? qe(n) || null : t === "href" ? x(n) ? n : null : t === "src" ? e === "iframe" ? n.startsWith(R) ? n : null : y(n) ? n : null : t === "srcset" ? _e(n) ? n : null : t === "cite" ? x(n) ? n : null : t === "id" ? He(n) : t === "contenteditable" ? n === "false" ? n : null : Oe.has(t) || ze.test(t) || (r = Me[e]) != null && r.has(t) || Be.has(e) && je.has(t) ? n : null;
610
+ }
611
+ const Fe = /* @__PURE__ */ new Set([
612
+ "window",
613
+ "document",
614
+ "self",
615
+ "top",
616
+ "parent",
617
+ "frames",
618
+ "opener",
619
+ "location",
620
+ "cookie",
621
+ "domain",
622
+ "body",
623
+ "head",
624
+ "forms",
625
+ "images",
626
+ "links",
627
+ "scripts",
628
+ "anchors",
629
+ "embeds",
630
+ "plugins",
631
+ "documentelement",
632
+ "defaultview",
633
+ "name",
634
+ "localstorage",
635
+ "sessionstorage",
636
+ "navigator",
637
+ "history",
638
+ "alert",
639
+ "eval",
640
+ "fetch",
641
+ "xmlhttprequest",
642
+ "implementation",
643
+ "currentscript",
644
+ "activeelement"
645
+ ]);
646
+ function He(e) {
647
+ return /^[A-Za-z][\w:.-]{0,127}$/.test(e) ? Fe.has(e.toLowerCase()) ? null : e : null;
648
+ }
649
+ const B = /expression\s*\(|behavior\s*:|-moz-binding|@import|javascript:|vbscript:/i, Ue = /url\s*\(\s*(['"]?)(.*?)\1\s*\)/gi;
650
+ function qe(e) {
651
+ if (!e) return "";
652
+ const t = e.replace(/\/\*[\s\S]*?\*\//g, "");
653
+ if (!B.test(t.replace(/\\/g, "")) && !/url\s*\(/i.test(t))
654
+ return t.trim();
655
+ const n = [];
656
+ for (const r of t.split(";")) {
657
+ const i = r.trim();
658
+ if (!i || B.test(i.replace(/\\/g, ""))) continue;
659
+ let o = !1;
660
+ i.replace(Ue, (s, c, a) => (y(a) || (o = !0), s)), !o && n.push(i);
661
+ }
662
+ return n.join("; ");
663
+ }
664
+ function Ge(e, t) {
665
+ if (!e || e.toLowerCase() === "_self") return t;
666
+ const n = new Set((t ?? "").split(/\s+/).filter(Boolean));
667
+ return n.add("noopener"), n.add("noreferrer"), [...n].join(" ");
668
+ }
669
+ function De(e) {
670
+ return e ? N(V(k(e))) : "";
671
+ }
672
+ function V(e) {
673
+ const t = [];
674
+ for (const n of e) {
675
+ if (n.type === "text") {
676
+ t.push(n);
677
+ continue;
678
+ }
679
+ const r = Ne(n.tag);
680
+ if (r === "drop" || n.tag === "iframe" && !Pe(n)) continue;
681
+ const i = V(n.children);
682
+ if (r === "unwrap") {
683
+ t.push(...i);
684
+ continue;
685
+ }
686
+ t.push({ type: "element", tag: n.tag, attrs: We(n), children: i });
687
+ }
688
+ return t;
689
+ }
690
+ function Pe(e) {
691
+ return K("iframe", "src", e.attrs.src ?? "") !== null;
692
+ }
693
+ function We(e) {
694
+ const t = {};
695
+ for (const [n, r] of Object.entries(e.attrs)) {
696
+ const i = K(e.tag, n, r);
697
+ i !== null && (t[n] = i);
698
+ }
699
+ if (e.tag === "a") {
700
+ const n = Ge(t.target ?? null, t.rel ?? null);
701
+ n && (t.rel = n);
702
+ }
703
+ return t;
704
+ }
705
+ const pt = 1;
706
+ function Ke(e) {
350
707
  const t = e.version;
351
708
  return typeof t == "number" && Number.isFinite(t) && t > 0 ? t : 1;
352
709
  }
353
- const ye = /* @__PURE__ */ new Set([
710
+ const Ve = /* @__PURE__ */ new Set([
354
711
  "paragraph",
355
712
  "heading",
356
713
  "bulletList",
@@ -358,6 +715,8 @@ const ye = /* @__PURE__ */ new Set([
358
715
  "taskList",
359
716
  "blockquote",
360
717
  "codeBlock",
718
+ "toggle",
719
+ "callout",
361
720
  "image",
362
721
  "table",
363
722
  "hr",
@@ -367,11 +726,11 @@ const ye = /* @__PURE__ */ new Set([
367
726
  "importedHtml",
368
727
  "unknown"
369
728
  ]);
370
- function O(e) {
371
- return e.map((t) => K(t));
729
+ function M(e) {
730
+ return e.map((t) => Ye(t));
372
731
  }
373
- function K(e) {
374
- const t = ye.has(e.kind) ? e.kind : "unknown", n = Math.max(we(e), 1);
732
+ function Ye(e) {
733
+ const t = Ve.has(e.kind) ? e.kind : "unknown", n = Math.max(Ke(e), 1);
375
734
  return {
376
735
  ...e,
377
736
  kind: t,
@@ -379,159 +738,144 @@ function K(e) {
379
738
  html: typeof e.html == "string" ? e.html : ""
380
739
  };
381
740
  }
382
- function He(e, t = {}) {
383
- const n = t.blockIds !== !1, r = O(e).map((o) => P(o, { blockIds: n })).join("");
741
+ function gt(e, t = {}) {
742
+ const n = t.blockIds !== !1, r = M(e).map((o) => Ze(o, { blockIds: n })).join("");
384
743
  return t.wrapper !== "content" ? r : `<div class="aeriz-wysiwyg aeriz-wysiwyg-viewer"${t.theme ? ` data-theme="${t.theme}"` : ""}><div class="aw-content-wrap"><div class="aw-content">${r}</div></div></div>`;
385
744
  }
386
- function qe(e, t = {}) {
387
- return P(K(e), t);
388
- }
389
- function P(e, t = {}) {
390
- const n = t.blockIds === !1 ? "" : ` ${re}="${f(e.id)}"`, r = Ae(e.html), i = (e.style ? ` style="${f(e.style)}"` : "") + Se(e.attributes), o = (c) => {
391
- var s;
392
- const a = ae(c, (s = e.attributes) == null ? void 0 : s.class);
393
- return a ? ` class="${f(a)}"` : "";
745
+ function Ze(e, t = {}) {
746
+ const n = t.blockIds === !1 ? "" : ` ${oe}="${p(e.id)}"`, r = De(e.html), i = (e.style ? ` style="${p(e.style)}"` : "") + Xe(e.attributes), o = (s) => {
747
+ var a;
748
+ const c = ue(s, (a = e.attributes) == null ? void 0 : a.class);
749
+ return c ? ` class="${p(c)}"` : "";
394
750
  };
395
751
  switch (e.kind) {
396
752
  case "paragraph":
397
753
  return `<p${n}${i}>${r || "<br>"}</p>`;
398
754
  case "unknown": {
399
- const c = se(e.attrs.tag);
400
- return `<${c}${n}${i}>${r || "<br>"}</${c}>`;
755
+ const s = le(e.attrs.tag);
756
+ return `<${s}${n}${i}>${r || "<br>"}</${s}>`;
401
757
  }
402
758
  case "heading": {
403
- const c = Ee(e.attrs.level);
404
- return `<h${c}${n}${i}>${r || "<br>"}</h${c}>`;
759
+ const s = Je(e.attrs.level);
760
+ return `<h${s}${n}${i}>${r || "<br>"}</h${s}>`;
405
761
  }
406
762
  case "bulletList":
407
763
  return `<ul${n}${i}>${r || "<li><br></li>"}</ul>`;
408
764
  case "orderedList":
409
765
  return `<ol${n}${i}>${r || "<li><br></li>"}</ol>`;
410
766
  case "taskList":
411
- return `<ul${o(le)}${n}${i}>${r || "<li><br></li>"}</ul>`;
767
+ return `<ul${o(de)}${n}${i}>${r || "<li><br></li>"}</ul>`;
412
768
  case "blockquote":
413
769
  return `<blockquote${n}${i}>${r || "<p><br></p>"}</blockquote>`;
414
770
  case "codeBlock": {
415
771
  if (r) return `<pre${n}${i}>${r}</pre>`;
416
- const c = e.attrs.language, a = c ? ` data-language="${f(c)}"` : "";
417
- return `<pre${n}${i}><code${a}></code></pre>`;
772
+ const s = e.attrs.language, c = s ? ` data-language="${p(s)}"` : "";
773
+ return `<pre${n}${i}><code${c}></code></pre>`;
774
+ }
775
+ case "callout": {
776
+ const s = U(e.attrs.variant), c = `${ge} ${me}${s}`;
777
+ return `<aside${o(c)}${n}${i}>${r || "<p><br></p>"}</aside>`;
418
778
  }
779
+ case "toggle":
780
+ return `<details${e.attrs.open ? " open" : ""}${n}${i}>${r || Qe()}</details>`;
419
781
  case "table":
420
- return `<table${n}${i}>${r || xe(e.attrs.rows, e.attrs.cols)}</table>`;
782
+ return `<table${n}${i}>${r || et(e.attrs.rows, e.attrs.cols)}</table>`;
421
783
  case "hr":
422
784
  return `<hr${n}${i}>`;
423
785
  case "image":
424
- return r ? `<figure${n}${i}>${L(r)}</figure>` : _e(e.attrs, n, i);
786
+ return r ? `<figure${n}${i}>${C(r)}</figure>` : tt(e.attrs, n, i);
425
787
  case "youtube": {
426
788
  if (!r)
427
- return Le(e.attrs, n, i, o);
428
- const c = D(e.attrs.videoId), a = c ? ` data-youtube-id="${f(c)}"` : "";
429
- return `<div${o("aw-youtube-embed")}${a}${n}${i}>${L(r)}</div>`;
789
+ return nt(e.attrs, n, i, o);
790
+ const s = D(e.attrs.videoId), c = s ? ` data-youtube-id="${p(s)}"` : "";
791
+ return `<div${o("aw-youtube-embed")}${c}${n}${i}>${C(r)}</div>`;
430
792
  }
431
793
  case "linkCard":
432
- return Ce(e.attrs, n, i, r, o);
794
+ return rt(e.attrs, n, i, r, o);
433
795
  case "file":
434
- return Ie(e.attrs, n, i, r, o);
796
+ return it(e.attrs, n, i, r, o);
435
797
  case "importedHtml": {
436
- const c = e.attrs.importedStyle, a = e.style ? i : c ? ` style="${f(c)}"` : "";
437
- return `<div data-imported-html="true"${o(e.attrs.importedClass)}${a}${n}>${r}</div>`;
798
+ const s = e.attrs.importedStyle, c = e.style ? i : s ? ` style="${p(s)}"` : "";
799
+ return `<div data-imported-html="true"${o(e.attrs.importedClass)}${c}${n}>${r}</div>`;
438
800
  }
439
801
  default:
440
802
  return "";
441
803
  }
442
804
  }
443
- function Se(e) {
805
+ function Xe(e) {
444
806
  if (!e) return "";
445
807
  let t = "";
446
- for (const n of oe) {
808
+ for (const n of ae) {
447
809
  if (n === "class") continue;
448
810
  const r = e[n];
449
- r === void 0 || r === "" || (t += ` ${n}="${f(r)}"`);
811
+ r === void 0 || r === "" || (t += ` ${n}="${p(r)}"`);
450
812
  }
451
813
  return t;
452
814
  }
453
- const B = /\s(href|src)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;
454
- function Ae(e) {
455
- return !e || !Te(e) && !ve.test(e) ? e : M(S(e).map(G));
456
- }
457
- const ve = /<iframe[\s>]/i;
458
- function Te(e) {
459
- B.lastIndex = 0;
460
- let t;
461
- for (; (t = B.exec(e)) !== null; ) {
462
- const n = (t[1] ?? "").toLowerCase(), r = y(t[2] ?? t[3] ?? t[4] ?? "");
463
- if (!(n === "href" ? C(r) : T(r))) return !0;
464
- }
465
- return !1;
466
- }
467
- function G(e) {
468
- if (e.type !== "element") return e;
469
- const t = e.tag === "iframe", n = {};
470
- for (const [r, i] of Object.entries(e.attrs))
471
- r === "href" && !C(i) || r === "src" && !(t ? i.startsWith(N) : T(i)) || (n[r] = i);
472
- return { ...e, attrs: n, children: e.children.map(G) };
473
- }
474
- const j = /aw-block-align-controls|aw-resize-handle/;
475
- function L(e) {
476
- if (!j.test(e)) return e;
477
- const t = S(e).filter(
478
- (n) => !(n.type === "element" && j.test(n.attrs.class ?? ""))
815
+ const z = /aw-block-align-controls|aw-resize-handle/;
816
+ function C(e) {
817
+ if (!z.test(e)) return e;
818
+ const t = k(e).filter(
819
+ (n) => !(n.type === "element" && z.test(n.attrs.class ?? ""))
479
820
  );
480
- return M(t);
821
+ return N(t);
481
822
  }
482
- function Ee(e) {
823
+ function Je(e) {
483
824
  return e === void 0 || e < 1 ? 1 : e > 6 ? 6 : e;
484
825
  }
485
- function xe(e, t) {
826
+ function Qe() {
827
+ return `<summary class="${he}"><br></summary><div class="${$e}"><p><br></p></div>`;
828
+ }
829
+ function et(e, t) {
486
830
  const n = Math.max(1, Number.isFinite(e) ? e : 1), r = Math.max(1, Number.isFinite(t) ? t : 1);
487
831
  return `<tbody>${`<tr>${"<td><br></td>".repeat(r)}</tr>`.repeat(n)}</tbody>`;
488
832
  }
489
- function _e(e, t, n) {
490
- const r = n || (e.wrapperStyle ? ` style="${f(e.wrapperStyle)}"` : ""), i = T(e.src), o = i ? ` src="${f(i)}"` : "", c = ` alt="${f(e.alt ?? "")}"`, a = e.caption ? `<figcaption>${g(e.caption)}</figcaption>` : "";
491
- return `<figure${t}${r}><img${o}${c}>${a}</figure>`;
492
- }
493
- function Le(e, t, n, r) {
494
- const i = D(e.videoId), o = n || (e.wrapperStyle ? ` style="${f(e.wrapperStyle)}"` : ""), c = i ? ` data-youtube-id="${f(i)}"` : "", a = i ? ` src="${f(`${N}${i}`)}"` : "";
495
- return `<div${r("aw-youtube-embed")}${c}${t}${o}><iframe${a} allow="${f(te)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`;
496
- }
497
- function Ce(e, t, n, r, i) {
498
- const o = C(e.href) || "#", c = e.text && e.text.length > 0 ? e.text : U(o) || o, a = e.description ?? "", s = T(e.image), u = e.favicon ? T(e.favicon) : J(o), l = `<a${i(s ? "aw-link-card aw-link-card-with-image" : "aw-link-card")} href="${f(o)}" target="_blank" rel="noopener"${t}${n}>`;
499
- if (r) return `${l}${L(r)}</a>`;
500
- let $ = l;
501
- return s && ($ += `<img class="aw-link-card-image" src="${f(s)}" alt="" loading="lazy">`), $ += '<span class="aw-link-card-body">', $ += `<span class="aw-link-card-title">${g(c)}</span>`, a && ($ += `<span class="aw-link-card-desc">${g(a)}</span>`), $ += '<span class="aw-link-card-url">', u && ($ += `<img class="aw-link-card-favicon" src="${f(u)}" alt="" loading="lazy">`), $ += `<span class="aw-link-card-url-text">${g(o)}</span>`, $ += "</span></span></a>", $;
502
- }
503
- function Ie(e, t, n, r, i) {
504
- const o = C(e.fileSrc), c = o ? ` href="${f(o)}"` : "", a = e.fileName ? ` data-file-name="${f(e.fileName)}"` : "", s = e.fileSize !== void 0 ? ` data-file-size="${f(String(e.fileSize))}"` : "", u = e.fileType ? ` data-file-type="${f(e.fileType)}"` : "", d = ` download="${f(e.fileName ?? "")}"`, l = [], $ = X(e.fileName, e.fileType);
505
- $ && l.push($), e.fileSize !== void 0 && l.push(Z(e.fileSize));
506
- const h = `<a${i("aw-file-attachment")} target="_blank" rel="noopener"${c}${d}${a}${s}${u}${t}${n}>`;
507
- if (r) return `${h}${L(r)}</a>`;
508
- let p = h;
509
- return p += `<span class="aw-file-icon" aria-hidden="true">${Q}</span>`, p += '<span class="aw-file-meta">', p += `<span class="aw-file-name">${g(e.fileName ?? ne)}</span>`, l.length > 0 && (p += `<span class="aw-file-info">${g(l.join(" · "))}</span>`), p += "</span>", p += `<span class="aw-file-action" aria-hidden="true">${ee}</span>`, p += "</a>", p;
510
- }
511
- const Ne = /([\\`*_[\]<])/g, Me = /^([#>|+-]|\d+\.)/;
512
- function De(e, t = {}) {
833
+ function tt(e, t, n) {
834
+ const r = n || (e.wrapperStyle ? ` style="${p(e.wrapperStyle)}"` : ""), i = y(e.src), o = i ? ` src="${p(i)}"` : "", s = ` alt="${p(e.alt ?? "")}"`, c = e.caption ? `<figcaption>${$(e.caption)}</figcaption>` : "";
835
+ return `<figure${t}${r}><img${o}${s}>${c}</figure>`;
836
+ }
837
+ function nt(e, t, n, r) {
838
+ const i = D(e.videoId), o = n || (e.wrapperStyle ? ` style="${p(e.wrapperStyle)}"` : ""), s = i ? ` data-youtube-id="${p(i)}"` : "", c = i ? ` src="${p(`${R}${i}`)}"` : "";
839
+ return `<div${r("aw-youtube-embed")}${s}${t}${o}><iframe${c} allow="${p(re)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`;
840
+ }
841
+ function rt(e, t, n, r, i) {
842
+ const o = x(e.href) || "#", s = e.text && e.text.length > 0 ? e.text : H(o) || o, c = e.description ?? "", a = y(e.image), u = e.favicon ? y(e.favicon) : ee(o), l = `<a${i(a ? "aw-link-card aw-link-card-with-image" : "aw-link-card")} href="${p(o)}" target="_blank" rel="noopener"${t}${n}>`;
843
+ if (r) return `${l}${C(r)}</a>`;
844
+ let f = l;
845
+ return a && (f += `<img class="aw-link-card-image" src="${p(a)}" alt="" loading="lazy">`), f += '<span class="aw-link-card-body">', f += `<span class="aw-link-card-title">${$(s)}</span>`, c && (f += `<span class="aw-link-card-desc">${$(c)}</span>`), f += '<span class="aw-link-card-url">', u && (f += `<img class="aw-link-card-favicon" src="${p(u)}" alt="" loading="lazy">`), f += `<span class="aw-link-card-url-text">${$(o)}</span>`, f += "</span></span></a>", f;
846
+ }
847
+ function it(e, t, n, r, i) {
848
+ const o = x(e.fileSrc), s = o ? ` href="${p(o)}"` : "", c = e.fileName ? ` data-file-name="${p(e.fileName)}"` : "", a = e.fileSize !== void 0 ? ` data-file-size="${p(String(e.fileSize))}"` : "", u = e.fileType ? ` data-file-type="${p(e.fileType)}"` : "", d = ` download="${p(e.fileName ?? "")}"`, l = [], f = Q(e.fileName, e.fileType);
849
+ f && l.push(f), e.fileSize !== void 0 && l.push(J(e.fileSize));
850
+ const w = `<a${i("aw-file-attachment")} target="_blank" rel="noopener"${s}${d}${c}${a}${u}${t}${n}>`;
851
+ if (r) return `${w}${C(r)}</a>`;
852
+ let g = w;
853
+ return g += `<span class="aw-file-icon" aria-hidden="true">${te}</span>`, g += '<span class="aw-file-meta">', g += `<span class="aw-file-name">${$(e.fileName ?? ie)}</span>`, l.length > 0 && (g += `<span class="aw-file-info">${$(l.join(" · "))}</span>`), g += "</span>", g += `<span class="aw-file-action" aria-hidden="true">${ne}</span>`, g += "</a>", g;
854
+ }
855
+ const ot = /([\\`*_[\]<])/g, st = /^([#>|+-]|\d+\.)/;
856
+ function mt(e, t = {}) {
513
857
  const n = t.bullet ?? "-", r = t.gfmTables !== !1, i = [];
514
- for (const o of O(e)) {
515
- const c = Re(o, n, r);
516
- c !== "" && i.push(c);
858
+ for (const o of M(e)) {
859
+ const s = at(o, n, r);
860
+ s !== "" && i.push(s);
517
861
  }
518
862
  return i.length > 0 ? `${i.join(`
519
863
 
520
864
  `)}
521
865
  ` : "";
522
866
  }
523
- function Re(e, t, n) {
524
- var i, o, c, a;
525
- const r = S(e.html);
867
+ function at(e, t, n) {
868
+ var i, o, s, c;
869
+ const r = k(e.html);
526
870
  switch (e.kind) {
527
871
  case "paragraph":
528
872
  case "unknown": {
529
- const s = k(r).trim();
530
- return s === "" ? "" : F(s);
873
+ const a = h(r).trim();
874
+ return a === "" ? "" : F(a);
531
875
  }
532
876
  case "heading": {
533
- const s = Math.min(6, Math.max(1, e.attrs.level ?? 1)), u = k(r).trim();
534
- return u === "" ? "" : `${"#".repeat(s)} ${u}`;
877
+ const a = Math.min(6, Math.max(1, e.attrs.level ?? 1)), u = h(r).trim();
878
+ return u === "" ? "" : `${"#".repeat(a)} ${u}`;
535
879
  }
536
880
  case "bulletList":
537
881
  return E(r, { ordered: !1, bullet: t, depth: 0 });
@@ -545,7 +889,7 @@ function Re(e, t, n) {
545
889
  task: !0
546
890
  });
547
891
  case "blockquote": {
548
- const s = _(r, "p"), d = (s.length > 0 ? s.map((l) => k(l.children).trim()) : [k(r).trim()]).filter((l) => l !== "").join(`
892
+ const a = _(r, "p"), d = (a.length > 0 ? a.map((l) => h(l.children).trim()) : [h(r).trim()]).filter((l) => l !== "").join(`
549
893
 
550
894
  `).split(`
551
895
  `).map((l) => l === "" ? ">" : `> ${l}`);
@@ -553,39 +897,60 @@ function Re(e, t, n) {
553
897
  `) : "";
554
898
  }
555
899
  case "codeBlock": {
556
- const s = _(r, "code")[0], u = R(s ? s.children : r).replace(/\n$/, ""), d = e.attrs.language ?? (s == null ? void 0 : s.attrs["data-language"]) ?? "", l = "`".repeat(Math.max(3, V(u) + 1));
900
+ const a = _(r, "code")[0], u = O(a ? a.children : r).replace(/\n$/, ""), d = e.attrs.language ?? (a == null ? void 0 : a.attrs["data-language"]) ?? "", l = "`".repeat(Math.max(3, Z(u) + 1));
557
901
  return `${l}${d}
558
902
  ${u}
559
903
  ${l}`;
560
904
  }
561
905
  case "image": {
562
- const s = e.attrs.src ?? "";
563
- if (s === "") return "";
564
- const u = `![${b(e.attrs.alt ?? "")}](${v(s)})`, d = (i = e.attrs.caption) == null ? void 0 : i.trim();
906
+ const a = e.attrs.src ?? "";
907
+ if (a === "") return "";
908
+ const u = `![${b(e.attrs.alt ?? "")}](${v(a)})`, d = (i = e.attrs.caption) == null ? void 0 : i.trim();
565
909
  return d ? `${u}
566
910
  *${b(d)}*` : u;
567
911
  }
568
912
  case "table":
569
- return n ? Oe(r) : `<table>${e.html}</table>`;
913
+ return n && !Y(r) ? ct(r) : `<table>${e.html}</table>`;
570
914
  case "hr":
571
915
  return "---";
572
916
  case "linkCard": {
573
- const s = e.attrs.href ?? "";
574
- if (s === "") return "";
575
- const u = ((o = e.attrs.text) == null ? void 0 : o.trim()) || s, d = `[${b(u)}](${v(s)})`, l = (c = e.attrs.description) == null ? void 0 : c.trim();
917
+ const a = e.attrs.href ?? "";
918
+ if (a === "") return "";
919
+ const u = ((o = e.attrs.text) == null ? void 0 : o.trim()) || a, d = `[${b(u)}](${v(a)})`, l = (s = e.attrs.description) == null ? void 0 : s.trim();
576
920
  return l ? `${d}
577
921
 
578
922
  ${F(b(l))}` : d;
579
923
  }
580
924
  case "youtube": {
581
- const s = e.attrs.videoId;
582
- return s ? `[YouTube](${N}${encodeURIComponent(s)})` : "";
925
+ const a = e.attrs.videoId;
926
+ return a ? `[YouTube](${R}${encodeURIComponent(a)})` : "";
583
927
  }
584
928
  case "file": {
585
- const s = e.attrs.fileSrc ?? "";
586
- if (s === "") return "";
587
- const u = ((a = e.attrs.fileName) == null ? void 0 : a.trim()) || s;
588
- return `[${b(u)}](${v(s)})`;
929
+ const a = e.attrs.fileSrc ?? "";
930
+ if (a === "") return "";
931
+ const u = ((c = e.attrs.fileName) == null ? void 0 : c.trim()) || a;
932
+ return `[${b(u)}](${v(a)})`;
933
+ }
934
+ case "callout": {
935
+ const a = U(e.attrs.variant), u = _(r, "p"), l = (u.length > 0 ? u.map((f) => h(f.children).trim()) : [h(r).trim()]).filter((f) => f !== "").join(`
936
+
937
+ `).split(`
938
+ `).map((f) => f === "" ? ">" : `> ${f}`);
939
+ return [`> [!${a.toUpperCase()}]`, ...l].join(`
940
+ `);
941
+ }
942
+ case "toggle": {
943
+ const a = W(r, "summary"), u = a ? h(a.children).trim() : "", d = r.filter(
944
+ (f) => f.type !== "element" || f.tag !== "summary"
945
+ ), l = h(d).trim();
946
+ return [
947
+ "<details>",
948
+ `<summary>${u}</summary>`,
949
+ "",
950
+ l,
951
+ "</details>"
952
+ ].join(`
953
+ `);
589
954
  }
590
955
  case "importedHtml":
591
956
  return e.html.trim();
@@ -597,17 +962,17 @@ function E(e, t) {
597
962
  const n = _(e, "li");
598
963
  if (n.length === 0) return "";
599
964
  const r = " ".repeat(t.depth), i = [];
600
- return n.forEach((o, c) => {
601
- const a = [], s = [];
602
- for (const p of o.children)
603
- p.type === "element" && (p.tag === "ul" || p.tag === "ol") ? s.push(p) : a.push(p);
604
- const u = t.ordered ? `${c + 1}.` : t.bullet, d = t.task ? `${u} ${o.attrs[ue] === "true" ? "[x]" : "[ ]"}` : u, l = k(a).trim(), $ = `${r}${" ".repeat(d.length + 1)}`, h = l.split(`
965
+ return n.forEach((o, s) => {
966
+ const c = [], a = [];
967
+ for (const g of o.children)
968
+ g.type === "element" && (g.tag === "ul" || g.tag === "ol") ? a.push(g) : c.push(g);
969
+ const u = t.ordered ? `${s + 1}.` : t.bullet, d = t.task ? `${u} ${o.attrs[fe] === "true" ? "[x]" : "[ ]"}` : u, l = h(c).trim(), f = `${r}${" ".repeat(d.length + 1)}`, w = l.split(`
605
970
  `).join(`
606
- ${$}`);
607
- i.push(`${r}${d} ${h}`);
608
- for (const p of s) {
609
- const A = E(p.children, {
610
- ordered: p.tag === "ol",
971
+ ${f}`);
972
+ i.push(`${r}${d} ${w}`);
973
+ for (const g of a) {
974
+ const A = E(g.children, {
975
+ ordered: g.tag === "ol",
611
976
  bullet: t.bullet,
612
977
  depth: t.depth + 1
613
978
  });
@@ -616,7 +981,12 @@ ${$}`);
616
981
  }), i.join(`
617
982
  `);
618
983
  }
619
- function Oe(e) {
984
+ function Y(e) {
985
+ return e.some(
986
+ (t) => t.type === "element" && ((t.tag === "td" || t.tag === "th") && (Number(t.attrs.rowspan) > 1 || Number(t.attrs.colspan) > 1) || Y(t.children))
987
+ );
988
+ }
989
+ function ct(e) {
620
990
  const t = [], n = (d) => {
621
991
  for (const l of d)
622
992
  if (l.type === "element") {
@@ -631,28 +1001,28 @@ function Oe(e) {
631
1001
  const r = t.map(
632
1002
  (d) => d.children.filter(
633
1003
  (l) => l.type === "element" && (l.tag === "td" || l.tag === "th")
634
- ).map((l) => ze(l.children))
1004
+ ).map((l) => lt(l.children))
635
1005
  ), i = r.reduce((d, l) => Math.max(d, l.length), 0);
636
1006
  if (i === 0) return "";
637
- const o = (d) => d.length === i ? d : [...d, ...Array(i - d.length).fill("")], [c, ...a] = r.map(o);
1007
+ const o = (d) => d.length === i ? d : [...d, ...Array(i - d.length).fill("")], [s, ...c] = r.map(o);
638
1008
  return [
639
- `| ${(c ?? Array(i).fill("")).join(" | ")} |`,
1009
+ `| ${(s ?? Array(i).fill("")).join(" | ")} |`,
640
1010
  `| ${Array(i).fill("---").join(" | ")} |`,
641
- ...a.map((d) => `| ${d.join(" | ")} |`)
1011
+ ...c.map((d) => `| ${d.join(" | ")} |`)
642
1012
  ].join(`
643
1013
  `);
644
1014
  }
645
- function ze(e) {
646
- return k(e, { inTableCell: !0 }).replace(/\n+/g, "<br>").replace(/\|/g, "\\|").trim();
1015
+ function lt(e) {
1016
+ return h(e, { inTableCell: !0 }).replace(/\n+/g, "<br>").replace(/\|/g, "\\|").trim();
647
1017
  }
648
- function k(e, t = {}) {
1018
+ function h(e, t = {}) {
649
1019
  let n = "";
650
1020
  for (const r of e) {
651
1021
  if (r.type === "text") {
652
1022
  n += b(r.value);
653
1023
  continue;
654
1024
  }
655
- const i = () => k(r.children, t);
1025
+ const i = () => h(r.children, t);
656
1026
  switch (r.tag) {
657
1027
  case "br":
658
1028
  n += t.inTableCell ? `
@@ -679,13 +1049,13 @@ function k(e, t = {}) {
679
1049
  break;
680
1050
  }
681
1051
  case "code": {
682
- const o = R(r.children), c = "`".repeat(V(o) + 1), a = o.startsWith("`") || o.endsWith("`") ? " " : "";
683
- n += `${c}${a}${o}${a}${c}`;
1052
+ const o = O(r.children), s = "`".repeat(Z(o) + 1), c = o.startsWith("`") || o.endsWith("`") ? " " : "";
1053
+ n += `${s}${c}${o}${c}${s}`;
684
1054
  break;
685
1055
  }
686
1056
  case "a": {
687
- const o = r.attrs.href, c = i();
688
- n += o ? `[${c}](${v(o)})` : c;
1057
+ const o = r.attrs.href, s = i();
1058
+ n += o ? `[${s}](${v(o)})` : s;
689
1059
  break;
690
1060
  }
691
1061
  case "img": {
@@ -707,12 +1077,12 @@ function k(e, t = {}) {
707
1077
  return n;
708
1078
  }
709
1079
  function b(e) {
710
- return e.replace(Ne, "\\$1");
1080
+ return e.replace(ot, "\\$1");
711
1081
  }
712
1082
  function F(e) {
713
- return e.replace(Me, "\\$1");
1083
+ return e.replace(st, "\\$1");
714
1084
  }
715
- function V(e) {
1085
+ function Z(e) {
716
1086
  let t = 0, n = 0;
717
1087
  for (const r of e)
718
1088
  r === "`" ? (n += 1, n > t && (t = n)) : n = 0;
@@ -722,42 +1092,42 @@ function v(e) {
722
1092
  const t = e.trim();
723
1093
  return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
724
1094
  }
725
- function We(e, t = {}) {
1095
+ function ht(e, t = {}) {
726
1096
  const n = t.blockSeparator ?? `
727
1097
 
728
1098
  `, r = t.cellSeparator ?? " ", i = [];
729
- for (const o of O(e)) {
730
- const c = Be(o, r);
731
- c !== "" && i.push(c);
1099
+ for (const o of M(e)) {
1100
+ const s = ut(o, r);
1101
+ s !== "" && i.push(s);
732
1102
  }
733
1103
  return i.join(n);
734
1104
  }
735
- function Be(e, t) {
1105
+ function ut(e, t) {
736
1106
  switch (e.kind) {
737
1107
  case "hr":
738
1108
  case "youtube":
739
1109
  return "";
740
1110
  case "image":
741
- return w(
1111
+ return S(
742
1112
  [e.attrs.alt, e.attrs.caption].filter(Boolean).join(`
743
1113
  `)
744
1114
  );
745
1115
  case "linkCard":
746
- return w(e.attrs.text ?? e.attrs.href ?? "");
1116
+ return S(e.attrs.text ?? e.attrs.href ?? "");
747
1117
  case "file":
748
- return w(e.attrs.fileName ?? "");
1118
+ return S(e.attrs.fileName ?? "");
749
1119
  case "bulletList":
750
1120
  case "orderedList":
751
1121
  case "taskList":
752
- return _(S(e.html), "li").map((r) => w(x(r.children))).filter((r) => r !== "").join(`
1122
+ return _(k(e.html), "li").map((r) => S(L(r.children))).filter((r) => r !== "").join(`
753
1123
  `);
754
1124
  case "table":
755
- return je(S(e.html), t);
1125
+ return dt(k(e.html), t);
756
1126
  default:
757
- return w(x(S(e.html)));
1127
+ return S(L(k(e.html)));
758
1128
  }
759
1129
  }
760
- function je(e, t) {
1130
+ function dt(e, t) {
761
1131
  const n = [], r = (i) => {
762
1132
  for (const o of i)
763
1133
  o.type === "element" && (o.tag === "tr" ? n.push(o) : ["tbody", "thead", "tfoot"].includes(o.tag) && r(o.children));
@@ -765,34 +1135,25 @@ function je(e, t) {
765
1135
  return r(e), n.map(
766
1136
  (i) => i.children.filter(
767
1137
  (o) => o.type === "element" && (o.tag === "td" || o.tag === "th")
768
- ).map((o) => w(x(o.children)).replace(/\n+/g, " ")).join(t)
769
- ).filter((i) => i.replace(new RegExp(Fe(t), "g"), "").trim() !== "").join(`
1138
+ ).map((o) => S(L(o.children)).replace(/\n+/g, " ")).join(t)
1139
+ ).filter((i) => i.replace(new RegExp(ft(t), "g"), "").trim() !== "").join(`
770
1140
  `);
771
1141
  }
772
- function w(e) {
773
- return e.replace(ie, "").split(`
1142
+ function S(e) {
1143
+ return e.replace(se, "").split(`
774
1144
  `).map((t) => t.replace(/[^\S\n]+/g, " ").trim()).join(`
775
1145
  `).replace(/\n{3,}/g, `
776
1146
 
777
1147
  `).trim();
778
1148
  }
779
- function Fe(e) {
1149
+ function ft(e) {
780
1150
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
781
1151
  }
782
1152
  export {
783
- Ue as SNAPSHOT_VERSION,
784
- De as blocksToMarkdown,
785
- We as blocksToPlainText,
786
- y as decodeEntities,
787
- f as escapeAttr,
788
- g as escapeHtml,
789
- S as parseHtmlFragment,
790
- qe as renderBlockToHTML,
791
- He as renderBlocksToHTML,
792
- M as serializeNodes,
793
- we as snapshotVersionOf,
794
- R as textOf,
795
- x as textWithBlockBreaks,
796
- K as upgradeSnapshot,
797
- O as upgradeSnapshots
1153
+ pt as SNAPSHOT_VERSION,
1154
+ mt as blocksToMarkdown,
1155
+ ht as blocksToPlainText,
1156
+ gt as renderBlocksToHTML,
1157
+ De as sanitizeHTML,
1158
+ M as upgradeSnapshots
798
1159
  };