@hachej/boring-workspace 0.1.27 → 0.1.29
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-DDO-RrZ8.js → FileTree-DUxjUbxL.js} +1 -1
- package/dist/{MarkdownEditor-Bx5InUeG.js → MarkdownEditor-DPBSzTBz.js} +91 -85
- package/dist/{WorkspaceLoadingState-DuLadpix.js → WorkspaceLoadingState-DJF_4S4_.js} +1 -1
- package/dist/{WorkspaceProvider-CpMMNtLh.js → WorkspaceProvider-0V-2x7AH.js} +630 -641
- package/dist/app-front.js +450 -446
- package/dist/testing.js +1 -1
- package/dist/workspace.js +5 -5
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { jsx as u, jsxs as C } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef as I, useEffect as y, useMemo as A, useCallback as k, createContext as _, useContext as z } from "react";
|
|
3
3
|
import { Tree as K } from "react-arborist";
|
|
4
4
|
import { FolderOpenIcon as S, FolderIcon as J, ChevronRightIcon as Q, Loader2Icon as U } from "lucide-react";
|
|
5
|
-
import { K as X } from "./WorkspaceProvider-
|
|
5
|
+
import { K as X } from "./WorkspaceProvider-0V-2x7AH.js";
|
|
6
6
|
import { Input as Y } from "@hachej/boring-ui-kit";
|
|
7
7
|
import { c as x } from "./utils-B6yFEsav.js";
|
|
8
8
|
import { createDragDropManager as Z } from "dnd-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as H, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as D, useCallback as K, useRef as L, useEffect as E, useMemo as Q } from "react";
|
|
3
3
|
import { ReactNodeViewRenderer as Z, NodeViewWrapper as G, useEditor as J, EditorContent as Y, useEditorState as tt } from "@tiptap/react";
|
|
4
4
|
import et from "@tiptap/starter-kit";
|
|
5
5
|
import rt from "@tiptap/extension-underline";
|
|
@@ -8,25 +8,25 @@ import q from "@tiptap/extension-placeholder";
|
|
|
8
8
|
import nt from "@tiptap/extension-task-list";
|
|
9
9
|
import at from "@tiptap/extension-task-item";
|
|
10
10
|
import ot from "@tiptap/extension-text-align";
|
|
11
|
-
import
|
|
12
|
-
import { Table as
|
|
11
|
+
import st from "@tiptap/extension-highlight";
|
|
12
|
+
import { Table as lt } from "@tiptap/extension-table";
|
|
13
13
|
import { TableRow as ct } from "@tiptap/extension-table-row";
|
|
14
14
|
import { TableHeader as ut } from "@tiptap/extension-table-header";
|
|
15
15
|
import { TableCell as gt } from "@tiptap/extension-table-cell";
|
|
16
16
|
import dt from "@tiptap/extension-image";
|
|
17
|
-
import { c as
|
|
18
|
-
import { _ as j, aq as _ } from "./WorkspaceProvider-
|
|
17
|
+
import { c as S } from "./utils-B6yFEsav.js";
|
|
18
|
+
import { _ as j, aq as _ } from "./WorkspaceProvider-0V-2x7AH.js";
|
|
19
19
|
import { uploadFile as ft } from "@hachej/boring-agent/front";
|
|
20
20
|
import mt from "@tiptap/extension-code-block-lowlight";
|
|
21
21
|
import { createLowlight as pt, common as ht } from "lowlight";
|
|
22
22
|
import { Markdown as wt } from "@tiptap/markdown";
|
|
23
|
-
import { BoldIcon as kt, ItalicIcon as vt, UnderlineIcon as bt, StrikethroughIcon as It, Heading1Icon as At, Heading2Icon as yt, Heading3Icon as Lt, ListIcon as xt, ListOrderedIcon as Nt, ListChecksIcon as Ct, QuoteIcon as Tt, CodeIcon as Mt, LinkIcon as Rt, ImageIcon as
|
|
23
|
+
import { BoldIcon as kt, ItalicIcon as vt, UnderlineIcon as bt, StrikethroughIcon as It, Heading1Icon as At, Heading2Icon as yt, Heading3Icon as Lt, ListIcon as xt, ListOrderedIcon as Nt, ListChecksIcon as Ct, QuoteIcon as Tt, CodeIcon as Mt, LinkIcon as Rt, ImageIcon as Ut, HighlighterIcon as Ht, AlignLeftIcon as St, AlignCenterIcon as $t, AlignRightIcon as Bt, MinusIcon as Et, Loader2Icon as Dt } from "lucide-react";
|
|
24
24
|
import { Toolbar as Ft, Input as zt, ToolbarButton as Wt, ToolbarSeparator as Pt } from "@hachej/boring-ui-kit";
|
|
25
25
|
function qt(t) {
|
|
26
|
-
const r = j(), i = _(), [a,
|
|
26
|
+
const r = j(), i = _(), [a, l] = D(0);
|
|
27
27
|
return { upload: K(
|
|
28
28
|
async (g, o) => {
|
|
29
|
-
|
|
29
|
+
l((p) => p + 1);
|
|
30
30
|
try {
|
|
31
31
|
return await ft(g, {
|
|
32
32
|
apiBaseUrl: r,
|
|
@@ -35,7 +35,7 @@ function qt(t) {
|
|
|
35
35
|
sourcePath: o == null ? void 0 : o.sourcePath
|
|
36
36
|
});
|
|
37
37
|
} finally {
|
|
38
|
-
|
|
38
|
+
l((p) => p - 1);
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
[r, i, t == null ? void 0 : t.directory]
|
|
@@ -73,8 +73,8 @@ const O = dt.extend({
|
|
|
73
73
|
}),
|
|
74
74
|
renderMarkdown: (t) => {
|
|
75
75
|
var y, b, A, n, c, k, I;
|
|
76
|
-
const r = typeof ((y = t.attrs) == null ? void 0 : y.src) == "string" ? t.attrs.src : "", i = typeof ((b = t.attrs) == null ? void 0 : b.alt) == "string" ? t.attrs.alt : "", a = typeof ((A = t.attrs) == null ? void 0 : A.title) == "string" ? t.attrs.title : "",
|
|
77
|
-
if (!
|
|
76
|
+
const r = typeof ((y = t.attrs) == null ? void 0 : y.src) == "string" ? t.attrs.src : "", i = typeof ((b = t.attrs) == null ? void 0 : b.alt) == "string" ? t.attrs.alt : "", a = typeof ((A = t.attrs) == null ? void 0 : A.title) == "string" ? t.attrs.title : "", l = W((n = t.attrs) == null ? void 0 : n.width), s = W((c = t.attrs) == null ? void 0 : c.height), g = ((k = t.attrs) == null ? void 0 : k.align) === "center" || ((I = t.attrs) == null ? void 0 : I.align) === "right" ? t.attrs.align : "left";
|
|
77
|
+
if (!l && !s && g === "left") {
|
|
78
78
|
const h = jt(i);
|
|
79
79
|
return a ? `}")` : ``;
|
|
80
80
|
}
|
|
@@ -82,8 +82,8 @@ const O = dt.extend({
|
|
|
82
82
|
`src="${B(r)}"`,
|
|
83
83
|
i ? `alt="${B(i)}"` : null,
|
|
84
84
|
a ? `title="${B(a)}"` : null,
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
l ? `width="${l}"` : null,
|
|
86
|
+
s ? `height="${s}"` : null
|
|
87
87
|
].filter(Boolean).join(" ")} />`;
|
|
88
88
|
return g === "center" || g === "right" ? `<p align="${g}">${p}</p>` : p;
|
|
89
89
|
},
|
|
@@ -96,13 +96,13 @@ const O = dt.extend({
|
|
|
96
96
|
parseHTML: (i) => {
|
|
97
97
|
const a = i.getAttribute("width");
|
|
98
98
|
if (a) {
|
|
99
|
-
const
|
|
100
|
-
return Number.isFinite(
|
|
99
|
+
const s = parseInt(a, 10);
|
|
100
|
+
return Number.isFinite(s) ? s : null;
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
const
|
|
105
|
-
return Number.isFinite(
|
|
102
|
+
const l = i.style.width;
|
|
103
|
+
if (l && l.endsWith("px")) {
|
|
104
|
+
const s = parseInt(l, 10);
|
|
105
|
+
return Number.isFinite(s) ? s : null;
|
|
106
106
|
}
|
|
107
107
|
return null;
|
|
108
108
|
},
|
|
@@ -133,16 +133,16 @@ const O = dt.extend({
|
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
135
|
function _t({ node: t, updateAttributes: r, selected: i, extension: a }) {
|
|
136
|
-
const
|
|
137
|
-
|
|
136
|
+
const l = L(null), s = L(null), [g, o] = D(!1), p = t.attrs.src ?? "", b = (a.options.resolveSrc ?? ((h) => h))(p), A = t.attrs.alt ?? "", n = t.attrs.title ?? void 0, c = t.attrs.width, k = t.attrs.align ?? "left";
|
|
137
|
+
E(() => {
|
|
138
138
|
if (!g) return;
|
|
139
139
|
const h = (x) => {
|
|
140
|
-
const u =
|
|
140
|
+
const u = s.current;
|
|
141
141
|
if (!u) return;
|
|
142
142
|
const d = x.clientX - u.x, m = Math.max(F, Math.min(z, u.width + d));
|
|
143
143
|
r({ width: Math.round(m) });
|
|
144
144
|
}, v = () => {
|
|
145
|
-
|
|
145
|
+
s.current = null, o(!1);
|
|
146
146
|
};
|
|
147
147
|
return window.addEventListener("pointermove", h), window.addEventListener("pointerup", v), window.addEventListener("pointercancel", v), () => {
|
|
148
148
|
window.removeEventListener("pointermove", h), window.removeEventListener("pointerup", v), window.removeEventListener("pointercancel", v);
|
|
@@ -151,16 +151,16 @@ function _t({ node: t, updateAttributes: r, selected: i, extension: a }) {
|
|
|
151
151
|
const I = (h) => {
|
|
152
152
|
var u;
|
|
153
153
|
h.preventDefault(), h.stopPropagation();
|
|
154
|
-
const v = (u =
|
|
155
|
-
|
|
154
|
+
const v = (u = l.current) == null ? void 0 : u.querySelector("img"), x = c ?? (v == null ? void 0 : v.getBoundingClientRect().width) ?? 320;
|
|
155
|
+
s.current = { x: h.clientX, width: x }, o(!0);
|
|
156
156
|
};
|
|
157
157
|
return /* @__PURE__ */ H(
|
|
158
158
|
G,
|
|
159
159
|
{
|
|
160
|
-
ref:
|
|
160
|
+
ref: l,
|
|
161
161
|
"data-resizable-image": "",
|
|
162
162
|
"data-selected": i ? "true" : void 0,
|
|
163
|
-
className:
|
|
163
|
+
className: S(
|
|
164
164
|
"relative block max-w-full align-baseline",
|
|
165
165
|
"[&>img]:block [&>img]:max-w-full [&>img]:h-auto [&>img]:rounded-md",
|
|
166
166
|
k === "left" && "mr-auto",
|
|
@@ -181,7 +181,7 @@ function _t({ node: t, updateAttributes: r, selected: i, extension: a }) {
|
|
|
181
181
|
"aria-valuemax": z,
|
|
182
182
|
"data-testid": "resize-handle",
|
|
183
183
|
onPointerDown: I,
|
|
184
|
-
className:
|
|
184
|
+
className: S(
|
|
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",
|
|
@@ -211,17 +211,20 @@ function Kt(t) {
|
|
|
211
211
|
return /^(?:[a-z][a-z0-9+.-]*:|\/|#)/i.test(t);
|
|
212
212
|
}
|
|
213
213
|
function Qt(t, r) {
|
|
214
|
-
|
|
214
|
+
return !(t === "" && !r);
|
|
215
|
+
}
|
|
216
|
+
function Zt(t, r) {
|
|
217
|
+
const i = t.match(/^([^?#]*)([?#].*)?$/), a = (i == null ? void 0 : i[1]) ?? t, l = (i == null ? void 0 : i[2]) ?? "", s = r != null && r.includes("/") ? r.slice(0, r.lastIndexOf("/")) : "", g = `${s ? `${s}/` : ""}${a}`.split("/"), o = [];
|
|
215
218
|
for (const p of g)
|
|
216
219
|
!p || p === "." || (p === ".." ? o.pop() : o.push(p));
|
|
217
|
-
return `${o.join("/")}${
|
|
220
|
+
return `${o.join("/")}${l}`;
|
|
218
221
|
}
|
|
219
|
-
function
|
|
222
|
+
function Gt(t, r, i, a) {
|
|
220
223
|
if (!t || Kt(t)) return t;
|
|
221
|
-
const
|
|
222
|
-
return a && g.set("workspaceId", a), `${
|
|
224
|
+
const l = Zt(t, r), s = i.replace(/\/$/, ""), g = new URLSearchParams({ path: l });
|
|
225
|
+
return a && g.set("workspaceId", a), `${s}/api/v1/files/raw?${g.toString()}`;
|
|
223
226
|
}
|
|
224
|
-
const
|
|
227
|
+
const Jt = [
|
|
225
228
|
et.configure({
|
|
226
229
|
codeBlock: !1,
|
|
227
230
|
link: !1,
|
|
@@ -243,8 +246,8 @@ const Gt = [
|
|
|
243
246
|
ot.configure({
|
|
244
247
|
types: ["heading", "paragraph"]
|
|
245
248
|
}),
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
st,
|
|
250
|
+
lt.configure({
|
|
248
251
|
resizable: !0
|
|
249
252
|
}),
|
|
250
253
|
ct,
|
|
@@ -263,7 +266,7 @@ const Gt = [
|
|
|
263
266
|
}
|
|
264
267
|
})
|
|
265
268
|
];
|
|
266
|
-
function f({ onClick: t, active: r, disabled: i, title: a, children:
|
|
269
|
+
function f({ onClick: t, active: r, disabled: i, title: a, children: l }) {
|
|
267
270
|
return /* @__PURE__ */ e(
|
|
268
271
|
Wt,
|
|
269
272
|
{
|
|
@@ -273,28 +276,28 @@ function f({ onClick: t, active: r, disabled: i, title: a, children: s }) {
|
|
|
273
276
|
disabled: i,
|
|
274
277
|
title: a,
|
|
275
278
|
"aria-pressed": r,
|
|
276
|
-
className:
|
|
279
|
+
className: S(
|
|
277
280
|
"text-muted-foreground/70",
|
|
278
281
|
r && "bg-[color:var(--accent-soft)] text-[color:var(--accent)]"
|
|
279
282
|
),
|
|
280
|
-
children:
|
|
283
|
+
children: l
|
|
281
284
|
}
|
|
282
285
|
);
|
|
283
286
|
}
|
|
284
|
-
function
|
|
287
|
+
function C() {
|
|
285
288
|
return /* @__PURE__ */ e(Pt, { className: "mx-2 h-3.5" });
|
|
286
289
|
}
|
|
287
290
|
function P(t) {
|
|
288
291
|
const r = t.trim().toLowerCase();
|
|
289
292
|
return !r.startsWith("javascript:") && !r.startsWith("data:text/html");
|
|
290
293
|
}
|
|
291
|
-
function
|
|
294
|
+
function Yt(t) {
|
|
292
295
|
return new Promise((r, i) => {
|
|
293
296
|
const a = new FileReader();
|
|
294
297
|
a.onload = () => r(a.result), a.onerror = () => i(a.error ?? new Error("Read failed")), a.readAsDataURL(t);
|
|
295
298
|
});
|
|
296
299
|
}
|
|
297
|
-
function
|
|
300
|
+
function te(t) {
|
|
298
301
|
if (!t) return null;
|
|
299
302
|
for (const r of Array.from(t.files ?? []))
|
|
300
303
|
if (r.type.startsWith("image/")) return r;
|
|
@@ -305,14 +308,14 @@ function Yt(t) {
|
|
|
305
308
|
}
|
|
306
309
|
return null;
|
|
307
310
|
}
|
|
308
|
-
function
|
|
311
|
+
function ee({
|
|
309
312
|
editor: t,
|
|
310
313
|
onInsertImage: r,
|
|
311
314
|
rawMode: i,
|
|
312
315
|
onToggleRawMode: a,
|
|
313
|
-
uploading:
|
|
316
|
+
uploading: l
|
|
314
317
|
}) {
|
|
315
|
-
const
|
|
318
|
+
const s = (n) => {
|
|
316
319
|
if (t) {
|
|
317
320
|
if (t.isActive("image")) {
|
|
318
321
|
t.chain().focus().updateAttributes("image", { align: n }).run();
|
|
@@ -366,15 +369,15 @@ function te({
|
|
|
366
369
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleItalic().run(), active: o.italic, title: "Italic", children: /* @__PURE__ */ e(vt, { className: "h-4 w-4" }) }),
|
|
367
370
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleUnderline().run(), active: o.underline, title: "Underline", children: /* @__PURE__ */ e(bt, { className: "h-4 w-4" }) }),
|
|
368
371
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleStrike().run(), active: o.strike, title: "Strikethrough", children: /* @__PURE__ */ e(It, { className: "h-4 w-4" }) }),
|
|
369
|
-
/* @__PURE__ */ e(
|
|
372
|
+
/* @__PURE__ */ e(C, {}),
|
|
370
373
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleHeading({ level: 1 }).run(), active: o.h1, title: "Heading 1", children: /* @__PURE__ */ e(At, { className: "h-4 w-4" }) }),
|
|
371
374
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleHeading({ level: 2 }).run(), active: o.h2, title: "Heading 2", children: /* @__PURE__ */ e(yt, { className: "h-4 w-4" }) }),
|
|
372
375
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleHeading({ level: 3 }).run(), active: o.h3, title: "Heading 3", children: /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }) }),
|
|
373
|
-
/* @__PURE__ */ e(
|
|
376
|
+
/* @__PURE__ */ e(C, {}),
|
|
374
377
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleBulletList().run(), active: o.bulletList, title: "Bullet list", children: /* @__PURE__ */ e(xt, { className: "h-4 w-4" }) }),
|
|
375
378
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleOrderedList().run(), active: o.orderedList, title: "Ordered list", children: /* @__PURE__ */ e(Nt, { className: "h-4 w-4" }) }),
|
|
376
379
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleTaskList().run(), active: o.taskList, title: "Task list", children: /* @__PURE__ */ e(Ct, { className: "h-4 w-4" }) }),
|
|
377
|
-
/* @__PURE__ */ e(
|
|
380
|
+
/* @__PURE__ */ e(C, {}),
|
|
378
381
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleBlockquote().run(), active: o.blockquote, title: "Quote", children: /* @__PURE__ */ e(Tt, { className: "h-4 w-4" }) }),
|
|
379
382
|
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleCodeBlock().run(), active: o.codeBlock, title: "Code block", children: /* @__PURE__ */ e(Mt, { className: "h-4 w-4" }) }),
|
|
380
383
|
/* @__PURE__ */ e(f, { onClick: p, active: o.link, title: "Link", children: /* @__PURE__ */ e(Rt, { className: "h-4 w-4" }) }),
|
|
@@ -383,7 +386,7 @@ function te({
|
|
|
383
386
|
{
|
|
384
387
|
onClick: b,
|
|
385
388
|
title: "Image (click to upload, Shift+click for URL)",
|
|
386
|
-
children: /* @__PURE__ */ e(
|
|
389
|
+
children: /* @__PURE__ */ e(Ut, { className: "h-4 w-4" })
|
|
387
390
|
}
|
|
388
391
|
),
|
|
389
392
|
/* @__PURE__ */ e(
|
|
@@ -397,22 +400,22 @@ function te({
|
|
|
397
400
|
onChange: A
|
|
398
401
|
}
|
|
399
402
|
),
|
|
400
|
-
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleHighlight().run(), active: o.highlight, title: "Highlight", children: /* @__PURE__ */ e(
|
|
401
|
-
/* @__PURE__ */ e(
|
|
402
|
-
/* @__PURE__ */ e(f, { onClick: () =>
|
|
403
|
-
/* @__PURE__ */ e(f, { onClick: () =>
|
|
404
|
-
/* @__PURE__ */ e(f, { onClick: () =>
|
|
405
|
-
/* @__PURE__ */ e(
|
|
406
|
-
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().setHorizontalRule().run(), title: "Horizontal rule", children: /* @__PURE__ */ e(
|
|
407
|
-
/* @__PURE__ */ e(
|
|
408
|
-
|
|
403
|
+
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().toggleHighlight().run(), active: o.highlight, title: "Highlight", children: /* @__PURE__ */ e(Ht, { className: "h-4 w-4" }) }),
|
|
404
|
+
/* @__PURE__ */ e(C, {}),
|
|
405
|
+
/* @__PURE__ */ e(f, { onClick: () => s("left"), active: o.alignLeft, title: "Align left", children: /* @__PURE__ */ e(St, { className: "h-4 w-4" }) }),
|
|
406
|
+
/* @__PURE__ */ e(f, { onClick: () => s("center"), active: o.alignCenter, title: "Center align", children: /* @__PURE__ */ e($t, { className: "h-4 w-4" }) }),
|
|
407
|
+
/* @__PURE__ */ e(f, { onClick: () => s("right"), active: o.alignRight, title: "Align right", children: /* @__PURE__ */ e(Bt, { className: "h-4 w-4" }) }),
|
|
408
|
+
/* @__PURE__ */ e(C, {}),
|
|
409
|
+
/* @__PURE__ */ e(f, { onClick: () => t.chain().focus().setHorizontalRule().run(), title: "Horizontal rule", children: /* @__PURE__ */ e(Et, { className: "h-4 w-4" }) }),
|
|
410
|
+
/* @__PURE__ */ e(C, {}),
|
|
411
|
+
l && /* @__PURE__ */ H(
|
|
409
412
|
"span",
|
|
410
413
|
{
|
|
411
414
|
role: "status",
|
|
412
415
|
"aria-live": "polite",
|
|
413
416
|
className: "ml-auto flex items-center gap-1.5 text-[11px] text-muted-foreground/80",
|
|
414
417
|
children: [
|
|
415
|
-
/* @__PURE__ */ e(
|
|
418
|
+
/* @__PURE__ */ e(Dt, { className: "h-3 w-3 animate-spin", "aria-hidden": !0 }),
|
|
416
419
|
"Uploading…"
|
|
417
420
|
]
|
|
418
421
|
}
|
|
@@ -428,25 +431,25 @@ function te({
|
|
|
428
431
|
)
|
|
429
432
|
] });
|
|
430
433
|
}
|
|
431
|
-
function
|
|
434
|
+
function Ne({
|
|
432
435
|
content: t,
|
|
433
436
|
onChange: r,
|
|
434
437
|
readOnly: i = !1,
|
|
435
438
|
placeholder: a,
|
|
436
|
-
className:
|
|
437
|
-
documentPath:
|
|
439
|
+
className: l,
|
|
440
|
+
documentPath: s
|
|
438
441
|
}) {
|
|
439
|
-
const g = j(), o = _(), { upload: p, uploading: y } = qt(), [b, A] =
|
|
442
|
+
const g = j(), o = _(), { upload: p, uploading: y } = qt(), [b, A] = D(!1), n = Q(() => {
|
|
440
443
|
const d = O.configure({
|
|
441
444
|
inline: !1,
|
|
442
445
|
allowBase64: !0,
|
|
443
|
-
resolveSrc: (w) =>
|
|
444
|
-
}), m =
|
|
446
|
+
resolveSrc: (w) => Gt(w, s, g, o)
|
|
447
|
+
}), m = Jt.map((w) => w.name === "image" ? d : w);
|
|
445
448
|
return a ? [
|
|
446
449
|
...m.filter((w) => w.name !== "placeholder"),
|
|
447
450
|
q.configure({ placeholder: a })
|
|
448
451
|
] : m;
|
|
449
|
-
}, [g,
|
|
452
|
+
}, [g, s, a, o]), c = L(r);
|
|
450
453
|
c.current = r;
|
|
451
454
|
const k = L(!1), I = L(null), h = L(async () => {
|
|
452
455
|
});
|
|
@@ -455,20 +458,20 @@ function xe({
|
|
|
455
458
|
if (!m) return;
|
|
456
459
|
let w;
|
|
457
460
|
try {
|
|
458
|
-
w = await
|
|
461
|
+
w = await Yt(d);
|
|
459
462
|
} catch {
|
|
460
463
|
return;
|
|
461
464
|
}
|
|
462
|
-
const
|
|
465
|
+
const N = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `pending-${Date.now()}-${Math.random().toString(36).slice(2)}`, V = { src: w, alt: d.name, pendingUploadId: N };
|
|
463
466
|
m.chain().focus().setImage(V).run();
|
|
464
467
|
try {
|
|
465
|
-
const { url:
|
|
466
|
-
if (!
|
|
467
|
-
|
|
468
|
+
const { url: T } = await p(d, { sourcePath: s }), M = I.current;
|
|
469
|
+
if (!M || M.isDestroyed) return;
|
|
470
|
+
M.commands.command(({ tr: $, state: R }) => (R.doc.descendants((U, X) => (U.type.name === "image" && U.attrs.pendingUploadId === N && $.setNodeMarkup(X, void 0, { ...U.attrs, src: T, pendingUploadId: null }), !0)), !0));
|
|
468
471
|
} catch {
|
|
469
|
-
const
|
|
470
|
-
if (!
|
|
471
|
-
|
|
472
|
+
const T = I.current;
|
|
473
|
+
if (!T || T.isDestroyed) return;
|
|
474
|
+
T.commands.command(({ tr: M, state: $ }) => ($.doc.descendants((R, U) => (R.type.name === "image" && R.attrs.pendingUploadId === N && M.setNodeMarkup(U, void 0, { ...R.attrs, pendingUploadId: null }), !0)), !0));
|
|
472
475
|
}
|
|
473
476
|
};
|
|
474
477
|
const v = t || { type: "doc", content: [{ type: "paragraph" }] }, x = t ? "markdown" : "json", u = J({
|
|
@@ -483,23 +486,25 @@ function xe({
|
|
|
483
486
|
transformPastedHTML: Xt,
|
|
484
487
|
handlePaste: (d, m) => {
|
|
485
488
|
if (i) return !1;
|
|
486
|
-
const w =
|
|
489
|
+
const w = te(m.clipboardData);
|
|
487
490
|
return w ? (m.preventDefault(), h.current(w), !0) : !1;
|
|
488
491
|
}
|
|
489
492
|
},
|
|
490
493
|
onUpdate: ({ editor: d }) => {
|
|
491
|
-
var
|
|
492
|
-
|
|
494
|
+
var w, N;
|
|
495
|
+
if (k.current) return;
|
|
496
|
+
const m = ((w = d.getMarkdown) == null ? void 0 : w.call(d)) ?? d.getHTML();
|
|
497
|
+
Qt(m, d.isFocused) && ((N = c.current) == null || N.call(c, m));
|
|
493
498
|
}
|
|
494
499
|
});
|
|
495
|
-
return I.current = u,
|
|
500
|
+
return I.current = u, E(() => {
|
|
496
501
|
!u || u.isDestroyed || u.setEditable(!i);
|
|
497
|
-
}, [u, i]),
|
|
502
|
+
}, [u, i]), E(() => {
|
|
498
503
|
var m;
|
|
499
504
|
!u || u.isDestroyed || (((m = u.getMarkdown) == null ? void 0 : m.call(u)) ?? u.getHTML()) === t || (k.current = !0, u.commands.setContent(v, { contentType: x }), k.current = !1);
|
|
500
|
-
}, [u, t]), /* @__PURE__ */ H("div", { className:
|
|
505
|
+
}, [u, t]), /* @__PURE__ */ H("div", { className: S("flex h-full min-h-0 flex-col overflow-hidden", l), children: [
|
|
501
506
|
!i && /* @__PURE__ */ e(
|
|
502
|
-
|
|
507
|
+
ee,
|
|
503
508
|
{
|
|
504
509
|
editor: u,
|
|
505
510
|
onInsertImage: (d) => h.current(d),
|
|
@@ -508,7 +513,7 @@ function xe({
|
|
|
508
513
|
uploading: y
|
|
509
514
|
}
|
|
510
515
|
),
|
|
511
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: b && !i ? /* @__PURE__ */ e(
|
|
516
|
+
/* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: b && !i ? /* @__PURE__ */ e(
|
|
512
517
|
"textarea",
|
|
513
518
|
{
|
|
514
519
|
"aria-label": "Raw markdown",
|
|
@@ -526,9 +531,10 @@ function xe({
|
|
|
526
531
|
] });
|
|
527
532
|
}
|
|
528
533
|
export {
|
|
529
|
-
|
|
534
|
+
Ne as MarkdownEditor,
|
|
530
535
|
P as isSafeUrl,
|
|
531
|
-
|
|
532
|
-
|
|
536
|
+
Qt as isUserEditedChange,
|
|
537
|
+
Gt as rawFileUrlForMarkdownImage,
|
|
538
|
+
Yt as readFileAsDataUrl,
|
|
533
539
|
Xt as sanitizeHtml
|
|
534
540
|
};
|
|
@@ -2,7 +2,7 @@ import { jsxs as l, jsx as o, Fragment as U } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback as b, useMemo as H, useEffect as z, useState as G, useSyncExternalStore as Y, Suspense as ee, useRef as ne } from "react";
|
|
3
3
|
import { IconButton as K, LoadingState as te, ResizeHandle as re, Button as oe, Kbd as ae } from "@hachej/boring-ui-kit";
|
|
4
4
|
import { c as g } from "./utils-B6yFEsav.js";
|
|
5
|
-
import { a2 as ie, ad as se, E as ce, aw as de, au as le, u as ue, ao as he } from "./WorkspaceProvider-
|
|
5
|
+
import { a2 as ie, ad as se, E as ce, aw as de, au as le, u as ue, ao as he } from "./WorkspaceProvider-0V-2x7AH.js";
|
|
6
6
|
import { Search as me, Plus as fe } from "lucide-react";
|
|
7
7
|
function _e(e, n, r = !0) {
|
|
8
8
|
if (!r || typeof window > "u") return n;
|