@pixerate/editor-react 0.90.1 → 0.91.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/hooks/useToolBridge.d.cts +3 -3
- package/dist/hooks/useToolBridge.d.ts +3 -3
- package/dist/hooks/useToolRegistryView.d.cts +9 -0
- package/dist/hooks/useToolRegistryView.d.ts +9 -0
- package/dist/index.cjs +533 -513
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -31
- package/package.json +13 -13
package/dist/index.d.cts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./hooks/useDocxExport.cjs";
|
|
|
10
10
|
export * from "./components/ExportDocxButton.cjs";
|
|
11
11
|
export * from "./hooks/useAgentToolProvider.cjs";
|
|
12
12
|
export * from "./hooks/useToolBridge.cjs";
|
|
13
|
+
export * from "./hooks/useToolRegistryView.cjs";
|
|
13
14
|
export * from "./components/EditorContent.cjs";
|
|
14
15
|
export * from "./components/BubbleMenu.cjs";
|
|
15
16
|
export * from "./components/TemplateRenderer.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./hooks/useDocxExport.js";
|
|
|
10
10
|
export * from "./components/ExportDocxButton.js";
|
|
11
11
|
export * from "./hooks/useAgentToolProvider.js";
|
|
12
12
|
export * from "./hooks/useToolBridge.js";
|
|
13
|
+
export * from "./hooks/useToolRegistryView.js";
|
|
13
14
|
export * from "./components/EditorContent.js";
|
|
14
15
|
export * from "./components/BubbleMenu.js";
|
|
15
16
|
export * from "./components/TemplateRenderer.js";
|
package/dist/index.js
CHANGED
|
@@ -720,6 +720,24 @@ function useToolBridge(registry, options) {
|
|
|
720
720
|
return state;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
// src/hooks/useToolRegistryView.ts
|
|
724
|
+
import { useEffect as useEffect9, useMemo as useMemo5 } from "react";
|
|
725
|
+
function useToolRegistryView(registry, options = {}) {
|
|
726
|
+
const { toolsets, readOnly, discovery } = options;
|
|
727
|
+
const view = useMemo5(
|
|
728
|
+
() => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
|
|
729
|
+
// toolsets is applied below without making a new view, so enabled tools survive.
|
|
730
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
731
|
+
[registry, readOnly, discovery]
|
|
732
|
+
);
|
|
733
|
+
const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
|
|
734
|
+
useEffect9(() => {
|
|
735
|
+
view?.setToolsets(toolsets);
|
|
736
|
+
}, [view, toolsetsKey]);
|
|
737
|
+
useEffect9(() => () => view?.dispose(), [view]);
|
|
738
|
+
return view;
|
|
739
|
+
}
|
|
740
|
+
|
|
723
741
|
// src/components/EditorContent.tsx
|
|
724
742
|
import {
|
|
725
743
|
EditorContent as TipTapEditorContent
|
|
@@ -734,7 +752,7 @@ var EditorContent = ({
|
|
|
734
752
|
};
|
|
735
753
|
|
|
736
754
|
// src/components/BubbleMenu.tsx
|
|
737
|
-
import { useEffect as
|
|
755
|
+
import { useEffect as useEffect10, useRef as useRef8, useState as useState5 } from "react";
|
|
738
756
|
import { createPortal } from "react-dom";
|
|
739
757
|
import {
|
|
740
758
|
BubbleMenuPlugin
|
|
@@ -753,7 +771,7 @@ var BubbleMenu = ({
|
|
|
753
771
|
if (!menuEl.current && typeof document !== "undefined") {
|
|
754
772
|
menuEl.current = document.createElement("div");
|
|
755
773
|
}
|
|
756
|
-
|
|
774
|
+
useEffect10(() => {
|
|
757
775
|
if (!editor || !menuEl.current || editor.isDestroyed) {
|
|
758
776
|
return;
|
|
759
777
|
}
|
|
@@ -784,7 +802,7 @@ var BubbleMenu = ({
|
|
|
784
802
|
};
|
|
785
803
|
|
|
786
804
|
// src/components/TemplateRenderer.tsx
|
|
787
|
-
import { useMemo as
|
|
805
|
+
import { useMemo as useMemo6 } from "react";
|
|
788
806
|
import {
|
|
789
807
|
describeConditionalTag,
|
|
790
808
|
evaluatePromptTokens,
|
|
@@ -803,11 +821,11 @@ var TemplateRenderer = ({
|
|
|
803
821
|
onTemplateClick,
|
|
804
822
|
onVariableClick
|
|
805
823
|
}) => {
|
|
806
|
-
const displayText =
|
|
824
|
+
const displayText = useMemo6(() => {
|
|
807
825
|
if (!resolve || templates.length === 0) return content;
|
|
808
826
|
return resolveTemplates(content, templates, { bindings });
|
|
809
827
|
}, [content, templates, resolve, bindings]);
|
|
810
|
-
const tokens =
|
|
828
|
+
const tokens = useMemo6(() => {
|
|
811
829
|
return evaluatePromptTokens(displayText, values);
|
|
812
830
|
}, [displayText, values]);
|
|
813
831
|
return /* @__PURE__ */ jsx3("div", { className, children: tokens.map((token, index) => {
|
|
@@ -896,7 +914,7 @@ var TemplateRenderer = ({
|
|
|
896
914
|
};
|
|
897
915
|
|
|
898
916
|
// src/components/VariableForm.tsx
|
|
899
|
-
import { useId, useMemo as
|
|
917
|
+
import { useId, useMemo as useMemo7, useState as useState6 } from "react";
|
|
900
918
|
import {
|
|
901
919
|
compactVariableValues,
|
|
902
920
|
getVariableFormFields
|
|
@@ -916,7 +934,7 @@ var VariableForm = ({
|
|
|
916
934
|
() => defaultValues ?? {}
|
|
917
935
|
);
|
|
918
936
|
const entered = values ?? internal;
|
|
919
|
-
const fields =
|
|
937
|
+
const fields = useMemo7(
|
|
920
938
|
() => getVariableFormFields(content, { templates, bindings }),
|
|
921
939
|
[content, templates, bindings]
|
|
922
940
|
);
|
|
@@ -987,7 +1005,7 @@ var VariableForm = ({
|
|
|
987
1005
|
import { useId as useId2, useState as useState8 } from "react";
|
|
988
1006
|
|
|
989
1007
|
// src/hooks/useMergePreview.ts
|
|
990
|
-
import { useCallback as useCallback5, useMemo as
|
|
1008
|
+
import { useCallback as useCallback5, useMemo as useMemo8, useState as useState7 } from "react";
|
|
991
1009
|
import {
|
|
992
1010
|
extractVariables,
|
|
993
1011
|
matchFields,
|
|
@@ -1002,15 +1020,15 @@ function useMergePreview(options) {
|
|
|
1002
1020
|
const [overrides, setOverrides] = useState7({});
|
|
1003
1021
|
const [index, setIndexState] = useState7(0);
|
|
1004
1022
|
const [result, setResult] = useState7(null);
|
|
1005
|
-
const source =
|
|
1023
|
+
const source = useMemo8(
|
|
1006
1024
|
() => parseDataSource(sourceText, parseOptions),
|
|
1007
1025
|
[sourceText, parseOptions]
|
|
1008
1026
|
);
|
|
1009
|
-
const variables =
|
|
1027
|
+
const variables = useMemo8(
|
|
1010
1028
|
() => extractVariables(template, { templates, bindings }).map((v) => v.name),
|
|
1011
1029
|
[template, templates, bindings]
|
|
1012
1030
|
);
|
|
1013
|
-
const mapping =
|
|
1031
|
+
const mapping = useMemo8(() => {
|
|
1014
1032
|
const merged = {
|
|
1015
1033
|
...matchFields(variables, source.fields).mapping
|
|
1016
1034
|
};
|
|
@@ -1024,7 +1042,7 @@ function useMergePreview(options) {
|
|
|
1024
1042
|
const count = source.records.length;
|
|
1025
1043
|
const current = count === 0 ? 0 : Math.min(index, count - 1);
|
|
1026
1044
|
const record = source.records[current];
|
|
1027
|
-
const values =
|
|
1045
|
+
const values = useMemo8(
|
|
1028
1046
|
() => record ? recordToValues(record, mapping) : {},
|
|
1029
1047
|
[record, mapping]
|
|
1030
1048
|
);
|
|
@@ -1279,10 +1297,10 @@ var MergePreview = ({
|
|
|
1279
1297
|
};
|
|
1280
1298
|
|
|
1281
1299
|
// src/hooks/useOutline.ts
|
|
1282
|
-
import { useMemo as
|
|
1300
|
+
import { useMemo as useMemo9, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
1283
1301
|
import { createOutlineStore } from "@pixerate/editor";
|
|
1284
1302
|
function useOutline(editor) {
|
|
1285
|
-
const store =
|
|
1303
|
+
const store = useMemo9(() => createOutlineStore(editor), [editor]);
|
|
1286
1304
|
return useSyncExternalStore5(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1287
1305
|
}
|
|
1288
1306
|
|
|
@@ -1328,15 +1346,15 @@ var OutlinePanel = ({
|
|
|
1328
1346
|
};
|
|
1329
1347
|
|
|
1330
1348
|
// src/hooks/useParagraphStyles.ts
|
|
1331
|
-
import { useMemo as
|
|
1349
|
+
import { useMemo as useMemo10, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1332
1350
|
import {
|
|
1333
1351
|
createParagraphStylesStore,
|
|
1334
1352
|
getStyleRegistry
|
|
1335
1353
|
} from "@pixerate/editor";
|
|
1336
1354
|
function useParagraphStyles(editor) {
|
|
1337
|
-
const store =
|
|
1355
|
+
const store = useMemo10(() => createParagraphStylesStore(editor), [editor]);
|
|
1338
1356
|
const snapshot = useSyncExternalStore6(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1339
|
-
return
|
|
1357
|
+
return useMemo10(() => {
|
|
1340
1358
|
const registry = getStyleRegistry(editor);
|
|
1341
1359
|
const live = () => editor && !editor.isDestroyed ? editor : null;
|
|
1342
1360
|
return {
|
|
@@ -1501,7 +1519,7 @@ import {
|
|
|
1501
1519
|
} from "@pixerate/editor";
|
|
1502
1520
|
|
|
1503
1521
|
// src/slots.tsx
|
|
1504
|
-
import { createContext, useContext, useMemo as
|
|
1522
|
+
import { createContext, useContext, useMemo as useMemo11 } from "react";
|
|
1505
1523
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1506
1524
|
var defaultSlots = {
|
|
1507
1525
|
Button: (props) => /* @__PURE__ */ jsx8(
|
|
@@ -1525,7 +1543,7 @@ var defaultSlots = {
|
|
|
1525
1543
|
};
|
|
1526
1544
|
var EditorSlotsContext = createContext(defaultSlots);
|
|
1527
1545
|
function EditorSlotsProvider({ slots, children }) {
|
|
1528
|
-
const mergedSlots =
|
|
1546
|
+
const mergedSlots = useMemo11(() => ({ ...defaultSlots, ...slots }), [slots]);
|
|
1529
1547
|
return /* @__PURE__ */ jsx8(EditorSlotsContext.Provider, { value: mergedSlots, children });
|
|
1530
1548
|
}
|
|
1531
1549
|
function useEditorSlots() {
|
|
@@ -1533,7 +1551,7 @@ function useEditorSlots() {
|
|
|
1533
1551
|
}
|
|
1534
1552
|
|
|
1535
1553
|
// src/review/useReview.ts
|
|
1536
|
-
import { useCallback as useCallback6, useMemo as
|
|
1554
|
+
import { useCallback as useCallback6, useMemo as useMemo12, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
1537
1555
|
import {
|
|
1538
1556
|
getCommentStore,
|
|
1539
1557
|
getTrackChangesStore
|
|
@@ -1561,7 +1579,7 @@ function useComments(source) {
|
|
|
1561
1579
|
);
|
|
1562
1580
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
1563
1581
|
const snapshot = useSyncExternalStore7(subscribe, getSnapshot, getSnapshot);
|
|
1564
|
-
return
|
|
1582
|
+
return useMemo12(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
1565
1583
|
}
|
|
1566
1584
|
function useTrackChanges(editor) {
|
|
1567
1585
|
const store = getTrackChangesStore(editor ?? null);
|
|
@@ -1571,7 +1589,7 @@ function useTrackChanges(editor) {
|
|
|
1571
1589
|
);
|
|
1572
1590
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
1573
1591
|
const snapshot = useSyncExternalStore7(subscribe, getSnapshot, getSnapshot);
|
|
1574
|
-
return
|
|
1592
|
+
return useMemo12(() => {
|
|
1575
1593
|
const run = (fn) => () => {
|
|
1576
1594
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
1577
1595
|
};
|
|
@@ -1871,7 +1889,7 @@ var CommentButton = ({
|
|
|
1871
1889
|
);
|
|
1872
1890
|
|
|
1873
1891
|
// src/review/useDocumentCompare.ts
|
|
1874
|
-
import { useCallback as useCallback7, useMemo as
|
|
1892
|
+
import { useCallback as useCallback7, useMemo as useMemo13, useRef as useRef9, useState as useState11 } from "react";
|
|
1875
1893
|
import {
|
|
1876
1894
|
applyDocumentComparison
|
|
1877
1895
|
} from "@pixerate/editor";
|
|
@@ -1892,7 +1910,7 @@ function useDocumentCompare(editor, options) {
|
|
|
1892
1910
|
[editor]
|
|
1893
1911
|
);
|
|
1894
1912
|
const clear = useCallback7(() => setSummary(null), []);
|
|
1895
|
-
return
|
|
1913
|
+
return useMemo13(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
1896
1914
|
}
|
|
1897
1915
|
|
|
1898
1916
|
// src/review/TrackedChangesList.tsx
|
|
@@ -1943,7 +1961,7 @@ var TrackedChangesList = ({
|
|
|
1943
1961
|
};
|
|
1944
1962
|
|
|
1945
1963
|
// src/find-replace/useFindReplace.ts
|
|
1946
|
-
import { useCallback as useCallback8, useMemo as
|
|
1964
|
+
import { useCallback as useCallback8, useMemo as useMemo14, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
1947
1965
|
import {
|
|
1948
1966
|
EMPTY_FIND_REPLACE_SNAPSHOT,
|
|
1949
1967
|
getFindReplaceStore
|
|
@@ -1958,7 +1976,7 @@ function useFindReplace(editor) {
|
|
|
1958
1976
|
);
|
|
1959
1977
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
1960
1978
|
const snapshot = useSyncExternalStore8(subscribe, getSnapshot, getSnapshot);
|
|
1961
|
-
return
|
|
1979
|
+
return useMemo14(() => {
|
|
1962
1980
|
const run = (fn) => {
|
|
1963
1981
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
1964
1982
|
};
|
|
@@ -1982,7 +2000,7 @@ function useFindReplace(editor) {
|
|
|
1982
2000
|
}
|
|
1983
2001
|
|
|
1984
2002
|
// src/find-replace/FindReplaceBar.tsx
|
|
1985
|
-
import { useEffect as
|
|
2003
|
+
import { useEffect as useEffect11, useRef as useRef10, useState as useState12 } from "react";
|
|
1986
2004
|
import { FIND_OPTION_TOGGLES, formatFindStatus } from "@pixerate/editor";
|
|
1987
2005
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1988
2006
|
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";
|
|
@@ -2000,7 +2018,7 @@ var FindReplaceBar = ({
|
|
|
2000
2018
|
const findInput = useRef10(null);
|
|
2001
2019
|
const [moreOpen, setMoreOpen] = useState12(false);
|
|
2002
2020
|
const visible = find.available && (alwaysOpen || find.open);
|
|
2003
|
-
|
|
2021
|
+
useEffect11(() => {
|
|
2004
2022
|
if (!visible || find.focusRequest === 0) return;
|
|
2005
2023
|
findInput.current?.focus();
|
|
2006
2024
|
findInput.current?.select();
|
|
@@ -2144,16 +2162,16 @@ var FindReplaceBar = ({
|
|
|
2144
2162
|
};
|
|
2145
2163
|
|
|
2146
2164
|
// src/tables/useTableMenu.ts
|
|
2147
|
-
import { useMemo as
|
|
2165
|
+
import { useMemo as useMemo15, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
2148
2166
|
import {
|
|
2149
2167
|
createTableStore,
|
|
2150
2168
|
getTableActionState,
|
|
2151
2169
|
runTableAction
|
|
2152
2170
|
} from "@pixerate/editor";
|
|
2153
2171
|
function useTableMenu(editor) {
|
|
2154
|
-
const store =
|
|
2172
|
+
const store = useMemo15(() => createTableStore(editor), [editor]);
|
|
2155
2173
|
const snapshot = useSyncExternalStore9(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2156
|
-
return
|
|
2174
|
+
return useMemo15(
|
|
2157
2175
|
() => ({
|
|
2158
2176
|
...snapshot,
|
|
2159
2177
|
run: (action, params) => runTableAction(editor, action, params, { focus: true }),
|
|
@@ -2448,6 +2466,7 @@ export {
|
|
|
2448
2466
|
useSpreadsheetViewport,
|
|
2449
2467
|
useTableMenu,
|
|
2450
2468
|
useToolBridge,
|
|
2469
|
+
useToolRegistryView,
|
|
2451
2470
|
useTrackChanges,
|
|
2452
2471
|
withoutDirty
|
|
2453
2472
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.1",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -213,16 +213,16 @@
|
|
|
213
213
|
],
|
|
214
214
|
"sideEffects": false,
|
|
215
215
|
"dependencies": {
|
|
216
|
-
"@tiptap/extension-bubble-menu": "^2.
|
|
217
|
-
"@tiptap/extension-placeholder": "^2.
|
|
218
|
-
"@tiptap/starter-kit": "^2.
|
|
216
|
+
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
217
|
+
"@tiptap/extension-placeholder": "^2.27.3",
|
|
218
|
+
"@tiptap/starter-kit": "^2.27.3"
|
|
219
219
|
},
|
|
220
220
|
"peerDependencies": {
|
|
221
221
|
"@dagrejs/dagre": "^1.1.8",
|
|
222
|
-
"@pixerate/editor": ">=0.
|
|
223
|
-
"@tiptap/core": "^2.
|
|
224
|
-
"@tiptap/pm": "^2.
|
|
225
|
-
"@tiptap/react": "^2.
|
|
222
|
+
"@pixerate/editor": ">=0.140.1 <1.0.0-0",
|
|
223
|
+
"@tiptap/core": "^2.27.3",
|
|
224
|
+
"@tiptap/pm": "^2.27.3",
|
|
225
|
+
"@tiptap/react": "^2.27.3",
|
|
226
226
|
"@xyflow/react": "^12.0.0",
|
|
227
227
|
"react": ">=18.0.0",
|
|
228
228
|
"react-dom": ">=18.0.0"
|
|
@@ -236,17 +236,17 @@
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
"devDependencies": {
|
|
239
|
-
"@tiptap/core": "^2.
|
|
240
|
-
"@tiptap/pm": "^2.
|
|
241
|
-
"@tiptap/react": "^2.
|
|
239
|
+
"@tiptap/core": "^2.27.3",
|
|
240
|
+
"@tiptap/pm": "^2.27.3",
|
|
241
|
+
"@tiptap/react": "^2.27.3",
|
|
242
242
|
"@types/react": "^19.3.0",
|
|
243
243
|
"@types/react-dom": "^19.3.0",
|
|
244
244
|
"react": "^19.3.0",
|
|
245
245
|
"react-dom": "^19.3.0",
|
|
246
|
-
"tsup": "^
|
|
246
|
+
"tsup": "^9.0.0",
|
|
247
247
|
"typescript": "^5.7.3",
|
|
248
248
|
"vitest": "^5.0.5",
|
|
249
|
-
"@pixerate/editor": "0.
|
|
249
|
+
"@pixerate/editor": "0.140.1"
|
|
250
250
|
},
|
|
251
251
|
"scripts": {
|
|
252
252
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|