@estiva-app/ui 0.87.1 → 0.88.1
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/BlockNodes.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +8 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ComposerTriggers.d.ts.map +1 -1
- package/dist/editor.js +160 -136
- package/dist/editor.js.map +4 -4
- package/package.json +1 -1
- package/registry.json +1 -1
- package/src/BlockNodes.tsx +3 -0
- package/src/CommentBox.mdx +3 -3
- package/src/CommentBox.test.tsx +65 -3
- package/src/CommentBox.tsx +40 -21
- package/src/ComposerTriggers.test.tsx +83 -0
- package/src/ComposerTriggers.tsx +18 -1
package/dist/BlockNodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockNodes.d.ts","sourceRoot":"","sources":["../src/BlockNodes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,SAAS,EAAa,IAAI,EAAe,MAAM,cAAc,CAAA;AAEtE,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAMxF,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"BlockNodes.d.ts","sourceRoot":"","sources":["../src/BlockNodes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,SAAS,EAAa,IAAI,EAAe,MAAM,cAAc,CAAA;AAEtE,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAMxF,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AA6QtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,OAAO,qBA+ClB,CAAA;AAKF,gHAAgH;AAChH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,iCA6ExB,CAAA;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,gBAqBvB,CAAA;AAgBF,uEAAuE;AACvE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,IAAI,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAA;CAChD;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,kCAqCzB,CAAA;AAIF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEjE;AAsFD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,qBAiFpB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,qBAkBlB,CAAA"}
|
package/dist/CommentBox.d.ts
CHANGED
|
@@ -56,8 +56,15 @@ export interface CommentBoxDraft {
|
|
|
56
56
|
export interface CommentBoxEdit {
|
|
57
57
|
/** What it says now, as `composerDocument` opens it. */
|
|
58
58
|
body: JSONContent;
|
|
59
|
-
/** Its files, which can be taken off;
|
|
59
|
+
/** Its files, which can be taken off; with `upload` and `writesFiles`, more can be added by `/` → Upload, a paste or a drop. A box reopened after a refusal is given the files that save carried. */
|
|
60
60
|
files?: BoxFile[];
|
|
61
|
+
/**
|
|
62
|
+
* The app's `onSave` writes the files it is handed, so a file can be added while editing (with `upload`).
|
|
63
|
+
* Opt-in, so an app whose save drops them never offers it: a file added and silently lost.
|
|
64
|
+
*/
|
|
65
|
+
writesFiles?: boolean;
|
|
66
|
+
/** Why the relay refused this edit, when the app reopens a box it closed at once: said under it as it opens. Read as the box opens, so a reopen is a new box (a new `key`). */
|
|
67
|
+
refused?: string;
|
|
61
68
|
onCancel: () => void;
|
|
62
69
|
/** Save; the box holds the words until the answer, and a refusal is said under it. */
|
|
63
70
|
onSave: (body: JSONContent, files: BoxFile[], under: BoxSentUnder) => Promise<SendAnswer>;
|
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,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,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAGxD,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;AAU3B;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjF,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OA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MAAM,OAAO,EAAE,SAAS,SAAS,EAQvC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,SAAS,EAIhD,CAAA;AAED,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE3C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAE,UAAqB,GAAG,OAAO,CA2D9F;AAgBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,UAAqB,GAAG,YAAY,CAavE;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAM9D;AAMD,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAGpG;AAED,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAA;CAClC;AAID;;;;GAIG;AACH,eAAO,MAAM,aAAa,sCAgCxB,CAAA"}
|
package/dist/editor.js
CHANGED
|
@@ -309,7 +309,7 @@ import { Extension as Extension6, InputRule, Node as Node2 } from "@tiptap/core"
|
|
|
309
309
|
import { DOMSerializer } from "@tiptap/pm/model";
|
|
310
310
|
import { Plugin as Plugin6, PluginKey as PluginKey6 } from "@tiptap/pm/state";
|
|
311
311
|
import { Mapping, ReplaceAroundStep } from "@tiptap/pm/transform";
|
|
312
|
-
import { NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer } from "@tiptap/react";
|
|
312
|
+
import { NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer as ReactRenderer2 } from "@tiptap/react";
|
|
313
313
|
import { Checkbox } from "@estiva-app/ui";
|
|
314
314
|
import { calloutLook } from "@estiva-app/ui";
|
|
315
315
|
|
|
@@ -955,8 +955,120 @@ function ReferenceMenuView({ editor }) {
|
|
|
955
955
|
);
|
|
956
956
|
}
|
|
957
957
|
|
|
958
|
-
// src/
|
|
958
|
+
// src/suggestionPopup.tsx
|
|
959
|
+
import { forwardRef, useRef as useRef2, useImperativeHandle } from "react";
|
|
960
|
+
import { ReactRenderer } from "@tiptap/react";
|
|
961
|
+
import { exitSuggestion } from "@tiptap/suggestion";
|
|
962
|
+
import { SuggestionMenu } from "@estiva-app/ui";
|
|
959
963
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
964
|
+
var openCount = 0;
|
|
965
|
+
var lastClose = 0;
|
|
966
|
+
function isSuggestionActive() {
|
|
967
|
+
return openCount > 0 || Date.now() - lastClose < 100;
|
|
968
|
+
}
|
|
969
|
+
function isSuggestionOpen() {
|
|
970
|
+
return openCount > 0;
|
|
971
|
+
}
|
|
972
|
+
var Popup = forwardRef(function Popup2({ options, ...props }, handle) {
|
|
973
|
+
const menu = useRef2(null);
|
|
974
|
+
useImperativeHandle(handle, () => ({ onKeyDown: (event) => menu.current?.onKeyDown(event) ?? false }));
|
|
975
|
+
const sections = options.sections ? options.sections(props.items, props.query) : [{ items: props.items }];
|
|
976
|
+
return /* @__PURE__ */ jsx3(
|
|
977
|
+
SuggestionMenu,
|
|
978
|
+
{
|
|
979
|
+
handle: menu,
|
|
980
|
+
rect: props.clientRect?.() ?? null,
|
|
981
|
+
editorElement: props.editor.view.dom,
|
|
982
|
+
ariaLabel: options.ariaLabel,
|
|
983
|
+
width: options.width,
|
|
984
|
+
maxHeight: options.maxHeight,
|
|
985
|
+
sections,
|
|
986
|
+
itemKey: options.itemKey,
|
|
987
|
+
row: options.row,
|
|
988
|
+
onSelect: (item) => props.command(item)
|
|
989
|
+
}
|
|
990
|
+
);
|
|
991
|
+
});
|
|
992
|
+
function suggestionPopup(options) {
|
|
993
|
+
return () => {
|
|
994
|
+
let component = null;
|
|
995
|
+
let container = null;
|
|
996
|
+
let last = null;
|
|
997
|
+
let unsubscribe;
|
|
998
|
+
let counted = false;
|
|
999
|
+
let unlisten;
|
|
1000
|
+
const count = (shown) => {
|
|
1001
|
+
if (shown === counted) return;
|
|
1002
|
+
counted = shown;
|
|
1003
|
+
openCount = shown ? openCount + 1 : Math.max(0, openCount - 1);
|
|
1004
|
+
};
|
|
1005
|
+
const listen = (props) => {
|
|
1006
|
+
const { view } = props.editor;
|
|
1007
|
+
const dom = view.dom;
|
|
1008
|
+
const onBlur = () => {
|
|
1009
|
+
if (dom.contains(document.activeElement) || !last) return;
|
|
1010
|
+
const from = last.range.from;
|
|
1011
|
+
count(false);
|
|
1012
|
+
for (const plugin of view.state.plugins) {
|
|
1013
|
+
const state = plugin.getState(view.state);
|
|
1014
|
+
if (state?.active && state.range?.from === from && plugin.spec.key) exitSuggestion(view, plugin.spec.key);
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
dom.addEventListener("blur", onBlur);
|
|
1018
|
+
unlisten = () => dom.removeEventListener("blur", onBlur);
|
|
1019
|
+
};
|
|
1020
|
+
const exit = () => {
|
|
1021
|
+
unsubscribe?.();
|
|
1022
|
+
unsubscribe = void 0;
|
|
1023
|
+
unlisten?.();
|
|
1024
|
+
unlisten = void 0;
|
|
1025
|
+
last = null;
|
|
1026
|
+
if (counted) lastClose = Date.now();
|
|
1027
|
+
count(false);
|
|
1028
|
+
if (!component) return;
|
|
1029
|
+
component.destroy();
|
|
1030
|
+
container?.remove();
|
|
1031
|
+
component = null;
|
|
1032
|
+
container = null;
|
|
1033
|
+
};
|
|
1034
|
+
return {
|
|
1035
|
+
onStart: (props) => {
|
|
1036
|
+
count(props.items.length > 0);
|
|
1037
|
+
component = new ReactRenderer(Popup, { props: { ...props, options }, editor: props.editor });
|
|
1038
|
+
container = document.createElement("div");
|
|
1039
|
+
document.body.appendChild(container);
|
|
1040
|
+
container.appendChild(component.element);
|
|
1041
|
+
last = props;
|
|
1042
|
+
listen(props);
|
|
1043
|
+
const { subscribe, refresh } = options;
|
|
1044
|
+
if (subscribe && refresh) {
|
|
1045
|
+
unsubscribe = subscribe(() => {
|
|
1046
|
+
if (!last || !component) return;
|
|
1047
|
+
last = { ...last, items: refresh(last.query) };
|
|
1048
|
+
count(last.items.length > 0);
|
|
1049
|
+
component.updateProps({ ...last, options });
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
onUpdate: (props) => {
|
|
1054
|
+
last = props;
|
|
1055
|
+
count(props.items.length > 0);
|
|
1056
|
+
component?.updateProps({ ...props, options });
|
|
1057
|
+
},
|
|
1058
|
+
onKeyDown: ({ event }) => {
|
|
1059
|
+
if (event.key === "Escape") {
|
|
1060
|
+
exit();
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
return component?.ref?.onKeyDown(event) ?? false;
|
|
1064
|
+
},
|
|
1065
|
+
onExit: exit
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// src/BlockNodes.tsx
|
|
1071
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
960
1072
|
var BLOCK_TYPES = [
|
|
961
1073
|
"paragraph",
|
|
962
1074
|
"heading",
|
|
@@ -1203,7 +1315,7 @@ var ReferenceNode = Node2.create({
|
|
|
1203
1315
|
const uri = String(node.attrs.uri ?? "");
|
|
1204
1316
|
const href = typeof node.attrs.href === "string" && node.attrs.href ? node.attrs.href : void 0;
|
|
1205
1317
|
const place2 = placeOf(decorations);
|
|
1206
|
-
return /* @__PURE__ */
|
|
1318
|
+
return /* @__PURE__ */ jsx4(
|
|
1207
1319
|
NodeViewWrapper,
|
|
1208
1320
|
{
|
|
1209
1321
|
as: "span",
|
|
@@ -1218,7 +1330,7 @@ var ReferenceNode = Node2.create({
|
|
|
1218
1330
|
event.preventDefault();
|
|
1219
1331
|
event.stopPropagation();
|
|
1220
1332
|
},
|
|
1221
|
-
children: uri ? /* @__PURE__ */
|
|
1333
|
+
children: uri ? /* @__PURE__ */ jsx4(View, { uri, ...href ? { href } : {}, place: place2, editing: editor.isEditable }) : /* @__PURE__ */ jsx4("span", { children: href })
|
|
1222
1334
|
}
|
|
1223
1335
|
);
|
|
1224
1336
|
}, {
|
|
@@ -1255,7 +1367,7 @@ var UnknownBlock = Node2.create({
|
|
|
1255
1367
|
function UnknownBlockView({ node }) {
|
|
1256
1368
|
const source = node.attrs.source;
|
|
1257
1369
|
const text = String(node.attrs.text ?? "");
|
|
1258
|
-
return /* @__PURE__ */
|
|
1370
|
+
return /* @__PURE__ */ jsx4(
|
|
1259
1371
|
NodeViewWrapper,
|
|
1260
1372
|
{
|
|
1261
1373
|
"data-block-id": source?.id,
|
|
@@ -1295,7 +1407,7 @@ var AttachmentNode = Node2.create({
|
|
|
1295
1407
|
addNodeView() {
|
|
1296
1408
|
const View = this.options.view;
|
|
1297
1409
|
if (!View) return null;
|
|
1298
|
-
return ReactNodeViewRenderer(({ node }) => /* @__PURE__ */
|
|
1410
|
+
return ReactNodeViewRenderer(({ node }) => /* @__PURE__ */ jsx4(NodeViewWrapper, { className: "my-2", children: /* @__PURE__ */ jsx4(View, { attrs: node.attrs }) }));
|
|
1299
1411
|
}
|
|
1300
1412
|
});
|
|
1301
1413
|
var TICK = "checklistTick";
|
|
@@ -1332,7 +1444,7 @@ function listItemView(editor, node, view, getPos) {
|
|
|
1332
1444
|
};
|
|
1333
1445
|
let words = node.firstChild?.textContent.trim() || "Item";
|
|
1334
1446
|
const props = () => ({ checked, onChange: view.editable ? tick : void 0, "aria-label": words });
|
|
1335
|
-
const renderer = new
|
|
1447
|
+
const renderer = new ReactRenderer2(Checkbox, { editor, props: props(), as: "span" });
|
|
1336
1448
|
box.appendChild(renderer.element);
|
|
1337
1449
|
let drawn = "";
|
|
1338
1450
|
const sync = () => {
|
|
@@ -1404,6 +1516,7 @@ var Checklist = Extension6.create({
|
|
|
1404
1516
|
addKeyboardShortcuts() {
|
|
1405
1517
|
return {
|
|
1406
1518
|
Enter: () => {
|
|
1519
|
+
if (isSuggestionOpen()) return false;
|
|
1407
1520
|
const { state } = this.editor;
|
|
1408
1521
|
const item = itemAtCaret(state);
|
|
1409
1522
|
const { $from, empty } = state.selection;
|
|
@@ -1476,118 +1589,6 @@ import { ScrollArea } from "@estiva-app/ui";
|
|
|
1476
1589
|
var FLOATING_SURFACE_CLASSES = "rounded-lg border border-border-default bg-bg-elevated shadow-lg";
|
|
1477
1590
|
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
1591
|
|
|
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
1592
|
// src/commentBoxFrame.tsx
|
|
1592
1593
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1593
1594
|
var COMPOSE_EDITOR_CLASSES = richTextClassName("default", "outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1");
|
|
@@ -1984,11 +1985,17 @@ var DOCUMENT_FORMATS = [
|
|
|
1984
1985
|
{ id: "warning", label: "Warning" }
|
|
1985
1986
|
];
|
|
1986
1987
|
function applyFormat(editor, id, code = "inline") {
|
|
1987
|
-
const chain = editor.chain().focus();
|
|
1988
1988
|
const run = (command, ...args) => {
|
|
1989
|
+
const chain = editor.chain().focus();
|
|
1989
1990
|
const named2 = chain[command];
|
|
1990
1991
|
return named2 ? named2(...args).run() : false;
|
|
1991
1992
|
};
|
|
1993
|
+
const leaveList = () => {
|
|
1994
|
+
if (!editor.schema.nodes.blockquote) return false;
|
|
1995
|
+
let left = false;
|
|
1996
|
+
while (editor.isActive("listItem") && run("liftListItem", "listItem")) left = true;
|
|
1997
|
+
return left;
|
|
1998
|
+
};
|
|
1992
1999
|
switch (id) {
|
|
1993
2000
|
case "paragraph":
|
|
1994
2001
|
return run("setParagraph");
|
|
@@ -1997,6 +2004,7 @@ function applyFormat(editor, id, code = "inline") {
|
|
|
1997
2004
|
case "subheading":
|
|
1998
2005
|
return run("setHeading", { level: 2 });
|
|
1999
2006
|
case "quote":
|
|
2007
|
+
if (leaveList() && editor.isActive("blockquote")) return true;
|
|
2000
2008
|
return run("toggleBlockquote");
|
|
2001
2009
|
case "bulletList":
|
|
2002
2010
|
return run("toggleBulletList");
|
|
@@ -2011,6 +2019,7 @@ function applyFormat(editor, id, code = "inline") {
|
|
|
2011
2019
|
}
|
|
2012
2020
|
case "note":
|
|
2013
2021
|
case "warning": {
|
|
2022
|
+
leaveList();
|
|
2014
2023
|
if (!editor.isActive("blockquote") && !run("toggleBlockquote")) return false;
|
|
2015
2024
|
return editor.chain().updateAttributes("blockquote", { tone: id }).run();
|
|
2016
2025
|
}
|
|
@@ -2423,7 +2432,7 @@ function CommentBox({
|
|
|
2423
2432
|
}) {
|
|
2424
2433
|
const [files, setFiles] = useState4(edit?.files ?? []);
|
|
2425
2434
|
const [sending, setSending] = useState4(false);
|
|
2426
|
-
const [refused, setRefused] = useState4(null);
|
|
2435
|
+
const [refused, setRefused] = useState4(edit?.refused ?? null);
|
|
2427
2436
|
const [reading, setReading] = useState4(void 0);
|
|
2428
2437
|
const [removed, setRemoved] = useState4(() => /* @__PURE__ */ new Set());
|
|
2429
2438
|
const picker = useRef3(null);
|
|
@@ -2433,7 +2442,7 @@ function CommentBox({
|
|
|
2433
2442
|
const save = useRef3(() => false);
|
|
2434
2443
|
const attachFiles = useCallback4((picked) => {
|
|
2435
2444
|
const uploadOne = latest.current.upload;
|
|
2436
|
-
if (!uploadOne || latest.current.edit) return false;
|
|
2445
|
+
if (!uploadOne || latest.current.edit && !latest.current.edit.writesFiles) return false;
|
|
2437
2446
|
for (const file of picked) {
|
|
2438
2447
|
fileCount += 1;
|
|
2439
2448
|
const id = `file-${fileCount}`;
|
|
@@ -2447,7 +2456,8 @@ function CommentBox({
|
|
|
2447
2456
|
}
|
|
2448
2457
|
return true;
|
|
2449
2458
|
}, []);
|
|
2450
|
-
const
|
|
2459
|
+
const takesFiles = !!upload && (!edit || !!edit.writesFiles);
|
|
2460
|
+
const rows = insert.filter((c) => !(!takesFiles && c.key === commentBoxRows.file.key) && !(edit && c.key === commentBoxRows.urgent.key));
|
|
2451
2461
|
const { editor, hold } = useBoxEditor({ extensions, referenceView: referenceView ?? null }, edit?.body ?? draft?.read(), {
|
|
2452
2462
|
editable: !closed,
|
|
2453
2463
|
editorProps: { attributes: { class: COMPOSE_EDITOR_CLASSES, role: "textbox", "aria-multiline": "true", "aria-label": label } }
|
|
@@ -2520,11 +2530,11 @@ function CommentBox({
|
|
|
2520
2530
|
}, [editor]);
|
|
2521
2531
|
useEffect4(() => {
|
|
2522
2532
|
const box = root.current;
|
|
2523
|
-
if (!box || !
|
|
2533
|
+
if (!box || !takesFiles) return;
|
|
2524
2534
|
const ask = () => picker.current?.click();
|
|
2525
2535
|
box.addEventListener(ATTACH_EVENT, ask);
|
|
2526
2536
|
return () => box.removeEventListener(ATTACH_EVENT, ask);
|
|
2527
|
-
}, [
|
|
2537
|
+
}, [takesFiles]);
|
|
2528
2538
|
const uploading = files.some((f) => f.state === "uploading");
|
|
2529
2539
|
const failed = files.filter((f) => f.state === "failed").length;
|
|
2530
2540
|
const ready = files.some((f) => f.state === "ready");
|
|
@@ -2574,7 +2584,7 @@ function CommentBox({
|
|
|
2574
2584
|
[files, removed, underOf, showsAtOnce, send, draft, onSent, onRefused]
|
|
2575
2585
|
);
|
|
2576
2586
|
save.current = () => {
|
|
2577
|
-
if (!editor || !edit || sending || uploading) return true;
|
|
2587
|
+
if (!editor || !edit || sending || uploading || failed > 0) return true;
|
|
2578
2588
|
setRefused(null);
|
|
2579
2589
|
setSending(true);
|
|
2580
2590
|
const body = editor.getJSON();
|
|
@@ -2619,8 +2629,27 @@ function CommentBox({
|
|
|
2619
2629
|
parts.map((part) => /* @__PURE__ */ jsx7(Fragment2, { children: part.view }, part.key))
|
|
2620
2630
|
] }) : void 0;
|
|
2621
2631
|
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.` });
|
|
2632
|
+
const onDrop = (event) => {
|
|
2633
|
+
const dropped = Array.from(event.dataTransfer?.files ?? []);
|
|
2634
|
+
if (dropped.length === 0 || !takesFiles) return;
|
|
2635
|
+
event.preventDefault();
|
|
2636
|
+
attachFiles(dropped);
|
|
2637
|
+
};
|
|
2638
|
+
const fileLines = /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
2639
|
+
uploading && !sending && /* @__PURE__ */ jsxs5(FieldLine, { children: [
|
|
2640
|
+
"Uploading\u2026 ",
|
|
2641
|
+
edit ? "Save" : "Send",
|
|
2642
|
+
" waits for the file."
|
|
2643
|
+
] }),
|
|
2644
|
+
failed > 0 && !uploading && !sending && /* @__PURE__ */ jsxs5(FieldLine, { children: [
|
|
2645
|
+
failed === 1 ? "Remove the file that did not upload" : "Remove the files that did not upload",
|
|
2646
|
+
" to ",
|
|
2647
|
+
edit ? "save" : "send",
|
|
2648
|
+
"."
|
|
2649
|
+
] })
|
|
2650
|
+
] });
|
|
2622
2651
|
if (edit) {
|
|
2623
|
-
return /* @__PURE__ */ jsxs5("div", { className: cn2("flex flex-col gap-1", className), children: [
|
|
2652
|
+
return /* @__PURE__ */ jsxs5("div", { ref: root, className: cn2("flex flex-col gap-1", className), onDragOver: takesFiles ? (e) => e.preventDefault() : void 0, onDrop, children: [
|
|
2624
2653
|
/* @__PURE__ */ jsx7(
|
|
2625
2654
|
BoxFrame,
|
|
2626
2655
|
{
|
|
@@ -2638,22 +2667,18 @@ function CommentBox({
|
|
|
2638
2667
|
] }),
|
|
2639
2668
|
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
2640
2669
|
/* @__PURE__ */ jsx7(Button, { variant: "outlined", size: "small", onClick: edit.onCancel, children: "Cancel" }),
|
|
2641
|
-
/* @__PURE__ */ jsx7(Button, { variant: "primary", size: "small", disabled: uploading || sending, onClick: () => save.current(), children: "Save" })
|
|
2670
|
+
/* @__PURE__ */ jsx7(Button, { variant: "primary", size: "small", disabled: uploading || failed > 0 || sending, onClick: () => save.current(), children: "Save" })
|
|
2642
2671
|
] })
|
|
2643
2672
|
] })
|
|
2644
2673
|
}
|
|
2645
2674
|
),
|
|
2646
2675
|
underBox,
|
|
2676
|
+
takesFiles && /* @__PURE__ */ jsx7(FilePicker, { ref: picker, multiple: true, accept, onPick: attachFiles }),
|
|
2647
2677
|
sending && /* @__PURE__ */ jsx7(FieldLine, { children: "Saving\u2026" }),
|
|
2678
|
+
fileLines,
|
|
2648
2679
|
refusedLine
|
|
2649
2680
|
] });
|
|
2650
2681
|
}
|
|
2651
|
-
const onDrop = (event) => {
|
|
2652
|
-
const dropped = Array.from(event.dataTransfer?.files ?? []);
|
|
2653
|
-
if (dropped.length === 0 || !upload) return;
|
|
2654
|
-
event.preventDefault();
|
|
2655
|
-
attachFiles(dropped);
|
|
2656
|
-
};
|
|
2657
2682
|
return /* @__PURE__ */ jsxs5("div", { ref: root, className: cn2("flex flex-col gap-1", className), onDragOver: upload ? (e) => e.preventDefault() : void 0, onDrop, children: [
|
|
2658
2683
|
/* @__PURE__ */ jsx7(
|
|
2659
2684
|
SendBox,
|
|
@@ -2673,8 +2698,7 @@ function CommentBox({
|
|
|
2673
2698
|
underBox,
|
|
2674
2699
|
upload && /* @__PURE__ */ jsx7(FilePicker, { ref: picker, multiple: true, accept, onPick: attachFiles }),
|
|
2675
2700
|
sending && /* @__PURE__ */ jsx7(FieldLine, { children: "Sending\u2026" }),
|
|
2676
|
-
|
|
2677
|
-
failed > 0 && !uploading && !sending && /* @__PURE__ */ jsx7(FieldLine, { children: failed === 1 ? "Remove the file that did not upload to send." : "Remove the files that did not upload to send." }),
|
|
2701
|
+
fileLines,
|
|
2678
2702
|
refusedLine
|
|
2679
2703
|
] });
|
|
2680
2704
|
}
|