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
144 changes: 4 additions & 140 deletions code/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- [#693](https://github.com/InditexTech/weavejs/issues/693) Clone elements on ALT + Click & Drag

## [0.73.1] - 2025-10-09

### Fixed
Expand Down Expand Up @@ -1104,283 +1108,143 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#18](https://github.com/InditexTech/weavejs/issues/18) Fix awareness not working on store-azure-web-pubsub

[Unreleased]: https://github.com/InditexTech/weavejs/compare/0.73.1...HEAD

[0.73.1]: https://github.com/InditexTech/weavejs/compare/0.73.0...0.73.1

[0.73.0]: https://github.com/InditexTech/weavejs/compare/0.72.1...0.73.0

[0.72.1]: https://github.com/InditexTech/weavejs/compare/0.72.0...0.72.1

[0.72.0]: https://github.com/InditexTech/weavejs/compare/0.71.0...0.72.0

[0.71.0]: https://github.com/InditexTech/weavejs/compare/0.70.0...0.71.0

[0.70.0]: https://github.com/InditexTech/weavejs/compare/0.69.2...0.70.0

[0.69.2]: https://github.com/InditexTech/weavejs/compare/0.69.1...0.69.2

[0.69.1]: https://github.com/InditexTech/weavejs/compare/0.69.0...0.69.1

[0.69.0]: https://github.com/InditexTech/weavejs/compare/0.68.1...0.69.0

[0.68.1]: https://github.com/InditexTech/weavejs/compare/0.68.0...0.68.1

[0.68.0]: https://github.com/InditexTech/weavejs/compare/0.67.5...0.68.0

[0.67.5]: https://github.com/InditexTech/weavejs/compare/0.67.4...0.67.5

[0.67.4]: https://github.com/InditexTech/weavejs/compare/0.67.3...0.67.4

[0.67.3]: https://github.com/InditexTech/weavejs/compare/0.67.2...0.67.3

[0.67.2]: https://github.com/InditexTech/weavejs/compare/0.67.1...0.67.2

[0.67.1]: https://github.com/InditexTech/weavejs/compare/0.67.0...0.67.1

[0.67.0]: https://github.com/InditexTech/weavejs/compare/0.66.0...0.67.0

[0.66.0]: https://github.com/InditexTech/weavejs/compare/0.64.0...0.66.0

[0.64.0]: https://github.com/InditexTech/weavejs/compare/0.62.4...0.64.0

[0.62.4]: https://github.com/InditexTech/weavejs/compare/0.62.3...0.62.4

[0.62.3]: https://github.com/InditexTech/weavejs/compare/0.62.2...0.62.3

[0.62.2]: https://github.com/InditexTech/weavejs/compare/0.62.1...0.62.2

[0.62.1]: https://github.com/InditexTech/weavejs/compare/0.62.0...0.62.1

[0.62.0]: https://github.com/InditexTech/weavejs/compare/0.61.0...0.62.0

[0.61.0]: https://github.com/InditexTech/weavejs/compare/0.60.0...0.61.0

[0.60.0]: https://github.com/InditexTech/weavejs/compare/0.59.0...0.60.0

[0.59.0]: https://github.com/InditexTech/weavejs/compare/0.58.0...0.59.0

[0.58.0]: https://github.com/InditexTech/weavejs/compare/0.57.1...0.58.0

[0.57.1]: https://github.com/InditexTech/weavejs/compare/0.57.0...0.57.1

[0.57.0]: https://github.com/InditexTech/weavejs/compare/0.56.2...0.57.0

[0.56.2]: https://github.com/InditexTech/weavejs/compare/0.56.1...0.56.2

[0.56.1]: https://github.com/InditexTech/weavejs/compare/0.56.0...0.56.1

[0.56.0]: https://github.com/InditexTech/weavejs/compare/0.55.2...0.56.0

[0.55.2]: https://github.com/InditexTech/weavejs/compare/0.55.1...0.55.2

[0.55.1]: https://github.com/InditexTech/weavejs/compare/0.55.0...0.55.1

[0.55.0]: https://github.com/InditexTech/weavejs/compare/0.54.1...0.55.0

[0.54.1]: https://github.com/InditexTech/weavejs/compare/0.54.0...0.54.1

[0.54.0]: https://github.com/InditexTech/weavejs/compare/0.53.0...0.54.0

[0.53.0]: https://github.com/InditexTech/weavejs/compare/0.52.3...0.53.0

[0.52.3]: https://github.com/InditexTech/weavejs/compare/0.52.2...0.52.3

[0.52.2]: https://github.com/InditexTech/weavejs/compare/0.52.1...0.52.2

[0.52.1]: https://github.com/InditexTech/weavejs/compare/0.52.0...0.52.1

[0.52.0]: https://github.com/InditexTech/weavejs/compare/0.51.0...0.52.0

[0.51.0]: https://github.com/InditexTech/weavejs/compare/0.50.0...0.51.0

[0.50.0]: https://github.com/InditexTech/weavejs/compare/0.49.0...0.50.0

[0.49.0]: https://github.com/InditexTech/weavejs/compare/0.48.0...0.49.0

[0.48.0]: https://github.com/InditexTech/weavejs/compare/0.47.1...0.48.0

[0.47.1]: https://github.com/InditexTech/weavejs/compare/0.47.0...0.47.1

[0.47.0]: https://github.com/InditexTech/weavejs/compare/0.46.1...0.47.0

[0.46.1]: https://github.com/InditexTech/weavejs/compare/0.46.0...0.46.1

[0.46.0]: https://github.com/InditexTech/weavejs/compare/0.45.0...0.46.0

[0.45.0]: https://github.com/InditexTech/weavejs/compare/0.44.0...0.45.0

[0.44.0]: https://github.com/InditexTech/weavejs/compare/0.43.0...0.44.0

[0.43.0]: https://github.com/InditexTech/weavejs/compare/0.42.2...0.43.0

[0.42.2]: https://github.com/InditexTech/weavejs/compare/0.42.1...0.42.2

[0.42.1]: https://github.com/InditexTech/weavejs/compare/0.42.0...0.42.1

[0.42.0]: https://github.com/InditexTech/weavejs/compare/0.41.0...0.42.0

[0.41.0]: https://github.com/InditexTech/weavejs/compare/0.40.2...0.41.0

[0.40.2]: https://github.com/InditexTech/weavejs/compare/0.40.1...0.40.2

[0.40.1]: https://github.com/InditexTech/weavejs/compare/0.40.0...0.40.1

[0.40.0]: https://github.com/InditexTech/weavejs/compare/0.39.3...0.40.0

[0.39.3]: https://github.com/InditexTech/weavejs/compare/0.39.2...0.39.3

[0.39.2]: https://github.com/InditexTech/weavejs/compare/0.39.1...0.39.2

[0.39.1]: https://github.com/InditexTech/weavejs/compare/0.39.0...0.39.1

[0.39.0]: https://github.com/InditexTech/weavejs/compare/0.38.0...0.39.0

[0.38.0]: https://github.com/InditexTech/weavejs/compare/0.37.0...0.38.0

[0.37.0]: https://github.com/InditexTech/weavejs/compare/0.36.0...0.37.0

[0.36.0]: https://github.com/InditexTech/weavejs/compare/0.35.0...0.36.0

[0.35.0]: https://github.com/InditexTech/weavejs/compare/0.34.0...0.35.0

[0.34.0]: https://github.com/InditexTech/weavejs/compare/0.33.0...0.34.0

[0.33.0]: https://github.com/InditexTech/weavejs/compare/0.32.0...0.33.0

[0.32.0]: https://github.com/InditexTech/weavejs/compare/0.31.1...0.32.0

[0.31.1]: https://github.com/InditexTech/weavejs/compare/0.31.0...0.31.1

[0.31.0]: https://github.com/InditexTech/weavejs/compare/0.30.1...0.31.0

[0.30.1]: https://github.com/InditexTech/weavejs/compare/0.30.0...0.30.1

[0.30.0]: https://github.com/InditexTech/weavejs/compare/0.29.1...0.30.0

[0.29.1]: https://github.com/InditexTech/weavejs/compare/0.29.0...0.29.1

[0.29.0]: https://github.com/InditexTech/weavejs/compare/0.28.0...0.29.0

[0.28.0]: https://github.com/InditexTech/weavejs/compare/0.27.4...0.28.0

[0.27.4]: https://github.com/InditexTech/weavejs/compare/0.27.3...0.27.4

[0.27.3]: https://github.com/InditexTech/weavejs/compare/0.27.2...0.27.3

[0.27.2]: https://github.com/InditexTech/weavejs/compare/0.27.1...0.27.2

[0.27.1]: https://github.com/InditexTech/weavejs/compare/0.27.0...0.27.1

[0.27.0]: https://github.com/InditexTech/weavejs/compare/0.26.2...0.27.0

[0.26.2]: https://github.com/InditexTech/weavejs/compare/0.26.1...0.26.2

[0.26.1]: https://github.com/InditexTech/weavejs/compare/0.26.0...0.26.1

[0.26.0]: https://github.com/InditexTech/weavejs/compare/0.25.0...0.26.0

[0.25.0]: https://github.com/InditexTech/weavejs/compare/0.24.1...0.25.0

[0.24.1]: https://github.com/InditexTech/weavejs/compare/0.24.0...0.24.1

[0.24.0]: https://github.com/InditexTech/weavejs/compare/0.23.1...0.24.0

[0.23.1]: https://github.com/InditexTech/weavejs/compare/0.23.0...0.23.1

[0.23.0]: https://github.com/InditexTech/weavejs/compare/0.22.1...0.23.0

[0.22.1]: https://github.com/InditexTech/weavejs/compare/0.22.0...0.22.1

[0.22.0]: https://github.com/InditexTech/weavejs/compare/0.21.2...0.22.0

[0.21.2]: https://github.com/InditexTech/weavejs/compare/0.21.1...0.21.2

[0.21.1]: https://github.com/InditexTech/weavejs/compare/0.21.0...0.21.1

[0.21.0]: https://github.com/InditexTech/weavejs/compare/0.20.4...0.21.0

[0.20.4]: https://github.com/InditexTech/weavejs/compare/0.20.3...0.20.4

[0.20.3]: https://github.com/InditexTech/weavejs/compare/0.20.2...0.20.3

[0.20.2]: https://github.com/InditexTech/weavejs/compare/0.20.1...0.20.2

[0.20.1]: https://github.com/InditexTech/weavejs/compare/0.20.0...0.20.1

[0.20.0]: https://github.com/InditexTech/weavejs/compare/0.19.0...0.20.0

[0.19.0]: https://github.com/InditexTech/weavejs/compare/0.18.0...0.19.0

[0.18.0]: https://github.com/InditexTech/weavejs/compare/0.17.0...0.18.0

[0.17.0]: https://github.com/InditexTech/weavejs/compare/0.16.2...0.17.0

[0.16.2]: https://github.com/InditexTech/weavejs/compare/0.16.1...0.16.2

[0.16.1]: https://github.com/InditexTech/weavejs/compare/0.16.0...0.16.1

[0.16.0]: https://github.com/InditexTech/weavejs/compare/0.15.0...0.16.0

[0.15.0]: https://github.com/InditexTech/weavejs/compare/0.14.3...0.15.0

[0.14.3]: https://github.com/InditexTech/weavejs/compare/0.14.2...0.14.3

[0.14.2]: https://github.com/InditexTech/weavejs/compare/0.14.1...0.14.2

[0.14.1]: https://github.com/InditexTech/weavejs/compare/0.14.0...0.14.1

[0.14.0]: https://github.com/InditexTech/weavejs/compare/0.13.1...0.14.0

[0.13.1]: https://github.com/InditexTech/weavejs/compare/0.13.0...0.13.1

[0.13.0]: https://github.com/InditexTech/weavejs/compare/0.12.1...0.13.0

[0.12.1]: https://github.com/InditexTech/weavejs/compare/0.12.0...0.12.1

[0.12.0]: https://github.com/InditexTech/weavejs/compare/0.11.0...0.12.0

[0.11.0]: https://github.com/InditexTech/weavejs/compare/0.10.3...0.11.0

[0.10.3]: https://github.com/InditexTech/weavejs/compare/0.10.2...0.10.3

[0.10.2]: https://github.com/InditexTech/weavejs/compare/0.10.1...0.10.2

[0.10.1]: https://github.com/InditexTech/weavejs/compare/0.10.0...0.10.1

[0.10.0]: https://github.com/InditexTech/weavejs/compare/0.9.3...0.10.0

[0.9.3]: https://github.com/InditexTech/weavejs/compare/0.9.2...0.9.3

[0.9.2]: https://github.com/InditexTech/weavejs/compare/0.9.1...0.9.2

[0.9.1]: https://github.com/InditexTech/weavejs/compare/0.9.0...0.9.1

[0.9.0]: https://github.com/InditexTech/weavejs/compare/0.8.0...0.9.0

[0.8.0]: https://github.com/InditexTech/weavejs/compare/0.7.1...0.8.0

[0.7.1]: https://github.com/InditexTech/weavejs/compare/0.7.0...0.7.1

[0.7.0]: https://github.com/InditexTech/weavejs/compare/0.6.0...0.7.0

[0.6.0]: https://github.com/InditexTech/weavejs/compare/0.5.0...0.6.0

[0.5.0]: https://github.com/InditexTech/weavejs/compare/0.4.0...0.5.0

[0.4.0]: https://github.com/InditexTech/weavejs/compare/0.3.3...0.4.0

[0.3.3]: https://github.com/InditexTech/weavejs/compare/0.3.2...0.3.3

[0.3.2]: https://github.com/InditexTech/weavejs/compare/0.3.1...0.3.2

[0.3.1]: https://github.com/InditexTech/weavejs/compare/0.3.0...0.3.1

[0.3.0]: https://github.com/InditexTech/weavejs/compare/0.2.1...0.3.0

[0.2.1]: https://github.com/InditexTech/weavejs/compare/0.2.0...0.2.1

[0.2.0]: https://github.com/InditexTech/weavejs/compare/0.1.1...0.2.0

[0.1.1]: https://github.com/InditexTech/weavejs/compare/0.1.0...0.1.1

[0.1.0]: https://github.com/InditexTech/weavejs/releases/tag/0.1.0
2 changes: 2 additions & 0 deletions code/packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export { WeaveStageGridPlugin } from './plugins/stage-grid/stage-grid';
export * from './plugins/stage-grid/constants';
export * from './plugins/stage-grid/types';
export { WeaveStagePanningPlugin } from './plugins/stage-panning/stage-panning';
export * from './plugins/stage-panning/constants';
export * from './plugins/stage-panning/types';
export { WeaveStageMinimapPlugin } from './plugins/stage-minimap/stage-minimap';
export { WeaveStageResizePlugin } from './plugins/stage-resize/stage-resize';
export { WeaveStageZoomPlugin } from './plugins/stage-zoom/stage-zoom';
Expand Down
65 changes: 64 additions & 1 deletion code/packages/sdk/src/managers/cloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import { v4 as uuidv4 } from 'uuid';
import { Weave } from '@/weave';
import { type Vector2d } from 'konva/lib/types';
import { type Logger } from 'pino';
import { type WeaveStateElement } from '@inditextech/weave-types';
import {
type WeaveElementInstance,
type WeaveStateElement,
} from '@inditextech/weave-types';
import type { WeaveNode } from '@/nodes/node';

export class WeaveCloningManager {
private instance: Weave;
private logger: Logger;
private clones: Konva.Node[] = [];

constructor(instance: Weave) {
this.instance = instance;
Expand Down Expand Up @@ -272,4 +276,63 @@ export class WeaveCloningManager {

newGroup.destroy();
}

private recursivelyUpdateKeys(nodes: WeaveStateElement[]) {
for (const child of nodes) {
const newNodeId = uuidv4();
child.key = newNodeId;
child.props.id = newNodeId;
if (child.props.children) {
this.recursivelyUpdateKeys(child.props.children);
}
}
}

cloneNode(targetNode: Konva.Node): Konva.Node | undefined {
const nodeHandler = this.instance.getNodeHandler<WeaveNode>(
targetNode.getAttrs().nodeType
);

if (!nodeHandler) {
return undefined;
}

const parent: Konva.Container = targetNode.getParent() as Konva.Container;

const serializedNode = nodeHandler.serialize(
targetNode as WeaveElementInstance
);

this.recursivelyUpdateKeys(serializedNode.props.children ?? []);

const newNodeId = uuidv4();
serializedNode.key = newNodeId;
serializedNode.props.id = newNodeId;

const realParent = this.instance.getInstanceRecursive(parent);

this.instance.addNode(serializedNode, realParent?.getAttrs().id);

return this.instance.getStage().findOne(`#${newNodeId}`);
}

addClone(node: Konva.Node) {
this.clones.push(node);
}

removeClone(node: Konva.Node) {
this.clones = this.clones.filter((c) => c !== node);
}

getClones() {
return this.clones;
}

isClone(node: Konva.Node) {
return this.clones.find((c) => c === node);
}

cleanupClones() {
this.clones = [];
}
}
Loading