kritzel-stencil 0.0.107 → 0.0.109

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 (117) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +858 -820
  2. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/key.handler.js +1 -1
  8. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/move.handler.js +62 -55
  10. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  12. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  14. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  15. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  16. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  17. package/dist/collection/classes/objects/base-object.class.js +3 -0
  18. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  19. package/dist/collection/classes/objects/text.class.js +11 -1
  20. package/dist/collection/classes/objects/text.class.js.map +1 -1
  21. package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
  22. package/dist/collection/classes/registries/tool.registry.js.map +1 -0
  23. package/dist/collection/classes/store.class.js +3 -54
  24. package/dist/collection/classes/store.class.js.map +1 -1
  25. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  26. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  28. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  29. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  30. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  33. package/dist/collection/classes/tools/selection-tool.class.js +94 -74
  34. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  35. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  36. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  37. package/dist/collection/classes/viewport.class.js +76 -69
  38. package/dist/collection/classes/viewport.class.js.map +1 -1
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  40. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -2
  41. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  42. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  43. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +69 -121
  44. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  45. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +1 -1
  46. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
  47. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  48. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  49. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  50. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  51. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  52. package/dist/collection/configs/default-engine-state.js +53 -0
  53. package/dist/collection/configs/default-engine-state.js.map +1 -0
  54. package/dist/collection/helpers/devices.helper.js +6 -0
  55. package/dist/collection/helpers/devices.helper.js.map +1 -0
  56. package/dist/collection/helpers/event.helper.js +43 -20
  57. package/dist/collection/helpers/event.helper.js.map +1 -1
  58. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  59. package/dist/collection/interfaces/object.interface.js.map +1 -1
  60. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  61. package/dist/components/kritzel-context-menu.js +1 -1
  62. package/dist/components/kritzel-controls.js +1 -1
  63. package/dist/components/kritzel-editor.js +6 -6
  64. package/dist/components/kritzel-editor.js.map +1 -1
  65. package/dist/components/kritzel-engine.js +1 -1
  66. package/dist/components/{p-CesjDLvT.js → p-7Ns73-wN.js} +237 -206
  67. package/dist/components/p-7Ns73-wN.js.map +1 -0
  68. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  69. package/dist/components/p-BmAloSfd.js.map +1 -0
  70. package/dist/components/{p-_3gCPfqz.js → p-BmrZipyu.js} +621 -622
  71. package/dist/components/p-BmrZipyu.js.map +1 -0
  72. package/dist/components/p-CZkSABuJ.js.map +1 -1
  73. package/dist/components/{p-DTcfnx4-.js → p-Ch6TgHX3.js} +18 -8
  74. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  75. package/dist/esm/kritzel-brush-style_18.entry.js +858 -820
  76. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/esm/stencil.js +1 -1
  79. package/dist/stencil/p-c976660c.entry.js +2 -0
  80. package/dist/stencil/p-c976660c.entry.js.map +1 -0
  81. package/dist/stencil/stencil.esm.js +1 -1
  82. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  83. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  84. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  85. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  86. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  87. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  88. package/dist/types/classes/objects/text.class.d.ts +1 -0
  89. package/dist/types/classes/{tool.registry.d.ts → registries/tool.registry.d.ts} +2 -2
  90. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  91. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  92. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  93. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  94. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  95. package/dist/types/classes/viewport.class.d.ts +3 -6
  96. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  97. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  98. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  99. package/dist/types/components.d.ts +0 -2
  100. package/dist/types/configs/default-engine-state.d.ts +2 -0
  101. package/dist/types/helpers/devices.helper.d.ts +3 -0
  102. package/dist/types/helpers/event.helper.d.ts +2 -4
  103. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  104. package/dist/types/interfaces/object.interface.d.ts +1 -0
  105. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  106. package/package.json +1 -1
  107. package/dist/collection/classes/icon-registry.class.js.map +0 -1
  108. package/dist/collection/classes/tool.registry.js.map +0 -1
  109. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  110. package/dist/components/p-CesjDLvT.js.map +0 -1
  111. package/dist/components/p-DTcfnx4-.js.map +0 -1
  112. package/dist/components/p-_3gCPfqz.js.map +0 -1
  113. package/dist/stencil/p-e596d004.entry.js +0 -2
  114. package/dist/stencil/p-e596d004.entry.js.map +0 -1
  115. /package/dist/collection/classes/{icon-registry.class.js → registries/icon-registry.class.js} +0 -0
  116. /package/dist/collection/classes/{tool.registry.js → registries/tool.registry.js} +0 -0
  117. /package/dist/types/classes/{icon-registry.class.d.ts → registries/icon-registry.class.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"store.class.js","sourceRoot":"","sources":["../../src/classes/store.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO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;YACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from './objects/base-object.class';\r\nimport { KritzelSelectionGroup } from './objects/selection-group.class';\r\nimport { RemoveSelectionGroupCommand } from './commands/remove-selection-group.command';\r\nimport { KritzelHistory } from './history.class';\r\nimport { KritzelEngineState } from '../interfaces/engine-state.interface';\r\nimport { KritzelOctree } from './structures/octree.structure';\r\nimport { KritzelBoundingBox } from '../interfaces/bounding-box.interface';\r\nimport { KrtizelSelectionBox } from './objects/selection-box.class';\r\nimport { StateChangeListener, StatePropertyKey } from '../types/state.types';\r\nimport { RemoveObjectCommand } from './commands/remove-object.command';\r\nimport { BatchCommand } from './commands/batch.command';\r\nimport { AddObjectCommand } from './commands/add-object.command';\r\nimport { AddSelectionGroupCommand } from './commands/add-selection-group.command';\r\nimport { UpdateObjectCommand } from './commands/update-object.command';\r\nimport { KritzelEngine } from '../components/core/kritzel-engine/kritzel-engine';\r\nimport { KritzelToolRegistry } from './tool.registry';\r\nimport { KritzelContextMenu } from '../components/ui/kritzel-context-menu/kritzel-context-menu';\r\n\r\nconst initialState: KritzelEngineState = {\r\n activeTool: null,\r\n activeText: null,\r\n currentPath: null,\r\n copiedObjects: null,\r\n objectsOctree: null,\r\n selectionBox: null,\r\n selectionGroup: null,\r\n resizeHandleType: null,\r\n hasViewportChanged: false,\r\n isEnabled: true,\r\n isScaling: false,\r\n isPanning: false,\r\n isFocused: false,\r\n isSelecting: false,\r\n isResizing: false,\r\n isResizeHandleSelected: false,\r\n isRotating: false,\r\n isRotationHandleSelected: false,\r\n isDragging: false,\r\n isDrawing: false,\r\n isErasing: false,\r\n isWriting: false,\r\n isCtrlKeyPressed: false,\r\n isContextMenuVisible: false,\r\n contextMenuItems: [],\r\n contextMenuX: 0,\r\n contextMenuY: 0,\r\n skipContextMenu: false,\r\n debugInfo: {\r\n showObjectInfo: false,\r\n showViewportInfo: false,\r\n logCommands: false,\r\n },\r\n host: null,\r\n cursorX: 0,\r\n cursorY: 0,\r\n scale: 1,\r\n scaleMax: 1000,\r\n scaleMin: 0.0001,\r\n scaleStep: 0.05,\r\n startX: 0,\r\n startY: 0,\r\n translateX: 0,\r\n translateY: 0,\r\n viewportWidth: 0,\r\n viewportHeight: 0,\r\n historyBufferSize: 1000,\r\n touchCount: 0,\r\n longTouchTimeout: null,\r\n longTouchDelay: 300,\r\n};\r\nexport class KritzelStore {\r\n private readonly _kritzelEngine: KritzelEngine;\r\n\r\n private readonly _state: KritzelEngineState;\r\n\r\n private readonly _history: KritzelHistory;\r\n\r\n private readonly _listeners: Map<StatePropertyKey, Set<StateChangeListener<any>>> = new Map();\r\n\r\n objects: KritzelBaseObject<any>[] = [];\r\n\r\n get history(): KritzelHistory {\r\n return this._history;\r\n }\r\n\r\n get state(): KritzelEngineState {\r\n return this._state;\r\n }\r\n\r\n get currentZIndex() {\r\n return this._state.objectsOctree.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).length;\r\n }\r\n\r\n get allObjects() {\r\n return this._state.objectsOctree.allObjects();\r\n }\r\n\r\n get selectedObjects() {\r\n return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.selected);\r\n }\r\n\r\n get offsetX() {\r\n return this._state.host.getBoundingClientRect().left;\r\n }\r\n\r\n get offsetY() {\r\n return this._state.host.getBoundingClientRect().top;\r\n }\r\n\r\n constructor(kritzelEngine: KritzelEngine) {\r\n this._state = initialState;\r\n this._kritzelEngine = kritzelEngine;\r\n this._history = new KritzelHistory(this);\r\n this._state.objectsOctree = new KritzelOctree<KritzelBaseObject<any>>({\r\n x: -Infinity,\r\n y: -Infinity,\r\n z: -Infinity,\r\n width: Infinity,\r\n height: Infinity,\r\n depth: Infinity,\r\n });\r\n }\r\n\r\n rerender() {\r\n const viewportBounds: KritzelBoundingBox = {\r\n x: -this._state.translateX / this._state.scale,\r\n y: -this._state.translateY / this._state.scale,\r\n z: this._state.scale,\r\n width: this._state.viewportWidth / this._state.scale,\r\n height: this._state.viewportHeight / this._state.scale,\r\n depth: 100,\r\n };\r\n\r\n this.objects = this._state.objectsOctree.query(viewportBounds);\r\n\r\n if (this._kritzelEngine) {\r\n this._kritzelEngine.forceUpdate++;\r\n }\r\n }\r\n\r\n findObjectById(id: string): KritzelBaseObject<any> | null {\r\n for (const object of this.allObjects) {\r\n if (object.id === id) {\r\n return object;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n deselectAllObjects(): void {\r\n if (this._state.selectionGroup) {\r\n this._history.executeCommand(new RemoveSelectionGroupCommand(this, this));\r\n }\r\n }\r\n\r\n onStateChange<K extends StatePropertyKey>(property: K, listener: StateChangeListener<KritzelEngineState[K]>): void {\r\n if (!this._listeners.has(property)) {\r\n this._listeners.set(property, new Set());\r\n }\r\n this._listeners.get(property).add(listener);\r\n }\r\n\r\n setState<K extends StatePropertyKey>(property: K, value: KritzelEngineState[K]): void {\r\n const oldValue = this._state[property];\r\n\r\n if (oldValue !== value) {\r\n this._state[property] = value;\r\n\r\n if (this._listeners.has(property)) {\r\n this._listeners.get(property).forEach(listener => listener(value, oldValue, String(property)));\r\n }\r\n }\r\n }\r\n\r\n delete() {\r\n if (!this.state.selectionGroup) {\r\n return;\r\n }\r\n\r\n const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new RemoveObjectCommand(this, this.state.selectionGroup, obj));\r\n const removeSelectionGroupCommand = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);\r\n const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];\r\n\r\n this.history.executeCommand(new BatchCommand(this, this.state.selectionGroup, commands));\r\n }\r\n\r\n deleteObject(id: string, isHistoryUpdated: boolean = true) {\r\n const object = this.findObjectById(id);\r\n if (object) {\r\n if (isHistoryUpdated) {\r\n const removeObjectCommand = new RemoveObjectCommand(this, this, object);\r\n this.history.executeCommand(removeObjectCommand);\r\n } else {\r\n this._state.objectsOctree.remove(obj => obj.id === id);\r\n this.rerender();\r\n }\r\n }\r\n }\r\n\r\n copy() {\r\n this.state.copiedObjects = this.state.selectionGroup.copy() as KritzelSelectionGroup;\r\n }\r\n\r\n paste(x?: number, y?: number) {\r\n this.state.copiedObjects.selected = true;\r\n\r\n const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;\r\n const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;\r\n\r\n this.state.copiedObjects.updatePosition(adjustedX, adjustedY);\r\n\r\n const commands = [];\r\n if (this.state.selectionGroup !== null) {\r\n commands.push(new RemoveSelectionGroupCommand(this, this.state.selectionGroup));\r\n }\r\n\r\n const addCopiedObjectsCommands = this.state.copiedObjects.objects.map(obj => new AddObjectCommand(this, this, obj));\r\n const addCopiedObjectsAsSelectionGroupCommand = new AddSelectionGroupCommand(this, this, this.state.copiedObjects);\r\n\r\n commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, commands));\r\n\r\n this.state.isSelecting = false;\r\n this.state.copiedObjects = this.state.selectionGroup.copy() as KritzelSelectionGroup;\r\n this.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n\r\n moveUp() {\r\n const max = this.allObjects.length + 1;\r\n const increaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n if (obj.zIndex === max) {\r\n return;\r\n }\r\n\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));\r\n }\r\n\r\n moveDown() {\r\n const min = 0;\r\n const decreaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n if (obj.zIndex === min) {\r\n return;\r\n }\r\n\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));\r\n }\r\n\r\n moveToTop() {\r\n const max = this.allObjects.length + 1;\r\n const increaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: max });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));\r\n }\r\n\r\n moveToBottom() {\r\n const min = -1;\r\n const decreaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: min });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));\r\n }\r\n\r\n selectObjects(objects: KritzelBaseObject<any>[]) {\r\n if (objects.length === 0) {\r\n return;\r\n }\r\n\r\n const selectionGroup = KritzelSelectionGroup.create(this);\r\n objects.forEach(obj => {\r\n obj.selected = false;\r\n selectionGroup.addOrRemove(obj);\r\n });\r\n\r\n selectionGroup.selected = true;\r\n\r\n this.state.selectionGroup = selectionGroup;\r\n\r\n if (objects.length === 1) {\r\n selectionGroup.rotation = selectionGroup.objects[0].rotation;\r\n }\r\n\r\n this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));\r\n }\r\n\r\n selectAllObjectsInViewport() {\r\n const objectsInViewport = this._state.objectsOctree\r\n .query({\r\n x: -this._state.translateX / this._state.scale,\r\n y: -this._state.translateY / this._state.scale,\r\n z: this._state.scale,\r\n width: this._state.viewportWidth / this._state.scale,\r\n height: this._state.viewportHeight / this._state.scale,\r\n depth: 100,\r\n })\r\n .filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));\r\n\r\n if (objectsInViewport.length > 0) {\r\n const selectionGroup = KritzelSelectionGroup.create(this);\r\n\r\n objectsInViewport.forEach(obj => {\r\n obj.selected = false;\r\n selectionGroup.addOrRemove(obj);\r\n });\r\n\r\n selectionGroup.selected = true;\r\n\r\n this.state.isSelecting = false;\r\n\r\n if (objectsInViewport.length === 1) {\r\n selectionGroup.rotation = selectionGroup.objects[0].rotation;\r\n }\r\n\r\n this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));\r\n this.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n }\r\n\r\n clearSelection() {\r\n const command = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);\r\n this.history.executeCommand(command);\r\n\r\n this.state.selectionGroup = null;\r\n this.state.selectionBox = null;\r\n this.state.isSelecting = false;\r\n this.state.isResizeHandleSelected = false;\r\n this.state.isRotationHandleSelected = false;\r\n }\r\n\r\n resetActiveText() {\r\n if (this.state.activeText && this.state.activeText.value === ' ') {\r\n this.deleteObject(this.state.activeText.id, false);\r\n this.history.undoStack.pop();\r\n }\r\n\r\n this.state.activeText = null;\r\n }\r\n\r\n getObjectFromPointerEvent(event: TouchEvent | MouseEvent, selector = '.object'): KritzelBaseObject<any> | null {\r\n const shadowRoot = this.state.host?.shadowRoot;\r\n if (!shadowRoot) return null;\r\n\r\n let clientX: number;\r\n let clientY: number;\r\n\r\n if ('touches' in event) {\r\n const touch = event.touches[0];\r\n if (!touch) return null;\r\n clientX = touch.clientX;\r\n clientY = touch.clientY;\r\n } else {\r\n clientX = event.clientX;\r\n clientY = event.clientY;\r\n }\r\n\r\n const elementAtPoint = shadowRoot.elementFromPoint(clientX, clientY);\r\n if (!elementAtPoint) return null;\r\n\r\n const selectedObject = elementAtPoint.closest(selector) as HTMLElement | null;\r\n\r\n if (selectedObject) {\r\n return this.allObjects.find(object => selectedObject.id === object.id);\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"store.class.js","sourceRoot":"","sources":["../../src/classes/store.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CA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cAAc,CAAC,OAAO,CAAC,QAAQ,CAAuB,CAAC;QAE9E,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from './objects/base-object.class';\r\nimport { KritzelSelectionGroup } from './objects/selection-group.class';\r\nimport { RemoveSelectionGroupCommand } from './commands/remove-selection-group.command';\r\nimport { KritzelHistory } from './history.class';\r\nimport { KritzelEngineState } from '../interfaces/engine-state.interface';\r\nimport { KritzelOctree } from './structures/octree.structure';\r\nimport { KritzelBoundingBox } from '../interfaces/bounding-box.interface';\r\nimport { KrtizelSelectionBox } from './objects/selection-box.class';\r\nimport { StateChangeListener, StatePropertyKey } from '../types/state.types';\r\nimport { RemoveObjectCommand } from './commands/remove-object.command';\r\nimport { BatchCommand } from './commands/batch.command';\r\nimport { AddObjectCommand } from './commands/add-object.command';\r\nimport { AddSelectionGroupCommand } from './commands/add-selection-group.command';\r\nimport { UpdateObjectCommand } from './commands/update-object.command';\r\nimport { KritzelEngine } from '../components/core/kritzel-engine/kritzel-engine';\r\nimport { KritzelContextMenu } from '../components/ui/kritzel-context-menu/kritzel-context-menu';\r\nimport { KritzelToolRegistry } from './registries/tool.registry';\r\nimport { DEFAULT_ENGINE_STATE } from '../configs/default-engine-state';\r\n\r\nexport class KritzelStore {\r\n private readonly _kritzelEngine: KritzelEngine;\r\n\r\n private readonly _state: KritzelEngineState;\r\n\r\n private readonly _history: KritzelHistory;\r\n\r\n private readonly _listeners: Map<StatePropertyKey, Set<StateChangeListener<any>>> = new Map();\r\n\r\n objects: KritzelBaseObject<any>[] = [];\r\n\r\n get history(): KritzelHistory {\r\n return this._history;\r\n }\r\n\r\n get state(): KritzelEngineState {\r\n return this._state;\r\n }\r\n\r\n get currentZIndex() {\r\n return this._state.objectsOctree.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).length;\r\n }\r\n\r\n get allObjects() {\r\n return this._state.objectsOctree.allObjects();\r\n }\r\n\r\n get selectedObjects() {\r\n return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.selected);\r\n }\r\n\r\n get offsetX() {\r\n return this._state.host.getBoundingClientRect().left;\r\n }\r\n\r\n get offsetY() {\r\n return this._state.host.getBoundingClientRect().top;\r\n }\r\n\r\n constructor(kritzelEngine: KritzelEngine) {\r\n this._state = DEFAULT_ENGINE_STATE;\r\n this._kritzelEngine = kritzelEngine;\r\n this._history = new KritzelHistory(this);\r\n this._state.objectsOctree = new KritzelOctree<KritzelBaseObject<any>>({\r\n x: -Infinity,\r\n y: -Infinity,\r\n z: -Infinity,\r\n width: Infinity,\r\n height: Infinity,\r\n depth: Infinity,\r\n });\r\n }\r\n\r\n rerender() {\r\n const viewportBounds: KritzelBoundingBox = {\r\n x: -this._state.translateX / this._state.scale,\r\n y: -this._state.translateY / this._state.scale,\r\n z: this._state.scale,\r\n width: this._state.viewportWidth / this._state.scale,\r\n height: this._state.viewportHeight / this._state.scale,\r\n depth: 100,\r\n };\r\n\r\n this.objects = this._state.objectsOctree.query(viewportBounds);\r\n\r\n if (this._kritzelEngine) {\r\n this._kritzelEngine.forceUpdate++;\r\n }\r\n }\r\n\r\n findObjectById(id: string): KritzelBaseObject<any> | null {\r\n for (const object of this.allObjects) {\r\n if (object.id === id) {\r\n return object;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n deselectAllObjects(): void {\r\n if (this._state.selectionGroup) {\r\n this._history.executeCommand(new RemoveSelectionGroupCommand(this, this));\r\n }\r\n }\r\n\r\n onStateChange<K extends StatePropertyKey>(property: K, listener: StateChangeListener<KritzelEngineState[K]>): void {\r\n if (!this._listeners.has(property)) {\r\n this._listeners.set(property, new Set());\r\n }\r\n this._listeners.get(property).add(listener);\r\n }\r\n\r\n setState<K extends StatePropertyKey>(property: K, value: KritzelEngineState[K]): void {\r\n const oldValue = this._state[property];\r\n\r\n if (oldValue !== value) {\r\n this._state[property] = value;\r\n\r\n if (this._listeners.has(property)) {\r\n this._listeners.get(property).forEach(listener => listener(value, oldValue, String(property)));\r\n }\r\n }\r\n }\r\n\r\n delete() {\r\n if (!this.state.selectionGroup) {\r\n return;\r\n }\r\n\r\n const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new RemoveObjectCommand(this, this.state.selectionGroup, obj));\r\n const removeSelectionGroupCommand = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);\r\n const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];\r\n\r\n this.history.executeCommand(new BatchCommand(this, this.state.selectionGroup, commands));\r\n }\r\n\r\n deleteObject(id: string, isHistoryUpdated: boolean = true) {\r\n const object = this.findObjectById(id);\r\n if (object) {\r\n if (isHistoryUpdated) {\r\n const removeObjectCommand = new RemoveObjectCommand(this, this, object);\r\n this.history.executeCommand(removeObjectCommand);\r\n } else {\r\n this._state.objectsOctree.remove(obj => obj.id === id);\r\n this.rerender();\r\n }\r\n }\r\n }\r\n\r\n copy() {\r\n this.state.copiedObjects = this.state.selectionGroup.copy() as KritzelSelectionGroup;\r\n }\r\n\r\n paste(x?: number, y?: number) {\r\n this.state.copiedObjects.selected = true;\r\n\r\n const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;\r\n const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;\r\n\r\n this.state.copiedObjects.updatePosition(adjustedX, adjustedY);\r\n\r\n const commands = [];\r\n if (this.state.selectionGroup !== null) {\r\n commands.push(new RemoveSelectionGroupCommand(this, this.state.selectionGroup));\r\n }\r\n\r\n const addCopiedObjectsCommands = this.state.copiedObjects.objects.map(obj => new AddObjectCommand(this, this, obj));\r\n const addCopiedObjectsAsSelectionGroupCommand = new AddSelectionGroupCommand(this, this, this.state.copiedObjects);\r\n\r\n commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, commands));\r\n\r\n this.state.isSelecting = false;\r\n this.state.copiedObjects = this.state.selectionGroup.copy() as KritzelSelectionGroup;\r\n this.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n\r\n moveUp() {\r\n const max = this.allObjects.length + 1;\r\n const increaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n if (obj.zIndex === max) {\r\n return;\r\n }\r\n\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));\r\n }\r\n\r\n moveDown() {\r\n const min = 0;\r\n const decreaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n if (obj.zIndex === min) {\r\n return;\r\n }\r\n\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));\r\n }\r\n\r\n moveToTop() {\r\n const max = this.allObjects.length + 1;\r\n const increaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: max });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));\r\n }\r\n\r\n moveToBottom() {\r\n const min = -1;\r\n const decreaseZIndexCommands = this.state.selectionGroup.objects.map(obj => {\r\n return new UpdateObjectCommand(this, this, obj, { zIndex: min });\r\n });\r\n\r\n this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));\r\n }\r\n\r\n selectObjects(objects: KritzelBaseObject<any>[]) {\r\n if (objects.length === 0) {\r\n return;\r\n }\r\n\r\n const selectionGroup = KritzelSelectionGroup.create(this);\r\n objects.forEach(obj => {\r\n obj.selected = false;\r\n selectionGroup.addOrRemove(obj);\r\n });\r\n\r\n selectionGroup.selected = true;\r\n\r\n this.state.selectionGroup = selectionGroup;\r\n\r\n if (objects.length === 1) {\r\n selectionGroup.rotation = selectionGroup.objects[0].rotation;\r\n }\r\n\r\n this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));\r\n }\r\n\r\n selectAllObjectsInViewport() {\r\n const objectsInViewport = this._state.objectsOctree\r\n .query({\r\n x: -this._state.translateX / this._state.scale,\r\n y: -this._state.translateY / this._state.scale,\r\n z: this._state.scale,\r\n width: this._state.viewportWidth / this._state.scale,\r\n height: this._state.viewportHeight / this._state.scale,\r\n depth: 100,\r\n })\r\n .filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));\r\n\r\n if (objectsInViewport.length > 0) {\r\n const selectionGroup = KritzelSelectionGroup.create(this);\r\n\r\n objectsInViewport.forEach(obj => {\r\n obj.selected = false;\r\n selectionGroup.addOrRemove(obj);\r\n });\r\n\r\n selectionGroup.selected = true;\r\n\r\n this.state.isSelecting = false;\r\n\r\n if (objectsInViewport.length === 1) {\r\n selectionGroup.rotation = selectionGroup.objects[0].rotation;\r\n }\r\n\r\n this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));\r\n this.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n }\r\n\r\n clearSelection() {\r\n const command = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);\r\n this.history.executeCommand(command);\r\n\r\n this.state.selectionGroup = null;\r\n this.state.selectionBox = null;\r\n this.state.isSelecting = false;\r\n this.state.isResizeHandleSelected = false;\r\n this.state.isRotationHandleSelected = false;\r\n }\r\n\r\n resetActiveText() {\r\n if (this.state.activeText && this.state.activeText.value === ' ') {\r\n this.deleteObject(this.state.activeText.id, false);\r\n this.history.undoStack.pop();\r\n }\r\n\r\n this.state.activeText = null;\r\n }\r\n\r\n getObjectFromPointerEvent(event: TouchEvent | MouseEvent, selector = '.object'): KritzelBaseObject<any> | null {\r\n const shadowRoot = this.state.host?.shadowRoot;\r\n if (!shadowRoot) return null;\r\n\r\n let clientX: number;\r\n let clientY: number;\r\n\r\n if ('touches' in event) {\r\n const touch = event.touches[0];\r\n if (!touch) return null;\r\n clientX = touch.clientX;\r\n clientY = touch.clientY;\r\n } else {\r\n clientX = event.clientX;\r\n clientY = event.clientY;\r\n }\r\n\r\n const elementAtPoint = shadowRoot.elementFromPoint(clientX, clientY);\r\n if (!elementAtPoint) return null;\r\n\r\n const selectedObject = elementAtPoint.closest(selector) as HTMLElement | null;\r\n\r\n if (selectedObject) {\r\n return this.allObjects.find(object => selectedObject.id === object.id);\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n"]}
@@ -11,28 +11,13 @@ export class KritzelBaseTool {
11
11
  onDeactivate() {
12
12
  // default implementation
13
13
  }
14
- handleMouseDown(_event) {
14
+ handlePointerDown(_event) {
15
15
  // default implementation
16
16
  }
17
- handleMouseMove(_event) {
17
+ handlePointerMove(_event) {
18
18
  // default implementation
19
19
  }
20
- handleMouseUp(_event) {
21
- // default implementation
22
- }
23
- handleDoubleClick(_event) {
24
- // default implementation
25
- }
26
- handleDoubleTap(_event) {
27
- // default implementation
28
- }
29
- handleTouchStart(_event) {
30
- // default implementation
31
- }
32
- handleTouchMove(_event) {
33
- // default implementation
34
- }
35
- handleTouchEnd(_event) {
20
+ handlePointerUp(_event) {
36
21
  // default implementation
37
22
  }
38
23
  handleWheel(_event) {
@@ -1 +1 @@
1
- {"version":3,"file":"base-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/base-tool.class.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,eAAe;IAO1B,YAAY,KAAmB;QAN/B,cAAS,GAAW,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAE1C,SAAI,GAAW,WAAW,CAAC;QAKzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,gCAAgC;IACpD,CAAC;IAED,UAAU;QACR,yBAAyB;IAC3B,CAAC;IAED,YAAY;QACV,yBAAyB;IAC3B,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,yBAAyB;IAC3B,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,yBAAyB;IAC3B,CAAC;IAED,aAAa,CAAC,MAAkB;QAC9B,yBAAyB;IAC3B,CAAC;IAED,iBAAiB,CAAC,MAAkB;QAClC,yBAAyB;IAC3B,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,yBAAyB;IAC3B,CAAC;IAED,gBAAgB,CAAC,MAAkB;QACjC,yBAAyB;IAC3B,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,yBAAyB;IAC3B,CAAC;IAED,cAAc,CAAC,MAAkB;QAC/B,yBAAyB;IAC3B,CAAC;IAED,WAAW,CAAC,MAAkB;QAC5B,yBAAyB;IAC3B,CAAC;IAED,MAAM,CAAC,MAAW;QAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { KritzelTool } from '../../components';\r\nimport { KritzelSerializable } from '../../interfaces/serializable.interface';\r\nimport { KritzelStore } from '../store.class';\r\n\r\nexport class KritzelBaseTool implements KritzelTool, KritzelSerializable {\r\n __class__: string = this.constructor.name;\r\n\r\n name: string = 'base-tool';\r\n\r\n protected readonly _store: KritzelStore;\r\n\r\n constructor(store: KritzelStore) {\r\n this._store = store;\r\n void this._store; // Avoid unused variable warning\r\n }\r\n\r\n onActivate(): void {\r\n // default implementation\r\n }\r\n\r\n onDeactivate(): void {\r\n // default implementation\r\n }\r\n\r\n handleMouseDown(_event: MouseEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleMouseMove(_event: MouseEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleDoubleClick(_event: MouseEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleDoubleTap(_event: TouchEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleTouchStart(_event: TouchEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleTouchMove(_event: TouchEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleWheel(_event: WheelEvent): void {\r\n // default implementation\r\n }\r\n\r\n revive(object: any): KritzelSerializable {\r\n Object.assign(this, object);\r\n return this;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"base-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/base-tool.class.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,eAAe;IAO1B,YAAY,KAAmB;QAN/B,cAAS,GAAW,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAE1C,SAAI,GAAW,WAAW,CAAC;QAKzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,gCAAgC;IACpD,CAAC;IAED,UAAU;QACR,yBAAyB;IAC3B,CAAC;IAED,YAAY;QACV,yBAAyB;IAC3B,CAAC;IAED,iBAAiB,CAAC,MAAoB;QACpC,yBAAyB;IAC3B,CAAC;IAED,iBAAiB,CAAC,MAAoB;QACpC,yBAAyB;IAC3B,CAAC;IAED,eAAe,CAAC,MAAoB;QAClC,yBAAyB;IAC3B,CAAC;IAED,WAAW,CAAC,MAAkB;QAC5B,yBAAyB;IAC3B,CAAC;IAED,MAAM,CAAC,MAAW;QAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { KritzelTool } from '../../components';\r\nimport { KritzelSerializable } from '../../interfaces/serializable.interface';\r\nimport { KritzelStore } from '../store.class';\r\n\r\nexport class KritzelBaseTool implements KritzelTool, KritzelSerializable {\r\n __class__: string = this.constructor.name;\r\n\r\n name: string = 'base-tool';\r\n\r\n protected readonly _store: KritzelStore;\r\n\r\n constructor(store: KritzelStore) {\r\n this._store = store;\r\n void this._store; // Avoid unused variable warning\r\n }\r\n\r\n onActivate(): void {\r\n // default implementation\r\n }\r\n\r\n onDeactivate(): void {\r\n // default implementation\r\n }\r\n\r\n handlePointerDown(_event: PointerEvent): void {\r\n // default implementation\r\n }\r\n\r\n handlePointerMove(_event: PointerEvent): void {\r\n // default implementation\r\n }\r\n\r\n handlePointerUp(_event: PointerEvent): void {\r\n // default implementation\r\n }\r\n\r\n handleWheel(_event: WheelEvent): void {\r\n // default implementation\r\n }\r\n\r\n revive(object: any): KritzelSerializable {\r\n Object.assign(this, object);\r\n return this;\r\n }\r\n}\r\n"]}
@@ -13,86 +13,94 @@ export class KritzelBrushTool extends KritzelBaseTool {
13
13
  highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
14
14
  };
15
15
  }
16
- handleMouseDown(event) {
17
- if (KritzelEventHelper.isLeftClick(event)) {
18
- this._store.state.isDrawing = true;
19
- const x = event.clientX - this._store.offsetX;
20
- const y = event.clientY - this._store.offsetY;
21
- this._store.state.currentPath = KritzelPath.create(this._store, {
22
- points: [[x, y]],
23
- translateX: -this._store.state.translateX,
24
- translateY: -this._store.state.translateY,
25
- scale: this._store.state.scale,
26
- fill: this.color,
27
- strokeWidth: this.size,
28
- });
16
+ handlePointerDown(event) {
17
+ if (event.pointerType === 'mouse') {
18
+ if (KritzelEventHelper.isLeftClick(event)) {
19
+ this._store.state.isDrawing = true;
20
+ const x = event.clientX - this._store.offsetX;
21
+ const y = event.clientY - this._store.offsetY;
22
+ this._store.state.currentPath = KritzelPath.create(this._store, {
23
+ points: [[x, y]],
24
+ translateX: -this._store.state.translateX,
25
+ translateY: -this._store.state.translateY,
26
+ scale: this._store.state.scale,
27
+ fill: this.color,
28
+ strokeWidth: this.size,
29
+ });
30
+ }
29
31
  }
30
- }
31
- handleMouseMove(event) {
32
- if (this._store.state.isDrawing) {
33
- const x = event.clientX - this._store.offsetX;
34
- const y = event.clientY - this._store.offsetY;
35
- this._store.state.currentPath = KritzelPath.create(this._store, {
36
- points: [...this._store.state.currentPath.points, [x, y]],
37
- translateX: -this._store.state.translateX,
38
- translateY: -this._store.state.translateY,
39
- scale: this._store.state.scale,
40
- fill: this.color,
41
- strokeWidth: this.size,
42
- });
43
- this._store.rerender();
32
+ if (event.pointerType === 'touch') {
33
+ const activePointers = Array.from(this._store.state.pointers.values());
34
+ if (activePointers.length === 1) {
35
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
36
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
37
+ this._store.state.isDrawing = true;
38
+ this._store.state.currentPath = KritzelPath.create(this._store, {
39
+ points: [[x, y]],
40
+ translateX: -this._store.state.translateX,
41
+ translateY: -this._store.state.translateY,
42
+ scale: this._store.state.scale,
43
+ fill: this.color,
44
+ strokeWidth: this.size,
45
+ });
46
+ this._store.rerender();
47
+ }
44
48
  }
45
49
  }
46
- handleMouseUp(_event) {
47
- if (this._store.state.isDrawing) {
48
- this._store.state.isDrawing = false;
49
- if (this._store.state.currentPath) {
50
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
51
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
50
+ handlePointerMove(event) {
51
+ if (event.pointerType === 'mouse') {
52
+ if (this._store.state.isDrawing) {
53
+ const x = event.clientX - this._store.offsetX;
54
+ const y = event.clientY - this._store.offsetY;
55
+ this._store.state.currentPath = KritzelPath.create(this._store, {
56
+ points: [...this._store.state.currentPath.points, [x, y]],
57
+ translateX: -this._store.state.translateX,
58
+ translateY: -this._store.state.translateY,
59
+ scale: this._store.state.scale,
60
+ fill: this.color,
61
+ strokeWidth: this.size,
62
+ });
63
+ this._store.rerender();
52
64
  }
53
- this._store.state.currentPath = undefined;
54
65
  }
55
- }
56
- handleTouchStart(event) {
57
- if (this._store.state.touchCount === 1) {
58
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
59
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
60
- this._store.state.isDrawing = true;
61
- this._store.state.currentPath = KritzelPath.create(this._store, {
62
- points: [[x, y]],
63
- translateX: -this._store.state.translateX,
64
- translateY: -this._store.state.translateY,
65
- scale: this._store.state.scale,
66
- fill: this.color,
67
- strokeWidth: this.size,
68
- });
69
- this._store.rerender();
66
+ if (event.pointerType === 'touch') {
67
+ const activePointers = Array.from(this._store.state.pointers.values());
68
+ if (activePointers.length === 1) {
69
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
70
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
71
+ this._store.state.currentPath = KritzelPath.create(this._store, {
72
+ points: [...this._store.state.currentPath.points, [x, y]],
73
+ translateX: -this._store.state.translateX,
74
+ translateY: -this._store.state.translateY,
75
+ scale: this._store.state.scale,
76
+ fill: this.color,
77
+ strokeWidth: this.size,
78
+ });
79
+ this._store.rerender();
80
+ }
70
81
  }
71
82
  }
72
- handleTouchMove(event) {
73
- if (this._store.state.touchCount === 1) {
74
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
75
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
76
- this._store.state.currentPath = KritzelPath.create(this._store, {
77
- points: [...this._store.state.currentPath.points, [x, y]],
78
- translateX: -this._store.state.translateX,
79
- translateY: -this._store.state.translateY,
80
- scale: this._store.state.scale,
81
- fill: this.color,
82
- strokeWidth: this.size,
83
- });
84
- this._store.rerender();
83
+ handlePointerUp(event) {
84
+ if (event.pointerType === 'mouse') {
85
+ if (this._store.state.isDrawing) {
86
+ this._store.state.isDrawing = false;
87
+ if (this._store.state.currentPath) {
88
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
89
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
90
+ }
91
+ this._store.state.currentPath = undefined;
92
+ }
85
93
  }
86
- }
87
- handleTouchEnd(_event) {
88
- if (this._store.state.isDrawing) {
89
- this._store.state.isDrawing = false;
90
- if (this._store.state.currentPath) {
91
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
92
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
94
+ if (event.pointerType === 'touch') {
95
+ if (this._store.state.isDrawing) {
96
+ this._store.state.isDrawing = false;
97
+ if (this._store.state.currentPath) {
98
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
99
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
100
+ }
101
+ this._store.state.currentPath = undefined;
102
+ this._store.rerender();
93
103
  }
94
- this._store.state.currentPath = undefined;
95
- this._store.rerender();
96
104
  }
97
105
  }
98
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"brush-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/brush-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IAcnD,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAdf,SAAI,GAA0B,KAAK,CAAC;QAEpC,UAAK,GAAW,SAAS,CAAC;QAE1B,SAAI,GAAW,CAAC,CAAC;QAEjB,aAAQ,GAEJ;YACF,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;YAC1K,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;SAC/C,CAAC;IAIF,CAAC;IAED,eAAe,CAAC,KAAiB;QAC/B,IAAI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AddObjectCommand } from '../commands/add-object.command';\r\nimport { KritzelPath } from '../objects/path.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\n\r\nexport class KritzelBrushTool extends KritzelBaseTool {\r\n type: 'pen' | 'highlighter' = 'pen';\r\n\r\n color: string = '#000000';\r\n\r\n size: number = 6;\r\n\r\n palettes: {\r\n [brushType: string]: string[];\r\n } = {\r\n pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],\r\n highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],\r\n };\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent) {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isDrawing = true;\r\n const x = event.clientX - this._store.offsetX;\r\n const y = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [[x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n }\r\n }\r\n\r\n handleMouseMove(event: MouseEvent): void {\r\n if (this._store.state.isDrawing) {\r\n const x = event.clientX - this._store.offsetX;\r\n const y = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [...this._store.state.currentPath.points, [x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n if (this._store.state.isDrawing) {\r\n this._store.state.isDrawing = false;\r\n\r\n if (this._store.state.currentPath) {\r\n this._store.state.currentPath.zIndex = this._store.currentZIndex;\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));\r\n }\r\n\r\n this._store.state.currentPath = undefined;\r\n }\r\n }\r\n\r\n handleTouchStart(event: TouchEvent): void {\r\n if (this._store.state.touchCount === 1) {\r\n const x = Math.round(event.touches[0].clientX - this._store.offsetX);\r\n const y = Math.round(event.touches[0].clientY - this._store.offsetY);\r\n\r\n this._store.state.isDrawing = true;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [[x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleTouchMove(event: TouchEvent): void {\r\n if (this._store.state.touchCount === 1) {\r\n const x = Math.round(event.touches[0].clientX - this._store.offsetX);\r\n const y = Math.round(event.touches[0].clientY - this._store.offsetY);\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [...this._store.state.currentPath.points, [x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n if (this._store.state.isDrawing) {\r\n this._store.state.isDrawing = false;\r\n\r\n if (this._store.state.currentPath) {\r\n this._store.state.currentPath.zIndex = this._store.currentZIndex;\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));\r\n }\r\n\r\n this._store.state.currentPath = undefined;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"brush-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/brush-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAg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AC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;oBACjE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC7G,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;gBAEpC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;oBACjE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC7G,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC;gBAE1C,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { AddObjectCommand } from '../commands/add-object.command';\r\nimport { KritzelPath } from '../objects/path.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\n\r\nexport class KritzelBrushTool extends KritzelBaseTool {\r\n type: 'pen' | 'highlighter' = 'pen';\r\n\r\n color: string = '#000000';\r\n\r\n size: number = 6;\r\n\r\n palettes: {\r\n [brushType: string]: string[];\r\n } = {\r\n pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],\r\n highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],\r\n };\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isDrawing = true;\r\n const x = event.clientX - this._store.offsetX;\r\n const y = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [[x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n\r\n if (activePointers.length === 1) {\r\n const x = Math.round(activePointers[0].clientX - this._store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._store.offsetY);\r\n\r\n this._store.state.isDrawing = true;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [[x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isDrawing) {\r\n const x = event.clientX - this._store.offsetX;\r\n const y = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [...this._store.state.currentPath.points, [x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n\r\n if (activePointers.length === 1) {\r\n const x = Math.round(activePointers[0].clientX - this._store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._store.offsetY);\r\n\r\n this._store.state.currentPath = KritzelPath.create(this._store, {\r\n points: [...this._store.state.currentPath.points, [x, y]],\r\n translateX: -this._store.state.translateX,\r\n translateY: -this._store.state.translateY,\r\n scale: this._store.state.scale,\r\n fill: this.color,\r\n strokeWidth: this.size,\r\n });\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isDrawing) {\r\n this._store.state.isDrawing = false;\r\n\r\n if (this._store.state.currentPath) {\r\n this._store.state.currentPath.zIndex = this._store.currentZIndex;\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));\r\n }\r\n\r\n this._store.state.currentPath = undefined;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isDrawing) {\r\n this._store.state.isDrawing = false;\r\n\r\n if (this._store.state.currentPath) {\r\n this._store.state.currentPath.zIndex = this._store.currentZIndex;\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));\r\n }\r\n\r\n this._store.state.currentPath = undefined;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -7,71 +7,76 @@ export class KritzelEraserTool extends KritzelBaseTool {
7
7
  super(store);
8
8
  this.touchStartTimeout = null;
9
9
  }
10
- handleMouseDown(event) {
11
- if (KritzelEventHelper.isLeftClick(event)) {
12
- this._store.state.isErasing = true;
10
+ handlePointerDown(event) {
11
+ if (event.pointerType === 'mouse') {
12
+ if (KritzelEventHelper.isLeftClick(event)) {
13
+ this._store.state.isErasing = true;
14
+ }
13
15
  }
14
- }
15
- handleMouseMove(event) {
16
- var _a;
17
- if (this._store.state.isErasing) {
18
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
19
- if (!shadowRoot)
20
- return;
21
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
22
- if (!selectedObject)
23
- return;
24
- selectedObject.markedForRemoval = true;
25
- this._store.rerender();
16
+ if (event.pointerType === 'touch') {
17
+ this.touchStartTimeout = setTimeout(() => {
18
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
19
+ this._store.state.isErasing = true;
20
+ }
21
+ }, 80);
26
22
  }
27
23
  }
28
- handleMouseUp(_event) {
29
- if (this._store.state.isErasing) {
30
- const removeCommands = this._store.allObjects
31
- .filter(object => object.markedForRemoval)
32
- .map(object => {
33
- object.markedForRemoval = false;
34
- return new RemoveObjectCommand(this._store, this, object);
35
- });
36
- if (removeCommands.length > 0) {
37
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
24
+ handlePointerMove(event) {
25
+ var _a, _b;
26
+ if (event.pointerType === 'mouse') {
27
+ if (this._store.state.isErasing) {
28
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
29
+ if (!shadowRoot)
30
+ return;
31
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
32
+ if (!selectedObject)
33
+ return;
34
+ selectedObject.markedForRemoval = true;
35
+ this._store.rerender();
38
36
  }
39
- this._store.state.isErasing = false;
40
37
  }
41
- }
42
- handleTouchStart(_event) {
43
- this.touchStartTimeout = setTimeout(() => {
44
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling) {
45
- this._store.state.isErasing = true;
38
+ if (event.pointerType === 'touch') {
39
+ if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
40
+ const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
41
+ if (!shadowRoot)
42
+ return;
43
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
44
+ if (!selectedObject)
45
+ return;
46
+ selectedObject.markedForRemoval = true;
47
+ this._store.rerender();
46
48
  }
47
- }, 80);
48
- }
49
- handleTouchMove(event) {
50
- var _a;
51
- if (this._store.state.touchCount === 1 && this._store.state.isErasing) {
52
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
53
- if (!shadowRoot)
54
- return;
55
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
56
- if (!selectedObject)
57
- return;
58
- selectedObject.markedForRemoval = true;
59
- this._store.rerender();
60
49
  }
61
50
  }
62
- handleTouchEnd(_event) {
63
- clearTimeout(this.touchStartTimeout);
64
- if (this._store.state.isErasing) {
65
- const removeCommands = this._store.allObjects
66
- .filter(object => object.markedForRemoval)
67
- .map(object => {
68
- object.markedForRemoval = false;
69
- return new RemoveObjectCommand(this._store, this, object);
70
- });
71
- if (removeCommands.length > 0) {
72
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
51
+ handlePointerUp(event) {
52
+ if (event.pointerType === 'mouse') {
53
+ if (this._store.state.isErasing) {
54
+ const removeCommands = this._store.allObjects
55
+ .filter(object => object.markedForRemoval)
56
+ .map(object => {
57
+ object.markedForRemoval = false;
58
+ return new RemoveObjectCommand(this._store, this, object);
59
+ });
60
+ if (removeCommands.length > 0) {
61
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
62
+ }
63
+ this._store.state.isErasing = false;
64
+ }
65
+ }
66
+ if (event.pointerType === 'touch') {
67
+ clearTimeout(this.touchStartTimeout);
68
+ if (this._store.state.isErasing) {
69
+ const removeCommands = this._store.allObjects
70
+ .filter(object => object.markedForRemoval)
71
+ .map(object => {
72
+ object.markedForRemoval = false;
73
+ return new RemoveObjectCommand(this._store, this, object);
74
+ });
75
+ if (removeCommands.length > 0) {
76
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
77
+ }
78
+ this._store.state.isErasing = false;
73
79
  }
74
- this._store.state.isErasing = false;
75
80
  }
76
81
  }
77
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eraser-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/eraser-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IAGpD,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAHf,sBAAiB,GAAQ,IAAI,CAAC;IAI9B,CAAC;IAED,eAAe,CAAC,KAAiB;QAC/B,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;QACrC,CAAC;IACH,CAAC;IAED,eAAe,CAAC,KAAiB;;QAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,0CAAE,UAAU,CAAC;YACtD,IAAI,CAAC,UAAU;gBAAE,OAAO;YAExB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC/E,IAAI,CAAC,cAAc;gBAAE,OAAO;YAE5B,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAEvC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,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AAM,UAAU,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,0CAAE,UAAU,CAAC;YACtD,IAAI,CAAC,UAAU;gBAAE,OAAO;YAExB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC/E,IAAI,CAAC,cAAc;gBAAE,OAAO;YAE5B,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAEvC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAkB;QAC/B,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAErC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU;iBAC1C,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;iBACzC,GAAG,CAAC,MAAM,CAAC,EAAE;gBACZ,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAC;gBAChC,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;YAEL,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;YAC1F,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QACtC,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { RemoveObjectCommand } from '../commands/remove-object.command';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\n\r\nexport class KritzelEraserTool extends KritzelBaseTool {\r\n touchStartTimeout: any = null;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isErasing = true;\r\n }\r\n }\r\n\r\n handleMouseMove(event: MouseEvent): void {\r\n if (this._store.state.isErasing) {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');\r\n if (!selectedObject) return;\r\n\r\n selectedObject.markedForRemoval = true;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n if (this._store.state.isErasing) {\r\n const removeCommands = this._store.allObjects\r\n .filter(object => object.markedForRemoval)\r\n .map(object => {\r\n object.markedForRemoval = false;\r\n return new RemoveObjectCommand(this._store, this, object);\r\n });\r\n\r\n if (removeCommands.length > 0) {\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));\r\n }\r\n\r\n this._store.state.isErasing = false;\r\n }\r\n }\r\n\r\n handleTouchStart(_event: TouchEvent): void {\r\n this.touchStartTimeout = setTimeout(() => {\r\n if (this._store.state.touchCount === 1 && !this._store.state.isScaling) {\r\n this._store.state.isErasing = true;\r\n }\r\n }, 80);\r\n }\r\n\r\n handleTouchMove(event: TouchEvent): void {\r\n if (this._store.state.touchCount === 1 && this._store.state.isErasing) {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');\r\n if (!selectedObject) return;\r\n\r\n selectedObject.markedForRemoval = true;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n clearTimeout(this.touchStartTimeout);\r\n\r\n if (this._store.state.isErasing) {\r\n const removeCommands = this._store.allObjects\r\n .filter(object => object.markedForRemoval)\r\n .map(object => {\r\n object.markedForRemoval = false;\r\n return new RemoveObjectCommand(this._store, this, object);\r\n });\r\n\r\n if (removeCommands.length > 0) {\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));\r\n }\r\n\r\n this._store.state.isErasing = false;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"eraser-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/eraser-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IAGpD,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAHf,sBAAiB,GAAQ,IAAI,CAAC;IAI9B,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;YACrC,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,GAAG,EAAE;gBACvC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;oBAC1E,IAAI,CAAC,MAAM,CAAC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5D,CAAC,CAAC,CAAC;gBAEL,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;gBAC1F,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { RemoveObjectCommand } from '../commands/remove-object.command';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\n\r\nexport class KritzelEraserTool extends KritzelBaseTool {\r\n touchStartTimeout: any = null;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isErasing = true;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n this.touchStartTimeout = setTimeout(() => {\r\n if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {\r\n this._store.state.isErasing = true;\r\n }\r\n }, 80);\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isErasing) {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');\r\n if (!selectedObject) return;\r\n\r\n selectedObject.markedForRemoval = true;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');\r\n if (!selectedObject) return;\r\n\r\n selectedObject.markedForRemoval = true;\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isErasing) {\r\n const removeCommands = this._store.allObjects\r\n .filter(object => object.markedForRemoval)\r\n .map(object => {\r\n object.markedForRemoval = false;\r\n return new RemoveObjectCommand(this._store, this, object);\r\n });\r\n\r\n if (removeCommands.length > 0) {\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));\r\n }\r\n\r\n this._store.state.isErasing = false;\r\n }\r\n }\r\n\r\n if( event.pointerType === 'touch') {\r\n clearTimeout(this.touchStartTimeout);\r\n\r\n if (this._store.state.isErasing) {\r\n const removeCommands = this._store.allObjects\r\n .filter(object => object.markedForRemoval)\r\n .map(object => {\r\n object.markedForRemoval = false;\r\n return new RemoveObjectCommand(this._store, this, object);\r\n });\r\n\r\n if (removeCommands.length > 0) {\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));\r\n }\r\n\r\n this._store.state.isErasing = false;\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -5,7 +5,7 @@ import { AddObjectCommand } from "../commands/add-object.command";
5
5
  import { BatchCommand } from "../commands/batch.command";
6
6
  import { AddSelectionGroupCommand } from "../commands/add-selection-group.command";
7
7
  import imageCompression from "browser-image-compression";
8
- import { KritzelToolRegistry } from "../tool.registry";
8
+ import { KritzelToolRegistry } from "../registries/tool.registry";
9
9
  export class KritzelImageTool extends KritzelBaseTool {
10
10
  constructor(store) {
11
11
  super(store);
@@ -1 +1 @@
1
- {"version":3,"file":"image-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/image-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,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AM,GAAG,MAAM,CAAC;QACtB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QACzC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,KAAmB;QACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjE,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE/B,MAAM,eAAe,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACvE,MAAM,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAEjG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC;QAErH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;CACF","sourcesContent":["import { KritzelSelectionGroup } from '../objects/selection-group.class';\r\nimport { KritzelImage } from '../objects/image.class';\r\nimport { KritzelStore } from '../store.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { AddObjectCommand } from '../commands/add-object.command';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { AddSelectionGroupCommand } from '../commands/add-selection-group.command';\r\nimport imageCompression from 'browser-image-compression';\r\nimport { KritzelToolRegistry } from '../tool.registry';\r\n\r\nexport class KritzelImageTool extends KritzelBaseTool {\r\n fileInput: HTMLInputElement | null = null;\r\n\r\n maxWidth: number = 300;\r\n maxHeight: number = 300;\r\n\r\n maxCompressionSize: number = 300;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n this.setupFileInput();\r\n }\r\n\r\n override onActivate(): void {\r\n this.openFilePicker();\r\n }\r\n\r\n private openFilePicker(): void {\r\n this.fileInput.click();\r\n }\r\n\r\n private setupFileInput(): void {\r\n this.fileInput = document.createElement('input');\r\n this.fileInput.type = 'file';\r\n this.fileInput.accept = 'image/*';\r\n this.fileInput.style.display = 'none';\r\n\r\n this.fileInput.addEventListener('change', this.handleFileSelect.bind(this));\r\n this.fileInput.addEventListener('cancel', this.handleCancel.bind(this));\r\n document.body.appendChild(this.fileInput);\r\n }\r\n\r\n private handleFileSelect(event: Event): void {\r\n const input = event.target as HTMLInputElement;\r\n if (input.files && input.files[0]) {\r\n const file = input.files[0];\r\n imageCompression(file, {\r\n maxWidthOrHeight: this.maxCompressionSize,\r\n })\r\n .then(compressedFile => {\r\n this.readFile(compressedFile);\r\n })\r\n .catch(error => {\r\n console.error('Error during image compression or processing:', error);\r\n this.handleCancel();\r\n });\r\n } else {\r\n console.info('File selection cancelled by user.');\r\n this.handleCancel();\r\n }\r\n\r\n if (input) {\r\n input.value = '';\r\n }\r\n }\r\n\r\n private readFile(file: File): void {\r\n const reader = new FileReader();\r\n reader.onload = e => {\r\n const img = new Image();\r\n img.src = e.target?.result as string;\r\n img.onload = () => this.processImage(img);\r\n };\r\n reader.readAsDataURL(file);\r\n }\r\n\r\n private processImage(img: HTMLImageElement): void {\r\n const { scaledWidth, scaledHeight } = this.calculateScaledDimensions(img);\r\n const image = this.createKritzelImage(img, scaledWidth, scaledHeight);\r\n this.addImageToStore(image);\r\n }\r\n\r\n private calculateScaledDimensions(img: HTMLImageElement): { scaledWidth: number; scaledHeight: number } {\r\n let scaledWidth = img.width;\r\n let scaledHeight = img.height;\r\n\r\n if (img.width > this.maxWidth || img.height > this.maxHeight) {\r\n const widthRatio = this.maxWidth / img.width;\r\n const heightRatio = this.maxHeight / img.height;\r\n const scaleRatio = Math.min(widthRatio, heightRatio);\r\n\r\n scaledWidth = img.width * scaleRatio;\r\n scaledHeight = img.height * scaleRatio;\r\n }\r\n\r\n return { scaledWidth, scaledHeight };\r\n }\r\n\r\n private createKritzelImage(img: HTMLImageElement, width: number, height: number): KritzelImage {\r\n const image = KritzelImage.create(this._store);\r\n image.src = img.src;\r\n image.width = width;\r\n image.height = height;\r\n image.zIndex = this._store.currentZIndex;\r\n image.centerInViewport();\r\n return image;\r\n }\r\n\r\n private addImageToStore(image: KritzelImage): void {\r\n const selectionGroup = KritzelSelectionGroup.create(this._store);\r\n selectionGroup.addOrRemove(image);\r\n selectionGroup.selected = true;\r\n\r\n const addImageCommand = new AddObjectCommand(this._store, this, image);\r\n const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);\r\n\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));\r\n\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n\r\n private handleCancel(): void {\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"image-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/image-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC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M,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjE,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE/B,MAAM,eAAe,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACvE,MAAM,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAEjG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC;QAErH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;CACF","sourcesContent":["import { KritzelSelectionGroup } from '../objects/selection-group.class';\r\nimport { KritzelImage } from '../objects/image.class';\r\nimport { KritzelStore } from '../store.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { AddObjectCommand } from '../commands/add-object.command';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { AddSelectionGroupCommand } from '../commands/add-selection-group.command';\r\nimport imageCompression from 'browser-image-compression';\r\nimport { KritzelToolRegistry } from '../registries/tool.registry';\r\n\r\nexport class KritzelImageTool extends KritzelBaseTool {\r\n fileInput: HTMLInputElement | null = null;\r\n\r\n maxWidth: number = 300;\r\n maxHeight: number = 300;\r\n\r\n maxCompressionSize: number = 300;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n this.setupFileInput();\r\n }\r\n\r\n override onActivate(): void {\r\n this.openFilePicker();\r\n }\r\n\r\n private openFilePicker(): void {\r\n this.fileInput.click();\r\n }\r\n\r\n private setupFileInput(): void {\r\n this.fileInput = document.createElement('input');\r\n this.fileInput.type = 'file';\r\n this.fileInput.accept = 'image/*';\r\n this.fileInput.style.display = 'none';\r\n\r\n this.fileInput.addEventListener('change', this.handleFileSelect.bind(this));\r\n this.fileInput.addEventListener('cancel', this.handleCancel.bind(this));\r\n document.body.appendChild(this.fileInput);\r\n }\r\n\r\n private handleFileSelect(event: Event): void {\r\n const input = event.target as HTMLInputElement;\r\n if (input.files && input.files[0]) {\r\n const file = input.files[0];\r\n imageCompression(file, {\r\n maxWidthOrHeight: this.maxCompressionSize,\r\n })\r\n .then(compressedFile => {\r\n this.readFile(compressedFile);\r\n })\r\n .catch(error => {\r\n console.error('Error during image compression or processing:', error);\r\n this.handleCancel();\r\n });\r\n } else {\r\n console.info('File selection cancelled by user.');\r\n this.handleCancel();\r\n }\r\n\r\n if (input) {\r\n input.value = '';\r\n }\r\n }\r\n\r\n private readFile(file: File): void {\r\n const reader = new FileReader();\r\n reader.onload = e => {\r\n const img = new Image();\r\n img.src = e.target?.result as string;\r\n img.onload = () => this.processImage(img);\r\n };\r\n reader.readAsDataURL(file);\r\n }\r\n\r\n private processImage(img: HTMLImageElement): void {\r\n const { scaledWidth, scaledHeight } = this.calculateScaledDimensions(img);\r\n const image = this.createKritzelImage(img, scaledWidth, scaledHeight);\r\n this.addImageToStore(image);\r\n }\r\n\r\n private calculateScaledDimensions(img: HTMLImageElement): { scaledWidth: number; scaledHeight: number } {\r\n let scaledWidth = img.width;\r\n let scaledHeight = img.height;\r\n\r\n if (img.width > this.maxWidth || img.height > this.maxHeight) {\r\n const widthRatio = this.maxWidth / img.width;\r\n const heightRatio = this.maxHeight / img.height;\r\n const scaleRatio = Math.min(widthRatio, heightRatio);\r\n\r\n scaledWidth = img.width * scaleRatio;\r\n scaledHeight = img.height * scaleRatio;\r\n }\r\n\r\n return { scaledWidth, scaledHeight };\r\n }\r\n\r\n private createKritzelImage(img: HTMLImageElement, width: number, height: number): KritzelImage {\r\n const image = KritzelImage.create(this._store);\r\n image.src = img.src;\r\n image.width = width;\r\n image.height = height;\r\n image.zIndex = this._store.currentZIndex;\r\n image.centerInViewport();\r\n return image;\r\n }\r\n\r\n private addImageToStore(image: KritzelImage): void {\r\n const selectionGroup = KritzelSelectionGroup.create(this._store);\r\n selectionGroup.addOrRemove(image);\r\n selectionGroup.selected = true;\r\n\r\n const addImageCommand = new AddObjectCommand(this._store, this, image);\r\n const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);\r\n\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));\r\n\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n\r\n private handleCancel(): void {\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n }\r\n}\r\n"]}