@clevertask/scribe 0.1.4 → 0.1.6

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 (85) hide show
  1. package/README.md +3 -0
  2. package/dist/BarMenu-CXaFlpRJ.js +272 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/BarMenu.js +2 -10
  6. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  7. package/dist/components/Menu/BubbleMenu.js +165 -1023
  8. package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
  9. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
  10. package/dist/components/Menu/LinkBubbleMenu.js +78 -0
  11. package/dist/components/Menu/LinkEditor.d.ts +14 -0
  12. package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
  13. package/dist/components/Menu/LinkEditor.js +140 -0
  14. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
  16. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
  17. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
  18. package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
  19. package/dist/components/Menu/linkUrl.d.ts +2 -0
  20. package/dist/components/Menu/linkUrl.d.ts.map +1 -0
  21. package/dist/components/Menu/linkUrl.js +21 -0
  22. package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
  23. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
  24. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
  26. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/extension-link.js +2 -4
  28. package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
  29. package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
  30. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
  32. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
  33. package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
  34. package/dist/components/Scribe/extension/index.d.ts +4 -4
  35. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/extension/index.js +2 -39521
  37. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
  38. package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
  39. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  40. package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
  41. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  42. package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
  43. package/dist/components/Scribe/extension/tableOfContents.js +153 -180
  44. package/dist/components/Scribe/index.d.ts.map +1 -1
  45. package/dist/components/Scribe/index.js +113 -153
  46. package/dist/dist-BQjH-i-q.js +7016 -0
  47. package/dist/dist-CnXCIcnl.js +3506 -0
  48. package/dist/dist-Cp938P7P.js +689 -0
  49. package/dist/extension-CZOsheCI.js +56236 -0
  50. package/dist/extension-link-DZID_SYl.js +908 -0
  51. package/dist/floating-ui.dom-rih69525.js +928 -0
  52. package/dist/html-to-markdown-CrNOkSye.js +497 -0
  53. package/dist/icons/ToolbarIcons.d.ts.map +1 -1
  54. package/dist/icons/ToolbarIcons.js +76 -135
  55. package/dist/main.css +10 -0
  56. package/dist/main.js +7 -15
  57. package/dist/markdown-to-html-DEczPfuq.js +1458 -0
  58. package/dist/menus-CakIdDdY.js +633 -0
  59. package/dist/purify.es-DF9CW1cl.js +767 -0
  60. package/dist/rolldown-runtime-CtkjhSXr.js +4 -0
  61. package/dist/slashCommand-B7CRIaKG.js +429 -0
  62. package/dist/tables-CjOC70rm.js +1345 -0
  63. package/dist/tippy.esm-D9LL2xiE.js +1713 -0
  64. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
  65. package/dist/utils/convert-legacy-math-delimiters.js +7 -13
  66. package/dist/utils/create-scribe-editor.js +2 -31
  67. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  68. package/dist/utils/html-to-markdown.js +2 -600
  69. package/dist/utils/index.js +24 -12
  70. package/dist/utils/is-in-viewport.d.ts.map +1 -1
  71. package/dist/utils/is-in-viewport.js +6 -6
  72. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  73. package/dist/utils/markdown-to-html.js +2 -5
  74. package/dist/vite-env.d.js +0 -1
  75. package/package.json +38 -36
  76. package/dist/BarMenu-BNk2I0zi.js +0 -327
  77. package/dist/extension-link-P1rro4zO.js +0 -1059
  78. package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
  79. package/dist/index-BMISMQrG.js +0 -855
  80. package/dist/index-ByyiiYsp.js +0 -1410
  81. package/dist/index-CnKS-BY2.js +0 -13834
  82. package/dist/index-CnQHDObA.js +0 -539
  83. package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
  84. package/dist/purify.es-DC1iJOxX.js +0 -864
  85. package/dist/tippy.esm-DLHdsnfG.js +0 -1711
