@estiva-app/ui 0.83.0 → 0.84.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/dist/CommentBox.d.ts +11 -2
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ComposeBox.d.ts +17 -0
- package/dist/ComposeBox.d.ts.map +1 -1
- package/dist/editor.js +139 -55
- package/dist/editor.js.map +3 -3
- package/dist/links.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +14 -2
- package/src/CommentBox.mdx +11 -1
- package/src/CommentBox.stories.tsx +75 -2
- package/src/CommentBox.test.tsx +170 -3
- package/src/CommentBox.tsx +211 -53
- package/src/ComposeBox.tsx +19 -2
- package/src/links.ts +4 -1
package/dist/CommentBox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from 'react';
|
|
2
2
|
import { type AnyExtension } from '@tiptap/core';
|
|
3
|
-
import { type JSONContent } from '@tiptap/react';
|
|
3
|
+
import { Editor, type JSONContent } from '@tiptap/react';
|
|
4
4
|
import { type ReferenceViewProps } from './BlockNodes';
|
|
5
5
|
import { type CodeFormat, type MentionPerson, type ReferenceSection, type SlashCommand } from './ComposerTriggers';
|
|
6
6
|
/**
|
|
@@ -142,6 +142,10 @@ export interface CommentBoxProps {
|
|
|
142
142
|
onSent?: (body: JSONContent, files: BoxFile[], under: BoxSentUnder) => void;
|
|
143
143
|
/** Called when a send shown at once was refused, so the app takes it back. */
|
|
144
144
|
onRefused?: () => void;
|
|
145
|
+
/** The bar down the text's left edge shows while this holds, besides while an urgent mention is in the box: the app's own marks (a highlight). */
|
|
146
|
+
marked?: (editor: Editor) => boolean;
|
|
147
|
+
/** Called with the box's editor once it is drawn, and with `null` as it goes: an app's launcher inserts into the box last used. */
|
|
148
|
+
onEditor?: (editor: Editor | null) => void;
|
|
145
149
|
className?: string;
|
|
146
150
|
}
|
|
147
151
|
/**
|
|
@@ -150,5 +154,10 @@ export interface CommentBoxProps {
|
|
|
150
154
|
* `file` is the Upload row, named as in a document's `/`.
|
|
151
155
|
*/
|
|
152
156
|
export declare const commentBoxRows: Readonly<Record<'file' | 'mention' | 'urgent' | 'reference', SlashCommand>>;
|
|
153
|
-
|
|
157
|
+
/** Keeps an editor built ahead for the next empty box given these `extensions` and `referenceView`, so it opens at once. */
|
|
158
|
+
export declare function keepCommentBoxWarm(app?: {
|
|
159
|
+
extensions?: readonly AnyExtension[];
|
|
160
|
+
referenceView?: ComponentType<ReferenceViewProps>;
|
|
161
|
+
}): void;
|
|
162
|
+
export declare function CommentBox({ people, references, referencesChanged, referenceIcon, insert, code, send, under, showsAtOnce, label, placeholder, draft, edit, upload, accept, closed, referenceView, extensions, autoFocus, onSent, onRefused, marked, onEditor, className, }: CommentBoxProps): import("react").JSX.Element;
|
|
154
163
|
//# sourceMappingURL=CommentBox.d.ts.map
|
package/dist/CommentBox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentBox.d.ts","sourceRoot":"","sources":["../src/CommentBox.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CommentBox.d.ts","sourceRoot":"","sources":["../src/CommentBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuE,KAAK,aAAa,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC/I,OAAO,EAAa,KAAK,YAAY,EAAsB,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAGvE,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAMrE,OAAO,EAQL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAA;AAY3B;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAA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G,QAAQ,GAAG,WAAW,EAAE,YAAY,CAAC,CAKtG,CAAA;AA2HD,4HAA4H;AAC5H,wBAAgB,kBAAkB,CAAC,GAAG,GAAE;IAAE,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAA;CAAO,GAAG,IAAI,CAO9I;AA0DD,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,MAAW,EACX,IAAc,EACd,IAAI,EACJ,KAAK,EACL,WAAmB,EACnB,KAAK,EACL,WAAW,EACX,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,MAAM,EACN,aAAa,EACb,UAA0B,EAC1B,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,GACV,EAAE,eAAe,+BAqUjB"}
|
package/dist/ComposeBox.d.ts
CHANGED
|
@@ -10,7 +10,24 @@ import { type SelectionToolbarProps } from './SelectionToolbar';
|
|
|
10
10
|
* `ComposeKeys`; this draws the box around it and sends.
|
|
11
11
|
*/
|
|
12
12
|
/** The editor's own classes inside the box: Peek's, rich text with no outline. Put them in `editorProps.attributes.class`. */
|
|
13
|
+
/** The classes the box's editor wears: rich text with no outline. It never scrolls itself; the box does, in a `ScrollArea`. */
|
|
13
14
|
export declare const COMPOSE_EDITOR_CLASSES: string;
|
|
15
|
+
/**
|
|
16
|
+
* A long draft stops at half the window and scrolls inside the box, so its
|
|
17
|
+
* first line can be reached (PEE-59). The package's `ScrollArea` scrolls it,
|
|
18
|
+
* not the browser: its bar, and one that shows while there is more (Katerina,
|
|
19
|
+
* 21 Oct: the browser's bar, and none at all in some browsers).
|
|
20
|
+
*
|
|
21
|
+
* The region reaches into the box's right padding (the box's `p-3`) and its
|
|
22
|
+
* content gives it back, so the text ends where it did and the bar sits 3px
|
|
23
|
+
* from the box's edge, as every other box's bar does (Katerina, 21 Oct: the gap
|
|
24
|
+
* on the right; measured 15px before, 3px after).
|
|
25
|
+
*/
|
|
26
|
+
export declare const COMPOSE_SCROLL_CLASSES: {
|
|
27
|
+
area: string;
|
|
28
|
+
viewport: string;
|
|
29
|
+
content: string;
|
|
30
|
+
};
|
|
14
31
|
type ComposeKeysStorage = {
|
|
15
32
|
send: (() => boolean) | null;
|
|
16
33
|
};
|
package/dist/ComposeBox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposeBox.d.ts","sourceRoot":"","sources":["../src/ComposeBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"ComposeBox.d.ts","sourceRoot":"","sources":["../src/ComposeBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAQ1D,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAGjF;;;;;;GAMG;AAEH,8HAA8H;AAC9H,+HAA+H;AAC/H,eAAO,MAAM,sBAAsB,QAAgG,CAAA;AAEnI;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB;;;;CAA+D,CAAA;AAElG,KAAK,kBAAkB,GAAG;IAAE,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,IAAI,CAAA;CAAE,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,WAAW,sDA4BtB,CAAA;AAEF,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CASlD;AAED,MAAM,WAAW,eAAe;IAC9B,wHAAwH;IACxH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB;;;OAGG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAA;IAC1C,2FAA2F;IAC3F,WAAW,EAAE,SAAS,CAAA;IACtB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,mEAAmE;IACnE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,qFAAqF;IACrF,SAAS,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAa,EAAE,OAAe,EAAE,MAAc,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,eAAe,+BAkFpK"}
|
package/dist/editor.js
CHANGED
|
@@ -306,6 +306,7 @@ import { IconButton } from "@estiva-app/ui";
|
|
|
306
306
|
import { Toolbar as Toolbar2 } from "@estiva-app/ui";
|
|
307
307
|
import { cn } from "@estiva-app/ui";
|
|
308
308
|
import { richTextClassName } from "@estiva-app/ui";
|
|
309
|
+
import { ScrollArea } from "@estiva-app/ui";
|
|
309
310
|
|
|
310
311
|
// src/looks.ts
|
|
311
312
|
var FLOATING_SURFACE_CLASSES = "rounded-lg border border-border-default bg-bg-elevated shadow-lg";
|
|
@@ -426,6 +427,7 @@ function suggestionPopup(options) {
|
|
|
426
427
|
// src/ComposeBox.tsx
|
|
427
428
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
428
429
|
var COMPOSE_EDITOR_CLASSES = richTextClassName("default", "outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1");
|
|
430
|
+
var COMPOSE_SCROLL_CLASSES = { area: "-mr-3", viewport: "max-h-[50vh]", content: "pr-3" };
|
|
429
431
|
var ComposeKeys = Extension2.create({
|
|
430
432
|
name: "composeKeys",
|
|
431
433
|
addStorage() {
|
|
@@ -493,8 +495,8 @@ function ComposeBox({ editor, onSend, placeholder, tools, attachments, ready = f
|
|
|
493
495
|
};
|
|
494
496
|
}, [editor]);
|
|
495
497
|
return /* @__PURE__ */ jsx3("div", { className: cn("relative", className), children: /* @__PURE__ */ jsxs2("div", { className: cn(WRITING_BOX_CLASSES, "focus-within:border-border-strong transition-colors"), children: [
|
|
496
|
-
/* @__PURE__ */ jsxs2("div", { "data-composer-editor": true, className: cn("relative min-h-[20px] transition-all", marked && "border-l-4 border-border-strong pl-2"), children: [
|
|
497
|
-
/* @__PURE__ */ jsx3(EditorContent, { editor }),
|
|
498
|
+
/* @__PURE__ */ jsxs2("div", { "data-composer-editor": true, "data-marked": marked || void 0, className: cn("relative min-h-[20px] transition-all", marked && "border-l-4 border-border-strong pl-2"), children: [
|
|
499
|
+
/* @__PURE__ */ jsx3(ScrollArea, { className: COMPOSE_SCROLL_CLASSES.area, viewportClassName: COMPOSE_SCROLL_CLASSES.viewport, contentClassName: COMPOSE_SCROLL_CLASSES.content, children: /* @__PURE__ */ jsx3(EditorContent, { editor }) }),
|
|
498
500
|
/* @__PURE__ */ jsx3(SelectionToolbar, { editor, ...selection }),
|
|
499
501
|
empty && /* @__PURE__ */ jsx3("div", { className: "pointer-events-none absolute inset-0 flex flex-wrap items-center gap-1 text-body-2 text-text-muted", children: placeholder })
|
|
500
502
|
] }),
|
|
@@ -528,9 +530,9 @@ function ComposeBox({ editor, onSend, placeholder, tools, attachments, ready = f
|
|
|
528
530
|
}
|
|
529
531
|
|
|
530
532
|
// src/CommentBox.tsx
|
|
531
|
-
import { Fragment as Fragment2, useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
533
|
+
import { Fragment as Fragment2, useCallback as useCallback4, useEffect as useEffect4, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
|
|
532
534
|
import { Extension as Extension11 } from "@tiptap/core";
|
|
533
|
-
import { EditorContent as EditorContent2
|
|
535
|
+
import { Editor, EditorContent as EditorContent2 } from "@tiptap/react";
|
|
534
536
|
import { IconLock, IconPaperclip, IconSquareRounded } from "@tabler/icons-react";
|
|
535
537
|
import { AttachmentCard } from "@estiva-app/ui";
|
|
536
538
|
|
|
@@ -2100,7 +2102,8 @@ var PasteOverWords = Extension9.create({
|
|
|
2100
2102
|
return false;
|
|
2101
2103
|
});
|
|
2102
2104
|
if (plain && LINK_ON_WORDS_TARGET.test(url) && !/[[\]\n]/.test(state.doc.textBetween(from, to))) {
|
|
2103
|
-
|
|
2105
|
+
const tr2 = state.tr.addMark(from, to, schema.marks.link.create({ href: url }));
|
|
2106
|
+
view.dispatch(tr2.setSelection(TextSelection2.create(tr2.doc, to)).removeStoredMark(schema.marks.link));
|
|
2104
2107
|
return true;
|
|
2105
2108
|
}
|
|
2106
2109
|
const before = state.doc.textBetween(Math.max(to - 1, $to.start()), to, "", "\uFFFC");
|
|
@@ -2236,6 +2239,7 @@ var PastedImages = Extension10.create({
|
|
|
2236
2239
|
});
|
|
2237
2240
|
|
|
2238
2241
|
// src/CommentBox.tsx
|
|
2242
|
+
import { ScrollArea as ScrollArea2 } from "@estiva-app/ui";
|
|
2239
2243
|
import { ToolbarButton as ToolbarButton2 } from "@estiva-app/ui";
|
|
2240
2244
|
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2241
2245
|
var ATTACH_EVENT = "commentbox:attach";
|
|
@@ -2262,6 +2266,105 @@ var BoxKeys = Extension11.create({
|
|
|
2262
2266
|
var stillNamed = (removed, names) => [...removed].every((value) => names.includes(value)) ? removed : new Set([...removed].filter((value) => names.includes(value)));
|
|
2263
2267
|
var SQUARE = /* @__PURE__ */ jsx7(IconSquareRounded, { size: 16, stroke: 1.5, className: "text-text-secondary" });
|
|
2264
2268
|
var SMALL_SQUARE = /* @__PURE__ */ jsx7(IconSquareRounded, { size: 14, stroke: 1.5 });
|
|
2269
|
+
var NO_EXTENSIONS = [];
|
|
2270
|
+
var sameApp = (a, b) => a.referenceView === b.referenceView && a.extensions.length === b.extensions.length && a.extensions.every((one, i) => one === b.extensions[i]);
|
|
2271
|
+
function boxExtensions(hold, app) {
|
|
2272
|
+
const iconFor = (uri) => hold.current.referenceIcon?.(uri);
|
|
2273
|
+
return [
|
|
2274
|
+
BoxKit.configure({ link: { openOnClick: false } }),
|
|
2275
|
+
PasteOverWords,
|
|
2276
|
+
KeptSelection,
|
|
2277
|
+
ComposeKeys,
|
|
2278
|
+
BoxKeys.configure({
|
|
2279
|
+
onEscape: () => {
|
|
2280
|
+
const editing = hold.current.edit;
|
|
2281
|
+
if (!editing) return false;
|
|
2282
|
+
editing.onCancel();
|
|
2283
|
+
return true;
|
|
2284
|
+
}
|
|
2285
|
+
}),
|
|
2286
|
+
PersonMention.configure({ people: () => hold.current.people }),
|
|
2287
|
+
// An edit makes nobody urgent (CON-24): `!@` opens no list there, as `/` offers no Urgent.
|
|
2288
|
+
UrgentPersonMention.extend({
|
|
2289
|
+
addOptions() {
|
|
2290
|
+
const parent = this.parent();
|
|
2291
|
+
return { ...parent, suggestion: { ...parent.suggestion, allow: () => !hold.current.edit } };
|
|
2292
|
+
}
|
|
2293
|
+
}).configure({ people: () => hold.current.people }),
|
|
2294
|
+
CaptionedReference.configure({ icon: SMALL_SQUARE, iconFor }),
|
|
2295
|
+
ReferenceTrigger.configure({
|
|
2296
|
+
items: () => [],
|
|
2297
|
+
sections: (query) => hold.current.references?.(query) ?? [],
|
|
2298
|
+
subscribe: (listener) => hold.current.referencesChanged?.(listener) ?? (() => {
|
|
2299
|
+
}),
|
|
2300
|
+
ariaLabel: "References",
|
|
2301
|
+
sectionLabel: "References",
|
|
2302
|
+
icon: SQUARE,
|
|
2303
|
+
iconFor
|
|
2304
|
+
}),
|
|
2305
|
+
SlashCommands.configure({ sections: hold.sections }),
|
|
2306
|
+
ReferenceNode.configure({ view: app.referenceView }),
|
|
2307
|
+
PastedImages.configure({ onImages: (files) => hold.current.attach(files) }),
|
|
2308
|
+
...app.extensions
|
|
2309
|
+
];
|
|
2310
|
+
}
|
|
2311
|
+
function buildBox(app, options) {
|
|
2312
|
+
const hold = { current: { people: [], attach: () => false }, sections: [] };
|
|
2313
|
+
return { editor: new Editor({ ...options, extensions: boxExtensions(hold, app) }), hold };
|
|
2314
|
+
}
|
|
2315
|
+
var warmApp = null;
|
|
2316
|
+
var spare = null;
|
|
2317
|
+
var sparing = false;
|
|
2318
|
+
function scheduleSpare() {
|
|
2319
|
+
if (!warmApp || spare || sparing || typeof window === "undefined" || !window.requestIdleCallback) return;
|
|
2320
|
+
sparing = true;
|
|
2321
|
+
window.requestIdleCallback(() => {
|
|
2322
|
+
sparing = false;
|
|
2323
|
+
if (warmApp && !spare) spare = buildBox(warmApp, { autofocus: false });
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
function useBoxEditor(app, content, options) {
|
|
2327
|
+
const args = useRef3({ app, content, options });
|
|
2328
|
+
args.current = { app, content, options };
|
|
2329
|
+
const [held, setHeld] = useState4(() => {
|
|
2330
|
+
const fits = !content && spare && !spare.editor.isDestroyed && warmApp && sameApp(warmApp, app);
|
|
2331
|
+
const taken = fits ? spare : null;
|
|
2332
|
+
if (taken) {
|
|
2333
|
+
spare = null;
|
|
2334
|
+
taken.editor.setOptions(options);
|
|
2335
|
+
}
|
|
2336
|
+
const one = taken ?? buildBox(app, { ...options, content });
|
|
2337
|
+
one.destroyAt = setTimeout(() => one.editor.destroy(), 1e4);
|
|
2338
|
+
scheduleSpare();
|
|
2339
|
+
return one;
|
|
2340
|
+
});
|
|
2341
|
+
useLayoutEffect(() => {
|
|
2342
|
+
clearTimeout(held.destroyAt);
|
|
2343
|
+
if (held.editor.isDestroyed) {
|
|
2344
|
+
const { app: now, content: opening, options: current } = args.current;
|
|
2345
|
+
setHeld(buildBox(now, { ...current, content: opening }));
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
return () => {
|
|
2349
|
+
held.destroyAt = setTimeout(() => held.editor.destroy(), 1);
|
|
2350
|
+
};
|
|
2351
|
+
}, [held]);
|
|
2352
|
+
const props = useRef3(options.editorProps);
|
|
2353
|
+
props.current = options.editorProps;
|
|
2354
|
+
const attributes = JSON.stringify(options.editorProps.attributes ?? {});
|
|
2355
|
+
useEffect4(() => {
|
|
2356
|
+
if (!held.editor.isDestroyed) held.editor.setOptions({ editorProps: props.current });
|
|
2357
|
+
}, [held, attributes]);
|
|
2358
|
+
return held;
|
|
2359
|
+
}
|
|
2360
|
+
var holdsUrgent = (editor) => {
|
|
2361
|
+
let found = false;
|
|
2362
|
+
editor.state.doc.descendants((node) => {
|
|
2363
|
+
if (node.type.name === "urgentMention") found = true;
|
|
2364
|
+
return !found;
|
|
2365
|
+
});
|
|
2366
|
+
return found;
|
|
2367
|
+
};
|
|
2265
2368
|
var fileCount = 0;
|
|
2266
2369
|
function CommentBox({
|
|
2267
2370
|
people,
|
|
@@ -2281,10 +2384,12 @@ function CommentBox({
|
|
|
2281
2384
|
accept,
|
|
2282
2385
|
closed,
|
|
2283
2386
|
referenceView,
|
|
2284
|
-
extensions =
|
|
2387
|
+
extensions = NO_EXTENSIONS,
|
|
2285
2388
|
autoFocus,
|
|
2286
2389
|
onSent,
|
|
2287
2390
|
onRefused,
|
|
2391
|
+
marked,
|
|
2392
|
+
onEditor,
|
|
2288
2393
|
className
|
|
2289
2394
|
}) {
|
|
2290
2395
|
const [files, setFiles] = useState4(edit?.files ?? []);
|
|
@@ -2294,8 +2399,8 @@ function CommentBox({
|
|
|
2294
2399
|
const [removed, setRemoved] = useState4(() => /* @__PURE__ */ new Set());
|
|
2295
2400
|
const picker = useRef3(null);
|
|
2296
2401
|
const root = useRef3(null);
|
|
2297
|
-
const latest = useRef3({ edit,
|
|
2298
|
-
latest.current = { edit,
|
|
2402
|
+
const latest = useRef3({ edit, upload, draft, under });
|
|
2403
|
+
latest.current = { edit, upload, draft, under };
|
|
2299
2404
|
const save = useRef3(() => false);
|
|
2300
2405
|
const attachFiles = useCallback4((picked) => {
|
|
2301
2406
|
const uploadOne = latest.current.upload;
|
|
@@ -2314,51 +2419,29 @@ function CommentBox({
|
|
|
2314
2419
|
return true;
|
|
2315
2420
|
}, []);
|
|
2316
2421
|
const rows = insert.filter((c) => !((edit || !upload) && c.key === commentBoxRows.file.key) && !(edit && c.key === commentBoxRows.urgent.key));
|
|
2317
|
-
const
|
|
2318
|
-
sections.splice(0, sections.length, formatSection(code), ...rows.length > 0 ? [{ label: "Insert", commands: rows }] : []);
|
|
2319
|
-
const iconFor = useCallback4((uri) => latest.current.referenceIcon?.(uri), []);
|
|
2320
|
-
const editor = useEditor({
|
|
2321
|
-
extensions: [
|
|
2322
|
-
BoxKit.configure({ link: { openOnClick: false } }),
|
|
2323
|
-
PasteOverWords,
|
|
2324
|
-
KeptSelection,
|
|
2325
|
-
ComposeKeys,
|
|
2326
|
-
BoxKeys.configure({
|
|
2327
|
-
onEscape: () => {
|
|
2328
|
-
const editing = latest.current.edit;
|
|
2329
|
-
if (!editing) return false;
|
|
2330
|
-
editing.onCancel();
|
|
2331
|
-
return true;
|
|
2332
|
-
}
|
|
2333
|
-
}),
|
|
2334
|
-
PersonMention.configure({ people: () => latest.current.people }),
|
|
2335
|
-
// An edit makes nobody urgent (CON-24): `!@` opens no list there, as `/` offers no Urgent.
|
|
2336
|
-
UrgentPersonMention.extend({
|
|
2337
|
-
addOptions() {
|
|
2338
|
-
const parent = this.parent();
|
|
2339
|
-
return { ...parent, suggestion: { ...parent.suggestion, allow: () => !latest.current.edit } };
|
|
2340
|
-
}
|
|
2341
|
-
}).configure({ people: () => latest.current.people }),
|
|
2342
|
-
CaptionedReference.configure({ icon: SMALL_SQUARE, iconFor }),
|
|
2343
|
-
ReferenceTrigger.configure({
|
|
2344
|
-
items: () => [],
|
|
2345
|
-
sections: (query) => latest.current.references?.(query) ?? [],
|
|
2346
|
-
subscribe: (listener) => latest.current.referencesChanged?.(listener) ?? (() => {
|
|
2347
|
-
}),
|
|
2348
|
-
ariaLabel: "References",
|
|
2349
|
-
sectionLabel: "References",
|
|
2350
|
-
icon: SQUARE,
|
|
2351
|
-
iconFor
|
|
2352
|
-
}),
|
|
2353
|
-
SlashCommands.configure({ sections }),
|
|
2354
|
-
ReferenceNode.configure({ view: referenceView ?? null }),
|
|
2355
|
-
PastedImages.configure({ onImages: attachFiles }),
|
|
2356
|
-
...extensions
|
|
2357
|
-
],
|
|
2358
|
-
content: edit?.body ?? draft?.read(),
|
|
2422
|
+
const { editor, hold } = useBoxEditor({ extensions, referenceView: referenceView ?? null }, edit?.body ?? draft?.read(), {
|
|
2359
2423
|
editable: !closed,
|
|
2360
2424
|
editorProps: { attributes: { class: COMPOSE_EDITOR_CLASSES, role: "textbox", "aria-multiline": "true", "aria-label": label } }
|
|
2361
2425
|
});
|
|
2426
|
+
hold.current = { edit, people, references, referencesChanged, referenceIcon, attach: attachFiles };
|
|
2427
|
+
hold.sections.splice(0, hold.sections.length, formatSection(code), ...rows.length > 0 ? [{ label: "Insert", commands: rows }] : []);
|
|
2428
|
+
const [marking, setMarking] = useState4(false);
|
|
2429
|
+
const markedBy = useRef3(marked);
|
|
2430
|
+
markedBy.current = marked;
|
|
2431
|
+
useLayoutEffect(() => {
|
|
2432
|
+
const read = () => setMarking(holdsUrgent(editor) || !!markedBy.current?.(editor));
|
|
2433
|
+
read();
|
|
2434
|
+
editor.on("update", read);
|
|
2435
|
+
return () => {
|
|
2436
|
+
editor.off("update", read);
|
|
2437
|
+
};
|
|
2438
|
+
}, [editor]);
|
|
2439
|
+
const handOut = useRef3(onEditor);
|
|
2440
|
+
handOut.current = onEditor;
|
|
2441
|
+
useEffect4(() => {
|
|
2442
|
+
handOut.current?.(editor);
|
|
2443
|
+
return () => handOut.current?.(null);
|
|
2444
|
+
}, [editor]);
|
|
2362
2445
|
useEffect4(() => {
|
|
2363
2446
|
if (!editor || edit) return;
|
|
2364
2447
|
const keep = () => {
|
|
@@ -2510,7 +2593,7 @@ function CommentBox({
|
|
|
2510
2593
|
if (edit) {
|
|
2511
2594
|
return /* @__PURE__ */ jsxs5("div", { className: cn2("flex flex-col gap-1", className), children: [
|
|
2512
2595
|
/* @__PURE__ */ jsxs5("div", { className: cn2(WRITING_BOX_CLASSES, "focus-within:border-border-strong transition-colors", sending && "[&_.ProseMirror]:text-text-muted"), children: [
|
|
2513
|
-
/* @__PURE__ */ jsx7(EditorContent2, { editor }),
|
|
2596
|
+
/* @__PURE__ */ jsx7("div", { "data-composer-editor": true, "data-marked": marking || void 0, className: cn2("relative min-h-[20px]", marking && "border-l-4 border-border-strong pl-2"), children: /* @__PURE__ */ jsx7(ScrollArea2, { className: COMPOSE_SCROLL_CLASSES.area, viewportClassName: COMPOSE_SCROLL_CLASSES.viewport, contentClassName: COMPOSE_SCROLL_CLASSES.content, children: /* @__PURE__ */ jsx7(EditorContent2, { editor }) }) }),
|
|
2514
2597
|
fileCards && /* @__PURE__ */ jsx7("div", { className: "flex flex-wrap gap-2", children: fileCards }),
|
|
2515
2598
|
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2516
2599
|
/* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-caption text-text-muted", children: [
|
|
@@ -2546,6 +2629,7 @@ function CommentBox({
|
|
|
2546
2629
|
tools: upload ? /* @__PURE__ */ jsx7(ToolbarButton2, { tooltip: "Attach a file", "aria-label": "Attach a file", disabled: sending, onClick: () => picker.current?.click(), children: /* @__PURE__ */ jsx7(IconPaperclip, { size: 16, stroke: 1.5 }) }) : void 0,
|
|
2547
2630
|
attachments: fileCards,
|
|
2548
2631
|
ready,
|
|
2632
|
+
marked: marking,
|
|
2549
2633
|
holding: uploading || failed > 0 || sending,
|
|
2550
2634
|
selection: { link: true },
|
|
2551
2635
|
className: cn2(sending && "[&_[data-composer-editor]]:text-text-muted")
|
|
@@ -2564,7 +2648,7 @@ function CommentBox({
|
|
|
2564
2648
|
import { useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useRef as useRef4, useState as useState5 } from "react";
|
|
2565
2649
|
import { Extension as Extension12, Node as Node3 } from "@tiptap/core";
|
|
2566
2650
|
import { history, redo, undo } from "@tiptap/pm/history";
|
|
2567
|
-
import { EditorContent as EditorContent3, useEditor
|
|
2651
|
+
import { EditorContent as EditorContent3, useEditor } from "@tiptap/react";
|
|
2568
2652
|
import { cn as cn3 } from "@estiva-app/ui";
|
|
2569
2653
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2570
2654
|
var VARIANT = {
|
|
@@ -2607,7 +2691,7 @@ function InlineText({ value, placeholder, label, onCommit, onText, onEnter, vari
|
|
|
2607
2691
|
if (pending.current === next) pending.current = null;
|
|
2608
2692
|
}
|
|
2609
2693
|
}, []);
|
|
2610
|
-
const editor =
|
|
2694
|
+
const editor = useEditor({
|
|
2611
2695
|
extensions: [OneLine, Paragraph, Text, Undo],
|
|
2612
2696
|
content: doc(value),
|
|
2613
2697
|
editable: !readOnly,
|
|
@@ -3398,7 +3482,7 @@ function EditorTableControls({ editor, children, className }) {
|
|
|
3398
3482
|
// src/DocumentEditor.tsx
|
|
3399
3483
|
import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef6, useState as useState7 } from "react";
|
|
3400
3484
|
import { TextSelection as TextSelection4 } from "@tiptap/pm/state";
|
|
3401
|
-
import { EditorContent as EditorContent4, useEditor as
|
|
3485
|
+
import { EditorContent as EditorContent4, useEditor as useEditor2, useEditorState as useEditorState2 } from "@tiptap/react";
|
|
3402
3486
|
import { TableKit } from "@tiptap/extension-table";
|
|
3403
3487
|
import { IconMessagePlus } from "@tabler/icons-react";
|
|
3404
3488
|
import { Button as Button2 } from "@estiva-app/ui";
|
|
@@ -3554,7 +3638,7 @@ function DocumentEditor({
|
|
|
3554
3638
|
};
|
|
3555
3639
|
const attachTo = useRef6(attach);
|
|
3556
3640
|
attachTo.current = attach;
|
|
3557
|
-
const editor =
|
|
3641
|
+
const editor = useEditor2(
|
|
3558
3642
|
{
|
|
3559
3643
|
extensions: [
|
|
3560
3644
|
DocumentKit.configure({
|