@crewlethq/ui 0.155.0 → 0.157.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/README.md +33 -0
- package/dist/ArtifactRef/index.js +3 -3
- package/dist/{Editor-LGZMJEUD.js → Editor-7HVKZ35J.js} +8 -5
- package/dist/InlineRef/index.js +2 -2
- package/dist/LimitMeters/LimitMeters.d.ts +39 -0
- package/dist/LimitMeters/index.d.ts +3 -0
- package/dist/LimitMeters/index.js +2 -0
- package/dist/LimitMeters-WCN2QTUU.css +131 -0
- package/dist/LinkCard/index.js +2 -2
- package/dist/Markdown/grammar.d.ts +107 -6
- package/dist/Markdown/index.js +1 -1
- package/dist/OpenInAppCard/index.js +2 -2
- package/dist/ProposalCard/index.js +2 -2
- package/dist/RichEditor/codec.d.ts +1 -1
- package/dist/RichEditor/index.js +3 -3
- package/dist/RichEditorMarkdown/index.js +3 -3
- package/dist/chunk-4LG6V4XY.js +71 -0
- package/dist/{chunk-7CSTEH5I.js → chunk-7XGDMXC5.js} +137 -75
- package/dist/{chunk-2DMTW2Y3.js → chunk-DGXHQMNP.js} +1 -1
- package/dist/chunk-KMTOGF6T.js +597 -0
- package/dist/{chunk-JUZKRHQB.js → chunk-LVHAGF4R.js} +2 -2
- package/dist/{chunk-AH7R777J.js → chunk-OBNOJ6IM.js} +1 -1
- package/dist/{chunk-346EXHOR.js → chunk-PVMDBNZ5.js} +1 -1
- package/dist/{chunk-QNSAFNGT.js → chunk-PZPLTFWX.js} +1 -1
- package/dist/{chunk-GBASM5EV.js → chunk-W5JAJJZO.js} +1 -1
- package/dist/{chunk-6KCQXKFQ.js → chunk-WTV24BFB.js} +1 -1
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +54 -53
- package/dist/index.js +54 -53
- package/dist/styles.css +134 -0
- package/package.json +3 -3
- package/dist/chunk-KBZO4B33.js +0 -293
- package/dist/{chunk-7E3M2X52.js → chunk-2YAK37D6.js} +1 -1
- /package/dist/{chunk-MC5JMA2T.js → chunk-XB6SMI7T.js} +0 -0
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
// src/Markdown/grammar.ts
|
|
2
|
+
var MARKDOWN_CALLOUT_TONES = ["note", "tip", "important", "warning", "caution"];
|
|
3
|
+
var MARKDOWN_CALLOUT_NAMES = {
|
|
4
|
+
note: "Note",
|
|
5
|
+
tip: "Tip",
|
|
6
|
+
important: "Important",
|
|
7
|
+
warning: "Warning",
|
|
8
|
+
caution: "Caution"
|
|
9
|
+
};
|
|
10
|
+
var SAFE_SCHEME = /^(https?:|mailto:)/i;
|
|
11
|
+
var URL_NOISE = /[\u0000- ]/g;
|
|
12
|
+
function safeHref(raw) {
|
|
13
|
+
const href = raw.trim();
|
|
14
|
+
if (href === "") return null;
|
|
15
|
+
const clean = href.replace(URL_NOISE, "");
|
|
16
|
+
if (clean.startsWith("#/")) return clean;
|
|
17
|
+
if (SAFE_SCHEME.test(clean)) return clean;
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var HEADING = /^ {0,3}(#{1,6})\s+(.*)$/;
|
|
21
|
+
var FENCE = /^( {0,3})(`{3,}|~{3,})\s*([A-Za-z0-9_+-]*)\s*$/;
|
|
22
|
+
var RULE = /^ {0,3}(?:-{3,}|\*{3,}|_{3,})[ \t]*$/;
|
|
23
|
+
var QUOTE = /^\s{0,3}>\s?(.*)$/;
|
|
24
|
+
var TABLE_RULE = /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;
|
|
25
|
+
var CALLOUT = /^\[!(note|tip|important|warning|caution)\]\s*$/i;
|
|
26
|
+
var TASK = /^\[([ xX])\](?:\s+(.*))?$/;
|
|
27
|
+
function markdownClosesFence(line, marker, length) {
|
|
28
|
+
const char = marker[0] ?? "`";
|
|
29
|
+
const indent = /^ {0,3}/.exec(line)?.[0].length ?? 0;
|
|
30
|
+
let end = indent;
|
|
31
|
+
while (line[end] === char) end++;
|
|
32
|
+
return end - indent >= length && line.slice(end).trim() === "";
|
|
33
|
+
}
|
|
34
|
+
function markdownFenceOf(line) {
|
|
35
|
+
const m = FENCE.exec(line);
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const run = m[2] ?? "```";
|
|
38
|
+
return {
|
|
39
|
+
marker: run.startsWith("~") ? "~~~" : "```",
|
|
40
|
+
length: run.length,
|
|
41
|
+
lang: m[3] ?? "",
|
|
42
|
+
indent: (m[1] ?? "").length
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function markdownHeadingOf(line) {
|
|
46
|
+
const m = HEADING.exec(line);
|
|
47
|
+
if (!m) return null;
|
|
48
|
+
return { level: (m[1] ?? "#").length, title: (m[2] ?? "").replace(/\s+#+\s*$/, "").trim() };
|
|
49
|
+
}
|
|
50
|
+
function markdownLines(source) {
|
|
51
|
+
return (source ?? "").replace(/\r\n?/g, "\n").split("\n");
|
|
52
|
+
}
|
|
53
|
+
function parseMarkdown(source) {
|
|
54
|
+
return new BlockReader(markdownLines(source)).read().map((span) => span.block);
|
|
55
|
+
}
|
|
56
|
+
function parseMarkdownSpans(source) {
|
|
57
|
+
const lines = markdownLines(source);
|
|
58
|
+
return { lines, spans: new BlockReader(lines).read() };
|
|
59
|
+
}
|
|
60
|
+
function alignOf(cell) {
|
|
61
|
+
const t = cell.trim();
|
|
62
|
+
if (t.startsWith(":") && t.endsWith(":")) return "center";
|
|
63
|
+
if (t.endsWith(":")) return "right";
|
|
64
|
+
return "left";
|
|
65
|
+
}
|
|
66
|
+
function splitRow(line) {
|
|
67
|
+
let t = line.trim();
|
|
68
|
+
if (t.startsWith("|")) t = t.slice(1);
|
|
69
|
+
if (t.endsWith("|") && !t.endsWith("\\|")) t = t.slice(0, -1);
|
|
70
|
+
const cells = [];
|
|
71
|
+
let cell = "";
|
|
72
|
+
for (let i = 0; i < t.length; i++) {
|
|
73
|
+
const c = t[i];
|
|
74
|
+
if (c === "\\" && t[i + 1] === "|") {
|
|
75
|
+
cell += "|";
|
|
76
|
+
i++;
|
|
77
|
+
} else if (c === "|") {
|
|
78
|
+
cells.push(cell.trim());
|
|
79
|
+
cell = "";
|
|
80
|
+
} else {
|
|
81
|
+
cell += c;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
cells.push(cell.trim());
|
|
85
|
+
return cells;
|
|
86
|
+
}
|
|
87
|
+
function blank(line) {
|
|
88
|
+
return (line ?? "").trim() === "";
|
|
89
|
+
}
|
|
90
|
+
function columnAfter(ws, from) {
|
|
91
|
+
let col = from;
|
|
92
|
+
for (const c of ws) col = c === " " ? col + 4 - col % 4 : col + 1;
|
|
93
|
+
return col;
|
|
94
|
+
}
|
|
95
|
+
function indentOf(line, col = 0) {
|
|
96
|
+
return columnAfter(/^\s*/.exec(line)?.[0] ?? "", col) - col;
|
|
97
|
+
}
|
|
98
|
+
function dedent(line, columns, col = 0) {
|
|
99
|
+
let at = 0;
|
|
100
|
+
let i = 0;
|
|
101
|
+
while (i < line.length && at < columns) {
|
|
102
|
+
const c = line[i] ?? "";
|
|
103
|
+
if (c === " ") {
|
|
104
|
+
const next = at + 4 - (col + at) % 4;
|
|
105
|
+
if (next > columns) return " ".repeat(next - columns) + line.slice(i + 1);
|
|
106
|
+
at = next;
|
|
107
|
+
} else if (/\s/.test(c)) {
|
|
108
|
+
at++;
|
|
109
|
+
} else {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
i++;
|
|
113
|
+
}
|
|
114
|
+
return line.slice(i);
|
|
115
|
+
}
|
|
116
|
+
function expand(line, col) {
|
|
117
|
+
const lead = /^\s*/.exec(line)?.[0] ?? "";
|
|
118
|
+
return lead.includes(" ") ? " ".repeat(columnAfter(lead, col) - col) + line.slice(lead.length) : line;
|
|
119
|
+
}
|
|
120
|
+
function unquote(line, col) {
|
|
121
|
+
const m = /^[ \t]*>/.exec(line);
|
|
122
|
+
if (!m) return null;
|
|
123
|
+
const at = columnAfter(m[0].slice(0, -1), col);
|
|
124
|
+
if (at - col > 3) return null;
|
|
125
|
+
const after = at + 1;
|
|
126
|
+
const i = m[0].length;
|
|
127
|
+
if (line[i] === " ") return { rest: line.slice(i + 1), col: after + 1 };
|
|
128
|
+
if (line[i] === " ") {
|
|
129
|
+
const stop = after + 4 - after % 4;
|
|
130
|
+
return { rest: " ".repeat(stop - after - 1) + line.slice(i + 1), col: after + 1 };
|
|
131
|
+
}
|
|
132
|
+
return { rest: line.slice(i), col: after };
|
|
133
|
+
}
|
|
134
|
+
var ITEM = /^(\s*)(?:([-*+])|(\d{1,9})([.)]))(\s+|$)/;
|
|
135
|
+
function itemStart(line, col = 0) {
|
|
136
|
+
const m = ITEM.exec(line);
|
|
137
|
+
if (!m) return null;
|
|
138
|
+
const indent = columnAfter(m[1] ?? "", col) - col;
|
|
139
|
+
if (indent > 3) return null;
|
|
140
|
+
const ordered = m[3] !== void 0;
|
|
141
|
+
const marker = ordered ? m[4] ?? "." : m[2] ?? "-";
|
|
142
|
+
const number = Number(m[3] ?? 1);
|
|
143
|
+
const after = indent + (ordered ? (m[3] ?? "").length + 1 : 1);
|
|
144
|
+
const text = line.slice(m[0].length);
|
|
145
|
+
if (text === "") return { ordered, marker, number, content: after + 1, text: "", textCol: after + 1 };
|
|
146
|
+
const spaces = columnAfter(m[5] ?? " ", col + after) - (col + after);
|
|
147
|
+
return spaces <= 4 ? { ordered, marker, number, content: after + spaces, text, textCol: after + spaces } : { ordered, marker, number, content: after + 1, text: " ".repeat(spaces - 1) + text, textCol: after + 1 };
|
|
148
|
+
}
|
|
149
|
+
function startsBlock(line) {
|
|
150
|
+
return blank(line) || markdownFenceOf(line) !== null || RULE.test(line) || markdownHeadingOf(line) !== null || QUOTE.test(line) || itemStart(line) !== null || htmlBlockStart(line);
|
|
151
|
+
}
|
|
152
|
+
var HTML_BLOCK_STARTS = [
|
|
153
|
+
/^<(?:script|pre|textarea|style)(?:\s|>|$)/i,
|
|
154
|
+
/^<!--/,
|
|
155
|
+
/^<[?]/,
|
|
156
|
+
/^<![A-Za-z]/,
|
|
157
|
+
/^<!\[CDATA\[/,
|
|
158
|
+
/^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|search|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)/i
|
|
159
|
+
];
|
|
160
|
+
function htmlBlockStart(line) {
|
|
161
|
+
const html = /^ {0,3}(<.*)$/.exec(line)?.[1];
|
|
162
|
+
return html !== void 0 && HTML_BLOCK_STARTS.some((start) => start.test(html));
|
|
163
|
+
}
|
|
164
|
+
function endsTable(line) {
|
|
165
|
+
return markdownFenceOf(line) !== null || RULE.test(line) || markdownHeadingOf(line) !== null || QUOTE.test(line) || itemStart(line) !== null || htmlBlockStart(line);
|
|
166
|
+
}
|
|
167
|
+
var MAX_NESTING = 100;
|
|
168
|
+
var BlockReader = class {
|
|
169
|
+
constructor(lines) {
|
|
170
|
+
this.lines = lines;
|
|
171
|
+
}
|
|
172
|
+
lines;
|
|
173
|
+
root = { kind: "root", children: [], leaf: null, start: 0, end: 0 };
|
|
174
|
+
stack = [];
|
|
175
|
+
/** How many quotes and list items are open: what [MAX_NESTING] caps. */
|
|
176
|
+
nesting = 0;
|
|
177
|
+
read() {
|
|
178
|
+
for (let i = 0; i < this.lines.length; i++) this.line(i);
|
|
179
|
+
this.closeFrom(0);
|
|
180
|
+
this.closeLeaf(this.root);
|
|
181
|
+
return this.root.children;
|
|
182
|
+
}
|
|
183
|
+
line(i) {
|
|
184
|
+
let rest = this.lines[i] ?? "";
|
|
185
|
+
let col = 0;
|
|
186
|
+
let depth = 0;
|
|
187
|
+
for (; depth < this.stack.length; depth++) {
|
|
188
|
+
const frame = this.stack[depth];
|
|
189
|
+
if (frame.kind === "list") continue;
|
|
190
|
+
if (frame.kind === "quote") {
|
|
191
|
+
const inner = unquote(rest, col);
|
|
192
|
+
if (!inner) break;
|
|
193
|
+
({ rest, col } = inner);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (blank(rest) ? !this.blankBelongs(frame, depth, i) : indentOf(rest, col) < frame.content) break;
|
|
197
|
+
if (!blank(rest)) frame.bare = false;
|
|
198
|
+
rest = dedent(rest, frame.content, col);
|
|
199
|
+
col += frame.content;
|
|
200
|
+
}
|
|
201
|
+
if (depth === this.stack.length) {
|
|
202
|
+
const top = this.stack[depth - 1] ?? this.root;
|
|
203
|
+
if (top.kind === "list") {
|
|
204
|
+
if (blank(rest)) {
|
|
205
|
+
this.extend(i);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const head = itemStart(rest, col);
|
|
209
|
+
if (head && sameList(head, top)) {
|
|
210
|
+
this.extend(i);
|
|
211
|
+
this.readOn(this.openItem(top, head, i, col), i);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
this.closeFrom(depth - 1);
|
|
215
|
+
this.extend(i);
|
|
216
|
+
this.start(rest, i, col);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.extend(i);
|
|
220
|
+
const leaf = top.leaf;
|
|
221
|
+
if (leaf?.kind === "code") {
|
|
222
|
+
leaf.end = i + 1;
|
|
223
|
+
if (markdownClosesFence(expand(rest, col), leaf.marker, leaf.length)) {
|
|
224
|
+
top.children.push({ block: codeOf(leaf), start: leaf.start, end: leaf.end });
|
|
225
|
+
top.leaf = null;
|
|
226
|
+
} else {
|
|
227
|
+
leaf.lines.push(dedent(rest, leaf.indent, col));
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (leaf?.kind === "table") {
|
|
232
|
+
if (!leaf.ruled) {
|
|
233
|
+
leaf.ruled = true;
|
|
234
|
+
leaf.align = splitRow(rest).map(alignOf);
|
|
235
|
+
leaf.end = i + 1;
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (!blank(rest) && !endsTable(expand(rest, col))) {
|
|
239
|
+
leaf.rows.push(splitRow(rest));
|
|
240
|
+
leaf.end = i + 1;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
this.start(rest, i, col);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (!blank(rest) && this.lazy(rest, i, col)) return;
|
|
248
|
+
const first = this.stack[depth];
|
|
249
|
+
if (first.kind === "item") {
|
|
250
|
+
const list = this.stack[depth - 1];
|
|
251
|
+
if (blank(rest)) {
|
|
252
|
+
const sibling = this.nextItem(i, depth, list);
|
|
253
|
+
this.closeFrom(depth);
|
|
254
|
+
if (sibling) {
|
|
255
|
+
list.loose = true;
|
|
256
|
+
this.extend(i);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this.closeFrom(depth - 1);
|
|
260
|
+
this.extend(i);
|
|
261
|
+
this.start(rest, i, col);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const head = itemStart(rest, col);
|
|
265
|
+
this.closeFrom(depth);
|
|
266
|
+
if (head && sameList(head, list)) {
|
|
267
|
+
this.extend(i);
|
|
268
|
+
this.readOn(this.openItem(list, head, i, col), i);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
this.closeFrom(depth - 1);
|
|
272
|
+
} else {
|
|
273
|
+
this.closeFrom(depth);
|
|
274
|
+
}
|
|
275
|
+
this.extend(i);
|
|
276
|
+
this.start(rest, i, col);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Take `rest` as a lazy line, if it is one: the innermost tip is an open
|
|
280
|
+
* paragraph and the line, judged at the indent it has, starts no block. It
|
|
281
|
+
* is added unindented, as the paragraph text it was taken for, and every
|
|
282
|
+
* container it did not reach stays open, a quote as much as an item: a
|
|
283
|
+
* quote's paragraph wrapped without its `>` is still the quote's, as every
|
|
284
|
+
* CommonMark reader draws it.
|
|
285
|
+
*/
|
|
286
|
+
lazy(rest, i, col) {
|
|
287
|
+
const top = this.stack[this.stack.length - 1] ?? this.root;
|
|
288
|
+
if (top.kind === "list" || top.leaf?.kind !== "paragraph") return false;
|
|
289
|
+
if (startsBlock(expand(rest, col))) return false;
|
|
290
|
+
top.leaf.lines.push(rest.trimStart());
|
|
291
|
+
top.leaf.end = i + 1;
|
|
292
|
+
this.extend(i);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Whether the first line that is not blank after the blank line `i`, read
|
|
297
|
+
* through the containers outside the list, is the list's next item.
|
|
298
|
+
*/
|
|
299
|
+
nextItem(i, depth, list) {
|
|
300
|
+
for (let k = i + 1; k < this.lines.length; k++) {
|
|
301
|
+
const next = this.peel(k, depth);
|
|
302
|
+
if (next === null) return false;
|
|
303
|
+
if (blank(next.rest)) continue;
|
|
304
|
+
const head = itemStart(next.rest, next.col);
|
|
305
|
+
return head !== null && sameList(head, list);
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Whether the blank line `i` belongs to the item at `depth`: it does when
|
|
311
|
+
* the next line that is not blank, read through the containers outside the
|
|
312
|
+
* item, is indented to the item's content. The answer covers the whole run
|
|
313
|
+
* of blank lines, so a run is looked through once, not once a line.
|
|
314
|
+
*/
|
|
315
|
+
blankBelongs(item, depth, i) {
|
|
316
|
+
if (item.bare) return false;
|
|
317
|
+
if (i < item.blankUntil) return true;
|
|
318
|
+
for (let k = i + 1; k < this.lines.length; k++) {
|
|
319
|
+
const next = this.peel(k, depth);
|
|
320
|
+
if (next === null) return false;
|
|
321
|
+
if (blank(next.rest)) continue;
|
|
322
|
+
if (indentOf(next.rest, next.col) < item.content) return false;
|
|
323
|
+
item.blankUntil = k;
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Line `k` as the first `depth` open containers would hand it on, or null
|
|
330
|
+
* when one of them would not take it. A blank line passes an item, whose own
|
|
331
|
+
* question about it is [blankBelongs].
|
|
332
|
+
*/
|
|
333
|
+
peel(k, depth) {
|
|
334
|
+
let rest = this.lines[k] ?? "";
|
|
335
|
+
let col = 0;
|
|
336
|
+
for (let d = 0; d < depth; d++) {
|
|
337
|
+
const frame = this.stack[d];
|
|
338
|
+
if (frame.kind === "list") continue;
|
|
339
|
+
if (frame.kind === "quote") {
|
|
340
|
+
const inner = unquote(rest, col);
|
|
341
|
+
if (!inner) return null;
|
|
342
|
+
({ rest, col } = inner);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (!blank(rest) && indentOf(rest, col) < frame.content) return null;
|
|
346
|
+
rest = dedent(rest, frame.content, col);
|
|
347
|
+
col += frame.content;
|
|
348
|
+
}
|
|
349
|
+
return { rest, col };
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Read `rest` of line `i`, starting at column `col`, as the start of a
|
|
353
|
+
* block, or the next line of a paragraph, in the innermost container.
|
|
354
|
+
*
|
|
355
|
+
* A LINE CAN OPEN CONTAINERS ONE INSIDE ANOTHER (`> - > - x`): each opens,
|
|
356
|
+
* and what is left of the line is read inside it, IN A LOOP rather than by
|
|
357
|
+
* a call of its own, so a chain of any length opens without growing the
|
|
358
|
+
* call stack; ten thousand `- ` on one line overflowed it.
|
|
359
|
+
*/
|
|
360
|
+
start(rest, i, col) {
|
|
361
|
+
for (let next = this.startOne(rest, i, col); next !== null; next = this.startOne(next.rest, i, next.col)) ;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Read `rest` of line `i` as [start] does, one step: the rest of the line
|
|
365
|
+
* and its column when a container opened that the rest is read inside,
|
|
366
|
+
* else null.
|
|
367
|
+
*/
|
|
368
|
+
startOne(rest, i, col) {
|
|
369
|
+
const top = this.stack[this.stack.length - 1] ?? this.root;
|
|
370
|
+
const leaf = top.leaf;
|
|
371
|
+
if (blank(rest)) {
|
|
372
|
+
this.closeLeaf(top);
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
const lead = expand(rest, col);
|
|
376
|
+
const fence = markdownFenceOf(lead);
|
|
377
|
+
if (fence) {
|
|
378
|
+
this.closeLeaf(top);
|
|
379
|
+
top.leaf = {
|
|
380
|
+
kind: "code",
|
|
381
|
+
marker: fence.marker,
|
|
382
|
+
length: fence.length,
|
|
383
|
+
lang: fence.lang,
|
|
384
|
+
indent: fence.indent,
|
|
385
|
+
lines: [],
|
|
386
|
+
start: i,
|
|
387
|
+
end: i + 1
|
|
388
|
+
};
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
if (RULE.test(lead)) {
|
|
392
|
+
this.closeLeaf(top);
|
|
393
|
+
top.children.push({ block: { kind: "rule" }, start: i, end: i + 1 });
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
const heading = markdownHeadingOf(lead);
|
|
397
|
+
if (heading) {
|
|
398
|
+
this.closeLeaf(top);
|
|
399
|
+
top.children.push({ block: { kind: "heading", level: heading.level, text: heading.title }, start: i, end: i + 1 });
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
const deepest = this.nesting >= MAX_NESTING;
|
|
403
|
+
const quoted = deepest ? null : unquote(rest, col);
|
|
404
|
+
if (quoted) {
|
|
405
|
+
this.closeLeaf(top);
|
|
406
|
+
const inner = quoted.rest;
|
|
407
|
+
const tone = CALLOUT.exec(inner);
|
|
408
|
+
this.nesting++;
|
|
409
|
+
this.stack.push({
|
|
410
|
+
kind: "quote",
|
|
411
|
+
tone: tone ? (tone[1] ?? "note").toLowerCase() : null,
|
|
412
|
+
children: [],
|
|
413
|
+
leaf: null,
|
|
414
|
+
start: i,
|
|
415
|
+
end: i + 1
|
|
416
|
+
});
|
|
417
|
+
return tone ? null : { rest: inner, col: quoted.col };
|
|
418
|
+
}
|
|
419
|
+
const head = deepest ? null : itemStart(rest, col);
|
|
420
|
+
const interrupts = head !== null && head.text !== "" && (!head.ordered || head.number === 1);
|
|
421
|
+
if (head && (leaf?.kind !== "paragraph" || interrupts)) {
|
|
422
|
+
this.closeLeaf(top);
|
|
423
|
+
const list = {
|
|
424
|
+
kind: "list",
|
|
425
|
+
ordered: head.ordered,
|
|
426
|
+
marker: head.marker,
|
|
427
|
+
number: head.ordered ? head.number : 1,
|
|
428
|
+
loose: false,
|
|
429
|
+
items: [],
|
|
430
|
+
start: i,
|
|
431
|
+
end: i + 1
|
|
432
|
+
};
|
|
433
|
+
this.stack.push(list);
|
|
434
|
+
return this.openItem(list, head, i, col);
|
|
435
|
+
}
|
|
436
|
+
const below = rest.includes("|") && i + 1 < this.lines.length ? this.peel(i + 1, this.stack.length)?.rest : void 0;
|
|
437
|
+
if (below !== void 0 && TABLE_RULE.test(below) && splitRow(rest).length === splitRow(below).length) {
|
|
438
|
+
this.closeLeaf(top);
|
|
439
|
+
top.leaf = { kind: "table", head: splitRow(rest), align: [], rows: [], ruled: false, start: i, end: i + 1 };
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
442
|
+
if (leaf?.kind === "paragraph" && !htmlBlockStart(lead)) {
|
|
443
|
+
leaf.lines.push(rest);
|
|
444
|
+
leaf.end = i + 1;
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
this.closeLeaf(top);
|
|
448
|
+
top.leaf = { kind: "paragraph", lines: [rest], start: i, end: i + 1 };
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Open the item `head` starts on line `i` (whose piece starts at column
|
|
453
|
+
* `col`), and answer its first line's content, to read as the item's own
|
|
454
|
+
* first line, or null when the marker stands alone.
|
|
455
|
+
*/
|
|
456
|
+
openItem(list, head, i, col) {
|
|
457
|
+
let text = head.text;
|
|
458
|
+
let textCol = col + head.textCol;
|
|
459
|
+
let checked = null;
|
|
460
|
+
const task = TASK.exec(text);
|
|
461
|
+
if (task) {
|
|
462
|
+
checked = (task[1] ?? " ").toLowerCase() === "x";
|
|
463
|
+
const after = task[2] ?? "";
|
|
464
|
+
textCol = columnAfter(text.slice(0, text.length - after.length), textCol);
|
|
465
|
+
text = after;
|
|
466
|
+
}
|
|
467
|
+
list.end = i + 1;
|
|
468
|
+
this.nesting++;
|
|
469
|
+
this.stack.push({
|
|
470
|
+
kind: "item",
|
|
471
|
+
content: head.content,
|
|
472
|
+
checked,
|
|
473
|
+
bare: blank(text),
|
|
474
|
+
blankUntil: 0,
|
|
475
|
+
children: [],
|
|
476
|
+
leaf: null,
|
|
477
|
+
start: i,
|
|
478
|
+
end: i + 1
|
|
479
|
+
});
|
|
480
|
+
return blank(text) ? null : { rest: text, col: textCol };
|
|
481
|
+
}
|
|
482
|
+
/** Read what is left of line `i` in the container just opened, if anything is. */
|
|
483
|
+
readOn(next, i) {
|
|
484
|
+
if (next) this.start(next.rest, i, next.col);
|
|
485
|
+
}
|
|
486
|
+
/** Every open container has read up to line `i`. */
|
|
487
|
+
extend(i) {
|
|
488
|
+
this.root.end = i + 1;
|
|
489
|
+
for (const frame of this.stack) frame.end = i + 1;
|
|
490
|
+
}
|
|
491
|
+
/** Finish the open leaf of `holder`, if it has one. */
|
|
492
|
+
closeLeaf(holder) {
|
|
493
|
+
const leaf = holder.leaf;
|
|
494
|
+
if (!leaf) return;
|
|
495
|
+
holder.leaf = null;
|
|
496
|
+
let block;
|
|
497
|
+
switch (leaf.kind) {
|
|
498
|
+
case "paragraph":
|
|
499
|
+
block = { kind: "paragraph", text: leaf.lines.join("\n") };
|
|
500
|
+
break;
|
|
501
|
+
case "code":
|
|
502
|
+
if (leaf.lines.length > 0 && leaf.lines[leaf.lines.length - 1] === "") leaf.lines.pop();
|
|
503
|
+
block = codeOf(leaf);
|
|
504
|
+
break;
|
|
505
|
+
case "table":
|
|
506
|
+
block = { kind: "table", head: leaf.head, align: leaf.align, rows: leaf.rows };
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
holder.children.push({ block, start: leaf.start, end: leaf.end });
|
|
510
|
+
}
|
|
511
|
+
/** Close every open container from `depth` up, each into the one it is in. */
|
|
512
|
+
closeFrom(depth) {
|
|
513
|
+
while (this.stack.length > depth) {
|
|
514
|
+
const frame = this.stack.pop();
|
|
515
|
+
if (frame.kind !== "list") this.nesting--;
|
|
516
|
+
const parent = this.stack[this.stack.length - 1] ?? this.root;
|
|
517
|
+
if (frame.kind === "list") {
|
|
518
|
+
const { ordered, number, marker, loose, items } = frame;
|
|
519
|
+
parent.children.push({
|
|
520
|
+
block: { kind: "list", ordered, start: number, marker, loose, items },
|
|
521
|
+
start: frame.start,
|
|
522
|
+
end: frame.end
|
|
523
|
+
});
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
this.closeLeaf(frame);
|
|
527
|
+
if (frame.kind === "item") {
|
|
528
|
+
const list = parent;
|
|
529
|
+
const spans = frame.children;
|
|
530
|
+
if (spans.some((span, j) => j > 0 && span.start > (spans[j - 1]?.end ?? 0))) list.loose = true;
|
|
531
|
+
list.items.push({ checked: frame.checked, blocks: spans.map((span) => span.block) });
|
|
532
|
+
} else if (frame.kind === "quote") {
|
|
533
|
+
const blocks = frame.children.map((span) => span.block);
|
|
534
|
+
parent.children.push({
|
|
535
|
+
block: frame.tone ? { kind: "callout", tone: frame.tone, blocks } : { kind: "quote", blocks },
|
|
536
|
+
start: frame.start,
|
|
537
|
+
end: frame.end
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
function sameList(head, list) {
|
|
544
|
+
return head.ordered === list.ordered && head.marker === list.marker;
|
|
545
|
+
}
|
|
546
|
+
function codeOf(leaf) {
|
|
547
|
+
return { kind: "code", lang: leaf.lang, text: leaf.lines.join("\n"), fence: leaf.marker };
|
|
548
|
+
}
|
|
549
|
+
var NOT_WP = String.raw`[^\s\p{P}\p{S}]`;
|
|
550
|
+
var WP = String.raw`[\s\p{P}\p{S}]`;
|
|
551
|
+
var PUNCT = String.raw`[\p{P}\p{S}]`;
|
|
552
|
+
var leftFlanking = (d) => String.raw`(?:(?<!${NOT_WP})${d}(?!\s|$)|(?<=${NOT_WP})${d}(?!${WP}|$))`;
|
|
553
|
+
var rightFlanking = (d) => String.raw`(?:(?<=${NOT_WP})${d}|(?<=${PUNCT})${d}(?!${NOT_WP}))`;
|
|
554
|
+
var underOpens = (d) => String.raw`(?<!${NOT_WP})${d}(?!\s|$)`;
|
|
555
|
+
var underCloses = (d) => String.raw`(?<!\s)${d}(?!${NOT_WP})`;
|
|
556
|
+
var label = (name) => String.raw`(?<${name}>(?:\\[\s\S]|[^\]\\])*)`;
|
|
557
|
+
var destination = (name, title) => String.raw`(?<${name}>(?:[^()\s]|\([^()\s]*\))*)(?:\s+"(?<${title}>[^"]*)")?\)`;
|
|
558
|
+
var linkLabel = (name) => String.raw`(?<${name}>(?:\\[\s\S]|!\[(?:\\[\s\S]|[^\]\\])*\]\((?:[^()\s]|\([^()\s]*\))*(?:\s+"[^"]*")?\)|[^\]\\])*)`;
|
|
559
|
+
var ASCII_PUNCTUATION = String.raw`[!-\/:-@\[-\x60{-~]`;
|
|
560
|
+
var INLINE_SOURCE = [
|
|
561
|
+
String.raw`\\(?<esc>${ASCII_PUNCTUATION})`,
|
|
562
|
+
String.raw`(?<!(?<!\\)\x60)(?<tick>\x60+)(?!\x60)(?<code>[\s\S]*?)(?<!\x60)\k<tick>(?!\x60)`,
|
|
563
|
+
String.raw`!\[` + label("alt") + String.raw`\]\(` + destination("src", "srcTitle"),
|
|
564
|
+
String.raw`\[` + linkLabel("label") + String.raw`\]\(` + destination("href", "hrefTitle"),
|
|
565
|
+
String.raw`<(?<auto>(?:https?:|mailto:)[^>\s]+)>`,
|
|
566
|
+
// A strong run closes on a `**` no third asterisk follows, so `***both***`
|
|
567
|
+
// is strong around emphasis rather than strong around `*both` and a stray.
|
|
568
|
+
leftFlanking(String.raw`\*\*`) + String.raw`(?<strong>[\s\S]+?)` + rightFlanking(String.raw`\*\*(?!\*)`),
|
|
569
|
+
underOpens("__") + String.raw`(?<strongUnder>[\s\S]+?)` + underCloses("__"),
|
|
570
|
+
leftFlanking(String.raw`\*`) + String.raw`(?<em>[\s\S]+?)` + rightFlanking(String.raw`\*`),
|
|
571
|
+
underOpens("_") + String.raw`(?<emUnder>[\s\S]+?)` + underCloses("_"),
|
|
572
|
+
String.raw`(?<!~)(?=(?<tilde>~~?)(?!~))` + leftFlanking(String.raw`\k<tilde>`) + String.raw`(?<del>[\s\S]+?)(?<!~)` + rightFlanking(String.raw`\k<tilde>(?!~)`)
|
|
573
|
+
].join("|");
|
|
574
|
+
function* markdownInline(text) {
|
|
575
|
+
const pattern = new RegExp(INLINE_SOURCE, "gu");
|
|
576
|
+
for (let m = pattern.exec(text); m !== null; m = pattern.exec(text)) {
|
|
577
|
+
const groups = m.groups ?? {};
|
|
578
|
+
if (onlyDelimiters(groups)) {
|
|
579
|
+
pattern.lastIndex = m.index + 1;
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
yield { index: m.index, end: m.index + m[0].length, groups };
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function onlyDelimiters(g) {
|
|
586
|
+
const only = (text, char) => text !== void 0 && [...text].every((c) => c === char);
|
|
587
|
+
return only(g.strong, "*") || only(g.em, "*") || only(g.strongUnder, "_") || only(g.emUnder, "_") || only(g.del, "~");
|
|
588
|
+
}
|
|
589
|
+
function markdownCodeText(code) {
|
|
590
|
+
const text = code.replace(/\n/g, " ");
|
|
591
|
+
return text.length >= 2 && text.startsWith(" ") && text.endsWith(" ") && text.trim() !== "" ? text.slice(1, -1) : text;
|
|
592
|
+
}
|
|
593
|
+
function markdownBreaks(text, hard = false) {
|
|
594
|
+
return text.split(hard ? /(?: +|\\)?\n/ : /(?: +|\\)\n/);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export { MARKDOWN_CALLOUT_NAMES, MARKDOWN_CALLOUT_TONES, htmlBlockStart, markdownBreaks, markdownClosesFence, markdownCodeText, markdownFenceOf, markdownHeadingOf, markdownInline, markdownLines, parseMarkdown, parseMarkdownSpans, safeHref };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { richEditorLabels } from './chunk-
|
|
1
|
+
import { richEditorLabels } from './chunk-DGXHQMNP.js';
|
|
2
2
|
import { Callout } from './chunk-CWACQEPP.js';
|
|
3
3
|
import { Skeleton } from './chunk-WFAJYBLX.js';
|
|
4
4
|
import { Button } from './chunk-IMF3CPTY.js';
|
|
@@ -9,7 +9,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
9
9
|
var engine = null;
|
|
10
10
|
var loading = null;
|
|
11
11
|
function loadEngine() {
|
|
12
|
-
loading ??= import('./Editor-
|
|
12
|
+
loading ??= import('./Editor-7HVKZ35J.js').then(
|
|
13
13
|
(module) => {
|
|
14
14
|
engine = module.Editor;
|
|
15
15
|
return engine;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconTile } from './chunk-VRVNLJUA.js';
|
|
2
2
|
import { ReceiptStrip } from './chunk-OAD4AXYJ.js';
|
|
3
3
|
import { StatusCard } from './chunk-NWKH5FF7.js';
|
|
4
|
-
import { safeHref } from './chunk-
|
|
4
|
+
import { safeHref } from './chunk-KMTOGF6T.js';
|
|
5
5
|
import { ButtonLink, Button } from './chunk-IMF3CPTY.js';
|
|
6
6
|
import { cx } from './chunk-ODEQTPFM.js';
|
|
7
7
|
import './OpenInAppCard-CKHCK7DO.css';
|
|
@@ -133,6 +133,7 @@ export * from '../KeyValueRows/index.js';
|
|
|
133
133
|
export * from '../Layer/index.js';
|
|
134
134
|
export * from '../LayersList/index.js';
|
|
135
135
|
export * from '../Layout/index.js';
|
|
136
|
+
export * from '../LimitMeters/index.js';
|
|
136
137
|
export * from '../Link/index.js';
|
|
137
138
|
export * from '../LinkCard/index.js';
|
|
138
139
|
export * from '../LinkInterstitial/index.js';
|