@@ -1 +1 @@
1
- {"version":3,"file":"convert-legacy-math-delimiters.d.ts","sourceRoot":"","sources":["../../lib/utils/convert-legacy-math-delimiters.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,WAOxD,CAAC"}
1
+ {"version":3,"file":"convert-legacy-math-delimiters.d.ts","sourceRoot":"","sources":["../../lib/utils/convert-legacy-math-delimiters.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,2BAA2B,UAAW,MAAM,WAOxD,CAAC"}
@@ -1,13 +1,7 @@
1
- const r = (t) => t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), o = (t) => `<span data-type="inline-math" data-latex="${r(t.trim())}"></span>`, p = (t) => `<div data-type="block-math" data-latex="${r(t.trim())}"></div>`, s = (t) => /\\[a-zA-Z]+|[_^]/.test(t), g = /\\\(([^\n]+?)\\\)|\\\[([^\n]+?)\\\]|\[([^\n]+?)\]|\(([^\n]+?)\)/g, d = (t) => t.replace(g, (e, n, a, l, c) => {
2
- const i = n || a || l || c || "";
3
- return !!!(n || a) && !s(i) ? e : o(i);
4
- }), m = (t) => t.split(/(<[^>]+>)/g).map((e) => e.startsWith("<") ? e : d(e)).join(""), x = (t) => {
5
- const e = t.replace(
6
- /(^|\n)[ \t]*(?:\\\[|\[)([\s\S]*?)(?:\\\]|\])[ \t]*(?=\n|$)/g,
7
- (n, a, l) => s(l) ? `${a}${p(l)}` : n
8
- );
9
- return m(e);
10
- };
11
- export {
12
- x as convertLegacyMathDelimiters
13
- };
1
+ //#region lib/utils/convert-legacy-math-delimiters.ts
2
+ var e = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), t = (t) => `<span data-type="inline-math" data-latex="${e(t.trim())}"></span>`, n = (t) => `<div data-type="block-math" data-latex="${e(t.trim())}"></div>`, r = (e) => /\\[a-zA-Z]+|[_^]/.test(e), i = /\\\(([^\n]+?)\\\)|\\\[([^\n]+?)\\\]|\[([^\n]+?)\]|\(([^\n]+?)\)/g, a = (e) => e.replace(i, (e, n, i, a, o) => {
3
+ let s = n || i || a || o || "";
4
+ return !(n || i) && !r(s) ? e : t(s);
5
+ }), o = (e) => e.split(/(<[^>]+>)/g).map((e) => e.startsWith("<") ? e : a(e)).join(""), s = (e) => o(e.replace(/(^|\n)[ \t]*(?:\\\[|\[)([\s\S]*?)(?:\\\]|\])[ \t]*(?=\n|$)/g, (e, t, i) => r(i) ? `${t}${n(i)}` : e));
6
+ //#endregion
7
+ export { s as convertLegacyMathDelimiters };
@@ -1,31 +1,2 @@
1
- import { E as i } from "../index-CnKS-BY2.js";
2
- import { initExtensions as n } from "../components/Scribe/extension/index.js";
3
- import { html2md as m } from "./html-to-markdown.js";
4
- import "../markdown-to-html-Bw9L43K6.js";
5
- import "../purify.es-DC1iJOxX.js";
6
- function d({
7
- content: r = "",
8
- editable: e = !1,
9
- onContentChange: o
10
- }) {
11
- return new i({
12
- content: r,
13
- editable: e,
14
- extensions: n({}),
15
- onUpdate({ editor: t }) {
16
- o && o({
17
- htmlContent: t.getHTML(),
18
- jsonContent: t.getJSON(),
19
- markdownContent: m(t.getHTML())
20
- });
21
- },
22
- editorProps: {
23
- attributes: {
24
- class: "scribe"
25
- }
26
- }
27
- });
28
- }
29
- export {
30
- d as createScribeEditor
31
- };
1
+ import { createScribeEditor as e } from "./index.js";
2
+ export { e as createScribeEditor };
@@ -1 +1 @@
1
- {"version":3,"file":"html-to-markdown.d.ts","sourceRoot":"","sources":["../../lib/utils/html-to-markdown.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,WAiCnC,CAAC"}
1
+ {"version":3,"file":"html-to-markdown.d.ts","sourceRoot":"","sources":["../../lib/utils/html-to-markdown.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,SAAU,MAAM,WAiCnC,CAAC"}
@@ -1,600 +1,2 @@
1
- import { p as $ } from "../purify.es-DC1iJOxX.js";
2
- function H(e) {
3
- for (var t = 1; t < arguments.length; t++) {
4
- var r = arguments[t];
5
- for (var n in r)
6
- Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
7
- }
8
- return e;
9
- }
10
- function v(e, t) {
11
- return Array(t + 1).join(e);
12
- }
13
- function C(e) {
14
- return e.replace(/^\n*/, "");
15
- }
16
- function b(e) {
17
- for (var t = e.length; t > 0 && e[t - 1] === `
18
- `; ) t--;
19
- return e.substring(0, t);
20
- }
21
- function S(e) {
22
- return b(C(e));
23
- }
24
- var F = ["ADDRESS", "ARTICLE", "ASIDE", "AUDIO", "BLOCKQUOTE", "BODY", "CANVAS", "CENTER", "DD", "DIR", "DIV", "DL", "DT", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "FRAMESET", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HGROUP", "HR", "HTML", "ISINDEX", "LI", "MAIN", "MENU", "NAV", "NOFRAMES", "NOSCRIPT", "OL", "OUTPUT", "P", "PRE", "SECTION", "TABLE", "TBODY", "TD", "TFOOT", "TH", "THEAD", "TR", "UL"];
25
- function A(e) {
26
- return y(e, F);
27
- }
28
- var w = ["AREA", "BASE", "BR", "COL", "COMMAND", "EMBED", "HR", "IMG", "INPUT", "KEYGEN", "LINK", "META", "PARAM", "SOURCE", "TRACK", "WBR"];
29
- function O(e) {
30
- return y(e, w);
31
- }
32
- function V(e) {
33
- return B(e, w);
34
- }
35
- var D = ["A", "TABLE", "THEAD", "TBODY", "TFOOT", "TH", "TD", "IFRAME", "SCRIPT", "AUDIO", "VIDEO"];
36
- function U(e) {
37
- return y(e, D);
38
- }
39
- function W(e) {
40
- return B(e, D);
41
- }
42
- function y(e, t) {
43
- return t.indexOf(e.nodeName) >= 0;
44
- }
45
- function B(e, t) {
46
- return e.getElementsByTagName && t.some(function(r) {
47
- return e.getElementsByTagName(r).length;
48
- });
49
- }
50
- var _ = [[/\\/g, "\\\\"], [/\*/g, "\\*"], [/^-/g, "\\-"], [/^\+ /g, "\\+ "], [/^(=+)/g, "\\$1"], [/^(#{1,6}) /g, "\\$1 "], [/`/g, "\\`"], [/^~~~/g, "\\~~~"], [/\[/g, "\\["], [/\]/g, "\\]"], [/^>/g, "\\>"], [/_/g, "\\_"], [/^(\d+)\. /g, "$1\\. "]];
51
- function x(e) {
52
- return _.reduce(function(t, r) {
53
- return t.replace(r[0], r[1]);
54
- }, e);
55
- }
56
- var o = {};
57
- o.paragraph = {
58
- filter: "p",
59
- replacement: function(e) {
60
- return `
61
-
62
- ` + e + `
63
-
64
- `;
65
- }
66
- };
67
- o.lineBreak = {
68
- filter: "br",
69
- replacement: function(e, t, r) {
70
- return r.br + `
71
- `;
72
- }
73
- };
74
- o.heading = {
75
- filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
76
- replacement: function(e, t, r) {
77
- var n = Number(t.nodeName.charAt(1));
78
- if (r.headingStyle === "setext" && n < 3) {
79
- var i = v(n === 1 ? "=" : "-", e.length);
80
- return `
81
-
82
- ` + e + `
83
- ` + i + `
84
-
85
- `;
86
- } else
87
- return `
88
-
89
- ` + v("#", n) + " " + e + `
90
-
91
- `;
92
- }
93
- };
94
- o.blockquote = {
95
- filter: "blockquote",
96
- replacement: function(e) {
97
- return e = S(e).replace(/^/gm, "> "), `
98
-
99
- ` + e + `
100
-
101
- `;
102
- }
103
- };
104
- o.list = {
105
- filter: ["ul", "ol"],
106
- replacement: function(e, t) {
107
- var r = t.parentNode;
108
- return r.nodeName === "LI" && r.lastElementChild === t ? `
109
- ` + e : `
110
-
111
- ` + e + `
112
-
113
- `;
114
- }
115
- };
116
- o.listItem = {
117
- filter: "li",
118
- replacement: function(e, t, r) {
119
- var n = r.bulletListMarker + " ", i = t.parentNode;
120
- if (i.nodeName === "OL") {
121
- var a = i.getAttribute("start"), s = Array.prototype.indexOf.call(i.children, t);
122
- n = (a ? Number(a) + s : s + 1) + ". ";
123
- }
124
- var u = /\n$/.test(e);
125
- return e = S(e) + (u ? `
126
- ` : ""), e = e.replace(/\n/gm, `
127
- ` + " ".repeat(n.length)), n + e + (t.nextSibling ? `
128
- ` : "");
129
- }
130
- };
131
- o.indentedCodeBlock = {
132
- filter: function(e, t) {
133
- return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
134
- },
135
- replacement: function(e, t, r) {
136
- return `
137
-
138
- ` + t.firstChild.textContent.replace(/\n/g, `
139
- `) + `
140
-
141
- `;
142
- }
143
- };
144
- o.fencedCodeBlock = {
145
- filter: function(e, t) {
146
- return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
147
- },
148
- replacement: function(e, t, r) {
149
- for (var n = t.firstChild.getAttribute("class") || "", i = (n.match(/language-(\S+)/) || [null, ""])[1], a = t.firstChild.textContent, s = r.fence.charAt(0), u = 3, l = new RegExp("^" + s + "{3,}", "gm"), c; c = l.exec(a); )
150
- c[0].length >= u && (u = c[0].length + 1);
151
- var f = v(s, u);
152
- return `
153
-
154
- ` + f + i + `
155
- ` + a.replace(/\n$/, "") + `
156
- ` + f + `
157
-
158
- `;
159
- }
160
- };
161
- o.horizontalRule = {
162
- filter: "hr",
163
- replacement: function(e, t, r) {
164
- return `
165
-
166
- ` + r.hr + `
167
-
168
- `;
169
- }
170
- };
171
- o.inlineLink = {
172
- filter: function(e, t) {
173
- return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
174
- },
175
- replacement: function(e, t) {
176
- var r = N(t.getAttribute("href")), n = k(h(t.getAttribute("title"))), i = n ? ' "' + n + '"' : "";
177
- return "[" + e + "](" + r + i + ")";
178
- }
179
- };
180
- o.referenceLink = {
181
- filter: function(e, t) {
182
- return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
183
- },
184
- replacement: function(e, t, r) {
185
- var n = N(t.getAttribute("href")), i = h(t.getAttribute("title"));
186
- i && (i = ' "' + k(i) + '"');
187
- var a, s;
188
- switch (r.linkReferenceStyle) {
189
- case "collapsed":
190
- a = "[" + e + "][]", s = "[" + e + "]: " + n + i;
191
- break;
192
- case "shortcut":
193
- a = "[" + e + "]", s = "[" + e + "]: " + n + i;
194
- break;
195
- default:
196
- var u = this.references.length + 1;
197
- a = "[" + e + "][" + u + "]", s = "[" + u + "]: " + n + i;
198
- }
199
- return this.references.push(s), a;
200
- },
201
- references: [],
202
- append: function(e) {
203
- var t = "";
204
- return this.references.length && (t = `
205
-
206
- ` + this.references.join(`
207
- `) + `
208
-
209
- `, this.references = []), t;
210
- }
211
- };
212
- o.emphasis = {
213
- filter: ["em", "i"],
214
- replacement: function(e, t, r) {
215
- return e.trim() ? r.emDelimiter + e + r.emDelimiter : "";
216
- }
217
- };
218
- o.strong = {
219
- filter: ["strong", "b"],
220
- replacement: function(e, t, r) {
221
- return e.trim() ? r.strongDelimiter + e + r.strongDelimiter : "";
222
- }
223
- };
224
- o.code = {
225
- filter: function(e) {
226
- var t = e.previousSibling || e.nextSibling, r = e.parentNode.nodeName === "PRE" && !t;
227
- return e.nodeName === "CODE" && !r;
228
- },
229
- replacement: function(e) {
230
- if (!e) return "";
231
- e = e.replace(/\r?\n|\r/g, " ");
232
- for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", r = "`", n = e.match(/`+/gm) || []; n.indexOf(r) !== -1; ) r = r + "`";
233
- return r + t + e + t + r;
234
- }
235
- };
236
- o.image = {
237
- filter: "img",
238
- replacement: function(e, t) {
239
- var r = x(h(t.getAttribute("alt"))), n = N(t.getAttribute("src") || ""), i = h(t.getAttribute("title")), a = i ? ' "' + k(i) + '"' : "";
240
- return n ? "![" + r + "](" + n + a + ")" : "";
241
- }
242
- };
243
- function h(e) {
244
- return e ? e.replace(/(\n+\s*)+/g, `
245
- `) : "";
246
- }
247
- function N(e) {
248
- var t = e.replace(/([<>()])/g, "\\$1");
249
- return t.indexOf(" ") >= 0 ? "<" + t + ">" : t;
250
- }
251
- function k(e) {
252
- return e.replace(/"/g, '\\"');
253
- }
254
- function L(e) {
255
- this.options = e, this._keep = [], this._remove = [], this.blankRule = {
256
- replacement: e.blankReplacement
257
- }, this.keepReplacement = e.keepReplacement, this.defaultRule = {
258
- replacement: e.defaultReplacement
259
- }, this.array = [];
260
- for (var t in e.rules) this.array.push(e.rules[t]);
261
- }
262
- L.prototype = {
263
- add: function(e, t) {
264
- this.array.unshift(t);
265
- },
266
- keep: function(e) {
267
- this._keep.unshift({
268
- filter: e,
269
- replacement: this.keepReplacement
270
- });
271
- },
272
- remove: function(e) {
273
- this._remove.unshift({
274
- filter: e,
275
- replacement: function() {
276
- return "";
277
- }
278
- });
279
- },
280
- forNode: function(e) {
281
- if (e.isBlank) return this.blankRule;
282
- var t;
283
- return (t = d(this.array, e, this.options)) || (t = d(this._keep, e, this.options)) || (t = d(this._remove, e, this.options)) ? t : this.defaultRule;
284
- },
285
- forEach: function(e) {
286
- for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
287
- }
288
- };
289
- function d(e, t, r) {
290
- for (var n = 0; n < e.length; n++) {
291
- var i = e[n];
292
- if (j(i, t, r)) return i;
293
- }
294
- }
295
- function j(e, t, r) {
296
- var n = e.filter;
297
- if (typeof n == "string") {
298
- if (n === t.nodeName.toLowerCase()) return !0;
299
- } else if (Array.isArray(n)) {
300
- if (n.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
301
- } else if (typeof n == "function") {
302
- if (n.call(e, t, r)) return !0;
303
- } else
304
- throw new TypeError("`filter` needs to be a string, array, or function");
305
- }
306
- function G(e) {
307
- var t = e.element, r = e.isBlock, n = e.isVoid, i = e.isPre || function(I) {
308
- return I.nodeName === "PRE";
309
- };
310
- if (!(!t.firstChild || i(t))) {
311
- for (var a = null, s = !1, u = null, l = T(u, t, i); l !== t; ) {
312
- if (l.nodeType === 3 || l.nodeType === 4) {
313
- var c = l.data.replace(/[ \r\n\t]+/g, " ");
314
- if ((!a || / $/.test(a.data)) && !s && c[0] === " " && (c = c.substr(1)), !c) {
315
- l = m(l);
316
- continue;
317
- }
318
- l.data = c, a = l;
319
- } else if (l.nodeType === 1)
320
- r(l) || l.nodeName === "BR" ? (a && (a.data = a.data.replace(/ $/, "")), a = null, s = !1) : n(l) || i(l) ? (a = null, s = !0) : a && (s = !1);
321
- else {
322
- l = m(l);
323
- continue;
324
- }
325
- var f = T(u, l, i);
326
- u = l, l = f;
327
- }
328
- a && (a.data = a.data.replace(/ $/, ""), a.data || m(a));
329
- }
330
- }
331
- function m(e) {
332
- var t = e.nextSibling || e.parentNode;
333
- return e.parentNode.removeChild(e), t;
334
- }
335
- function T(e, t, r) {
336
- return e && e.parentNode === t || r(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
337
- }
338
- var E = typeof window < "u" ? window : {};
339
- function X() {
340
- var e = E.DOMParser, t = !1;
341
- try {
342
- new e().parseFromString("", "text/html") && (t = !0);
343
- } catch {
344
- }
345
- return t;
346
- }
347
- function K() {
348
- var e = function() {
349
- };
350
- return Y() ? e.prototype.parseFromString = function(t) {
351
- var r = new window.ActiveXObject("htmlfile");
352
- return r.designMode = "on", r.open(), r.write(t), r.close(), r;
353
- } : e.prototype.parseFromString = function(t) {
354
- var r = document.implementation.createHTMLDocument("");
355
- return r.open(), r.write(t), r.close(), r;
356
- }, e;
357
- }
358
- function Y() {
359
- var e = !1;
360
- try {
361
- document.implementation.createHTMLDocument("").open();
362
- } catch {
363
- E.ActiveXObject && (e = !0);
364
- }
365
- return e;
366
- }
367
- var z = X() ? E.DOMParser : K();
368
- function q(e, t) {
369
- var r;
370
- if (typeof e == "string") {
371
- var n = Q().parseFromString(
372
- // DOM parsers arrange elements in the <head> and <body>.
373
- // Wrapping in a custom element ensures elements are reliably arranged in
374
- // a single element.
375
- '<x-turndown id="turndown-root">' + e + "</x-turndown>",
376
- "text/html"
377
- );
378
- r = n.getElementById("turndown-root");
379
- } else
380
- r = e.cloneNode(!0);
381
- return G({
382
- element: r,
383
- isBlock: A,
384
- isVoid: O,
385
- isPre: t.preformattedCode ? J : null
386
- }), r;
387
- }
388
- var g;
389
- function Q() {
390
- return g = g || new z(), g;
391
- }
392
- function J(e) {
393
- return e.nodeName === "PRE" || e.nodeName === "CODE";
394
- }
395
- function Z(e, t) {
396
- return e.isBlock = A(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = ee(e), e.flankingWhitespace = te(e, t), e;
397
- }
398
- function ee(e) {
399
- return !O(e) && !U(e) && /^\s*$/i.test(e.textContent) && !V(e) && !W(e);
400
- }
401
- function te(e, t) {
402
- if (e.isBlock || t.preformattedCode && e.isCode)
403
- return {
404
- leading: "",
405
- trailing: ""
406
- };
407
- var r = re(e.textContent);
408
- return r.leadingAscii && R("left", e, t) && (r.leading = r.leadingNonAscii), r.trailingAscii && R("right", e, t) && (r.trailing = r.trailingNonAscii), {
409
- leading: r.leading,
410
- trailing: r.trailing
411
- };
412
- }
413
- function re(e) {
414
- var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
415
- return {
416
- leading: t[1],
417
- // whole string for whitespace-only strings
418
- leadingAscii: t[2],
419
- leadingNonAscii: t[3],
420
- trailing: t[4],
421
- // empty for whitespace-only strings
422
- trailingNonAscii: t[5],
423
- trailingAscii: t[6]
424
- };
425
- }
426
- function R(e, t, r) {
427
- var n, i, a;
428
- return e === "left" ? (n = t.previousSibling, i = / $/) : (n = t.nextSibling, i = /^ /), n && (n.nodeType === 3 ? a = i.test(n.nodeValue) : r.preformattedCode && n.nodeName === "CODE" ? a = !1 : n.nodeType === 1 && !A(n) && (a = i.test(n.textContent))), a;
429
- }
430
- var ne = Array.prototype.reduce;
431
- function p(e) {
432
- if (!(this instanceof p)) return new p(e);
433
- var t = {
434
- rules: o,
435
- headingStyle: "setext",
436
- hr: "* * *",
437
- bulletListMarker: "*",
438
- codeBlockStyle: "indented",
439
- fence: "```",
440
- emDelimiter: "_",
441
- strongDelimiter: "**",
442
- linkStyle: "inlined",
443
- linkReferenceStyle: "full",
444
- br: " ",
445
- preformattedCode: !1,
446
- blankReplacement: function(r, n) {
447
- return n.isBlock ? `
448
-
449
- ` : "";
450
- },
451
- keepReplacement: function(r, n) {
452
- return n.isBlock ? `
453
-
454
- ` + n.outerHTML + `
455
-
456
- ` : n.outerHTML;
457
- },
458
- defaultReplacement: function(r, n) {
459
- return n.isBlock ? `
460
-
461
- ` + r + `
462
-
463
- ` : r;
464
- }
465
- };
466
- this.options = H({}, t, e), this.rules = new L(this.options);
467
- }
468
- p.prototype = {
469
- /**
470
- * The entry point for converting a string or DOM node to Markdown
471
- * @public
472
- * @param {String|HTMLElement} input The string or DOM node to convert
473
- * @returns A Markdown representation of the input
474
- * @type String
475
- */
476
- turndown: function(e) {
477
- if (!le(e))
478
- throw new TypeError(e + " is not a string, or an element/document/fragment node.");
479
- if (e === "") return "";
480
- var t = P.call(this, new q(e, this.options));
481
- return ie.call(this, t);
482
- },
483
- /**
484
- * Add one or more plugins
485
- * @public
486
- * @param {Function|Array} plugin The plugin or array of plugins to add
487
- * @returns The Turndown instance for chaining
488
- * @type Object
489
- */
490
- use: function(e) {
491
- if (Array.isArray(e))
492
- for (var t = 0; t < e.length; t++) this.use(e[t]);
493
- else if (typeof e == "function")
494
- e(this);
495
- else
496
- throw new TypeError("plugin must be a Function or an Array of Functions");
497
- return this;
498
- },
499
- /**
500
- * Adds a rule
501
- * @public
502
- * @param {String} key The unique key of the rule
503
- * @param {Object} rule The rule
504
- * @returns The Turndown instance for chaining
505
- * @type Object
506
- */
507
- addRule: function(e, t) {
508
- return this.rules.add(e, t), this;
509
- },
510
- /**
511
- * Keep a node (as HTML) that matches the filter
512
- * @public
513
- * @param {String|Array|Function} filter The unique key of the rule
514
- * @returns The Turndown instance for chaining
515
- * @type Object
516
- */
517
- keep: function(e) {
518
- return this.rules.keep(e), this;
519
- },
520
- /**
521
- * Remove a node that matches the filter
522
- * @public
523
- * @param {String|Array|Function} filter The unique key of the rule
524
- * @returns The Turndown instance for chaining
525
- * @type Object
526
- */
527
- remove: function(e) {
528
- return this.rules.remove(e), this;
529
- },
530
- /**
531
- * Escapes Markdown syntax
532
- * @public
533
- * @param {String} string The string to escape
534
- * @returns A string with Markdown syntax escaped
535
- * @type String
536
- */
537
- escape: function(e) {
538
- return x(e);
539
- }
540
- };
541
- function P(e) {
542
- var t = this;
543
- return ne.call(e.childNodes, function(r, n) {
544
- n = new Z(n, t.options);
545
- var i = "";
546
- return n.nodeType === 3 ? i = n.isCode ? n.nodeValue : t.escape(n.nodeValue) : n.nodeType === 1 && (i = ae.call(t, n)), M(r, i);
547
- }, "");
548
- }
549
- function ie(e) {
550
- var t = this;
551
- return this.rules.forEach(function(r) {
552
- typeof r.append == "function" && (e = M(e, r.append(t.options)));
553
- }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
554
- }
555
- function ae(e) {
556
- var t = this.rules.forNode(e), r = P.call(this, e), n = e.flankingWhitespace;
557
- return (n.leading || n.trailing) && (r = r.trim()), n.leading + t.replacement(r, e, this.options) + n.trailing;
558
- }
559
- function M(e, t) {
560
- var r = b(e), n = C(t), i = Math.max(e.length - r.length, t.length - n.length), a = `
561
-
562
- `.substring(0, i);
563
- return r + a + n;
564
- }
565
- function le(e) {
566
- return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
567
- }
568
- const oe = (e) => {
569
- const t = new p({
570
- headingStyle: "atx",
571
- hr: "---",
572
- bulletListMarker: "-",
573
- codeBlockStyle: "fenced"
574
- });
575
- t.addRule("latex", {
576
- filter: function(n) {
577
- return n.nodeName === "SPAN" && n.getAttribute("data-type") === "latex";
578
- },
579
- replacement: function(n, i) {
580
- const a = i, s = a.getAttribute("data-content") || "";
581
- return a.getAttribute("data-display-mode") === "true" ? `
582
-
583
- $$
584
- ${s}
585
- $$
586
-
587
- ` : `$${s}$`;
588
- }
589
- }), t.addRule("strikethrough", {
590
- filter: ["del", "s"],
591
- replacement: function(n) {
592
- return "~~" + n + "~~";
593
- }
594
- });
595
- const r = (n) => n.replace(/<span([^>]+data-type="latex"[^>]*)><\/span>/g, "<span$1>•</span>");
596
- return t.turndown($.sanitize(r(e)));
597
- };
598
- export {
599
- oe as html2md
600
- };
1
+ import { t as e } from "../html-to-markdown-CrNOkSye.js";
2
+ export { e as html2md };