markdown-flow-ui 0.2.31 → 0.2.32
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 +3 -3
- package/dist/_virtual/index.es3.js +5 -4
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +4 -5
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index.es9.js +2 -2
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/index9.cjs +1 -1
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +1 -1
- package/dist/components/ContentRender/ContentRender.es.js +183 -172
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/utils/video-markdown-run.cjs +13 -13
- package/dist/components/ContentRender/utils/video-markdown-run.cjs.map +1 -1
- package/dist/components/ContentRender/utils/video-markdown-run.es.js +223 -217
- package/dist/components/ContentRender/utils/video-markdown-run.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
- package/package.json +1 -1
|
@@ -2,183 +2,183 @@ import { decodeString as j } from "../../../node_modules/micromark-util-decode-s
|
|
|
2
2
|
import { getMarkdownSourceAnalysis as U } from "./inline-code-ranges.es.js";
|
|
3
3
|
import { normalizeInlineHtml as K } from "./normalize-inline-html.es.js";
|
|
4
4
|
import { readHtmlMarkup as L, findStreamingHtmlElementEnd as q, isHtmlRawTextTag as D } from "./html-block-end.es.js";
|
|
5
|
-
const F = "contentRenderVisibility",
|
|
6
|
-
let
|
|
7
|
-
for (;
|
|
8
|
-
const
|
|
9
|
-
e[
|
|
5
|
+
const F = "contentRenderVisibility", b = (e, a) => {
|
|
6
|
+
let o = 0, n = e.length;
|
|
7
|
+
for (; o < n; ) {
|
|
8
|
+
const d = o + n >>> 1;
|
|
9
|
+
e[d] < a ? o = d + 1 : n = d;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const a = e.position?.start?.offset,
|
|
14
|
-
return a === void 0 ||
|
|
11
|
+
return o;
|
|
12
|
+
}, N = (e, a) => Math.max(0, b(e.offsets, a + 1) - 1), R = (e) => {
|
|
13
|
+
const a = e.position?.start?.offset, o = e.position?.end?.offset;
|
|
14
|
+
return a === void 0 || o === void 0 ? void 0 : { start: a, end: o };
|
|
15
15
|
}, nt = (e) => e.data?.[F], G = (e, a) => {
|
|
16
|
-
let
|
|
17
|
-
for (;
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
for (; a[n]?.end <=
|
|
21
|
-
if (a[n]?.start <=
|
|
22
|
-
|
|
16
|
+
let o = 0, n = 0;
|
|
17
|
+
for (; o < e.length; ) {
|
|
18
|
+
const d = e.indexOf("<", o);
|
|
19
|
+
if (d === -1) break;
|
|
20
|
+
for (; a[n]?.end <= d; ) n += 1;
|
|
21
|
+
if (a[n]?.start <= d) {
|
|
22
|
+
o = a[n].end;
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
let
|
|
26
|
-
for (let
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
25
|
+
let p = 0;
|
|
26
|
+
for (let u = d - 1; u >= 0 && e[u] === "\\"; u -= 1)
|
|
27
|
+
p += 1;
|
|
28
|
+
if (p % 2) {
|
|
29
|
+
o = d + 1;
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
return /^<svg(?=[\s/>]|$)/i.test(e.slice(
|
|
35
|
-
|
|
32
|
+
const i = L(e, d);
|
|
33
|
+
if (i.kind === "incomplete")
|
|
34
|
+
return /^<svg(?=[\s/>]|$)/i.test(e.slice(d)) ? { start: d, end: e.length } : void 0;
|
|
35
|
+
o = i.kind === "tag" && !i.closing && !i.selfClosing && D(i.name) ? q(e, d) : i.kind === "invalid" ? d + 1 : i.end;
|
|
36
36
|
}
|
|
37
37
|
}, J = (e, a) => {
|
|
38
38
|
if (e === a) return;
|
|
39
|
-
const
|
|
39
|
+
const o = [];
|
|
40
40
|
let n = 0;
|
|
41
|
-
for (let
|
|
42
|
-
if (n = e.indexOf(a[
|
|
41
|
+
for (let d = 0; d < a.length; d += 1) {
|
|
42
|
+
if (n = e.indexOf(a[d], n), n === -1)
|
|
43
43
|
throw new Error("HTML normalization changed source characters");
|
|
44
|
-
|
|
44
|
+
o.push(++n);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
47
|
-
}, z = (e, a,
|
|
46
|
+
return o;
|
|
47
|
+
}, z = (e, a, o = !1) => e.rawEnds ? o ? a === 0 ? 0 : e.rawEnds[a - 1] : a === e.markdownSource.length ? e.fullSource.length : e.rawEnds[a] - 1 : a, W = (e, a) => a && {
|
|
48
48
|
start: z(e, a.start),
|
|
49
49
|
end: z(e, a.end, !0)
|
|
50
50
|
}, Q = (e, a) => {
|
|
51
51
|
if (!e.rawEnds) return;
|
|
52
|
-
const
|
|
53
|
-
let
|
|
54
|
-
for (;
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
return { line:
|
|
60
|
-
},
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
start: l
|
|
64
|
-
end: l
|
|
65
|
-
}), "children" in
|
|
52
|
+
const o = [0], n = /\r\n|\r|\n/g;
|
|
53
|
+
let d;
|
|
54
|
+
for (; d = n.exec(e.fullSource); )
|
|
55
|
+
o.push(d.index + d[0].length);
|
|
56
|
+
const p = (u, l) => {
|
|
57
|
+
if (u?.offset === void 0) return u;
|
|
58
|
+
const c = z(e, u.offset, l), f = b(o, c + 1);
|
|
59
|
+
return { line: f, column: c - o[f - 1] + 1, offset: c };
|
|
60
|
+
}, i = (u) => {
|
|
61
|
+
const l = u === a ? e.sourceTree.position : u.position;
|
|
62
|
+
l && (u.position = {
|
|
63
|
+
start: p(l.start, !1),
|
|
64
|
+
end: p(l.end, !0)
|
|
65
|
+
}), "children" in u && u.children.forEach(i);
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
i(a);
|
|
68
68
|
}, rt = (e, a) => {
|
|
69
|
-
const
|
|
69
|
+
const o = [];
|
|
70
70
|
let n = "";
|
|
71
|
-
for (const
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
(
|
|
71
|
+
for (const c of e)
|
|
72
|
+
o.push(n.length), n += c.value;
|
|
73
|
+
const d = a ?? U(n), p = K(n, d.markdown), i = J(n, p), u = i ? U(p) : d, l = e.flatMap(
|
|
74
|
+
(c, f) => c.type === "markdown" && c.immediate ? [
|
|
75
75
|
{
|
|
76
|
-
start:
|
|
77
|
-
end:
|
|
76
|
+
start: i ? b(i, o[f] + 1) : o[f],
|
|
77
|
+
end: i ? b(i, o[f] + c.value.length) + 1 : o[f] + c.value.length
|
|
78
78
|
}
|
|
79
79
|
] : []
|
|
80
80
|
);
|
|
81
81
|
return {
|
|
82
82
|
fullSource: n,
|
|
83
|
-
markdownSource:
|
|
84
|
-
rawEnds:
|
|
83
|
+
markdownSource: p,
|
|
84
|
+
rawEnds: i,
|
|
85
85
|
segments: e,
|
|
86
|
-
offsets:
|
|
86
|
+
offsets: o,
|
|
87
87
|
immediateOffsets: e.flatMap(
|
|
88
|
-
(
|
|
88
|
+
(c, f) => c.type === "markdown" && c.immediate && !c.pending ? [o[f]] : []
|
|
89
89
|
),
|
|
90
|
-
sourceTree:
|
|
91
|
-
pendingMetadata:
|
|
92
|
-
(
|
|
90
|
+
sourceTree: u.tree,
|
|
91
|
+
pendingMetadata: u.metadata.filter(
|
|
92
|
+
(c) => c.pending && c.end === p.length
|
|
93
93
|
),
|
|
94
94
|
incompleteSvg: G(
|
|
95
|
-
|
|
96
|
-
[...
|
|
97
|
-
(
|
|
95
|
+
p,
|
|
96
|
+
[...u.literal, ...l].sort(
|
|
97
|
+
(c, f) => c.start - f.start
|
|
98
98
|
)
|
|
99
99
|
),
|
|
100
100
|
visibility: /* @__PURE__ */ new WeakMap()
|
|
101
101
|
};
|
|
102
|
-
}, B = (e, a,
|
|
103
|
-
const n = [],
|
|
104
|
-
let
|
|
105
|
-
for (;
|
|
106
|
-
const
|
|
102
|
+
}, B = (e, a, o = "markdown") => {
|
|
103
|
+
const n = [], d = /\\[!-/:-@[-`{-~]|&(?:#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});|\r\n|\r|[\s\S]/gi, p = e.slice(a.start, a.end);
|
|
104
|
+
let i;
|
|
105
|
+
for (; i = d.exec(p); ) {
|
|
106
|
+
const u = i[0], c = (o === "code" || o === "html" && u.startsWith("\\") ? u : j(u)).replace(
|
|
107
107
|
/\r\n|\r/g,
|
|
108
108
|
`
|
|
109
109
|
`
|
|
110
110
|
);
|
|
111
|
-
for (let
|
|
111
|
+
for (let f = 0; f < c.length; f += 1)
|
|
112
112
|
n.push({
|
|
113
|
-
character:
|
|
114
|
-
end: a.start +
|
|
113
|
+
character: c[f],
|
|
114
|
+
end: a.start + i.index + (c === u ? f + 1 : u.length)
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
return n;
|
|
118
118
|
}, X = (e, a) => {
|
|
119
|
-
const
|
|
119
|
+
const o = /^`+/.exec(e.slice(a.start, a.end))?.[0] ?? "", n = B(
|
|
120
120
|
e,
|
|
121
|
-
{ start: a.start +
|
|
121
|
+
{ start: a.start + o.length, end: a.end - o.length },
|
|
122
122
|
"code"
|
|
123
|
-
).map((
|
|
124
|
-
...
|
|
125
|
-
character:
|
|
126
|
-
` ? " " :
|
|
123
|
+
).map((d) => ({
|
|
124
|
+
...d,
|
|
125
|
+
character: d.character === `
|
|
126
|
+
` ? " " : d.character
|
|
127
127
|
}));
|
|
128
128
|
return n.length > a.value.length && n[0]?.character === " " && n.at(-1)?.character === " " ? n.slice(1, -1) : n;
|
|
129
129
|
}, Y = (e, a) => {
|
|
130
|
-
const
|
|
131
|
-
let
|
|
130
|
+
const o = e.slice(a.start, a.end), n = /^(?:`{3,}|~{3,})/.test(o);
|
|
131
|
+
let d = a.start + (n ? o.indexOf(`
|
|
132
132
|
`) + 1 : 0);
|
|
133
|
-
const
|
|
134
|
-
for (const
|
|
133
|
+
const p = [];
|
|
134
|
+
for (const i of a.value.split(`
|
|
135
135
|
`)) {
|
|
136
|
-
const
|
|
137
|
-
`,
|
|
138
|
-
for (let M = 0; M <
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
`, end: Math.min(a.end,
|
|
136
|
+
const u = e.indexOf(`
|
|
137
|
+
`, d), l = u === -1 ? a.end : Math.min(u, a.end), c = e[l - 1] === "\r" ? l - 1 : l, f = Math.max(d, c - i.length);
|
|
138
|
+
for (let M = 0; M < i.length; M += 1)
|
|
139
|
+
p.push({ character: i[M], end: f + M + 1 });
|
|
140
|
+
p.push({ character: `
|
|
141
|
+
`, end: Math.min(a.end, l + 1) }), d = l + 1;
|
|
142
142
|
}
|
|
143
|
-
return
|
|
143
|
+
return p;
|
|
144
144
|
}, st = (e) => {
|
|
145
145
|
const a = structuredClone(e.sourceTree);
|
|
146
146
|
if (e.pendingMetadata.length) {
|
|
147
|
-
const
|
|
147
|
+
const l = [0];
|
|
148
148
|
for (let h = 0; h < e.markdownSource.length; h += 1)
|
|
149
149
|
e.markdownSource[h] === `
|
|
150
|
-
` &&
|
|
151
|
-
const
|
|
152
|
-
const k =
|
|
153
|
-
return { line: k, column: h -
|
|
154
|
-
},
|
|
150
|
+
` && l.push(h + 1);
|
|
151
|
+
const c = (h) => {
|
|
152
|
+
const k = b(l, h + 1);
|
|
153
|
+
return { line: k, column: h - l[k - 1] + 1, offset: h };
|
|
154
|
+
}, f = e.pendingMetadata.map(({ start: h }) => h), M = (h) => {
|
|
155
155
|
h.children = h.children?.flatMap((k) => {
|
|
156
156
|
k.children && M(k);
|
|
157
157
|
const y = R(k);
|
|
158
158
|
if (k.type !== "html" || !k.value || !y) return [k];
|
|
159
159
|
let S = Math.max(
|
|
160
160
|
0,
|
|
161
|
-
|
|
161
|
+
b(f, y.start + 1) - 1
|
|
162
162
|
);
|
|
163
163
|
for (; e.pendingMetadata[S]?.end <= y.start; ) S += 1;
|
|
164
|
-
if (!e.pendingMetadata[S] ||
|
|
164
|
+
if (!e.pendingMetadata[S] || f[S] >= y.end)
|
|
165
165
|
return [k];
|
|
166
|
-
const
|
|
166
|
+
const I = k.value, $ = e.markdownSource.slice(y.start, y.end);
|
|
167
167
|
let C;
|
|
168
|
-
if ($ !==
|
|
168
|
+
if ($ !== I) {
|
|
169
169
|
let r = 0;
|
|
170
|
-
C =
|
|
170
|
+
C = I.split("").map((s) => (r = $.indexOf(s, r), y.start + ++r));
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const V = (r) => C ? b(C, r + 1) : r - y.start, T = [];
|
|
173
173
|
let O = y.start;
|
|
174
174
|
const t = (r, s) => {
|
|
175
175
|
if (r <= O) return;
|
|
176
|
-
const w =
|
|
176
|
+
const w = I.slice(V(O), V(r));
|
|
177
177
|
T.push({
|
|
178
178
|
...k,
|
|
179
179
|
type: s ? "text" : "html",
|
|
180
180
|
value: s ? j(w) : w,
|
|
181
|
-
position: { start:
|
|
181
|
+
position: { start: c(O), end: c(r) }
|
|
182
182
|
}), O = r;
|
|
183
183
|
};
|
|
184
184
|
for (; e.pendingMetadata[S]?.start < y.end; ) {
|
|
@@ -190,100 +190,100 @@ const F = "contentRenderVisibility", E = (e, a) => {
|
|
|
190
190
|
};
|
|
191
191
|
M(a);
|
|
192
192
|
}
|
|
193
|
-
const
|
|
194
|
-
if (!
|
|
195
|
-
const n = e.markdownSource.slice(0,
|
|
193
|
+
const o = e.incompleteSvg;
|
|
194
|
+
if (!o) return a;
|
|
195
|
+
const n = e.markdownSource.slice(0, o.start), d = {
|
|
196
196
|
line: n.split(`
|
|
197
197
|
`).length,
|
|
198
|
-
column:
|
|
198
|
+
column: o.start - n.lastIndexOf(`
|
|
199
199
|
`),
|
|
200
|
-
offset:
|
|
201
|
-
},
|
|
200
|
+
offset: o.start
|
|
201
|
+
}, p = {
|
|
202
202
|
type: "element",
|
|
203
203
|
data: { hName: "svg" },
|
|
204
204
|
children: [],
|
|
205
|
-
position: { start:
|
|
205
|
+
position: { start: d, end: a.position.end }
|
|
206
206
|
};
|
|
207
|
-
let
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
if (
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
215
|
-
const M = B(e.markdownSource,
|
|
207
|
+
let i = !1;
|
|
208
|
+
const u = (l) => {
|
|
209
|
+
l.children = l.children?.flatMap((c) => {
|
|
210
|
+
const f = R(c);
|
|
211
|
+
if (!f || f.end <= o.start) return [c];
|
|
212
|
+
if (f.start > o.start || i) return [];
|
|
213
|
+
if (c.children)
|
|
214
|
+
return u(c), [c];
|
|
215
|
+
const M = B(e.markdownSource, f);
|
|
216
216
|
let h = 0, k = 0;
|
|
217
|
-
for (const S of (
|
|
217
|
+
for (const S of (c.value ?? "").split("")) {
|
|
218
218
|
for (; M[h] && M[h].character !== S; )
|
|
219
219
|
h += 1;
|
|
220
|
-
if (!M[h] || M[h].end >
|
|
220
|
+
if (!M[h] || M[h].end > o.start) break;
|
|
221
221
|
h += 1, k += 1;
|
|
222
222
|
}
|
|
223
223
|
const y = k ? [
|
|
224
224
|
{
|
|
225
|
-
...
|
|
226
|
-
value:
|
|
227
|
-
position: { start:
|
|
225
|
+
...c,
|
|
226
|
+
value: c.value.slice(0, k),
|
|
227
|
+
position: { start: c.position.start, end: d }
|
|
228
228
|
}
|
|
229
229
|
] : [];
|
|
230
|
-
return
|
|
230
|
+
return i = !0, [...y, p];
|
|
231
231
|
});
|
|
232
232
|
};
|
|
233
|
-
return
|
|
234
|
-
}, at = (e, a,
|
|
233
|
+
return u(a), a;
|
|
234
|
+
}, at = (e, a, o = (n) => n) => {
|
|
235
235
|
const n = {
|
|
236
236
|
...e,
|
|
237
237
|
visibility: /* @__PURE__ */ new WeakMap()
|
|
238
238
|
};
|
|
239
239
|
Q(n, a);
|
|
240
|
-
const
|
|
241
|
-
const r =
|
|
242
|
-
if (r && t.type !== "root" && "children" in t &&
|
|
240
|
+
const d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), u = (t) => {
|
|
241
|
+
const r = W(n, R(t));
|
|
242
|
+
if (r && t.type !== "root" && "children" in t && i.add(`${r.start}:${r.end}`), r && t.type === "listItem" && typeof t.checked == "boolean") {
|
|
243
243
|
const s = R(t), w = n.markdownSource.indexOf("[", s.start), m = n.markdownSource.indexOf("]", w + 1) + 1;
|
|
244
244
|
if (w >= s.start && m > w && m <= s.end) {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const v = t.children[0],
|
|
248
|
-
v?.type === "paragraph" &&
|
|
249
|
-
`${
|
|
250
|
-
|
|
245
|
+
const E = W(n, { start: w, end: m });
|
|
246
|
+
p.set(`${r.start}:${r.end}`, E);
|
|
247
|
+
const v = t.children[0], g = v && W(n, R(v));
|
|
248
|
+
v?.type === "paragraph" && g && p.set(
|
|
249
|
+
`${g.start}:${g.end}`,
|
|
250
|
+
E
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
if (r && "value" in t && typeof t.value == "string" &&
|
|
254
|
+
if (r && "value" in t && typeof t.value == "string" && d.set(`${r.start}:${r.end}`, {
|
|
255
255
|
...r,
|
|
256
256
|
value: t.value,
|
|
257
257
|
type: t.type
|
|
258
258
|
}), "children" in t)
|
|
259
259
|
for (const s of t.children)
|
|
260
|
-
|
|
260
|
+
u(s);
|
|
261
261
|
};
|
|
262
|
-
|
|
263
|
-
const
|
|
262
|
+
u(n.sourceTree);
|
|
263
|
+
const l = (t) => {
|
|
264
264
|
const r = t.properties.className;
|
|
265
265
|
return Array.isArray(r) && r.some(
|
|
266
266
|
(s) => s === "language-math" || s === "math-inline" || s === "math-display"
|
|
267
267
|
);
|
|
268
|
-
},
|
|
268
|
+
}, c = (t, r) => {
|
|
269
269
|
t.children = t.children.map((s) => {
|
|
270
270
|
if (s.type !== "element") return s;
|
|
271
271
|
const w = R(s) ?? r;
|
|
272
|
-
if ((
|
|
273
|
-
const
|
|
272
|
+
if ((l(s) || s.tagName === "pre" && s.children.some((E) => E.type === "element" && l(E))) && w) {
|
|
273
|
+
const E = {
|
|
274
274
|
type: "element",
|
|
275
275
|
tagName: "span",
|
|
276
276
|
properties: {},
|
|
277
277
|
children: [s],
|
|
278
278
|
position: s.position
|
|
279
279
|
};
|
|
280
|
-
return n.visibility.set(
|
|
280
|
+
return n.visibility.set(E, { range: w, atomic: !0 }), E;
|
|
281
281
|
}
|
|
282
|
-
return
|
|
282
|
+
return c(s, w), s;
|
|
283
283
|
});
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
const
|
|
285
|
+
c(a), n.tree = o(a);
|
|
286
|
+
const f = /* @__PURE__ */ new WeakMap(), M = (t) => {
|
|
287
287
|
const r = R(t);
|
|
288
288
|
let s;
|
|
289
289
|
if ("children" in t)
|
|
@@ -294,26 +294,26 @@ const F = "contentRenderVisibility", E = (e, a) => {
|
|
|
294
294
|
end: Math.max(s.end, m.end)
|
|
295
295
|
} : m);
|
|
296
296
|
}
|
|
297
|
-
return !r && s &&
|
|
297
|
+
return !r && s && f.set(t, s), r ?? s;
|
|
298
298
|
};
|
|
299
299
|
M(n.tree);
|
|
300
300
|
const h = (t) => {
|
|
301
|
-
const r =
|
|
301
|
+
const r = b(n.immediateOffsets, t.start);
|
|
302
302
|
if (n.immediateOffsets[r] < t.end) return !0;
|
|
303
303
|
const s = n.immediateOffsets[r - 1];
|
|
304
304
|
if (s === void 0) return !1;
|
|
305
|
-
const w =
|
|
305
|
+
const w = N(n, s);
|
|
306
306
|
return t.start < s + n.segments[w].value.length;
|
|
307
307
|
}, k = (t) => t.units ??= t.source?.type === "code" ? Y(n.fullSource, t.source) : t.source?.type === "inlineCode" ? X(n.fullSource, t.source) : B(n.fullSource, t.range, t.mode), y = n.pendingMetadata.map(
|
|
308
|
-
(t) =>
|
|
309
|
-
), S = y.map(({ start: t }) => t),
|
|
310
|
-
const r = y[
|
|
308
|
+
(t) => W(n, t)
|
|
309
|
+
), S = y.map(({ start: t }) => t), I = (t) => {
|
|
310
|
+
const r = y[b(S, t.start + 1) - 1];
|
|
311
311
|
return !!(r && t.end <= r.end);
|
|
312
|
-
}, $ = [...
|
|
312
|
+
}, $ = [...d.values()].filter(
|
|
313
313
|
({ type: t }) => t === "html"
|
|
314
|
-
), C = [...
|
|
314
|
+
), C = [...d.values()].filter(
|
|
315
315
|
({ type: t }) => t === "flowInteraction"
|
|
316
|
-
),
|
|
316
|
+
), V = C.map(({ start: t }) => t), T = (t) => {
|
|
317
317
|
let r = 0, s = $.length;
|
|
318
318
|
for (; r < s; ) {
|
|
319
319
|
const m = r + s >>> 1;
|
|
@@ -327,32 +327,32 @@ const F = "contentRenderVisibility", E = (e, a) => {
|
|
|
327
327
|
const v = Math.max(
|
|
328
328
|
r.rawCursor,
|
|
329
329
|
r.units?.[r.index - 1]?.end ?? 0
|
|
330
|
-
),
|
|
331
|
-
|
|
330
|
+
), g = C[b(V, v)];
|
|
331
|
+
g && g.end <= r.range.end && (s = g);
|
|
332
332
|
}
|
|
333
|
-
if (!s && t.type === "element" && t.tagName === "input" && t.properties.type === "checkbox" && t.properties.disabled === !0 && r && (s =
|
|
333
|
+
if (!s && t.type === "element" && t.tagName === "input" && t.properties.type === "checkbox" && t.properties.disabled === !0 && r && (s = p.get(
|
|
334
334
|
`${r.range.start}:${r.range.end}`
|
|
335
335
|
)), !s && t.type === "element" && t.tagName === "br" && r) {
|
|
336
336
|
const v = k(r);
|
|
337
|
-
let
|
|
338
|
-
for (;
|
|
337
|
+
let g = r.index;
|
|
338
|
+
for (; g < v.length && (v[g].end <= r.rawCursor || v[g].character !== `
|
|
339
339
|
`); )
|
|
340
|
-
|
|
341
|
-
const x = v[
|
|
342
|
-
x !== void 0 && (r.index =
|
|
340
|
+
g += 1;
|
|
341
|
+
const x = v[g]?.end;
|
|
342
|
+
x !== void 0 && (r.index = g + 1, s = {
|
|
343
343
|
start: x - (n.fullSource.slice(x - 2, x) === `\r
|
|
344
344
|
` ? 2 : 1),
|
|
345
345
|
end: x
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
-
s ??=
|
|
349
|
-
const w = s &&
|
|
348
|
+
s ??= f.get(t);
|
|
349
|
+
const w = s && d.get(`${s.start}:${s.end}`);
|
|
350
350
|
let m = r;
|
|
351
|
-
const
|
|
351
|
+
const E = w?.type === "code" || w?.type === "inlineCode";
|
|
352
352
|
if (s && (!r || s.start !== r.range.start || s.end !== r.range.end) && (m = {
|
|
353
353
|
range: s,
|
|
354
354
|
source: w,
|
|
355
|
-
mode:
|
|
355
|
+
mode: E ? "code" : I(s) ? "markdown" : T(s) ? "html" : r?.mode ?? "markdown",
|
|
356
356
|
index: 0,
|
|
357
357
|
rawCursor: s.start
|
|
358
358
|
}), t.type === "text" && m) {
|
|
@@ -360,41 +360,41 @@ const F = "contentRenderVisibility", E = (e, a) => {
|
|
|
360
360
|
return;
|
|
361
361
|
const v = k(m);
|
|
362
362
|
for (; v[m.index]?.end <= m.rawCursor; ) m.index += 1;
|
|
363
|
-
const
|
|
363
|
+
const g = [], x = t.value.split("");
|
|
364
364
|
m.breakEnd !== void 0 && x[0] === `
|
|
365
|
-
` && !t.position?.start && (
|
|
366
|
-
for (const
|
|
367
|
-
for (; m.index < v.length && v[m.index].character !==
|
|
365
|
+
` && !t.position?.start && (g.push(m.breakEnd), x.shift()), m.breakEnd = void 0;
|
|
366
|
+
for (const A of x) {
|
|
367
|
+
for (; m.index < v.length && v[m.index].character !== A; )
|
|
368
368
|
m.index += 1;
|
|
369
|
-
|
|
369
|
+
g.push(v[m.index]?.end ?? m.range.end), m.index += 1;
|
|
370
370
|
}
|
|
371
|
-
n.visibility.set(t, { ends:
|
|
371
|
+
n.visibility.set(t, { ends: g });
|
|
372
372
|
} else if (t.type === "element") {
|
|
373
373
|
if (n.visibility.get(t)?.atomic) return;
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
`${
|
|
378
|
-
)), P =
|
|
374
|
+
const g = s ?? m?.range;
|
|
375
|
+
if (g) {
|
|
376
|
+
const A = !(t.tagName === "input" || t.tagName === "a" || t.tagName.startsWith("custom-") || t.tagName === "svg") && (t.children.length > 0 || !t.position && i.has(
|
|
377
|
+
`${g.start}:${g.end}`
|
|
378
|
+
)), P = N(n, g.start), H = n.segments[P];
|
|
379
379
|
n.visibility.set(t, {
|
|
380
|
-
range:
|
|
381
|
-
structural:
|
|
380
|
+
range: g,
|
|
381
|
+
structural: A,
|
|
382
382
|
svg: t.tagName === "svg",
|
|
383
383
|
immediate: (
|
|
384
384
|
// Ancestors of immediate HTML keep their stable host elements.
|
|
385
385
|
// Leaves inside a received HTML span share its budget.
|
|
386
|
-
(
|
|
386
|
+
(A || t.children.length > 0) && h(g) || H.type === "markdown" && H.immediate && !H.pending && g.end <= n.offsets[P] + H.value.length
|
|
387
387
|
)
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
390
|
t.tagName === "br" && s && r && !T(s) && (r.breakEnd = s.end);
|
|
391
391
|
}
|
|
392
392
|
if ("children" in t) {
|
|
393
|
-
for (const
|
|
393
|
+
for (const g of t.children) O(g, m);
|
|
394
394
|
const v = n.visibility.get(t);
|
|
395
395
|
if (v?.structural && v.range)
|
|
396
|
-
for (const
|
|
397
|
-
const x = n.visibility.get(
|
|
396
|
+
for (const g of t.children) {
|
|
397
|
+
const x = n.visibility.get(g)?.range;
|
|
398
398
|
x && x.start < v.range.start && (v.range = { ...v.range, start: x.start });
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -403,54 +403,60 @@ const F = "contentRenderVisibility", E = (e, a) => {
|
|
|
403
403
|
return O(n.tree), n;
|
|
404
404
|
}, it = (e, a) => {
|
|
405
405
|
if (!e.tree) throw new Error("Video Markdown run has not been prepared");
|
|
406
|
-
const
|
|
407
|
-
(
|
|
406
|
+
const o = e.segments.map(
|
|
407
|
+
(i, u) => e.offsets[u] + (i.type === "markdown" && i.pending ? 0 : Math.min(
|
|
408
408
|
a[u]?.value.length ?? 0,
|
|
409
|
-
|
|
409
|
+
i.value.length
|
|
410
410
|
))
|
|
411
|
-
), n = (
|
|
412
|
-
const
|
|
413
|
-
if (l.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
411
|
+
), n = (i) => i <= o[N(e, i - 1)], d = (i) => {
|
|
412
|
+
const u = b(e.immediateOffsets, i.start), l = e.immediateOffsets[u];
|
|
413
|
+
if (l < i.end && o[N(e, l)] > l)
|
|
414
|
+
return !0;
|
|
415
|
+
const c = e.immediateOffsets[u - 1];
|
|
416
|
+
return c !== void 0 && i.start < o[N(e, c)];
|
|
417
|
+
}, p = (i, u = !1) => {
|
|
418
|
+
const l = e.visibility.get(i);
|
|
419
|
+
if (i.type === "text") {
|
|
420
|
+
let c = i.value.length;
|
|
421
|
+
if (!u && l?.ends)
|
|
422
|
+
for (c = 0; c < l.ends.length && n(l.ends[c]); )
|
|
423
|
+
c += 1;
|
|
424
|
+
return { ...i, value: i.value.slice(0, c) };
|
|
419
425
|
}
|
|
420
|
-
if ("children" in
|
|
421
|
-
const
|
|
422
|
-
(
|
|
426
|
+
if ("children" in i) {
|
|
427
|
+
const c = i.children.map(
|
|
428
|
+
(f) => p(f, u || !!l?.atomic)
|
|
423
429
|
);
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
...
|
|
427
|
-
properties: { ...
|
|
428
|
-
children:
|
|
430
|
+
if (i.type === "element") {
|
|
431
|
+
const f = {
|
|
432
|
+
...i,
|
|
433
|
+
properties: { ...i.properties },
|
|
434
|
+
children: c
|
|
429
435
|
};
|
|
430
|
-
if (
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
...
|
|
436
|
+
if (l?.range) {
|
|
437
|
+
const M = !!l.immediate && d(l.range) || n(l.structural ? l.range.start + 1 : l.range.end), h = l.svg ? o[N(e, l.range.start)] : l.range.start;
|
|
438
|
+
f.data = {
|
|
439
|
+
...i.data,
|
|
434
440
|
[F]: {
|
|
435
|
-
...
|
|
436
|
-
active:
|
|
437
|
-
svgSource:
|
|
438
|
-
|
|
441
|
+
...l,
|
|
442
|
+
active: M,
|
|
443
|
+
svgSource: l.svg ? e.fullSource.slice(
|
|
444
|
+
l.range.start,
|
|
439
445
|
Math.min(
|
|
440
|
-
|
|
441
|
-
Math.max(
|
|
446
|
+
l.range.end,
|
|
447
|
+
Math.max(l.range.start, h)
|
|
442
448
|
)
|
|
443
449
|
) : void 0
|
|
444
450
|
}
|
|
445
451
|
};
|
|
446
452
|
}
|
|
447
|
-
return
|
|
453
|
+
return f;
|
|
448
454
|
}
|
|
449
|
-
return { ...
|
|
455
|
+
return { ...i, children: c };
|
|
450
456
|
}
|
|
451
|
-
return { ...
|
|
457
|
+
return { ...i };
|
|
452
458
|
};
|
|
453
|
-
return
|
|
459
|
+
return p(e.tree);
|
|
454
460
|
};
|
|
455
461
|
export {
|
|
456
462
|
st as cloneVideoMarkdownSourceTree,
|