@pixerate/editor-react 0.209.0 → 0.210.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/animation-editor/index.cjs +1 -1
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-MK3YNIBU.js → chunk-BKFMPODE.js} +1 -1
- package/dist/{chunk-WTW6HRFI.js → chunk-EXHL4EKM.js} +1 -1
- package/dist/effects/index.cjs +1 -1
- package/dist/effects/index.js +1 -1
- package/dist/hooks/useTextProposals.d.cts +47 -0
- package/dist/hooks/useTextProposals.d.ts +47 -0
- package/dist/image-editor/index.cjs +1 -1
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +839 -769
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +152 -81
- package/dist/paint-editor/index.cjs +1 -1
- package/dist/paint-editor/index.js +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +1 -1
- package/dist/video-editor/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./hooks/useFileImport.cjs";
|
|
|
11
11
|
export * from "./hooks/useDocxExport.cjs";
|
|
12
12
|
export * from "./components/ExportDocxButton.cjs";
|
|
13
13
|
export * from "./hooks/useAgentToolProvider.cjs";
|
|
14
|
+
export * from "./hooks/useTextProposals.cjs";
|
|
14
15
|
export * from "./hooks/useRichTextEditorDocument.cjs";
|
|
15
16
|
export * from "./playback/index.cjs";
|
|
16
17
|
export * from "./hooks/useToolBridge.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./hooks/useFileImport.js";
|
|
|
11
11
|
export * from "./hooks/useDocxExport.js";
|
|
12
12
|
export * from "./components/ExportDocxButton.js";
|
|
13
13
|
export * from "./hooks/useAgentToolProvider.js";
|
|
14
|
+
export * from "./hooks/useTextProposals.js";
|
|
14
15
|
export * from "./hooks/useRichTextEditorDocument.js";
|
|
15
16
|
export * from "./playback/index.js";
|
|
16
17
|
export * from "./hooks/useToolBridge.js";
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
useImageEditor,
|
|
64
64
|
useImageEffectsTools,
|
|
65
65
|
useImageHistogram
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-BKFMPODE.js";
|
|
67
67
|
import {
|
|
68
68
|
ImageCheckbox,
|
|
69
69
|
ImageColor,
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
LayerEffectsPanel,
|
|
74
74
|
useImageEditorControls
|
|
75
75
|
} from "./chunk-EP6C5N54.js";
|
|
76
|
-
import "./chunk-
|
|
76
|
+
import "./chunk-EXHL4EKM.js";
|
|
77
77
|
import "./chunk-5RPB4WGT.js";
|
|
78
78
|
import "./chunk-KIRIU53A.js";
|
|
79
79
|
import "./chunk-3I7FOSLF.js";
|
|
@@ -604,22 +604,91 @@ function useAgentToolProvider(registry, provider, options = {}) {
|
|
|
604
604
|
}, [registry, provider]);
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
+
// src/hooks/useTextProposals.ts
|
|
608
|
+
import { useEffect as useEffect8, useMemo as useMemo5, useRef as useRef8, useState as useState5, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
609
|
+
import {
|
|
610
|
+
createTextChangeFeed,
|
|
611
|
+
createTextProposals
|
|
612
|
+
} from "@pixerate/editor/tools";
|
|
613
|
+
function useTextProposals(options) {
|
|
614
|
+
const latest = useRef8(options);
|
|
615
|
+
latest.current = options;
|
|
616
|
+
const storeRef = useRef8(null);
|
|
617
|
+
if (storeRef.current === null) {
|
|
618
|
+
storeRef.current = createTextProposals({
|
|
619
|
+
getText: () => latest.current.text,
|
|
620
|
+
applyEdit: (edit, step) => latest.current.applyEdit(edit, step),
|
|
621
|
+
readOnly: () => latest.current.readOnly?.() ?? false,
|
|
622
|
+
origin: options.origin,
|
|
623
|
+
idGenerator: options.idGenerator,
|
|
624
|
+
now: options.now
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
const store = storeRef.current;
|
|
628
|
+
const state = useSyncExternalStore6(store.subscribe, store.getState, store.getState);
|
|
629
|
+
useEffect8(() => {
|
|
630
|
+
store.sync();
|
|
631
|
+
}, [store, options.text]);
|
|
632
|
+
return useMemo5(
|
|
633
|
+
() => ({
|
|
634
|
+
store,
|
|
635
|
+
proposals: state.proposals,
|
|
636
|
+
propose: store.propose,
|
|
637
|
+
accept: store.accept,
|
|
638
|
+
reject: store.reject,
|
|
639
|
+
clear: store.clear
|
|
640
|
+
}),
|
|
641
|
+
[store, state]
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
function useTextChangeFeed(options) {
|
|
645
|
+
const latest = useRef8(options);
|
|
646
|
+
latest.current = options;
|
|
647
|
+
const [last, setLast] = useState5(null);
|
|
648
|
+
const feed = useMemo5(
|
|
649
|
+
() => createTextChangeFeed({
|
|
650
|
+
getText: () => latest.current.text,
|
|
651
|
+
getSelection: () => latest.current.selection ?? null,
|
|
652
|
+
burstMs: options.burstMs
|
|
653
|
+
}),
|
|
654
|
+
[]
|
|
655
|
+
);
|
|
656
|
+
useEffect8(
|
|
657
|
+
() => feed.subscribe((change) => {
|
|
658
|
+
setLast(change);
|
|
659
|
+
latest.current.onChange?.(change);
|
|
660
|
+
}),
|
|
661
|
+
[feed]
|
|
662
|
+
);
|
|
663
|
+
useEffect8(() => options.history?.onCommit(feed.noteCommit), [feed, options.history]);
|
|
664
|
+
useEffect8(
|
|
665
|
+
() => () => {
|
|
666
|
+
feed.endGesture();
|
|
667
|
+
},
|
|
668
|
+
[feed]
|
|
669
|
+
);
|
|
670
|
+
useEffect8(() => {
|
|
671
|
+
feed.check();
|
|
672
|
+
}, [feed, options.text, options.selection?.from, options.selection?.to]);
|
|
673
|
+
return { feed, last };
|
|
674
|
+
}
|
|
675
|
+
|
|
607
676
|
// src/hooks/useRichTextEditorDocument.ts
|
|
608
|
-
import { useEffect as
|
|
677
|
+
import { useEffect as useEffect9, useMemo as useMemo6 } from "react";
|
|
609
678
|
import { createRichTextEditorDocument } from "@pixerate/editor";
|
|
610
679
|
function useRichTextEditorDocument(editor) {
|
|
611
|
-
const doc =
|
|
612
|
-
|
|
680
|
+
const doc = useMemo6(() => editor ? createRichTextEditorDocument(editor) : null, [editor]);
|
|
681
|
+
useEffect9(() => () => doc?.destroy(), [doc]);
|
|
613
682
|
return doc;
|
|
614
683
|
}
|
|
615
684
|
|
|
616
685
|
// src/hooks/useToolBridge.ts
|
|
617
|
-
import { useEffect as
|
|
686
|
+
import { useEffect as useEffect10, useState as useState6 } from "react";
|
|
618
687
|
import { connectToolBridge } from "@pixerate/editor/tools";
|
|
619
688
|
function useToolBridge(registry, options) {
|
|
620
|
-
const [state, setState] =
|
|
689
|
+
const [state, setState] = useState6({ status: "off", editorId: null });
|
|
621
690
|
const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
|
|
622
|
-
|
|
691
|
+
useEffect10(() => {
|
|
623
692
|
if (!registry || !options) {
|
|
624
693
|
setState({ status: "off", editorId: null });
|
|
625
694
|
return;
|
|
@@ -639,20 +708,20 @@ function useToolBridge(registry, options) {
|
|
|
639
708
|
}
|
|
640
709
|
|
|
641
710
|
// src/hooks/useToolRegistryView.ts
|
|
642
|
-
import { useEffect as
|
|
711
|
+
import { useEffect as useEffect11, useMemo as useMemo7 } from "react";
|
|
643
712
|
function useToolRegistryView(registry, options = {}) {
|
|
644
713
|
const { toolsets, readOnly, discovery } = options;
|
|
645
|
-
const view =
|
|
714
|
+
const view = useMemo7(
|
|
646
715
|
() => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
|
|
647
716
|
// toolsets is applied below without making a new view, so enabled tools survive.
|
|
648
717
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
649
718
|
[registry, readOnly, discovery]
|
|
650
719
|
);
|
|
651
720
|
const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
|
|
652
|
-
|
|
721
|
+
useEffect11(() => {
|
|
653
722
|
view?.setToolsets(toolsets);
|
|
654
723
|
}, [view, toolsetsKey]);
|
|
655
|
-
|
|
724
|
+
useEffect11(() => () => view?.dispose(), [view]);
|
|
656
725
|
return view;
|
|
657
726
|
}
|
|
658
727
|
|
|
@@ -670,7 +739,7 @@ var EditorContent = ({
|
|
|
670
739
|
};
|
|
671
740
|
|
|
672
741
|
// src/components/BubbleMenu.tsx
|
|
673
|
-
import { useEffect as
|
|
742
|
+
import { useEffect as useEffect12, useRef as useRef9, useState as useState7 } from "react";
|
|
674
743
|
import { createPortal } from "react-dom";
|
|
675
744
|
import {
|
|
676
745
|
BubbleMenuPlugin
|
|
@@ -684,12 +753,12 @@ var BubbleMenu = ({
|
|
|
684
753
|
pluginKey = "bubbleMenu",
|
|
685
754
|
updateDelay
|
|
686
755
|
}) => {
|
|
687
|
-
const menuEl =
|
|
688
|
-
const [mounted, setMounted] =
|
|
756
|
+
const menuEl = useRef9(null);
|
|
757
|
+
const [mounted, setMounted] = useState7(false);
|
|
689
758
|
if (!menuEl.current && typeof document !== "undefined") {
|
|
690
759
|
menuEl.current = document.createElement("div");
|
|
691
760
|
}
|
|
692
|
-
|
|
761
|
+
useEffect12(() => {
|
|
693
762
|
if (!editor || !menuEl.current || editor.isDestroyed) {
|
|
694
763
|
return;
|
|
695
764
|
}
|
|
@@ -720,7 +789,7 @@ var BubbleMenu = ({
|
|
|
720
789
|
};
|
|
721
790
|
|
|
722
791
|
// src/components/TemplateRenderer.tsx
|
|
723
|
-
import { useMemo as
|
|
792
|
+
import { useMemo as useMemo8 } from "react";
|
|
724
793
|
import {
|
|
725
794
|
describeConditionalTag,
|
|
726
795
|
evaluatePromptTokens,
|
|
@@ -739,11 +808,11 @@ var TemplateRenderer = ({
|
|
|
739
808
|
onTemplateClick,
|
|
740
809
|
onVariableClick
|
|
741
810
|
}) => {
|
|
742
|
-
const displayText =
|
|
811
|
+
const displayText = useMemo8(() => {
|
|
743
812
|
if (!resolve || templates.length === 0) return content;
|
|
744
813
|
return resolveTemplates(content, templates, { bindings });
|
|
745
814
|
}, [content, templates, resolve, bindings]);
|
|
746
|
-
const tokens =
|
|
815
|
+
const tokens = useMemo8(() => {
|
|
747
816
|
return evaluatePromptTokens(displayText, values);
|
|
748
817
|
}, [displayText, values]);
|
|
749
818
|
return /* @__PURE__ */ jsx4("div", { className, children: tokens.map((token, index) => {
|
|
@@ -832,7 +901,7 @@ var TemplateRenderer = ({
|
|
|
832
901
|
};
|
|
833
902
|
|
|
834
903
|
// src/components/VariableForm.tsx
|
|
835
|
-
import { useId, useMemo as
|
|
904
|
+
import { useId, useMemo as useMemo9, useState as useState8 } from "react";
|
|
836
905
|
import {
|
|
837
906
|
compactVariableValues,
|
|
838
907
|
getVariableFormFields
|
|
@@ -848,11 +917,11 @@ var VariableForm = ({
|
|
|
848
917
|
className = "flex flex-col gap-3 text-sm"
|
|
849
918
|
}) => {
|
|
850
919
|
const idPrefix = useId();
|
|
851
|
-
const [internal, setInternal] =
|
|
920
|
+
const [internal, setInternal] = useState8(
|
|
852
921
|
() => defaultValues ?? {}
|
|
853
922
|
);
|
|
854
923
|
const entered = values ?? internal;
|
|
855
|
-
const fields =
|
|
924
|
+
const fields = useMemo9(
|
|
856
925
|
() => getVariableFormFields(content, { templates, bindings }),
|
|
857
926
|
[content, templates, bindings]
|
|
858
927
|
);
|
|
@@ -920,10 +989,10 @@ var VariableForm = ({
|
|
|
920
989
|
};
|
|
921
990
|
|
|
922
991
|
// src/components/MergePreview.tsx
|
|
923
|
-
import { useId as useId2, useState as
|
|
992
|
+
import { useId as useId2, useState as useState10 } from "react";
|
|
924
993
|
|
|
925
994
|
// src/hooks/useMergePreview.ts
|
|
926
|
-
import { useCallback as useCallback6, useMemo as
|
|
995
|
+
import { useCallback as useCallback6, useMemo as useMemo10, useState as useState9 } from "react";
|
|
927
996
|
import {
|
|
928
997
|
extractVariables,
|
|
929
998
|
matchFields,
|
|
@@ -934,19 +1003,19 @@ import {
|
|
|
934
1003
|
} from "@pixerate/editor";
|
|
935
1004
|
function useMergePreview(options) {
|
|
936
1005
|
const { template, templates, bindings, parseOptions } = options;
|
|
937
|
-
const [sourceText, setSourceTextState] =
|
|
938
|
-
const [overrides, setOverrides] =
|
|
939
|
-
const [index, setIndexState] =
|
|
940
|
-
const [result, setResult] =
|
|
941
|
-
const source =
|
|
1006
|
+
const [sourceText, setSourceTextState] = useState9(options.initialSource ?? "");
|
|
1007
|
+
const [overrides, setOverrides] = useState9({});
|
|
1008
|
+
const [index, setIndexState] = useState9(0);
|
|
1009
|
+
const [result, setResult] = useState9(null);
|
|
1010
|
+
const source = useMemo10(
|
|
942
1011
|
() => parseDataSource(sourceText, parseOptions),
|
|
943
1012
|
[sourceText, parseOptions]
|
|
944
1013
|
);
|
|
945
|
-
const variables =
|
|
1014
|
+
const variables = useMemo10(
|
|
946
1015
|
() => extractVariables(template, { templates, bindings }).map((v) => v.name),
|
|
947
1016
|
[template, templates, bindings]
|
|
948
1017
|
);
|
|
949
|
-
const mapping =
|
|
1018
|
+
const mapping = useMemo10(() => {
|
|
950
1019
|
const merged = {
|
|
951
1020
|
...matchFields(variables, source.fields).mapping
|
|
952
1021
|
};
|
|
@@ -960,7 +1029,7 @@ function useMergePreview(options) {
|
|
|
960
1029
|
const count = source.records.length;
|
|
961
1030
|
const current = count === 0 ? 0 : Math.min(index, count - 1);
|
|
962
1031
|
const record = source.records[current];
|
|
963
|
-
const values =
|
|
1032
|
+
const values = useMemo10(
|
|
964
1033
|
() => record ? recordToValues(record, mapping) : {},
|
|
965
1034
|
[record, mapping]
|
|
966
1035
|
);
|
|
@@ -1058,7 +1127,7 @@ var MergePreview = ({
|
|
|
1058
1127
|
separator,
|
|
1059
1128
|
maxOutputs
|
|
1060
1129
|
});
|
|
1061
|
-
const [copied, setCopied] =
|
|
1130
|
+
const [copied, setCopied] = useState10(false);
|
|
1062
1131
|
const { source, result } = merge;
|
|
1063
1132
|
const copy = async () => {
|
|
1064
1133
|
try {
|
|
@@ -1215,11 +1284,11 @@ var MergePreview = ({
|
|
|
1215
1284
|
};
|
|
1216
1285
|
|
|
1217
1286
|
// src/hooks/useOutline.ts
|
|
1218
|
-
import { useMemo as
|
|
1287
|
+
import { useMemo as useMemo11, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
1219
1288
|
import { createOutlineStore } from "@pixerate/editor";
|
|
1220
1289
|
function useOutline(editor) {
|
|
1221
|
-
const store =
|
|
1222
|
-
return
|
|
1290
|
+
const store = useMemo11(() => createOutlineStore(editor), [editor]);
|
|
1291
|
+
return useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1223
1292
|
}
|
|
1224
1293
|
|
|
1225
1294
|
// src/components/OutlinePanel.tsx
|
|
@@ -1264,15 +1333,15 @@ var OutlinePanel = ({
|
|
|
1264
1333
|
};
|
|
1265
1334
|
|
|
1266
1335
|
// src/hooks/useParagraphStyles.ts
|
|
1267
|
-
import { useMemo as
|
|
1336
|
+
import { useMemo as useMemo12, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
1268
1337
|
import {
|
|
1269
1338
|
createParagraphStylesStore,
|
|
1270
1339
|
getStyleRegistry
|
|
1271
1340
|
} from "@pixerate/editor";
|
|
1272
1341
|
function useParagraphStyles(editor) {
|
|
1273
|
-
const store =
|
|
1274
|
-
const snapshot =
|
|
1275
|
-
return
|
|
1342
|
+
const store = useMemo12(() => createParagraphStylesStore(editor), [editor]);
|
|
1343
|
+
const snapshot = useSyncExternalStore8(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1344
|
+
return useMemo12(() => {
|
|
1276
1345
|
const registry = getStyleRegistry(editor);
|
|
1277
1346
|
const live = () => editor && !editor.isDestroyed ? editor : null;
|
|
1278
1347
|
return {
|
|
@@ -1295,7 +1364,7 @@ function useParagraphStyles(editor) {
|
|
|
1295
1364
|
}
|
|
1296
1365
|
|
|
1297
1366
|
// src/components/StylesGallery.tsx
|
|
1298
|
-
import { useState as
|
|
1367
|
+
import { useState as useState11 } from "react";
|
|
1299
1368
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1300
1369
|
var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1301
1370
|
var keepSelection = (event) => event.preventDefault();
|
|
@@ -1311,9 +1380,9 @@ var StylesGallery = ({
|
|
|
1311
1380
|
onChange
|
|
1312
1381
|
}) => {
|
|
1313
1382
|
const styles = useParagraphStyles(editor);
|
|
1314
|
-
const [open, setOpen] =
|
|
1315
|
-
const [creating, setCreating] =
|
|
1316
|
-
const [name, setName] =
|
|
1383
|
+
const [open, setOpen] = useState11(false);
|
|
1384
|
+
const [creating, setCreating] = useState11(false);
|
|
1385
|
+
const [name, setName] = useState11("");
|
|
1317
1386
|
const list = showAllStyles ? styles.styles : styles.gallery;
|
|
1318
1387
|
const current = styles.currentStyle;
|
|
1319
1388
|
const expanded = variant === "gallery" || open;
|
|
@@ -1437,7 +1506,7 @@ import {
|
|
|
1437
1506
|
} from "@pixerate/editor";
|
|
1438
1507
|
|
|
1439
1508
|
// src/slots.tsx
|
|
1440
|
-
import { createContext, useContext, useMemo as
|
|
1509
|
+
import { createContext, useContext, useMemo as useMemo13 } from "react";
|
|
1441
1510
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1442
1511
|
var defaultSlots = {
|
|
1443
1512
|
Button: (props) => /* @__PURE__ */ jsx9(
|
|
@@ -1461,7 +1530,7 @@ var defaultSlots = {
|
|
|
1461
1530
|
};
|
|
1462
1531
|
var EditorSlotsContext = createContext(defaultSlots);
|
|
1463
1532
|
function EditorSlotsProvider({ slots, children }) {
|
|
1464
|
-
const mergedSlots =
|
|
1533
|
+
const mergedSlots = useMemo13(() => ({ ...defaultSlots, ...slots }), [slots]);
|
|
1465
1534
|
return /* @__PURE__ */ jsx9(EditorSlotsContext.Provider, { value: mergedSlots, children });
|
|
1466
1535
|
}
|
|
1467
1536
|
function useEditorSlots() {
|
|
@@ -1469,7 +1538,7 @@ function useEditorSlots() {
|
|
|
1469
1538
|
}
|
|
1470
1539
|
|
|
1471
1540
|
// src/review/useReview.ts
|
|
1472
|
-
import { useCallback as useCallback7, useMemo as
|
|
1541
|
+
import { useCallback as useCallback7, useMemo as useMemo14, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
1473
1542
|
import {
|
|
1474
1543
|
getCommentStore,
|
|
1475
1544
|
getTrackChangesStore
|
|
@@ -1496,8 +1565,8 @@ function useComments(source) {
|
|
|
1496
1565
|
[store]
|
|
1497
1566
|
);
|
|
1498
1567
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
1499
|
-
const snapshot =
|
|
1500
|
-
return
|
|
1568
|
+
const snapshot = useSyncExternalStore9(subscribe, getSnapshot, getSnapshot);
|
|
1569
|
+
return useMemo14(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
1501
1570
|
}
|
|
1502
1571
|
function useTrackChanges(editor) {
|
|
1503
1572
|
const store = getTrackChangesStore(editor ?? null);
|
|
@@ -1506,8 +1575,8 @@ function useTrackChanges(editor) {
|
|
|
1506
1575
|
[store]
|
|
1507
1576
|
);
|
|
1508
1577
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
1509
|
-
const snapshot =
|
|
1510
|
-
return
|
|
1578
|
+
const snapshot = useSyncExternalStore9(subscribe, getSnapshot, getSnapshot);
|
|
1579
|
+
return useMemo14(() => {
|
|
1511
1580
|
const run = (fn) => () => {
|
|
1512
1581
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
1513
1582
|
};
|
|
@@ -1530,7 +1599,7 @@ function useTrackChanges(editor) {
|
|
|
1530
1599
|
}
|
|
1531
1600
|
|
|
1532
1601
|
// src/review/CommentsPanel.tsx
|
|
1533
|
-
import { useState as
|
|
1602
|
+
import { useState as useState12 } from "react";
|
|
1534
1603
|
import {
|
|
1535
1604
|
formatReviewTime,
|
|
1536
1605
|
getCommentAuthor
|
|
@@ -1549,7 +1618,7 @@ var CommentsPanel = ({
|
|
|
1549
1618
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
1550
1619
|
}) => {
|
|
1551
1620
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
1552
|
-
const [showResolved, setShowResolved] =
|
|
1621
|
+
const [showResolved, setShowResolved] = useState12(showResolvedInitial);
|
|
1553
1622
|
const author = authorProp ?? getCommentAuthor(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
1554
1623
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
1555
1624
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
@@ -1593,7 +1662,7 @@ var CommentThreadCard = ({
|
|
|
1593
1662
|
author,
|
|
1594
1663
|
formatTime
|
|
1595
1664
|
}) => {
|
|
1596
|
-
const [draft, setDraft] =
|
|
1665
|
+
const [draft, setDraft] = useState12("");
|
|
1597
1666
|
const isDraft = thread.body === "";
|
|
1598
1667
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
1599
1668
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -1807,13 +1876,13 @@ var CommentButton = ({
|
|
|
1807
1876
|
);
|
|
1808
1877
|
|
|
1809
1878
|
// src/review/useDocumentCompare.ts
|
|
1810
|
-
import { useCallback as useCallback8, useMemo as
|
|
1879
|
+
import { useCallback as useCallback8, useMemo as useMemo15, useRef as useRef10, useState as useState13 } from "react";
|
|
1811
1880
|
import {
|
|
1812
1881
|
applyDocumentComparison
|
|
1813
1882
|
} from "@pixerate/editor";
|
|
1814
1883
|
function useDocumentCompare(editor, options) {
|
|
1815
|
-
const [summary, setSummary] =
|
|
1816
|
-
const defaults =
|
|
1884
|
+
const [summary, setSummary] = useState13(null);
|
|
1885
|
+
const defaults = useRef10(options);
|
|
1817
1886
|
defaults.current = options;
|
|
1818
1887
|
const compare = useCallback8(
|
|
1819
1888
|
(original, revised, overrides) => {
|
|
@@ -1828,7 +1897,7 @@ function useDocumentCompare(editor, options) {
|
|
|
1828
1897
|
[editor]
|
|
1829
1898
|
);
|
|
1830
1899
|
const clear = useCallback8(() => setSummary(null), []);
|
|
1831
|
-
return
|
|
1900
|
+
return useMemo15(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
1832
1901
|
}
|
|
1833
1902
|
|
|
1834
1903
|
// src/review/TrackedChangesList.tsx
|
|
@@ -1879,7 +1948,7 @@ var TrackedChangesList = ({
|
|
|
1879
1948
|
};
|
|
1880
1949
|
|
|
1881
1950
|
// src/find-replace/useFindReplace.ts
|
|
1882
|
-
import { useCallback as useCallback9, useMemo as
|
|
1951
|
+
import { useCallback as useCallback9, useMemo as useMemo16, useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
1883
1952
|
import {
|
|
1884
1953
|
EMPTY_FIND_REPLACE_SNAPSHOT,
|
|
1885
1954
|
getFindReplaceStore
|
|
@@ -1893,8 +1962,8 @@ function useFindReplace(editor) {
|
|
|
1893
1962
|
[store]
|
|
1894
1963
|
);
|
|
1895
1964
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
1896
|
-
const snapshot =
|
|
1897
|
-
return
|
|
1965
|
+
const snapshot = useSyncExternalStore10(subscribe, getSnapshot, getSnapshot);
|
|
1966
|
+
return useMemo16(() => {
|
|
1898
1967
|
const run = (fn) => {
|
|
1899
1968
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
1900
1969
|
};
|
|
@@ -1918,7 +1987,7 @@ function useFindReplace(editor) {
|
|
|
1918
1987
|
}
|
|
1919
1988
|
|
|
1920
1989
|
// src/find-replace/FindReplaceBar.tsx
|
|
1921
|
-
import { useEffect as
|
|
1990
|
+
import { useEffect as useEffect13, useRef as useRef11, useState as useState14 } from "react";
|
|
1922
1991
|
import { FIND_OPTION_TOGGLES, formatFindStatus } from "@pixerate/editor";
|
|
1923
1992
|
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1924
1993
|
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";
|
|
@@ -1933,10 +2002,10 @@ var FindReplaceBar = ({
|
|
|
1933
2002
|
onClose
|
|
1934
2003
|
}) => {
|
|
1935
2004
|
const find = useFindReplace(editor);
|
|
1936
|
-
const findInput =
|
|
1937
|
-
const [moreOpen, setMoreOpen] =
|
|
2005
|
+
const findInput = useRef11(null);
|
|
2006
|
+
const [moreOpen, setMoreOpen] = useState14(false);
|
|
1938
2007
|
const visible = find.available && (alwaysOpen || find.open);
|
|
1939
|
-
|
|
2008
|
+
useEffect13(() => {
|
|
1940
2009
|
if (!visible || find.focusRequest === 0) return;
|
|
1941
2010
|
findInput.current?.focus();
|
|
1942
2011
|
findInput.current?.select();
|
|
@@ -2080,16 +2149,16 @@ var FindReplaceBar = ({
|
|
|
2080
2149
|
};
|
|
2081
2150
|
|
|
2082
2151
|
// src/tables/useTableMenu.ts
|
|
2083
|
-
import { useMemo as
|
|
2152
|
+
import { useMemo as useMemo17, useSyncExternalStore as useSyncExternalStore11 } from "react";
|
|
2084
2153
|
import {
|
|
2085
2154
|
createTableStore,
|
|
2086
2155
|
getTableActionState,
|
|
2087
2156
|
runTableAction
|
|
2088
2157
|
} from "@pixerate/editor";
|
|
2089
2158
|
function useTableMenu(editor) {
|
|
2090
|
-
const store =
|
|
2091
|
-
const snapshot =
|
|
2092
|
-
return
|
|
2159
|
+
const store = useMemo17(() => createTableStore(editor), [editor]);
|
|
2160
|
+
const snapshot = useSyncExternalStore11(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2161
|
+
return useMemo17(
|
|
2093
2162
|
() => ({
|
|
2094
2163
|
...snapshot,
|
|
2095
2164
|
run: (action, params) => runTableAction(editor, action, params, { focus: true }),
|
|
@@ -2145,7 +2214,7 @@ var TableToolbar = ({
|
|
|
2145
2214
|
};
|
|
2146
2215
|
|
|
2147
2216
|
// src/tables/InsertTableGrid.tsx
|
|
2148
|
-
import { useState as
|
|
2217
|
+
import { useState as useState15 } from "react";
|
|
2149
2218
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2150
2219
|
var keepSelection3 = (event) => event.preventDefault();
|
|
2151
2220
|
var InsertTableGrid = ({
|
|
@@ -2159,7 +2228,7 @@ var InsertTableGrid = ({
|
|
|
2159
2228
|
onInsert
|
|
2160
2229
|
}) => {
|
|
2161
2230
|
const table = useTableMenu(editor);
|
|
2162
|
-
const [hover, setHover] =
|
|
2231
|
+
const [hover, setHover] = useState15(null);
|
|
2163
2232
|
const status = table.actions.insertTable;
|
|
2164
2233
|
const disabled = !editor || !status.enabled;
|
|
2165
2234
|
const insert = (size) => {
|
|
@@ -2296,12 +2365,12 @@ function createReactChartNodeView(options = {}) {
|
|
|
2296
2365
|
}
|
|
2297
2366
|
|
|
2298
2367
|
// src/style/useStyle.ts
|
|
2299
|
-
import { useCallback as useCallback10, useEffect as
|
|
2368
|
+
import { useCallback as useCallback10, useEffect as useEffect14, useMemo as useMemo18, useState as useState16 } from "react";
|
|
2300
2369
|
import { styleSwatches } from "@pixerate/editor/tools";
|
|
2301
2370
|
import { richTextStyleState } from "@pixerate/editor";
|
|
2302
2371
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
2303
2372
|
function useResolverTask(styles, run, deliver, deps) {
|
|
2304
|
-
|
|
2373
|
+
useEffect14(() => {
|
|
2305
2374
|
if (!styles || !run) {
|
|
2306
2375
|
deliver({ value: null, error: null });
|
|
2307
2376
|
return;
|
|
@@ -2328,7 +2397,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
2328
2397
|
}, [styles, ...deps]);
|
|
2329
2398
|
}
|
|
2330
2399
|
function useStyle(styles, domain) {
|
|
2331
|
-
const [result, setResult] =
|
|
2400
|
+
const [result, setResult] = useState16({ style: null, error: null });
|
|
2332
2401
|
useResolverTask(
|
|
2333
2402
|
styles,
|
|
2334
2403
|
(s) => s.resolve(domain),
|
|
@@ -2338,7 +2407,7 @@ function useStyle(styles, domain) {
|
|
|
2338
2407
|
return result;
|
|
2339
2408
|
}
|
|
2340
2409
|
function useStyleFindings(styles, domain, state, scope) {
|
|
2341
|
-
const [result, setResult] =
|
|
2410
|
+
const [result, setResult] = useState16({ report: null, style: null, error: null });
|
|
2342
2411
|
useResolverTask(
|
|
2343
2412
|
styles,
|
|
2344
2413
|
(s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
|
|
@@ -2354,7 +2423,7 @@ function useStyleFindings(styles, domain, state, scope) {
|
|
|
2354
2423
|
return result;
|
|
2355
2424
|
}
|
|
2356
2425
|
function useStyleChoices(styles, scope) {
|
|
2357
|
-
const [state, setState] =
|
|
2426
|
+
const [state, setState] = useState16({ groups: null, error: null });
|
|
2358
2427
|
useResolverTask(
|
|
2359
2428
|
styles,
|
|
2360
2429
|
(s) => s.choices(scope !== void 0 ? { scope } : {}),
|
|
@@ -2376,21 +2445,21 @@ function useStyleChoices(styles, scope) {
|
|
|
2376
2445
|
return { ...state, choose };
|
|
2377
2446
|
}
|
|
2378
2447
|
function useStyleSwatches(styles, domain, scope) {
|
|
2379
|
-
const [state, setState] =
|
|
2448
|
+
const [state, setState] = useState16({ style: null, error: null });
|
|
2380
2449
|
useResolverTask(
|
|
2381
2450
|
styles,
|
|
2382
2451
|
(s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
|
|
2383
2452
|
({ value, error }) => setState({ style: value, error }),
|
|
2384
2453
|
[domain, scope]
|
|
2385
2454
|
);
|
|
2386
|
-
return
|
|
2455
|
+
return useMemo18(() => {
|
|
2387
2456
|
const { colors, fonts } = state.style ? styleSwatches(state.style) : { colors: [], fonts: [] };
|
|
2388
2457
|
return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
|
|
2389
2458
|
}, [state]);
|
|
2390
2459
|
}
|
|
2391
2460
|
function useRichTextStyleFindings(styles, editor, scope) {
|
|
2392
|
-
const [doc, setDoc] =
|
|
2393
|
-
|
|
2461
|
+
const [doc, setDoc] = useState16(() => editor?.state.doc ?? null);
|
|
2462
|
+
useEffect14(() => {
|
|
2394
2463
|
if (!editor) {
|
|
2395
2464
|
setDoc(null);
|
|
2396
2465
|
return;
|
|
@@ -2402,7 +2471,7 @@ function useRichTextStyleFindings(styles, editor, scope) {
|
|
|
2402
2471
|
editor.off("update", onUpdate);
|
|
2403
2472
|
};
|
|
2404
2473
|
}, [editor]);
|
|
2405
|
-
const state =
|
|
2474
|
+
const state = useMemo18(() => doc ? richTextStyleState(doc) : null, [doc]);
|
|
2406
2475
|
return useStyleFindings(state ? styles : null, "rich-text", state, scope);
|
|
2407
2476
|
}
|
|
2408
2477
|
|
|
@@ -2584,6 +2653,8 @@ export {
|
|
|
2584
2653
|
useStyleFindings,
|
|
2585
2654
|
useStyleSwatches,
|
|
2586
2655
|
useTableMenu,
|
|
2656
|
+
useTextChangeFeed,
|
|
2657
|
+
useTextProposals,
|
|
2587
2658
|
useToolBridge,
|
|
2588
2659
|
useToolRegistryView,
|
|
2589
2660
|
useTrackChanges,
|
|
@@ -2786,7 +2786,7 @@ function useEffectDescription(provider, effect) {
|
|
|
2786
2786
|
var import_react24 = require("react");
|
|
2787
2787
|
var import_effects = require("@pixerate/editor/effects");
|
|
2788
2788
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2789
|
-
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing" };
|
|
2789
|
+
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing", "text-treatment": "Text treatment" };
|
|
2790
2790
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
2791
2791
|
const ref = (0, import_react24.useRef)(null);
|
|
2792
2792
|
const [failed, setFailed] = (0, import_react24.useState)(effect.kind in LABELS);
|
package/dist/vector/index.cjs
CHANGED
|
@@ -3592,7 +3592,7 @@ function useEffectDescription(provider, effect) {
|
|
|
3592
3592
|
var import_react22 = require("react");
|
|
3593
3593
|
var import_effects = require("@pixerate/editor/effects");
|
|
3594
3594
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3595
|
-
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing" };
|
|
3595
|
+
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing", "text-treatment": "Text treatment" };
|
|
3596
3596
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
3597
3597
|
const ref = (0, import_react22.useRef)(null);
|
|
3598
3598
|
const [failed, setFailed] = (0, import_react22.useState)(effect.kind in LABELS);
|
package/dist/vector/index.js
CHANGED
|
@@ -811,7 +811,7 @@ function useEffectDescription(provider, effect) {
|
|
|
811
811
|
var import_react9 = require("react");
|
|
812
812
|
var import_effects = require("@pixerate/editor/effects");
|
|
813
813
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
814
|
-
var LABELS2 = { motion: "Motion", camera: "Camera", timing: "Timing" };
|
|
814
|
+
var LABELS2 = { motion: "Motion", camera: "Camera", timing: "Timing", "text-treatment": "Text treatment" };
|
|
815
815
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
816
816
|
const ref = (0, import_react9.useRef)(null);
|
|
817
817
|
const [failed, setFailed] = (0, import_react9.useState)(effect.kind in LABELS2);
|