@crewlethq/ui 0.29.0 → 0.31.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 +28 -3
- package/dist/ArtifactBar/ArtifactBar.d.ts +13 -1
- package/dist/ArtifactBar/index.js +1 -1
- package/dist/{ArtifactBar-IBWB5POL.css → ArtifactBar-MLMJHWY6.css} +7 -0
- package/dist/ArtifactCover/index.js +2 -2
- package/dist/CommentThread/index.js +2 -2
- package/dist/DataView/index.js +2 -2
- package/dist/Document/Document.d.ts +8 -1
- package/dist/Document/index.js +1 -1
- package/dist/{Document-PQGXJHB7.css → Document-G3YTZIUL.css} +71 -0
- package/dist/EditingStatus/EditingStatus.d.ts +25 -0
- package/dist/EditingStatus/index.d.ts +3 -0
- package/dist/EditingStatus/index.js +2 -0
- package/dist/EditingStatus-NFADEPSX.css +53 -0
- package/dist/Editor-YZ7KG2RD.js +2099 -0
- package/dist/Markdown/grammar.d.ts +170 -0
- package/dist/Markdown/index.d.ts +2 -0
- package/dist/Markdown/index.js +1 -0
- package/dist/RichEditor/Editor.d.ts +17 -0
- package/dist/RichEditor/RichEditor.d.ts +26 -0
- package/dist/RichEditor/codec.d.ts +78 -0
- package/dist/RichEditor/commands.d.ts +89 -0
- package/dist/RichEditor/index.d.ts +4 -0
- package/dist/RichEditor/index.js +8 -0
- package/dist/RichEditor/keys.d.ts +16 -0
- package/dist/RichEditor/nodeviews.d.ts +60 -0
- package/dist/RichEditor/paste.d.ts +47 -0
- package/dist/RichEditor/plugins.d.ts +49 -0
- package/dist/RichEditor/roundtrip.d.ts +14 -0
- package/dist/RichEditor/schema.d.ts +23 -0
- package/dist/RichEditor/types.d.ts +140 -0
- package/dist/RichEditor-NPD2KAPS.css +419 -0
- package/dist/RichEditorMarkdown/index.d.ts +1 -0
- package/dist/RichEditorMarkdown/index.js +3 -0
- package/dist/chunk-3DPIU2Q7.js +28 -0
- package/dist/{chunk-XALUCIG5.js → chunk-6AH2XJ3Q.js} +1 -1
- package/dist/chunk-A4E5YLXO.js +85 -0
- package/dist/{chunk-FKULOLKG.js → chunk-GR55WT4R.js} +1 -1
- package/dist/chunk-IDBHX5SR.js +12 -0
- package/dist/{chunk-WI6K5M5X.js → chunk-M3LUNN7F.js} +1 -1
- package/dist/{chunk-QMBP23BL.js → chunk-P4BOXB6E.js} +17 -1
- package/dist/chunk-SKOYC2CF.js +288 -0
- package/dist/chunk-VOX3YRFO.js +76 -0
- package/dist/chunk-YFW4MTK4.js +749 -0
- package/dist/generated/index.d.ts +4 -0
- package/dist/generated/index.js +50 -44
- package/dist/index.js +50 -44
- package/dist/styles.css +558 -2
- package/package.json +13 -3
- package/dist/{chunk-IFNQKWUO.js → chunk-OC46246T.js} +0 -0
- package/dist/{chunk-RODMM35O.js → chunk-UVJ5FF5V.js} +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readMarkdown, writeMarkdown } from './chunk-YFW4MTK4.js';
|
|
2
|
+
|
|
3
|
+
// src/RichEditor/roundtrip.ts
|
|
4
|
+
function roundTripMarkdown(markdown) {
|
|
5
|
+
const { doc, source } = readMarkdown(markdown);
|
|
6
|
+
return writeMarkdown(doc, source);
|
|
7
|
+
}
|
|
8
|
+
function canonicalMarkdown(markdown) {
|
|
9
|
+
return writeMarkdown(readMarkdown(markdown).doc);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { canonicalMarkdown, roundTripMarkdown };
|
|
@@ -7,7 +7,7 @@ import { Button } from './chunk-OG6CL3EB.js';
|
|
|
7
7
|
import { IconButton } from './chunk-4FQT6ZAY.js';
|
|
8
8
|
import { VisuallyHidden } from './chunk-BZFWDIV6.js';
|
|
9
9
|
import { cx } from './chunk-ODEQTPFM.js';
|
|
10
|
-
import './ArtifactBar-
|
|
10
|
+
import './ArtifactBar-MLMJHWY6.css';
|
|
11
11
|
import { useId, useState, useRef, useEffect } from 'react';
|
|
12
12
|
import { ChevronLeftGlyph, EllipsisGlyph, ChevronDownGlyph } from '@crewlethq/icons/glyphs';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -31,6 +31,7 @@ function ArtifactBar({
|
|
|
31
31
|
version,
|
|
32
32
|
modes,
|
|
33
33
|
presence,
|
|
34
|
+
status,
|
|
34
35
|
kindTools = [],
|
|
35
36
|
tools = [],
|
|
36
37
|
menu = [],
|
|
@@ -109,6 +110,7 @@ function ArtifactBar({
|
|
|
109
110
|
}
|
|
110
111
|
) }) : null,
|
|
111
112
|
/* @__PURE__ */ jsxs("div", { className: "crewlet-artifact-bar__end", children: [
|
|
113
|
+
status ? /* @__PURE__ */ jsx("span", { className: "crewlet-artifact-bar__status", children: status }) : null,
|
|
112
114
|
presence ? /* @__PURE__ */ jsx("span", { className: "crewlet-artifact-bar__presence", children: presence }) : null,
|
|
113
115
|
kindTools.some((t) => !t.labelled) ? /* @__PURE__ */ jsx("span", { className: "crewlet-artifact-bar__tools crewlet-artifact-bar__wide", children: kindTools.filter((t) => !t.labelled).map((tool) => /* @__PURE__ */ jsx(ToolButton, { tool, apple }, tool.key)) }) : null,
|
|
114
116
|
tools.some((t) => !t.labelled) ? /* @__PURE__ */ jsxs("span", { className: "crewlet-artifact-bar__tools crewlet-artifact-bar__wide", children: [
|
|
@@ -165,6 +167,20 @@ function ToolButton({ tool, apple }) {
|
|
|
165
167
|
}
|
|
166
168
|
function LabelledTool({ tool, apple }) {
|
|
167
169
|
const shortcut = tool.keys ? ariaKeys(tool.keys, apple) : void 0;
|
|
170
|
+
if (tool.emphasis === "primary") {
|
|
171
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(Tip, { tool, apple }), placement: "bottom", disabled: !tool.keys, children: /* @__PURE__ */ jsx(
|
|
172
|
+
Button,
|
|
173
|
+
{
|
|
174
|
+
size: "small",
|
|
175
|
+
variant: "primary",
|
|
176
|
+
leadingIcon: tool.icon,
|
|
177
|
+
disabledReason: tool.disabledReason,
|
|
178
|
+
"aria-keyshortcuts": shortcut,
|
|
179
|
+
onClick: tool.onSelect,
|
|
180
|
+
children: tool.label
|
|
181
|
+
}
|
|
182
|
+
) });
|
|
183
|
+
}
|
|
168
184
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
185
|
/* @__PURE__ */ jsx("span", { className: "crewlet-artifact-bar__roomy", children: /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(Tip, { tool, apple }), placement: "bottom", disabled: !tool.keys, children: /* @__PURE__ */ jsx(
|
|
170
186
|
Button,
|
|
@@ -0,0 +1,288 @@
|
|
|
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 = /^(#{1,6})\s+(.*)$/;
|
|
21
|
+
var FENCE = /^(```|~~~)\s*([A-Za-z0-9_+-]*)\s*$/;
|
|
22
|
+
var RULE = /^(?:\s*(?:-{3,}|\*{3,}|_{3,})\s*)$/;
|
|
23
|
+
var BULLET = /^(\s*)([-*+])\s+(.*)$/;
|
|
24
|
+
var ORDERED = /^(\s*)(\d{1,9})([.)])\s+(.*)$/;
|
|
25
|
+
var QUOTE = /^\s{0,3}>\s?(.*)$/;
|
|
26
|
+
var TABLE_RULE = /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;
|
|
27
|
+
var CALLOUT = /^\[!(note|tip|important|warning|caution)\]\s*$/i;
|
|
28
|
+
var TASK = /^\[([ xX])\]\s+(.*)$/;
|
|
29
|
+
var FENCE_CLOSE = {
|
|
30
|
+
"```": /^`{3,}[ \t]*$/,
|
|
31
|
+
"~~~": /^~{3,}[ \t]*$/
|
|
32
|
+
};
|
|
33
|
+
function markdownClosesFence(line, marker) {
|
|
34
|
+
return FENCE_CLOSE[marker].test(line);
|
|
35
|
+
}
|
|
36
|
+
function markdownFenceOf(line) {
|
|
37
|
+
const m = FENCE.exec(line);
|
|
38
|
+
return m ? { marker: m[1] ?? "```", lang: m[2] ?? "" } : null;
|
|
39
|
+
}
|
|
40
|
+
function markdownHeadingOf(line) {
|
|
41
|
+
const m = HEADING.exec(line);
|
|
42
|
+
if (!m) return null;
|
|
43
|
+
return { level: (m[1] ?? "#").length, title: (m[2] ?? "").replace(/\s+#+\s*$/, "").trim() };
|
|
44
|
+
}
|
|
45
|
+
function markdownLines(source) {
|
|
46
|
+
return (source ?? "").replace(/\r\n?/g, "\n").split("\n");
|
|
47
|
+
}
|
|
48
|
+
function parseMarkdown(source) {
|
|
49
|
+
return blocksOf(markdownLines(source)).map((span) => span.block);
|
|
50
|
+
}
|
|
51
|
+
function parseMarkdownSpans(source) {
|
|
52
|
+
const lines = markdownLines(source);
|
|
53
|
+
return { lines, spans: blocksOf(lines) };
|
|
54
|
+
}
|
|
55
|
+
function blocksOf(lines) {
|
|
56
|
+
const out = [];
|
|
57
|
+
let i = 0;
|
|
58
|
+
const paragraph = [];
|
|
59
|
+
let paragraphStart = 0;
|
|
60
|
+
const flush = () => {
|
|
61
|
+
if (paragraph.length) {
|
|
62
|
+
out.push({
|
|
63
|
+
block: { kind: "paragraph", text: paragraph.join("\n") },
|
|
64
|
+
start: paragraphStart,
|
|
65
|
+
end: paragraphStart + paragraph.length
|
|
66
|
+
});
|
|
67
|
+
paragraph.length = 0;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
while (i < lines.length) {
|
|
71
|
+
const line = lines[i] ?? "";
|
|
72
|
+
const start = i;
|
|
73
|
+
if (line.trim() === "") {
|
|
74
|
+
flush();
|
|
75
|
+
i++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const fence = markdownFenceOf(line);
|
|
79
|
+
if (fence) {
|
|
80
|
+
flush();
|
|
81
|
+
const body = [];
|
|
82
|
+
i++;
|
|
83
|
+
while (i < lines.length && !markdownClosesFence(lines[i] ?? "", fence.marker)) {
|
|
84
|
+
body.push(lines[i] ?? "");
|
|
85
|
+
i++;
|
|
86
|
+
}
|
|
87
|
+
if (i >= lines.length && body.length > 0 && body[body.length - 1] === "") {
|
|
88
|
+
body.pop();
|
|
89
|
+
}
|
|
90
|
+
i = Math.min(i + 1, lines.length);
|
|
91
|
+
out.push({
|
|
92
|
+
block: { kind: "code", lang: fence.lang, text: body.join("\n"), fence: fence.marker },
|
|
93
|
+
start,
|
|
94
|
+
end: i
|
|
95
|
+
});
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (RULE.test(line)) {
|
|
99
|
+
flush();
|
|
100
|
+
i++;
|
|
101
|
+
out.push({ block: { kind: "rule" }, start, end: i });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const heading = markdownHeadingOf(line);
|
|
105
|
+
if (heading) {
|
|
106
|
+
flush();
|
|
107
|
+
i++;
|
|
108
|
+
out.push({ block: { kind: "heading", level: heading.level, text: heading.title }, start, end: i });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (QUOTE.test(line)) {
|
|
112
|
+
flush();
|
|
113
|
+
const inner = [];
|
|
114
|
+
while (i < lines.length && QUOTE.test(lines[i] ?? "")) {
|
|
115
|
+
inner.push(QUOTE.exec(lines[i] ?? "")?.[1] ?? "");
|
|
116
|
+
i++;
|
|
117
|
+
}
|
|
118
|
+
const tone = CALLOUT.exec(inner[0] ?? "");
|
|
119
|
+
out.push({
|
|
120
|
+
block: tone ? {
|
|
121
|
+
kind: "callout",
|
|
122
|
+
tone: (tone[1] ?? "note").toLowerCase(),
|
|
123
|
+
blocks: parseMarkdown(inner.slice(1).join("\n"))
|
|
124
|
+
} : { kind: "quote", blocks: parseMarkdown(inner.join("\n")) },
|
|
125
|
+
start,
|
|
126
|
+
end: i
|
|
127
|
+
});
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (line.includes("|") && TABLE_RULE.test(lines[i + 1] ?? "")) {
|
|
131
|
+
flush();
|
|
132
|
+
const head = splitRow(line);
|
|
133
|
+
const align = splitRow(lines[i + 1] ?? "").map(alignOf);
|
|
134
|
+
i += 2;
|
|
135
|
+
const rows = [];
|
|
136
|
+
while (i < lines.length && (lines[i] ?? "").includes("|") && (lines[i] ?? "").trim() !== "") {
|
|
137
|
+
rows.push(splitRow(lines[i] ?? ""));
|
|
138
|
+
i++;
|
|
139
|
+
}
|
|
140
|
+
out.push({ block: { kind: "table", head, align, rows }, start, end: i });
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (BULLET.test(line) || ORDERED.test(line)) {
|
|
144
|
+
flush();
|
|
145
|
+
const [list, next] = parseList(lines, i);
|
|
146
|
+
out.push({ block: list, start, end: next });
|
|
147
|
+
i = next;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (paragraph.length === 0) paragraphStart = i;
|
|
151
|
+
paragraph.push(line);
|
|
152
|
+
i++;
|
|
153
|
+
}
|
|
154
|
+
flush();
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function alignOf(cell) {
|
|
158
|
+
const t = cell.trim();
|
|
159
|
+
if (t.startsWith(":") && t.endsWith(":")) return "center";
|
|
160
|
+
if (t.endsWith(":")) return "right";
|
|
161
|
+
return "left";
|
|
162
|
+
}
|
|
163
|
+
function splitRow(line) {
|
|
164
|
+
let t = line.trim();
|
|
165
|
+
if (t.startsWith("|")) t = t.slice(1);
|
|
166
|
+
if (t.endsWith("|") && !t.endsWith("\\|")) t = t.slice(0, -1);
|
|
167
|
+
const cells = [];
|
|
168
|
+
let cell = "";
|
|
169
|
+
for (let i = 0; i < t.length; i++) {
|
|
170
|
+
const c = t[i];
|
|
171
|
+
if (c === "\\" && t[i + 1] === "|") {
|
|
172
|
+
cell += "|";
|
|
173
|
+
i++;
|
|
174
|
+
} else if (c === "|") {
|
|
175
|
+
cells.push(cell.trim());
|
|
176
|
+
cell = "";
|
|
177
|
+
} else {
|
|
178
|
+
cell += c;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
cells.push(cell.trim());
|
|
182
|
+
return cells;
|
|
183
|
+
}
|
|
184
|
+
function parseList(lines, start) {
|
|
185
|
+
const head = lines[start] ?? "";
|
|
186
|
+
const firstBullet = BULLET.exec(head);
|
|
187
|
+
const firstOrdered = ORDERED.exec(head);
|
|
188
|
+
const baseIndent = ((firstBullet ?? firstOrdered)?.[1] ?? "").length;
|
|
189
|
+
const ordered = firstOrdered !== null && firstBullet === null;
|
|
190
|
+
const startNumber = ordered ? Number(firstOrdered?.[2] ?? 1) : 1;
|
|
191
|
+
const marker = ordered ? firstOrdered?.[3] ?? "." : firstBullet?.[2] ?? "-";
|
|
192
|
+
const items = [];
|
|
193
|
+
let i = start;
|
|
194
|
+
let own = [];
|
|
195
|
+
let checked = null;
|
|
196
|
+
let open = false;
|
|
197
|
+
let loose = false;
|
|
198
|
+
const close = () => {
|
|
199
|
+
if (!open) return;
|
|
200
|
+
items.push({ checked, blocks: parseMarkdown(own.join("\n")) });
|
|
201
|
+
own = [];
|
|
202
|
+
checked = null;
|
|
203
|
+
open = false;
|
|
204
|
+
};
|
|
205
|
+
while (i < lines.length) {
|
|
206
|
+
const line = lines[i] ?? "";
|
|
207
|
+
const bullet = BULLET.exec(line);
|
|
208
|
+
const numbered = ORDERED.exec(line);
|
|
209
|
+
const found = bullet ?? numbered;
|
|
210
|
+
const indent = (found?.[1] ?? "").length;
|
|
211
|
+
if (found && indent === baseIndent) {
|
|
212
|
+
if (ordered !== (numbered !== null && bullet === null)) break;
|
|
213
|
+
close();
|
|
214
|
+
open = true;
|
|
215
|
+
const body = (bullet ? bullet[3] : numbered?.[4]) ?? "";
|
|
216
|
+
const task = TASK.exec(body);
|
|
217
|
+
if (task) {
|
|
218
|
+
checked = (task[1] ?? " ").toLowerCase() === "x";
|
|
219
|
+
own.push(task[2] ?? "");
|
|
220
|
+
} else {
|
|
221
|
+
own.push(body);
|
|
222
|
+
}
|
|
223
|
+
i++;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (found && indent > baseIndent) {
|
|
227
|
+
own.push(line.slice(baseIndent));
|
|
228
|
+
i++;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (line.trim() === "") {
|
|
232
|
+
const following = lines[i + 1] ?? "";
|
|
233
|
+
const continues = BULLET.test(following) || ORDERED.test(following) || /^\s{2,}\S/.test(following);
|
|
234
|
+
if (!continues) break;
|
|
235
|
+
const sibling = BULLET.exec(following) ?? ORDERED.exec(following);
|
|
236
|
+
if (sibling && (sibling[1] ?? "").length === baseIndent) loose = true;
|
|
237
|
+
own.push("");
|
|
238
|
+
i++;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (found === null && /^\s{2,}\S/.test(line) && open) {
|
|
242
|
+
own.push(line.slice(baseIndent));
|
|
243
|
+
i++;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
close();
|
|
249
|
+
return [{ kind: "list", ordered, start: startNumber, marker, loose, items }, i];
|
|
250
|
+
}
|
|
251
|
+
var NOT_WP = String.raw`[^\s\p{P}\p{S}]`;
|
|
252
|
+
var WP = String.raw`[\s\p{P}\p{S}]`;
|
|
253
|
+
var PUNCT = String.raw`[\p{P}\p{S}]`;
|
|
254
|
+
var leftFlanking = (d) => String.raw`(?:(?<!${NOT_WP})${d}(?!\s|$)|(?<=${NOT_WP})${d}(?!${WP}|$))`;
|
|
255
|
+
var rightFlanking = (d) => String.raw`(?:(?<=${NOT_WP})${d}|(?<=${PUNCT})${d}(?!${NOT_WP}))`;
|
|
256
|
+
var underOpens = (d) => String.raw`(?<!${NOT_WP})${d}(?!\s|$)`;
|
|
257
|
+
var underCloses = (d) => String.raw`(?<!\s)${d}(?!${NOT_WP})`;
|
|
258
|
+
var label = (name) => String.raw`(?<${name}>(?:\\[\s\S]|[^\]\\])*)`;
|
|
259
|
+
var destination = (name, title) => String.raw`(?<${name}>(?:[^()\s]|\([^()\s]*\))*)(?:\s+"(?<${title}>[^"]*)")?\)`;
|
|
260
|
+
var ASCII_PUNCTUATION = String.raw`[!-\/:-@\[-\x60{-~]`;
|
|
261
|
+
var INLINE_SOURCE = [
|
|
262
|
+
String.raw`\\(?<esc>${ASCII_PUNCTUATION})`,
|
|
263
|
+
String.raw`(?<tick>\x60+)(?<code>[\s\S]*?)\k<tick>`,
|
|
264
|
+
String.raw`!\[` + label("alt") + String.raw`\]\(` + destination("src", "srcTitle"),
|
|
265
|
+
String.raw`\[` + label("label") + String.raw`\]\(` + destination("href", "hrefTitle"),
|
|
266
|
+
String.raw`<(?<auto>(?:https?:|mailto:)[^>\s]+)>`,
|
|
267
|
+
// A strong run closes on a `**` no third asterisk follows, so `***both***`
|
|
268
|
+
// is strong around emphasis rather than strong around `*both` and a stray.
|
|
269
|
+
leftFlanking(String.raw`\*\*`) + String.raw`(?<strong>[\s\S]+?)` + rightFlanking(String.raw`\*\*(?!\*)`),
|
|
270
|
+
underOpens("__") + String.raw`(?<strongUnder>[\s\S]+?)` + underCloses("__"),
|
|
271
|
+
leftFlanking(String.raw`\*`) + String.raw`(?<em>[\s\S]+?)` + rightFlanking(String.raw`\*`),
|
|
272
|
+
underOpens("_") + String.raw`(?<emUnder>[\s\S]+?)` + underCloses("_"),
|
|
273
|
+
String.raw`~~(?<del>[\s\S]+?)~~`
|
|
274
|
+
].join("|");
|
|
275
|
+
function* markdownInline(text) {
|
|
276
|
+
const pattern = new RegExp(INLINE_SOURCE, "gu");
|
|
277
|
+
for (let m = pattern.exec(text); m !== null; m = pattern.exec(text)) {
|
|
278
|
+
yield { index: m.index, end: m.index + m[0].length, groups: m.groups ?? {} };
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function markdownCodeText(code) {
|
|
282
|
+
return code.replace(/^ | $/g, "");
|
|
283
|
+
}
|
|
284
|
+
function markdownBreaks(text, hard = false) {
|
|
285
|
+
return text.split(hard ? /(?: +|\\)?\n/ : /(?: +|\\)\n/);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { MARKDOWN_CALLOUT_NAMES, MARKDOWN_CALLOUT_TONES, markdownBreaks, markdownClosesFence, markdownCodeText, markdownFenceOf, markdownHeadingOf, markdownInline, markdownLines, parseMarkdown, parseMarkdownSpans, safeHref };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { richEditorLabels } from './chunk-A4E5YLXO.js';
|
|
2
|
+
import { Skeleton } from './chunk-W5J7R5EB.js';
|
|
3
|
+
import { Callout } from './chunk-SVSCLHHI.js';
|
|
4
|
+
import { Button } from './chunk-OG6CL3EB.js';
|
|
5
|
+
import './RichEditor-NPD2KAPS.css';
|
|
6
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var engine = null;
|
|
10
|
+
var loading = null;
|
|
11
|
+
function loadEngine() {
|
|
12
|
+
loading ??= import('./Editor-YZ7KG2RD.js').then(
|
|
13
|
+
(module) => {
|
|
14
|
+
engine = module.Editor;
|
|
15
|
+
return engine;
|
|
16
|
+
},
|
|
17
|
+
(error) => {
|
|
18
|
+
loading = null;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return loading;
|
|
23
|
+
}
|
|
24
|
+
function preloadRichEditor() {
|
|
25
|
+
return loadEngine().then(
|
|
26
|
+
() => void 0,
|
|
27
|
+
() => void 0
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
var RichEditor = forwardRef(function RichEditor2(props, ref) {
|
|
31
|
+
const [Engine, setEngine] = useState(() => engine);
|
|
32
|
+
const [failed, setFailed] = useState(false);
|
|
33
|
+
const [attempt, setAttempt] = useState(0);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (Engine) return;
|
|
36
|
+
let live = true;
|
|
37
|
+
loadEngine().then(
|
|
38
|
+
(loaded) => {
|
|
39
|
+
if (live) setEngine(() => loaded);
|
|
40
|
+
},
|
|
41
|
+
() => {
|
|
42
|
+
if (live) setFailed(true);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
return () => {
|
|
46
|
+
live = false;
|
|
47
|
+
};
|
|
48
|
+
}, [Engine, attempt]);
|
|
49
|
+
if (Engine) return /* @__PURE__ */ jsx(Engine, { ref, ...props });
|
|
50
|
+
const text = richEditorLabels(props.labels);
|
|
51
|
+
if (failed) {
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
Callout,
|
|
54
|
+
{
|
|
55
|
+
variant: "danger",
|
|
56
|
+
title: text.failed,
|
|
57
|
+
action: /* @__PURE__ */ jsx(
|
|
58
|
+
Button,
|
|
59
|
+
{
|
|
60
|
+
size: "small",
|
|
61
|
+
variant: "secondary",
|
|
62
|
+
onClick: () => {
|
|
63
|
+
setFailed(false);
|
|
64
|
+
setAttempt((n) => n + 1);
|
|
65
|
+
},
|
|
66
|
+
children: text.retry
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
children: text.failedDetail
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsx("div", { className: "crewlet-rich-editor crewlet-rich-editor--loading", "aria-busy": "true", children: props.fallback ?? /* @__PURE__ */ jsx(Skeleton, { variant: "text", rows: 6, label: text.loading }) });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export { RichEditor, preloadRichEditor };
|