@hachej/boring-workspace 0.1.47 → 0.1.48
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/dist/FileTree-CoZWkHqn.js +315 -0
- package/dist/{MarkdownEditor-FJtYn6Xx.js → MarkdownEditor-DOZy49fg.js} +160 -160
- package/dist/{WorkspaceLoadingState-BoFzsDji.js → WorkspaceLoadingState-CjXix_Fa.js} +22 -22
- package/dist/{WorkspaceProvider-CSwoKjTp.js → WorkspaceProvider-CRd7lb76.js} +833 -826
- package/dist/app-front.js +515 -504
- package/dist/testing.js +1 -1
- package/dist/workspace.d.ts +24 -4
- package/dist/workspace.js +5 -5
- package/package.json +4 -4
- package/dist/FileTree-DKzSeYJX.js +0 -289
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as W, useCallback as
|
|
3
|
-
import { ReactNodeViewRenderer as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { jsxs as S, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as W, useCallback as Y, useRef as A, useEffect as F, useMemo as j } from "react";
|
|
3
|
+
import { ReactNodeViewRenderer as tt, NodeViewWrapper as et, useEditor as rt, EditorContent as nt, useEditorState as it } from "@tiptap/react";
|
|
4
|
+
import at from "@tiptap/starter-kit";
|
|
5
|
+
import ot from "@tiptap/extension-underline";
|
|
6
|
+
import st from "@tiptap/extension-link";
|
|
7
7
|
import P from "@tiptap/extension-placeholder";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Table as
|
|
13
|
-
import { TableRow as
|
|
14
|
-
import { TableHeader as
|
|
15
|
-
import { TableCell as
|
|
16
|
-
import
|
|
17
|
-
import { c as
|
|
18
|
-
import { _ as O, aq as V, p as
|
|
19
|
-
import { uploadFile as
|
|
20
|
-
import
|
|
21
|
-
import { createLowlight as
|
|
22
|
-
import { Markdown as
|
|
23
|
-
import { BoldIcon as
|
|
24
|
-
import { Toolbar as
|
|
25
|
-
function
|
|
8
|
+
import lt from "@tiptap/extension-task-list";
|
|
9
|
+
import ct from "@tiptap/extension-task-item";
|
|
10
|
+
import ut from "@tiptap/extension-text-align";
|
|
11
|
+
import gt from "@tiptap/extension-highlight";
|
|
12
|
+
import { Table as dt } from "@tiptap/extension-table";
|
|
13
|
+
import { TableRow as ft } from "@tiptap/extension-table-row";
|
|
14
|
+
import { TableHeader as pt } from "@tiptap/extension-table-header";
|
|
15
|
+
import { TableCell as mt } from "@tiptap/extension-table-cell";
|
|
16
|
+
import ht from "@tiptap/extension-image";
|
|
17
|
+
import { c as E } from "./utils-B6yFEsav.js";
|
|
18
|
+
import { _ as O, aq as V, p as wt } from "./WorkspaceProvider-CRd7lb76.js";
|
|
19
|
+
import { uploadFile as kt } from "@hachej/boring-agent/front";
|
|
20
|
+
import bt from "@tiptap/extension-code-block-lowlight";
|
|
21
|
+
import { createLowlight as vt, common as It } from "lowlight";
|
|
22
|
+
import { Markdown as xt } from "@tiptap/markdown";
|
|
23
|
+
import { BoldIcon as yt, ItalicIcon as Lt, UnderlineIcon as At, StrikethroughIcon as Ct, Heading1Icon as Nt, Heading2Icon as Tt, Heading3Icon as $t, ListIcon as Mt, ListOrderedIcon as Rt, ListChecksIcon as Ut, QuoteIcon as Ht, CodeIcon as St, LinkIcon as Et, ImageIcon as Bt, HighlighterIcon as Dt, AlignLeftIcon as Ft, AlignCenterIcon as zt, AlignRightIcon as Wt, MinusIcon as jt, Loader2Icon as qt } from "lucide-react";
|
|
24
|
+
import { Toolbar as _t, Input as Kt, ToolbarButton as Pt, ToolbarSeparator as Ot } from "@hachej/boring-ui-kit";
|
|
25
|
+
function Vt(t) {
|
|
26
26
|
const e = O(), r = V(), [o, l] = W(0);
|
|
27
|
-
return { upload:
|
|
27
|
+
return { upload: Y(
|
|
28
28
|
async (c, a) => {
|
|
29
29
|
l((m) => m + 1);
|
|
30
30
|
try {
|
|
31
|
-
return await
|
|
31
|
+
return await kt(c, {
|
|
32
32
|
apiBaseUrl: e,
|
|
33
33
|
workspaceRequestId: r,
|
|
34
34
|
directory: (a == null ? void 0 : a.directory) ?? (t == null ? void 0 : t.directory),
|
|
@@ -42,7 +42,7 @@ function Ot(t) {
|
|
|
42
42
|
), uploading: o > 0 };
|
|
43
43
|
}
|
|
44
44
|
const q = 64, _ = 2e3;
|
|
45
|
-
function
|
|
45
|
+
function Xt(t) {
|
|
46
46
|
return t.replace(/\\/g, "\\\\").replace(/]/g, "\\]");
|
|
47
47
|
}
|
|
48
48
|
function D(t) {
|
|
@@ -56,7 +56,7 @@ function K(t) {
|
|
|
56
56
|
}
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
59
|
-
const X =
|
|
59
|
+
const X = ht.extend({
|
|
60
60
|
name: "image",
|
|
61
61
|
draggable: !0,
|
|
62
62
|
addOptions() {
|
|
@@ -72,11 +72,11 @@ const X = mt.extend({
|
|
|
72
72
|
alt: t.text
|
|
73
73
|
}),
|
|
74
74
|
renderMarkdown: (t) => {
|
|
75
|
-
var
|
|
76
|
-
const e = typeof ((
|
|
75
|
+
var C, v, y, i, g, k, L;
|
|
76
|
+
const e = typeof ((C = t.attrs) == null ? void 0 : C.src) == "string" ? t.attrs.src : "", r = typeof ((v = t.attrs) == null ? void 0 : v.alt) == "string" ? t.attrs.alt : "", o = typeof ((y = t.attrs) == null ? void 0 : y.title) == "string" ? t.attrs.title : "", l = K((i = t.attrs) == null ? void 0 : i.width), s = K((g = t.attrs) == null ? void 0 : g.height), c = ((k = t.attrs) == null ? void 0 : k.align) === "center" || ((L = t.attrs) == null ? void 0 : L.align) === "right" ? t.attrs.align : "left";
|
|
77
77
|
if (!l && !s && c === "left") {
|
|
78
|
-
const
|
|
79
|
-
return o ? `}")` : ``;
|
|
80
80
|
}
|
|
81
81
|
const m = `<img ${[
|
|
82
82
|
`src="${D(e)}"`,
|
|
@@ -129,48 +129,48 @@ const X = mt.extend({
|
|
|
129
129
|
};
|
|
130
130
|
},
|
|
131
131
|
addNodeView() {
|
|
132
|
-
return
|
|
132
|
+
return tt(Qt);
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
|
-
function
|
|
136
|
-
const l =
|
|
135
|
+
function Qt({ node: t, updateAttributes: e, selected: r, extension: o }) {
|
|
136
|
+
const l = A(null), s = A(null), [c, a] = W(!1), m = t.attrs.src ?? "", v = (o.options.resolveSrc ?? ((w) => w))(m), y = t.attrs.alt ?? "", i = t.attrs.title ?? void 0, g = t.attrs.width, k = t.attrs.align ?? "left";
|
|
137
137
|
F(() => {
|
|
138
138
|
if (!c) return;
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
142
|
-
const
|
|
143
|
-
e({ width: Math.round(
|
|
139
|
+
const w = (N) => {
|
|
140
|
+
const I = s.current;
|
|
141
|
+
if (!I) return;
|
|
142
|
+
const H = N.clientX - I.x, h = Math.max(q, Math.min(_, I.width + H));
|
|
143
|
+
e({ width: Math.round(h) });
|
|
144
144
|
}, b = () => {
|
|
145
145
|
s.current = null, a(!1);
|
|
146
146
|
};
|
|
147
|
-
return window.addEventListener("pointermove",
|
|
148
|
-
window.removeEventListener("pointermove",
|
|
147
|
+
return window.addEventListener("pointermove", w), window.addEventListener("pointerup", b), window.addEventListener("pointercancel", b), () => {
|
|
148
|
+
window.removeEventListener("pointermove", w), window.removeEventListener("pointerup", b), window.removeEventListener("pointercancel", b);
|
|
149
149
|
};
|
|
150
150
|
}, [c, e]);
|
|
151
|
-
const
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
const b = (
|
|
155
|
-
s.current = { x:
|
|
151
|
+
const L = (w) => {
|
|
152
|
+
var I;
|
|
153
|
+
w.preventDefault(), w.stopPropagation();
|
|
154
|
+
const b = (I = l.current) == null ? void 0 : I.querySelector("img"), N = g ?? (b == null ? void 0 : b.getBoundingClientRect().width) ?? 320;
|
|
155
|
+
s.current = { x: w.clientX, width: N }, a(!0);
|
|
156
156
|
};
|
|
157
|
-
return /* @__PURE__ */
|
|
158
|
-
|
|
157
|
+
return /* @__PURE__ */ S(
|
|
158
|
+
et,
|
|
159
159
|
{
|
|
160
160
|
ref: l,
|
|
161
161
|
"data-resizable-image": "",
|
|
162
162
|
"data-selected": r ? "true" : void 0,
|
|
163
|
-
className:
|
|
163
|
+
className: E(
|
|
164
164
|
"relative block max-w-full align-baseline",
|
|
165
165
|
"[&>img]:block [&>img]:max-w-full [&>img]:h-auto [&>img]:rounded-md",
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
k === "left" && "mr-auto",
|
|
167
|
+
k === "center" && "mx-auto",
|
|
168
|
+
k === "right" && "ml-auto",
|
|
169
169
|
r && "ring-2 ring-[color:var(--accent)] ring-offset-1 ring-offset-background"
|
|
170
170
|
),
|
|
171
171
|
style: { width: g ? `${g}px` : void 0 },
|
|
172
172
|
children: [
|
|
173
|
-
/* @__PURE__ */ n("img", { src: v, alt:
|
|
173
|
+
/* @__PURE__ */ n("img", { src: v, alt: y, title: i, draggable: !1 }),
|
|
174
174
|
/* @__PURE__ */ n(
|
|
175
175
|
"span",
|
|
176
176
|
{
|
|
@@ -180,8 +180,8 @@ function Xt({ node: t, updateAttributes: e, selected: r, extension: o }) {
|
|
|
180
180
|
"aria-valuemin": q,
|
|
181
181
|
"aria-valuemax": _,
|
|
182
182
|
"data-testid": "resize-handle",
|
|
183
|
-
onPointerDown:
|
|
184
|
-
className:
|
|
183
|
+
onPointerDown: L,
|
|
184
|
+
className: E(
|
|
185
185
|
"absolute right-0 bottom-0 h-3 w-3 translate-x-1/2 translate-y-1/2 cursor-nwse-resize",
|
|
186
186
|
"rounded-full border border-background bg-[color:var(--accent)] shadow",
|
|
187
187
|
"opacity-0 transition-opacity duration-150 ease-out",
|
|
@@ -193,7 +193,7 @@ function Xt({ node: t, updateAttributes: e, selected: r, extension: o }) {
|
|
|
193
193
|
}
|
|
194
194
|
);
|
|
195
195
|
}
|
|
196
|
-
const
|
|
196
|
+
const Zt = vt(It), Gt = [
|
|
197
197
|
/<script[\s>][\s\S]*?<\/script>/gi,
|
|
198
198
|
/<iframe[\s>][\s\S]*?<\/iframe>/gi,
|
|
199
199
|
/\s+on\w+\s*=\s*["'][^"']*["']/gi,
|
|
@@ -201,42 +201,42 @@ const Qt = bt(vt), Zt = [
|
|
|
201
201
|
/href\s*=\s*["']?\s*javascript:[^"'\s>]*/gi,
|
|
202
202
|
/src\s*=\s*["']?\s*javascript:[^"'\s>]*/gi
|
|
203
203
|
];
|
|
204
|
-
function
|
|
204
|
+
function Jt(t) {
|
|
205
205
|
let e = t;
|
|
206
|
-
for (const r of
|
|
206
|
+
for (const r of Gt)
|
|
207
207
|
e = e.replace(r, "");
|
|
208
208
|
return e;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function Yt(t) {
|
|
211
211
|
const r = t.replace(/```[\s\S]*?```/g, " ").replace(/`[^`]*`/g, " ").replace(/^\s{0,3}#{1,6}\s+/gm, "").replace(/!\[[^\]]*\]\([^)]*\)/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/<[^>]+>/g, " ").replace(/^\s{0,3}[-*_]{3,}\s*$/gm, " ").replace(/^\s{0,3}(?:[-*+]\s+|\d+[.)]\s+|>\s?)/gm, "").replace(/^\s{0,3}\|?(?:\s*:?-+:?\s*\|)+\s*$/gm, " ").replace(/\|/g, " ").replace(/[*_~>#]/g, " ").match(/\b[\p{L}\p{N}']+\b/gu);
|
|
212
212
|
return (r == null ? void 0 : r.length) ?? 0;
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function te(t) {
|
|
215
215
|
return `${t} word${t === 1 ? "" : "s"}`;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function ee(t) {
|
|
218
218
|
return /^(?:[a-z][a-z0-9+.-]*:|\/|#)/i.test(t);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function re(t, e) {
|
|
221
221
|
return !(t === "" && !e);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ne(t, e) {
|
|
224
224
|
const r = t.match(/^([^?#]*)([?#].*)?$/), o = (r == null ? void 0 : r[1]) ?? t, l = (r == null ? void 0 : r[2]) ?? "", s = e != null && e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", c = `${s ? `${s}/` : ""}${o}`.split("/"), a = [];
|
|
225
225
|
for (const m of c)
|
|
226
226
|
!m || m === "." || (m === ".." ? a.pop() : a.push(m));
|
|
227
227
|
return `${a.join("/")}${l}`;
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
if (!t ||
|
|
231
|
-
const l =
|
|
229
|
+
function ie(t, e, r, o) {
|
|
230
|
+
if (!t || ee(t)) return t;
|
|
231
|
+
const l = ne(t, e), s = r.replace(/\/$/, ""), c = new URLSearchParams({ path: l });
|
|
232
232
|
return o && c.set("workspaceId", o), `${s}/api/v1/files/raw?${c.toString()}`;
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function ae(t) {
|
|
235
235
|
return /^(?:[a-z][a-z0-9+.-]*:|\/\/|\/|#|\?)/i.test(t);
|
|
236
236
|
}
|
|
237
237
|
function Q(t, e) {
|
|
238
238
|
const r = t.trim();
|
|
239
|
-
if (!r ||
|
|
239
|
+
if (!r || ae(r)) return null;
|
|
240
240
|
const o = r.split(/[?#]/, 1)[0];
|
|
241
241
|
if (!o) return null;
|
|
242
242
|
const l = e != null && e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", s = `${l ? `${l}/` : ""}${o}`.split("/"), c = [];
|
|
@@ -251,17 +251,17 @@ function Q(t, e) {
|
|
|
251
251
|
}
|
|
252
252
|
return c.join("/") || null;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function oe(t) {
|
|
255
255
|
return t.button === 0 && !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey;
|
|
256
256
|
}
|
|
257
|
-
const
|
|
258
|
-
|
|
257
|
+
const se = [
|
|
258
|
+
at.configure({
|
|
259
259
|
codeBlock: !1,
|
|
260
260
|
link: !1,
|
|
261
261
|
underline: !1
|
|
262
262
|
}),
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
ot,
|
|
264
|
+
st.configure({
|
|
265
265
|
openOnClick: !0,
|
|
266
266
|
autolink: !0,
|
|
267
267
|
linkOnPaste: !0,
|
|
@@ -272,24 +272,24 @@ const oe = [
|
|
|
272
272
|
P.configure({
|
|
273
273
|
placeholder: "Start writing..."
|
|
274
274
|
}),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
lt,
|
|
276
|
+
ct.configure({ nested: !0 }),
|
|
277
|
+
ut.configure({
|
|
278
278
|
types: ["heading", "paragraph"]
|
|
279
279
|
}),
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
gt,
|
|
281
|
+
dt.configure({
|
|
282
282
|
resizable: !0
|
|
283
283
|
}),
|
|
284
|
-
dt,
|
|
285
284
|
ft,
|
|
286
285
|
pt,
|
|
286
|
+
mt,
|
|
287
287
|
X.configure({
|
|
288
288
|
inline: !1,
|
|
289
289
|
allowBase64: !0
|
|
290
290
|
}),
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
bt.configure({ lowlight: Zt }),
|
|
292
|
+
xt.configure({
|
|
293
293
|
markedOptions: {
|
|
294
294
|
gfm: !0,
|
|
295
295
|
breaks: !1,
|
|
@@ -299,7 +299,7 @@ const oe = [
|
|
|
299
299
|
];
|
|
300
300
|
function f({ onClick: t, active: e, disabled: r, title: o, children: l }) {
|
|
301
301
|
return /* @__PURE__ */ n(
|
|
302
|
-
|
|
302
|
+
Pt,
|
|
303
303
|
{
|
|
304
304
|
type: "button",
|
|
305
305
|
size: "icon-xs",
|
|
@@ -307,7 +307,7 @@ function f({ onClick: t, active: e, disabled: r, title: o, children: l }) {
|
|
|
307
307
|
disabled: r,
|
|
308
308
|
title: o,
|
|
309
309
|
"aria-pressed": e,
|
|
310
|
-
className:
|
|
310
|
+
className: E(
|
|
311
311
|
"text-muted-foreground/70",
|
|
312
312
|
e && "bg-[color:var(--accent-soft)] text-[color:var(--accent)]"
|
|
313
313
|
),
|
|
@@ -316,19 +316,19 @@ function f({ onClick: t, active: e, disabled: r, title: o, children: l }) {
|
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
318
|
function T() {
|
|
319
|
-
return /* @__PURE__ */ n(
|
|
319
|
+
return /* @__PURE__ */ n(Ot, { className: "mx-2 h-3.5" });
|
|
320
320
|
}
|
|
321
321
|
function z(t) {
|
|
322
322
|
const e = t.trim().toLowerCase();
|
|
323
323
|
return !e.startsWith("javascript:") && !e.startsWith("data:text/html");
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function le(t) {
|
|
326
326
|
return new Promise((e, r) => {
|
|
327
327
|
const o = new FileReader();
|
|
328
328
|
o.onload = () => e(o.result), o.onerror = () => r(o.error ?? new Error("Read failed")), o.readAsDataURL(t);
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function ce(t) {
|
|
332
332
|
if (!t) return null;
|
|
333
333
|
for (const e of Array.from(t.files ?? []))
|
|
334
334
|
if (e.type.startsWith("image/")) return e;
|
|
@@ -339,7 +339,7 @@ function le(t) {
|
|
|
339
339
|
}
|
|
340
340
|
return null;
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function ue({
|
|
343
343
|
editor: t,
|
|
344
344
|
onInsertImage: e,
|
|
345
345
|
rawMode: r,
|
|
@@ -354,7 +354,7 @@ function ce({
|
|
|
354
354
|
}
|
|
355
355
|
t.chain().focus().setTextAlign(i).run();
|
|
356
356
|
}
|
|
357
|
-
}, c =
|
|
357
|
+
}, c = A(null), a = it({
|
|
358
358
|
editor: t,
|
|
359
359
|
selector: ({ editor: i }) => i ? {
|
|
360
360
|
bold: i.isActive("bold"),
|
|
@@ -380,73 +380,73 @@ function ce({
|
|
|
380
380
|
const m = () => {
|
|
381
381
|
const i = window.prompt("URL:");
|
|
382
382
|
i && z(i) && t.chain().focus().extendMarkRange("link").setLink({ href: i }).run();
|
|
383
|
-
},
|
|
383
|
+
}, C = () => {
|
|
384
384
|
const i = window.prompt("Image URL:");
|
|
385
385
|
i && z(i) && t.chain().focus().setImage({ src: i }).run();
|
|
386
386
|
}, v = (i) => {
|
|
387
387
|
var g;
|
|
388
388
|
if (i != null && i.shiftKey) {
|
|
389
|
-
|
|
389
|
+
C();
|
|
390
390
|
return;
|
|
391
391
|
}
|
|
392
392
|
(g = c.current) == null || g.click();
|
|
393
|
-
},
|
|
394
|
-
var
|
|
395
|
-
const g = (
|
|
393
|
+
}, y = async (i) => {
|
|
394
|
+
var k;
|
|
395
|
+
const g = (k = i.target.files) == null ? void 0 : k[0];
|
|
396
396
|
i.target.value = "", !(!g || !g.type.startsWith("image/")) && await e(g);
|
|
397
397
|
};
|
|
398
|
-
return /* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleBold().run(), active: a.bold, title: "Bold", children: /* @__PURE__ */ n(
|
|
400
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleItalic().run(), active: a.italic, title: "Italic", children: /* @__PURE__ */ n(
|
|
401
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleUnderline().run(), active: a.underline, title: "Underline", children: /* @__PURE__ */ n(
|
|
402
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleStrike().run(), active: a.strike, title: "Strikethrough", children: /* @__PURE__ */ n(
|
|
398
|
+
return /* @__PURE__ */ S(_t, { className: "border-b border-border/60 bg-background px-3 py-1.5", "aria-label": "Formatting toolbar", children: [
|
|
399
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleBold().run(), active: a.bold, title: "Bold", children: /* @__PURE__ */ n(yt, { className: "h-4 w-4" }) }),
|
|
400
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleItalic().run(), active: a.italic, title: "Italic", children: /* @__PURE__ */ n(Lt, { className: "h-4 w-4" }) }),
|
|
401
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleUnderline().run(), active: a.underline, title: "Underline", children: /* @__PURE__ */ n(At, { className: "h-4 w-4" }) }),
|
|
402
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleStrike().run(), active: a.strike, title: "Strikethrough", children: /* @__PURE__ */ n(Ct, { className: "h-4 w-4" }) }),
|
|
403
403
|
/* @__PURE__ */ n(T, {}),
|
|
404
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 1 }).run(), active: a.h1, title: "Heading 1", children: /* @__PURE__ */ n(
|
|
405
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 2 }).run(), active: a.h2, title: "Heading 2", children: /* @__PURE__ */ n(
|
|
406
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 3 }).run(), active: a.h3, title: "Heading 3", children: /* @__PURE__ */ n(
|
|
404
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 1 }).run(), active: a.h1, title: "Heading 1", children: /* @__PURE__ */ n(Nt, { className: "h-4 w-4" }) }),
|
|
405
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 2 }).run(), active: a.h2, title: "Heading 2", children: /* @__PURE__ */ n(Tt, { className: "h-4 w-4" }) }),
|
|
406
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHeading({ level: 3 }).run(), active: a.h3, title: "Heading 3", children: /* @__PURE__ */ n($t, { className: "h-4 w-4" }) }),
|
|
407
407
|
/* @__PURE__ */ n(T, {}),
|
|
408
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleBulletList().run(), active: a.bulletList, title: "Bullet list", children: /* @__PURE__ */ n(
|
|
409
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleOrderedList().run(), active: a.orderedList, title: "Ordered list", children: /* @__PURE__ */ n(
|
|
408
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleBulletList().run(), active: a.bulletList, title: "Bullet list", children: /* @__PURE__ */ n(Mt, { className: "h-4 w-4" }) }),
|
|
409
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleOrderedList().run(), active: a.orderedList, title: "Ordered list", children: /* @__PURE__ */ n(Rt, { className: "h-4 w-4" }) }),
|
|
410
410
|
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleTaskList().run(), active: a.taskList, title: "Task list", children: /* @__PURE__ */ n(Ut, { className: "h-4 w-4" }) }),
|
|
411
411
|
/* @__PURE__ */ n(T, {}),
|
|
412
412
|
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleBlockquote().run(), active: a.blockquote, title: "Quote", children: /* @__PURE__ */ n(Ht, { className: "h-4 w-4" }) }),
|
|
413
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleCodeBlock().run(), active: a.codeBlock, title: "Code block", children: /* @__PURE__ */ n(
|
|
414
|
-
/* @__PURE__ */ n(f, { onClick: m, active: a.link, title: "Link", children: /* @__PURE__ */ n(
|
|
413
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleCodeBlock().run(), active: a.codeBlock, title: "Code block", children: /* @__PURE__ */ n(St, { className: "h-4 w-4" }) }),
|
|
414
|
+
/* @__PURE__ */ n(f, { onClick: m, active: a.link, title: "Link", children: /* @__PURE__ */ n(Et, { className: "h-4 w-4" }) }),
|
|
415
415
|
/* @__PURE__ */ n(
|
|
416
416
|
f,
|
|
417
417
|
{
|
|
418
418
|
onClick: v,
|
|
419
419
|
title: "Image (click to upload, Shift+click for URL)",
|
|
420
|
-
children: /* @__PURE__ */ n(
|
|
420
|
+
children: /* @__PURE__ */ n(Bt, { className: "h-4 w-4" })
|
|
421
421
|
}
|
|
422
422
|
),
|
|
423
423
|
/* @__PURE__ */ n(
|
|
424
|
-
|
|
424
|
+
Kt,
|
|
425
425
|
{
|
|
426
426
|
ref: c,
|
|
427
427
|
"data-testid": "image-file-input",
|
|
428
428
|
type: "file",
|
|
429
429
|
accept: "image/*",
|
|
430
430
|
className: "hidden",
|
|
431
|
-
onChange:
|
|
431
|
+
onChange: y
|
|
432
432
|
}
|
|
433
433
|
),
|
|
434
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHighlight().run(), active: a.highlight, title: "Highlight", children: /* @__PURE__ */ n(
|
|
434
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().toggleHighlight().run(), active: a.highlight, title: "Highlight", children: /* @__PURE__ */ n(Dt, { className: "h-4 w-4" }) }),
|
|
435
435
|
/* @__PURE__ */ n(T, {}),
|
|
436
|
-
/* @__PURE__ */ n(f, { onClick: () => s("left"), active: a.alignLeft, title: "Align left", children: /* @__PURE__ */ n(
|
|
437
|
-
/* @__PURE__ */ n(f, { onClick: () => s("center"), active: a.alignCenter, title: "Center align", children: /* @__PURE__ */ n(
|
|
438
|
-
/* @__PURE__ */ n(f, { onClick: () => s("right"), active: a.alignRight, title: "Align right", children: /* @__PURE__ */ n(
|
|
436
|
+
/* @__PURE__ */ n(f, { onClick: () => s("left"), active: a.alignLeft, title: "Align left", children: /* @__PURE__ */ n(Ft, { className: "h-4 w-4" }) }),
|
|
437
|
+
/* @__PURE__ */ n(f, { onClick: () => s("center"), active: a.alignCenter, title: "Center align", children: /* @__PURE__ */ n(zt, { className: "h-4 w-4" }) }),
|
|
438
|
+
/* @__PURE__ */ n(f, { onClick: () => s("right"), active: a.alignRight, title: "Align right", children: /* @__PURE__ */ n(Wt, { className: "h-4 w-4" }) }),
|
|
439
439
|
/* @__PURE__ */ n(T, {}),
|
|
440
|
-
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().setHorizontalRule().run(), title: "Horizontal rule", children: /* @__PURE__ */ n(
|
|
440
|
+
/* @__PURE__ */ n(f, { onClick: () => t.chain().focus().setHorizontalRule().run(), title: "Horizontal rule", children: /* @__PURE__ */ n(jt, { className: "h-4 w-4" }) }),
|
|
441
441
|
/* @__PURE__ */ n(T, {}),
|
|
442
|
-
l && /* @__PURE__ */
|
|
442
|
+
l && /* @__PURE__ */ S(
|
|
443
443
|
"span",
|
|
444
444
|
{
|
|
445
445
|
role: "status",
|
|
446
446
|
"aria-live": "polite",
|
|
447
447
|
className: "ml-auto flex items-center gap-1.5 text-[11px] text-muted-foreground/80",
|
|
448
448
|
children: [
|
|
449
|
-
/* @__PURE__ */ n(
|
|
449
|
+
/* @__PURE__ */ n(qt, { className: "h-3 w-3 animate-spin", "aria-hidden": !0 }),
|
|
450
450
|
"Uploading…"
|
|
451
451
|
]
|
|
452
452
|
}
|
|
@@ -462,7 +462,7 @@ function ce({
|
|
|
462
462
|
)
|
|
463
463
|
] });
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function Ee({
|
|
466
466
|
content: t,
|
|
467
467
|
onChange: e,
|
|
468
468
|
readOnly: r = !1,
|
|
@@ -470,89 +470,89 @@ function Se({
|
|
|
470
470
|
className: l,
|
|
471
471
|
documentPath: s
|
|
472
472
|
}) {
|
|
473
|
-
const c = O(), a = V(), { upload: m, uploading:
|
|
473
|
+
const c = O(), a = V(), { upload: m, uploading: C } = Vt(), [v, y] = W(!1), i = j(() => {
|
|
474
474
|
const u = X.configure({
|
|
475
475
|
inline: !1,
|
|
476
476
|
allowBase64: !0,
|
|
477
|
-
resolveSrc: (p) =>
|
|
478
|
-
}), d =
|
|
477
|
+
resolveSrc: (p) => ie(p, s, c, a)
|
|
478
|
+
}), d = se.map((p) => p.name === "image" ? u : p);
|
|
479
479
|
return o ? [
|
|
480
480
|
...d.filter((p) => p.name !== "placeholder"),
|
|
481
481
|
P.configure({ placeholder: o })
|
|
482
482
|
] : d;
|
|
483
|
-
}, [c, s, o, a]), g =
|
|
483
|
+
}, [c, s, o, a]), g = A(e);
|
|
484
484
|
g.current = e;
|
|
485
|
-
const
|
|
485
|
+
const k = A(!1), L = A(t), w = A(null), b = j(() => Yt(t), [t]), N = A(async () => {
|
|
486
486
|
});
|
|
487
|
-
|
|
488
|
-
const d =
|
|
487
|
+
N.current = async (u) => {
|
|
488
|
+
const d = w.current;
|
|
489
489
|
if (!d) return;
|
|
490
490
|
let p;
|
|
491
491
|
try {
|
|
492
|
-
p = await
|
|
492
|
+
p = await le(u);
|
|
493
493
|
} catch {
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
|
-
const
|
|
497
|
-
d.chain().focus().setImage(
|
|
496
|
+
const x = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `pending-${Date.now()}-${Math.random().toString(36).slice(2)}`, G = { src: p, alt: u.name, pendingUploadId: x };
|
|
497
|
+
d.chain().focus().setImage(G).run();
|
|
498
498
|
try {
|
|
499
|
-
const { url: $ } = await m(u, { sourcePath: s }), M =
|
|
499
|
+
const { url: $ } = await m(u, { sourcePath: s }), M = w.current;
|
|
500
500
|
if (!M || M.isDestroyed) return;
|
|
501
|
-
M.commands.command(({ tr: B, state:
|
|
501
|
+
M.commands.command(({ tr: B, state: R }) => (R.doc.descendants((U, J) => (U.type.name === "image" && U.attrs.pendingUploadId === x && B.setNodeMarkup(J, void 0, { ...U.attrs, src: $, pendingUploadId: null }), !0)), !0));
|
|
502
502
|
} catch {
|
|
503
|
-
const $ =
|
|
503
|
+
const $ = w.current;
|
|
504
504
|
if (!$ || $.isDestroyed) return;
|
|
505
|
-
$.commands.command(({ tr: M, state: B }) => (B.doc.descendants((
|
|
505
|
+
$.commands.command(({ tr: M, state: B }) => (B.doc.descendants((R, U) => (R.type.name === "image" && R.attrs.pendingUploadId === x && M.setNodeMarkup(U, void 0, { ...R.attrs, pendingUploadId: null }), !0)), !0));
|
|
506
506
|
}
|
|
507
507
|
};
|
|
508
|
-
const
|
|
508
|
+
const I = t || { type: "doc", content: [{ type: "paragraph" }] }, H = t ? "markdown" : "json", h = rt({
|
|
509
509
|
extensions: i,
|
|
510
|
-
content:
|
|
511
|
-
contentType:
|
|
510
|
+
content: I,
|
|
511
|
+
contentType: H,
|
|
512
512
|
editable: !r,
|
|
513
513
|
editorProps: {
|
|
514
514
|
attributes: {
|
|
515
515
|
class: "tiptap-prose max-w-[68ch] px-8 py-6 focus:outline-none min-h-[200px]"
|
|
516
516
|
},
|
|
517
|
-
transformPastedHTML:
|
|
517
|
+
transformPastedHTML: Jt,
|
|
518
518
|
handlePaste: (u, d) => {
|
|
519
519
|
if (r) return !1;
|
|
520
|
-
const p =
|
|
521
|
-
return p ? (d.preventDefault(),
|
|
520
|
+
const p = ce(d.clipboardData);
|
|
521
|
+
return p ? (d.preventDefault(), N.current(p), !0) : !1;
|
|
522
522
|
}
|
|
523
523
|
},
|
|
524
524
|
onUpdate: ({ editor: u }) => {
|
|
525
|
-
var p,
|
|
526
|
-
if (
|
|
525
|
+
var p, x;
|
|
526
|
+
if (k.current) return;
|
|
527
527
|
const d = ((p = u.getMarkdown) == null ? void 0 : p.call(u)) ?? u.getHTML();
|
|
528
|
-
|
|
528
|
+
L.current = d, re(d, u.isFocused) && ((x = g.current) == null || x.call(g, d));
|
|
529
529
|
}
|
|
530
530
|
});
|
|
531
|
-
|
|
531
|
+
w.current = h, F(() => {
|
|
532
532
|
!h || h.isDestroyed || h.setEditable(!r);
|
|
533
533
|
}, [h, r]), F(() => {
|
|
534
534
|
var d;
|
|
535
|
-
!h || h.isDestroyed || (((d = h.getMarkdown) == null ? void 0 : d.call(h)) ?? h.getHTML()) === t || (
|
|
535
|
+
!h || h.isDestroyed || t === L.current || (((d = h.getMarkdown) == null ? void 0 : d.call(h)) ?? h.getHTML()) === t || (k.current = !0, h.commands.setContent(I, { contentType: H }), k.current = !1, L.current = t);
|
|
536
536
|
}, [h, t]);
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
537
|
+
const Z = (u) => {
|
|
538
|
+
if (!oe(u.nativeEvent)) return;
|
|
539
539
|
const d = u.target instanceof Element ? u.target.closest("a[href]") : null, p = d == null ? void 0 : d.getAttribute("href");
|
|
540
540
|
if (!p) return;
|
|
541
|
-
const
|
|
542
|
-
|
|
541
|
+
const x = Q(p, s);
|
|
542
|
+
x && (u.preventDefault(), u.stopPropagation(), wt({ kind: "openFile", params: { path: x } }));
|
|
543
543
|
};
|
|
544
|
-
return /* @__PURE__ */
|
|
544
|
+
return /* @__PURE__ */ S("div", { className: E("flex h-full min-h-0 flex-col overflow-hidden", l), children: [
|
|
545
545
|
!r && /* @__PURE__ */ n(
|
|
546
|
-
|
|
546
|
+
ue,
|
|
547
547
|
{
|
|
548
548
|
editor: h,
|
|
549
|
-
onInsertImage: (u) =>
|
|
549
|
+
onInsertImage: (u) => N.current(u),
|
|
550
550
|
rawMode: v,
|
|
551
|
-
onToggleRawMode: () =>
|
|
552
|
-
uploading:
|
|
551
|
+
onToggleRawMode: () => y((u) => !u),
|
|
552
|
+
uploading: C
|
|
553
553
|
}
|
|
554
554
|
),
|
|
555
|
-
/* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-auto", onClickCapture:
|
|
555
|
+
/* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-auto", onClickCapture: Z, children: v && !r ? /* @__PURE__ */ n(
|
|
556
556
|
"textarea",
|
|
557
557
|
{
|
|
558
558
|
"aria-label": "Raw markdown",
|
|
@@ -566,17 +566,17 @@ function Se({
|
|
|
566
566
|
return (d = g.current) == null ? void 0 : d.call(g, u.target.value);
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
) : /* @__PURE__ */ n(
|
|
570
|
-
/* @__PURE__ */ n("div", { className: "border-t border-border/60 px-4 py-2 text-right text-xs text-muted-foreground", "data-testid": "markdown-word-count", children:
|
|
569
|
+
) : /* @__PURE__ */ n(nt, { editor: h }) }),
|
|
570
|
+
/* @__PURE__ */ n("div", { className: "border-t border-border/60 px-4 py-2 text-right text-xs text-muted-foreground", "data-testid": "markdown-word-count", children: te(b) })
|
|
571
571
|
] });
|
|
572
572
|
}
|
|
573
573
|
export {
|
|
574
|
-
|
|
575
|
-
|
|
574
|
+
Ee as MarkdownEditor,
|
|
575
|
+
Yt as countMarkdownWords,
|
|
576
576
|
z as isSafeUrl,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
577
|
+
re as isUserEditedChange,
|
|
578
|
+
ie as rawFileUrlForMarkdownImage,
|
|
579
|
+
le as readFileAsDataUrl,
|
|
580
|
+
Jt as sanitizeHtml,
|
|
581
581
|
Q as workspaceFilePathForMarkdownLink
|
|
582
582
|
};
|