@pixerate/editor-react 0.101.0 → 0.103.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/canvas/index.cjs +613 -572
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +114 -72
- package/dist/canvas/useCanvasEditorDocument.d.cts +15 -0
- package/dist/canvas/useCanvasEditorDocument.d.ts +15 -0
- package/dist/{chunk-EP6MSQN4.js → chunk-VZ7HBWKL.js} +22 -17
- package/dist/hooks/useRichTextEditorDocument.d.cts +8 -0
- package/dist/hooks/useRichTextEditorDocument.d.ts +8 -0
- package/dist/index.cjs +649 -634
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +48 -38
- package/dist/spreadsheet/index.cjs +4 -0
- package/dist/spreadsheet/index.js +1 -1
- package/dist/spreadsheet/useSpreadsheetEditor.d.cts +2 -0
- package/dist/spreadsheet/useSpreadsheetEditor.d.ts +2 -0
- package/dist/tokens/index.cjs +3 -1
- package/dist/tokens/index.js +5 -2
- package/dist/tokens/useTokens.d.cts +3 -0
- package/dist/tokens/useTokens.d.ts +3 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./hooks/useFileImport.cjs";
|
|
|
9
9
|
export * from "./hooks/useDocxExport.cjs";
|
|
10
10
|
export * from "./components/ExportDocxButton.cjs";
|
|
11
11
|
export * from "./hooks/useAgentToolProvider.cjs";
|
|
12
|
+
export * from "./hooks/useRichTextEditorDocument.cjs";
|
|
12
13
|
export * from "./playback/index.cjs";
|
|
13
14
|
export * from "./hooks/useToolBridge.cjs";
|
|
14
15
|
export * from "./hooks/useToolRegistryView.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./hooks/useFileImport.js";
|
|
|
9
9
|
export * from "./hooks/useDocxExport.js";
|
|
10
10
|
export * from "./components/ExportDocxButton.js";
|
|
11
11
|
export * from "./hooks/useAgentToolProvider.js";
|
|
12
|
+
export * from "./hooks/useRichTextEditorDocument.js";
|
|
12
13
|
export * from "./playback/index.js";
|
|
13
14
|
export * from "./hooks/useToolBridge.js";
|
|
14
15
|
export * from "./hooks/useToolRegistryView.js";
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
useSpreadsheetClipboard,
|
|
22
22
|
useSpreadsheetEditor,
|
|
23
23
|
useSpreadsheetViewport
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VZ7HBWKL.js";
|
|
25
25
|
import {
|
|
26
26
|
AdjustmentLayersPanel,
|
|
27
27
|
BrushOptionsBar,
|
|
@@ -713,13 +713,22 @@ function useAgentToolProvider(registry, provider, options = {}) {
|
|
|
713
713
|
}, [registry, provider]);
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
+
// src/hooks/useRichTextEditorDocument.ts
|
|
717
|
+
import { useEffect as useEffect8, useMemo as useMemo5 } from "react";
|
|
718
|
+
import { createRichTextEditorDocument } from "@pixerate/editor";
|
|
719
|
+
function useRichTextEditorDocument(editor) {
|
|
720
|
+
const doc = useMemo5(() => editor ? createRichTextEditorDocument(editor) : null, [editor]);
|
|
721
|
+
useEffect8(() => () => doc?.destroy(), [doc]);
|
|
722
|
+
return doc;
|
|
723
|
+
}
|
|
724
|
+
|
|
716
725
|
// src/hooks/useToolBridge.ts
|
|
717
|
-
import { useEffect as
|
|
726
|
+
import { useEffect as useEffect9, useState as useState4 } from "react";
|
|
718
727
|
import { connectToolBridge } from "@pixerate/editor/tools";
|
|
719
728
|
function useToolBridge(registry, options) {
|
|
720
729
|
const [state, setState] = useState4({ status: "off", editorId: null });
|
|
721
730
|
const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
|
|
722
|
-
|
|
731
|
+
useEffect9(() => {
|
|
723
732
|
if (!registry || !options) {
|
|
724
733
|
setState({ status: "off", editorId: null });
|
|
725
734
|
return;
|
|
@@ -739,20 +748,20 @@ function useToolBridge(registry, options) {
|
|
|
739
748
|
}
|
|
740
749
|
|
|
741
750
|
// src/hooks/useToolRegistryView.ts
|
|
742
|
-
import { useEffect as
|
|
751
|
+
import { useEffect as useEffect10, useMemo as useMemo6 } from "react";
|
|
743
752
|
function useToolRegistryView(registry, options = {}) {
|
|
744
753
|
const { toolsets, readOnly, discovery } = options;
|
|
745
|
-
const view =
|
|
754
|
+
const view = useMemo6(
|
|
746
755
|
() => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
|
|
747
756
|
// toolsets is applied below without making a new view, so enabled tools survive.
|
|
748
757
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
749
758
|
[registry, readOnly, discovery]
|
|
750
759
|
);
|
|
751
760
|
const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
|
|
752
|
-
|
|
761
|
+
useEffect10(() => {
|
|
753
762
|
view?.setToolsets(toolsets);
|
|
754
763
|
}, [view, toolsetsKey]);
|
|
755
|
-
|
|
764
|
+
useEffect10(() => () => view?.dispose(), [view]);
|
|
756
765
|
return view;
|
|
757
766
|
}
|
|
758
767
|
|
|
@@ -770,7 +779,7 @@ var EditorContent = ({
|
|
|
770
779
|
};
|
|
771
780
|
|
|
772
781
|
// src/components/BubbleMenu.tsx
|
|
773
|
-
import { useEffect as
|
|
782
|
+
import { useEffect as useEffect11, useRef as useRef8, useState as useState5 } from "react";
|
|
774
783
|
import { createPortal } from "react-dom";
|
|
775
784
|
import {
|
|
776
785
|
BubbleMenuPlugin
|
|
@@ -789,7 +798,7 @@ var BubbleMenu = ({
|
|
|
789
798
|
if (!menuEl.current && typeof document !== "undefined") {
|
|
790
799
|
menuEl.current = document.createElement("div");
|
|
791
800
|
}
|
|
792
|
-
|
|
801
|
+
useEffect11(() => {
|
|
793
802
|
if (!editor || !menuEl.current || editor.isDestroyed) {
|
|
794
803
|
return;
|
|
795
804
|
}
|
|
@@ -820,7 +829,7 @@ var BubbleMenu = ({
|
|
|
820
829
|
};
|
|
821
830
|
|
|
822
831
|
// src/components/TemplateRenderer.tsx
|
|
823
|
-
import { useMemo as
|
|
832
|
+
import { useMemo as useMemo7 } from "react";
|
|
824
833
|
import {
|
|
825
834
|
describeConditionalTag,
|
|
826
835
|
evaluatePromptTokens,
|
|
@@ -839,11 +848,11 @@ var TemplateRenderer = ({
|
|
|
839
848
|
onTemplateClick,
|
|
840
849
|
onVariableClick
|
|
841
850
|
}) => {
|
|
842
|
-
const displayText =
|
|
851
|
+
const displayText = useMemo7(() => {
|
|
843
852
|
if (!resolve || templates.length === 0) return content;
|
|
844
853
|
return resolveTemplates(content, templates, { bindings });
|
|
845
854
|
}, [content, templates, resolve, bindings]);
|
|
846
|
-
const tokens =
|
|
855
|
+
const tokens = useMemo7(() => {
|
|
847
856
|
return evaluatePromptTokens(displayText, values);
|
|
848
857
|
}, [displayText, values]);
|
|
849
858
|
return /* @__PURE__ */ jsx3("div", { className, children: tokens.map((token, index) => {
|
|
@@ -932,7 +941,7 @@ var TemplateRenderer = ({
|
|
|
932
941
|
};
|
|
933
942
|
|
|
934
943
|
// src/components/VariableForm.tsx
|
|
935
|
-
import { useId, useMemo as
|
|
944
|
+
import { useId, useMemo as useMemo8, useState as useState6 } from "react";
|
|
936
945
|
import {
|
|
937
946
|
compactVariableValues,
|
|
938
947
|
getVariableFormFields
|
|
@@ -952,7 +961,7 @@ var VariableForm = ({
|
|
|
952
961
|
() => defaultValues ?? {}
|
|
953
962
|
);
|
|
954
963
|
const entered = values ?? internal;
|
|
955
|
-
const fields =
|
|
964
|
+
const fields = useMemo8(
|
|
956
965
|
() => getVariableFormFields(content, { templates, bindings }),
|
|
957
966
|
[content, templates, bindings]
|
|
958
967
|
);
|
|
@@ -1023,7 +1032,7 @@ var VariableForm = ({
|
|
|
1023
1032
|
import { useId as useId2, useState as useState8 } from "react";
|
|
1024
1033
|
|
|
1025
1034
|
// src/hooks/useMergePreview.ts
|
|
1026
|
-
import { useCallback as useCallback5, useMemo as
|
|
1035
|
+
import { useCallback as useCallback5, useMemo as useMemo9, useState as useState7 } from "react";
|
|
1027
1036
|
import {
|
|
1028
1037
|
extractVariables,
|
|
1029
1038
|
matchFields,
|
|
@@ -1038,15 +1047,15 @@ function useMergePreview(options) {
|
|
|
1038
1047
|
const [overrides, setOverrides] = useState7({});
|
|
1039
1048
|
const [index, setIndexState] = useState7(0);
|
|
1040
1049
|
const [result, setResult] = useState7(null);
|
|
1041
|
-
const source =
|
|
1050
|
+
const source = useMemo9(
|
|
1042
1051
|
() => parseDataSource(sourceText, parseOptions),
|
|
1043
1052
|
[sourceText, parseOptions]
|
|
1044
1053
|
);
|
|
1045
|
-
const variables =
|
|
1054
|
+
const variables = useMemo9(
|
|
1046
1055
|
() => extractVariables(template, { templates, bindings }).map((v) => v.name),
|
|
1047
1056
|
[template, templates, bindings]
|
|
1048
1057
|
);
|
|
1049
|
-
const mapping =
|
|
1058
|
+
const mapping = useMemo9(() => {
|
|
1050
1059
|
const merged = {
|
|
1051
1060
|
...matchFields(variables, source.fields).mapping
|
|
1052
1061
|
};
|
|
@@ -1060,7 +1069,7 @@ function useMergePreview(options) {
|
|
|
1060
1069
|
const count = source.records.length;
|
|
1061
1070
|
const current = count === 0 ? 0 : Math.min(index, count - 1);
|
|
1062
1071
|
const record = source.records[current];
|
|
1063
|
-
const values =
|
|
1072
|
+
const values = useMemo9(
|
|
1064
1073
|
() => record ? recordToValues(record, mapping) : {},
|
|
1065
1074
|
[record, mapping]
|
|
1066
1075
|
);
|
|
@@ -1315,10 +1324,10 @@ var MergePreview = ({
|
|
|
1315
1324
|
};
|
|
1316
1325
|
|
|
1317
1326
|
// src/hooks/useOutline.ts
|
|
1318
|
-
import { useMemo as
|
|
1327
|
+
import { useMemo as useMemo10, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
1319
1328
|
import { createOutlineStore } from "@pixerate/editor";
|
|
1320
1329
|
function useOutline(editor) {
|
|
1321
|
-
const store =
|
|
1330
|
+
const store = useMemo10(() => createOutlineStore(editor), [editor]);
|
|
1322
1331
|
return useSyncExternalStore5(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1323
1332
|
}
|
|
1324
1333
|
|
|
@@ -1364,15 +1373,15 @@ var OutlinePanel = ({
|
|
|
1364
1373
|
};
|
|
1365
1374
|
|
|
1366
1375
|
// src/hooks/useParagraphStyles.ts
|
|
1367
|
-
import { useMemo as
|
|
1376
|
+
import { useMemo as useMemo11, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1368
1377
|
import {
|
|
1369
1378
|
createParagraphStylesStore,
|
|
1370
1379
|
getStyleRegistry
|
|
1371
1380
|
} from "@pixerate/editor";
|
|
1372
1381
|
function useParagraphStyles(editor) {
|
|
1373
|
-
const store =
|
|
1382
|
+
const store = useMemo11(() => createParagraphStylesStore(editor), [editor]);
|
|
1374
1383
|
const snapshot = useSyncExternalStore6(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1375
|
-
return
|
|
1384
|
+
return useMemo11(() => {
|
|
1376
1385
|
const registry = getStyleRegistry(editor);
|
|
1377
1386
|
const live = () => editor && !editor.isDestroyed ? editor : null;
|
|
1378
1387
|
return {
|
|
@@ -1537,7 +1546,7 @@ import {
|
|
|
1537
1546
|
} from "@pixerate/editor";
|
|
1538
1547
|
|
|
1539
1548
|
// src/slots.tsx
|
|
1540
|
-
import { createContext, useContext, useMemo as
|
|
1549
|
+
import { createContext, useContext, useMemo as useMemo12 } from "react";
|
|
1541
1550
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1542
1551
|
var defaultSlots = {
|
|
1543
1552
|
Button: (props) => /* @__PURE__ */ jsx8(
|
|
@@ -1561,7 +1570,7 @@ var defaultSlots = {
|
|
|
1561
1570
|
};
|
|
1562
1571
|
var EditorSlotsContext = createContext(defaultSlots);
|
|
1563
1572
|
function EditorSlotsProvider({ slots, children }) {
|
|
1564
|
-
const mergedSlots =
|
|
1573
|
+
const mergedSlots = useMemo12(() => ({ ...defaultSlots, ...slots }), [slots]);
|
|
1565
1574
|
return /* @__PURE__ */ jsx8(EditorSlotsContext.Provider, { value: mergedSlots, children });
|
|
1566
1575
|
}
|
|
1567
1576
|
function useEditorSlots() {
|
|
@@ -1569,7 +1578,7 @@ function useEditorSlots() {
|
|
|
1569
1578
|
}
|
|
1570
1579
|
|
|
1571
1580
|
// src/review/useReview.ts
|
|
1572
|
-
import { useCallback as useCallback6, useMemo as
|
|
1581
|
+
import { useCallback as useCallback6, useMemo as useMemo13, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
1573
1582
|
import {
|
|
1574
1583
|
getCommentStore,
|
|
1575
1584
|
getTrackChangesStore
|
|
@@ -1597,7 +1606,7 @@ function useComments(source) {
|
|
|
1597
1606
|
);
|
|
1598
1607
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
1599
1608
|
const snapshot = useSyncExternalStore7(subscribe, getSnapshot, getSnapshot);
|
|
1600
|
-
return
|
|
1609
|
+
return useMemo13(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
1601
1610
|
}
|
|
1602
1611
|
function useTrackChanges(editor) {
|
|
1603
1612
|
const store = getTrackChangesStore(editor ?? null);
|
|
@@ -1607,7 +1616,7 @@ function useTrackChanges(editor) {
|
|
|
1607
1616
|
);
|
|
1608
1617
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
1609
1618
|
const snapshot = useSyncExternalStore7(subscribe, getSnapshot, getSnapshot);
|
|
1610
|
-
return
|
|
1619
|
+
return useMemo13(() => {
|
|
1611
1620
|
const run = (fn) => () => {
|
|
1612
1621
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
1613
1622
|
};
|
|
@@ -1907,7 +1916,7 @@ var CommentButton = ({
|
|
|
1907
1916
|
);
|
|
1908
1917
|
|
|
1909
1918
|
// src/review/useDocumentCompare.ts
|
|
1910
|
-
import { useCallback as useCallback7, useMemo as
|
|
1919
|
+
import { useCallback as useCallback7, useMemo as useMemo14, useRef as useRef9, useState as useState11 } from "react";
|
|
1911
1920
|
import {
|
|
1912
1921
|
applyDocumentComparison
|
|
1913
1922
|
} from "@pixerate/editor";
|
|
@@ -1928,7 +1937,7 @@ function useDocumentCompare(editor, options) {
|
|
|
1928
1937
|
[editor]
|
|
1929
1938
|
);
|
|
1930
1939
|
const clear = useCallback7(() => setSummary(null), []);
|
|
1931
|
-
return
|
|
1940
|
+
return useMemo14(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
1932
1941
|
}
|
|
1933
1942
|
|
|
1934
1943
|
// src/review/TrackedChangesList.tsx
|
|
@@ -1979,7 +1988,7 @@ var TrackedChangesList = ({
|
|
|
1979
1988
|
};
|
|
1980
1989
|
|
|
1981
1990
|
// src/find-replace/useFindReplace.ts
|
|
1982
|
-
import { useCallback as useCallback8, useMemo as
|
|
1991
|
+
import { useCallback as useCallback8, useMemo as useMemo15, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
1983
1992
|
import {
|
|
1984
1993
|
EMPTY_FIND_REPLACE_SNAPSHOT,
|
|
1985
1994
|
getFindReplaceStore
|
|
@@ -1994,7 +2003,7 @@ function useFindReplace(editor) {
|
|
|
1994
2003
|
);
|
|
1995
2004
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
1996
2005
|
const snapshot = useSyncExternalStore8(subscribe, getSnapshot, getSnapshot);
|
|
1997
|
-
return
|
|
2006
|
+
return useMemo15(() => {
|
|
1998
2007
|
const run = (fn) => {
|
|
1999
2008
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
2000
2009
|
};
|
|
@@ -2018,7 +2027,7 @@ function useFindReplace(editor) {
|
|
|
2018
2027
|
}
|
|
2019
2028
|
|
|
2020
2029
|
// src/find-replace/FindReplaceBar.tsx
|
|
2021
|
-
import { useEffect as
|
|
2030
|
+
import { useEffect as useEffect12, useRef as useRef10, useState as useState12 } from "react";
|
|
2022
2031
|
import { FIND_OPTION_TOGGLES, formatFindStatus } from "@pixerate/editor";
|
|
2023
2032
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2024
2033
|
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";
|
|
@@ -2036,7 +2045,7 @@ var FindReplaceBar = ({
|
|
|
2036
2045
|
const findInput = useRef10(null);
|
|
2037
2046
|
const [moreOpen, setMoreOpen] = useState12(false);
|
|
2038
2047
|
const visible = find.available && (alwaysOpen || find.open);
|
|
2039
|
-
|
|
2048
|
+
useEffect12(() => {
|
|
2040
2049
|
if (!visible || find.focusRequest === 0) return;
|
|
2041
2050
|
findInput.current?.focus();
|
|
2042
2051
|
findInput.current?.select();
|
|
@@ -2180,16 +2189,16 @@ var FindReplaceBar = ({
|
|
|
2180
2189
|
};
|
|
2181
2190
|
|
|
2182
2191
|
// src/tables/useTableMenu.ts
|
|
2183
|
-
import { useMemo as
|
|
2192
|
+
import { useMemo as useMemo16, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
2184
2193
|
import {
|
|
2185
2194
|
createTableStore,
|
|
2186
2195
|
getTableActionState,
|
|
2187
2196
|
runTableAction
|
|
2188
2197
|
} from "@pixerate/editor";
|
|
2189
2198
|
function useTableMenu(editor) {
|
|
2190
|
-
const store =
|
|
2199
|
+
const store = useMemo16(() => createTableStore(editor), [editor]);
|
|
2191
2200
|
const snapshot = useSyncExternalStore9(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2192
|
-
return
|
|
2201
|
+
return useMemo16(
|
|
2193
2202
|
() => ({
|
|
2194
2203
|
...snapshot,
|
|
2195
2204
|
run: (action, params) => runTableAction(editor, action, params, { focus: true }),
|
|
@@ -2487,6 +2496,7 @@ export {
|
|
|
2487
2496
|
usePlaybackSurface,
|
|
2488
2497
|
usePromptEditor,
|
|
2489
2498
|
useRegisterCommands,
|
|
2499
|
+
useRichTextEditorDocument,
|
|
2490
2500
|
useSpreadsheetClipboard,
|
|
2491
2501
|
useSpreadsheetEditor,
|
|
2492
2502
|
useSpreadsheetViewport,
|
|
@@ -222,6 +222,8 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
222
222
|
[controller, afterSheetSwitch]
|
|
223
223
|
);
|
|
224
224
|
const conditionalFormatOverlay = (0, import_react.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
|
|
225
|
+
const editorDocument = (0, import_react.useMemo)(() => (0, import_spreadsheet.createSpreadsheetEditorDocument)(controller), [controller]);
|
|
226
|
+
(0, import_react.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
|
|
225
227
|
return {
|
|
226
228
|
document: doc,
|
|
227
229
|
activeCell,
|
|
@@ -233,6 +235,8 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
233
235
|
resolveValidationPrompt,
|
|
234
236
|
commitCellInput,
|
|
235
237
|
controller,
|
|
238
|
+
/** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
|
|
239
|
+
editorDocument,
|
|
236
240
|
getCell: (rowId, colId) => controller.getCell(rowId, colId),
|
|
237
241
|
setCellValue,
|
|
238
242
|
selectCell,
|
|
@@ -102,6 +102,8 @@ export declare function useSpreadsheetEditor(options?: SpreadsheetControllerOpti
|
|
|
102
102
|
resolveValidationPrompt: (action: SpreadsheetValidationAction) => void;
|
|
103
103
|
commitCellInput: (rowId: string, colId: string, raw: string) => SpreadsheetCommitResult;
|
|
104
104
|
controller: SpreadsheetController;
|
|
105
|
+
/** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
|
|
106
|
+
editorDocument: import("@pixerate/editor/persistence").EditorDocument<import("@pixerate/editor").SpreadsheetWorkbook>;
|
|
105
107
|
getCell: (rowId: string, colId: string) => import("@pixerate/editor").CellData;
|
|
106
108
|
setCellValue: (rowId: string, colId: string, raw: string) => void;
|
|
107
109
|
selectCell: (row: number, col: number, extendSelection?: boolean) => void;
|
|
@@ -102,6 +102,8 @@ export declare function useSpreadsheetEditor(options?: SpreadsheetControllerOpti
|
|
|
102
102
|
resolveValidationPrompt: (action: SpreadsheetValidationAction) => void;
|
|
103
103
|
commitCellInput: (rowId: string, colId: string, raw: string) => SpreadsheetCommitResult;
|
|
104
104
|
controller: SpreadsheetController;
|
|
105
|
+
/** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
|
|
106
|
+
editorDocument: import("@pixerate/editor/persistence").EditorDocument<import("@pixerate/editor").SpreadsheetWorkbook>;
|
|
105
107
|
getCell: (rowId: string, colId: string) => import("@pixerate/editor").CellData;
|
|
106
108
|
setCellValue: (rowId: string, colId: string, raw: string) => void;
|
|
107
109
|
selectCell: (row: number, col: number, extendSelection?: boolean) => void;
|
package/dist/tokens/index.cjs
CHANGED
|
@@ -51,7 +51,9 @@ function useTokens(store, options = {}) {
|
|
|
51
51
|
const css = (0, import_react.useMemo)(() => (0, import_tokens.exportTokensCss)(state, options.css), [state, cssKey]);
|
|
52
52
|
const undo = (0, import_react.useCallback)(() => void store.undo(), [store]);
|
|
53
53
|
const redo = (0, import_react.useCallback)(() => void store.redo(), [store]);
|
|
54
|
-
|
|
54
|
+
const editorDocument = (0, import_react.useMemo)(() => (0, import_tokens.createTokensEditorDocument)(store), [store]);
|
|
55
|
+
(0, import_react.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
|
|
56
|
+
return { store, editorDocument, state, cssVariables, css, canUndo: store.canUndo(), canRedo: store.canRedo(), undo, redo };
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
// src/tokens/TokensPanel.tsx
|
package/dist/tokens/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/tokens/useTokens.ts
|
|
2
|
-
import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
3
|
import {
|
|
4
4
|
TokenStore,
|
|
5
|
+
createTokensEditorDocument,
|
|
5
6
|
exportTokensCss,
|
|
6
7
|
getTokenCssVariables
|
|
7
8
|
} from "@pixerate/editor/tokens";
|
|
@@ -25,7 +26,9 @@ function useTokens(store, options = {}) {
|
|
|
25
26
|
const css = useMemo(() => exportTokensCss(state, options.css), [state, cssKey]);
|
|
26
27
|
const undo = useCallback(() => void store.undo(), [store]);
|
|
27
28
|
const redo = useCallback(() => void store.redo(), [store]);
|
|
28
|
-
|
|
29
|
+
const editorDocument = useMemo(() => createTokensEditorDocument(store), [store]);
|
|
30
|
+
useEffect(() => () => editorDocument.destroy(), [editorDocument]);
|
|
31
|
+
return { store, editorDocument, state, cssVariables, css, canUndo: store.canUndo(), canRedo: store.canRedo(), undo, redo };
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
// src/tokens/TokensPanel.tsx
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TokenStore, type TokenCssOptions, type TokenModeContext, type TokenState, type TokenStoreOptions } from '@pixerate/editor/tokens';
|
|
2
|
+
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
2
3
|
/** A `TokenStore` created once for the component's lifetime. */
|
|
3
4
|
export declare function useTokenStore(options?: TokenStoreOptions): TokenStore;
|
|
4
5
|
/** The store's current state (re-renders on every change). */
|
|
@@ -11,6 +12,8 @@ export interface UseTokensOptions {
|
|
|
11
12
|
}
|
|
12
13
|
export interface UseTokensResult {
|
|
13
14
|
store: TokenStore;
|
|
15
|
+
/** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
|
|
16
|
+
editorDocument: EditorDocument<TokenState>;
|
|
14
17
|
state: TokenState;
|
|
15
18
|
/** Resolved custom properties for `modes`, e.g. `<div style={cssVariables}>`. */
|
|
16
19
|
cssVariables: Record<string, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TokenStore, type TokenCssOptions, type TokenModeContext, type TokenState, type TokenStoreOptions } from '@pixerate/editor/tokens';
|
|
2
|
+
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
2
3
|
/** A `TokenStore` created once for the component's lifetime. */
|
|
3
4
|
export declare function useTokenStore(options?: TokenStoreOptions): TokenStore;
|
|
4
5
|
/** The store's current state (re-renders on every change). */
|
|
@@ -11,6 +12,8 @@ export interface UseTokensOptions {
|
|
|
11
12
|
}
|
|
12
13
|
export interface UseTokensResult {
|
|
13
14
|
store: TokenStore;
|
|
15
|
+
/** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
|
|
16
|
+
editorDocument: EditorDocument<TokenState>;
|
|
14
17
|
state: TokenState;
|
|
15
18
|
/** Resolved custom properties for `modes`, e.g. `<div style={cssVariables}>`. */
|
|
16
19
|
cssVariables: Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.103.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
},
|
|
246
246
|
"peerDependencies": {
|
|
247
247
|
"@dagrejs/dagre": "^1.1.8",
|
|
248
|
-
"@pixerate/editor": ">=0.
|
|
248
|
+
"@pixerate/editor": ">=0.154.0 <1.0.0-0",
|
|
249
249
|
"@tiptap/core": "^2.27.3",
|
|
250
250
|
"@tiptap/pm": "^2.27.3",
|
|
251
251
|
"@tiptap/react": "^2.27.3",
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
"tsup": "^9.0.0",
|
|
273
273
|
"typescript": "^5.7.3",
|
|
274
274
|
"vitest": "^5.0.5",
|
|
275
|
-
"@pixerate/editor": "0.
|
|
275
|
+
"@pixerate/editor": "0.154.0"
|
|
276
276
|
},
|
|
277
277
|
"scripts": {
|
|
278
278
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|