@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,133 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelBaseTool } from "./base-tool.class";
|
|
3
|
+
/**
|
|
4
|
+
* Eraser tool for removing objects from the canvas.
|
|
5
|
+
* Objects touched by the eraser during a drag gesture are marked for removal
|
|
6
|
+
* and deleted when the gesture completes. Supports mouse, touch, and pen input.
|
|
7
|
+
*/
|
|
8
|
+
export class KritzelEraserTool extends KritzelBaseTool {
|
|
9
|
+
toolType = 'eraser';
|
|
10
|
+
/** Timeout handle for delayed touch start activation to prevent accidental erasing */
|
|
11
|
+
touchStartTimeout = null;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new instance of KritzelEraserTool.
|
|
14
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
15
|
+
*/
|
|
16
|
+
constructor(core) {
|
|
17
|
+
super(core);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Handles pointer down events to start the erasing gesture.
|
|
21
|
+
* For mouse input, immediately activates erasing on left-click.
|
|
22
|
+
* For touch/pen input, uses a delayed activation to prevent accidental erasing.
|
|
23
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
24
|
+
*/
|
|
25
|
+
handlePointerDown(event) {
|
|
26
|
+
if (event.pointerType === 'mouse') {
|
|
27
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
28
|
+
this._core.store.state.isErasing = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
32
|
+
this.touchStartTimeout = setTimeout(() => {
|
|
33
|
+
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
34
|
+
this._core.store.state.isErasing = true;
|
|
35
|
+
}
|
|
36
|
+
}, 80);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Handles pointer move events to mark objects for removal during erasing.
|
|
41
|
+
* Performs hit testing on objects under the pointer and marks them for removal.
|
|
42
|
+
* Objects are visually indicated as being erased but not yet removed from the canvas.
|
|
43
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
44
|
+
*/
|
|
45
|
+
handlePointerMove(event) {
|
|
46
|
+
if (event.pointerType === 'mouse') {
|
|
47
|
+
if (this._core.store.state.isErasing) {
|
|
48
|
+
const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
49
|
+
if (selectedObjects.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
const x = this._core.store.state.pointerX;
|
|
52
|
+
const y = this._core.store.state.pointerY;
|
|
53
|
+
selectedObjects.forEach(selectedObject => {
|
|
54
|
+
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
55
|
+
});
|
|
56
|
+
this._core.rerender();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
60
|
+
if (this._core.store.state.pointers.size === 1 && this._core.store.state.isErasing) {
|
|
61
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
62
|
+
if (!shadowRoot)
|
|
63
|
+
return;
|
|
64
|
+
const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
65
|
+
if (selectedObjects.length === 0)
|
|
66
|
+
return;
|
|
67
|
+
const x = this._core.store.state.pointerX;
|
|
68
|
+
const y = this._core.store.state.pointerY;
|
|
69
|
+
selectedObjects.forEach(selectedObject => {
|
|
70
|
+
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
71
|
+
});
|
|
72
|
+
this._core.rerender();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handles pointer up events to complete the erasing gesture.
|
|
78
|
+
* Removes all objects that were marked for removal during the gesture.
|
|
79
|
+
* Clears the erasing state and emits an objects change event if any objects were removed.
|
|
80
|
+
* @param event - The PointerEvent indicating the end of the erasing gesture
|
|
81
|
+
*/
|
|
82
|
+
handlePointerUp(event) {
|
|
83
|
+
if (event.pointerType === 'mouse') {
|
|
84
|
+
if (this._core.store.state.isErasing) {
|
|
85
|
+
const objectsToRemove = this._core.store.allObjects.filter(object => object.markedForRemoval);
|
|
86
|
+
if (objectsToRemove.length > 0) {
|
|
87
|
+
// Seal the previous undo step so create+delete of the same object
|
|
88
|
+
// (e.g. just-drawn shape) don't collapse into a no-op on undo.
|
|
89
|
+
this._core.store.objects.stopUndoCapturing();
|
|
90
|
+
// Group all removals from this sweep into a single undo step.
|
|
91
|
+
this._core.store.objects.transaction(() => {
|
|
92
|
+
objectsToRemove.forEach(object => {
|
|
93
|
+
object.markedForRemoval = false;
|
|
94
|
+
this._core.removeObject(object);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
this._core.rerender();
|
|
98
|
+
}
|
|
99
|
+
this._core.store.state.isErasing = false;
|
|
100
|
+
this._core.engine.emitObjectsChange();
|
|
101
|
+
if (objectsToRemove.length > 0) {
|
|
102
|
+
this._core.engine.emitObjectsRemoved(objectsToRemove);
|
|
103
|
+
this._core.store.objects.stopUndoCapturing();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
108
|
+
clearTimeout(this.touchStartTimeout);
|
|
109
|
+
if (this._core.store.state.isErasing) {
|
|
110
|
+
const objectsToRemove = this._core.store.allObjects.filter(object => object.markedForRemoval);
|
|
111
|
+
if (objectsToRemove.length > 0) {
|
|
112
|
+
// Seal the previous undo step so create+delete of the same object
|
|
113
|
+
// (e.g. just-drawn shape) don't collapse into a no-op on undo.
|
|
114
|
+
this._core.store.objects.stopUndoCapturing();
|
|
115
|
+
// Group all removals from this sweep into a single undo step.
|
|
116
|
+
this._core.store.objects.transaction(() => {
|
|
117
|
+
objectsToRemove.forEach(object => {
|
|
118
|
+
object.markedForRemoval = false;
|
|
119
|
+
this._core.removeObject(object);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
this._core.rerender();
|
|
123
|
+
}
|
|
124
|
+
this._core.store.state.isErasing = false;
|
|
125
|
+
this._core.engine.emitObjectsChange();
|
|
126
|
+
if (objectsToRemove.length > 0) {
|
|
127
|
+
this._core.engine.emitObjectsRemoved(objectsToRemove);
|
|
128
|
+
this._core.store.objects.stopUndoCapturing();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { KritzelImage } from "../objects/image.class";
|
|
2
|
+
import { KritzelBaseTool } from "./base-tool.class";
|
|
3
|
+
import imageCompression from "browser-image-compression";
|
|
4
|
+
import { KritzelImageFileHelper } from "../../helpers/image-file.helper";
|
|
5
|
+
/**
|
|
6
|
+
* Image tool for importing and placing images on the canvas.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. User picks a file.
|
|
10
|
+
* 2. Static images are compressed via `browser-image-compression` (bandwidth win).
|
|
11
|
+
* GIF files retain their original bytes so animation is preserved.
|
|
12
|
+
* 3. Intrinsic dimensions are measured from a temporary object URL.
|
|
13
|
+
* 4. Bytes are uploaded through the asset resolver (write-through:
|
|
14
|
+
* local IndexedDB immediately, remote providers in the background).
|
|
15
|
+
* 5. A `KritzelImage` is created carrying only the resulting asset id
|
|
16
|
+
* and MIME type, then added to the canvas. The renderer resolves
|
|
17
|
+
* the id to a URL via the asset resolver.
|
|
18
|
+
*/
|
|
19
|
+
export class KritzelImageTool extends KritzelBaseTool {
|
|
20
|
+
toolType = 'image';
|
|
21
|
+
/** Hidden file input element for image selection */
|
|
22
|
+
fileInput = null;
|
|
23
|
+
/** Maximum dimension (width or height) for image compression in pixels */
|
|
24
|
+
maxCompressionSize = 1200;
|
|
25
|
+
/** Diagonal offset (in world units) applied between images when multiple are imported at once */
|
|
26
|
+
multiImportOffset = 20;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new instance of KritzelImageTool.
|
|
29
|
+
* Sets up the hidden file input element for image selection.
|
|
30
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
31
|
+
*/
|
|
32
|
+
constructor(core) {
|
|
33
|
+
super(core);
|
|
34
|
+
this.setupFileInput();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Called when the image tool becomes active.
|
|
38
|
+
* Automatically opens the file picker dialog.
|
|
39
|
+
*/
|
|
40
|
+
onActivate() {
|
|
41
|
+
this.openFilePicker();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Opens the native file picker dialog for image selection.
|
|
45
|
+
* Does nothing if the canvas is in disabled state.
|
|
46
|
+
*/
|
|
47
|
+
openFilePicker() {
|
|
48
|
+
if (this._core.store.isDisabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.fileInput?.click();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates and configures the hidden file input element.
|
|
55
|
+
* Sets up event listeners for file selection and cancellation.
|
|
56
|
+
*/
|
|
57
|
+
setupFileInput() {
|
|
58
|
+
this.fileInput = document.createElement('input');
|
|
59
|
+
this.fileInput.type = 'file';
|
|
60
|
+
this.fileInput.accept = 'image/*';
|
|
61
|
+
this.fileInput.multiple = true;
|
|
62
|
+
this.fileInput.style.display = 'none';
|
|
63
|
+
this.fileInput.addEventListener('change', this.handleFileSelect.bind(this));
|
|
64
|
+
this.fileInput.addEventListener('cancel', this.handleCancel.bind(this));
|
|
65
|
+
document.body.appendChild(this.fileInput);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handles the file selection event from the file input.
|
|
69
|
+
* Compresses each selected image if necessaryand places them as a batch on the canvas.
|
|
70
|
+
* Resets the file input value after processing.
|
|
71
|
+
* @param event - The change event from the file input element
|
|
72
|
+
*/
|
|
73
|
+
handleFileSelect(event) {
|
|
74
|
+
const input = event.target;
|
|
75
|
+
const files = input.files ? Array.from(input.files) : [];
|
|
76
|
+
if (files.length === 0) {
|
|
77
|
+
console.info('File selection cancelled by user.');
|
|
78
|
+
this.handleCancel();
|
|
79
|
+
if (input) {
|
|
80
|
+
input.value = '';
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const prepared = files.map(async (file) => {
|
|
85
|
+
const preparedFile = await this.prepareImageFile(file);
|
|
86
|
+
return KritzelImage.fromBlob(this._core, preparedFile);
|
|
87
|
+
});
|
|
88
|
+
Promise.allSettled(prepared)
|
|
89
|
+
.then(results => {
|
|
90
|
+
const images = [];
|
|
91
|
+
for (const result of results) {
|
|
92
|
+
if (result.status === 'fulfilled') {
|
|
93
|
+
images.push(result.value);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error('Error during image compression or processing:', result.reason);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (images.length === 0) {
|
|
100
|
+
this.handleCancel();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.addImagesToStore(images);
|
|
104
|
+
});
|
|
105
|
+
if (input) {
|
|
106
|
+
input.value = '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Prepares an image file for insertion by compressing it if necessary.
|
|
111
|
+
* @param file
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
async prepareImageFile(file) {
|
|
115
|
+
if (KritzelImageFileHelper.isGifFile(file)) {
|
|
116
|
+
return file;
|
|
117
|
+
}
|
|
118
|
+
return imageCompression(file, { maxWidthOrHeight: this.maxCompressionSize });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Adds a batch of prepared images to the canvas store and switches
|
|
122
|
+
* to the selection tool. The first image is centered in the viewport;
|
|
123
|
+
* each subsequent image is offset diagonally so multiple imports do
|
|
124
|
+
* not fully overlap. All images are selected together and a single
|
|
125
|
+
* batch change/added event is emitted.
|
|
126
|
+
*
|
|
127
|
+
* @param images - The prepared `KritzelImage` objects to add
|
|
128
|
+
*/
|
|
129
|
+
addImagesToStore(images) {
|
|
130
|
+
const baseZIndex = this._core.store.currentZIndex;
|
|
131
|
+
images.forEach((image, index) => {
|
|
132
|
+
image.zIndex = baseZIndex + index;
|
|
133
|
+
image.centerInViewport();
|
|
134
|
+
if (index > 0) {
|
|
135
|
+
const offset = index * this.multiImportOffset;
|
|
136
|
+
image.updatePosition(image.translateX + offset, image.translateY + offset);
|
|
137
|
+
}
|
|
138
|
+
this._core.addObject(image);
|
|
139
|
+
});
|
|
140
|
+
this._core.store.setState('activeTool', this._core.toolRegistry.getTool('selection'));
|
|
141
|
+
this._core.selectObjects(images);
|
|
142
|
+
this._core.engine.emitObjectsChange();
|
|
143
|
+
this._core.engine.emitObjectsAdded(images);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Handles cancellation of the file picker or errors during image processing.
|
|
147
|
+
* Switches back to the selection tool without adding any image.
|
|
148
|
+
*/
|
|
149
|
+
handleCancel() {
|
|
150
|
+
this._core.store.setState('activeTool', this._core.toolRegistry.getTool('selection'));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelLine } from "../objects/line.class";
|
|
3
|
+
import { KritzelBaseTool } from "./base-tool.class";
|
|
4
|
+
import { KritzelSelectionGroup } from "../objects/selection-group.class";
|
|
5
|
+
import { DEFAULT_COLOR_PALETTE } from "../../constants/color-palette.constants";
|
|
6
|
+
import { DEFAULT_STROKE_SIZES } from "../../constants/stroke-size.constants";
|
|
7
|
+
/**
|
|
8
|
+
* Line tool for drawing straight lines on the canvas.
|
|
9
|
+
* Creates lines by tracking the start and end points of a drag gesture.
|
|
10
|
+
* Supports configurable stroke color, width, opacity, and arrow heads.
|
|
11
|
+
* Automatically switches to selection tool after line completion.
|
|
12
|
+
*/
|
|
13
|
+
export class KritzelLineTool extends KritzelBaseTool {
|
|
14
|
+
toolType = 'line';
|
|
15
|
+
/** The stroke color of the line (supports theme-aware light/dark colors) */
|
|
16
|
+
color = DEFAULT_COLOR_PALETTE[0];
|
|
17
|
+
/** The stroke width of the line in pixels */
|
|
18
|
+
size = 4;
|
|
19
|
+
/** The opacity of the line (0-1) */
|
|
20
|
+
opacity = 1;
|
|
21
|
+
/** Available color palette for the line tool */
|
|
22
|
+
palette = [...DEFAULT_COLOR_PALETTE];
|
|
23
|
+
/** Available stroke size presets for the line tool */
|
|
24
|
+
sizes = [...DEFAULT_STROKE_SIZES];
|
|
25
|
+
/** Arrow head configuration for lines created with this tool */
|
|
26
|
+
arrows;
|
|
27
|
+
/** X coordinate of the line's starting point */
|
|
28
|
+
_startX = 0;
|
|
29
|
+
/** Y coordinate of the line's starting point */
|
|
30
|
+
_startY = 0;
|
|
31
|
+
/** Tracks the ID of the line currently being drawn */
|
|
32
|
+
_currentLineId = null;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new instance of KritzelLineTool.
|
|
35
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
36
|
+
*/
|
|
37
|
+
constructor(core) {
|
|
38
|
+
super(core);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Handles pointer down events to start drawing a new line.
|
|
42
|
+
* Creates a new KritzelLine object at the pointer position with start and end points at the same location.
|
|
43
|
+
* Supports both mouse (left-click) and touch/pen input.
|
|
44
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
45
|
+
*/
|
|
46
|
+
handlePointerDown(event) {
|
|
47
|
+
if (event.cancelable) {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
}
|
|
50
|
+
if (event.pointerType === 'mouse') {
|
|
51
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
52
|
+
this._core.store.state.isDrawing = true;
|
|
53
|
+
const viewportScale = this._core.store.state.scale;
|
|
54
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
55
|
+
const divider = lockScale ? viewportScale : 1;
|
|
56
|
+
const x = (event.clientX - this._core.store.offsetX) / divider;
|
|
57
|
+
const y = (event.clientY - this._core.store.offsetY) / divider;
|
|
58
|
+
this._startX = x;
|
|
59
|
+
this._startY = y;
|
|
60
|
+
const line = KritzelLine.create(this._core, {
|
|
61
|
+
startX: x,
|
|
62
|
+
startY: y,
|
|
63
|
+
endX: x,
|
|
64
|
+
endY: y,
|
|
65
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
66
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
67
|
+
scale: lockScale ? 1 : viewportScale,
|
|
68
|
+
stroke: this.color,
|
|
69
|
+
strokeWidth: this.size,
|
|
70
|
+
opacity: this.opacity,
|
|
71
|
+
arrows: this.arrows,
|
|
72
|
+
});
|
|
73
|
+
line.isCompleted = false;
|
|
74
|
+
this._currentLineId = line.id;
|
|
75
|
+
this._core.store.objects.insert(line);
|
|
76
|
+
this._core.store.objects?.setActiveDrawingObject(line.id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
80
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
81
|
+
if (activePointers.length === 1) {
|
|
82
|
+
const viewportScale = this._core.store.state.scale;
|
|
83
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
84
|
+
const divider = lockScale ? viewportScale : 1;
|
|
85
|
+
const x = Math.round((activePointers[0].clientX - this._core.store.offsetX) / divider);
|
|
86
|
+
const y = Math.round((activePointers[0].clientY - this._core.store.offsetY) / divider);
|
|
87
|
+
this._core.store.state.isDrawing = true;
|
|
88
|
+
this._startX = x;
|
|
89
|
+
this._startY = y;
|
|
90
|
+
const line = KritzelLine.create(this._core, {
|
|
91
|
+
startX: x,
|
|
92
|
+
startY: y,
|
|
93
|
+
endX: x,
|
|
94
|
+
endY: y,
|
|
95
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
96
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
97
|
+
scale: lockScale ? 1 : viewportScale,
|
|
98
|
+
stroke: this.color,
|
|
99
|
+
strokeWidth: this.size,
|
|
100
|
+
opacity: this.opacity,
|
|
101
|
+
arrows: this.arrows,
|
|
102
|
+
});
|
|
103
|
+
line.isCompleted = false;
|
|
104
|
+
this._currentLineId = line.id;
|
|
105
|
+
this._core.store.objects.insert(line);
|
|
106
|
+
this._core.store.objects?.setActiveDrawingObject(line.id);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Handles pointer move events to update the line's end point while drawing.
|
|
112
|
+
* Updates the current line's end coordinates to follow the pointer position.
|
|
113
|
+
* Only processes events when actively drawing (isDrawing state is true).
|
|
114
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
115
|
+
*/
|
|
116
|
+
handlePointerMove(event) {
|
|
117
|
+
if (event.cancelable) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
}
|
|
120
|
+
if (event.pointerType === 'mouse') {
|
|
121
|
+
if (this._core.store.state.isDrawing && this._currentLineId) {
|
|
122
|
+
const currentLine = this._core.store.objects.findById(this._currentLineId);
|
|
123
|
+
if (currentLine) {
|
|
124
|
+
const viewportScale = this._core.store.state.scale;
|
|
125
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
126
|
+
const divider = lockScale ? viewportScale : 1;
|
|
127
|
+
const x = (event.clientX - this._core.store.offsetX) / divider;
|
|
128
|
+
const y = (event.clientY - this._core.store.offsetY) / divider;
|
|
129
|
+
const updatedLine = KritzelLine.create(this._core, {
|
|
130
|
+
startX: this._startX,
|
|
131
|
+
startY: this._startY,
|
|
132
|
+
endX: x,
|
|
133
|
+
endY: y,
|
|
134
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
135
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
136
|
+
scale: lockScale ? 1 : viewportScale,
|
|
137
|
+
stroke: this.color,
|
|
138
|
+
strokeWidth: this.size,
|
|
139
|
+
opacity: this.opacity,
|
|
140
|
+
arrows: this.arrows,
|
|
141
|
+
});
|
|
142
|
+
updatedLine.id = currentLine.id;
|
|
143
|
+
updatedLine.workspaceId = currentLine.workspaceId;
|
|
144
|
+
updatedLine.zIndex = currentLine.zIndex;
|
|
145
|
+
updatedLine.isCompleted = false;
|
|
146
|
+
this._core.store.objects.update(updatedLine);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
151
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
152
|
+
if (activePointers.length === 1 && this._currentLineId) {
|
|
153
|
+
const currentLine = this._core.store.objects.findById(this._currentLineId);
|
|
154
|
+
if (currentLine) {
|
|
155
|
+
const viewportScale = this._core.store.state.scale;
|
|
156
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
157
|
+
const divider = lockScale ? viewportScale : 1;
|
|
158
|
+
const x = Math.round((activePointers[0].clientX - this._core.store.offsetX) / divider);
|
|
159
|
+
const y = Math.round((activePointers[0].clientY - this._core.store.offsetY) / divider);
|
|
160
|
+
const updatedLine = KritzelLine.create(this._core, {
|
|
161
|
+
startX: this._startX,
|
|
162
|
+
startY: this._startY,
|
|
163
|
+
endX: x,
|
|
164
|
+
endY: y,
|
|
165
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
166
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
167
|
+
scale: lockScale ? 1 : viewportScale,
|
|
168
|
+
stroke: this.color,
|
|
169
|
+
strokeWidth: this.size,
|
|
170
|
+
opacity: this.opacity,
|
|
171
|
+
arrows: this.arrows,
|
|
172
|
+
});
|
|
173
|
+
updatedLine.id = currentLine.id;
|
|
174
|
+
updatedLine.workspaceId = currentLine.workspaceId;
|
|
175
|
+
updatedLine.zIndex = currentLine.zIndex;
|
|
176
|
+
updatedLine.isCompleted = false;
|
|
177
|
+
this._core.store.objects.update(updatedLine);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Handles pointer up events to complete the current line.
|
|
184
|
+
* Marks the line as completed, updates the store, emits an objects change event,
|
|
185
|
+
* and switches to selection tool with the drawn line selected.
|
|
186
|
+
* @param event - The PointerEvent indicating the end of the drawing gesture
|
|
187
|
+
*/
|
|
188
|
+
handlePointerUp(event) {
|
|
189
|
+
if (event.cancelable) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
}
|
|
192
|
+
if (event.pointerType === 'mouse') {
|
|
193
|
+
if (this._core.store.state.isDrawing) {
|
|
194
|
+
this._core.store.state.isDrawing = false;
|
|
195
|
+
if (this._currentLineId) {
|
|
196
|
+
const currentLine = this._core.store.objects.findById(this._currentLineId);
|
|
197
|
+
if (currentLine) {
|
|
198
|
+
currentLine.isCompleted = true;
|
|
199
|
+
this._core.store.objects.update(currentLine);
|
|
200
|
+
this._core.engine.emitObjectsChange();
|
|
201
|
+
this._core.engine.emitObjectsAdded([currentLine]);
|
|
202
|
+
// Switch to selection tool and select the drawn line
|
|
203
|
+
this.selectLineAndSwitchTool(currentLine);
|
|
204
|
+
}
|
|
205
|
+
this._core.store.objects?.setActiveDrawingObject(null);
|
|
206
|
+
this._currentLineId = null;
|
|
207
|
+
this._core.store.objects?.stopUndoCapturing();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
212
|
+
if (this._core.store.state.isDrawing) {
|
|
213
|
+
this._core.store.state.isDrawing = false;
|
|
214
|
+
if (this._currentLineId) {
|
|
215
|
+
const currentLine = this._core.store.objects.findById(this._currentLineId);
|
|
216
|
+
if (currentLine) {
|
|
217
|
+
currentLine.isCompleted = true;
|
|
218
|
+
this._core.store.objects.update(currentLine);
|
|
219
|
+
this._core.engine.emitObjectsChange();
|
|
220
|
+
this._core.engine.emitObjectsAdded([currentLine]);
|
|
221
|
+
// Switch to selection tool and select the drawn line
|
|
222
|
+
this.selectLineAndSwitchTool(currentLine);
|
|
223
|
+
}
|
|
224
|
+
this._core.store.objects?.setActiveDrawingObject(null);
|
|
225
|
+
this._currentLineId = null;
|
|
226
|
+
this._core.store.objects?.stopUndoCapturing();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Creates a selection group with the drawn line, selects it, and switches to the selection tool.
|
|
233
|
+
* This provides immediate editing capability for the newly drawn line.
|
|
234
|
+
* @param line - The KritzelLine object to select
|
|
235
|
+
*/
|
|
236
|
+
selectLineAndSwitchTool(line) {
|
|
237
|
+
// Create a selection group with the drawn line
|
|
238
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
239
|
+
selectionGroup.addOrRemove(line);
|
|
240
|
+
selectionGroup.isSelected = true;
|
|
241
|
+
selectionGroup.rotation = line.rotation;
|
|
242
|
+
// Add the selection group
|
|
243
|
+
this._core.addSelectionGroup(selectionGroup);
|
|
244
|
+
// Switch to selection tool
|
|
245
|
+
this._core.store.setState('activeTool', this._core.toolRegistry.getTool('selection'));
|
|
246
|
+
// Rerender
|
|
247
|
+
this._core.rerender();
|
|
248
|
+
}
|
|
249
|
+
}
|