md-editor-v3 6.5.6 → 7.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.
- package/lib/cjs/MdEditor.cjs +1 -1
- package/lib/cjs/chunks/config.cjs +14 -1
- package/lib/cjs/chunks/index3.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +45 -45
- package/lib/cjs/chunks/index5.cjs +7 -2
- package/lib/es/MdEditor.mjs +5 -4
- package/lib/es/chunks/config.mjs +919 -69
- package/lib/es/chunks/event-bus.mjs +5 -5
- package/lib/es/chunks/index3.mjs +57 -56
- package/lib/es/chunks/index4.mjs +701 -635
- package/lib/es/chunks/index5.mjs +199 -32
- package/lib/preview.css +2 -2
- package/lib/style.css +4 -4
- package/lib/types/index.d.ts +80 -80
- package/package.json +3 -2
package/lib/es/chunks/index5.mjs
CHANGED
|
@@ -1,38 +1,205 @@
|
|
|
1
|
-
import { p } from "./config.mjs";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { p as d } from "./config.mjs";
|
|
2
|
+
const w = /^<\s*(\/?)\s*([a-zA-Z][a-zA-Z0-9:_-]*)(?:\s[\s\S]*?)?\s*(\/?)>$/, A = /* @__PURE__ */ new Set([
|
|
3
|
+
"area",
|
|
4
|
+
"base",
|
|
5
|
+
"br",
|
|
6
|
+
"col",
|
|
7
|
+
"embed",
|
|
8
|
+
"hr",
|
|
9
|
+
"img",
|
|
10
|
+
"input",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
]), R = (e) => e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'"), S = (e) => {
|
|
18
|
+
const n = e.replace(/\r\n?/g, `
|
|
19
|
+
`), t = n.endsWith(`
|
|
20
|
+
`) ? n.slice(0, -1) : n;
|
|
21
|
+
return t ? t.split(`
|
|
22
|
+
`) : [""];
|
|
23
|
+
}, p = (e, n) => {
|
|
24
|
+
if (e.startsWith("<!--", n)) {
|
|
25
|
+
const s = e.indexOf("-->", n + 4);
|
|
26
|
+
return s === -1 ? -1 : s + 2;
|
|
27
|
+
}
|
|
28
|
+
if (e.startsWith("<![CDATA[", n)) {
|
|
29
|
+
const s = e.indexOf("]]>", n + 9);
|
|
30
|
+
return s === -1 ? -1 : s + 2;
|
|
31
|
+
}
|
|
32
|
+
let t = "";
|
|
33
|
+
for (let s = n + 1; s < e.length; s += 1) {
|
|
34
|
+
const r = e[s];
|
|
35
|
+
if (t) {
|
|
36
|
+
r === t && (t = "");
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (r === '"' || r === "'")
|
|
40
|
+
t = r;
|
|
41
|
+
else if (r === ">")
|
|
42
|
+
return s;
|
|
43
|
+
}
|
|
44
|
+
return -1;
|
|
45
|
+
}, x = (e) => {
|
|
46
|
+
const n = w.exec(e);
|
|
47
|
+
if (!n)
|
|
48
|
+
return null;
|
|
49
|
+
const t = n[2].toLowerCase();
|
|
50
|
+
return {
|
|
51
|
+
isClosing: n[1] === "/",
|
|
52
|
+
isSelfClosing: n[3] === "/" || A.has(t),
|
|
53
|
+
name: t,
|
|
54
|
+
source: e
|
|
55
|
+
};
|
|
56
|
+
}, f = (e, n) => {
|
|
57
|
+
const t = e.indexOf("<", n);
|
|
58
|
+
if (t === -1)
|
|
59
|
+
return null;
|
|
60
|
+
const s = p(e, t);
|
|
61
|
+
return s === -1 ? null : {
|
|
62
|
+
endIndex: s,
|
|
63
|
+
parsedTag: x(e.slice(t, s + 1)),
|
|
64
|
+
startIndex: t
|
|
65
|
+
};
|
|
66
|
+
}, L = (e) => e.map((n) => n.openingTag).join(""), H = (e) => [...e].reverse().map((n) => `</${n.name}>`).join(""), E = (e) => {
|
|
67
|
+
let n = 0;
|
|
68
|
+
for (; n < e.length; ) {
|
|
69
|
+
const t = f(e, n), s = t?.startIndex ?? e.length;
|
|
70
|
+
if (e.slice(n, s).trim())
|
|
71
|
+
return !0;
|
|
72
|
+
if (!t)
|
|
73
|
+
return !1;
|
|
74
|
+
n = t.endIndex + 1;
|
|
75
|
+
}
|
|
76
|
+
return !1;
|
|
77
|
+
}, M = (e) => {
|
|
78
|
+
const n = f(e, 0);
|
|
79
|
+
if (!n || n.startIndex !== 0 || n.parsedTag?.name !== "pre" || n.parsedTag.isClosing || n.parsedTag.isSelfClosing)
|
|
80
|
+
return null;
|
|
81
|
+
let t = 0, s = -1, r = n.endIndex + 1;
|
|
82
|
+
for (; r < e.length; ) {
|
|
83
|
+
const i = f(e, r);
|
|
84
|
+
if (!i)
|
|
85
|
+
break;
|
|
86
|
+
const o = i.parsedTag;
|
|
87
|
+
if (!o) {
|
|
88
|
+
r = i.endIndex + 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (o.name === "pre" && o.isClosing && t === 0)
|
|
92
|
+
break;
|
|
93
|
+
if (o.name === "code")
|
|
94
|
+
if (o.isClosing) {
|
|
95
|
+
if (t > 0 && (t -= 1, t === 0))
|
|
96
|
+
return {
|
|
97
|
+
endIndex: i.startIndex,
|
|
98
|
+
startIndex: s
|
|
99
|
+
};
|
|
100
|
+
} else o.isSelfClosing || (t === 0 && (s = i.endIndex + 1), t += 1);
|
|
101
|
+
r = i.endIndex + 1;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}, k = (e) => {
|
|
105
|
+
const n = e.replace(/\r\n?/g, `
|
|
106
|
+
`), t = [""], s = [];
|
|
107
|
+
let r = 0, i = 0;
|
|
108
|
+
for (; i < n.length; ) {
|
|
109
|
+
const o = n[i];
|
|
110
|
+
if (o === "<") {
|
|
111
|
+
const l = p(n, i);
|
|
112
|
+
if (l === -1) {
|
|
113
|
+
t[r] += n.slice(i);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
const g = n.slice(i, l + 1), c = x(g);
|
|
117
|
+
if (t[r] += g, c)
|
|
118
|
+
if (c.isClosing) {
|
|
119
|
+
for (let a = s.length - 1; a >= 0; a -= 1)
|
|
120
|
+
if (s[a].name === c.name) {
|
|
121
|
+
s.splice(a, 1);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
} else c.isSelfClosing || s.push({
|
|
125
|
+
name: c.name,
|
|
126
|
+
openingTag: c.source
|
|
127
|
+
});
|
|
128
|
+
i = l + 1;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (o === `
|
|
132
|
+
`) {
|
|
133
|
+
t[r] += H(s), t.push(L(s)), r += 1, i += 1;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
t[r] += o, i += 1;
|
|
137
|
+
}
|
|
138
|
+
return t;
|
|
139
|
+
}, G = (e, n = "image.png") => {
|
|
140
|
+
const t = e.split(","), s = t[0].match(/:(.*?);/);
|
|
141
|
+
if (s) {
|
|
142
|
+
const r = s[1], i = atob(t[1]);
|
|
143
|
+
let o = i.length;
|
|
144
|
+
const l = new Uint8Array(o);
|
|
145
|
+
for (; o--; )
|
|
146
|
+
l[o] = i.charCodeAt(o);
|
|
147
|
+
return new File([l], n, { type: r });
|
|
11
148
|
}
|
|
12
149
|
return null;
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
150
|
+
}, y = (e, n, t = {}) => {
|
|
151
|
+
const { lineHighlightRanges: s = [], showLineNumber: r = !1 } = t, i = S(n), o = k(e);
|
|
152
|
+
for (; o.length > i.length && !E(o[o.length - 1]); )
|
|
153
|
+
o.pop();
|
|
154
|
+
const l = o.length === i.length, g = i.map((a, h) => {
|
|
155
|
+
const m = l ? o[h] : R(a), u = h + 1, I = s.some(
|
|
156
|
+
({ start: b, end: $ }) => u >= b && u <= $
|
|
157
|
+
), C = [
|
|
158
|
+
`${d}-code-line`,
|
|
159
|
+
r ? `${d}-code-line-numbered` : "",
|
|
160
|
+
I ? `${d}-code-line-highlight` : ""
|
|
161
|
+
].filter(Boolean).join(" "), T = r ? `<span rn-wrapper aria-hidden="true" data-line-number="${u}"></span>` : "";
|
|
162
|
+
return [
|
|
163
|
+
`<span class="${C}">`,
|
|
164
|
+
T,
|
|
165
|
+
`<span class="${d}-code-line-content">${m}</span>`,
|
|
166
|
+
"</span>"
|
|
167
|
+
].join("");
|
|
168
|
+
}), c = r ? ` style="--md-code-line-number-width: ${Math.max(2, String(i.length).length) + 0.5}ch;"` : "";
|
|
169
|
+
return `<span class="${d}-code-block-lines"${c}>${g.join(`
|
|
170
|
+
`)}</span>`;
|
|
171
|
+
}, B = (e, n, t = {}) => {
|
|
172
|
+
const s = M(e);
|
|
173
|
+
if (!s)
|
|
174
|
+
return null;
|
|
175
|
+
const r = y(
|
|
176
|
+
e.slice(s.startIndex, s.endIndex),
|
|
177
|
+
n,
|
|
178
|
+
t
|
|
179
|
+
);
|
|
180
|
+
return `${e.slice(0, s.startIndex)}${r}${e.slice(s.endIndex)}`;
|
|
181
|
+
}, N = (e, n, t = {}) => {
|
|
182
|
+
const { lineHighlightRanges: s = [], showLineNumber: r = !1 } = t;
|
|
183
|
+
return !r && !s.length ? { html: e, shouldReturnDirectly: !0 } : e.startsWith("<pre") ? {
|
|
184
|
+
html: B(e, n, t) ?? e,
|
|
185
|
+
shouldReturnDirectly: !0
|
|
186
|
+
} : { html: e, shouldReturnDirectly: !1 };
|
|
187
|
+
}, j = (e, n) => {
|
|
188
|
+
if (!e || !n)
|
|
23
189
|
return 0;
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
},
|
|
30
|
-
let
|
|
31
|
-
return () => ++
|
|
190
|
+
const t = e?.getBoundingClientRect();
|
|
191
|
+
if (n === document.documentElement)
|
|
192
|
+
return t.top - n.clientTop;
|
|
193
|
+
const s = n?.getBoundingClientRect();
|
|
194
|
+
return t.top - s.top;
|
|
195
|
+
}, W = /* @__PURE__ */ (() => {
|
|
196
|
+
let e = 0;
|
|
197
|
+
return () => ++e;
|
|
32
198
|
})();
|
|
33
199
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
g
|
|
200
|
+
y as a,
|
|
201
|
+
G as b,
|
|
202
|
+
W as c,
|
|
203
|
+
j as g,
|
|
204
|
+
N as p
|
|
38
205
|
};
|
package/lib/preview.css
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
color: #73d13d;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.md-editor-catalog-dark {
|
|
52
|
+
.md-editor-catalog[data-theme=dark] {
|
|
53
53
|
--md-color: #999;
|
|
54
54
|
--md-hover-color: #bbb;
|
|
55
55
|
--md-bk-color: #000;
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
overflow: visible;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
.md-editor-dark,
|
|
180
|
+
.md-editor[data-theme=dark],
|
|
181
181
|
.md-editor-modal-container[data-theme=dark] {
|
|
182
182
|
--md-color: #999;
|
|
183
183
|
--md-hover-color: #bbb;
|
package/lib/style.css
CHANGED
|
@@ -517,10 +517,10 @@
|
|
|
517
517
|
padding-inline: 6px;
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
.md-editor-dark .md-editor-table-shape-col-default {
|
|
520
|
+
.md-editor[data-theme=dark] .md-editor-table-shape-col-default {
|
|
521
521
|
background-color: #222;
|
|
522
522
|
}
|
|
523
|
-
.md-editor-dark .md-editor-table-shape-col-include {
|
|
523
|
+
.md-editor[data-theme=dark] .md-editor-table-shape-col-include {
|
|
524
524
|
background-color: #555;
|
|
525
525
|
}
|
|
526
526
|
|
|
@@ -730,7 +730,7 @@
|
|
|
730
730
|
color: #73d13d;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
.md-editor-catalog-dark {
|
|
733
|
+
.md-editor-catalog[data-theme=dark] {
|
|
734
734
|
--md-color: #999;
|
|
735
735
|
--md-hover-color: #bbb;
|
|
736
736
|
--md-bk-color: #000;
|
|
@@ -858,7 +858,7 @@
|
|
|
858
858
|
overflow: visible;
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
-
.md-editor-dark,
|
|
861
|
+
.md-editor[data-theme=dark],
|
|
862
862
|
.md-editor-modal-container[data-theme=dark] {
|
|
863
863
|
--md-color: #999;
|
|
864
864
|
--md-hover-color: #bbb;
|