@pixerate/editor-react 0.207.0 → 0.209.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/{chunk-HOFRSMB6.js → chunk-MK3YNIBU.js} +1500 -1188
- package/dist/hooks/useLinkFocus.d.cts +36 -0
- package/dist/hooks/useLinkFocus.d.ts +36 -0
- package/dist/image-editor/LayersPanel.d.cts +6 -1
- package/dist/image-editor/LayersPanel.d.ts +6 -1
- package/dist/image-editor/SmartObjectPanel.d.cts +16 -0
- package/dist/image-editor/SmartObjectPanel.d.ts +16 -0
- package/dist/image-editor/index.cjs +1903 -1599
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +3 -1
- package/dist/index.cjs +2872 -2535
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +102 -68
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ export { formatCommandsFor, type FormatManifest, type FormatManifestCommand, typ
|
|
|
4
4
|
export * from "./hooks/useNavigationGuard.cjs";
|
|
5
5
|
export * from "./hooks/useDismissGuard.cjs";
|
|
6
6
|
export * from "./hooks/useHistory.cjs";
|
|
7
|
+
export * from "./hooks/useLinkFocus.cjs";
|
|
7
8
|
export * from "./hooks/useHistoryDirty.cjs";
|
|
8
9
|
export * from "./hooks/useHistoryShortcuts.cjs";
|
|
9
10
|
export * from "./hooks/useFileImport.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { formatCommandsFor, type FormatManifest, type FormatManifestCommand, typ
|
|
|
4
4
|
export * from "./hooks/useNavigationGuard.js";
|
|
5
5
|
export * from "./hooks/useDismissGuard.js";
|
|
6
6
|
export * from "./hooks/useHistory.js";
|
|
7
|
+
export * from "./hooks/useLinkFocus.js";
|
|
7
8
|
export * from "./hooks/useHistoryDirty.js";
|
|
8
9
|
export * from "./hooks/useHistoryShortcuts.js";
|
|
9
10
|
export * from "./hooks/useFileImport.js";
|
package/dist/index.js
CHANGED
|
@@ -57,12 +57,13 @@ import {
|
|
|
57
57
|
SelectionRecipePanel,
|
|
58
58
|
SeparateSubjectPanel,
|
|
59
59
|
ShapeOptionsBar,
|
|
60
|
+
SmartObjectPanel,
|
|
60
61
|
TypeOptionsBar,
|
|
61
62
|
VectorMaskEdgesPanel,
|
|
62
63
|
useImageEditor,
|
|
63
64
|
useImageEffectsTools,
|
|
64
65
|
useImageHistogram
|
|
65
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-MK3YNIBU.js";
|
|
66
67
|
import {
|
|
67
68
|
ImageCheckbox,
|
|
68
69
|
ImageColor,
|
|
@@ -397,8 +398,39 @@ function useHistory(managerOrOptions) {
|
|
|
397
398
|
};
|
|
398
399
|
}
|
|
399
400
|
|
|
401
|
+
// src/hooks/useLinkFocus.ts
|
|
402
|
+
import { useCallback as useCallback4, useState as useState3, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
403
|
+
import { createLinkFocus } from "@pixerate/editor/tools";
|
|
404
|
+
function useLinkFocus(options) {
|
|
405
|
+
const [model] = useState3(() => options.model ?? createLinkFocus({ marks: options.marks ?? [], links: options.links ?? {}, order: options.order, labels: options.labels, dim: options.dim }));
|
|
406
|
+
const state = useSyncExternalStore2(model.subscribe, model.getState, model.getState);
|
|
407
|
+
const markProps = useCallback4(
|
|
408
|
+
(key) => ({ onPointerEnter: () => model.focus(key), onFocus: () => model.focus(key), "data-link-focus": key }),
|
|
409
|
+
[model]
|
|
410
|
+
);
|
|
411
|
+
const rootProps = {
|
|
412
|
+
onKeyDown: (event) => {
|
|
413
|
+
if (model.handleKey(event)) event.preventDefault();
|
|
414
|
+
},
|
|
415
|
+
onPointerLeave: () => {
|
|
416
|
+
model.clear();
|
|
417
|
+
},
|
|
418
|
+
onBlur: (event) => {
|
|
419
|
+
if (!event.currentTarget.contains(event.relatedTarget)) model.clear();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
model,
|
|
424
|
+
state,
|
|
425
|
+
markProps,
|
|
426
|
+
rootProps,
|
|
427
|
+
opacity: (index) => state.lit[index] ? 1 : model.dim,
|
|
428
|
+
description: model.describe(state.focus)
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
400
432
|
// src/hooks/useHistoryDirty.ts
|
|
401
|
-
import { useCallback as
|
|
433
|
+
import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef5, useState as useState4, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
402
434
|
import {
|
|
403
435
|
DirtyTracker,
|
|
404
436
|
bindDirtyToHistory
|
|
@@ -406,7 +438,7 @@ import {
|
|
|
406
438
|
function useHistoryDirty(options) {
|
|
407
439
|
const getValueRef = useRef5(options.getValue);
|
|
408
440
|
getValueRef.current = options.getValue;
|
|
409
|
-
const [tracker] =
|
|
441
|
+
const [tracker] = useState4(
|
|
410
442
|
() => options.tracker ?? new DirtyTracker(options.getValue(), {
|
|
411
443
|
isEqual: options.isEqual,
|
|
412
444
|
normalize: options.normalize
|
|
@@ -425,20 +457,20 @@ function useHistoryDirty(options) {
|
|
|
425
457
|
if (bindingRef.current === binding) bindingRef.current = null;
|
|
426
458
|
};
|
|
427
459
|
}, [options.history, tracker]);
|
|
428
|
-
const isDirty =
|
|
429
|
-
|
|
460
|
+
const isDirty = useSyncExternalStore3(
|
|
461
|
+
useCallback5((onChange) => tracker.subscribe(onChange), [tracker]),
|
|
430
462
|
() => tracker.dirty,
|
|
431
463
|
() => tracker.dirty
|
|
432
464
|
);
|
|
433
|
-
const markClean =
|
|
465
|
+
const markClean = useCallback5(
|
|
434
466
|
() => tracker.markClean(getValueRef.current()),
|
|
435
467
|
[tracker]
|
|
436
468
|
);
|
|
437
|
-
const suppress =
|
|
469
|
+
const suppress = useCallback5(
|
|
438
470
|
(fn) => bindingRef.current ? bindingRef.current.suppress(fn) : tracker.suppress(fn),
|
|
439
471
|
[tracker]
|
|
440
472
|
);
|
|
441
|
-
const refresh =
|
|
473
|
+
const refresh = useCallback5(
|
|
442
474
|
() => tracker.update(getValueRef.current()),
|
|
443
475
|
[tracker]
|
|
444
476
|
);
|
|
@@ -477,7 +509,7 @@ function useHistoryShortcuts(manager, options = {}) {
|
|
|
477
509
|
}
|
|
478
510
|
|
|
479
511
|
// src/hooks/useFileImport.ts
|
|
480
|
-
import { useEffect as useEffect5, useMemo as useMemo3, useRef as useRef6, useSyncExternalStore as
|
|
512
|
+
import { useEffect as useEffect5, useMemo as useMemo3, useRef as useRef6, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
481
513
|
import {
|
|
482
514
|
FileImportController,
|
|
483
515
|
summarizeImportStructure
|
|
@@ -495,7 +527,7 @@ function useFileImport(editor, options = {}) {
|
|
|
495
527
|
useEffect5(() => {
|
|
496
528
|
controller.setOptions(options);
|
|
497
529
|
});
|
|
498
|
-
const state =
|
|
530
|
+
const state = useSyncExternalStore4(controller.subscribe, controller.getState, controller.getState);
|
|
499
531
|
const structureSummary = useMemo3(() => summarizeImportStructure(state.lastOutcomes), [state.lastOutcomes]);
|
|
500
532
|
return {
|
|
501
533
|
...state,
|
|
@@ -507,7 +539,7 @@ function useFileImport(editor, options = {}) {
|
|
|
507
539
|
}
|
|
508
540
|
|
|
509
541
|
// src/hooks/useDocxExport.ts
|
|
510
|
-
import { useEffect as useEffect6, useMemo as useMemo4, useRef as useRef7, useSyncExternalStore as
|
|
542
|
+
import { useEffect as useEffect6, useMemo as useMemo4, useRef as useRef7, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
511
543
|
import {
|
|
512
544
|
DocxExportController
|
|
513
545
|
} from "@pixerate/editor/export";
|
|
@@ -524,7 +556,7 @@ function useDocxExport(editor, options = {}) {
|
|
|
524
556
|
useEffect6(() => {
|
|
525
557
|
controller.setOptions(options);
|
|
526
558
|
});
|
|
527
|
-
const state =
|
|
559
|
+
const state = useSyncExternalStore5(controller.subscribe, controller.getState, controller.getState);
|
|
528
560
|
return {
|
|
529
561
|
...state,
|
|
530
562
|
download: (fileName) => controller.download(fileName),
|
|
@@ -582,10 +614,10 @@ function useRichTextEditorDocument(editor) {
|
|
|
582
614
|
}
|
|
583
615
|
|
|
584
616
|
// src/hooks/useToolBridge.ts
|
|
585
|
-
import { useEffect as useEffect9, useState as
|
|
617
|
+
import { useEffect as useEffect9, useState as useState5 } from "react";
|
|
586
618
|
import { connectToolBridge } from "@pixerate/editor/tools";
|
|
587
619
|
function useToolBridge(registry, options) {
|
|
588
|
-
const [state, setState] =
|
|
620
|
+
const [state, setState] = useState5({ status: "off", editorId: null });
|
|
589
621
|
const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
|
|
590
622
|
useEffect9(() => {
|
|
591
623
|
if (!registry || !options) {
|
|
@@ -638,7 +670,7 @@ var EditorContent = ({
|
|
|
638
670
|
};
|
|
639
671
|
|
|
640
672
|
// src/components/BubbleMenu.tsx
|
|
641
|
-
import { useEffect as useEffect11, useRef as useRef8, useState as
|
|
673
|
+
import { useEffect as useEffect11, useRef as useRef8, useState as useState6 } from "react";
|
|
642
674
|
import { createPortal } from "react-dom";
|
|
643
675
|
import {
|
|
644
676
|
BubbleMenuPlugin
|
|
@@ -653,7 +685,7 @@ var BubbleMenu = ({
|
|
|
653
685
|
updateDelay
|
|
654
686
|
}) => {
|
|
655
687
|
const menuEl = useRef8(null);
|
|
656
|
-
const [mounted, setMounted] =
|
|
688
|
+
const [mounted, setMounted] = useState6(false);
|
|
657
689
|
if (!menuEl.current && typeof document !== "undefined") {
|
|
658
690
|
menuEl.current = document.createElement("div");
|
|
659
691
|
}
|
|
@@ -800,7 +832,7 @@ var TemplateRenderer = ({
|
|
|
800
832
|
};
|
|
801
833
|
|
|
802
834
|
// src/components/VariableForm.tsx
|
|
803
|
-
import { useId, useMemo as useMemo8, useState as
|
|
835
|
+
import { useId, useMemo as useMemo8, useState as useState7 } from "react";
|
|
804
836
|
import {
|
|
805
837
|
compactVariableValues,
|
|
806
838
|
getVariableFormFields
|
|
@@ -816,7 +848,7 @@ var VariableForm = ({
|
|
|
816
848
|
className = "flex flex-col gap-3 text-sm"
|
|
817
849
|
}) => {
|
|
818
850
|
const idPrefix = useId();
|
|
819
|
-
const [internal, setInternal] =
|
|
851
|
+
const [internal, setInternal] = useState7(
|
|
820
852
|
() => defaultValues ?? {}
|
|
821
853
|
);
|
|
822
854
|
const entered = values ?? internal;
|
|
@@ -888,10 +920,10 @@ var VariableForm = ({
|
|
|
888
920
|
};
|
|
889
921
|
|
|
890
922
|
// src/components/MergePreview.tsx
|
|
891
|
-
import { useId as useId2, useState as
|
|
923
|
+
import { useId as useId2, useState as useState9 } from "react";
|
|
892
924
|
|
|
893
925
|
// src/hooks/useMergePreview.ts
|
|
894
|
-
import { useCallback as
|
|
926
|
+
import { useCallback as useCallback6, useMemo as useMemo9, useState as useState8 } from "react";
|
|
895
927
|
import {
|
|
896
928
|
extractVariables,
|
|
897
929
|
matchFields,
|
|
@@ -902,10 +934,10 @@ import {
|
|
|
902
934
|
} from "@pixerate/editor";
|
|
903
935
|
function useMergePreview(options) {
|
|
904
936
|
const { template, templates, bindings, parseOptions } = options;
|
|
905
|
-
const [sourceText, setSourceTextState] =
|
|
906
|
-
const [overrides, setOverrides] =
|
|
907
|
-
const [index, setIndexState] =
|
|
908
|
-
const [result, setResult] =
|
|
937
|
+
const [sourceText, setSourceTextState] = useState8(options.initialSource ?? "");
|
|
938
|
+
const [overrides, setOverrides] = useState8({});
|
|
939
|
+
const [index, setIndexState] = useState8(0);
|
|
940
|
+
const [result, setResult] = useState8(null);
|
|
909
941
|
const source = useMemo9(
|
|
910
942
|
() => parseDataSource(sourceText, parseOptions),
|
|
911
943
|
[sourceText, parseOptions]
|
|
@@ -932,25 +964,25 @@ function useMergePreview(options) {
|
|
|
932
964
|
() => record ? recordToValues(record, mapping) : {},
|
|
933
965
|
[record, mapping]
|
|
934
966
|
);
|
|
935
|
-
const setSourceText =
|
|
967
|
+
const setSourceText = useCallback6((text) => {
|
|
936
968
|
setSourceTextState(text);
|
|
937
969
|
setIndexState(0);
|
|
938
970
|
setResult(null);
|
|
939
971
|
}, []);
|
|
940
|
-
const loadFile =
|
|
972
|
+
const loadFile = useCallback6(
|
|
941
973
|
async (file) => setSourceText(await file.text()),
|
|
942
974
|
[setSourceText]
|
|
943
975
|
);
|
|
944
|
-
const setIndex =
|
|
976
|
+
const setIndex = useCallback6(
|
|
945
977
|
(next) => setIndexState(Math.max(0, Math.min(next, count - 1))),
|
|
946
978
|
[count]
|
|
947
979
|
);
|
|
948
|
-
const setFieldMapping =
|
|
980
|
+
const setFieldMapping = useCallback6((variable, field) => {
|
|
949
981
|
setOverrides((previous) => ({ ...previous, [variable]: field }));
|
|
950
982
|
setResult(null);
|
|
951
983
|
}, []);
|
|
952
|
-
const resetMapping =
|
|
953
|
-
const merge =
|
|
984
|
+
const resetMapping = useCallback6(() => setOverrides({}), []);
|
|
985
|
+
const merge = useCallback6(() => {
|
|
954
986
|
const merged = mergeRecords(template, source, {
|
|
955
987
|
templates,
|
|
956
988
|
bindings,
|
|
@@ -962,7 +994,7 @@ function useMergePreview(options) {
|
|
|
962
994
|
setResult(merged);
|
|
963
995
|
return merged;
|
|
964
996
|
}, [template, source, templates, bindings, mapping, options.skipIf, options.separator, options.maxOutputs]);
|
|
965
|
-
const serialize =
|
|
997
|
+
const serialize = useCallback6(
|
|
966
998
|
(format) => result ? serializeMergeOutputs(result.outputs, format, options.separator) : "",
|
|
967
999
|
[result, options.separator]
|
|
968
1000
|
);
|
|
@@ -1026,7 +1058,7 @@ var MergePreview = ({
|
|
|
1026
1058
|
separator,
|
|
1027
1059
|
maxOutputs
|
|
1028
1060
|
});
|
|
1029
|
-
const [copied, setCopied] =
|
|
1061
|
+
const [copied, setCopied] = useState9(false);
|
|
1030
1062
|
const { source, result } = merge;
|
|
1031
1063
|
const copy = async () => {
|
|
1032
1064
|
try {
|
|
@@ -1183,11 +1215,11 @@ var MergePreview = ({
|
|
|
1183
1215
|
};
|
|
1184
1216
|
|
|
1185
1217
|
// src/hooks/useOutline.ts
|
|
1186
|
-
import { useMemo as useMemo10, useSyncExternalStore as
|
|
1218
|
+
import { useMemo as useMemo10, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1187
1219
|
import { createOutlineStore } from "@pixerate/editor";
|
|
1188
1220
|
function useOutline(editor) {
|
|
1189
1221
|
const store = useMemo10(() => createOutlineStore(editor), [editor]);
|
|
1190
|
-
return
|
|
1222
|
+
return useSyncExternalStore6(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1191
1223
|
}
|
|
1192
1224
|
|
|
1193
1225
|
// src/components/OutlinePanel.tsx
|
|
@@ -1232,14 +1264,14 @@ var OutlinePanel = ({
|
|
|
1232
1264
|
};
|
|
1233
1265
|
|
|
1234
1266
|
// src/hooks/useParagraphStyles.ts
|
|
1235
|
-
import { useMemo as useMemo11, useSyncExternalStore as
|
|
1267
|
+
import { useMemo as useMemo11, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
1236
1268
|
import {
|
|
1237
1269
|
createParagraphStylesStore,
|
|
1238
1270
|
getStyleRegistry
|
|
1239
1271
|
} from "@pixerate/editor";
|
|
1240
1272
|
function useParagraphStyles(editor) {
|
|
1241
1273
|
const store = useMemo11(() => createParagraphStylesStore(editor), [editor]);
|
|
1242
|
-
const snapshot =
|
|
1274
|
+
const snapshot = useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1243
1275
|
return useMemo11(() => {
|
|
1244
1276
|
const registry = getStyleRegistry(editor);
|
|
1245
1277
|
const live = () => editor && !editor.isDestroyed ? editor : null;
|
|
@@ -1263,7 +1295,7 @@ function useParagraphStyles(editor) {
|
|
|
1263
1295
|
}
|
|
1264
1296
|
|
|
1265
1297
|
// src/components/StylesGallery.tsx
|
|
1266
|
-
import { useState as
|
|
1298
|
+
import { useState as useState10 } from "react";
|
|
1267
1299
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1268
1300
|
var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1269
1301
|
var keepSelection = (event) => event.preventDefault();
|
|
@@ -1279,9 +1311,9 @@ var StylesGallery = ({
|
|
|
1279
1311
|
onChange
|
|
1280
1312
|
}) => {
|
|
1281
1313
|
const styles = useParagraphStyles(editor);
|
|
1282
|
-
const [open, setOpen] =
|
|
1283
|
-
const [creating, setCreating] =
|
|
1284
|
-
const [name, setName] =
|
|
1314
|
+
const [open, setOpen] = useState10(false);
|
|
1315
|
+
const [creating, setCreating] = useState10(false);
|
|
1316
|
+
const [name, setName] = useState10("");
|
|
1285
1317
|
const list = showAllStyles ? styles.styles : styles.gallery;
|
|
1286
1318
|
const current = styles.currentStyle;
|
|
1287
1319
|
const expanded = variant === "gallery" || open;
|
|
@@ -1437,7 +1469,7 @@ function useEditorSlots() {
|
|
|
1437
1469
|
}
|
|
1438
1470
|
|
|
1439
1471
|
// src/review/useReview.ts
|
|
1440
|
-
import { useCallback as
|
|
1472
|
+
import { useCallback as useCallback7, useMemo as useMemo13, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
1441
1473
|
import {
|
|
1442
1474
|
getCommentStore,
|
|
1443
1475
|
getTrackChangesStore
|
|
@@ -1459,22 +1491,22 @@ function isCommentStore(value) {
|
|
|
1459
1491
|
}
|
|
1460
1492
|
function useComments(source) {
|
|
1461
1493
|
const store = isCommentStore(source) ? source : getCommentStore(source);
|
|
1462
|
-
const subscribe =
|
|
1494
|
+
const subscribe = useCallback7(
|
|
1463
1495
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
1464
1496
|
[store]
|
|
1465
1497
|
);
|
|
1466
1498
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
1467
|
-
const snapshot =
|
|
1499
|
+
const snapshot = useSyncExternalStore8(subscribe, getSnapshot, getSnapshot);
|
|
1468
1500
|
return useMemo13(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
1469
1501
|
}
|
|
1470
1502
|
function useTrackChanges(editor) {
|
|
1471
1503
|
const store = getTrackChangesStore(editor ?? null);
|
|
1472
|
-
const subscribe =
|
|
1504
|
+
const subscribe = useCallback7(
|
|
1473
1505
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
1474
1506
|
[store]
|
|
1475
1507
|
);
|
|
1476
1508
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
1477
|
-
const snapshot =
|
|
1509
|
+
const snapshot = useSyncExternalStore8(subscribe, getSnapshot, getSnapshot);
|
|
1478
1510
|
return useMemo13(() => {
|
|
1479
1511
|
const run = (fn) => () => {
|
|
1480
1512
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
@@ -1498,7 +1530,7 @@ function useTrackChanges(editor) {
|
|
|
1498
1530
|
}
|
|
1499
1531
|
|
|
1500
1532
|
// src/review/CommentsPanel.tsx
|
|
1501
|
-
import { useState as
|
|
1533
|
+
import { useState as useState11 } from "react";
|
|
1502
1534
|
import {
|
|
1503
1535
|
formatReviewTime,
|
|
1504
1536
|
getCommentAuthor
|
|
@@ -1517,7 +1549,7 @@ var CommentsPanel = ({
|
|
|
1517
1549
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
1518
1550
|
}) => {
|
|
1519
1551
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
1520
|
-
const [showResolved, setShowResolved] =
|
|
1552
|
+
const [showResolved, setShowResolved] = useState11(showResolvedInitial);
|
|
1521
1553
|
const author = authorProp ?? getCommentAuthor(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
1522
1554
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
1523
1555
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
@@ -1561,7 +1593,7 @@ var CommentThreadCard = ({
|
|
|
1561
1593
|
author,
|
|
1562
1594
|
formatTime
|
|
1563
1595
|
}) => {
|
|
1564
|
-
const [draft, setDraft] =
|
|
1596
|
+
const [draft, setDraft] = useState11("");
|
|
1565
1597
|
const isDraft = thread.body === "";
|
|
1566
1598
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
1567
1599
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -1775,15 +1807,15 @@ var CommentButton = ({
|
|
|
1775
1807
|
);
|
|
1776
1808
|
|
|
1777
1809
|
// src/review/useDocumentCompare.ts
|
|
1778
|
-
import { useCallback as
|
|
1810
|
+
import { useCallback as useCallback8, useMemo as useMemo14, useRef as useRef9, useState as useState12 } from "react";
|
|
1779
1811
|
import {
|
|
1780
1812
|
applyDocumentComparison
|
|
1781
1813
|
} from "@pixerate/editor";
|
|
1782
1814
|
function useDocumentCompare(editor, options) {
|
|
1783
|
-
const [summary, setSummary] =
|
|
1815
|
+
const [summary, setSummary] = useState12(null);
|
|
1784
1816
|
const defaults = useRef9(options);
|
|
1785
1817
|
defaults.current = options;
|
|
1786
|
-
const compare =
|
|
1818
|
+
const compare = useCallback8(
|
|
1787
1819
|
(original, revised, overrides) => {
|
|
1788
1820
|
if (!editor || editor.isDestroyed) return null;
|
|
1789
1821
|
const result = applyDocumentComparison(editor, original, revised, {
|
|
@@ -1795,7 +1827,7 @@ function useDocumentCompare(editor, options) {
|
|
|
1795
1827
|
},
|
|
1796
1828
|
[editor]
|
|
1797
1829
|
);
|
|
1798
|
-
const clear =
|
|
1830
|
+
const clear = useCallback8(() => setSummary(null), []);
|
|
1799
1831
|
return useMemo14(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
1800
1832
|
}
|
|
1801
1833
|
|
|
@@ -1847,7 +1879,7 @@ var TrackedChangesList = ({
|
|
|
1847
1879
|
};
|
|
1848
1880
|
|
|
1849
1881
|
// src/find-replace/useFindReplace.ts
|
|
1850
|
-
import { useCallback as
|
|
1882
|
+
import { useCallback as useCallback9, useMemo as useMemo15, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
1851
1883
|
import {
|
|
1852
1884
|
EMPTY_FIND_REPLACE_SNAPSHOT,
|
|
1853
1885
|
getFindReplaceStore
|
|
@@ -1856,12 +1888,12 @@ var noopUnsubscribe2 = () => {
|
|
|
1856
1888
|
};
|
|
1857
1889
|
function useFindReplace(editor) {
|
|
1858
1890
|
const store = getFindReplaceStore(editor ?? null);
|
|
1859
|
-
const subscribe =
|
|
1891
|
+
const subscribe = useCallback9(
|
|
1860
1892
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
1861
1893
|
[store]
|
|
1862
1894
|
);
|
|
1863
1895
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
1864
|
-
const snapshot =
|
|
1896
|
+
const snapshot = useSyncExternalStore9(subscribe, getSnapshot, getSnapshot);
|
|
1865
1897
|
return useMemo15(() => {
|
|
1866
1898
|
const run = (fn) => {
|
|
1867
1899
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
@@ -1886,7 +1918,7 @@ function useFindReplace(editor) {
|
|
|
1886
1918
|
}
|
|
1887
1919
|
|
|
1888
1920
|
// src/find-replace/FindReplaceBar.tsx
|
|
1889
|
-
import { useEffect as useEffect12, useRef as useRef10, useState as
|
|
1921
|
+
import { useEffect as useEffect12, useRef as useRef10, useState as useState13 } from "react";
|
|
1890
1922
|
import { FIND_OPTION_TOGGLES, formatFindStatus } from "@pixerate/editor";
|
|
1891
1923
|
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1892
1924
|
var inputClass = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
|
|
@@ -1902,7 +1934,7 @@ var FindReplaceBar = ({
|
|
|
1902
1934
|
}) => {
|
|
1903
1935
|
const find = useFindReplace(editor);
|
|
1904
1936
|
const findInput = useRef10(null);
|
|
1905
|
-
const [moreOpen, setMoreOpen] =
|
|
1937
|
+
const [moreOpen, setMoreOpen] = useState13(false);
|
|
1906
1938
|
const visible = find.available && (alwaysOpen || find.open);
|
|
1907
1939
|
useEffect12(() => {
|
|
1908
1940
|
if (!visible || find.focusRequest === 0) return;
|
|
@@ -2048,7 +2080,7 @@ var FindReplaceBar = ({
|
|
|
2048
2080
|
};
|
|
2049
2081
|
|
|
2050
2082
|
// src/tables/useTableMenu.ts
|
|
2051
|
-
import { useMemo as useMemo16, useSyncExternalStore as
|
|
2083
|
+
import { useMemo as useMemo16, useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
2052
2084
|
import {
|
|
2053
2085
|
createTableStore,
|
|
2054
2086
|
getTableActionState,
|
|
@@ -2056,7 +2088,7 @@ import {
|
|
|
2056
2088
|
} from "@pixerate/editor";
|
|
2057
2089
|
function useTableMenu(editor) {
|
|
2058
2090
|
const store = useMemo16(() => createTableStore(editor), [editor]);
|
|
2059
|
-
const snapshot =
|
|
2091
|
+
const snapshot = useSyncExternalStore10(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2060
2092
|
return useMemo16(
|
|
2061
2093
|
() => ({
|
|
2062
2094
|
...snapshot,
|
|
@@ -2113,7 +2145,7 @@ var TableToolbar = ({
|
|
|
2113
2145
|
};
|
|
2114
2146
|
|
|
2115
2147
|
// src/tables/InsertTableGrid.tsx
|
|
2116
|
-
import { useState as
|
|
2148
|
+
import { useState as useState14 } from "react";
|
|
2117
2149
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2118
2150
|
var keepSelection3 = (event) => event.preventDefault();
|
|
2119
2151
|
var InsertTableGrid = ({
|
|
@@ -2127,7 +2159,7 @@ var InsertTableGrid = ({
|
|
|
2127
2159
|
onInsert
|
|
2128
2160
|
}) => {
|
|
2129
2161
|
const table = useTableMenu(editor);
|
|
2130
|
-
const [hover, setHover] =
|
|
2162
|
+
const [hover, setHover] = useState14(null);
|
|
2131
2163
|
const status = table.actions.insertTable;
|
|
2132
2164
|
const disabled = !editor || !status.enabled;
|
|
2133
2165
|
const insert = (size) => {
|
|
@@ -2264,7 +2296,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
2264
2296
|
}
|
|
2265
2297
|
|
|
2266
2298
|
// src/style/useStyle.ts
|
|
2267
|
-
import { useCallback as
|
|
2299
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useMemo as useMemo17, useState as useState15 } from "react";
|
|
2268
2300
|
import { styleSwatches } from "@pixerate/editor/tools";
|
|
2269
2301
|
import { richTextStyleState } from "@pixerate/editor";
|
|
2270
2302
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
@@ -2296,7 +2328,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
2296
2328
|
}, [styles, ...deps]);
|
|
2297
2329
|
}
|
|
2298
2330
|
function useStyle(styles, domain) {
|
|
2299
|
-
const [result, setResult] =
|
|
2331
|
+
const [result, setResult] = useState15({ style: null, error: null });
|
|
2300
2332
|
useResolverTask(
|
|
2301
2333
|
styles,
|
|
2302
2334
|
(s) => s.resolve(domain),
|
|
@@ -2306,7 +2338,7 @@ function useStyle(styles, domain) {
|
|
|
2306
2338
|
return result;
|
|
2307
2339
|
}
|
|
2308
2340
|
function useStyleFindings(styles, domain, state, scope) {
|
|
2309
|
-
const [result, setResult] =
|
|
2341
|
+
const [result, setResult] = useState15({ report: null, style: null, error: null });
|
|
2310
2342
|
useResolverTask(
|
|
2311
2343
|
styles,
|
|
2312
2344
|
(s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
|
|
@@ -2322,14 +2354,14 @@ function useStyleFindings(styles, domain, state, scope) {
|
|
|
2322
2354
|
return result;
|
|
2323
2355
|
}
|
|
2324
2356
|
function useStyleChoices(styles, scope) {
|
|
2325
|
-
const [state, setState] =
|
|
2357
|
+
const [state, setState] = useState15({ groups: null, error: null });
|
|
2326
2358
|
useResolverTask(
|
|
2327
2359
|
styles,
|
|
2328
2360
|
(s) => s.choices(scope !== void 0 ? { scope } : {}),
|
|
2329
2361
|
({ value, error }) => setState({ groups: value, error }),
|
|
2330
2362
|
[scope]
|
|
2331
2363
|
);
|
|
2332
|
-
const choose =
|
|
2364
|
+
const choose = useCallback10(
|
|
2333
2365
|
async (name, options = {}) => {
|
|
2334
2366
|
if (!styles) throw new Error("There is no style resolver to choose with.");
|
|
2335
2367
|
try {
|
|
@@ -2344,7 +2376,7 @@ function useStyleChoices(styles, scope) {
|
|
|
2344
2376
|
return { ...state, choose };
|
|
2345
2377
|
}
|
|
2346
2378
|
function useStyleSwatches(styles, domain, scope) {
|
|
2347
|
-
const [state, setState] =
|
|
2379
|
+
const [state, setState] = useState15({ style: null, error: null });
|
|
2348
2380
|
useResolverTask(
|
|
2349
2381
|
styles,
|
|
2350
2382
|
(s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
|
|
@@ -2357,7 +2389,7 @@ function useStyleSwatches(styles, domain, scope) {
|
|
|
2357
2389
|
}, [state]);
|
|
2358
2390
|
}
|
|
2359
2391
|
function useRichTextStyleFindings(styles, editor, scope) {
|
|
2360
|
-
const [doc, setDoc] =
|
|
2392
|
+
const [doc, setDoc] = useState15(() => editor?.state.doc ?? null);
|
|
2361
2393
|
useEffect13(() => {
|
|
2362
2394
|
if (!editor) {
|
|
2363
2395
|
setDoc(null);
|
|
@@ -2484,6 +2516,7 @@ export {
|
|
|
2484
2516
|
SeparateSubjectPanel,
|
|
2485
2517
|
ShapeOptionsBar,
|
|
2486
2518
|
SheetTabs,
|
|
2519
|
+
SmartObjectPanel,
|
|
2487
2520
|
SpreadsheetConditionalFormatPanel,
|
|
2488
2521
|
SpreadsheetContextMenu,
|
|
2489
2522
|
SpreadsheetDataValidationPanel,
|
|
@@ -2533,6 +2566,7 @@ export {
|
|
|
2533
2566
|
useImageEffectsTools,
|
|
2534
2567
|
useImageHistogram,
|
|
2535
2568
|
useJobProgress,
|
|
2569
|
+
useLinkFocus,
|
|
2536
2570
|
useMergePreview,
|
|
2537
2571
|
useNavigationGuard,
|
|
2538
2572
|
useOutline,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.209.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
"dependencies": {},
|
|
284
284
|
"peerDependencies": {
|
|
285
285
|
"@dagrejs/dagre": "^1.1.8",
|
|
286
|
-
"@pixerate/editor": ">=0.
|
|
286
|
+
"@pixerate/editor": ">=0.321.0 <1.0.0-0",
|
|
287
287
|
"@tiptap/core": "^2.27.3",
|
|
288
288
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
289
289
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
"tsup": "^9.0.0",
|
|
335
335
|
"typescript": "^5.7.3",
|
|
336
336
|
"vitest": "^5.1.0",
|
|
337
|
-
"@pixerate/editor": "0.
|
|
337
|
+
"@pixerate/editor": "0.321.0"
|
|
338
338
|
},
|
|
339
339
|
"scripts": {
|
|
340
340
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|