@estiva-app/ui 0.84.0 → 0.85.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 +1 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/{ComposeBox.d.ts → commentBoxFrame.d.ts} +32 -13
- package/dist/commentBoxFrame.d.ts.map +1 -0
- package/dist/editor.d.ts +0 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +316 -292
- package/dist/editor.js.map +4 -4
- package/dist/eslint/index.js +594 -559
- package/dist/eslint/index.js.map +4 -4
- package/dist/eslint/no-hand-rolled-behaviour.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/looks.d.ts +1 -1
- package/package.json +1 -1
- package/registry.json +4 -128
- package/src/CommentBox.mdx +4 -3
- package/src/CommentBox.stories.tsx +3 -0
- package/src/CommentBox.test.tsx +15 -0
- package/src/CommentBox.tsx +39 -32
- package/src/{ComposeBox.tsx → commentBoxFrame.tsx} +61 -27
- package/src/editor.ts +1 -1
- package/src/eslint/no-hand-rolled-behaviour.test.ts +27 -0
- package/src/eslint/no-hand-rolled-behaviour.ts +44 -0
- package/src/looks.ts +1 -1
- package/src/registry/app.test.ts +3 -4
- package/src/registry/registry.test.ts +5 -5
- package/stories/Choosing.mdx +0 -1
- package/dist/ComposeBox.d.ts.map +0 -1
- package/src/ComposeBox.mdx +0 -58
- package/src/ComposeBox.stories.tsx +0 -81
package/dist/editor.js
CHANGED
|
@@ -297,256 +297,24 @@ function SelectionToolbar({ editor, marks = ["bold", "italic", "underline"], lin
|
|
|
297
297
|
);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
// src/ComposeBox.tsx
|
|
301
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
302
|
-
import { Extension as Extension2 } from "@tiptap/core";
|
|
303
|
-
import { EditorContent } from "@tiptap/react";
|
|
304
|
-
import { IconArrowUp } from "@tabler/icons-react";
|
|
305
|
-
import { IconButton } from "@estiva-app/ui";
|
|
306
|
-
import { Toolbar as Toolbar2 } from "@estiva-app/ui";
|
|
307
|
-
import { cn } from "@estiva-app/ui";
|
|
308
|
-
import { richTextClassName } from "@estiva-app/ui";
|
|
309
|
-
import { ScrollArea } from "@estiva-app/ui";
|
|
310
|
-
|
|
311
|
-
// src/looks.ts
|
|
312
|
-
var FLOATING_SURFACE_CLASSES = "rounded-lg border border-border-default bg-bg-elevated shadow-lg";
|
|
313
|
-
var WRITING_BOX_CLASSES = "relative bg-bg-inset border border-border-default rounded-lg p-3 flex flex-col gap-4 signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring";
|
|
314
|
-
|
|
315
|
-
// src/suggestionPopup.tsx
|
|
316
|
-
import { forwardRef, useRef as useRef2, useImperativeHandle } from "react";
|
|
317
|
-
import { ReactRenderer } from "@tiptap/react";
|
|
318
|
-
import { exitSuggestion } from "@tiptap/suggestion";
|
|
319
|
-
import { SuggestionMenu } from "@estiva-app/ui";
|
|
320
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
321
|
-
var openCount = 0;
|
|
322
|
-
var lastClose = 0;
|
|
323
|
-
function isSuggestionActive() {
|
|
324
|
-
return openCount > 0 || Date.now() - lastClose < 100;
|
|
325
|
-
}
|
|
326
|
-
function isSuggestionOpen() {
|
|
327
|
-
return openCount > 0;
|
|
328
|
-
}
|
|
329
|
-
var Popup = forwardRef(function Popup2({ options, ...props }, handle) {
|
|
330
|
-
const menu = useRef2(null);
|
|
331
|
-
useImperativeHandle(handle, () => ({ onKeyDown: (event) => menu.current?.onKeyDown(event) ?? false }));
|
|
332
|
-
const sections = options.sections ? options.sections(props.items, props.query) : [{ items: props.items }];
|
|
333
|
-
return /* @__PURE__ */ jsx2(
|
|
334
|
-
SuggestionMenu,
|
|
335
|
-
{
|
|
336
|
-
handle: menu,
|
|
337
|
-
rect: props.clientRect?.() ?? null,
|
|
338
|
-
editorElement: props.editor.view.dom,
|
|
339
|
-
ariaLabel: options.ariaLabel,
|
|
340
|
-
width: options.width,
|
|
341
|
-
maxHeight: options.maxHeight,
|
|
342
|
-
sections,
|
|
343
|
-
itemKey: options.itemKey,
|
|
344
|
-
row: options.row,
|
|
345
|
-
onSelect: (item) => props.command(item)
|
|
346
|
-
}
|
|
347
|
-
);
|
|
348
|
-
});
|
|
349
|
-
function suggestionPopup(options) {
|
|
350
|
-
return () => {
|
|
351
|
-
let component = null;
|
|
352
|
-
let container = null;
|
|
353
|
-
let last = null;
|
|
354
|
-
let unsubscribe;
|
|
355
|
-
let counted = false;
|
|
356
|
-
let unlisten;
|
|
357
|
-
const count = (shown) => {
|
|
358
|
-
if (shown === counted) return;
|
|
359
|
-
counted = shown;
|
|
360
|
-
openCount = shown ? openCount + 1 : Math.max(0, openCount - 1);
|
|
361
|
-
};
|
|
362
|
-
const listen = (props) => {
|
|
363
|
-
const { view } = props.editor;
|
|
364
|
-
const dom = view.dom;
|
|
365
|
-
const onBlur = () => {
|
|
366
|
-
if (dom.contains(document.activeElement) || !last) return;
|
|
367
|
-
const from = last.range.from;
|
|
368
|
-
count(false);
|
|
369
|
-
for (const plugin of view.state.plugins) {
|
|
370
|
-
const state = plugin.getState(view.state);
|
|
371
|
-
if (state?.active && state.range?.from === from && plugin.spec.key) exitSuggestion(view, plugin.spec.key);
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
dom.addEventListener("blur", onBlur);
|
|
375
|
-
unlisten = () => dom.removeEventListener("blur", onBlur);
|
|
376
|
-
};
|
|
377
|
-
const exit = () => {
|
|
378
|
-
unsubscribe?.();
|
|
379
|
-
unsubscribe = void 0;
|
|
380
|
-
unlisten?.();
|
|
381
|
-
unlisten = void 0;
|
|
382
|
-
last = null;
|
|
383
|
-
if (counted) lastClose = Date.now();
|
|
384
|
-
count(false);
|
|
385
|
-
if (!component) return;
|
|
386
|
-
component.destroy();
|
|
387
|
-
container?.remove();
|
|
388
|
-
component = null;
|
|
389
|
-
container = null;
|
|
390
|
-
};
|
|
391
|
-
return {
|
|
392
|
-
onStart: (props) => {
|
|
393
|
-
count(props.items.length > 0);
|
|
394
|
-
component = new ReactRenderer(Popup, { props: { ...props, options }, editor: props.editor });
|
|
395
|
-
container = document.createElement("div");
|
|
396
|
-
document.body.appendChild(container);
|
|
397
|
-
container.appendChild(component.element);
|
|
398
|
-
last = props;
|
|
399
|
-
listen(props);
|
|
400
|
-
const { subscribe, refresh } = options;
|
|
401
|
-
if (subscribe && refresh) {
|
|
402
|
-
unsubscribe = subscribe(() => {
|
|
403
|
-
if (!last || !component) return;
|
|
404
|
-
last = { ...last, items: refresh(last.query) };
|
|
405
|
-
count(last.items.length > 0);
|
|
406
|
-
component.updateProps({ ...last, options });
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
onUpdate: (props) => {
|
|
411
|
-
last = props;
|
|
412
|
-
count(props.items.length > 0);
|
|
413
|
-
component?.updateProps({ ...props, options });
|
|
414
|
-
},
|
|
415
|
-
onKeyDown: ({ event }) => {
|
|
416
|
-
if (event.key === "Escape") {
|
|
417
|
-
exit();
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
return component?.ref?.onKeyDown(event) ?? false;
|
|
421
|
-
},
|
|
422
|
-
onExit: exit
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/ComposeBox.tsx
|
|
428
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
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" };
|
|
431
|
-
var ComposeKeys = Extension2.create({
|
|
432
|
-
name: "composeKeys",
|
|
433
|
-
addStorage() {
|
|
434
|
-
return { send: null };
|
|
435
|
-
},
|
|
436
|
-
addKeyboardShortcuts() {
|
|
437
|
-
return {
|
|
438
|
-
Enter: () => {
|
|
439
|
-
if (isSuggestionActive()) return false;
|
|
440
|
-
this.storage.send?.();
|
|
441
|
-
return true;
|
|
442
|
-
},
|
|
443
|
-
"Shift-Enter": ({ editor }) => {
|
|
444
|
-
const { $from } = editor.state.selection;
|
|
445
|
-
for (let d = $from.depth; d > 0; d--) {
|
|
446
|
-
const node = $from.node(d);
|
|
447
|
-
if (node.type.name === "listItem") {
|
|
448
|
-
return node.textContent.length === 0 ? editor.commands.liftListItem("listItem") : editor.commands.splitListItem("listItem");
|
|
449
|
-
}
|
|
450
|
-
if (node.type.name === "blockquote") {
|
|
451
|
-
if ($from.parent.textContent.length === 0) return editor.commands.lift("paragraph");
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return editor.commands.splitBlock();
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
function isEmptyDoc(editor) {
|
|
461
|
-
const doc2 = editor.state.doc;
|
|
462
|
-
if (doc2.textContent.trim().length > 0) return false;
|
|
463
|
-
let empty = true;
|
|
464
|
-
doc2.descendants((node) => {
|
|
465
|
-
if (node.isAtom && !node.isText && node.type.name !== "hardBreak") empty = false;
|
|
466
|
-
});
|
|
467
|
-
return empty;
|
|
468
|
-
}
|
|
469
|
-
function ComposeBox({ editor, onSend, placeholder, tools, attachments, ready = false, holding = false, marked = false, selection, className }) {
|
|
470
|
-
const [empty, setEmpty] = useState2(true);
|
|
471
|
-
const canSend = (!empty || ready) && !holding;
|
|
472
|
-
const send = useCallback2(() => {
|
|
473
|
-
if (!editor || holding || isEmptyDoc(editor) && !ready) return true;
|
|
474
|
-
if (onSend(editor) === false) return true;
|
|
475
|
-
editor.commands.clearContent(true);
|
|
476
|
-
editor.commands.focus();
|
|
477
|
-
return true;
|
|
478
|
-
}, [editor, holding, ready, onSend]);
|
|
479
|
-
useEffect2(() => {
|
|
480
|
-
if (!editor) return;
|
|
481
|
-
const storage = editor.storage.composeKeys;
|
|
482
|
-
if (!storage) return;
|
|
483
|
-
storage.send = send;
|
|
484
|
-
return () => {
|
|
485
|
-
storage.send = null;
|
|
486
|
-
};
|
|
487
|
-
}, [editor, send]);
|
|
488
|
-
useEffect2(() => {
|
|
489
|
-
if (!editor) return;
|
|
490
|
-
const read = () => setEmpty(isEmptyDoc(editor));
|
|
491
|
-
read();
|
|
492
|
-
editor.on("update", read);
|
|
493
|
-
return () => {
|
|
494
|
-
editor.off("update", read);
|
|
495
|
-
};
|
|
496
|
-
}, [editor]);
|
|
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: [
|
|
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 }) }),
|
|
500
|
-
/* @__PURE__ */ jsx3(SelectionToolbar, { editor, ...selection }),
|
|
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 })
|
|
502
|
-
] }),
|
|
503
|
-
attachments && /* @__PURE__ */ jsx3("div", { className: "flex flex-wrap gap-2", children: attachments }),
|
|
504
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between", children: [
|
|
505
|
-
tools ? /* @__PURE__ */ jsx3(Toolbar2, { "aria-label": "Compose tools", surface: false, className: "flex items-center gap-1", children: tools }) : /* @__PURE__ */ jsx3("span", {}),
|
|
506
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2.5", children: [
|
|
507
|
-
/* @__PURE__ */ jsx3("span", { className: "hidden select-none font-mono text-menu font-normal tracking-wider text-text-muted signal:inline", children: "Enter to send \xB7 Shift+Enter new line" }),
|
|
508
|
-
/* @__PURE__ */ jsx3(
|
|
509
|
-
IconButton,
|
|
510
|
-
{
|
|
511
|
-
variant: "primary",
|
|
512
|
-
onMouseDown: (e) => {
|
|
513
|
-
e.preventDefault();
|
|
514
|
-
send();
|
|
515
|
-
},
|
|
516
|
-
onClick: (e) => {
|
|
517
|
-
if (e.detail === 0) send();
|
|
518
|
-
},
|
|
519
|
-
disabled: !canSend,
|
|
520
|
-
"aria-label": "Send",
|
|
521
|
-
tooltip: "Send",
|
|
522
|
-
tooltipShortcut: "Enter",
|
|
523
|
-
glow: canSend,
|
|
524
|
-
children: /* @__PURE__ */ jsx3(IconArrowUp, { size: 16, stroke: 1.5 })
|
|
525
|
-
}
|
|
526
|
-
)
|
|
527
|
-
] })
|
|
528
|
-
] })
|
|
529
|
-
] }) });
|
|
530
|
-
}
|
|
531
|
-
|
|
532
300
|
// src/CommentBox.tsx
|
|
533
301
|
import { Fragment as Fragment2, useCallback as useCallback4, useEffect as useEffect4, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
|
|
534
302
|
import { Extension as Extension11 } from "@tiptap/core";
|
|
535
|
-
import { Editor
|
|
303
|
+
import { Editor } from "@tiptap/react";
|
|
536
304
|
import { IconLock, IconPaperclip, IconSquareRounded } from "@tabler/icons-react";
|
|
537
305
|
import { AttachmentCard } from "@estiva-app/ui";
|
|
538
306
|
|
|
539
307
|
// src/BlockNodes.tsx
|
|
540
|
-
import { Extension as
|
|
308
|
+
import { Extension as Extension6, InputRule, Node as Node2 } from "@tiptap/core";
|
|
541
309
|
import { DOMSerializer } from "@tiptap/pm/model";
|
|
542
310
|
import { Plugin as Plugin6, PluginKey as PluginKey6 } from "@tiptap/pm/state";
|
|
543
311
|
import { Mapping, ReplaceAroundStep } from "@tiptap/pm/transform";
|
|
544
|
-
import { NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer
|
|
312
|
+
import { NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer } from "@tiptap/react";
|
|
545
313
|
import { Checkbox } from "@estiva-app/ui";
|
|
546
314
|
import { calloutLook } from "@estiva-app/ui";
|
|
547
315
|
|
|
548
316
|
// src/LinkPlaces.ts
|
|
549
|
-
import { Extension as
|
|
317
|
+
import { Extension as Extension2 } from "@tiptap/core";
|
|
550
318
|
import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
551
319
|
import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@tiptap/pm/view";
|
|
552
320
|
var CONTAINERS = /* @__PURE__ */ new Set(["bulletList", "orderedList", "listItem"]);
|
|
@@ -635,7 +403,7 @@ function placeOf(decorations) {
|
|
|
635
403
|
return "chip";
|
|
636
404
|
}
|
|
637
405
|
var key = new PluginKey2("linkPlaces");
|
|
638
|
-
var LinkPlaces =
|
|
406
|
+
var LinkPlaces = Extension2.create({
|
|
639
407
|
name: "linkPlaces",
|
|
640
408
|
addProseMirrorPlugins() {
|
|
641
409
|
const decorate = (doc2) => DecorationSet2.create(
|
|
@@ -656,15 +424,15 @@ var LinkPlaces = Extension3.create({
|
|
|
656
424
|
});
|
|
657
425
|
|
|
658
426
|
// src/ReferenceMenu.tsx
|
|
659
|
-
import { useCallback as
|
|
660
|
-
import { Extension as
|
|
427
|
+
import { useCallback as useCallback2 } from "react";
|
|
428
|
+
import { Extension as Extension5 } from "@tiptap/core";
|
|
661
429
|
import { useEditorState } from "@tiptap/react";
|
|
662
430
|
import { NodeSelection as NodeSelection2, Plugin as Plugin5, PluginKey as PluginKey5, TextSelection } from "@tiptap/pm/state";
|
|
663
431
|
import { ReplaceStep } from "@tiptap/pm/transform";
|
|
664
432
|
import { IconCheck, IconExternalLink } from "@tabler/icons-react";
|
|
665
433
|
|
|
666
434
|
// src/LinkChips.ts
|
|
667
|
-
import { Extension as
|
|
435
|
+
import { Extension as Extension3 } from "@tiptap/core";
|
|
668
436
|
import { closeHistory } from "@tiptap/pm/history";
|
|
669
437
|
import { Plugin as Plugin3, PluginKey as PluginKey3 } from "@tiptap/pm/state";
|
|
670
438
|
var key2 = new PluginKey3("linkChips");
|
|
@@ -742,7 +510,7 @@ function refreshLinkChips(editor) {
|
|
|
742
510
|
const tr = apply(editor.state, findLinkChips(editor.state.doc, editor.state.selection, chips.options.referenceOf, chips.pasted));
|
|
743
511
|
if (tr) editor.view.dispatch(tr);
|
|
744
512
|
}
|
|
745
|
-
var LinkChips =
|
|
513
|
+
var LinkChips = Extension3.create({
|
|
746
514
|
name: "linkChips",
|
|
747
515
|
addOptions() {
|
|
748
516
|
return { referenceOf: null, ask: null, limit: 24 };
|
|
@@ -815,10 +583,10 @@ import { MenuItem, MenuSection, MenuSeparator } from "@estiva-app/ui";
|
|
|
815
583
|
import { Popover as Popover2 } from "@estiva-app/ui";
|
|
816
584
|
|
|
817
585
|
// src/ReferenceCards.ts
|
|
818
|
-
import { Extension as
|
|
586
|
+
import { Extension as Extension4 } from "@tiptap/core";
|
|
819
587
|
import { NodeSelection, Plugin as Plugin4, PluginKey as PluginKey4 } from "@tiptap/pm/state";
|
|
820
588
|
import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@tiptap/pm/view";
|
|
821
|
-
import { useEffect as
|
|
589
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
822
590
|
function layoutOf(raw) {
|
|
823
591
|
if (typeof raw !== "string" || raw === "" || raw === "none") return void 0;
|
|
824
592
|
return raw === "detailed" ? "detailed" : "compact";
|
|
@@ -859,7 +627,7 @@ function elementFor(storage, slotKey) {
|
|
|
859
627
|
function storageOf(editor) {
|
|
860
628
|
return editor.storage.referenceCards;
|
|
861
629
|
}
|
|
862
|
-
var ReferenceCards =
|
|
630
|
+
var ReferenceCards = Extension4.create({
|
|
863
631
|
name: "referenceCards",
|
|
864
632
|
addStorage() {
|
|
865
633
|
return { elements: /* @__PURE__ */ new Map() };
|
|
@@ -891,8 +659,8 @@ var ReferenceCards = Extension5.create({
|
|
|
891
659
|
}
|
|
892
660
|
});
|
|
893
661
|
function useReferenceCards(editor) {
|
|
894
|
-
const [slots, setSlots] =
|
|
895
|
-
|
|
662
|
+
const [slots, setSlots] = useState2([]);
|
|
663
|
+
useEffect2(() => {
|
|
896
664
|
if (!editor) return;
|
|
897
665
|
const storage = storageOf(editor);
|
|
898
666
|
if (!storage) return;
|
|
@@ -957,7 +725,7 @@ function setReferenceCardAt(editor, pos, layout) {
|
|
|
957
725
|
}
|
|
958
726
|
|
|
959
727
|
// src/ReferenceMenu.tsx
|
|
960
|
-
import { Fragment, jsx as
|
|
728
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
961
729
|
var key4 = new PluginKey5("referenceMenu");
|
|
962
730
|
var SHOW_AS = [
|
|
963
731
|
{ as: "row", label: "Row" },
|
|
@@ -1038,7 +806,7 @@ function caretAfter(state, pos) {
|
|
|
1038
806
|
const node = state.doc.nodeAt(pos);
|
|
1039
807
|
return state.tr.setSelection(TextSelection.create(state.doc, pos + (node?.nodeSize ?? 1)));
|
|
1040
808
|
}
|
|
1041
|
-
var ReferenceMenu =
|
|
809
|
+
var ReferenceMenu = Extension5.create({
|
|
1042
810
|
name: "referenceMenu",
|
|
1043
811
|
// Before the editor's own keys, so Enter on a highlighted row is the row's, not a new line.
|
|
1044
812
|
priority: 1e3,
|
|
@@ -1117,7 +885,7 @@ function ReferenceMenuView({ editor }) {
|
|
|
1117
885
|
return { pos: open.pos, active: open.active, shownAs: linkPlaceAt(ed.state.doc, open.pos) === "card" ? "card" : "row" };
|
|
1118
886
|
}
|
|
1119
887
|
});
|
|
1120
|
-
const keepFocus2 =
|
|
888
|
+
const keepFocus2 = useCallback2((list) => {
|
|
1121
889
|
const panel = list?.closest('[role="dialog"]');
|
|
1122
890
|
if (!panel) return;
|
|
1123
891
|
const keep = (event) => event.preventDefault();
|
|
@@ -1135,7 +903,7 @@ function ReferenceMenuView({ editor }) {
|
|
|
1135
903
|
};
|
|
1136
904
|
return (
|
|
1137
905
|
// finalFocus={false}: focus never left the text.
|
|
1138
|
-
/* @__PURE__ */
|
|
906
|
+
/* @__PURE__ */ jsx2(
|
|
1139
907
|
Popover2,
|
|
1140
908
|
{
|
|
1141
909
|
anchor,
|
|
@@ -1147,14 +915,14 @@ function ReferenceMenuView({ editor }) {
|
|
|
1147
915
|
align: "left",
|
|
1148
916
|
ariaLabel: "Link",
|
|
1149
917
|
finalFocus: false,
|
|
1150
|
-
children: shown && /* @__PURE__ */
|
|
1151
|
-
opens && /* @__PURE__ */
|
|
918
|
+
children: shown && /* @__PURE__ */ jsxs2("div", { ref: keepFocus2, role: "menu", "aria-label": "Link", className: "flex flex-col gap-0.5", children: [
|
|
919
|
+
opens && /* @__PURE__ */ jsx2(
|
|
1152
920
|
MenuItem,
|
|
1153
921
|
{
|
|
1154
922
|
role: "menuitem",
|
|
1155
923
|
tabIndex: -1,
|
|
1156
924
|
label: "Open",
|
|
1157
|
-
leading: /* @__PURE__ */
|
|
925
|
+
leading: /* @__PURE__ */ jsx2(IconExternalLink, { size: 16 }),
|
|
1158
926
|
selected: shown.active === 0,
|
|
1159
927
|
onMouseDown: (event) => {
|
|
1160
928
|
event.preventDefault();
|
|
@@ -1162,9 +930,9 @@ function ReferenceMenuView({ editor }) {
|
|
|
1162
930
|
}
|
|
1163
931
|
}
|
|
1164
932
|
),
|
|
1165
|
-
showAs && /* @__PURE__ */
|
|
1166
|
-
opens && /* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
933
|
+
showAs && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
934
|
+
opens && /* @__PURE__ */ jsx2(MenuSeparator, {}),
|
|
935
|
+
/* @__PURE__ */ jsx2("div", { role: "group", "aria-label": "Show as", children: /* @__PURE__ */ jsx2(MenuSection, { label: "Show as", children: SHOW_AS.map(({ as, label }, i) => /* @__PURE__ */ jsx2(
|
|
1168
936
|
MenuItem,
|
|
1169
937
|
{
|
|
1170
938
|
role: "menuitemradio",
|
|
@@ -1172,7 +940,7 @@ function ReferenceMenuView({ editor }) {
|
|
|
1172
940
|
tabIndex: -1,
|
|
1173
941
|
label,
|
|
1174
942
|
selected: shown.active === i + (opens ? 1 : 0),
|
|
1175
|
-
trailing: shown.shownAs === as ? /* @__PURE__ */
|
|
943
|
+
trailing: shown.shownAs === as ? /* @__PURE__ */ jsx2(IconCheck, { size: 16, "aria-hidden": true }) : void 0,
|
|
1176
944
|
onMouseDown: (event) => {
|
|
1177
945
|
event.preventDefault();
|
|
1178
946
|
run(as);
|
|
@@ -1188,7 +956,7 @@ function ReferenceMenuView({ editor }) {
|
|
|
1188
956
|
}
|
|
1189
957
|
|
|
1190
958
|
// src/BlockNodes.tsx
|
|
1191
|
-
import { jsx as
|
|
959
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1192
960
|
var BLOCK_TYPES = [
|
|
1193
961
|
"paragraph",
|
|
1194
962
|
"heading",
|
|
@@ -1346,7 +1114,7 @@ function bringsInBlocks(transactions) {
|
|
|
1346
1114
|
})
|
|
1347
1115
|
);
|
|
1348
1116
|
}
|
|
1349
|
-
var BlockId =
|
|
1117
|
+
var BlockId = Extension6.create({
|
|
1350
1118
|
name: "blockId",
|
|
1351
1119
|
onCreate() {
|
|
1352
1120
|
const { state, view } = this.editor;
|
|
@@ -1435,7 +1203,7 @@ var ReferenceNode = Node2.create({
|
|
|
1435
1203
|
const uri = String(node.attrs.uri ?? "");
|
|
1436
1204
|
const href = typeof node.attrs.href === "string" && node.attrs.href ? node.attrs.href : void 0;
|
|
1437
1205
|
const place2 = placeOf(decorations);
|
|
1438
|
-
return /* @__PURE__ */
|
|
1206
|
+
return /* @__PURE__ */ jsx3(
|
|
1439
1207
|
NodeViewWrapper,
|
|
1440
1208
|
{
|
|
1441
1209
|
as: "span",
|
|
@@ -1450,7 +1218,7 @@ var ReferenceNode = Node2.create({
|
|
|
1450
1218
|
event.preventDefault();
|
|
1451
1219
|
event.stopPropagation();
|
|
1452
1220
|
},
|
|
1453
|
-
children: uri ? /* @__PURE__ */
|
|
1221
|
+
children: uri ? /* @__PURE__ */ jsx3(View, { uri, ...href ? { href } : {}, place: place2, editing: editor.isEditable }) : /* @__PURE__ */ jsx3("span", { children: href })
|
|
1454
1222
|
}
|
|
1455
1223
|
);
|
|
1456
1224
|
}, {
|
|
@@ -1487,7 +1255,7 @@ var UnknownBlock = Node2.create({
|
|
|
1487
1255
|
function UnknownBlockView({ node }) {
|
|
1488
1256
|
const source = node.attrs.source;
|
|
1489
1257
|
const text = String(node.attrs.text ?? "");
|
|
1490
|
-
return /* @__PURE__ */
|
|
1258
|
+
return /* @__PURE__ */ jsx3(
|
|
1491
1259
|
NodeViewWrapper,
|
|
1492
1260
|
{
|
|
1493
1261
|
"data-block-id": source?.id,
|
|
@@ -1527,7 +1295,7 @@ var AttachmentNode = Node2.create({
|
|
|
1527
1295
|
addNodeView() {
|
|
1528
1296
|
const View = this.options.view;
|
|
1529
1297
|
if (!View) return null;
|
|
1530
|
-
return ReactNodeViewRenderer(({ node }) => /* @__PURE__ */
|
|
1298
|
+
return ReactNodeViewRenderer(({ node }) => /* @__PURE__ */ jsx3(NodeViewWrapper, { className: "my-2", children: /* @__PURE__ */ jsx3(View, { attrs: node.attrs }) }));
|
|
1531
1299
|
}
|
|
1532
1300
|
});
|
|
1533
1301
|
var TICK = "checklistTick";
|
|
@@ -1564,7 +1332,7 @@ function listItemView(editor, node, view, getPos) {
|
|
|
1564
1332
|
};
|
|
1565
1333
|
let words = node.firstChild?.textContent.trim() || "Item";
|
|
1566
1334
|
const props = () => ({ checked, onChange: view.editable ? tick : void 0, "aria-label": words });
|
|
1567
|
-
const renderer = new
|
|
1335
|
+
const renderer = new ReactRenderer(Checkbox, { editor, props: props(), as: "span" });
|
|
1568
1336
|
box.appendChild(renderer.element);
|
|
1569
1337
|
let drawn = "";
|
|
1570
1338
|
const sync = () => {
|
|
@@ -1596,7 +1364,7 @@ function listItemView(editor, node, view, getPos) {
|
|
|
1596
1364
|
}
|
|
1597
1365
|
};
|
|
1598
1366
|
}
|
|
1599
|
-
var Checklist =
|
|
1367
|
+
var Checklist = Extension6.create({
|
|
1600
1368
|
name: "checklist",
|
|
1601
1369
|
// Before the list item's own Enter and Backspace.
|
|
1602
1370
|
priority: 101,
|
|
@@ -1668,7 +1436,7 @@ var Checklist = Extension7.create({
|
|
|
1668
1436
|
];
|
|
1669
1437
|
}
|
|
1670
1438
|
});
|
|
1671
|
-
var Callout =
|
|
1439
|
+
var Callout = Extension6.create({
|
|
1672
1440
|
name: "callout",
|
|
1673
1441
|
addGlobalAttributes() {
|
|
1674
1442
|
return [
|
|
@@ -1693,6 +1461,255 @@ import { Card } from "@estiva-app/ui";
|
|
|
1693
1461
|
import { CardUnder } from "@estiva-app/ui";
|
|
1694
1462
|
import { cn as cn2 } from "@estiva-app/ui";
|
|
1695
1463
|
|
|
1464
|
+
// src/commentBoxFrame.tsx
|
|
1465
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState3 } from "react";
|
|
1466
|
+
import { Extension as Extension7 } from "@tiptap/core";
|
|
1467
|
+
import { EditorContent } from "@tiptap/react";
|
|
1468
|
+
import { IconArrowUp } from "@tabler/icons-react";
|
|
1469
|
+
import { IconButton } from "@estiva-app/ui";
|
|
1470
|
+
import { Toolbar as Toolbar2 } from "@estiva-app/ui";
|
|
1471
|
+
import { cn } from "@estiva-app/ui";
|
|
1472
|
+
import { richTextClassName } from "@estiva-app/ui";
|
|
1473
|
+
import { ScrollArea } from "@estiva-app/ui";
|
|
1474
|
+
|
|
1475
|
+
// src/looks.ts
|
|
1476
|
+
var FLOATING_SURFACE_CLASSES = "rounded-lg border border-border-default bg-bg-elevated shadow-lg";
|
|
1477
|
+
var WRITING_BOX_CLASSES = "relative bg-bg-inset border border-border-default rounded-lg p-3 flex flex-col gap-4 signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring";
|
|
1478
|
+
|
|
1479
|
+
// src/suggestionPopup.tsx
|
|
1480
|
+
import { forwardRef, useRef as useRef2, useImperativeHandle } from "react";
|
|
1481
|
+
import { ReactRenderer as ReactRenderer2 } from "@tiptap/react";
|
|
1482
|
+
import { exitSuggestion } from "@tiptap/suggestion";
|
|
1483
|
+
import { SuggestionMenu } from "@estiva-app/ui";
|
|
1484
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1485
|
+
var openCount = 0;
|
|
1486
|
+
var lastClose = 0;
|
|
1487
|
+
function isSuggestionActive() {
|
|
1488
|
+
return openCount > 0 || Date.now() - lastClose < 100;
|
|
1489
|
+
}
|
|
1490
|
+
function isSuggestionOpen() {
|
|
1491
|
+
return openCount > 0;
|
|
1492
|
+
}
|
|
1493
|
+
var Popup = forwardRef(function Popup2({ options, ...props }, handle) {
|
|
1494
|
+
const menu = useRef2(null);
|
|
1495
|
+
useImperativeHandle(handle, () => ({ onKeyDown: (event) => menu.current?.onKeyDown(event) ?? false }));
|
|
1496
|
+
const sections = options.sections ? options.sections(props.items, props.query) : [{ items: props.items }];
|
|
1497
|
+
return /* @__PURE__ */ jsx4(
|
|
1498
|
+
SuggestionMenu,
|
|
1499
|
+
{
|
|
1500
|
+
handle: menu,
|
|
1501
|
+
rect: props.clientRect?.() ?? null,
|
|
1502
|
+
editorElement: props.editor.view.dom,
|
|
1503
|
+
ariaLabel: options.ariaLabel,
|
|
1504
|
+
width: options.width,
|
|
1505
|
+
maxHeight: options.maxHeight,
|
|
1506
|
+
sections,
|
|
1507
|
+
itemKey: options.itemKey,
|
|
1508
|
+
row: options.row,
|
|
1509
|
+
onSelect: (item) => props.command(item)
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
});
|
|
1513
|
+
function suggestionPopup(options) {
|
|
1514
|
+
return () => {
|
|
1515
|
+
let component = null;
|
|
1516
|
+
let container = null;
|
|
1517
|
+
let last = null;
|
|
1518
|
+
let unsubscribe;
|
|
1519
|
+
let counted = false;
|
|
1520
|
+
let unlisten;
|
|
1521
|
+
const count = (shown) => {
|
|
1522
|
+
if (shown === counted) return;
|
|
1523
|
+
counted = shown;
|
|
1524
|
+
openCount = shown ? openCount + 1 : Math.max(0, openCount - 1);
|
|
1525
|
+
};
|
|
1526
|
+
const listen = (props) => {
|
|
1527
|
+
const { view } = props.editor;
|
|
1528
|
+
const dom = view.dom;
|
|
1529
|
+
const onBlur = () => {
|
|
1530
|
+
if (dom.contains(document.activeElement) || !last) return;
|
|
1531
|
+
const from = last.range.from;
|
|
1532
|
+
count(false);
|
|
1533
|
+
for (const plugin of view.state.plugins) {
|
|
1534
|
+
const state = plugin.getState(view.state);
|
|
1535
|
+
if (state?.active && state.range?.from === from && plugin.spec.key) exitSuggestion(view, plugin.spec.key);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
dom.addEventListener("blur", onBlur);
|
|
1539
|
+
unlisten = () => dom.removeEventListener("blur", onBlur);
|
|
1540
|
+
};
|
|
1541
|
+
const exit = () => {
|
|
1542
|
+
unsubscribe?.();
|
|
1543
|
+
unsubscribe = void 0;
|
|
1544
|
+
unlisten?.();
|
|
1545
|
+
unlisten = void 0;
|
|
1546
|
+
last = null;
|
|
1547
|
+
if (counted) lastClose = Date.now();
|
|
1548
|
+
count(false);
|
|
1549
|
+
if (!component) return;
|
|
1550
|
+
component.destroy();
|
|
1551
|
+
container?.remove();
|
|
1552
|
+
component = null;
|
|
1553
|
+
container = null;
|
|
1554
|
+
};
|
|
1555
|
+
return {
|
|
1556
|
+
onStart: (props) => {
|
|
1557
|
+
count(props.items.length > 0);
|
|
1558
|
+
component = new ReactRenderer2(Popup, { props: { ...props, options }, editor: props.editor });
|
|
1559
|
+
container = document.createElement("div");
|
|
1560
|
+
document.body.appendChild(container);
|
|
1561
|
+
container.appendChild(component.element);
|
|
1562
|
+
last = props;
|
|
1563
|
+
listen(props);
|
|
1564
|
+
const { subscribe, refresh } = options;
|
|
1565
|
+
if (subscribe && refresh) {
|
|
1566
|
+
unsubscribe = subscribe(() => {
|
|
1567
|
+
if (!last || !component) return;
|
|
1568
|
+
last = { ...last, items: refresh(last.query) };
|
|
1569
|
+
count(last.items.length > 0);
|
|
1570
|
+
component.updateProps({ ...last, options });
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
onUpdate: (props) => {
|
|
1575
|
+
last = props;
|
|
1576
|
+
count(props.items.length > 0);
|
|
1577
|
+
component?.updateProps({ ...props, options });
|
|
1578
|
+
},
|
|
1579
|
+
onKeyDown: ({ event }) => {
|
|
1580
|
+
if (event.key === "Escape") {
|
|
1581
|
+
exit();
|
|
1582
|
+
return true;
|
|
1583
|
+
}
|
|
1584
|
+
return component?.ref?.onKeyDown(event) ?? false;
|
|
1585
|
+
},
|
|
1586
|
+
onExit: exit
|
|
1587
|
+
};
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// src/commentBoxFrame.tsx
|
|
1592
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1593
|
+
var COMPOSE_EDITOR_CLASSES = richTextClassName("default", "outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1");
|
|
1594
|
+
var COMPOSE_SCROLL_CLASSES = { area: "-mr-3", viewport: "max-h-[50vh]", content: "pr-3" };
|
|
1595
|
+
var ComposeKeys = Extension7.create({
|
|
1596
|
+
name: "composeKeys",
|
|
1597
|
+
addStorage() {
|
|
1598
|
+
return { send: null };
|
|
1599
|
+
},
|
|
1600
|
+
addKeyboardShortcuts() {
|
|
1601
|
+
return {
|
|
1602
|
+
Enter: () => {
|
|
1603
|
+
if (isSuggestionActive()) return false;
|
|
1604
|
+
this.storage.send?.();
|
|
1605
|
+
return true;
|
|
1606
|
+
},
|
|
1607
|
+
"Shift-Enter": ({ editor }) => {
|
|
1608
|
+
const { $from } = editor.state.selection;
|
|
1609
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
1610
|
+
const node = $from.node(d);
|
|
1611
|
+
if (node.type.name === "listItem") {
|
|
1612
|
+
return node.textContent.length === 0 ? editor.commands.liftListItem("listItem") : editor.commands.splitListItem("listItem");
|
|
1613
|
+
}
|
|
1614
|
+
if (node.type.name === "blockquote") {
|
|
1615
|
+
if ($from.parent.textContent.length === 0) return editor.commands.lift("paragraph");
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
return editor.commands.splitBlock();
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
function isEmptyDoc(editor) {
|
|
1625
|
+
const doc2 = editor.state.doc;
|
|
1626
|
+
if (doc2.textContent.trim().length > 0) return false;
|
|
1627
|
+
let empty = true;
|
|
1628
|
+
doc2.descendants((node) => {
|
|
1629
|
+
if (node.isAtom && !node.isText && node.type.name !== "hardBreak") empty = false;
|
|
1630
|
+
});
|
|
1631
|
+
return empty;
|
|
1632
|
+
}
|
|
1633
|
+
function BoxFrame({ editor, marked = false, selection, placeholder, empty = false, attachments, footer, className }) {
|
|
1634
|
+
return /* @__PURE__ */ jsxs3("div", { className: cn(WRITING_BOX_CLASSES, "focus-within:border-border-strong transition-colors", className), children: [
|
|
1635
|
+
/* @__PURE__ */ jsxs3("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: [
|
|
1636
|
+
/* @__PURE__ */ jsx5(ScrollArea, { className: COMPOSE_SCROLL_CLASSES.area, viewportClassName: COMPOSE_SCROLL_CLASSES.viewport, contentClassName: COMPOSE_SCROLL_CLASSES.content, children: /* @__PURE__ */ jsx5(EditorContent, { editor }) }),
|
|
1637
|
+
selection && /* @__PURE__ */ jsx5(SelectionToolbar, { editor, ...selection }),
|
|
1638
|
+
empty && placeholder != null && /* @__PURE__ */ jsx5("div", { className: "pointer-events-none absolute inset-0 flex flex-wrap items-center gap-1 text-body-2 text-text-muted", children: placeholder })
|
|
1639
|
+
] }),
|
|
1640
|
+
attachments && /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-2", children: attachments }),
|
|
1641
|
+
footer
|
|
1642
|
+
] });
|
|
1643
|
+
}
|
|
1644
|
+
function SendBox({ editor, onSend, placeholder, tools, attachments, ready = false, holding = false, marked = false, selection, className }) {
|
|
1645
|
+
const [empty, setEmpty] = useState3(true);
|
|
1646
|
+
const canSend = (!empty || ready) && !holding;
|
|
1647
|
+
const send = useCallback3(() => {
|
|
1648
|
+
if (!editor || holding || isEmptyDoc(editor) && !ready) return true;
|
|
1649
|
+
if (onSend(editor) === false) return true;
|
|
1650
|
+
editor.commands.clearContent(true);
|
|
1651
|
+
editor.commands.focus();
|
|
1652
|
+
return true;
|
|
1653
|
+
}, [editor, holding, ready, onSend]);
|
|
1654
|
+
useEffect3(() => {
|
|
1655
|
+
if (!editor) return;
|
|
1656
|
+
const storage = editor.storage.composeKeys;
|
|
1657
|
+
if (!storage) return;
|
|
1658
|
+
storage.send = send;
|
|
1659
|
+
return () => {
|
|
1660
|
+
storage.send = null;
|
|
1661
|
+
};
|
|
1662
|
+
}, [editor, send]);
|
|
1663
|
+
useEffect3(() => {
|
|
1664
|
+
if (!editor) return;
|
|
1665
|
+
const read = () => setEmpty(isEmptyDoc(editor));
|
|
1666
|
+
read();
|
|
1667
|
+
editor.on("update", read);
|
|
1668
|
+
return () => {
|
|
1669
|
+
editor.off("update", read);
|
|
1670
|
+
};
|
|
1671
|
+
}, [editor]);
|
|
1672
|
+
return /* @__PURE__ */ jsx5("div", { className: cn("relative", className), children: /* @__PURE__ */ jsx5(
|
|
1673
|
+
BoxFrame,
|
|
1674
|
+
{
|
|
1675
|
+
editor,
|
|
1676
|
+
marked,
|
|
1677
|
+
selection: selection ?? {},
|
|
1678
|
+
placeholder,
|
|
1679
|
+
empty,
|
|
1680
|
+
attachments,
|
|
1681
|
+
footer: (
|
|
1682
|
+
// The tools are one strip — one Tab stop, arrows along it; Send, the answer rather than a tool, keeps its own.
|
|
1683
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between", children: [
|
|
1684
|
+
tools ? /* @__PURE__ */ jsx5(Toolbar2, { "aria-label": "Compose tools", surface: false, className: "flex items-center gap-1", children: tools }) : /* @__PURE__ */ jsx5("span", {}),
|
|
1685
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2.5", children: [
|
|
1686
|
+
/* @__PURE__ */ jsx5("span", { className: "hidden select-none font-mono text-menu font-normal tracking-wider text-text-muted signal:inline", children: "Enter to send \xB7 Shift+Enter new line" }),
|
|
1687
|
+
/* @__PURE__ */ jsx5(
|
|
1688
|
+
IconButton,
|
|
1689
|
+
{
|
|
1690
|
+
variant: "primary",
|
|
1691
|
+
onMouseDown: (e) => {
|
|
1692
|
+
e.preventDefault();
|
|
1693
|
+
send();
|
|
1694
|
+
},
|
|
1695
|
+
onClick: (e) => {
|
|
1696
|
+
if (e.detail === 0) send();
|
|
1697
|
+
},
|
|
1698
|
+
disabled: !canSend,
|
|
1699
|
+
"aria-label": "Send",
|
|
1700
|
+
tooltip: "Send",
|
|
1701
|
+
tooltipShortcut: "Enter",
|
|
1702
|
+
glow: canSend,
|
|
1703
|
+
children: /* @__PURE__ */ jsx5(IconArrowUp, { size: 16, stroke: 1.5 })
|
|
1704
|
+
}
|
|
1705
|
+
)
|
|
1706
|
+
] })
|
|
1707
|
+
] })
|
|
1708
|
+
)
|
|
1709
|
+
}
|
|
1710
|
+
) });
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1696
1713
|
// src/ComposerTriggers.tsx
|
|
1697
1714
|
import { Extension as Extension8 } from "@tiptap/core";
|
|
1698
1715
|
import { PluginKey as PluginKey7 } from "@tiptap/pm/state";
|
|
@@ -2239,7 +2256,6 @@ var PastedImages = Extension10.create({
|
|
|
2239
2256
|
});
|
|
2240
2257
|
|
|
2241
2258
|
// src/CommentBox.tsx
|
|
2242
|
-
import { ScrollArea as ScrollArea2 } from "@estiva-app/ui";
|
|
2243
2259
|
import { ToolbarButton as ToolbarButton2 } from "@estiva-app/ui";
|
|
2244
2260
|
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2245
2261
|
var ATTACH_EVENT = "commentbox:attach";
|
|
@@ -2259,7 +2275,7 @@ var BoxKeys = Extension11.create({
|
|
|
2259
2275
|
return {
|
|
2260
2276
|
"Mod-Enter": ({ editor }) => editor.storage.composeKeys?.send?.() ?? false,
|
|
2261
2277
|
// Open now, with no grace: the first Escape closes a list, the next is a deliberate cancel (suggestionPopup).
|
|
2262
|
-
Escape: () => isSuggestionOpen() ? false : this.options.onEscape()
|
|
2278
|
+
Escape: ({ editor }) => isSuggestionOpen() ? false : this.options.onEscape(editor)
|
|
2263
2279
|
};
|
|
2264
2280
|
}
|
|
2265
2281
|
});
|
|
@@ -2276,9 +2292,14 @@ function boxExtensions(hold, app) {
|
|
|
2276
2292
|
KeptSelection,
|
|
2277
2293
|
ComposeKeys,
|
|
2278
2294
|
BoxKeys.configure({
|
|
2279
|
-
onEscape: () => {
|
|
2295
|
+
onEscape: (ed) => {
|
|
2280
2296
|
const editing = hold.current.edit;
|
|
2281
2297
|
if (!editing) return false;
|
|
2298
|
+
const { selection } = ed.state;
|
|
2299
|
+
if (!selection.empty) {
|
|
2300
|
+
ed.commands.setTextSelection(selection.to);
|
|
2301
|
+
return true;
|
|
2302
|
+
}
|
|
2282
2303
|
editing.onCancel();
|
|
2283
2304
|
return true;
|
|
2284
2305
|
}
|
|
@@ -2592,22 +2613,28 @@ function CommentBox({
|
|
|
2592
2613
|
const refusedLine = refused && /* @__PURE__ */ jsx7(FieldLine, { tone: "error", children: edit ? `Not saved: ${refused}. Your changes are still in the box.` : `Not sent: ${refused}. Your text is back in the box.` });
|
|
2593
2614
|
if (edit) {
|
|
2594
2615
|
return /* @__PURE__ */ jsxs5("div", { className: cn2("flex flex-col gap-1", className), children: [
|
|
2595
|
-
/* @__PURE__ */
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2616
|
+
/* @__PURE__ */ jsx7(
|
|
2617
|
+
BoxFrame,
|
|
2618
|
+
{
|
|
2619
|
+
editor,
|
|
2620
|
+
marked: marking,
|
|
2621
|
+
selection: { link: true },
|
|
2622
|
+
attachments: fileCards,
|
|
2623
|
+
className: cn2(sending && "[&_.ProseMirror]:text-text-muted"),
|
|
2624
|
+
footer: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2625
|
+
/* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-caption text-text-muted", children: [
|
|
2626
|
+
/* @__PURE__ */ jsx7(Kbd, { children: "Esc" }),
|
|
2627
|
+
" to cancel \xB7 ",
|
|
2628
|
+
/* @__PURE__ */ jsx7(Kbd, { children: "Enter" }),
|
|
2629
|
+
" to save"
|
|
2630
|
+
] }),
|
|
2631
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
2632
|
+
/* @__PURE__ */ jsx7(Button, { variant: "outlined", size: "small", onClick: edit.onCancel, children: "Cancel" }),
|
|
2633
|
+
/* @__PURE__ */ jsx7(Button, { variant: "primary", size: "small", disabled: uploading || sending, onClick: () => save.current(), children: "Save" })
|
|
2634
|
+
] })
|
|
2608
2635
|
] })
|
|
2609
|
-
|
|
2610
|
-
|
|
2636
|
+
}
|
|
2637
|
+
),
|
|
2611
2638
|
underBox,
|
|
2612
2639
|
sending && /* @__PURE__ */ jsx7(FieldLine, { children: "Saving\u2026" }),
|
|
2613
2640
|
refusedLine
|
|
@@ -2621,7 +2648,7 @@ function CommentBox({
|
|
|
2621
2648
|
};
|
|
2622
2649
|
return /* @__PURE__ */ jsxs5("div", { ref: root, className: cn2("flex flex-col gap-1", className), onDragOver: upload ? (e) => e.preventDefault() : void 0, onDrop, children: [
|
|
2623
2650
|
/* @__PURE__ */ jsx7(
|
|
2624
|
-
|
|
2651
|
+
SendBox,
|
|
2625
2652
|
{
|
|
2626
2653
|
editor,
|
|
2627
2654
|
onSend: go,
|
|
@@ -2648,7 +2675,7 @@ function CommentBox({
|
|
|
2648
2675
|
import { useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useRef as useRef4, useState as useState5 } from "react";
|
|
2649
2676
|
import { Extension as Extension12, Node as Node3 } from "@tiptap/core";
|
|
2650
2677
|
import { history, redo, undo } from "@tiptap/pm/history";
|
|
2651
|
-
import { EditorContent as
|
|
2678
|
+
import { EditorContent as EditorContent2, useEditor } from "@tiptap/react";
|
|
2652
2679
|
import { cn as cn3 } from "@estiva-app/ui";
|
|
2653
2680
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2654
2681
|
var VARIANT = {
|
|
@@ -2758,7 +2785,7 @@ function InlineText({ value, placeholder, label, onCommit, onText, onEnter, vari
|
|
|
2758
2785
|
focus: (at = "start") => editor?.commands.focus(at)
|
|
2759
2786
|
}), [editor]);
|
|
2760
2787
|
return /* @__PURE__ */ jsxs6("div", { className: cn3("relative", VARIANT[variant], className), children: [
|
|
2761
|
-
/* @__PURE__ */ jsx8(
|
|
2788
|
+
/* @__PURE__ */ jsx8(EditorContent2, { editor, className: cn3(ROOM, !readOnly && "cursor-text") }),
|
|
2762
2789
|
empty && !readOnly && /* @__PURE__ */ jsx8("span", { "aria-hidden": true, className: "pointer-events-none absolute left-0 top-1 text-text-muted", children: placeholder })
|
|
2763
2790
|
] });
|
|
2764
2791
|
}
|
|
@@ -3482,7 +3509,7 @@ function EditorTableControls({ editor, children, className }) {
|
|
|
3482
3509
|
// src/DocumentEditor.tsx
|
|
3483
3510
|
import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef6, useState as useState7 } from "react";
|
|
3484
3511
|
import { TextSelection as TextSelection4 } from "@tiptap/pm/state";
|
|
3485
|
-
import { EditorContent as
|
|
3512
|
+
import { EditorContent as EditorContent3, useEditor as useEditor2, useEditorState as useEditorState2 } from "@tiptap/react";
|
|
3486
3513
|
import { TableKit } from "@tiptap/extension-table";
|
|
3487
3514
|
import { IconMessagePlus } from "@tabler/icons-react";
|
|
3488
3515
|
import { Button as Button2 } from "@estiva-app/ui";
|
|
@@ -3772,7 +3799,7 @@ function DocumentEditor({
|
|
|
3772
3799
|
const who = changedBy?.name ?? "Someone";
|
|
3773
3800
|
const drawn = /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1", children: [
|
|
3774
3801
|
/* @__PURE__ */ jsxs9(EditorBlockHandle, { editor, actions: blockRows, children: [
|
|
3775
|
-
/* @__PURE__ */ jsx11(EditorTableControls, { editor, children: /* @__PURE__ */ jsx11(
|
|
3802
|
+
/* @__PURE__ */ jsx11(EditorTableControls, { editor, children: /* @__PURE__ */ jsx11(EditorContent3, { editor, className: "-mx-2 cursor-text px-2 py-1", "data-document-editor": "" }) }),
|
|
3776
3803
|
empty && !readOnly && placeholder && /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "pointer-events-none absolute left-0 top-1 text-body-2 text-text-muted", children: placeholder })
|
|
3777
3804
|
] }),
|
|
3778
3805
|
(!readOnly || onCommentOnSelection) && /* @__PURE__ */ jsx11(
|
|
@@ -3823,15 +3850,12 @@ function slashSections({ table, upload, pickFile }) {
|
|
|
3823
3850
|
export {
|
|
3824
3851
|
AttachmentNode,
|
|
3825
3852
|
BlockId,
|
|
3826
|
-
COMPOSE_EDITOR_CLASSES,
|
|
3827
3853
|
Callout,
|
|
3828
3854
|
CaptionedReference,
|
|
3829
3855
|
Checklist,
|
|
3830
3856
|
CodeBlockColours,
|
|
3831
3857
|
CommentBox,
|
|
3832
3858
|
CommentHighlights,
|
|
3833
|
-
ComposeBox,
|
|
3834
|
-
ComposeKeys,
|
|
3835
3859
|
DocumentEditor,
|
|
3836
3860
|
EditorBlockHandle,
|
|
3837
3861
|
EditorTableControls,
|