hexagon-editor 0.1.0 → 0.1.2
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.
- package/README.md +1 -1
- package/dist/{MarkdownEditorLinkForm-mq-BVYM_.js → MarkdownEditorLinkForm-C7CGgA83.js} +74 -79
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/forms.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +241 -240
- package/dist/renderer/MarkdownRenderer.vue.d.ts.map +1 -1
- package/dist/renderer.css +1 -0
- package/dist/renderer.js +115 -114
- package/package.json +1 -1
package/dist/renderer.js
CHANGED
|
@@ -2,9 +2,10 @@ import { defineComponent as M, ref as S, getCurrentInstance as w, computed as I,
|
|
|
2
2
|
import { M as x, k as W } from "./katex-ByXcxnHy.js";
|
|
3
3
|
import { d as B } from "./index-uerphigI.js";
|
|
4
4
|
import { i as D, s as E, a as O } from "./index-CqpK5VVw.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { _ as z } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
import './renderer.css';const h = new x().utils.escapeHtml;
|
|
7
|
+
function L(n) {
|
|
8
|
+
n.inline.ruler.after("backticks", "inline_math", (e, r) => {
|
|
8
9
|
if (e.src[e.pos] !== "$" || e.src[e.pos + 1] === "$" || y(e.src, e.pos)) return !1;
|
|
9
10
|
let i = e.pos + 1;
|
|
10
11
|
for (; i < e.posMax; ) {
|
|
@@ -14,18 +15,18 @@ function z(t) {
|
|
|
14
15
|
}
|
|
15
16
|
if (i <= e.pos + 1 || /\s/.test(e.src[e.pos + 1] ?? "") || /\s/.test(e.src[i - 1] ?? "")) return !1;
|
|
16
17
|
if (!r) {
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const t = e.push("inline_math", "", 0);
|
|
19
|
+
t.content = e.src.slice(e.pos + 1, i);
|
|
19
20
|
}
|
|
20
21
|
return e.pos = i + 1, !0;
|
|
21
|
-
}),
|
|
22
|
+
}), n.block.ruler.before("fence", "math_block", (e, r, i, t) => {
|
|
22
23
|
const o = e.getLines(r, r + 1, 0, !1).trim();
|
|
23
24
|
if (!o.startsWith("$$")) return !1;
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
if (!
|
|
27
|
-
const
|
|
28
|
-
|
|
25
|
+
const s = o.match(/^\$\$\s*(.*?)\s*\$\$$/);
|
|
26
|
+
if (s !== null) {
|
|
27
|
+
if (!t) {
|
|
28
|
+
const l = e.push("math_block", "", 0);
|
|
29
|
+
l.content = s[1] ?? "";
|
|
29
30
|
}
|
|
30
31
|
return e.line = r + 1, !0;
|
|
31
32
|
}
|
|
@@ -33,183 +34,183 @@ function z(t) {
|
|
|
33
34
|
let c = r + 1;
|
|
34
35
|
for (; c < i && e.getLines(c, c + 1, 0, !1).trim() !== "$$"; ) c += 1;
|
|
35
36
|
if (c === i) return !1;
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
if (!t) {
|
|
38
|
+
const l = e.push("math_block", "", 0);
|
|
39
|
+
l.content = e.getLines(r + 1, c, 0, !1).trim();
|
|
39
40
|
}
|
|
40
41
|
return e.line = c + 1, !0;
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
44
|
+
function F(n) {
|
|
45
|
+
n.block.ruler.before("fence", "yfm_html_block", (e, r, i, t) => {
|
|
45
46
|
if (e.getLines(r, r + 1, 0, !1).trim() !== ":::html") return !1;
|
|
46
47
|
let o = r + 1;
|
|
47
48
|
for (; o < i && e.getLines(o, o + 1, 0, !1).trim() !== ":::"; ) o += 1;
|
|
48
49
|
if (o === i) return !1;
|
|
49
|
-
if (!
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
if (!t) {
|
|
51
|
+
const s = e.push("yfm_html_block", "", 0);
|
|
52
|
+
s.content = e.getLines(r + 1, o, 0, !1).trim();
|
|
52
53
|
}
|
|
53
54
|
return e.line = o + 1, !0;
|
|
54
|
-
}),
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
55
|
+
}), n.block.ruler.before("fence", "directive", (e, r, i, t) => {
|
|
56
|
+
const s = e.getLines(r, r + 1, 0, !1).trim().match(/^:::\s*(\w+)\s*$/);
|
|
57
|
+
if (s === null) return !1;
|
|
57
58
|
let c = r + 1;
|
|
58
59
|
for (; c < i && e.getLines(c, c + 1, 0, !1).trim() !== ":::"; ) c += 1;
|
|
59
60
|
if (c === i) return !1;
|
|
60
|
-
if (!
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
if (!t) {
|
|
62
|
+
const l = e.push("directive", "", 0);
|
|
63
|
+
l.info = s[1] ?? "note", l.content = e.getLines(r + 1, c, 0, !1).trim();
|
|
63
64
|
}
|
|
64
65
|
return e.line = c + 1, !0;
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
68
|
+
function P(n) {
|
|
69
|
+
n.core.ruler.after("block", "mermaid_fences", (e) => {
|
|
69
70
|
for (const r of e.tokens)
|
|
70
71
|
r.type === "fence" && r.info.trim() === "mermaid" && (r.type = "mermaid");
|
|
71
|
-
}),
|
|
72
|
+
}), n.core.ruler.after("inline", "renderer_extensions", (e) => {
|
|
72
73
|
for (let r = 0; r < e.tokens.length; r += 1) {
|
|
73
|
-
const i = e.tokens[r],
|
|
74
|
-
if (i?.type === "paragraph_open" &&
|
|
75
|
-
const c =
|
|
76
|
-
c !== null && (i.type = "heading_open", i.tag = `h${c[1]?.length ?? 1}`, i.attrSet("data-folding", "true"),
|
|
74
|
+
const i = e.tokens[r], t = e.tokens[r + 1], o = e.tokens[r + 2];
|
|
75
|
+
if (i?.type === "paragraph_open" && t?.type === "inline" && o?.type === "paragraph_close") {
|
|
76
|
+
const c = t.content.match(/^(#{1,6})\+\s+(.+)$/);
|
|
77
|
+
c !== null && (i.type = "heading_open", i.tag = `h${c[1]?.length ?? 1}`, i.attrSet("data-folding", "true"), t.content = c[2] ?? "", k(e, t), o.type = "heading_close", o.tag = i.tag);
|
|
77
78
|
}
|
|
78
|
-
if (i?.type === "heading_open" &&
|
|
79
|
-
|
|
80
|
-
const c =
|
|
79
|
+
if (i?.type === "heading_open" && t?.type === "inline") {
|
|
80
|
+
t.content.startsWith("+ ") && (t.content = t.content.slice(2), i.attrSet("data-folding", "true"), k(e, t));
|
|
81
|
+
const c = t.content.match(/\s+\{([^}]+)\}$/);
|
|
81
82
|
if (c !== null) {
|
|
82
|
-
|
|
83
|
-
for (const
|
|
84
|
-
|
|
83
|
+
t.content = t.content.slice(0, c.index), k(e, t);
|
|
84
|
+
for (const l of c[1]?.split(/\s+/) ?? [])
|
|
85
|
+
l.startsWith("#") && i.attrSet("id", l.slice(1)), l.startsWith(".") && i.attrJoin("class", l.slice(1));
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
88
|
+
const s = i?.children;
|
|
89
|
+
s != null && J(s);
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function k(n, e) {
|
|
93
94
|
const r = [];
|
|
94
|
-
|
|
95
|
+
n.md.inline.parse(e.content, n.md, n.env, r), e.children = r;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
-
for (let e = 0; e <
|
|
98
|
-
const r =
|
|
97
|
+
function J(n) {
|
|
98
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
99
|
+
const r = n[e], i = n[e + 1];
|
|
99
100
|
if (r?.type === "image" && i?.type === "text") {
|
|
100
|
-
const
|
|
101
|
-
|
|
101
|
+
const t = i.content.match(/^\{width=(\d+%?)(?:\s+height=(\d+))?(?:\s+object-fit=(contain|cover|fill|none|scale-down))?}/);
|
|
102
|
+
t !== null && (r.attrSet("width", t[1] ?? ""), t[2] !== void 0 && r.attrSet("height", t[2]), t[3] !== void 0 && r.attrSet("data-image-object-fit", t[3]), i.content = i.content.slice(t[0].length));
|
|
102
103
|
}
|
|
103
104
|
if (r?.type === "link_close" && i?.type === "text") {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
105
|
+
const t = i.content.match(/^\s*\{target="_blank" rel="noopener noreferrer"}/);
|
|
106
|
+
if (t !== null)
|
|
106
107
|
for (let o = e - 1; o >= 0; o -= 1) {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
|
|
108
|
+
const s = n[o];
|
|
109
|
+
if (s?.type === "link_open") {
|
|
110
|
+
s.attrSet("target", "_blank"), s.attrSet("rel", "noopener noreferrer"), i.content = i.content.slice(t[0].length);
|
|
110
111
|
break;
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
117
|
+
function K(n) {
|
|
118
|
+
n.core.ruler.after("renderer_extensions", "quote_links", (e) => {
|
|
118
119
|
for (let r = 0; r < e.tokens.length; r += 1) {
|
|
119
|
-
const i = e.tokens[r],
|
|
120
|
-
if (i?.type !== "blockquote_open" ||
|
|
120
|
+
const i = e.tokens[r], t = e.tokens[r + 1], o = e.tokens[r + 2], s = e.tokens[r + 3];
|
|
121
|
+
if (i?.type !== "blockquote_open" || t?.type !== "paragraph_open" || o?.type !== "inline" || s?.type !== "paragraph_close") continue;
|
|
121
122
|
const c = o.content.match(/^\[([^\]]+)]\(([^)]+)\)\{data-quotelink=true}$/);
|
|
122
123
|
c === null || e.tokens.findIndex((f, d) => d > r && f.type === "blockquote_close") < 0 || (i.attrSet("cite", c[2] ?? ""), i.attrSet("data-content", c[1] ?? ""), i.attrSet("data-quote-link", ""), e.tokens.splice(r + 1, 3));
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
`,
|
|
129
|
-
`,
|
|
130
|
-
const
|
|
131
|
-
return
|
|
132
|
-
` : `<div data-directive="${h(
|
|
127
|
+
function N(n) {
|
|
128
|
+
n.renderer.rules.inline_math = (t, o) => v(t[o]?.content ?? "", !1), n.renderer.rules.math_block = (t, o) => v(t[o]?.content ?? "", !0), n.renderer.rules.mermaid = (t, o) => `<div data-mermaid aria-busy="true"><pre>${h(t[o]?.content ?? "")}</pre></div>
|
|
129
|
+
`, n.renderer.rules.yfm_html_block = (t, o) => `<p data-yfm-html>:::html<br>${h(t[o]?.content ?? "")}<br>:::</p>
|
|
130
|
+
`, n.renderer.rules.directive = (t, o) => {
|
|
131
|
+
const s = t[o];
|
|
132
|
+
return s?.info === "html" ? `${s.content}
|
|
133
|
+
` : `<div data-directive="${h(s?.info || "note")}">${h(s?.content ?? "")}</div>
|
|
133
134
|
`;
|
|
134
|
-
},
|
|
135
|
-
`,
|
|
136
|
-
const e =
|
|
137
|
-
|
|
138
|
-
const f =
|
|
139
|
-
return d != null && /^\d+%?$/.test(d) && m.push(`width: ${d.endsWith("%") ? d : `${d}px`}`), a != null && /^\d+$/.test(a) && m.push(`height: ${a}px`), u != null && m.push(`object-fit: ${u}`), m.length > 0 && f?.attrSet("style", m.join("; ")), e?.(
|
|
135
|
+
}, n.renderer.rules.html_block = (t, o) => `<div data-raw-html>${h(t[o]?.content ?? "")}</div>
|
|
136
|
+
`, n.renderer.rules.html_inline = (t, o) => Q(t[o]?.content ?? "");
|
|
137
|
+
const e = n.renderer.rules.image;
|
|
138
|
+
n.renderer.rules.image = (t, o, s, c, l) => {
|
|
139
|
+
const f = t[o], d = f?.attrGet("width"), a = f?.attrGet("height"), u = f?.attrGet("data-image-object-fit"), m = [];
|
|
140
|
+
return d != null && /^\d+%?$/.test(d) && m.push(`width: ${d.endsWith("%") ? d : `${d}px`}`), a != null && /^\d+$/.test(a) && m.push(`height: ${a}px`), u != null && m.push(`object-fit: ${u}`), m.length > 0 && f?.attrSet("style", m.join("; ")), e?.(t, o, s, c, l) ?? l.renderToken(t, o, s);
|
|
140
141
|
};
|
|
141
|
-
const r =
|
|
142
|
-
|
|
143
|
-
const f =
|
|
142
|
+
const r = n.renderer.rules.heading_open ?? ((t, o, s, c, l) => l.renderToken(t, o, s)), i = n.renderer.rules.heading_close ?? ((t, o, s, c, l) => l.renderToken(t, o, s));
|
|
143
|
+
n.renderer.rules.heading_open = (t, o, s, c, l) => {
|
|
144
|
+
const f = t[o], d = Number(f?.tag.slice(1)) || 1, a = c.foldingHeadings ??= [];
|
|
144
145
|
let u = "";
|
|
145
146
|
for (; (a.at(-1) ?? 0) >= d; )
|
|
146
147
|
a.pop(), u += "</details>";
|
|
147
|
-
return f?.attrGet("data-folding") === "true" && (a.push(d), u += "<details data-folding-section open><summary>"), u + r(
|
|
148
|
-
},
|
|
149
|
-
const f =
|
|
150
|
-
return i(
|
|
148
|
+
return f?.attrGet("data-folding") === "true" && (a.push(d), u += "<details data-folding-section open><summary>"), u + r(t, o, s, c, l);
|
|
149
|
+
}, n.renderer.rules.heading_close = (t, o, s, c, l) => {
|
|
150
|
+
const f = t[o - 2];
|
|
151
|
+
return i(t, o, s, c, l) + (f?.attrGet("data-folding") === "true" ? "</summary>" : "");
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
|
-
function v(
|
|
154
|
+
function v(n, e) {
|
|
154
155
|
try {
|
|
155
|
-
return W.renderToString(
|
|
156
|
+
return W.renderToString(n, { displayMode: e, throwOnError: !0 });
|
|
156
157
|
} catch {
|
|
157
158
|
const r = e ? "pre" : "span";
|
|
158
|
-
return `<${r} data-math-error>${h(
|
|
159
|
+
return `<${r} data-math-error>${h(n)}</${r}>`;
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
function
|
|
162
|
-
if (/^<\/?u>$/.test(
|
|
163
|
-
const e =
|
|
164
|
-
return e !== void 0 && /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\([^;<>]+\)|[a-z]+)$/i.test(e) ? `<span style="color: ${h(e)}">` : h(
|
|
162
|
+
function Q(n) {
|
|
163
|
+
if (/^<\/?u>$/.test(n) || n === "</span>") return n;
|
|
164
|
+
const e = n.match(/^<span style="color:\s*([^";<>]+)">$/i)?.[1]?.trim();
|
|
165
|
+
return e !== void 0 && /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\([^;<>]+\)|[a-z]+)$/i.test(e) ? `<span style="color: ${h(e)}">` : h(n);
|
|
165
166
|
}
|
|
166
|
-
function y(
|
|
167
|
+
function y(n, e) {
|
|
167
168
|
let r = 0;
|
|
168
|
-
for (let i = e - 1; i >= 0 &&
|
|
169
|
+
for (let i = e - 1; i >= 0 && n[i] === "\\"; i -= 1) r += 1;
|
|
169
170
|
return r % 2 === 1;
|
|
170
171
|
}
|
|
171
|
-
function
|
|
172
|
-
const
|
|
173
|
-
return
|
|
172
|
+
function U() {
|
|
173
|
+
const n = new x("commonmark", { html: !0 }).enable("table").enable("strikethrough").use(B).use(D).use(E).use(O);
|
|
174
|
+
return L(n), F(n), P(n), K(n), N(n), n;
|
|
174
175
|
}
|
|
175
|
-
const
|
|
176
|
-
function
|
|
177
|
-
const e = {}, r =
|
|
176
|
+
const V = U();
|
|
177
|
+
function X(n) {
|
|
178
|
+
const e = {}, r = V.render(n, e), i = e.foldingHeadings?.length ?? 0;
|
|
178
179
|
return r + "</details>".repeat(i);
|
|
179
180
|
}
|
|
180
|
-
let
|
|
181
|
-
function Y() {
|
|
182
|
-
return $ ??= import("./mermaid.core-CR0bA2Wa.js").then((t) => t.bq).then(({ default: t }) => (t.initialize({ securityLevel: "strict", startOnLoad: !1 }), t)), $;
|
|
183
|
-
}
|
|
181
|
+
let Y = 0, $;
|
|
184
182
|
function Z() {
|
|
185
|
-
return
|
|
183
|
+
return $ ??= import("./mermaid.core-CR0bA2Wa.js").then((n) => n.bq).then(({ default: n }) => (n.initialize({ securityLevel: "strict", startOnLoad: !1 }), n)), $;
|
|
184
|
+
}
|
|
185
|
+
function ee() {
|
|
186
|
+
return `markdown-renderer-mermaid-${++Y}`;
|
|
186
187
|
}
|
|
187
|
-
const
|
|
188
|
+
const te = ["innerHTML"], ne = /* @__PURE__ */ M({
|
|
188
189
|
name: "MarkdownRenderer",
|
|
189
190
|
__name: "MarkdownRenderer",
|
|
190
191
|
props: {
|
|
191
192
|
content: {},
|
|
192
193
|
directiveComponents: {}
|
|
193
194
|
},
|
|
194
|
-
setup(
|
|
195
|
-
const e =
|
|
196
|
-
let o = 0,
|
|
197
|
-
function
|
|
195
|
+
setup(n) {
|
|
196
|
+
const e = n, r = S(), i = w()?.appContext, t = I(() => X(e.content));
|
|
197
|
+
let o = 0, s = !1, c = [];
|
|
198
|
+
function l() {
|
|
198
199
|
for (const a of c) b(null, a);
|
|
199
200
|
c = [];
|
|
200
201
|
}
|
|
201
202
|
function f() {
|
|
202
|
-
if (
|
|
203
|
+
if (l(), e.directiveComponents !== void 0)
|
|
203
204
|
for (const a of r.value?.querySelectorAll("[data-directive]") ?? []) {
|
|
204
205
|
const u = a.dataset.directive ?? "", m = e.directiveComponents[u];
|
|
205
206
|
if (m === void 0) continue;
|
|
206
|
-
const
|
|
207
|
+
const _ = {
|
|
207
208
|
content: a.textContent ?? "",
|
|
208
209
|
name: u,
|
|
209
210
|
readonly: !0,
|
|
210
211
|
updateContent: () => {
|
|
211
212
|
}
|
|
212
|
-
}, g = R(m,
|
|
213
|
+
}, g = R(m, _);
|
|
213
214
|
g.appContext = i ?? null, b(g, a), c.push(a);
|
|
214
215
|
}
|
|
215
216
|
}
|
|
@@ -218,18 +219,18 @@ const ee = ["innerHTML"], ie = /* @__PURE__ */ M({
|
|
|
218
219
|
if (u.length === 0) return;
|
|
219
220
|
let m;
|
|
220
221
|
try {
|
|
221
|
-
m = await
|
|
222
|
+
m = await Z();
|
|
222
223
|
} catch {
|
|
223
224
|
for (const p of u)
|
|
224
225
|
p.removeAttribute("aria-busy"), p.setAttribute("data-mermaid-error", "");
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
227
228
|
for (const p of u) {
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
229
|
+
if (s || a !== o || !p.isConnected) return;
|
|
230
|
+
const _ = p.querySelector("pre")?.textContent ?? "";
|
|
230
231
|
try {
|
|
231
|
-
const { bindFunctions: g, svg: C } = await m.render(
|
|
232
|
-
if (
|
|
232
|
+
const { bindFunctions: g, svg: C } = await m.render(ee(), _);
|
|
233
|
+
if (s || a !== o || !p.isConnected) return;
|
|
233
234
|
p.innerHTML = C, p.removeAttribute("aria-busy"), g?.(p);
|
|
234
235
|
} catch {
|
|
235
236
|
p.removeAttribute("aria-busy"), p.setAttribute("data-mermaid-error", "");
|
|
@@ -244,15 +245,15 @@ const ee = ["innerHTML"], ie = /* @__PURE__ */ M({
|
|
|
244
245
|
), H(() => {
|
|
245
246
|
f(), d();
|
|
246
247
|
}), A(() => {
|
|
247
|
-
|
|
248
|
+
s = !0, o += 1, l();
|
|
248
249
|
}), (a, u) => (j(), G("div", {
|
|
249
250
|
ref_key: "root",
|
|
250
251
|
ref: r,
|
|
251
252
|
class: "markdown-renderer",
|
|
252
|
-
innerHTML:
|
|
253
|
-
}, null, 8,
|
|
253
|
+
innerHTML: t.value
|
|
254
|
+
}, null, 8, te));
|
|
254
255
|
}
|
|
255
|
-
});
|
|
256
|
+
}), le = /* @__PURE__ */ z(ne, [["__scopeId", "data-v-91962f8a"]]);
|
|
256
257
|
export {
|
|
257
|
-
|
|
258
|
+
le as MarkdownRenderer
|
|
258
259
|
};
|