@kritzel/engine 0.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +50 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/engine.constants-CakmdKMW.js +28206 -0
- package/dist/cjs/index-BbbWU2aN.js +1742 -0
- package/dist/cjs/index.cjs.js +4232 -0
- package/dist/cjs/kritzel-awareness-cursors_5.cjs.entry.js +28004 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/stencil.cjs.js +25 -0
- package/dist/collection/classes/core/core.class.js +1389 -0
- package/dist/collection/classes/core/reviver.class.js +124 -0
- package/dist/collection/classes/core/store.class.js +337 -0
- package/dist/collection/classes/core/viewport.class.js +794 -0
- package/dist/collection/classes/core/workspace.class.js +112 -0
- package/dist/collection/classes/handlers/base.handler.js +20 -0
- package/dist/collection/classes/handlers/context-menu.handler.js +170 -0
- package/dist/collection/classes/handlers/hover.handler.js +35 -0
- package/dist/collection/classes/handlers/key.handler.js +162 -0
- package/dist/collection/classes/handlers/line-handle.handler.js +475 -0
- package/dist/collection/classes/handlers/move.handler.js +295 -0
- package/dist/collection/classes/handlers/resize.handler.js +327 -0
- package/dist/collection/classes/handlers/rotation.handler.js +174 -0
- package/dist/collection/classes/handlers/selection.handler.js +526 -0
- package/dist/collection/classes/managers/anchor.manager.js +1476 -0
- package/dist/collection/classes/managers/browser-permission.manager.js +64 -0
- package/dist/collection/classes/managers/clipboard.manager.js +346 -0
- package/dist/collection/classes/managers/clipboard.types.js +1 -0
- package/dist/collection/classes/managers/cursor.manager.js +139 -0
- package/dist/collection/classes/managers/license.manager.js +341 -0
- package/dist/collection/classes/managers/localization.manager.js +227 -0
- package/dist/collection/classes/managers/theme.manager.js +206 -0
- package/dist/collection/classes/objects/base-object.class.js +462 -0
- package/dist/collection/classes/objects/dynamic-object.class.js +437 -0
- package/dist/collection/classes/objects/group.class.js +590 -0
- package/dist/collection/classes/objects/image.class.js +500 -0
- package/dist/collection/classes/objects/line.class.js +789 -0
- package/dist/collection/classes/objects/path.class.js +578 -0
- package/dist/collection/classes/objects/selection-box.class.js +32 -0
- package/dist/collection/classes/objects/selection-group.class.js +752 -0
- package/dist/collection/classes/objects/shape.class.js +628 -0
- package/dist/collection/classes/objects/text.class.js +461 -0
- package/dist/collection/classes/providers/assets/asset-resolver.class.js +536 -0
- package/dist/collection/classes/providers/assets/http-asset-provider.class.js +111 -0
- package/dist/collection/classes/providers/assets/indexeddb-asset-provider.class.js +241 -0
- package/dist/collection/classes/providers/assets/presigned-asset-provider.class.js +86 -0
- package/dist/collection/classes/providers/paste-intent/event-paste-intent.provider.js +48 -0
- package/dist/collection/classes/providers/paste-intent/ios-paste-intent.provider.js +16 -0
- package/dist/collection/classes/providers/paste-intent/navigator-paste-intent.provider.js +86 -0
- package/dist/collection/classes/providers/sync/broadcast-sync-provider.class.js +100 -0
- package/dist/collection/classes/providers/sync/hocuspocus-sync-provider.class.js +333 -0
- package/dist/collection/classes/providers/sync/in-memory-sync-provider.class.js +69 -0
- package/dist/collection/classes/providers/sync/indexeddb-sync-provider.class.js +39 -0
- package/dist/collection/classes/providers/sync/websocket-sync-provider.class.js +110 -0
- package/dist/collection/classes/registries/dynamic-object-renderer.registry.js +52 -0
- package/dist/collection/classes/registries/font-registry.class.js +161 -0
- package/dist/collection/classes/registries/icon-registry.class.js +118 -0
- package/dist/collection/classes/registries/paste-intent-provider.registry.js +26 -0
- package/dist/collection/classes/registries/tool.registry.js +69 -0
- package/dist/collection/classes/structures/app-state-map.structure.js +461 -0
- package/dist/collection/classes/structures/object-map.structure.js +1103 -0
- package/dist/collection/classes/structures/quadtree.structure.js +251 -0
- package/dist/collection/classes/tools/base-tool.class.js +88 -0
- package/dist/collection/classes/tools/brush-tool.class.js +236 -0
- package/dist/collection/classes/tools/eraser-tool.class.js +133 -0
- package/dist/collection/classes/tools/image-tool.class.js +152 -0
- package/dist/collection/classes/tools/line-tool.class.js +249 -0
- package/dist/collection/classes/tools/selection-tool.class.js +611 -0
- package/dist/collection/classes/tools/shape-tool.class.js +251 -0
- package/dist/collection/classes/tools/text-tool.class.js +179 -0
- package/dist/collection/collection-manifest.json +17 -0
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.css +115 -0
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.js +380 -0
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -0
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.js +153 -0
- package/dist/collection/components/kritzel-engine/kritzel-engine.css +81 -0
- package/dist/collection/components/kritzel-engine/kritzel-engine.js +6345 -0
- package/dist/collection/components/kritzel-icon/kritzel-icon.css +18 -0
- package/dist/collection/components/kritzel-icon/kritzel-icon.js +93 -0
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.css +29 -0
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.js +83 -0
- package/dist/collection/configs/default-asset-storage.config.js +9 -0
- package/dist/collection/configs/default-brush-tool.config.js +9 -0
- package/dist/collection/configs/default-engine-config.js +73 -0
- package/dist/collection/configs/default-line-tool.config.js +12 -0
- package/dist/collection/configs/default-shape-tool.config.js +15 -0
- package/dist/collection/configs/default-sync.config.js +6 -0
- package/dist/collection/configs/default-text-tool.config.js +12 -0
- package/dist/collection/constants/color-palette.constants.js +40 -0
- package/dist/collection/constants/core.constants.js +1 -0
- package/dist/collection/constants/engine.constants.js +4 -0
- package/dist/collection/constants/license.constants.js +25 -0
- package/dist/collection/constants/schema.constants.js +4 -0
- package/dist/collection/constants/storage.constants.js +1 -0
- package/dist/collection/constants/stroke-size.constants.js +2 -0
- package/dist/collection/constants/text-tool-fonts.constants.js +18 -0
- package/dist/collection/constants/version.js +6 -0
- package/dist/collection/enums/alignment.enum.js +9 -0
- package/dist/collection/enums/event-button.enum.js +6 -0
- package/dist/collection/enums/handle-type.enum.js +7 -0
- package/dist/collection/enums/shape-type.enum.js +6 -0
- package/dist/collection/events/active-workspace-change.event.js +1 -0
- package/dist/collection/events/editor-is-ready.event.js +1 -0
- package/dist/collection/events/login.event.js +1 -0
- package/dist/collection/helpers/alignment.helper.js +73 -0
- package/dist/collection/helpers/class.helper.js +5 -0
- package/dist/collection/helpers/color.helper.js +106 -0
- package/dist/collection/helpers/cursor.helper.js +57 -0
- package/dist/collection/helpers/devices.helper.js +28 -0
- package/dist/collection/helpers/event.helper.js +58 -0
- package/dist/collection/helpers/geometry.helper.js +149 -0
- package/dist/collection/helpers/html.helper.js +116 -0
- package/dist/collection/helpers/image-file.helper.js +6 -0
- package/dist/collection/helpers/keyboard.helper.js +55 -0
- package/dist/collection/helpers/localization.helper.js +25 -0
- package/dist/collection/helpers/math.helper.js +8 -0
- package/dist/collection/helpers/migration.helper.js +45 -0
- package/dist/collection/helpers/object.helper.js +29 -0
- package/dist/collection/helpers/svg-export.helper.js +655 -0
- package/dist/collection/helpers/theme.helper.js +77 -0
- package/dist/collection/helpers/tool-config.helper.js +63 -0
- package/dist/collection/helpers/wheel.helper.js +113 -0
- package/dist/collection/index.js +107 -0
- package/dist/collection/interfaces/anchor.interface.js +1 -0
- package/dist/collection/interfaces/arrow-head.interface.js +1 -0
- package/dist/collection/interfaces/asset-provider.interface.js +1 -0
- package/dist/collection/interfaces/asset-storage-config.interface.js +1 -0
- package/dist/collection/interfaces/asset.interface.js +1 -0
- package/dist/collection/interfaces/bounding-box.interface.js +1 -0
- package/dist/collection/interfaces/clonable.interface.js +1 -0
- package/dist/collection/interfaces/context-menu-item.interface.js +1 -0
- package/dist/collection/interfaces/context-menu-state.interface.js +1 -0
- package/dist/collection/interfaces/debug-info.interface.js +1 -0
- package/dist/collection/interfaces/dialog.interface.js +1 -0
- package/dist/collection/interfaces/document-metadata.interface.js +1 -0
- package/dist/collection/interfaces/dynamic-object-renderer.interface.js +1 -0
- package/dist/collection/interfaces/engine-state.interface.js +1 -0
- package/dist/collection/interfaces/font.interface.js +1 -0
- package/dist/collection/interfaces/localization.interface.js +1 -0
- package/dist/collection/interfaces/login-config.interface.js +1 -0
- package/dist/collection/interfaces/master-detail.interface.js +1 -0
- package/dist/collection/interfaces/menu-item.interface.js +1 -0
- package/dist/collection/interfaces/migration.interface.js +1 -0
- package/dist/collection/interfaces/notification.interface.js +1 -0
- package/dist/collection/interfaces/object-change-event.interface.js +1 -0
- package/dist/collection/interfaces/object-export.interface.js +1 -0
- package/dist/collection/interfaces/object.interface.js +1 -0
- package/dist/collection/interfaces/paste-intent-provider.interface.js +1 -0
- package/dist/collection/interfaces/point.interface.js +1 -0
- package/dist/collection/interfaces/polygon.interface.js +1 -0
- package/dist/collection/interfaces/remote-cursor.interface.js +1 -0
- package/dist/collection/interfaces/selection-state.interface.js +1 -0
- package/dist/collection/interfaces/serializable.interface.js +1 -0
- package/dist/collection/interfaces/settings.interface.js +1 -0
- package/dist/collection/interfaces/share.interface.js +1 -0
- package/dist/collection/interfaces/shortcut.interface.js +1 -0
- package/dist/collection/interfaces/sync-config.interface.js +21 -0
- package/dist/collection/interfaces/sync-provider.interface.js +1 -0
- package/dist/collection/interfaces/theme.interface.js +1 -0
- package/dist/collection/interfaces/tool-config.interface.js +1 -0
- package/dist/collection/interfaces/tool-type.interface.js +1 -0
- package/dist/collection/interfaces/tool.interface.js +1 -0
- package/dist/collection/interfaces/toolbar-item.interface.js +1 -0
- package/dist/collection/interfaces/undo-state.interface.js +1 -0
- package/dist/collection/interfaces/user.interface.js +1 -0
- package/dist/collection/interfaces/viewport-state.interface.js +1 -0
- package/dist/collection/locales/de-locale.js +119 -0
- package/dist/collection/locales/en-locale.js +120 -0
- package/dist/collection/locales/fr-locale.js +119 -0
- package/dist/collection/migrations/app-state.migrations.js +47 -0
- package/dist/collection/migrations/workspace.migrations.js +67 -0
- package/dist/collection/themes/dark-theme.js +340 -0
- package/dist/collection/themes/light-theme.js +346 -0
- package/dist/collection/types/deep-readonly.type.js +1 -0
- package/dist/collection/types/state.types.js +1 -0
- package/dist/components/index.d.ts +47 -0
- package/dist/components/index.js +4143 -0
- package/dist/components/kritzel-awareness-cursors.d.ts +11 -0
- package/dist/components/kritzel-awareness-cursors.js +6 -0
- package/dist/components/kritzel-cursor-trail.d.ts +11 -0
- package/dist/components/kritzel-cursor-trail.js +6 -0
- package/dist/components/kritzel-engine.d.ts +11 -0
- package/dist/components/kritzel-engine.js +52641 -0
- package/dist/components/kritzel-icon.d.ts +11 -0
- package/dist/components/kritzel-icon.js +6 -0
- package/dist/components/kritzel-watermark.d.ts +11 -0
- package/dist/components/kritzel-watermark.js +6 -0
- package/dist/components/p-B2Htv9ou.js +49 -0
- package/dist/components/p-BvRGQvVI.js +3456 -0
- package/dist/components/p-CfSx6HU_.js +1469 -0
- package/dist/components/p-YP8wAcF4.js +122 -0
- package/dist/components/p-fx6msYHJ.js +167 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/engine.constants-Bl5-pbq-.js +28143 -0
- package/dist/esm/index-BU9Mv7y0.js +1715 -0
- package/dist/esm/index.js +4134 -0
- package/dist/esm/kritzel-awareness-cursors_5.entry.js +27978 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/stencil.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil/index.esm.js +4134 -0
- package/dist/stencil/p-BU9Mv7y0.js +1702 -0
- package/dist/stencil/p-Bl5-pbq-.js +28143 -0
- package/dist/stencil/p-DQuL1Twl.js +3 -0
- package/dist/stencil/p-f0a8b7af.entry.js +27978 -0
- package/dist/stencil/stencil.esm.js +21 -0
- package/dist/types/classes/core/core.class.d.ts +532 -0
- package/dist/types/classes/core/reviver.class.d.ts +32 -0
- package/dist/types/classes/core/store.class.d.ts +198 -0
- package/dist/types/classes/core/viewport.class.d.ts +256 -0
- package/dist/types/classes/core/workspace.class.d.ts +95 -0
- package/dist/types/classes/handlers/base.handler.d.ts +18 -0
- package/dist/types/classes/handlers/context-menu.handler.d.ts +67 -0
- package/dist/types/classes/handlers/hover.handler.d.ts +23 -0
- package/dist/types/classes/handlers/key.handler.d.ts +44 -0
- package/dist/types/classes/handlers/line-handle.handler.d.ts +115 -0
- package/dist/types/classes/handlers/move.handler.d.ts +94 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +95 -0
- package/dist/types/classes/handlers/rotation.handler.d.ts +50 -0
- package/dist/types/classes/handlers/selection.handler.d.ts +153 -0
- package/dist/types/classes/managers/anchor.manager.d.ts +513 -0
- package/dist/types/classes/managers/browser-permission.manager.d.ts +41 -0
- package/dist/types/classes/managers/clipboard.manager.d.ts +71 -0
- package/dist/types/classes/managers/clipboard.types.d.ts +23 -0
- package/dist/types/classes/managers/cursor.manager.d.ts +66 -0
- package/dist/types/classes/managers/license.manager.d.ts +147 -0
- package/dist/types/classes/managers/localization.manager.d.ts +145 -0
- package/dist/types/classes/managers/theme.manager.d.ts +112 -0
- package/dist/types/classes/objects/base-object.class.d.ts +266 -0
- package/dist/types/classes/objects/dynamic-object.class.d.ts +148 -0
- package/dist/types/classes/objects/group.class.d.ts +231 -0
- package/dist/types/classes/objects/image.class.d.ts +246 -0
- package/dist/types/classes/objects/line.class.d.ts +285 -0
- package/dist/types/classes/objects/path.class.d.ts +220 -0
- package/dist/types/classes/objects/selection-box.class.d.ts +19 -0
- package/dist/types/classes/objects/selection-group.class.d.ts +267 -0
- package/dist/types/classes/objects/shape.class.d.ts +322 -0
- package/dist/types/classes/objects/text.class.d.ts +197 -0
- package/dist/types/classes/providers/assets/asset-resolver.class.d.ts +141 -0
- package/dist/types/classes/providers/assets/http-asset-provider.class.d.ts +79 -0
- package/dist/types/classes/providers/assets/indexeddb-asset-provider.class.d.ts +69 -0
- package/dist/types/classes/providers/assets/presigned-asset-provider.class.d.ts +69 -0
- package/dist/types/classes/providers/paste-intent/event-paste-intent.provider.d.ts +8 -0
- package/dist/types/classes/providers/paste-intent/ios-paste-intent.provider.d.ts +6 -0
- package/dist/types/classes/providers/paste-intent/navigator-paste-intent.provider.d.ts +9 -0
- package/dist/types/classes/providers/sync/broadcast-sync-provider.class.d.ts +23 -0
- package/dist/types/classes/providers/sync/hocuspocus-sync-provider.class.d.ts +163 -0
- package/dist/types/classes/providers/sync/in-memory-sync-provider.class.d.ts +39 -0
- package/dist/types/classes/providers/sync/indexeddb-sync-provider.class.d.ts +25 -0
- package/dist/types/classes/providers/sync/websocket-sync-provider.class.d.ts +63 -0
- package/dist/types/classes/registries/dynamic-object-renderer.registry.d.ts +32 -0
- package/dist/types/classes/registries/font-registry.class.d.ts +19 -0
- package/dist/types/classes/registries/icon-registry.class.d.ts +39 -0
- package/dist/types/classes/registries/paste-intent-provider.registry.d.ts +10 -0
- package/dist/types/classes/registries/tool.registry.d.ts +53 -0
- package/dist/types/classes/structures/app-state-map.structure.d.ts +171 -0
- package/dist/types/classes/structures/object-map.structure.d.ts +403 -0
- package/dist/types/classes/structures/quadtree.structure.d.ts +128 -0
- package/dist/types/classes/tools/base-tool.class.d.ts +72 -0
- package/dist/types/classes/tools/brush-tool.class.d.ts +68 -0
- package/dist/types/classes/tools/eraser-tool.class.d.ts +38 -0
- package/dist/types/classes/tools/image-tool.class.d.ts +74 -0
- package/dist/types/classes/tools/line-tool.class.d.ts +63 -0
- package/dist/types/classes/tools/selection-tool.class.d.ts +188 -0
- package/dist/types/classes/tools/shape-tool.class.d.ts +90 -0
- package/dist/types/classes/tools/text-tool.class.d.ts +66 -0
- package/dist/types/components/kritzel-awareness-cursors/kritzel-awareness-cursors.d.ts +29 -0
- package/dist/types/components/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +19 -0
- package/dist/types/components/kritzel-engine/kritzel-engine.d.ts +695 -0
- package/dist/types/components/kritzel-icon/kritzel-icon.d.ts +6 -0
- package/dist/types/components/kritzel-watermark/kritzel-watermark.d.ts +20 -0
- package/dist/types/components.d.ts +981 -0
- package/dist/types/configs/default-asset-storage.config.d.ts +8 -0
- package/dist/types/configs/default-brush-tool.config.d.ts +2 -0
- package/dist/types/configs/default-engine-config.d.ts +2 -0
- package/dist/types/configs/default-line-tool.config.d.ts +2 -0
- package/dist/types/configs/default-shape-tool.config.d.ts +2 -0
- package/dist/types/configs/default-sync.config.d.ts +5 -0
- package/dist/types/configs/default-text-tool.config.d.ts +2 -0
- package/dist/types/constants/color-palette.constants.d.ts +31 -0
- package/dist/types/constants/core.constants.d.ts +0 -0
- package/dist/types/constants/engine.constants.d.ts +4 -0
- package/dist/types/constants/license.constants.d.ts +25 -0
- package/dist/types/constants/schema.constants.d.ts +4 -0
- package/dist/types/constants/storage.constants.d.ts +1 -0
- package/dist/types/constants/stroke-size.constants.d.ts +2 -0
- package/dist/types/constants/text-tool-fonts.constants.d.ts +3 -0
- package/dist/types/constants/version.d.ts +6 -0
- package/dist/types/enums/alignment.enum.d.ts +8 -0
- package/dist/types/enums/event-button.enum.d.ts +5 -0
- package/dist/types/enums/handle-type.enum.d.ts +6 -0
- package/dist/types/enums/shape-type.enum.d.ts +5 -0
- package/dist/types/events/active-workspace-change.event.d.ts +7 -0
- package/dist/types/events/editor-is-ready.event.d.ts +18 -0
- package/dist/types/events/login.event.d.ts +3 -0
- package/dist/types/helpers/alignment.helper.d.ts +21 -0
- package/dist/types/helpers/class.helper.d.ts +3 -0
- package/dist/types/helpers/color.helper.d.ts +34 -0
- package/dist/types/helpers/cursor.helper.d.ts +22 -0
- package/dist/types/helpers/devices.helper.d.ts +8 -0
- package/dist/types/helpers/event.helper.d.ts +6 -0
- package/dist/types/helpers/geometry.helper.d.ts +38 -0
- package/dist/types/helpers/html.helper.d.ts +8 -0
- package/dist/types/helpers/image-file.helper.d.ts +3 -0
- package/dist/types/helpers/keyboard.helper.d.ts +6 -0
- package/dist/types/helpers/localization.helper.d.ts +18 -0
- package/dist/types/helpers/math.helper.d.ts +4 -0
- package/dist/types/helpers/migration.helper.d.ts +30 -0
- package/dist/types/helpers/object.helper.d.ts +9 -0
- package/dist/types/helpers/svg-export.helper.d.ts +231 -0
- package/dist/types/helpers/theme.helper.d.ts +42 -0
- package/dist/types/helpers/tool-config.helper.d.ts +4 -0
- package/dist/types/helpers/wheel.helper.d.ts +9 -0
- package/dist/types/index.d.ts +109 -0
- package/dist/types/interfaces/anchor.interface.d.ts +147 -0
- package/dist/types/interfaces/arrow-head.interface.d.ts +27 -0
- package/dist/types/interfaces/asset-provider.interface.d.ts +88 -0
- package/dist/types/interfaces/asset-storage-config.interface.d.ts +40 -0
- package/dist/types/interfaces/asset.interface.d.ts +43 -0
- package/dist/types/interfaces/bounding-box.interface.d.ts +8 -0
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/dist/types/interfaces/context-menu-item.interface.d.ts +25 -0
- package/dist/types/interfaces/context-menu-state.interface.d.ts +16 -0
- package/dist/types/interfaces/debug-info.interface.d.ts +7 -0
- package/dist/types/interfaces/dialog.interface.d.ts +4 -0
- package/dist/types/interfaces/document-metadata.interface.d.ts +6 -0
- package/dist/types/interfaces/dynamic-object-renderer.interface.d.ts +40 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +82 -0
- package/dist/types/interfaces/font.interface.d.ts +15 -0
- package/dist/types/interfaces/localization.interface.d.ts +143 -0
- package/dist/types/interfaces/login-config.interface.d.ts +24 -0
- package/dist/types/interfaces/master-detail.interface.d.ts +14 -0
- package/dist/types/interfaces/menu-item.interface.d.ts +27 -0
- package/dist/types/interfaces/migration.interface.d.ts +16 -0
- package/dist/types/interfaces/notification.interface.d.ts +10 -0
- package/dist/types/interfaces/object-change-event.interface.d.ts +31 -0
- package/dist/types/interfaces/object-export.interface.d.ts +20 -0
- package/dist/types/interfaces/object.interface.d.ts +53 -0
- package/dist/types/interfaces/paste-intent-provider.interface.d.ts +10 -0
- package/dist/types/interfaces/point.interface.d.ts +4 -0
- package/dist/types/interfaces/polygon.interface.d.ts +7 -0
- package/dist/types/interfaces/remote-cursor.interface.d.ts +18 -0
- package/dist/types/interfaces/selection-state.interface.d.ts +7 -0
- package/dist/types/interfaces/serializable.interface.d.ts +5 -0
- package/dist/types/interfaces/settings.interface.d.ts +25 -0
- package/dist/types/interfaces/share.interface.d.ts +9 -0
- package/dist/types/interfaces/shortcut.interface.d.ts +10 -0
- package/dist/types/interfaces/sync-config.interface.d.ts +41 -0
- package/dist/types/interfaces/sync-provider.interface.d.ts +66 -0
- package/dist/types/interfaces/theme.interface.d.ts +553 -0
- package/dist/types/interfaces/tool-config.interface.d.ts +24 -0
- package/dist/types/interfaces/tool-type.interface.d.ts +1 -0
- package/dist/types/interfaces/tool.interface.d.ts +8 -0
- package/dist/types/interfaces/toolbar-item.interface.d.ts +66 -0
- package/dist/types/interfaces/undo-state.interface.d.ts +6 -0
- package/dist/types/interfaces/user.interface.d.ts +22 -0
- package/dist/types/interfaces/viewport-state.interface.d.ts +7 -0
- package/dist/types/locales/de-locale.d.ts +5 -0
- package/dist/types/locales/en-locale.d.ts +6 -0
- package/dist/types/locales/fr-locale.d.ts +5 -0
- package/dist/types/migrations/app-state.migrations.d.ts +11 -0
- package/dist/types/migrations/workspace.migrations.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1873 -0
- package/dist/types/themes/dark-theme.d.ts +5 -0
- package/dist/types/themes/light-theme.d.ts +5 -0
- package/dist/types/types/deep-readonly.type.d.ts +7 -0
- package/dist/types/types/state.types.d.ts +3 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +101 -0
- package/readme.md +11 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
3
|
+
import { KritzelLine } from "../objects/line.class";
|
|
4
|
+
/** Threshold in screen pixels for disconnecting anchored lines during drag */
|
|
5
|
+
const ANCHOR_DISCONNECT_THRESHOLD = 30;
|
|
6
|
+
/**
|
|
7
|
+
* Handler class responsible for managing move/drag operations on selected objects.
|
|
8
|
+
* Handles pointer events for mouse, touch, and pen inputs to enable dragging
|
|
9
|
+
* of selected objects on the canvas. Also manages anchor disconnection when
|
|
10
|
+
* lines are dragged beyond a threshold distance.
|
|
11
|
+
*/
|
|
12
|
+
export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
13
|
+
/** X coordinate where the drag started (updates during drag for incremental movement) */
|
|
14
|
+
dragStartX = 0;
|
|
15
|
+
/** Y coordinate where the drag started (updates during drag for incremental movement) */
|
|
16
|
+
dragStartY = 0;
|
|
17
|
+
/** Initial X coordinate when starting interaction (remains constant during drag) */
|
|
18
|
+
startX = 0;
|
|
19
|
+
/** Initial Y coordinate when starting interaction (remains constant during drag) */
|
|
20
|
+
startY = 0;
|
|
21
|
+
/** Current X coordinate during move operation */
|
|
22
|
+
endX = 0;
|
|
23
|
+
/** Current Y coordinate during move operation */
|
|
24
|
+
endY = 0;
|
|
25
|
+
/** Initial position when drag started (for calculating total accumulated distance) */
|
|
26
|
+
initialDragX = 0;
|
|
27
|
+
initialDragY = 0;
|
|
28
|
+
/** Set of line IDs that have been disconnected from anchors during this drag */
|
|
29
|
+
disconnectedLineIds = new Set();
|
|
30
|
+
/** Flag indicating whether objects have been moved during the current drag operation */
|
|
31
|
+
hasMoved = false;
|
|
32
|
+
/** The pointer ID being tracked for the current drag operation (null if not dragging) */
|
|
33
|
+
trackedPointerId = null;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new instance of KritzelMoveHandler.
|
|
36
|
+
* @param core - The KritzelCore instance providing access to store, engine, and other core services
|
|
37
|
+
*/
|
|
38
|
+
constructor(core) {
|
|
39
|
+
super(core);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resets all internal state variables to their initial values.
|
|
43
|
+
* Called after a drag operation completes or is cancelled to prepare
|
|
44
|
+
* the handler for the next interaction.
|
|
45
|
+
* @returns void
|
|
46
|
+
*/
|
|
47
|
+
reset() {
|
|
48
|
+
this.dragStartX = 0;
|
|
49
|
+
this.dragStartY = 0;
|
|
50
|
+
this.startX = 0;
|
|
51
|
+
this.startY = 0;
|
|
52
|
+
this.endX = 0;
|
|
53
|
+
this.endY = 0;
|
|
54
|
+
this.initialDragX = 0;
|
|
55
|
+
this.initialDragY = 0;
|
|
56
|
+
this.disconnectedLineIds.clear();
|
|
57
|
+
this.hasMoved = false;
|
|
58
|
+
this.trackedPointerId = null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Cancels any pending drag operation without completing it.
|
|
62
|
+
* Sets the dragging state to false and resets internal state.
|
|
63
|
+
* Useful for aborting a drag when another interaction takes precedence.
|
|
64
|
+
* @returns void
|
|
65
|
+
*/
|
|
66
|
+
cancelPendingDrag() {
|
|
67
|
+
this._core.store.state.isDragging = false;
|
|
68
|
+
this.reset();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Handles the pointer down event to initiate a drag operation.
|
|
72
|
+
* Validates that the event is appropriate for starting a drag (e.g., left mouse click,
|
|
73
|
+
* single touch, correct state) and initializes drag tracking variables.
|
|
74
|
+
* Supports mouse, touch, and pen input types.
|
|
75
|
+
* @param event - The PointerEvent from the browser containing pointer information
|
|
76
|
+
* including clientX, clientY, pointerId, pointerType, and modifier keys
|
|
77
|
+
* @returns void
|
|
78
|
+
*/
|
|
79
|
+
handlePointerDown(event) {
|
|
80
|
+
if (event.pointerType === 'mouse') {
|
|
81
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
82
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
83
|
+
const isAdditive = event.shiftKey || event.ctrlKey;
|
|
84
|
+
if (selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected && !this._core.store.state.isLineHandleSelected && !isAdditive) {
|
|
85
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
86
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
87
|
+
this._core.store.state.isDragging = true;
|
|
88
|
+
this.dragStartX = clientX;
|
|
89
|
+
this.dragStartY = clientY;
|
|
90
|
+
this.startX = this.dragStartX;
|
|
91
|
+
this.startY = this.dragStartY;
|
|
92
|
+
this.initialDragX = clientX;
|
|
93
|
+
this.initialDragY = clientY;
|
|
94
|
+
this.disconnectedLineIds.clear();
|
|
95
|
+
this.trackedPointerId = event.pointerId;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.trackedPointerId = null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.trackedPointerId = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
106
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
107
|
+
if (this._core.store.state.pointers.size === 1) {
|
|
108
|
+
if (this._core.store.state.isScaling) {
|
|
109
|
+
this.trackedPointerId = null;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
113
|
+
const isAdditive = event.shiftKey || event.ctrlKey;
|
|
114
|
+
if (selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected && !this._core.store.state.isLineHandleSelected && !isAdditive) {
|
|
115
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
116
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
117
|
+
this.dragStartX = x;
|
|
118
|
+
this.dragStartY = y;
|
|
119
|
+
this.startX = x;
|
|
120
|
+
this.startY = y;
|
|
121
|
+
this.initialDragX = x;
|
|
122
|
+
this.initialDragY = y;
|
|
123
|
+
this.disconnectedLineIds.clear();
|
|
124
|
+
this.trackedPointerId = event.pointerId;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.trackedPointerId = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Handles pointer move events during a drag operation.
|
|
134
|
+
* Calculates movement delta, applies a movement threshold to filter micro-movements,
|
|
135
|
+
* checks for anchor disconnection on lines, and updates the position of selected objects.
|
|
136
|
+
* Supports mouse, touch, and pen input types.
|
|
137
|
+
* @param event - The PointerEvent from the browser containing current pointer position
|
|
138
|
+
* and pointer identification (pointerId, pointerType, clientX, clientY)
|
|
139
|
+
* @returns void
|
|
140
|
+
*/
|
|
141
|
+
handlePointerMove(event) {
|
|
142
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (event.pointerType === 'mouse') {
|
|
146
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
147
|
+
if (this._core.store.state.isDragging && selectionGroup) {
|
|
148
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
149
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
150
|
+
this.endX = clientX;
|
|
151
|
+
this.endY = clientY;
|
|
152
|
+
const moveDeltaX = Math.abs(clientX - this.startX);
|
|
153
|
+
const moveDeltaY = Math.abs(clientY - this.startY);
|
|
154
|
+
const moveThreshold = 5;
|
|
155
|
+
if (this.hasMoved || moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
|
|
156
|
+
// Check for anchor disconnect threshold on lines
|
|
157
|
+
this.checkAndDisconnectAnchors(clientX, clientY);
|
|
158
|
+
selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
|
|
159
|
+
this.dragStartX = clientX;
|
|
160
|
+
this.dragStartY = clientY;
|
|
161
|
+
this.hasMoved = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
166
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
167
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
168
|
+
if (this._core.store.state.pointers.size === 1 &&
|
|
169
|
+
selectionGroup &&
|
|
170
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
171
|
+
!this._core.store.state.isRotationHandleSelected &&
|
|
172
|
+
!this._core.store.state.isScaling) {
|
|
173
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
174
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
175
|
+
this._core.store.state.isDragging = true;
|
|
176
|
+
this.endX = x;
|
|
177
|
+
this.endY = y;
|
|
178
|
+
const moveDeltaX = Math.abs(x - this.startX);
|
|
179
|
+
const moveDeltaY = Math.abs(y - this.startY);
|
|
180
|
+
const moveThreshold = 5;
|
|
181
|
+
if (this.hasMoved || moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
|
|
182
|
+
const timeout = this._core.store.state.longTouchTimeout;
|
|
183
|
+
if (timeout) {
|
|
184
|
+
globalThis.clearTimeout?.(timeout);
|
|
185
|
+
}
|
|
186
|
+
// Check for anchor disconnect threshold on lines
|
|
187
|
+
this.checkAndDisconnectAnchors(x, y);
|
|
188
|
+
selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
|
|
189
|
+
this.dragStartX = x;
|
|
190
|
+
this.dragStartY = y;
|
|
191
|
+
this.hasMoved = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Handles the pointer up event to complete a drag operation.
|
|
198
|
+
* Finalizes the move by updating the selection group, emitting change events
|
|
199
|
+
* if objects were moved, and resetting internal state for the next operation.
|
|
200
|
+
* Supports mouse, touch, and pen input types.
|
|
201
|
+
* @param event - The PointerEvent from the browser containing pointer identification
|
|
202
|
+
* (pointerId, pointerType) to verify this is the tracked pointer
|
|
203
|
+
* @returns void
|
|
204
|
+
*/
|
|
205
|
+
handlePointerUp(event) {
|
|
206
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (event.pointerType === 'mouse') {
|
|
210
|
+
if (this._core.store.state.isDragging) {
|
|
211
|
+
this._core.store.state.isDragging = false;
|
|
212
|
+
if (this.hasMoved) {
|
|
213
|
+
this._core.store.selectionGroup.persistChildren();
|
|
214
|
+
this._core.store.selectionGroup.refreshObjectDimensions(undefined, false);
|
|
215
|
+
this._core.store.selectionGroup.update();
|
|
216
|
+
this._core.engine.emitObjectsChange();
|
|
217
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
218
|
+
this._core.store.objects.stopUndoCapturing();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
223
|
+
if (this._core.store.state.isDragging) {
|
|
224
|
+
this._core.store.state.isDragging = false;
|
|
225
|
+
if (this.hasMoved) {
|
|
226
|
+
this._core.store.selectionGroup.persistChildren();
|
|
227
|
+
this._core.store.selectionGroup.refreshObjectDimensions(undefined, false);
|
|
228
|
+
this._core.store.selectionGroup.update();
|
|
229
|
+
this._core.engine.emitObjectsChange();
|
|
230
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
231
|
+
this._core.store.objects.stopUndoCapturing();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
this.reset();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Checks if the total accumulated drag distance exceeds the anchor disconnect threshold.
|
|
239
|
+
* If so, disconnects all anchors from any KritzelLine objects in the selection group.
|
|
240
|
+
* This allows anchored lines to be freely moved after dragging beyond the threshold.
|
|
241
|
+
*
|
|
242
|
+
* Only disconnects anchors when the selection contains exclusively line objects.
|
|
243
|
+
* If the selection includes other object types (e.g., shapes that lines might be
|
|
244
|
+
* anchored to), no disconnection occurs to preserve intended relationships.
|
|
245
|
+
*
|
|
246
|
+
* @param currentX - The current X coordinate of the pointer in screen pixels
|
|
247
|
+
* @param currentY - The current Y coordinate of the pointer in screen pixels
|
|
248
|
+
* @returns void
|
|
249
|
+
*/
|
|
250
|
+
checkAndDisconnectAnchors(currentX, currentY) {
|
|
251
|
+
const totalDeltaX = currentX - this.initialDragX;
|
|
252
|
+
const totalDeltaY = currentY - this.initialDragY;
|
|
253
|
+
const totalDistance = Math.sqrt(totalDeltaX * totalDeltaX + totalDeltaY * totalDeltaY);
|
|
254
|
+
if (totalDistance < ANCHOR_DISCONNECT_THRESHOLD) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
258
|
+
if (!selectionGroup) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// Only disconnect lines if the selection group contains ONLY lines.
|
|
262
|
+
// If moving lines with other objects (e.g. shapes they might be anchored to), prevent auto-disconnect.
|
|
263
|
+
// Cache objects once to avoid repeated getter calls
|
|
264
|
+
const children = selectionGroup.objects;
|
|
265
|
+
const onlyLines = children.every(obj => obj instanceof KritzelLine);
|
|
266
|
+
if (!onlyLines) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
// Find and disconnect anchors from all anchored lines in the selection
|
|
270
|
+
for (const obj of children) {
|
|
271
|
+
// Skip if already disconnected in this drag session
|
|
272
|
+
if (this.disconnectedLineIds.has(obj.id)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
// Check if this is a line with anchors
|
|
276
|
+
if (obj instanceof KritzelLine) {
|
|
277
|
+
const line = obj;
|
|
278
|
+
const hasAnchors = line.startAnchor || line.endAnchor;
|
|
279
|
+
if (hasAnchors) {
|
|
280
|
+
// Disconnect both anchors
|
|
281
|
+
if (line.startAnchor) {
|
|
282
|
+
this._core.anchorManager.removeAnchor(line.id, 'start');
|
|
283
|
+
}
|
|
284
|
+
if (line.endAnchor) {
|
|
285
|
+
this._core.anchorManager.removeAnchor(line.id, 'end');
|
|
286
|
+
}
|
|
287
|
+
// Mark as disconnected so we don't try again
|
|
288
|
+
this.disconnectedLineIds.add(line.id);
|
|
289
|
+
// Update the line to persist the change
|
|
290
|
+
this._core.store.objects.update(line);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { KritzelHandleType } from "../../enums/handle-type.enum";
|
|
2
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
3
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
4
|
+
/**
|
|
5
|
+
* Handler class responsible for managing resize operations on selected objects.
|
|
6
|
+
* Supports mouse, touch, and pen input types, with rotation-aware resizing
|
|
7
|
+
* and optional aspect ratio locking via Shift key (mouse only).
|
|
8
|
+
*/
|
|
9
|
+
export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
10
|
+
/** Initial mouse/pointer X coordinate when resize started */
|
|
11
|
+
initialMouseX = 0;
|
|
12
|
+
/** Initial mouse/pointer Y coordinate when resize started */
|
|
13
|
+
initialMouseY = 0;
|
|
14
|
+
/** Initial position and dimensions of the selection group before resize */
|
|
15
|
+
initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
16
|
+
/** New position and dimensions being calculated during resize */
|
|
17
|
+
newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
18
|
+
/** Flag indicating whether the user has moved past the resize threshold */
|
|
19
|
+
hasResized = false;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new KritzelResizeHandler instance.
|
|
22
|
+
* @param core - The KritzelCore instance providing access to store, engine, and other core functionalities
|
|
23
|
+
*/
|
|
24
|
+
constructor(core) {
|
|
25
|
+
super(core);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resets all internal state variables to their default values.
|
|
29
|
+
* Called after a resize operation completes to prepare for the next resize.
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
reset() {
|
|
33
|
+
this.initialMouseX = 0;
|
|
34
|
+
this.initialMouseY = 0;
|
|
35
|
+
this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
36
|
+
this.newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
37
|
+
this.hasResized = false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Rebase pointer and size baselines to the latest live selection bounds.
|
|
41
|
+
* This prevents drift when anchored lines to external objects expand/shrink
|
|
42
|
+
* the selection box while a resize gesture is in progress.
|
|
43
|
+
*/
|
|
44
|
+
rebaseResizeBaseline(selectionGroup, clientX, clientY) {
|
|
45
|
+
this.initialMouseX = clientX;
|
|
46
|
+
this.initialMouseY = clientY;
|
|
47
|
+
this.initialSize.width = selectionGroup.width;
|
|
48
|
+
this.initialSize.height = selectionGroup.height;
|
|
49
|
+
this.initialSize.x = selectionGroup.translateX;
|
|
50
|
+
this.initialSize.y = selectionGroup.translateY;
|
|
51
|
+
}
|
|
52
|
+
shouldRebaseResizeBaseline(selectionGroup) {
|
|
53
|
+
return selectionGroup.hasExternalAnchoredLineConnections?.() === true;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handles the pointer down event to initiate a resize operation.
|
|
57
|
+
* Captures the initial mouse position and selection group dimensions when
|
|
58
|
+
* the user clicks/touches a resize handle. Supports both mouse and touch/pen inputs.
|
|
59
|
+
*
|
|
60
|
+
* For mouse: Requires left click on an active resize handle.
|
|
61
|
+
* For touch/pen: Requires single finger touch on an active resize handle.
|
|
62
|
+
*
|
|
63
|
+
* @param event - The PointerEvent containing pointer type, position, and button information
|
|
64
|
+
*/
|
|
65
|
+
handlePointerDown(event) {
|
|
66
|
+
if (event.pointerType === 'mouse') {
|
|
67
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
68
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
69
|
+
if (selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
70
|
+
selectionGroup.beginTransform();
|
|
71
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
72
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
73
|
+
this._core.store.state.isResizing = true;
|
|
74
|
+
this.initialMouseX = clientX;
|
|
75
|
+
this.initialMouseY = clientY;
|
|
76
|
+
this.initialSize.width = selectionGroup.width;
|
|
77
|
+
this.initialSize.height = selectionGroup.height;
|
|
78
|
+
this.initialSize.x = selectionGroup.translateX;
|
|
79
|
+
this.initialSize.y = selectionGroup.translateY;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
84
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
85
|
+
const firstTouch = activePointers[0];
|
|
86
|
+
if (!firstTouch) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (activePointers.length === 1) {
|
|
90
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
91
|
+
if (selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
92
|
+
selectionGroup.beginTransform();
|
|
93
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
94
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
95
|
+
this._core.store.state.isResizing = true;
|
|
96
|
+
this.initialMouseX = clientX;
|
|
97
|
+
this.initialMouseY = clientY;
|
|
98
|
+
this.initialSize.width = selectionGroup.width;
|
|
99
|
+
this.initialSize.height = selectionGroup.height;
|
|
100
|
+
this.initialSize.x = selectionGroup.translateX;
|
|
101
|
+
this.initialSize.y = selectionGroup.translateY;
|
|
102
|
+
const timeout = this._core.store.state.longTouchTimeout;
|
|
103
|
+
if (timeout) {
|
|
104
|
+
globalThis.clearTimeout?.(timeout);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Handles the pointer move event during an active resize operation.
|
|
112
|
+
* Calculates the new dimensions based on pointer movement, taking into account:
|
|
113
|
+
* - The rotation of the selection group (transforms screen delta to local space)
|
|
114
|
+
* - The current canvas scale/zoom level
|
|
115
|
+
* - The type of resize handle being dragged (TopLeft, TopRight, BottomLeft, BottomRight)
|
|
116
|
+
* - Aspect ratio locking when Shift key is pressed (mouse only)
|
|
117
|
+
*
|
|
118
|
+
* Uses a movement threshold to prevent accidental micro-resizes.
|
|
119
|
+
* The resize is applied symmetrically around the center point.
|
|
120
|
+
*
|
|
121
|
+
* @param event - The PointerEvent containing current pointer position and modifier keys
|
|
122
|
+
*/
|
|
123
|
+
handlePointerMove(event) {
|
|
124
|
+
if (event.pointerType === 'mouse') {
|
|
125
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
126
|
+
if (this._core.store.state.isResizing && selectionGroup) {
|
|
127
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
128
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
129
|
+
const dx = clientX - this.initialMouseX;
|
|
130
|
+
const dy = clientY - this.initialMouseY;
|
|
131
|
+
const resizeDeltaX = Math.abs(dx);
|
|
132
|
+
const resizeDeltaY = Math.abs(dy);
|
|
133
|
+
const resizeThreshold = 5;
|
|
134
|
+
if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {
|
|
135
|
+
this.hasResized = true;
|
|
136
|
+
}
|
|
137
|
+
if (!this.hasResized) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const rotation = selectionGroup.rotation;
|
|
141
|
+
const sin = Math.sin(rotation);
|
|
142
|
+
const cos = Math.cos(rotation);
|
|
143
|
+
const objectScale = selectionGroup.scale || 1;
|
|
144
|
+
const currentScale = this._core.store.state.scale;
|
|
145
|
+
// Calculate delta in local unrotated space
|
|
146
|
+
// We rotate the screen delta by -rotation to align with the object's axes
|
|
147
|
+
const localDx = (dx * cos + dy * sin) / currentScale;
|
|
148
|
+
const localDy = (-dx * sin + dy * cos) / currentScale;
|
|
149
|
+
// Calculate the center of the selection group before resize
|
|
150
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;
|
|
151
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;
|
|
152
|
+
// The center moves by half of the screen delta (scaled)
|
|
153
|
+
// This is true regardless of rotation because the resize happens symmetrically around the center
|
|
154
|
+
// relative to the fixed point logic
|
|
155
|
+
const newCenterX = initialCenterX + dx / currentScale / 2;
|
|
156
|
+
const newCenterY = initialCenterY + dy / currentScale / 2;
|
|
157
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
158
|
+
case KritzelHandleType.TopLeft:
|
|
159
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
160
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
161
|
+
break;
|
|
162
|
+
case KritzelHandleType.TopRight:
|
|
163
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
164
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
165
|
+
break;
|
|
166
|
+
case KritzelHandleType.BottomLeft:
|
|
167
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
168
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
169
|
+
break;
|
|
170
|
+
case KritzelHandleType.BottomRight:
|
|
171
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
172
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
// Lock aspect ratio when Shift key is pressed
|
|
176
|
+
if (event.shiftKey) {
|
|
177
|
+
this.constrainToAspectRatio();
|
|
178
|
+
}
|
|
179
|
+
this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;
|
|
180
|
+
this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;
|
|
181
|
+
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
182
|
+
if (this.shouldRebaseResizeBaseline(selectionGroup)) {
|
|
183
|
+
this.rebaseResizeBaseline(selectionGroup, clientX, clientY);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
188
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
189
|
+
const oneFingerTouch = activePointers[0];
|
|
190
|
+
if (!oneFingerTouch) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
194
|
+
if (this._core.store.state.isResizing && selectionGroup) {
|
|
195
|
+
const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);
|
|
196
|
+
const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);
|
|
197
|
+
const dx = clientX - this.initialMouseX;
|
|
198
|
+
const dy = clientY - this.initialMouseY;
|
|
199
|
+
const resizeDeltaX = Math.abs(dx);
|
|
200
|
+
const resizeDeltaY = Math.abs(dy);
|
|
201
|
+
const resizeThreshold = 5;
|
|
202
|
+
if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {
|
|
203
|
+
const timeout = this._core.store.state.longTouchTimeout;
|
|
204
|
+
if (timeout) {
|
|
205
|
+
globalThis.clearTimeout?.(timeout);
|
|
206
|
+
}
|
|
207
|
+
this.hasResized = true;
|
|
208
|
+
}
|
|
209
|
+
if (!this.hasResized) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const rotation = selectionGroup.rotation;
|
|
213
|
+
const sin = Math.sin(rotation);
|
|
214
|
+
const cos = Math.cos(rotation);
|
|
215
|
+
const objectScale = selectionGroup.scale || 1;
|
|
216
|
+
const currentScale = this._core.store.state.scale;
|
|
217
|
+
// Calculate delta in local unrotated space
|
|
218
|
+
// We rotate the screen delta by -rotation to align with the object's axes
|
|
219
|
+
const localDx = (dx * cos + dy * sin) / currentScale;
|
|
220
|
+
const localDy = (-dx * sin + dy * cos) / currentScale;
|
|
221
|
+
// Calculate the center of the selection group before resize
|
|
222
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;
|
|
223
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;
|
|
224
|
+
// The center moves by half of the screen delta (scaled)
|
|
225
|
+
// This is true regardless of rotation because the resize happens symmetrically around the center
|
|
226
|
+
// relative to the fixed point logic
|
|
227
|
+
const newCenterX = initialCenterX + dx / currentScale / 2;
|
|
228
|
+
const newCenterY = initialCenterY + dy / currentScale / 2;
|
|
229
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
230
|
+
case KritzelHandleType.TopLeft:
|
|
231
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
232
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
233
|
+
break;
|
|
234
|
+
case KritzelHandleType.TopRight:
|
|
235
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
236
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
237
|
+
break;
|
|
238
|
+
case KritzelHandleType.BottomLeft:
|
|
239
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
240
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
241
|
+
break;
|
|
242
|
+
case KritzelHandleType.BottomRight:
|
|
243
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
244
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
// Note: Touch events don't have shiftKey, aspect ratio locking is mouse-only
|
|
248
|
+
this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;
|
|
249
|
+
this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;
|
|
250
|
+
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
251
|
+
if (this.shouldRebaseResizeBaseline(selectionGroup)) {
|
|
252
|
+
this.rebaseResizeBaseline(selectionGroup, clientX, clientY);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Constrains the new size to maintain the original aspect ratio.
|
|
259
|
+
* Uses the dominant scale factor (the axis with larger relative change)
|
|
260
|
+
* to determine the final size, ensuring natural resize behavior.
|
|
261
|
+
*
|
|
262
|
+
* If width changed more proportionally, height is adjusted to match the aspect ratio.
|
|
263
|
+
* If height changed more proportionally, width is adjusted to match the aspect ratio.
|
|
264
|
+
*
|
|
265
|
+
* @private
|
|
266
|
+
* @remarks Does nothing if initial width or height is zero to prevent division errors
|
|
267
|
+
*/
|
|
268
|
+
constrainToAspectRatio() {
|
|
269
|
+
const initialWidth = this.initialSize.width;
|
|
270
|
+
const initialHeight = this.initialSize.height;
|
|
271
|
+
if (initialWidth === 0 || initialHeight === 0) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const aspectRatio = initialWidth / initialHeight;
|
|
275
|
+
const widthScale = this.newSize.width / initialWidth;
|
|
276
|
+
const heightScale = this.newSize.height / initialHeight;
|
|
277
|
+
// Use the dominant scale factor (the one with larger magnitude change)
|
|
278
|
+
if (Math.abs(widthScale - 1) > Math.abs(heightScale - 1)) {
|
|
279
|
+
// Width changed more, adjust height to match
|
|
280
|
+
this.newSize.height = this.newSize.width / aspectRatio;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Height changed more, adjust width to match
|
|
284
|
+
this.newSize.width = this.newSize.height * aspectRatio;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Handles the pointer up event to finalize a resize operation.
|
|
289
|
+
* If resizing occurred (movement exceeded threshold), updates the selection group
|
|
290
|
+
* and emits change events. Resets all internal state regardless of whether
|
|
291
|
+
* actual resizing took place.
|
|
292
|
+
*
|
|
293
|
+
* For touch/pen inputs, also clears any pending long touch timeout.
|
|
294
|
+
*
|
|
295
|
+
* @param event - The PointerEvent containing pointer type information
|
|
296
|
+
*/
|
|
297
|
+
handlePointerUp(event) {
|
|
298
|
+
if (event.pointerType === 'mouse') {
|
|
299
|
+
if (this._core.store.state.isResizing) {
|
|
300
|
+
this._core.store.state.isResizing = false;
|
|
301
|
+
if (this.hasResized) {
|
|
302
|
+
this._core.store.selectionGroup.update();
|
|
303
|
+
this._core.engine.emitObjectsChange();
|
|
304
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
305
|
+
this._core.store.objects.stopUndoCapturing();
|
|
306
|
+
}
|
|
307
|
+
this.reset();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
311
|
+
if (this._core.store.state.isResizing) {
|
|
312
|
+
this._core.store.state.isResizing = false;
|
|
313
|
+
if (this.hasResized) {
|
|
314
|
+
this._core.store.selectionGroup.update();
|
|
315
|
+
this._core.engine.emitObjectsChange();
|
|
316
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
317
|
+
this._core.store.objects.stopUndoCapturing();
|
|
318
|
+
}
|
|
319
|
+
this.reset();
|
|
320
|
+
const timeout = this._core.store.state.longTouchTimeout;
|
|
321
|
+
if (timeout) {
|
|
322
|
+
globalThis.clearTimeout?.(timeout);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|