@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,475 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelLine } from "../objects/line.class";
|
|
3
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
4
|
+
import { KritzelColorHelper } from "../../helpers/color.helper";
|
|
5
|
+
/**
|
|
6
|
+
* Handler for manipulating line object handles (endpoints and control points).
|
|
7
|
+
* Manages dragging of line start/end points and curve control points,
|
|
8
|
+
* including snap-to-object functionality for creating anchored connections.
|
|
9
|
+
*/
|
|
10
|
+
export class KritzelLineHandleHandler extends KritzelBaseHandler {
|
|
11
|
+
initialMouseX = 0;
|
|
12
|
+
initialMouseY = 0;
|
|
13
|
+
initialStartX = 0;
|
|
14
|
+
initialStartY = 0;
|
|
15
|
+
initialEndX = 0;
|
|
16
|
+
initialEndY = 0;
|
|
17
|
+
initialControlX;
|
|
18
|
+
initialControlY;
|
|
19
|
+
initialTranslateX = 0;
|
|
20
|
+
initialTranslateY = 0;
|
|
21
|
+
hasMoved = false;
|
|
22
|
+
/** Current snap target during drag, if any */
|
|
23
|
+
currentSnapTarget = null;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new instance of the line handle handler.
|
|
26
|
+
* @param core - The KritzelCore instance providing access to the drawing engine and state management.
|
|
27
|
+
*/
|
|
28
|
+
constructor(core) {
|
|
29
|
+
super(core);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resets the handler's internal state to its initial values.
|
|
33
|
+
* Called after a drag operation completes to prepare for the next interaction.
|
|
34
|
+
* Clears all stored initial positions, movement flags, and snap candidates.
|
|
35
|
+
*/
|
|
36
|
+
reset() {
|
|
37
|
+
this.initialMouseX = 0;
|
|
38
|
+
this.initialMouseY = 0;
|
|
39
|
+
this.initialStartX = 0;
|
|
40
|
+
this.initialStartY = 0;
|
|
41
|
+
this.initialEndX = 0;
|
|
42
|
+
this.initialEndY = 0;
|
|
43
|
+
this.initialControlX = undefined;
|
|
44
|
+
this.initialControlY = undefined;
|
|
45
|
+
this.initialTranslateX = 0;
|
|
46
|
+
this.initialTranslateY = 0;
|
|
47
|
+
this.hasMoved = false;
|
|
48
|
+
this.currentSnapTarget = null;
|
|
49
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
50
|
+
this._core.anchorManager.clearSnapPreviewCandidate();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Handles pointer down events to initiate line handle dragging.
|
|
54
|
+
* For mouse input, responds only to left clicks.
|
|
55
|
+
* For touch/pen input, responds only when there's exactly one active pointer.
|
|
56
|
+
* @param event - The pointer event containing position and input type information.
|
|
57
|
+
*/
|
|
58
|
+
handlePointerDown(event) {
|
|
59
|
+
if (event.pointerType === 'mouse') {
|
|
60
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
61
|
+
this.startHandleDrag(event);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
65
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
66
|
+
if (activePointers.length === 1) {
|
|
67
|
+
this.startHandleDrag(event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Initializes the drag operation for a line handle.
|
|
73
|
+
* Stores the initial mouse position and line state (endpoints, control point, translation)
|
|
74
|
+
* to enable delta calculations during movement. Also removes any existing anchor
|
|
75
|
+
* for the endpoint being dragged to allow repositioning.
|
|
76
|
+
* @param event - The pointer event that initiated the drag.
|
|
77
|
+
*/
|
|
78
|
+
startHandleDrag(event) {
|
|
79
|
+
const line = this.getSelectedLine();
|
|
80
|
+
if (!line || !this._core.store.state.isLineHandleSelected) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
84
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
85
|
+
this._core.store.state.isLineHandleDragging = true;
|
|
86
|
+
this.initialMouseX = clientX;
|
|
87
|
+
this.initialMouseY = clientY;
|
|
88
|
+
// Store initial line state
|
|
89
|
+
this.initialStartX = line.startX;
|
|
90
|
+
this.initialStartY = line.startY;
|
|
91
|
+
this.initialEndX = line.endX;
|
|
92
|
+
this.initialEndY = line.endY;
|
|
93
|
+
this.initialControlX = line.controlX;
|
|
94
|
+
this.initialControlY = line.controlY;
|
|
95
|
+
this.initialTranslateX = line.translateX;
|
|
96
|
+
this.initialTranslateY = line.translateY;
|
|
97
|
+
// Remove existing anchor for this endpoint when starting to drag
|
|
98
|
+
const handleType = this._core.store.state.lineHandleType;
|
|
99
|
+
if (handleType === 'start' || handleType === 'end') {
|
|
100
|
+
this._core.anchorManager.removeAnchor(line.id, handleType);
|
|
101
|
+
}
|
|
102
|
+
const timeout = this._core.store.state.longTouchTimeout;
|
|
103
|
+
if (timeout) {
|
|
104
|
+
globalThis.clearTimeout?.(timeout);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Handles pointer move events during a line handle drag operation.
|
|
109
|
+
* Updates the appropriate line property based on the handle type being dragged:
|
|
110
|
+
* - 'start': Updates the line's start point, checking for snap targets.
|
|
111
|
+
* - 'end': Updates the line's end point, checking for snap targets.
|
|
112
|
+
* - 'center': Updates the quadratic curve control point, with snap-to-straight behavior.
|
|
113
|
+
*
|
|
114
|
+
* Applies coordinate transformations to convert screen delta to the line's local coordinate system,
|
|
115
|
+
* accounting for viewport scale, object scale, and rotation.
|
|
116
|
+
*
|
|
117
|
+
* @param event - The pointer event containing the current cursor position.
|
|
118
|
+
*/
|
|
119
|
+
handlePointerMove(event) {
|
|
120
|
+
const line = this.getSelectedLine();
|
|
121
|
+
if (!line || !this._core.store.state.isLineHandleDragging) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
125
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
126
|
+
const dx = clientX - this.initialMouseX;
|
|
127
|
+
const dy = clientY - this.initialMouseY;
|
|
128
|
+
const moveThreshold = 3;
|
|
129
|
+
if (Math.abs(dx) > moveThreshold || Math.abs(dy) > moveThreshold) {
|
|
130
|
+
this.hasMoved = true;
|
|
131
|
+
}
|
|
132
|
+
if (!this.hasMoved) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const viewportScale = this._core.store.state.scale;
|
|
136
|
+
const objectScale = line.scale || 1;
|
|
137
|
+
const rotation = line.rotation;
|
|
138
|
+
// Convert mouse delta to world coordinates
|
|
139
|
+
const worldDx = dx / viewportScale;
|
|
140
|
+
const worldDy = dy / viewportScale;
|
|
141
|
+
// Rotate the delta into the line's local coordinate system
|
|
142
|
+
const cos = Math.cos(-rotation);
|
|
143
|
+
const sin = Math.sin(-rotation);
|
|
144
|
+
const localDx = (worldDx * cos - worldDy * sin) * objectScale;
|
|
145
|
+
const localDy = (worldDx * sin + worldDy * cos) * objectScale;
|
|
146
|
+
const handleType = this._core.store.state.lineHandleType;
|
|
147
|
+
if (handleType === 'start') {
|
|
148
|
+
// Calculate world position directly from mouse position for snap detection
|
|
149
|
+
const worldX = (clientX - this._core.store.state.translateX) / viewportScale;
|
|
150
|
+
const worldY = (clientY - this._core.store.state.translateY) / viewportScale;
|
|
151
|
+
// Get other endpoint's anchor to prevent anchoring both to same object
|
|
152
|
+
const otherAnchorId = line.endAnchor?.objectId;
|
|
153
|
+
const previewTarget = this._core.anchorManager.findSnapPreviewTarget(worldX, worldY, line.id, otherAnchorId);
|
|
154
|
+
// Check for snap target
|
|
155
|
+
const snapTarget = this._core.anchorManager.findSnapTarget(worldX, worldY, line.id, otherAnchorId, event.pointerType);
|
|
156
|
+
this.currentSnapTarget = snapTarget;
|
|
157
|
+
const otherEndpointWorld = this.lineLocalToWorld(line, this.initialEndX, this.initialEndY);
|
|
158
|
+
let controlWorld = undefined;
|
|
159
|
+
if (line.controlX !== undefined && line.controlY !== undefined) {
|
|
160
|
+
controlWorld = this.lineLocalToWorld(line, line.controlX, line.controlY);
|
|
161
|
+
}
|
|
162
|
+
if (snapTarget) {
|
|
163
|
+
// Snap to target center - convert world coords to local
|
|
164
|
+
const localCoords = this.worldToLineLocal(line, snapTarget.centerX, snapTarget.centerY);
|
|
165
|
+
this.updateLineEndpoint(line, localCoords.x, localCoords.y, this.initialEndX, this.initialEndY);
|
|
166
|
+
// Calculate edge intersection point using AnchorManager to support curves
|
|
167
|
+
const targetObject = this._core.store.allNonSelectionObjects.find(obj => obj.id === snapTarget.objectId);
|
|
168
|
+
let edgeX;
|
|
169
|
+
let edgeY;
|
|
170
|
+
let t;
|
|
171
|
+
if (targetObject) {
|
|
172
|
+
const clipInfo = this._core.anchorManager.computeAnchorClipInfo(line, 'start', targetObject);
|
|
173
|
+
if (clipInfo) {
|
|
174
|
+
edgeX = clipInfo.worldX;
|
|
175
|
+
edgeY = clipInfo.worldY;
|
|
176
|
+
t = clipInfo.t;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Update snap indicator
|
|
180
|
+
this._core.anchorManager.setSnapPreviewCandidate(null);
|
|
181
|
+
this._core.anchorManager.setSnapCandidate(this.createIndicatorCandidate(line, 'start', snapTarget, otherEndpointWorld, controlWorld, { edgeX, edgeY, t }));
|
|
182
|
+
}
|
|
183
|
+
else if (previewTarget) {
|
|
184
|
+
const newStartX = this.initialStartX + localDx;
|
|
185
|
+
const newStartY = this.initialStartY + localDy;
|
|
186
|
+
this.updateLineEndpoint(line, newStartX, newStartY, this.initialEndX, this.initialEndY);
|
|
187
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
188
|
+
this._core.anchorManager.setSnapPreviewCandidate(this.createIndicatorCandidate(line, 'start', previewTarget, otherEndpointWorld, controlWorld));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// No snap - use regular position
|
|
192
|
+
const newStartX = this.initialStartX + localDx;
|
|
193
|
+
const newStartY = this.initialStartY + localDy;
|
|
194
|
+
this.updateLineEndpoint(line, newStartX, newStartY, this.initialEndX, this.initialEndY);
|
|
195
|
+
// Clear snap indicator
|
|
196
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
197
|
+
this._core.anchorManager.clearSnapPreviewCandidate();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (handleType === 'end') {
|
|
201
|
+
// Calculate world position directly from mouse position for snap detection
|
|
202
|
+
const worldX = (clientX - this._core.store.state.translateX) / viewportScale;
|
|
203
|
+
const worldY = (clientY - this._core.store.state.translateY) / viewportScale;
|
|
204
|
+
// Get other endpoint's anchor to prevent anchoring both to same object
|
|
205
|
+
const otherAnchorId = line.startAnchor?.objectId;
|
|
206
|
+
const previewTarget = this._core.anchorManager.findSnapPreviewTarget(worldX, worldY, line.id, otherAnchorId);
|
|
207
|
+
// Check for snap target
|
|
208
|
+
const snapTarget = this._core.anchorManager.findSnapTarget(worldX, worldY, line.id, otherAnchorId, event.pointerType);
|
|
209
|
+
this.currentSnapTarget = snapTarget;
|
|
210
|
+
const otherEndpointWorld = this.lineLocalToWorld(line, this.initialStartX, this.initialStartY);
|
|
211
|
+
let controlWorld = undefined;
|
|
212
|
+
if (line.controlX !== undefined && line.controlY !== undefined) {
|
|
213
|
+
controlWorld = this.lineLocalToWorld(line, line.controlX, line.controlY);
|
|
214
|
+
}
|
|
215
|
+
if (snapTarget) {
|
|
216
|
+
// Snap to target center - convert world coords to local
|
|
217
|
+
const localCoords = this.worldToLineLocal(line, snapTarget.centerX, snapTarget.centerY);
|
|
218
|
+
this.updateLineEndpoint(line, this.initialStartX, this.initialStartY, localCoords.x, localCoords.y);
|
|
219
|
+
// Calculate edge intersection point using AnchorManager to support curves
|
|
220
|
+
const targetObject = this._core.store.allNonSelectionObjects.find(obj => obj.id === snapTarget.objectId);
|
|
221
|
+
let edgeX;
|
|
222
|
+
let edgeY;
|
|
223
|
+
let t;
|
|
224
|
+
if (targetObject) {
|
|
225
|
+
const clipInfo = this._core.anchorManager.computeAnchorClipInfo(line, 'end', targetObject);
|
|
226
|
+
if (clipInfo) {
|
|
227
|
+
edgeX = clipInfo.worldX;
|
|
228
|
+
edgeY = clipInfo.worldY;
|
|
229
|
+
t = clipInfo.t;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Update snap indicator
|
|
233
|
+
this._core.anchorManager.setSnapPreviewCandidate(null);
|
|
234
|
+
this._core.anchorManager.setSnapCandidate(this.createIndicatorCandidate(line, 'end', snapTarget, otherEndpointWorld, controlWorld, { edgeX, edgeY, t }));
|
|
235
|
+
}
|
|
236
|
+
else if (previewTarget) {
|
|
237
|
+
const newEndX = this.initialEndX + localDx;
|
|
238
|
+
const newEndY = this.initialEndY + localDy;
|
|
239
|
+
this.updateLineEndpoint(line, this.initialStartX, this.initialStartY, newEndX, newEndY);
|
|
240
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
241
|
+
this._core.anchorManager.setSnapPreviewCandidate(this.createIndicatorCandidate(line, 'end', previewTarget, otherEndpointWorld, controlWorld));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// No snap - use regular position
|
|
245
|
+
const newEndX = this.initialEndX + localDx;
|
|
246
|
+
const newEndY = this.initialEndY + localDy;
|
|
247
|
+
this.updateLineEndpoint(line, this.initialStartX, this.initialStartY, newEndX, newEndY);
|
|
248
|
+
// Clear snap indicator
|
|
249
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
250
|
+
this._core.anchorManager.clearSnapPreviewCandidate();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (handleType === 'center') {
|
|
254
|
+
this._core.anchorManager.clearSnapPreviewCandidate();
|
|
255
|
+
this._core.anchorManager.clearSnapCandidate();
|
|
256
|
+
const startControlX = this.initialControlX ?? (this.initialStartX + this.initialEndX) / 2;
|
|
257
|
+
const startControlY = this.initialControlY ?? (this.initialStartY + this.initialEndY) / 2;
|
|
258
|
+
const newControlX = startControlX + localDx * 2;
|
|
259
|
+
const newControlY = startControlY + localDy * 2;
|
|
260
|
+
// Check distance to line segment for snapping back to straight
|
|
261
|
+
const x1 = line.startX;
|
|
262
|
+
const y1 = line.startY;
|
|
263
|
+
const x2 = line.endX;
|
|
264
|
+
const y2 = line.endY;
|
|
265
|
+
const A = newControlX - x1;
|
|
266
|
+
const B = newControlY - y1;
|
|
267
|
+
const C = x2 - x1;
|
|
268
|
+
const D = y2 - y1;
|
|
269
|
+
const dot = A * C + B * D;
|
|
270
|
+
const len_sq = C * C + D * D;
|
|
271
|
+
let param = -1;
|
|
272
|
+
if (len_sq !== 0) {
|
|
273
|
+
param = dot / len_sq;
|
|
274
|
+
}
|
|
275
|
+
let xx, yy;
|
|
276
|
+
if (param < 0) {
|
|
277
|
+
xx = x1;
|
|
278
|
+
yy = y1;
|
|
279
|
+
}
|
|
280
|
+
else if (param > 1) {
|
|
281
|
+
xx = x2;
|
|
282
|
+
yy = y2;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
xx = x1 + param * C;
|
|
286
|
+
yy = y1 + param * D;
|
|
287
|
+
}
|
|
288
|
+
const dx = newControlX - xx;
|
|
289
|
+
const dy = newControlY - yy;
|
|
290
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
291
|
+
// Threshold for snapping back to straight line
|
|
292
|
+
const snapToStraightThreshold = 15;
|
|
293
|
+
if (distance < snapToStraightThreshold) {
|
|
294
|
+
line.updateControlPoint(undefined, undefined);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
line.updateControlPoint(newControlX, newControlY);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
this._core.rerender();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Converts world coordinates to a line's local coordinate system.
|
|
304
|
+
* Accounts for the line's translation, scale, and rotation to transform
|
|
305
|
+
* absolute canvas positions into the line's internal coordinate space.
|
|
306
|
+
*
|
|
307
|
+
* @param line - The line object whose coordinate system to transform into.
|
|
308
|
+
* @param worldX - The X coordinate in world/canvas space.
|
|
309
|
+
* @param worldY - The Y coordinate in world/canvas space.
|
|
310
|
+
* @returns An object containing the transformed local X and Y coordinates.
|
|
311
|
+
*/
|
|
312
|
+
worldToLineLocal(line, worldX, worldY) {
|
|
313
|
+
const dx = (worldX - line.translateX) * line.scale;
|
|
314
|
+
const dy = (worldY - line.translateY) * line.scale;
|
|
315
|
+
const cx = line.totalWidth / 2;
|
|
316
|
+
const cy = line.totalHeight / 2;
|
|
317
|
+
const cos = Math.cos(-line.rotation);
|
|
318
|
+
const sin = Math.sin(-line.rotation);
|
|
319
|
+
const rotatedX = (dx - cx) * cos - (dy - cy) * sin + cx;
|
|
320
|
+
const rotatedY = (dx - cx) * sin + (dy - cy) * cos + cy;
|
|
321
|
+
return {
|
|
322
|
+
x: rotatedX + line.x,
|
|
323
|
+
y: rotatedY + line.y,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Converts a line's local coordinate system to world coordinates.
|
|
328
|
+
* Reverses the transformations applied by worldToLineLocal to convert
|
|
329
|
+
* the line's internal coordinates back to absolute canvas positions.
|
|
330
|
+
*
|
|
331
|
+
* @param line - The line object whose coordinate system to transform from.
|
|
332
|
+
* @param localX - The X coordinate in the line's local space.
|
|
333
|
+
* @param localY - The Y coordinate in the line's local space.
|
|
334
|
+
* @returns An object containing the transformed world X and Y coordinates.
|
|
335
|
+
*/
|
|
336
|
+
lineLocalToWorld(line, localX, localY) {
|
|
337
|
+
const px = localX - line.x;
|
|
338
|
+
const py = localY - line.y;
|
|
339
|
+
const cx = line.totalWidth / 2;
|
|
340
|
+
const cy = line.totalHeight / 2;
|
|
341
|
+
const cos = Math.cos(line.rotation);
|
|
342
|
+
const sin = Math.sin(line.rotation);
|
|
343
|
+
const rotatedX = (px - cx) * cos - (py - cy) * sin + cx;
|
|
344
|
+
const rotatedY = (px - cx) * sin + (py - cy) * cos + cy;
|
|
345
|
+
return {
|
|
346
|
+
x: rotatedX / line.scale + line.translateX,
|
|
347
|
+
y: rotatedY / line.scale + line.translateY,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Updates a line's endpoint positions and recalculates all dependent properties.
|
|
352
|
+
* Computes new bounding boxes for both the old and new line configurations,
|
|
353
|
+
* adjusts the line's position (x, y), dimensions (width, height), and translation
|
|
354
|
+
* to maintain visual consistency while moving endpoints.
|
|
355
|
+
*
|
|
356
|
+
* @param line - The line object to update.
|
|
357
|
+
* @param startX - The new X coordinate for the line's start point in local space.
|
|
358
|
+
* @param startY - The new Y coordinate for the line's start point in local space.
|
|
359
|
+
* @param endX - The new X coordinate for the line's end point in local space.
|
|
360
|
+
* @param endY - The new Y coordinate for the line's end point in local space.
|
|
361
|
+
*/
|
|
362
|
+
updateLineEndpoint(line, startX, startY, endX, endY) {
|
|
363
|
+
// Calculate new bounding box using the static method that accounts for curve extrema
|
|
364
|
+
const { minX, minY, maxX, maxY } = KritzelLine.calculateBoundingBox(startX, startY, endX, endY, line.controlX, line.controlY, line.strokeWidth);
|
|
365
|
+
const newWidth = maxX - minX;
|
|
366
|
+
const newHeight = maxY - minY;
|
|
367
|
+
// Calculate old bounding box
|
|
368
|
+
const { minX: oldMinX, minY: oldMinY, maxX: oldMaxX, maxY: oldMaxY, } = KritzelLine.calculateBoundingBox(this.initialStartX, this.initialStartY, this.initialEndX, this.initialEndY, this.initialControlX, this.initialControlY, line.strokeWidth);
|
|
369
|
+
const oldWidth = oldMaxX - oldMinX;
|
|
370
|
+
const oldHeight = oldMaxY - oldMinY;
|
|
371
|
+
// Calculate center shift in local space
|
|
372
|
+
const shiftX = minX - oldMinX;
|
|
373
|
+
const shiftY = minY - oldMinY;
|
|
374
|
+
const deltaCx = shiftX + (newWidth - oldWidth) / 2;
|
|
375
|
+
const deltaCy = shiftY + (newHeight - oldHeight) / 2;
|
|
376
|
+
// Convert the center shift to world coordinates
|
|
377
|
+
const rotation = line.rotation;
|
|
378
|
+
const cos = Math.cos(rotation);
|
|
379
|
+
const sin = Math.sin(rotation);
|
|
380
|
+
const scale = 1 / line.scale;
|
|
381
|
+
const rotatedDeltaCx = deltaCx * cos - deltaCy * sin;
|
|
382
|
+
const rotatedDeltaCy = deltaCx * sin + deltaCy * cos;
|
|
383
|
+
// Calculate new translate
|
|
384
|
+
const newTranslateX = this.initialTranslateX + (scale * (oldWidth - newWidth)) / 2 + scale * rotatedDeltaCx;
|
|
385
|
+
const newTranslateY = this.initialTranslateY + (scale * (oldHeight - newHeight)) / 2 + scale * rotatedDeltaCy;
|
|
386
|
+
// Update the line properties
|
|
387
|
+
line.startX = startX;
|
|
388
|
+
line.startY = startY;
|
|
389
|
+
line.endX = endX;
|
|
390
|
+
line.endY = endY;
|
|
391
|
+
line.x = minX;
|
|
392
|
+
line.y = minY;
|
|
393
|
+
line.width = newWidth;
|
|
394
|
+
line.height = newHeight;
|
|
395
|
+
// Adjust translateX/Y to compensate for the bounding box shift
|
|
396
|
+
line.translateX = newTranslateX;
|
|
397
|
+
line.translateY = newTranslateY;
|
|
398
|
+
// Clear transient caches so geometry and anchor clipping recompute on demand.
|
|
399
|
+
const linePrivate = line;
|
|
400
|
+
linePrivate._adjustedPoints = null;
|
|
401
|
+
linePrivate._clipInfo = null;
|
|
402
|
+
this._core.store.objects.update(line);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Handles pointer up events to complete a line handle drag operation.
|
|
406
|
+
* If the line was moved and snapped to a target object, creates an anchor connection.
|
|
407
|
+
* Refreshes the selection group dimensions and triggers change events.
|
|
408
|
+
* Finally resets the handler state and triggers a rerender.
|
|
409
|
+
*
|
|
410
|
+
* @param _event - The pointer event (unused, but required by the handler interface).
|
|
411
|
+
*/
|
|
412
|
+
handlePointerUp(_event) {
|
|
413
|
+
if (this._core.store.state.isLineHandleDragging) {
|
|
414
|
+
const line = this.getSelectedLine();
|
|
415
|
+
const handleType = this._core.store.state.lineHandleType;
|
|
416
|
+
if (line && this.hasMoved) {
|
|
417
|
+
// If we were snapped to a target, create the anchor
|
|
418
|
+
if (this.currentSnapTarget && (handleType === 'start' || handleType === 'end')) {
|
|
419
|
+
this._core.anchorManager.setAnchor(line.id, handleType, this.currentSnapTarget.objectId);
|
|
420
|
+
}
|
|
421
|
+
// Refresh the selection group dimensions after line endpoint change
|
|
422
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
423
|
+
if (selectionGroup) {
|
|
424
|
+
selectionGroup.refreshObjectDimensions();
|
|
425
|
+
selectionGroup.update();
|
|
426
|
+
this._core.engine.emitObjectsChange();
|
|
427
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
428
|
+
}
|
|
429
|
+
this._core.store.objects.stopUndoCapturing();
|
|
430
|
+
}
|
|
431
|
+
this._core.store.state.isLineHandleDragging = false;
|
|
432
|
+
this.reset();
|
|
433
|
+
this._core.rerender();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Retrieves the currently selected line object, if any.
|
|
438
|
+
* Returns the line only when exactly one object is selected and it is a KritzelLine instance.
|
|
439
|
+
*
|
|
440
|
+
* @returns The selected KritzelLine object, or null if no single line is selected.
|
|
441
|
+
*/
|
|
442
|
+
getSelectedLine() {
|
|
443
|
+
const selectionGroup = this._core.store.selectionGroup;
|
|
444
|
+
if (!selectionGroup || selectionGroup.objects.length !== 1) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
const object = selectionGroup.objects[0];
|
|
448
|
+
if (object instanceof KritzelLine) {
|
|
449
|
+
return object;
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
createIndicatorCandidate(line, endpoint, target, otherEndpointWorld, controlWorld, clipInfo) {
|
|
454
|
+
return {
|
|
455
|
+
objectId: target.objectId,
|
|
456
|
+
endpoint,
|
|
457
|
+
centerX: target.centerX,
|
|
458
|
+
centerY: target.centerY,
|
|
459
|
+
lineEndpointX: otherEndpointWorld.x,
|
|
460
|
+
lineEndpointY: otherEndpointWorld.y,
|
|
461
|
+
controlX: controlWorld?.x,
|
|
462
|
+
controlY: controlWorld?.y,
|
|
463
|
+
t: clipInfo?.t,
|
|
464
|
+
edgeX: clipInfo?.edgeX,
|
|
465
|
+
edgeY: clipInfo?.edgeY,
|
|
466
|
+
lineStroke: KritzelColorHelper.resolveThemeColor(line.stroke, this._core.themeManager.currentTheme),
|
|
467
|
+
lineStrokeWidth: line.strokeWidth / line.scale,
|
|
468
|
+
arrowOffset: endpoint === 'start'
|
|
469
|
+
? (line.hasStartArrow ? line.getArrowSize('start') / line.scale : undefined)
|
|
470
|
+
: (line.hasEndArrow ? line.getArrowSize('end') / line.scale : undefined),
|
|
471
|
+
arrowStyle: endpoint === 'start' ? line.arrows?.start?.style : line.arrows?.end?.style,
|
|
472
|
+
arrowFill: endpoint === 'start' ? line.getArrowFill('start') : line.getArrowFill('end'),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
}
|