@inditextech/weave-react 0.29.1 → 0.30.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/react.cjs +4 -20
- package/dist/react.d.cts +2 -9
- package/dist/react.d.ts +2 -9
- package/dist/react.js +5 -21
- package/package.json +2 -2
package/dist/react.cjs
CHANGED
|
@@ -228,7 +228,7 @@ const useWeave = create()((set) => ({
|
|
|
228
228
|
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/components/provider.tsx
|
|
231
|
-
const WeaveProvider = ({
|
|
231
|
+
const WeaveProvider = ({ getContainer, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [], children }) => {
|
|
232
232
|
const weaveInstanceRef = react.default.useRef(null);
|
|
233
233
|
const selectedNodes = useWeave((state) => state.selection.nodes);
|
|
234
234
|
const setInstance = useWeave((state) => state.setInstance);
|
|
@@ -285,7 +285,8 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
285
285
|
);
|
|
286
286
|
react.default.useEffect(() => {
|
|
287
287
|
async function initWeave() {
|
|
288
|
-
const weaveEle =
|
|
288
|
+
const weaveEle = getContainer();
|
|
289
|
+
if (!weaveEle) throw new Error(`Weave container not defined.`);
|
|
289
290
|
const weaveEleClientRect = weaveEle?.getBoundingClientRect();
|
|
290
291
|
if (weaveEle && !weaveInstanceRef.current) {
|
|
291
292
|
const instanceNodes = [];
|
|
@@ -294,23 +295,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
294
295
|
if (actions.length > 0) for (const action of actions) instanceActions.push(action);
|
|
295
296
|
const instancePlugins = [];
|
|
296
297
|
if (plugins.length > 0) for (const plugin of plugins) instancePlugins.push(plugin);
|
|
297
|
-
else {
|
|
298
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveStageGridPlugin());
|
|
299
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveStagePanningPlugin());
|
|
300
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveStageResizePlugin());
|
|
301
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveStageZoomPlugin());
|
|
302
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveNodesSelectionPlugin());
|
|
303
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveNodesSnappingPlugin());
|
|
304
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveStageDropAreaPlugin());
|
|
305
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveCopyPasteNodesPlugin());
|
|
306
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveConnectedUsersPlugin({ config: { getUser } }));
|
|
307
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveUsersPointersPlugin({ config: { getUser } }));
|
|
308
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveUsersSelectionPlugin({ config: { getUser } }));
|
|
309
|
-
instancePlugins.push(new __inditextech_weave_sdk.WeaveContextMenuPlugin({ config: {
|
|
310
|
-
xOffset: 10,
|
|
311
|
-
yOffset: 10
|
|
312
|
-
} }));
|
|
313
|
-
}
|
|
314
298
|
weaveInstanceRef.current = new __inditextech_weave_sdk.Weave({
|
|
315
299
|
store,
|
|
316
300
|
nodes,
|
|
@@ -319,7 +303,7 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
319
303
|
fonts,
|
|
320
304
|
logger: { level: "info" }
|
|
321
305
|
}, {
|
|
322
|
-
container:
|
|
306
|
+
container: weaveEle,
|
|
323
307
|
width: weaveEleClientRect?.width ?? 1920,
|
|
324
308
|
height: weaveEleClientRect?.height ?? 1080
|
|
325
309
|
});
|
package/dist/react.d.cts
CHANGED
|
@@ -35,11 +35,6 @@ type WeaveSelection = {
|
|
|
35
35
|
instance: Konva.Shape | Konva.Group;
|
|
36
36
|
node: WeaveStateElement;
|
|
37
37
|
};
|
|
38
|
-
type WeaveUser = {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
name: string;
|
|
41
|
-
email: string;
|
|
42
|
-
};
|
|
43
38
|
type WeaveFont = {
|
|
44
39
|
id: string;
|
|
45
40
|
name: string;
|
|
@@ -55,8 +50,7 @@ declare const WEAVE_INSTANCE_STATUS: {
|
|
|
55
50
|
}; //#endregion
|
|
56
51
|
//#region src/components/provider.d.ts
|
|
57
52
|
type WeaveProviderType = {
|
|
58
|
-
|
|
59
|
-
getUser: () => WeaveUser;
|
|
53
|
+
getContainer: () => HTMLDivElement;
|
|
60
54
|
fonts?: WeaveFont[];
|
|
61
55
|
store: WeaveStore;
|
|
62
56
|
nodes?: WeaveNode[];
|
|
@@ -68,8 +62,7 @@ type WeaveProviderType = {
|
|
|
68
62
|
children: React.ReactNode;
|
|
69
63
|
};
|
|
70
64
|
declare const WeaveProvider: ({
|
|
71
|
-
|
|
72
|
-
getUser,
|
|
65
|
+
getContainer,
|
|
73
66
|
store,
|
|
74
67
|
nodes,
|
|
75
68
|
actions,
|
package/dist/react.d.ts
CHANGED
|
@@ -35,11 +35,6 @@ type WeaveSelection = {
|
|
|
35
35
|
instance: Konva.Shape | Konva.Group;
|
|
36
36
|
node: WeaveStateElement;
|
|
37
37
|
};
|
|
38
|
-
type WeaveUser = {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
name: string;
|
|
41
|
-
email: string;
|
|
42
|
-
};
|
|
43
38
|
type WeaveFont = {
|
|
44
39
|
id: string;
|
|
45
40
|
name: string;
|
|
@@ -55,8 +50,7 @@ declare const WEAVE_INSTANCE_STATUS: {
|
|
|
55
50
|
}; //#endregion
|
|
56
51
|
//#region src/components/provider.d.ts
|
|
57
52
|
type WeaveProviderType = {
|
|
58
|
-
|
|
59
|
-
getUser: () => WeaveUser;
|
|
53
|
+
getContainer: () => HTMLDivElement;
|
|
60
54
|
fonts?: WeaveFont[];
|
|
61
55
|
store: WeaveStore;
|
|
62
56
|
nodes?: WeaveNode[];
|
|
@@ -68,8 +62,7 @@ type WeaveProviderType = {
|
|
|
68
62
|
children: React.ReactNode;
|
|
69
63
|
};
|
|
70
64
|
declare const WeaveProvider: ({
|
|
71
|
-
|
|
72
|
-
getUser,
|
|
65
|
+
getContainer,
|
|
73
66
|
store,
|
|
74
67
|
nodes,
|
|
75
68
|
actions,
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Weave, WeaveAction,
|
|
2
|
+
import { Weave, WeaveAction, WeaveNode, WeavePlugin, WeaveStore } from "@inditextech/weave-sdk";
|
|
3
3
|
import Konva from "konva";
|
|
4
4
|
import "yjs";
|
|
5
5
|
|
|
@@ -204,7 +204,7 @@ const useWeave = create()((set) => ({
|
|
|
204
204
|
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region src/components/provider.tsx
|
|
207
|
-
const WeaveProvider = ({
|
|
207
|
+
const WeaveProvider = ({ getContainer, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [], children }) => {
|
|
208
208
|
const weaveInstanceRef = React.useRef(null);
|
|
209
209
|
const selectedNodes = useWeave((state) => state.selection.nodes);
|
|
210
210
|
const setInstance = useWeave((state) => state.setInstance);
|
|
@@ -261,7 +261,8 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
261
261
|
);
|
|
262
262
|
React.useEffect(() => {
|
|
263
263
|
async function initWeave() {
|
|
264
|
-
const weaveEle =
|
|
264
|
+
const weaveEle = getContainer();
|
|
265
|
+
if (!weaveEle) throw new Error(`Weave container not defined.`);
|
|
265
266
|
const weaveEleClientRect = weaveEle?.getBoundingClientRect();
|
|
266
267
|
if (weaveEle && !weaveInstanceRef.current) {
|
|
267
268
|
const instanceNodes = [];
|
|
@@ -270,23 +271,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
270
271
|
if (actions.length > 0) for (const action of actions) instanceActions.push(action);
|
|
271
272
|
const instancePlugins = [];
|
|
272
273
|
if (plugins.length > 0) for (const plugin of plugins) instancePlugins.push(plugin);
|
|
273
|
-
else {
|
|
274
|
-
instancePlugins.push(new WeaveStageGridPlugin());
|
|
275
|
-
instancePlugins.push(new WeaveStagePanningPlugin());
|
|
276
|
-
instancePlugins.push(new WeaveStageResizePlugin());
|
|
277
|
-
instancePlugins.push(new WeaveStageZoomPlugin());
|
|
278
|
-
instancePlugins.push(new WeaveNodesSelectionPlugin());
|
|
279
|
-
instancePlugins.push(new WeaveNodesSnappingPlugin());
|
|
280
|
-
instancePlugins.push(new WeaveStageDropAreaPlugin());
|
|
281
|
-
instancePlugins.push(new WeaveCopyPasteNodesPlugin());
|
|
282
|
-
instancePlugins.push(new WeaveConnectedUsersPlugin({ config: { getUser } }));
|
|
283
|
-
instancePlugins.push(new WeaveUsersPointersPlugin({ config: { getUser } }));
|
|
284
|
-
instancePlugins.push(new WeaveUsersSelectionPlugin({ config: { getUser } }));
|
|
285
|
-
instancePlugins.push(new WeaveContextMenuPlugin({ config: {
|
|
286
|
-
xOffset: 10,
|
|
287
|
-
yOffset: 10
|
|
288
|
-
} }));
|
|
289
|
-
}
|
|
290
274
|
weaveInstanceRef.current = new Weave({
|
|
291
275
|
store,
|
|
292
276
|
nodes,
|
|
@@ -295,7 +279,7 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
295
279
|
fonts,
|
|
296
280
|
logger: { level: "info" }
|
|
297
281
|
}, {
|
|
298
|
-
container:
|
|
282
|
+
container: weaveEle,
|
|
299
283
|
width: weaveEleClientRect?.width ?? 1920,
|
|
300
284
|
height: weaveEleClientRect?.height ?? 1080
|
|
301
285
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"yjs": "13.6.26"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@inditextech/weave-sdk": "0.
|
|
51
|
+
"@inditextech/weave-sdk": "0.30.0",
|
|
52
52
|
"@types/node": "^22.15.3",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "8.26.0",
|
|
54
54
|
"@typescript-eslint/parser": "8.26.0",
|