kritzel-stencil 0.0.159 → 0.0.160

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.
Files changed (29) hide show
  1. package/dist/cjs/{default-text-tool.config-BySzvIox.js → default-text-tool.config-D10FksvZ.js} +139 -50
  2. package/dist/cjs/default-text-tool.config-D10FksvZ.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-color_22.cjs.entry.js +1 -1
  5. package/dist/collection/classes/handlers/resize.handler.js +46 -32
  6. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  7. package/dist/collection/classes/objects/selection-group.class.js +91 -16
  8. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  9. package/dist/components/index.js +2 -2
  10. package/dist/components/kritzel-editor.js +1 -1
  11. package/dist/components/kritzel-engine.js +1 -1
  12. package/dist/components/{p-BAplhrRJ.js → p-DTHqEUDc.js} +139 -50
  13. package/dist/components/p-DTHqEUDc.js.map +1 -0
  14. package/dist/esm/{default-text-tool.config-2YFQA3SF.js → default-text-tool.config-DzqpOikl.js} +139 -50
  15. package/dist/esm/default-text-tool.config-DzqpOikl.js.map +1 -0
  16. package/dist/esm/index.js +2 -2
  17. package/dist/esm/kritzel-color_22.entry.js +1 -1
  18. package/dist/stencil/index.esm.js +1 -1
  19. package/dist/stencil/{p-2e85a4af.entry.js → p-5475442e.entry.js} +3 -3
  20. package/dist/stencil/{p-2YFQA3SF.js → p-DzqpOikl.js} +2 -2
  21. package/dist/stencil/p-DzqpOikl.js.map +1 -0
  22. package/dist/stencil/stencil.esm.js +1 -1
  23. package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
  24. package/package.json +1 -1
  25. package/dist/cjs/default-text-tool.config-BySzvIox.js.map +0 -1
  26. package/dist/components/p-BAplhrRJ.js.map +0 -1
  27. package/dist/esm/default-text-tool.config-2YFQA3SF.js.map +0 -1
  28. package/dist/stencil/p-2YFQA3SF.js.map +0 -1
  29. /package/dist/stencil/{p-2e85a4af.entry.js.map → p-5475442e.entry.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var defaultTextTool_config = require('./default-text-tool.config-BySzvIox.js');
3
+ var defaultTextTool_config = require('./default-text-tool.config-D10FksvZ.js');
4
4
 
5
5
  /**
6
6
  * BroadcastChannel sync provider for cross-tab synchronization
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-Cj__YTlG.js');
4
- var defaultTextTool_config = require('./default-text-tool.config-BySzvIox.js');
4
+ var defaultTextTool_config = require('./default-text-tool.config-D10FksvZ.js');
5
5
 
6
6
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
7
 
@@ -74,32 +74,42 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
74
74
  if (!this.hasResized) {
75
75
  return;
76
76
  }
77
+ const rotation = selectionGroup.rotation;
78
+ const sin = Math.sin(rotation);
79
+ const cos = Math.cos(rotation);
80
+ const activeScale = selectionGroup.scale || this._core.store.state.scale;
81
+ // Calculate delta in local unrotated space
82
+ // We rotate the screen delta by -rotation to align with the object's axes
83
+ const localDx = dx * cos + dy * sin;
84
+ const localDy = -dx * sin + dy * cos;
85
+ // Calculate the center of the selection group before resize
86
+ const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;
87
+ const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;
88
+ // The center moves by half of the screen delta (scaled)
89
+ // This is true regardless of rotation because the resize happens symmetrically around the center
90
+ // relative to the fixed point logic
91
+ const newCenterX = initialCenterX + dx / activeScale / 2;
92
+ const newCenterY = initialCenterY + dy / activeScale / 2;
77
93
  switch (this._core.store.state.resizeHandleType) {
78
94
  case KritzelHandleType.TopLeft:
79
- this.newSize.width = this.initialSize.width - dx;
80
- this.newSize.height = this.initialSize.height - dy;
81
- this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
82
- this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
95
+ this.newSize.width = this.initialSize.width - localDx;
96
+ this.newSize.height = this.initialSize.height - localDy;
83
97
  break;
84
98
  case KritzelHandleType.TopRight:
85
- this.newSize.width = this.initialSize.width + dx;
86
- this.newSize.height = this.initialSize.height - dy;
87
- this.newSize.x = this.initialSize.x;
88
- this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
99
+ this.newSize.width = this.initialSize.width + localDx;
100
+ this.newSize.height = this.initialSize.height - localDy;
89
101
  break;
90
102
  case KritzelHandleType.BottomLeft:
91
- this.newSize.width = this.initialSize.width - dx;
92
- this.newSize.height = this.initialSize.height + dy;
93
- this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
94
- this.newSize.y = this.initialSize.y;
103
+ this.newSize.width = this.initialSize.width - localDx;
104
+ this.newSize.height = this.initialSize.height + localDy;
95
105
  break;
96
106
  case KritzelHandleType.BottomRight:
97
- this.newSize.width = this.initialSize.width + dx;
98
- this.newSize.height = this.initialSize.height + dy;
99
- this.newSize.x = this.initialSize.x;
100
- this.newSize.y = this.initialSize.y;
107
+ this.newSize.width = this.initialSize.width + localDx;
108
+ this.newSize.height = this.initialSize.height + localDy;
101
109
  break;
102
110
  }
111
+ this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;
112
+ this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;
103
113
  selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
104
114
  }
105
115
  }
@@ -125,32 +135,36 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
125
135
  if (!this.hasResized) {
126
136
  return;
127
137
  }
138
+ const rotation = selectionGroup.rotation;
139
+ const sin = Math.sin(rotation);
140
+ const cos = Math.cos(rotation);
141
+ const activeScale = selectionGroup.scale || this._core.store.state.scale;
142
+ const localDx = dx * cos + dy * sin;
143
+ const localDy = -dx * sin + dy * cos;
144
+ const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;
145
+ const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;
146
+ const newCenterX = initialCenterX + dx / activeScale / 2;
147
+ const newCenterY = initialCenterY + dy / activeScale / 2;
128
148
  switch (this._core.store.state.resizeHandleType) {
129
149
  case KritzelHandleType.TopLeft:
130
- this.newSize.width = this.initialSize.width - dx;
131
- this.newSize.height = this.initialSize.height - dy;
132
- this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
133
- this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
150
+ this.newSize.width = this.initialSize.width - localDx;
151
+ this.newSize.height = this.initialSize.height - localDy;
134
152
  break;
135
153
  case KritzelHandleType.TopRight:
136
- this.newSize.width = this.initialSize.width + dx;
137
- this.newSize.height = this.initialSize.height - dy;
138
- this.newSize.x = this.initialSize.x;
139
- this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
154
+ this.newSize.width = this.initialSize.width + localDx;
155
+ this.newSize.height = this.initialSize.height - localDy;
140
156
  break;
141
157
  case KritzelHandleType.BottomLeft:
142
- this.newSize.width = this.initialSize.width - dx;
143
- this.newSize.height = this.initialSize.height + dy;
144
- this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
145
- this.newSize.y = this.initialSize.y;
158
+ this.newSize.width = this.initialSize.width - localDx;
159
+ this.newSize.height = this.initialSize.height + localDy;
146
160
  break;
147
161
  case KritzelHandleType.BottomRight:
148
- this.newSize.width = this.initialSize.width + dx;
149
- this.newSize.height = this.initialSize.height + dy;
150
- this.newSize.x = this.initialSize.x;
151
- this.newSize.y = this.initialSize.y;
162
+ this.newSize.width = this.initialSize.width + localDx;
163
+ this.newSize.height = this.initialSize.height + localDy;
152
164
  break;
153
165
  }
166
+ this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;
167
+ this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;
154
168
  selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
155
169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AED,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n hasResized: boolean = false;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialMouseX = 0;\r\n this.initialMouseY = 0;\r\n this.initialSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.newSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.hasResized = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"resize.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/resize.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,oBA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AiB,EAAE,CAAC;oBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAClD,CAAC;gBAED,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n hasResized: boolean = false;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialMouseX = 0;\r\n this.initialMouseY = 0;\r\n this.initialSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.newSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.hasResized = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const activeScale = selectionGroup.scale || this._core.store.state.scale;\r\n\r\n // Calculate delta in local unrotated space\r\n // We rotate the screen delta by -rotation to align with the object's axes\r\n const localDx = dx * cos + dy * sin;\r\n const localDy = -dx * sin + dy * cos;\r\n\r\n // Calculate the center of the selection group before resize\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;\r\n\r\n // The center moves by half of the screen delta (scaled)\r\n // This is true regardless of rotation because the resize happens symmetrically around the center\r\n // relative to the fixed point logic\r\n const newCenterX = initialCenterX + dx / activeScale / 2;\r\n const newCenterY = initialCenterY + dy / activeScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const activeScale = selectionGroup.scale || this._core.store.state.scale;\r\n\r\n const localDx = dx * cos + dy * sin;\r\n const localDy = -dx * sin + dy * cos;\r\n\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;\r\n\r\n const newCenterX = initialCenterX + dx / activeScale / 2;\r\n const newCenterY = initialCenterY + dy / activeScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -5,6 +5,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
5
5
  objectIds = [];
6
6
  // Store snapshots of object state for transformations (rotation, resize)
7
7
  unchangedObjectSnapshots = new Map();
8
+ snapshotRotation = 0;
8
9
  minX;
9
10
  maxX;
10
11
  minY;
@@ -75,6 +76,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
75
76
  */
76
77
  captureUnchangedSnapshots() {
77
78
  this.unchangedObjectSnapshots.clear();
79
+ this.snapshotRotation = this.rotation;
78
80
  this.objects.forEach(obj => {
79
81
  this.unchangedObjectSnapshots.set(obj.id, {
80
82
  id: obj.id,
@@ -134,14 +136,56 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
134
136
  resize(x, y, width, height) {
135
137
  const widthScaleFactor = width / this.width;
136
138
  const heightScaleFactor = height / this.height;
137
- const deltaX = x - this.translateX;
138
- const deltaY = y - this.translateY;
139
+ // Calculate old center
140
+ const oldCenterX = this.translateX + this.totalWidth / 2 / this.scale;
141
+ const oldCenterY = this.translateY + this.totalHeight / 2 / this.scale;
142
+ // Calculate new center
143
+ const newTotalWidth = width + this.padding * 2;
144
+ const newTotalHeight = height + this.padding * 2;
145
+ const newCenterX = x + newTotalWidth / 2 / this.scale;
146
+ const newCenterY = y + newTotalHeight / 2 / this.scale;
147
+ const rotation = this.rotation;
148
+ const cos = Math.cos(-rotation);
149
+ const sin = Math.sin(-rotation);
150
+ const cosR = Math.cos(rotation);
151
+ const sinR = Math.sin(rotation);
139
152
  this._core.store.state.objects.transaction(() => {
140
153
  this.objects.forEach(child => {
141
- const updatedWidth = child.width * widthScaleFactor;
142
- const updatedHeight = child.height * heightScaleFactor;
143
- const updatedX = child.translateX + deltaX + (child.translateX - this.translateX) * (widthScaleFactor - 1);
144
- const updatedY = child.translateY + deltaY + (child.translateY - this.translateY) * (heightScaleFactor - 1);
154
+ // Calculate child center
155
+ const childCenterX = child.translateX + child.totalWidth / 2 / child.scale;
156
+ const childCenterY = child.translateY + child.totalHeight / 2 / child.scale;
157
+ // Vector from old group center to child center
158
+ const dx = childCenterX - oldCenterX;
159
+ const dy = childCenterY - oldCenterY;
160
+ // Rotate to local space (align with group axes)
161
+ const localX = dx * cos - dy * sin;
162
+ const localY = dx * sin + dy * cos;
163
+ // Scale in local space
164
+ const scaledLocalX = localX * widthScaleFactor;
165
+ const scaledLocalY = localY * heightScaleFactor;
166
+ // Rotate back to world space
167
+ const rotatedX = scaledLocalX * cosR - scaledLocalY * sinR;
168
+ const rotatedY = scaledLocalX * sinR + scaledLocalY * cosR;
169
+ // New child center
170
+ const newChildCenterX = newCenterX + rotatedX;
171
+ const newChildCenterY = newCenterY + rotatedY;
172
+ // New child top-left
173
+ // Calculate relative rotation
174
+ const relativeRotation = child.rotation - rotation;
175
+ const cosRel = Math.cos(relativeRotation);
176
+ const sinRel = Math.sin(relativeRotation);
177
+ // Project the group's scale factors onto the child's local axes
178
+ // We use absolute values because scaling is magnitude-based
179
+ // If the child is aligned (0 deg), cos=1, sin=0 -> scales match
180
+ // If the child is 90 deg, cos=0, sin=1 -> scales swap
181
+ const newChildWidthScale = Math.sqrt(Math.pow(widthScaleFactor * cosRel, 2) + Math.pow(heightScaleFactor * sinRel, 2));
182
+ const newChildHeightScale = Math.sqrt(Math.pow(widthScaleFactor * sinRel, 2) + Math.pow(heightScaleFactor * cosRel, 2));
183
+ const updatedWidth = child.width * newChildWidthScale;
184
+ const updatedHeight = child.height * newChildHeightScale;
185
+ const updatedTotalWidth = updatedWidth + child.padding * 2;
186
+ const updatedTotalHeight = updatedHeight + child.padding * 2;
187
+ const updatedX = newChildCenterX - updatedTotalWidth / 2 / child.scale;
188
+ const updatedY = newChildCenterY - updatedTotalHeight / 2 / child.scale;
145
189
  child.resize(updatedX, updatedY, updatedWidth, updatedHeight);
146
190
  });
147
191
  // Refresh dimensions and update the SelectionGroup to propagate changes to other tabs
@@ -154,7 +198,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
154
198
  this.rotation = value;
155
199
  const centerX = this.translateX + this.totalWidth / 2 / this.scale;
156
200
  const centerY = this.translateY + this.totalHeight / 2 / this.scale;
157
- const angle = value;
201
+ const angle = value - this.snapshotRotation;
158
202
  const cos = Math.cos(angle);
159
203
  const sin = Math.sin(angle);
160
204
  this._core.store.state.objects.transaction(() => {
@@ -170,7 +214,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
170
214
  const rotatedY = sin * offsetX + cos * offsetY;
171
215
  child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
172
216
  child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
173
- child.rotate(this.objects.length === 1 ? value : value + unchangedSnapshot.rotation);
217
+ child.rotate(this.objects.length === 1 ? value : unchangedSnapshot.rotation + angle);
174
218
  });
175
219
  });
176
220
  }
@@ -201,14 +245,45 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
201
245
  this.height = (this.maxY - this.minY - this.padding) * this.scale;
202
246
  }
203
247
  else {
204
- this.minX = Math.min(...this.objects.map(obj => obj.minXRotated));
205
- this.maxX = Math.max(...this.objects.map(obj => obj.maxXRotated));
206
- this.minY = Math.min(...this.objects.map(obj => obj.minYRotated));
207
- this.maxY = Math.max(...this.objects.map(obj => obj.maxYRotated));
208
- this.translateX = this.minX - this.padding;
209
- this.translateY = this.minY - this.padding;
210
- this.width = (this.maxX - this.minX - this.padding) * this.scale;
211
- this.height = (this.maxY - this.minY - this.padding) * this.scale;
248
+ const rotation = this.rotation;
249
+ const cos = Math.cos(-rotation);
250
+ const sin = Math.sin(-rotation);
251
+ let minX = Infinity;
252
+ let maxX = -Infinity;
253
+ let minY = Infinity;
254
+ let maxY = -Infinity;
255
+ this.objects.forEach(obj => {
256
+ const polygon = obj.rotatedPolygon;
257
+ const corners = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];
258
+ corners.forEach(corner => {
259
+ // Rotate corner into local space (aligned with group rotation)
260
+ const rx = corner.x * cos - corner.y * sin;
261
+ const ry = corner.x * sin + corner.y * cos;
262
+ if (rx < minX)
263
+ minX = rx;
264
+ if (rx > maxX)
265
+ maxX = rx;
266
+ if (ry < minY)
267
+ minY = ry;
268
+ if (ry > maxY)
269
+ maxY = ry;
270
+ });
271
+ });
272
+ // Dimensions in world units (unrotated)
273
+ const worldWidth = maxX - minX;
274
+ const worldHeight = maxY - minY;
275
+ this.width = (worldWidth - this.padding) * this.scale;
276
+ this.height = (worldHeight - this.padding) * this.scale;
277
+ // Center of the box in rotated space
278
+ const cRx = (minX + maxX) / 2;
279
+ const cRy = (minY + maxY) / 2;
280
+ // Rotate center back to world space
281
+ const cosR = Math.cos(rotation);
282
+ const sinR = Math.sin(rotation);
283
+ const cx = cRx * cosR - cRy * sinR;
284
+ const cy = cRx * sinR + cRy * cosR;
285
+ this.translateX = cx - (this.width / this.scale + 2 * this.padding) / 2;
286
+ this.translateY = cy - (this.height / this.scale + 2 * this.padding) / 2;
212
287
  }
213
288
  this._core.store.state.objects.update(this);
214
289
  }
@@ -1 +1 @@
1
- {"version":3,"file":"selection-group.class.js","sourceRoot":"","sources":["../../../src/classes/objects/selection-group.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAcxD,MAAM,OAAO,qBAAsB,SAAQ,iBAA8B;IAC9D,SAAS,GAAW,uBAAuB,CAAC;IAErD,gDAAgD;IAChD,SAAS,GAAa,EAAE,CAAC;IAEzB,yEAAyE;IACzE,wBAA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I,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YACjE,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEO,8BAA8B,CAAC,QAAiC;QACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QAClF,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACxE,OAAO,UAAU,GAAG,YAAY,CAAC;IACnC,CAAC;IAEO,8BAA8B,CAAC,QAAiC;QACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QACnF,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACzE,OAAO,UAAU,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["import { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseObject } from './base-object.class';\r\n\r\ninterface UnchangedObjectSnapshot {\r\n id: string;\r\n translateX: number;\r\n translateY: number;\r\n rotation: number;\r\n width: number;\r\n height: number;\r\n totalWidth: number;\r\n totalHeight: number;\r\n scale: number;\r\n}\r\n\r\nexport class KritzelSelectionGroup extends KritzelBaseObject<HTMLElement> {\r\n override __class__: string = 'KritzelSelectionGroup';\r\n\r\n // Store only object IDs instead of full objects\r\n objectIds: string[] = [];\r\n \r\n // Store snapshots of object state for transformations (rotation, resize)\r\n unchangedObjectSnapshots: Map<string, UnchangedObjectSnapshot> = new Map();\r\n\r\n minX: number;\r\n maxX: number;\r\n\r\n minY: number;\r\n maxY: number;\r\n\r\n // Getter to retrieve actual objects from the store by their IDs\r\n get objects(): KritzelBaseObject<any>[] {\r\n return this.objectIds\r\n .map(id => {\r\n const found = this._core.store.state.objects.filter(obj => obj.id === id);\r\n return found.length > 0 ? found[0] : null;\r\n })\r\n .filter(obj => obj !== null) as KritzelBaseObject<any>[];\r\n }\r\n\r\n get length(): number {\r\n return this.objectIds.length;\r\n }\r\n\r\n static override create(core: KritzelCore): KritzelSelectionGroup {\r\n const object = new KritzelSelectionGroup();\r\n\r\n object._core = core;\r\n object.id = object.generateId();\r\n object.workspaceId = core.store.state.activeWorkspace.id;\r\n object.scale = core.store.state.scale;\r\n object.zIndex = 99999;\r\n\r\n return object;\r\n }\r\n\r\n addOrRemove(object: KritzelBaseObject<any>) {\r\n const index = this.objectIds.findIndex(id => id === object.id);\r\n if (index === -1) {\r\n this.objectIds.push(object.id);\r\n } else {\r\n this.objectIds.splice(index, 1);\r\n }\r\n\r\n this.captureUnchangedSnapshots();\r\n this.refreshObjectDimensions();\r\n }\r\n\r\n deselectAllChildren() {\r\n this.objects.forEach(obj => (obj.isSelected = false));\r\n }\r\n\r\n updateWorkspaceId(workspaceId: string) {\r\n this.workspaceId = workspaceId;\r\n this.objects.forEach(obj => (obj.workspaceId = workspaceId));\r\n }\r\n\r\n updateZIndices(startZIndex: number) {\r\n this.objects.forEach((obj, i) => {\r\n obj.zIndex = startZIndex + i;\r\n });\r\n }\r\n\r\n updatePosition(x: number, y: number) {\r\n this.objects.forEach(obj => {\r\n const deltaX = obj.translateX - this.translateX;\r\n const deltaY = obj.translateY - this.translateY;\r\n obj.updatePosition(x + deltaX, y + deltaY);\r\n });\r\n\r\n // Update snapshots\r\n this.unchangedObjectSnapshots.forEach(snapshot => {\r\n const deltaX = snapshot.translateX - this.translateX;\r\n const deltaY = snapshot.translateY - this.translateY;\r\n snapshot.translateX = x + deltaX;\r\n snapshot.translateY = x + deltaY;\r\n });\r\n\r\n this.translateX = x;\r\n this.translateY = y;\r\n\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n /**\r\n * Capture snapshots of current object states for undo/redo operations\r\n */\r\n private captureUnchangedSnapshots(): void {\r\n this.unchangedObjectSnapshots.clear();\r\n this.objects.forEach(obj => {\r\n this.unchangedObjectSnapshots.set(obj.id, {\r\n id: obj.id,\r\n translateX: obj.translateX,\r\n translateY: obj.translateY,\r\n rotation: obj.rotation,\r\n width: obj.width,\r\n height: obj.height,\r\n totalWidth: obj.totalWidth,\r\n totalHeight: obj.totalHeight,\r\n scale: obj.scale,\r\n });\r\n });\r\n }\r\n\r\n override serialize() {\r\n const { _core, _elementRef, element, totalWidth, totalHeight, unchangedObjectSnapshots, ...remainingProps } = this as any;\r\n\r\n const clonedProps = structuredClone(remainingProps);\r\n\r\n if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {\r\n clonedProps.element = element.cloneNode(true) as HTMLElement;\r\n }\r\n\r\n // Convert Map to plain object for serialization\r\n clonedProps.unchangedObjectSnapshots = Object.fromEntries(this.unchangedObjectSnapshots);\r\n\r\n return clonedProps;\r\n }\r\n\r\n override deserialize<T>(object: any): T {\r\n // First, deserialize all base properties using parent's deserialize\r\n super.deserialize(object);\r\n\r\n // Restore the Map from serialized object\r\n if (object.unchangedObjectSnapshots) {\r\n this.unchangedObjectSnapshots = new Map(Object.entries(object.unchangedObjectSnapshots));\r\n }\r\n\r\n return this as unknown as T;\r\n }\r\n\r\n override update(): void {\r\n // Only update the selection group itself\r\n // Child objects are already updated during move/resize/rotate operations\r\n // Updating them again here would create redundant y.js updates\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n override move(startX: number, startY: number, endX: number, endY: number): void {\r\n const deltaX = (startX - endX) / this._core.store.state.scale;\r\n const deltaY = (startY - endY) / this._core.store.state.scale;\r\n\r\n this.translateX += deltaX;\r\n this.translateY += deltaY;\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n this._core.store.state.objects.update(this);\r\n\r\n this.objects.forEach(obj => {\r\n obj.move(startX, startY, endX, endY);\r\n });\r\n });\r\n\r\n // Update snapshots\r\n this.unchangedObjectSnapshots.forEach(snapshot => {\r\n snapshot.translateX += deltaX;\r\n snapshot.translateY += deltaY;\r\n });\r\n }\r\n\r\n override resize(x: number, y: number, width: number, height: number): void {\r\n const widthScaleFactor = width / this.width;\r\n const heightScaleFactor = height / this.height;\r\n\r\n const deltaX = x - this.translateX;\r\n const deltaY = y - this.translateY;\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n this.objects.forEach(child => {\r\n const updatedWidth = child.width * widthScaleFactor;\r\n const updatedHeight = child.height * heightScaleFactor;\r\n\r\n const updatedX = child.translateX + deltaX + (child.translateX - this.translateX) * (widthScaleFactor - 1);\r\n const updatedY = child.translateY + deltaY + (child.translateY - this.translateY) * (heightScaleFactor - 1);\r\n\r\n child.resize(updatedX, updatedY, updatedWidth, updatedHeight);\r\n });\r\n\r\n // Refresh dimensions and update the SelectionGroup to propagate changes to other tabs\r\n this.refreshObjectDimensions();\r\n this.captureUnchangedSnapshots();\r\n this._core.store.state.objects.update(this);\r\n });\r\n }\r\n\r\n override rotate(value: number): void {\r\n this.rotation = value;\r\n\r\n const centerX = this.translateX + this.totalWidth / 2 / this.scale;\r\n const centerY = this.translateY + this.totalHeight / 2 / this.scale;\r\n\r\n const angle = value;\r\n const cos = Math.cos(angle);\r\n const sin = Math.sin(angle);\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n // Update the SelectionGroup itself to propagate rotation to other tabs\r\n this._core.store.state.objects.update(this);\r\n\r\n this.objects.forEach(child => {\r\n const unchangedSnapshot = this.unchangedObjectSnapshots.get(child.id);\r\n if (!unchangedSnapshot) return;\r\n\r\n const offsetX = this.getOffsetXToCenterFromSnapshot(unchangedSnapshot);\r\n const offsetY = this.getOffsetYToCenterFromSnapshot(unchangedSnapshot);\r\n\r\n const rotatedX = cos * offsetX - sin * offsetY;\r\n const rotatedY = sin * offsetX + cos * offsetY;\r\n\r\n child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;\r\n child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;\r\n\r\n child.rotate(this.objects.length === 1 ? value : value + unchangedSnapshot.rotation);\r\n });\r\n });\r\n }\r\n\r\n override copy(): KritzelBaseObject<HTMLElement> {\r\n const selectionGroup = KritzelSelectionGroup.create(this._core);\r\n\r\n this.objects\r\n .sort((a, b) => a.zIndex - b.zIndex)\r\n .forEach(obj => {\r\n const copiedObject = obj.copy() as KritzelBaseObject<any>;\r\n selectionGroup.addOrRemove(copiedObject);\r\n });\r\n\r\n selectionGroup.captureUnchangedSnapshots();\r\n\r\n if (this.objects.length === 1) {\r\n selectionGroup.rotation = this.objects[0].rotation;\r\n }\r\n\r\n return selectionGroup;\r\n }\r\n\r\n refreshObjectDimensions() {\r\n if (this.objects.length === 1) {\r\n const obj = this.objects[0];\r\n this.minX = obj.boundingBox.x / this.scale;\r\n this.maxX = obj.boundingBox.x / this.scale + obj.boundingBox.width;\r\n this.minY = obj.boundingBox.y / this.scale;\r\n this.maxY = obj.boundingBox.y / this.scale + obj.boundingBox.height;\r\n\r\n this.translateX = (this.minX - this.padding) * this.scale;\r\n this.translateY = (this.minY - this.padding) * this.scale;\r\n\r\n this.width = (this.maxX - this.minX - this.padding) * this.scale;\r\n this.height = (this.maxY - this.minY - this.padding) * this.scale;\r\n } else {\r\n this.minX = Math.min(...this.objects.map(obj => obj.minXRotated));\r\n this.maxX = Math.max(...this.objects.map(obj => obj.maxXRotated));\r\n\r\n this.minY = Math.min(...this.objects.map(obj => obj.minYRotated));\r\n this.maxY = Math.max(...this.objects.map(obj => obj.maxYRotated));\r\n\r\n this.translateX = this.minX - this.padding;\r\n this.translateY = this.minY - this.padding;\r\n\r\n this.width = (this.maxX - this.minX - this.padding) * this.scale;\r\n this.height = (this.maxY - this.minY - this.padding) * this.scale;\r\n }\r\n\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n private getOffsetXToCenterFromSnapshot(snapshot: UnchangedObjectSnapshot): number {\r\n const objCenterX = snapshot.translateX + snapshot.totalWidth / snapshot.scale / 2;\r\n const groupCenterX = this.translateX + this.totalWidth / this.scale / 2;\r\n return objCenterX - groupCenterX;\r\n }\r\n\r\n private getOffsetYToCenterFromSnapshot(snapshot: UnchangedObjectSnapshot): number {\r\n const objCenterY = snapshot.translateY + snapshot.totalHeight / snapshot.scale / 2;\r\n const groupCenterY = this.translateY + this.totalHeight / this.scale / 2;\r\n return objCenterY - groupCenterY;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"selection-group.class.js","sourceRoot":"","sources":["../../../src/classes/objects/selection-group.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAcxD,MAAM,OAAO,qBAAsB,SAAQ,iBAA8B;IAC9D,SAAS,GAAW,uBAAuB,CAAC;IAErD,gDAAgD;IAChD,SAAS,GAAa,EAAE,CAAC;IAEzB,yEAAyE;IACzE,wBAAwB,GAAyC,IAAI,GAAG,EAAE,CAAC;IAC3E,gBAAgB,GAAW,CAAC,CAAC;IAE7B,IAAI,CAAS;IACb,IAAI,CAAS;IAEb,IAAI,CAAS;IACb,IAAI,CAAS;IAEb,gEAAgE;IAChE,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS;aAClB,GAAG,CAAC,EAAE,CAAC,EAAE;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1E,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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AAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACxE,OAAO,UAAU,GAAG,YAAY,CAAC;IACnC,CAAC;IAEO,8BAA8B,CAAC,QAAiC;QACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QACnF,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACzE,OAAO,UAAU,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["import { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseObject } from './base-object.class';\r\n\r\ninterface UnchangedObjectSnapshot {\r\n id: string;\r\n translateX: number;\r\n translateY: number;\r\n rotation: number;\r\n width: number;\r\n height: number;\r\n totalWidth: number;\r\n totalHeight: number;\r\n scale: number;\r\n}\r\n\r\nexport class KritzelSelectionGroup extends KritzelBaseObject<HTMLElement> {\r\n override __class__: string = 'KritzelSelectionGroup';\r\n\r\n // Store only object IDs instead of full objects\r\n objectIds: string[] = [];\r\n \r\n // Store snapshots of object state for transformations (rotation, resize)\r\n unchangedObjectSnapshots: Map<string, UnchangedObjectSnapshot> = new Map();\r\n snapshotRotation: number = 0;\r\n\r\n minX: number;\r\n maxX: number;\r\n\r\n minY: number;\r\n maxY: number;\r\n\r\n // Getter to retrieve actual objects from the store by their IDs\r\n get objects(): KritzelBaseObject<any>[] {\r\n return this.objectIds\r\n .map(id => {\r\n const found = this._core.store.state.objects.filter(obj => obj.id === id);\r\n return found.length > 0 ? found[0] : null;\r\n })\r\n .filter(obj => obj !== null) as KritzelBaseObject<any>[];\r\n }\r\n\r\n get length(): number {\r\n return this.objectIds.length;\r\n }\r\n\r\n static override create(core: KritzelCore): KritzelSelectionGroup {\r\n const object = new KritzelSelectionGroup();\r\n\r\n object._core = core;\r\n object.id = object.generateId();\r\n object.workspaceId = core.store.state.activeWorkspace.id;\r\n object.scale = core.store.state.scale;\r\n object.zIndex = 99999;\r\n\r\n return object;\r\n }\r\n\r\n addOrRemove(object: KritzelBaseObject<any>) {\r\n const index = this.objectIds.findIndex(id => id === object.id);\r\n if (index === -1) {\r\n this.objectIds.push(object.id);\r\n } else {\r\n this.objectIds.splice(index, 1);\r\n }\r\n\r\n this.captureUnchangedSnapshots();\r\n this.refreshObjectDimensions();\r\n }\r\n\r\n deselectAllChildren() {\r\n this.objects.forEach(obj => (obj.isSelected = false));\r\n }\r\n\r\n updateWorkspaceId(workspaceId: string) {\r\n this.workspaceId = workspaceId;\r\n this.objects.forEach(obj => (obj.workspaceId = workspaceId));\r\n }\r\n\r\n updateZIndices(startZIndex: number) {\r\n this.objects.forEach((obj, i) => {\r\n obj.zIndex = startZIndex + i;\r\n });\r\n }\r\n\r\n updatePosition(x: number, y: number) {\r\n this.objects.forEach(obj => {\r\n const deltaX = obj.translateX - this.translateX;\r\n const deltaY = obj.translateY - this.translateY;\r\n obj.updatePosition(x + deltaX, y + deltaY);\r\n });\r\n\r\n // Update snapshots\r\n this.unchangedObjectSnapshots.forEach(snapshot => {\r\n const deltaX = snapshot.translateX - this.translateX;\r\n const deltaY = snapshot.translateY - this.translateY;\r\n snapshot.translateX = x + deltaX;\r\n snapshot.translateY = x + deltaY;\r\n });\r\n\r\n this.translateX = x;\r\n this.translateY = y;\r\n\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n /**\r\n * Capture snapshots of current object states for undo/redo operations\r\n */\r\n private captureUnchangedSnapshots(): void {\r\n this.unchangedObjectSnapshots.clear();\r\n this.snapshotRotation = this.rotation;\r\n this.objects.forEach(obj => {\r\n this.unchangedObjectSnapshots.set(obj.id, {\r\n id: obj.id,\r\n translateX: obj.translateX,\r\n translateY: obj.translateY,\r\n rotation: obj.rotation,\r\n width: obj.width,\r\n height: obj.height,\r\n totalWidth: obj.totalWidth,\r\n totalHeight: obj.totalHeight,\r\n scale: obj.scale,\r\n });\r\n });\r\n }\r\n\r\n override serialize() {\r\n const { _core, _elementRef, element, totalWidth, totalHeight, unchangedObjectSnapshots, ...remainingProps } = this as any;\r\n\r\n const clonedProps = structuredClone(remainingProps);\r\n\r\n if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {\r\n clonedProps.element = element.cloneNode(true) as HTMLElement;\r\n }\r\n\r\n // Convert Map to plain object for serialization\r\n clonedProps.unchangedObjectSnapshots = Object.fromEntries(this.unchangedObjectSnapshots);\r\n\r\n return clonedProps;\r\n }\r\n\r\n override deserialize<T>(object: any): T {\r\n // First, deserialize all base properties using parent's deserialize\r\n super.deserialize(object);\r\n\r\n // Restore the Map from serialized object\r\n if (object.unchangedObjectSnapshots) {\r\n this.unchangedObjectSnapshots = new Map(Object.entries(object.unchangedObjectSnapshots));\r\n }\r\n\r\n return this as unknown as T;\r\n }\r\n\r\n override update(): void {\r\n // Only update the selection group itself\r\n // Child objects are already updated during move/resize/rotate operations\r\n // Updating them again here would create redundant y.js updates\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n override move(startX: number, startY: number, endX: number, endY: number): void {\r\n const deltaX = (startX - endX) / this._core.store.state.scale;\r\n const deltaY = (startY - endY) / this._core.store.state.scale;\r\n\r\n this.translateX += deltaX;\r\n this.translateY += deltaY;\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n this._core.store.state.objects.update(this);\r\n\r\n this.objects.forEach(obj => {\r\n obj.move(startX, startY, endX, endY);\r\n });\r\n });\r\n\r\n // Update snapshots\r\n this.unchangedObjectSnapshots.forEach(snapshot => {\r\n snapshot.translateX += deltaX;\r\n snapshot.translateY += deltaY;\r\n });\r\n }\r\n\r\n override resize(x: number, y: number, width: number, height: number): void {\r\n const widthScaleFactor = width / this.width;\r\n const heightScaleFactor = height / this.height;\r\n\r\n // Calculate old center\r\n const oldCenterX = this.translateX + this.totalWidth / 2 / this.scale;\r\n const oldCenterY = this.translateY + this.totalHeight / 2 / this.scale;\r\n\r\n // Calculate new center\r\n const newTotalWidth = width + this.padding * 2;\r\n const newTotalHeight = height + this.padding * 2;\r\n const newCenterX = x + newTotalWidth / 2 / this.scale;\r\n const newCenterY = y + newTotalHeight / 2 / this.scale;\r\n\r\n const rotation = this.rotation;\r\n const cos = Math.cos(-rotation);\r\n const sin = Math.sin(-rotation);\r\n const cosR = Math.cos(rotation);\r\n const sinR = Math.sin(rotation);\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n this.objects.forEach(child => {\r\n // Calculate child center\r\n const childCenterX = child.translateX + child.totalWidth / 2 / child.scale;\r\n const childCenterY = child.translateY + child.totalHeight / 2 / child.scale;\r\n\r\n // Vector from old group center to child center\r\n const dx = childCenterX - oldCenterX;\r\n const dy = childCenterY - oldCenterY;\r\n\r\n // Rotate to local space (align with group axes)\r\n const localX = dx * cos - dy * sin;\r\n const localY = dx * sin + dy * cos;\r\n\r\n // Scale in local space\r\n const scaledLocalX = localX * widthScaleFactor;\r\n const scaledLocalY = localY * heightScaleFactor;\r\n\r\n // Rotate back to world space\r\n const rotatedX = scaledLocalX * cosR - scaledLocalY * sinR;\r\n const rotatedY = scaledLocalX * sinR + scaledLocalY * cosR;\r\n\r\n // New child center\r\n const newChildCenterX = newCenterX + rotatedX;\r\n const newChildCenterY = newCenterY + rotatedY;\r\n\r\n // New child top-left\r\n // Calculate relative rotation\r\n const relativeRotation = child.rotation - rotation;\r\n const cosRel = Math.cos(relativeRotation);\r\n const sinRel = Math.sin(relativeRotation);\r\n\r\n // Project the group's scale factors onto the child's local axes\r\n // We use absolute values because scaling is magnitude-based\r\n // If the child is aligned (0 deg), cos=1, sin=0 -> scales match\r\n // If the child is 90 deg, cos=0, sin=1 -> scales swap\r\n const newChildWidthScale = Math.sqrt(\r\n Math.pow(widthScaleFactor * cosRel, 2) + Math.pow(heightScaleFactor * sinRel, 2)\r\n );\r\n const newChildHeightScale = Math.sqrt(\r\n Math.pow(widthScaleFactor * sinRel, 2) + Math.pow(heightScaleFactor * cosRel, 2)\r\n );\r\n\r\n const updatedWidth = child.width * newChildWidthScale;\r\n const updatedHeight = child.height * newChildHeightScale;\r\n const updatedTotalWidth = updatedWidth + child.padding * 2;\r\n const updatedTotalHeight = updatedHeight + child.padding * 2;\r\n\r\n const updatedX = newChildCenterX - updatedTotalWidth / 2 / child.scale;\r\n const updatedY = newChildCenterY - updatedTotalHeight / 2 / child.scale;\r\n\r\n child.resize(updatedX, updatedY, updatedWidth, updatedHeight);\r\n });\r\n\r\n // Refresh dimensions and update the SelectionGroup to propagate changes to other tabs\r\n this.refreshObjectDimensions();\r\n this.captureUnchangedSnapshots();\r\n this._core.store.state.objects.update(this);\r\n });\r\n }\r\n\r\n override rotate(value: number): void {\r\n this.rotation = value;\r\n\r\n const centerX = this.translateX + this.totalWidth / 2 / this.scale;\r\n const centerY = this.translateY + this.totalHeight / 2 / this.scale;\r\n\r\n const angle = value - this.snapshotRotation;\r\n const cos = Math.cos(angle);\r\n const sin = Math.sin(angle);\r\n\r\n this._core.store.state.objects.transaction(() => {\r\n // Update the SelectionGroup itself to propagate rotation to other tabs\r\n this._core.store.state.objects.update(this);\r\n\r\n this.objects.forEach(child => {\r\n const unchangedSnapshot = this.unchangedObjectSnapshots.get(child.id);\r\n if (!unchangedSnapshot) return;\r\n\r\n const offsetX = this.getOffsetXToCenterFromSnapshot(unchangedSnapshot);\r\n const offsetY = this.getOffsetYToCenterFromSnapshot(unchangedSnapshot);\r\n\r\n const rotatedX = cos * offsetX - sin * offsetY;\r\n const rotatedY = sin * offsetX + cos * offsetY;\r\n\r\n child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;\r\n child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;\r\n\r\n child.rotate(this.objects.length === 1 ? value : unchangedSnapshot.rotation + angle);\r\n });\r\n });\r\n }\r\n\r\n override copy(): KritzelBaseObject<HTMLElement> {\r\n const selectionGroup = KritzelSelectionGroup.create(this._core);\r\n\r\n this.objects\r\n .sort((a, b) => a.zIndex - b.zIndex)\r\n .forEach(obj => {\r\n const copiedObject = obj.copy() as KritzelBaseObject<any>;\r\n selectionGroup.addOrRemove(copiedObject);\r\n });\r\n\r\n selectionGroup.captureUnchangedSnapshots();\r\n\r\n if (this.objects.length === 1) {\r\n selectionGroup.rotation = this.objects[0].rotation;\r\n }\r\n\r\n return selectionGroup;\r\n }\r\n\r\n refreshObjectDimensions() {\r\n if (this.objects.length === 1) {\r\n const obj = this.objects[0];\r\n this.minX = obj.boundingBox.x / this.scale;\r\n this.maxX = obj.boundingBox.x / this.scale + obj.boundingBox.width;\r\n this.minY = obj.boundingBox.y / this.scale;\r\n this.maxY = obj.boundingBox.y / this.scale + obj.boundingBox.height;\r\n\r\n this.translateX = (this.minX - this.padding) * this.scale;\r\n this.translateY = (this.minY - this.padding) * this.scale;\r\n\r\n this.width = (this.maxX - this.minX - this.padding) * this.scale;\r\n this.height = (this.maxY - this.minY - this.padding) * this.scale;\r\n } else {\r\n const rotation = this.rotation;\r\n const cos = Math.cos(-rotation);\r\n const sin = Math.sin(-rotation);\r\n\r\n let minX = Infinity;\r\n let maxX = -Infinity;\r\n let minY = Infinity;\r\n let maxY = -Infinity;\r\n\r\n this.objects.forEach(obj => {\r\n const polygon = obj.rotatedPolygon;\r\n const corners = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];\r\n\r\n corners.forEach(corner => {\r\n // Rotate corner into local space (aligned with group rotation)\r\n const rx = corner.x * cos - corner.y * sin;\r\n const ry = corner.x * sin + corner.y * cos;\r\n\r\n if (rx < minX) minX = rx;\r\n if (rx > maxX) maxX = rx;\r\n if (ry < minY) minY = ry;\r\n if (ry > maxY) maxY = ry;\r\n });\r\n });\r\n\r\n // Dimensions in world units (unrotated)\r\n const worldWidth = maxX - minX;\r\n const worldHeight = maxY - minY;\r\n\r\n this.width = (worldWidth - this.padding) * this.scale;\r\n this.height = (worldHeight - this.padding) * this.scale;\r\n\r\n // Center of the box in rotated space\r\n const cRx = (minX + maxX) / 2;\r\n const cRy = (minY + maxY) / 2;\r\n\r\n // Rotate center back to world space\r\n const cosR = Math.cos(rotation);\r\n const sinR = Math.sin(rotation);\r\n\r\n const cx = cRx * cosR - cRy * sinR;\r\n const cy = cRx * sinR + cRy * cosR;\r\n\r\n this.translateX = cx - (this.width / this.scale + 2 * this.padding) / 2;\r\n this.translateY = cy - (this.height / this.scale + 2 * this.padding) / 2;\r\n }\r\n\r\n this._core.store.state.objects.update(this);\r\n }\r\n\r\n private getOffsetXToCenterFromSnapshot(snapshot: UnchangedObjectSnapshot): number {\r\n const objCenterX = snapshot.translateX + snapshot.totalWidth / snapshot.scale / 2;\r\n const groupCenterX = this.translateX + this.totalWidth / this.scale / 2;\r\n return objCenterX - groupCenterX;\r\n }\r\n\r\n private getOffsetYToCenterFromSnapshot(snapshot: UnchangedObjectSnapshot): number {\r\n const objCenterY = snapshot.translateY + snapshot.totalHeight / snapshot.scale / 2;\r\n const groupCenterY = this.translateY + this.totalHeight / this.scale / 2;\r\n return objCenterY - groupCenterY;\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  export { g as getAssetPath, r as render, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-CwkUrTy1.js';
2
2
  export { b as KritzelBrushTool, a as KritzelPath, K as KritzelText, c as KritzelTextTool } from './p-CBYBurdY.js';
3
- import { w as writeVarUint, a as writeVarUint8Array, t as toUint8Array, r as readVarUint, b as readVarUint8Array, e as encodeStateAsUpdate, c as applyUpdate, d as encodeStateVector, f as createEncoder, g as createDecoder, s as setIfUndefined, h as create, i as fromBase64, v as varStorage, j as toBase64, o as onChange, k as createUint8ArrayFromArrayBuffer, l as offChange, m as readVarString, O as Observable, n as floor, p as getUnixTime, q as equalityDeep, u as writeVarString, x as map, y as ObservableV2, z as length, A as isNode, B as min, C as pow, H as HocuspocusProvider, D as HocuspocusProviderWebsocket } from './p-BAplhrRJ.js';
4
- export { I as IndexedDBSyncProvider, J as KritzelAppStateMap, E as KritzelEraserTool, K as KritzelImage, F as KritzelImageTool, G as KritzelSelectionTool } from './p-BAplhrRJ.js';
3
+ import { w as writeVarUint, a as writeVarUint8Array, t as toUint8Array, r as readVarUint, b as readVarUint8Array, e as encodeStateAsUpdate, c as applyUpdate, d as encodeStateVector, f as createEncoder, g as createDecoder, s as setIfUndefined, h as create, i as fromBase64, v as varStorage, j as toBase64, o as onChange, k as createUint8ArrayFromArrayBuffer, l as offChange, m as readVarString, O as Observable, n as floor, p as getUnixTime, q as equalityDeep, u as writeVarString, x as map, y as ObservableV2, z as length, A as isNode, B as min, C as pow, H as HocuspocusProvider, D as HocuspocusProviderWebsocket } from './p-DTHqEUDc.js';
4
+ export { I as IndexedDBSyncProvider, J as KritzelAppStateMap, E as KritzelEraserTool, K as KritzelImage, F as KritzelImageTool, G as KritzelSelectionTool } from './p-DTHqEUDc.js';
5
5
  export { K as KritzelWorkspace } from './p-n789Y3S-.js';
6
6
  export { D as DEFAULT_BRUSH_CONFIG, a as DEFAULT_TEXT_CONFIG, KritzelEditor, defineCustomElement as defineCustomElementKritzelEditor } from './kritzel-editor.js';
7
7
  export { KritzelBrushStyle, defineCustomElement as defineCustomElementKritzelBrushStyle } from './kritzel-brush-style.js';
@@ -1,6 +1,6 @@
1
1
  import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-CwkUrTy1.js';
2
2
  import { K as KritzelIconRegistry, d as defineCustomElement$a } from './p-Bhtn9qay.js';
3
- import { L as ABSOLUTE_SCALE_MAX, M as ABSOLUTE_SCALE_MIN, G as KritzelSelectionTool, E as KritzelEraserTool, F as KritzelImageTool, N as defineCustomElement$e } from './p-BAplhrRJ.js';
3
+ import { L as ABSOLUTE_SCALE_MAX, M as ABSOLUTE_SCALE_MIN, G as KritzelSelectionTool, E as KritzelEraserTool, F as KritzelImageTool, N as defineCustomElement$e } from './p-DTHqEUDc.js';
4
4
  import { b as KritzelBrushTool, c as KritzelTextTool, d as KritzelKeyboardHelper } from './p-CBYBurdY.js';
5
5
  import { K as KritzelWorkspace } from './p-n789Y3S-.js';
6
6
  import { K as KritzelDevicesHelper } from './p-l10It7Nm.js';
@@ -1,4 +1,4 @@
1
- import { P as KritzelEngine$1, N as defineCustomElement$1 } from './p-BAplhrRJ.js';
1
+ import { P as KritzelEngine$1, N as defineCustomElement$1 } from './p-DTHqEUDc.js';
2
2
 
3
3
  const KritzelEngine = KritzelEngine$1;
4
4
  const defineCustomElement = defineCustomElement$1;