@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,611 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelClassHelper } from "../../helpers/class.helper";
|
|
3
|
+
import { KritzelColorHelper } from "../../helpers/color.helper";
|
|
4
|
+
import { KritzelMoveHandler } from "../handlers/move.handler";
|
|
5
|
+
import { KritzelResizeHandler } from "../handlers/resize.handler";
|
|
6
|
+
import { KritzelRotationHandler } from "../handlers/rotation.handler";
|
|
7
|
+
import { KritzelSelectionHandler } from "../handlers/selection.handler";
|
|
8
|
+
import { KritzelSelectionGroup } from "../objects/selection-group.class";
|
|
9
|
+
import { KritzelBaseTool } from "./base-tool.class";
|
|
10
|
+
import { KritzelHoverHandler } from "../handlers/hover.handler";
|
|
11
|
+
import { KritzelLineHandleHandler } from "../handlers/line-handle.handler";
|
|
12
|
+
import { KritzelPath } from "../objects/path.class";
|
|
13
|
+
import { KritzelLine } from "../objects/line.class";
|
|
14
|
+
import { KritzelShape } from "../objects/shape.class";
|
|
15
|
+
import { KritzelText } from "../objects/text.class";
|
|
16
|
+
import { KritzelImage } from "../objects/image.class";
|
|
17
|
+
import { DEFAULT_COLOR_PALETTE } from "../../constants/color-palette.constants";
|
|
18
|
+
/**
|
|
19
|
+
* Selection tool for selecting, moving, resizing, and rotating objects on the canvas.
|
|
20
|
+
* Provides comprehensive object manipulation capabilities including multi-select,
|
|
21
|
+
* property editing, and various transformation handles. Delegates specific interactions
|
|
22
|
+
* to specialized handlers (selection, move, resize, rotation, hover, line handle).
|
|
23
|
+
*/
|
|
24
|
+
export class KritzelSelectionTool extends KritzelBaseTool {
|
|
25
|
+
toolType = 'selection';
|
|
26
|
+
/** Handler for selection box and object selection logic */
|
|
27
|
+
selectionHandler;
|
|
28
|
+
/** Handler for moving selected objects */
|
|
29
|
+
moveHandler;
|
|
30
|
+
/** Handler for hover effects on objects */
|
|
31
|
+
hoverHandler;
|
|
32
|
+
/** Handler for resizing selected objects */
|
|
33
|
+
resizeHandler;
|
|
34
|
+
/** Handler for rotating selected objects */
|
|
35
|
+
rotationHandler;
|
|
36
|
+
/** Handler for manipulating line start/end handles */
|
|
37
|
+
lineHandleHandler;
|
|
38
|
+
/** Available color palette for selected objects */
|
|
39
|
+
palette = [...DEFAULT_COLOR_PALETTE];
|
|
40
|
+
/**
|
|
41
|
+
* Stores a selection group that was cleared on the first finger-down of a
|
|
42
|
+
* potential pinch-zoom gesture, so it can be restored when the second finger
|
|
43
|
+
* arrives. Cleared when the touch interaction ends.
|
|
44
|
+
*/
|
|
45
|
+
_savedSelectionGroupForPinch = null;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if there are any objects currently selected.
|
|
48
|
+
* @returns True if there are objects in the selection group, false otherwise
|
|
49
|
+
*/
|
|
50
|
+
hasSelection() {
|
|
51
|
+
return !!this._core.store.selectionGroup && this._core.store.selectionGroup.objects.length > 0;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the currently selected objects.
|
|
55
|
+
* @returns Array of selected objects, or empty array if no selection
|
|
56
|
+
*/
|
|
57
|
+
getSelectedObjects() {
|
|
58
|
+
return this._core.store.selectionGroup?.objects ?? [];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Recursively flattens a collection of objects, expanding any groups into their children.
|
|
62
|
+
* @param objects - Array of objects that may include groups
|
|
63
|
+
* @returns Flattened array with all nested group children expanded
|
|
64
|
+
*/
|
|
65
|
+
flattenObjects(objects) {
|
|
66
|
+
let result = [];
|
|
67
|
+
for (const obj of objects) {
|
|
68
|
+
if (KritzelClassHelper.isInstanceOf(obj, 'KritzelGroup')) {
|
|
69
|
+
result = result.concat(this.flattenObjects(obj.children));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
result.push(obj);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets the primary color of the selected objects.
|
|
79
|
+
* Returns the fill color for paths, stroke for lines, font color for text, or stroke color for shapes.
|
|
80
|
+
*/
|
|
81
|
+
get color() {
|
|
82
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
83
|
+
if (objects.length === 0)
|
|
84
|
+
return DEFAULT_COLOR_PALETTE[0];
|
|
85
|
+
for (const obj of objects) {
|
|
86
|
+
if (obj instanceof KritzelPath)
|
|
87
|
+
return obj.fill;
|
|
88
|
+
if (obj instanceof KritzelLine)
|
|
89
|
+
return obj.stroke;
|
|
90
|
+
if (obj instanceof KritzelText)
|
|
91
|
+
return obj.fontColor;
|
|
92
|
+
if (obj instanceof KritzelShape)
|
|
93
|
+
return obj.strokeColor;
|
|
94
|
+
}
|
|
95
|
+
return DEFAULT_COLOR_PALETTE[0];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sets the primary color of all selected objects.
|
|
99
|
+
* Updates the appropriate color property based on object type (fill, stroke, fontColor, strokeColor).
|
|
100
|
+
*/
|
|
101
|
+
set color(value) {
|
|
102
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
103
|
+
objects.forEach(obj => {
|
|
104
|
+
if (obj instanceof KritzelPath)
|
|
105
|
+
this._core.updateObject(obj, { fill: value });
|
|
106
|
+
if (obj instanceof KritzelLine)
|
|
107
|
+
this._core.updateObject(obj, { stroke: value });
|
|
108
|
+
if (obj instanceof KritzelText)
|
|
109
|
+
this._core.updateObject(obj, { fontColor: value });
|
|
110
|
+
if (obj instanceof KritzelShape)
|
|
111
|
+
this._core.updateObject(obj, { strokeColor: value });
|
|
112
|
+
});
|
|
113
|
+
this._core.rerender();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the opacity of the first selected object.
|
|
117
|
+
* @returns The opacity value (0-1) or 1 if no selection
|
|
118
|
+
*/
|
|
119
|
+
get opacity() {
|
|
120
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
121
|
+
if (objects.length === 0)
|
|
122
|
+
return 1;
|
|
123
|
+
return objects[0].opacity;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Sets the opacity of all selected objects.
|
|
127
|
+
* @param value - The opacity value (0-1)
|
|
128
|
+
*/
|
|
129
|
+
set opacity(value) {
|
|
130
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
131
|
+
objects.forEach(obj => this._core.updateObject(obj, { opacity: value }));
|
|
132
|
+
this._core.rerender();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the size (stroke width or font size) of the selected objects.
|
|
136
|
+
* Returns strokeWidth for paths/lines/shapes, fontSize for text objects.
|
|
137
|
+
*/
|
|
138
|
+
get size() {
|
|
139
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
140
|
+
if (objects.length === 0)
|
|
141
|
+
return 1;
|
|
142
|
+
for (const obj of objects) {
|
|
143
|
+
if (obj instanceof KritzelPath)
|
|
144
|
+
return obj.strokeWidth;
|
|
145
|
+
if (obj instanceof KritzelLine)
|
|
146
|
+
return obj.strokeWidth;
|
|
147
|
+
if (obj instanceof KritzelText)
|
|
148
|
+
return obj.fontSize;
|
|
149
|
+
if (obj instanceof KritzelShape)
|
|
150
|
+
return obj.strokeWidth;
|
|
151
|
+
}
|
|
152
|
+
return 1;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Sets the size (stroke width or font size) of all selected objects.
|
|
156
|
+
* Updates strokeWidth for paths/lines/shapes and fontSize for text objects.
|
|
157
|
+
* Refreshes selection group dimensions after updating.
|
|
158
|
+
*/
|
|
159
|
+
set size(value) {
|
|
160
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
161
|
+
objects.forEach(obj => {
|
|
162
|
+
if (obj instanceof KritzelPath)
|
|
163
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
164
|
+
if (obj instanceof KritzelLine)
|
|
165
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
166
|
+
if (obj instanceof KritzelText)
|
|
167
|
+
this._core.updateObject(obj, { fontSize: value });
|
|
168
|
+
if (obj instanceof KritzelShape)
|
|
169
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
170
|
+
});
|
|
171
|
+
this._core.rerender();
|
|
172
|
+
this.refreshSelectionGroupDimensions();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Gets the fill color of the first selected shape.
|
|
176
|
+
* @returns The fill color or transparent if no shapes are selected
|
|
177
|
+
*/
|
|
178
|
+
get fillColor() {
|
|
179
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
180
|
+
for (const obj of objects) {
|
|
181
|
+
if (obj instanceof KritzelShape)
|
|
182
|
+
return obj.fillColor;
|
|
183
|
+
}
|
|
184
|
+
return { light: 'transparent', dark: 'transparent' };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sets the fill color of all selected shapes.
|
|
188
|
+
* Also updates the font color based on fill color contrast and syncs stroke color when fill is not transparent.
|
|
189
|
+
*/
|
|
190
|
+
set fillColor(value) {
|
|
191
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
192
|
+
objects.forEach(obj => {
|
|
193
|
+
if (obj instanceof KritzelShape) {
|
|
194
|
+
// Calculate new font color based on fill color
|
|
195
|
+
const newFontColor = KritzelColorHelper.determineTextColor(value);
|
|
196
|
+
this._core.updateObject(obj, { fillColor: value, fontColor: newFontColor });
|
|
197
|
+
// When switching to fill mode, also update stroke color to match
|
|
198
|
+
const isTransparent = typeof value === 'string' ? value === 'transparent' :
|
|
199
|
+
(value.light === 'transparent' && value.dark === 'transparent');
|
|
200
|
+
if (!isTransparent) {
|
|
201
|
+
this._core.updateObject(obj, { strokeColor: value });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
this._core.rerender();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Gets the font family of the first selected text or shape object.
|
|
209
|
+
* @returns The font family name or 'Arial' as default
|
|
210
|
+
*/
|
|
211
|
+
get fontFamily() {
|
|
212
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
213
|
+
for (const obj of objects) {
|
|
214
|
+
if (obj instanceof KritzelText)
|
|
215
|
+
return obj.fontFamily;
|
|
216
|
+
if (obj instanceof KritzelShape)
|
|
217
|
+
return obj.fontFamily;
|
|
218
|
+
}
|
|
219
|
+
return 'Arial';
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sets the font family of all selected text and shape objects.
|
|
223
|
+
* Refreshes selection group dimensions after updating.
|
|
224
|
+
*/
|
|
225
|
+
set fontFamily(value) {
|
|
226
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
227
|
+
objects.forEach(obj => {
|
|
228
|
+
if (obj instanceof KritzelText)
|
|
229
|
+
this._core.updateObject(obj, { fontFamily: value });
|
|
230
|
+
if (obj instanceof KritzelShape)
|
|
231
|
+
this._core.updateObject(obj, { fontFamily: value });
|
|
232
|
+
});
|
|
233
|
+
this._core.rerender();
|
|
234
|
+
this.refreshSelectionGroupDimensions();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Gets the arrow configuration of the first selected line.
|
|
238
|
+
* @returns The arrow config or default disabled arrows if no lines are selected
|
|
239
|
+
*/
|
|
240
|
+
get arrows() {
|
|
241
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
242
|
+
for (const obj of objects) {
|
|
243
|
+
if (obj instanceof KritzelLine)
|
|
244
|
+
return obj.arrows ?? { start: { enabled: false }, end: { enabled: false } };
|
|
245
|
+
}
|
|
246
|
+
return { start: { enabled: false }, end: { enabled: false } };
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Sets the arrow configuration of all selected lines.
|
|
250
|
+
* Refreshes selection group dimensions after updating.
|
|
251
|
+
*/
|
|
252
|
+
set arrows(value) {
|
|
253
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
254
|
+
objects.forEach(obj => {
|
|
255
|
+
if (obj instanceof KritzelLine)
|
|
256
|
+
this._core.updateObject(obj, { arrows: value });
|
|
257
|
+
});
|
|
258
|
+
this._core.rerender();
|
|
259
|
+
this.refreshSelectionGroupDimensions();
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Generates a tool configuration definition based on the types of selected objects.
|
|
263
|
+
* Determines which controls should be shown in the UI based on whether the selection
|
|
264
|
+
* contains shapes, text, lines, images, or stroke-based objects.
|
|
265
|
+
* @returns Tool configuration for the UI, or null if nothing is selected
|
|
266
|
+
*/
|
|
267
|
+
getToolConfig() {
|
|
268
|
+
if (!this.hasSelection())
|
|
269
|
+
return null;
|
|
270
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
271
|
+
const controls = [];
|
|
272
|
+
const hasShape = objects.some(o => o instanceof KritzelShape);
|
|
273
|
+
const hasText = objects.some(o => o instanceof KritzelText);
|
|
274
|
+
const hasLine = objects.some(o => o instanceof KritzelLine);
|
|
275
|
+
const hasImage = objects.some(o => o instanceof KritzelImage);
|
|
276
|
+
const hasStroke = objects.some(o => o instanceof KritzelPath || o instanceof KritzelLine || o instanceof KritzelShape);
|
|
277
|
+
// If only images are selected, return config with opacity only (no palette, no controls)
|
|
278
|
+
if (hasImage && !hasShape && !hasText && !hasLine && !hasStroke) {
|
|
279
|
+
return {
|
|
280
|
+
type: 'selection',
|
|
281
|
+
colorProperty: 'color',
|
|
282
|
+
sizeProperty: 'size',
|
|
283
|
+
opacityProperty: 'opacity',
|
|
284
|
+
paletteSource: 'none',
|
|
285
|
+
sizesSource: 'none',
|
|
286
|
+
controls: [],
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (hasText && !hasStroke) {
|
|
290
|
+
controls.push({ type: 'font-size', propertyName: 'size' });
|
|
291
|
+
controls.push({ type: 'font-family', propertyName: 'fontFamily' });
|
|
292
|
+
}
|
|
293
|
+
else if (hasStroke && !hasText) {
|
|
294
|
+
controls.push({ type: 'stroke-size', propertyName: 'size' });
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
if (hasStroke)
|
|
298
|
+
controls.push({ type: 'stroke-size', propertyName: 'size' });
|
|
299
|
+
if (hasText)
|
|
300
|
+
controls.push({ type: 'font-family', propertyName: 'fontFamily' });
|
|
301
|
+
}
|
|
302
|
+
if (hasLine) {
|
|
303
|
+
controls.push({ type: 'line-endings', propertyName: 'arrows' });
|
|
304
|
+
}
|
|
305
|
+
if (hasShape) {
|
|
306
|
+
controls.push({ type: 'shape-fill', propertyName: 'fillColor' });
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
type: 'selection',
|
|
310
|
+
colorProperty: 'color',
|
|
311
|
+
sizeProperty: 'size',
|
|
312
|
+
opacityProperty: 'opacity',
|
|
313
|
+
paletteSource: 'palette',
|
|
314
|
+
sizesSource: 'none',
|
|
315
|
+
controls,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Refreshes the selection group's dimensions after object properties that affect size have changed.
|
|
320
|
+
* Uses requestAnimationFrame to ensure the DOM has been updated before measuring.
|
|
321
|
+
*/
|
|
322
|
+
refreshSelectionGroupDimensions() {
|
|
323
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
324
|
+
if (selectionGroup) {
|
|
325
|
+
requestAnimationFrame(() => {
|
|
326
|
+
requestAnimationFrame(() => {
|
|
327
|
+
selectionGroup.refreshObjectDimensions();
|
|
328
|
+
this._core.rerender();
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
constructor(core) {
|
|
334
|
+
super(core);
|
|
335
|
+
this.selectionHandler = new KritzelSelectionHandler(this._core);
|
|
336
|
+
this.moveHandler = new KritzelMoveHandler(this._core);
|
|
337
|
+
this.hoverHandler = new KritzelHoverHandler(this._core);
|
|
338
|
+
this.resizeHandler = new KritzelResizeHandler(this._core);
|
|
339
|
+
this.rotationHandler = new KritzelRotationHandler(this._core);
|
|
340
|
+
this.lineHandleHandler = new KritzelLineHandleHandler(this._core);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Handles pointer down events for selection and manipulation.
|
|
344
|
+
* Determines the type of interaction (resize handle, rotation handle, line handle, or object)
|
|
345
|
+
* and delegates to the appropriate handler. Manages selection state and supports
|
|
346
|
+
* additive selection with Shift/Ctrl modifiers.
|
|
347
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
348
|
+
*/
|
|
349
|
+
handlePointerDown(event) {
|
|
350
|
+
if (event.cancelable) {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
}
|
|
353
|
+
if (event.pointerType === 'mouse') {
|
|
354
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
355
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
356
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
357
|
+
this._core.store.state.isLineHandleSelected = this.isLineHandleSelected(event);
|
|
358
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
359
|
+
this._core.store.state.lineHandleType = this.getLineHandleType(event);
|
|
360
|
+
const selectedObject = this.getSelectedObject(event);
|
|
361
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
362
|
+
const isDifferentObject = selectedObject && selectionGroup && selectedObject.id !== selectionGroup.id;
|
|
363
|
+
const isAdditive = event.shiftKey || event.ctrlKey;
|
|
364
|
+
if ((selectedObject === null || isDifferentObject) &&
|
|
365
|
+
selectionGroup &&
|
|
366
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
367
|
+
!this._core.store.state.isRotationHandleSelected &&
|
|
368
|
+
!this._core.store.state.isLineHandleSelected &&
|
|
369
|
+
!isAdditive) {
|
|
370
|
+
this._core.removeSelectionGroup();
|
|
371
|
+
this._core.rerender();
|
|
372
|
+
}
|
|
373
|
+
if (selectedObject && selectedObject.isSelected === false && selectedObject?.objects.length === 1) {
|
|
374
|
+
const firstObj = selectedObject.objects[0];
|
|
375
|
+
if (KritzelClassHelper.isInstanceOf(firstObj, 'KritzelDynamicObject')) {
|
|
376
|
+
// Selected single dynamic objects hand pointer interaction to their
|
|
377
|
+
// embedded DOM content. Unselected dynamic objects remain selectable.
|
|
378
|
+
if (firstObj.isSelected && this._core.store.selectionGroup?.objects.length === 1)
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
else if (firstObj.isInteractive) {
|
|
382
|
+
// Preserve existing behavior for text/shape edit mode
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
this.lineHandleHandler.handlePointerDown(event);
|
|
388
|
+
this.moveHandler.handlePointerDown(event);
|
|
389
|
+
this.selectionHandler.handlePointerDown(event);
|
|
390
|
+
this.resizeHandler.handlePointerDown(event);
|
|
391
|
+
this.rotationHandler.handlePointerDown(event);
|
|
392
|
+
this._core.rerender();
|
|
393
|
+
}
|
|
394
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
395
|
+
if (this._core.store.state.isScaling === true) {
|
|
396
|
+
const activePointerCount = this._core.store.state.pointers.size;
|
|
397
|
+
// During a real pinch (two active pointers), keep touch handling suspended.
|
|
398
|
+
// If only one pointer is active, scaling is stale (debounce window after pinch),
|
|
399
|
+
// so resume normal touch selection behavior immediately.
|
|
400
|
+
if (activePointerCount === 1) {
|
|
401
|
+
this._core.store.state.isScaling = false;
|
|
402
|
+
this._savedSelectionGroupForPinch = null;
|
|
403
|
+
}
|
|
404
|
+
// A second finger has arrived to start a pinch-zoom gesture. If we
|
|
405
|
+
// cleared a selection group on the first finger-down, restore it now
|
|
406
|
+
// so the user's selection is preserved while zooming.
|
|
407
|
+
if (this._savedSelectionGroupForPinch && !this._core.store.selectionGroup) {
|
|
408
|
+
this._core.addSelectionGroup(this._savedSelectionGroupForPinch);
|
|
409
|
+
this._savedSelectionGroupForPinch = null;
|
|
410
|
+
this._core.rerender();
|
|
411
|
+
}
|
|
412
|
+
if (this._core.store.state.isScaling === true) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
// Continue with normal touch handling when scaling was stale.
|
|
416
|
+
}
|
|
417
|
+
if (this._core.store.state.pointers.size === 1) {
|
|
418
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
419
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
420
|
+
this._core.store.state.isLineHandleSelected = this.isLineHandleSelected(event);
|
|
421
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
422
|
+
this._core.store.state.lineHandleType = this.getLineHandleType(event);
|
|
423
|
+
const selectedObject = this.getSelectedObject(event);
|
|
424
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
425
|
+
const isDifferentObject = selectedObject && selectionGroup && selectedObject.id !== selectionGroup.id;
|
|
426
|
+
const isAdditive = event.shiftKey || event.ctrlKey;
|
|
427
|
+
if (!selectionGroup && selectedObject) {
|
|
428
|
+
this._core.store.state.skipContextMenu = true;
|
|
429
|
+
}
|
|
430
|
+
if ((selectedObject === null || isDifferentObject) &&
|
|
431
|
+
selectionGroup &&
|
|
432
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
433
|
+
!this._core.store.state.isRotationHandleSelected &&
|
|
434
|
+
!this._core.store.state.isLineHandleSelected &&
|
|
435
|
+
!isAdditive) {
|
|
436
|
+
// Save the selection group before removing it, so we can restore it
|
|
437
|
+
// if the user adds a second finger to start a pinch-zoom gesture.
|
|
438
|
+
this._savedSelectionGroupForPinch = selectionGroup;
|
|
439
|
+
this._core.removeSelectionGroup();
|
|
440
|
+
this._core.rerender();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
this.lineHandleHandler.handlePointerDown(event);
|
|
444
|
+
this.rotationHandler.handlePointerDown(event);
|
|
445
|
+
this.resizeHandler.handlePointerDown(event);
|
|
446
|
+
this.moveHandler.handlePointerDown(event);
|
|
447
|
+
// Only process selection handler if we are not scaling (2 pointers)
|
|
448
|
+
if (this._core.store.state.pointers.size === 1) {
|
|
449
|
+
this.selectionHandler.handlePointerDown(event);
|
|
450
|
+
}
|
|
451
|
+
this._core.rerender();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Handles pointer move events during selection and manipulation.
|
|
456
|
+
* Delegates movement to the appropriate handler based on the current interaction state
|
|
457
|
+
* (line handle, move, hover, selection box, resize, or rotation).
|
|
458
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
459
|
+
*/
|
|
460
|
+
handlePointerMove(event) {
|
|
461
|
+
if (event.cancelable) {
|
|
462
|
+
event.preventDefault();
|
|
463
|
+
}
|
|
464
|
+
if (event.pointerType === 'mouse') {
|
|
465
|
+
this.lineHandleHandler.handlePointerMove(event);
|
|
466
|
+
this.moveHandler.handlePointerMove(event);
|
|
467
|
+
this.hoverHandler.handlePointerMove(event);
|
|
468
|
+
this.selectionHandler.handlePointerMove(event);
|
|
469
|
+
this.resizeHandler.handlePointerMove(event);
|
|
470
|
+
this.rotationHandler.handlePointerMove(event);
|
|
471
|
+
this._core.rerender();
|
|
472
|
+
}
|
|
473
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
474
|
+
if (this._core.store.state.isScaling === true) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
this.lineHandleHandler.handlePointerMove(event);
|
|
478
|
+
this.rotationHandler.handlePointerMove(event);
|
|
479
|
+
this.resizeHandler.handlePointerMove(event);
|
|
480
|
+
this.moveHandler.handlePointerMove(event);
|
|
481
|
+
this.selectionHandler.handlePointerMove(event);
|
|
482
|
+
this._core.rerender();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Handles pointer up events to complete selection and manipulation operations.
|
|
487
|
+
* Delegates to all handlers to finalize their respective operations.
|
|
488
|
+
* @param event - The PointerEvent indicating the end of the interaction
|
|
489
|
+
*/
|
|
490
|
+
handlePointerUp(event) {
|
|
491
|
+
if (event.cancelable) {
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
}
|
|
494
|
+
if (event.pointerType === 'mouse') {
|
|
495
|
+
this.lineHandleHandler.handlePointerUp(event);
|
|
496
|
+
this.moveHandler.handlePointerUp(event);
|
|
497
|
+
this.resizeHandler.handlePointerUp(event);
|
|
498
|
+
this.rotationHandler.handlePointerUp(event);
|
|
499
|
+
this.selectionHandler.handlePointerUp(event);
|
|
500
|
+
this._core.rerender();
|
|
501
|
+
}
|
|
502
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
503
|
+
if (this._core.store.state.isScaling === true) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
// The single-finger gesture has ended without becoming a pinch-zoom,
|
|
507
|
+
// so discard any selection group we had saved for potential restoration.
|
|
508
|
+
this._savedSelectionGroupForPinch = null;
|
|
509
|
+
this.lineHandleHandler.handlePointerUp(event);
|
|
510
|
+
this.rotationHandler.handlePointerUp(event);
|
|
511
|
+
this.resizeHandler.handlePointerUp(event);
|
|
512
|
+
this.moveHandler.handlePointerUp(event);
|
|
513
|
+
this.selectionHandler.handlePointerUp(event);
|
|
514
|
+
this._core.rerender();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Gets the object at the pointer event location and wraps it in a selection group.
|
|
519
|
+
* Performs hit testing to ensure the pointer is actually over the object.
|
|
520
|
+
* @param event - The PointerEvent to get the object from
|
|
521
|
+
* @returns A KritzelSelectionGroup containing the object, or null if no object at that location
|
|
522
|
+
*/
|
|
523
|
+
getSelectedObject(event) {
|
|
524
|
+
const path = event.composedPath();
|
|
525
|
+
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
526
|
+
const object = objectElement?.id ? this._core.findObjectById(objectElement.id) : null;
|
|
527
|
+
if (!object) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
const { x, y } = this._core.getCanvasPoint(event);
|
|
531
|
+
if (!object.hitTest(x, y)) {
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
const currentSelectionGroup = this._core.store.selectionGroup;
|
|
535
|
+
if (currentSelectionGroup?.objects.some(selectedObject => selectedObject.id === object.id)) {
|
|
536
|
+
return currentSelectionGroup;
|
|
537
|
+
}
|
|
538
|
+
if (object instanceof KritzelSelectionGroup) {
|
|
539
|
+
return object;
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
const group = KritzelSelectionGroup.create(this._core);
|
|
543
|
+
group.translateX = 0;
|
|
544
|
+
group.translateY = 0;
|
|
545
|
+
group.objectIds = [object.id];
|
|
546
|
+
return group;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Determines the type of resize handle at the pointer location.
|
|
551
|
+
* @param event - The PointerEvent to check for handle type
|
|
552
|
+
* @returns The KritzelHandleType if a resize handle is at the location, undefined otherwise
|
|
553
|
+
*/
|
|
554
|
+
getHandleType(event) {
|
|
555
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
556
|
+
if (!shadowRoot)
|
|
557
|
+
return;
|
|
558
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(event.clientX, event.clientY);
|
|
559
|
+
const handle = elementsAtPoint.find(el => el.classList.contains('resize-handle-overlay'));
|
|
560
|
+
return handle?.classList[1];
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Checks if a resize handle is at the pointer location.
|
|
564
|
+
* @param event - The PointerEvent to check
|
|
565
|
+
* @returns True if a resize handle overlay element is at the pointer location
|
|
566
|
+
*/
|
|
567
|
+
isHandleSelected(event) {
|
|
568
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
569
|
+
if (!shadowRoot)
|
|
570
|
+
return false;
|
|
571
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(event.clientX, event.clientY);
|
|
572
|
+
return elementsAtPoint.some(el => el.classList.contains('resize-handle-overlay'));
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Checks if a rotation handle is at the pointer location.
|
|
576
|
+
* @param event - The PointerEvent to check
|
|
577
|
+
* @returns True if a rotation handle overlay element is at the pointer location
|
|
578
|
+
*/
|
|
579
|
+
isRotationHandleSelected(event) {
|
|
580
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
581
|
+
if (!shadowRoot)
|
|
582
|
+
return false;
|
|
583
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(event.clientX, event.clientY);
|
|
584
|
+
return elementsAtPoint.some(el => el.classList.contains('rotation-handle-overlay'));
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Checks if a line handle (start or end point) is at the pointer location.
|
|
588
|
+
* @param event - The PointerEvent to check
|
|
589
|
+
* @returns True if a line handle overlay element is at the pointer location
|
|
590
|
+
*/
|
|
591
|
+
isLineHandleSelected(event) {
|
|
592
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
593
|
+
if (!shadowRoot)
|
|
594
|
+
return false;
|
|
595
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(event.clientX, event.clientY);
|
|
596
|
+
return elementsAtPoint.some(el => el.classList.contains('selection-line-handle-overlay'));
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Determines the type of line handle (start or end) at the pointer location.
|
|
600
|
+
* @param event - The PointerEvent to check for line handle type
|
|
601
|
+
* @returns The LineHandleType if a line handle is at the location, undefined otherwise
|
|
602
|
+
*/
|
|
603
|
+
getLineHandleType(event) {
|
|
604
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
605
|
+
if (!shadowRoot)
|
|
606
|
+
return;
|
|
607
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(event.clientX, event.clientY);
|
|
608
|
+
const handle = elementsAtPoint.find(el => el.classList.contains('selection-line-handle-overlay'));
|
|
609
|
+
return handle?.classList[1];
|
|
610
|
+
}
|
|
611
|
+
}
|