Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1036](https://github.com/InditexTech/weavejs/issues/1036) Corrupt Image nodes prevent frames to complete initial loading
- [#1038](https://github.com/InditexTech/weavejs/issues/1038) Is possible to add a frame inside a frame by pasting with right mouse button
- [#1043](https://github.com/InditexTech/weavejs/issues/1043) Canvas does not auto-scroll when dragging an element near the border
- [#1044](https://github.com/InditexTech/weavejs/issues/1044) Nodes disappear when moving between frames

## [3.8.0] - 2026-04-24

Expand Down
6 changes: 1 addition & 5 deletions code/packages/renderer-konva-base/src/reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ export const SIMPLE_RECONCILER = {
child.setZIndex(index);
}
},
removeChild(
instance: Weave,
parent: WeaveElementInstance | undefined,
child: WeaveElementInstance
) {
removeChild(instance: Weave, child: WeaveElementInstance) {
const type = child.getAttrs().nodeType;

const handler = instance.getNodeHandler<WeaveNode>(type);
Expand Down
33 changes: 13 additions & 20 deletions code/packages/renderer-konva-base/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
} from '@inditextech/weave-types';
import Konva from 'konva';
import { isEqual } from 'lodash';
import type { Stage } from 'konva/lib/Stage';
import type { Layer } from 'konva/lib/Layer';
import type { Group } from 'konva/lib/Group';
import type { RendererInstruction } from './types';
import { SIMPLE_RECONCILER } from './reconciler';
import { WeaveRenderer } from '@inditextech/weave-sdk';
Expand Down Expand Up @@ -299,23 +296,22 @@ export class WeaveKonvaBaseRenderer extends WeaveRenderer {

const stage = this.instance.getStage();

const parentInstance = stage.findOne(`#${instruction.parentKey}`) as
| Stage
| Layer
| Group;

const childInstance = stage.findOne(
const childInstances: WeaveElementInstance[] = stage.find(
`#${instruction.key}`
) as WeaveElementInstance;
);

if (!childInstance) {
console.warn(
`Trying to remove non existing node with key ${instruction.key}`
);
return;
}
for (const childInstance of childInstances) {
let parent = childInstance.getParent();
if (parent?.getAttrs().nodeId) {
parent = stage.findOne(
`#${parent.getAttrs().nodeId}`
) as Konva.Container;
}

this.reconciler.removeChild(this.instance, parentInstance, childInstance);
if (parent?.id() === instruction.parentKey) {
this.reconciler.removeChild(this.instance, childInstance);
}
}
}

private updateProps(instruction: RendererInstruction) {
Expand All @@ -330,9 +326,6 @@ export class WeaveKonvaBaseRenderer extends WeaveRenderer {
const node = stage.findOne(`#${instruction.key}`) as WeaveElementInstance;

if (!node) {
console.warn(
`Trying to update non existing node with key ${instruction.key}`
);
return;
}

Expand Down
10 changes: 4 additions & 6 deletions code/packages/sdk/src/actions/image-tool/image-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import { WeaveNodesSelectionPlugin } from '@/plugins/nodes-selection/nodes-selec
import Konva from 'konva';
import type { WeaveImageNode } from '@/nodes/image/image';
import { SELECTION_TOOL_ACTION_NAME } from '../selection-tool/constants';
import {
getPositionRelativeToContainerOnPosition,
mergeExceptArrays,
} from '@/utils/utils';
import { mergeExceptArrays } from '@/utils/utils';
import type {
WeaveElementAttributes,
WeaveElementInstance,
Expand Down Expand Up @@ -109,8 +106,9 @@ export class WeaveImageToolAction extends WeaveAction {
if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
this.instance.getStage().setPointersPositions(e);

const position: Konva.Vector2d | null | undefined =
getPositionRelativeToContainerOnPosition(this.instance);
const position: Konva.Vector2d | null | undefined = this.instance
.getStage()
.getRelativePointerPosition();

if (!position) {
return;
Expand Down
10 changes: 4 additions & 6 deletions code/packages/sdk/src/actions/images-tool/images-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import {
WEAVE_IMAGES_TOOL_UPLOAD_TYPE,
} from './constants';
import { WeaveAction } from '../action';
import {
getPositionRelativeToContainerOnPosition,
mergeExceptArrays,
} from '@/utils/utils';
import { mergeExceptArrays } from '@/utils/utils';
import type { WeaveImageToolAction } from '../image-tool/image-tool';
import {
WEAVE_IMAGE_TOOL_ACTION_NAME,
Expand Down Expand Up @@ -120,8 +117,9 @@ export class WeaveImagesToolAction extends WeaveAction {

if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
this.instance.getStage().setPointersPositions(e);
const position: Konva.Vector2d | null | undefined =
getPositionRelativeToContainerOnPosition(this.instance);
const position: Konva.Vector2d | null | undefined = this.instance
.getStage()
.getRelativePointerPosition();

if (!position) {
return;
Expand Down
6 changes: 3 additions & 3 deletions code/packages/sdk/src/actions/video-tool/video-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { WeaveNodesSelectionPlugin } from '@/plugins/nodes-selection/nodes-selec
import Konva from 'konva';
import { SELECTION_TOOL_ACTION_NAME } from '../selection-tool/constants';
import type { WeaveVideoNode } from '@/nodes/video/video';
import { getPositionRelativeToContainerOnPosition } from '@/utils/utils';

export class WeaveVideoToolAction extends WeaveAction {
protected initialized: boolean = false;
Expand Down Expand Up @@ -82,8 +81,9 @@ export class WeaveVideoToolAction extends WeaveAction {

if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
this.instance.getStage().setPointersPositions(e);
const position: Konva.Vector2d | null | undefined =
getPositionRelativeToContainerOnPosition(this.instance);
const position: Konva.Vector2d | null | undefined = this.instance
.getStage()
.getRelativePointerPosition();

this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
videoId: dragProperties.videoId,
Expand Down
61 changes: 18 additions & 43 deletions code/packages/sdk/src/managers/targeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
WeaveMousePointInfoSimple,
} from '@inditextech/weave-types';
import type { WeaveNodesSelectionPlugin } from '@/plugins/nodes-selection/nodes-selection';
import { getBoundingBox } from '@/utils/utils';
import { containerOverCursor, getBoundingBox } from '@/utils/utils';

export class WeaveTargetingManager {
private instance: Weave;
Expand Down Expand Up @@ -181,64 +181,37 @@ export class WeaveTargetingManager {

getMousePointer(point?: Konva.Vector2d): WeaveMousePointInfo {
this.logger.debug({ point }, 'getMousePointer');
const stage = this.instance.getStage();
const mainLayer = this.instance.getMainLayer();

let relativeMousePointer =
typeof point !== 'undefined'
? point
: mainLayer?.getRelativePointerPosition() ?? { x: 0, y: 0 };
let measureContainer: Konva.Layer | Konva.Group | undefined = mainLayer;
let container: Konva.Layer | Konva.Node | undefined = mainLayer;

const utilityLayer = this.instance.getUtilityLayer();
if (utilityLayer) {
utilityLayer.visible(false);
}

let containerAlt = containerOverCursor(
this.instance,
[],
relativeMousePointer
);

if (!containerAlt) {
containerAlt = this.instance.getMainLayer();
}

const nodesSelection =
this.instance.getPlugin<WeaveNodesSelectionPlugin>('nodesSelection');

if (nodesSelection) {
nodesSelection.getTransformer().visible(false);
}

const dummyRect = new Konva.Rect({
width: 10,
height: 10,
x: relativeMousePointer.x,
y: relativeMousePointer.y,
});
mainLayer?.add(dummyRect);

const intersectedNode = this.nodeIntersectsContainerElement(dummyRect);
if (intersectedNode) {
const containerOfNode = stage.findOne(
`#${intersectedNode.getAttrs().containerId}`
) as Konva.Group | undefined;
if (containerOfNode) {
container = intersectedNode;
measureContainer = containerOfNode;
}
}

if (
typeof point === 'undefined' &&
container?.getAttrs().nodeType !== 'layer'
) {
relativeMousePointer =
measureContainer?.getRelativePointerPosition() ?? relativeMousePointer;
}

if (
typeof point === 'undefined' &&
container?.getAttrs().nodeType === 'layer'
) {
relativeMousePointer = measureContainer?.getRelativePointerPosition() ?? {
x: 0,
y: 0,
};
}
relativeMousePointer =
containerAlt?.getRelativePointerPosition() ?? relativeMousePointer;

if (utilityLayer) {
utilityLayer.visible(true);
Expand All @@ -248,9 +221,11 @@ export class WeaveTargetingManager {
nodesSelection.getTransformer().visible(true);
}

dummyRect.destroy();

return { mousePoint: relativeMousePointer, container, measureContainer };
return {
mousePoint: relativeMousePointer,
container: containerAlt,
measureContainer: containerAlt,
};
}

getMousePointerRelativeToContainer(
Expand Down
1 change: 0 additions & 1 deletion code/packages/sdk/src/nodes/connector/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,6 @@ export class WeaveConnectorNode extends WeaveNode {
delete cleanedAttrs.startInfoLoaded;
delete cleanedAttrs.endInfoLoaded;
delete cleanedAttrs.overridesMouseControl;
delete cleanedAttrs.onMoveContainer;
delete cleanedAttrs.dragBoundFunc;

return {
Expand Down
1 change: 0 additions & 1 deletion code/packages/sdk/src/nodes/extensions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ declare module 'konva/lib/Node' {
updatePosition(position: Vector2d): void;
dblClick(): void;
isSelectable(): boolean;
movedToContainer(container: Konva.Layer | Konva.Group): void;
handleMouseover(e: KonvaEventObject): void;
handleMouseout(e: KonvaEventObject): void;
handleSelectNode(): void;
Expand Down
1 change: 0 additions & 1 deletion code/packages/sdk/src/nodes/frame/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ export class WeaveFrameNode extends WeaveNode {
delete cleanedAttrs.draggable;
delete cleanedAttrs.onTargetEnter;
delete cleanedAttrs.overridesMouseControl;
delete cleanedAttrs.onMoveContainer;
delete cleanedAttrs.dragBoundFunc;

return {
Expand Down
1 change: 0 additions & 1 deletion code/packages/sdk/src/nodes/group/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class WeaveGroupNode extends WeaveNode {
delete cleanedAttrs.mutexUserId;
delete cleanedAttrs.draggable;
delete cleanedAttrs.overridesMouseControl;
delete cleanedAttrs.onMoveContainer;
delete cleanedAttrs.dragBoundFunc;

return {
Expand Down
3 changes: 3 additions & 0 deletions code/packages/sdk/src/nodes/image/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const WEAVE_IMAGE_CROP_ANCHOR_POSITION = {
} as const;

export const WEAVE_IMAGE_DEFAULT_CONFIG: WeaveImageProperties = {
cleanup: {
intervalMs: 60 * 1000, // 1 minute
},
performance: {
cache: {
enabled: false,
Expand Down
Loading
Loading