@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,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A quadtree data structure for efficient spatial indexing of objects.
|
|
3
|
+
* Quadtrees recursively subdivide 2D space into four quadrants to enable
|
|
4
|
+
* fast spatial queries like finding all objects within a given region.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of objects stored in the quadtree, must extend KritzelBaseObject
|
|
7
|
+
*/
|
|
8
|
+
export class KritzelQuadtree {
|
|
9
|
+
bounds;
|
|
10
|
+
capacity;
|
|
11
|
+
objects = [];
|
|
12
|
+
children = null;
|
|
13
|
+
_size = 0;
|
|
14
|
+
/**
|
|
15
|
+
* Total number of objects in the quadtree (O(1) access).
|
|
16
|
+
* @returns The count of all objects stored in this quadtree and its children
|
|
17
|
+
*/
|
|
18
|
+
get size() {
|
|
19
|
+
return this._size;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new quadtree with the specified bounds and capacity.
|
|
23
|
+
*
|
|
24
|
+
* @param bounds - The bounding box defining the spatial region covered by this quadtree
|
|
25
|
+
* @param capacity - Maximum number of objects a node can hold before subdividing (default: 16)
|
|
26
|
+
*/
|
|
27
|
+
constructor(bounds, capacity = 16) {
|
|
28
|
+
this.bounds = bounds;
|
|
29
|
+
this.capacity = capacity;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resets the quadtree to its initial empty state.
|
|
33
|
+
* Clears all stored objects and removes all child nodes.
|
|
34
|
+
*/
|
|
35
|
+
reset() {
|
|
36
|
+
this.objects = [];
|
|
37
|
+
this.children = null;
|
|
38
|
+
this._size = 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Inserts an object into the quadtree.
|
|
42
|
+
* If the current node exceeds capacity, it will subdivide and delegate
|
|
43
|
+
* the insertion to the appropriate child quadrant.
|
|
44
|
+
*
|
|
45
|
+
* @param object - The object to insert, must have a rotatedBoundingBox property
|
|
46
|
+
* @returns `true` if the object was successfully inserted, `false` if it doesn't intersect the quadtree bounds
|
|
47
|
+
*/
|
|
48
|
+
insert(object) {
|
|
49
|
+
if (!this.intersects(object.rotatedBoundingBox, this.bounds)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (this.objects.length < this.capacity && this.children === null) {
|
|
53
|
+
this.objects.push(object);
|
|
54
|
+
this._size++;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (this.children === null) {
|
|
58
|
+
this.subdivide();
|
|
59
|
+
}
|
|
60
|
+
for (const child of this.children) {
|
|
61
|
+
if (child.insert(object)) {
|
|
62
|
+
this._size++;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Updates an existing object in the quadtree by matching its ID.
|
|
70
|
+
* Searches through the tree to find the object and replaces it with the new reference.
|
|
71
|
+
* Note: This does not reposition the object if its bounding box has changed.
|
|
72
|
+
*
|
|
73
|
+
* @param object - The updated object with the same ID as the one to replace
|
|
74
|
+
* @returns `true` if the object was found and updated, `false` otherwise
|
|
75
|
+
*/
|
|
76
|
+
update(object) {
|
|
77
|
+
const index = this.objects.findIndex(o => o.id === object.id);
|
|
78
|
+
if (index !== -1) {
|
|
79
|
+
this.objects[index] = object;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (this.children !== null) {
|
|
83
|
+
for (const child of this.children) {
|
|
84
|
+
if (child.update(object)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reindexes an existing object by removing it from its current node and
|
|
93
|
+
* reinserting it based on its latest bounding box.
|
|
94
|
+
*
|
|
95
|
+
* @param object - The updated object to reindex
|
|
96
|
+
* @returns `true` if the object was found and reinserted, `false` otherwise
|
|
97
|
+
*/
|
|
98
|
+
reindex(object) {
|
|
99
|
+
const removed = this.remove(o => o.id === object.id);
|
|
100
|
+
if (removed === 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return this.insert(object);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Removes objects from the quadtree that match the given predicate.
|
|
107
|
+
* Recursively searches through all nodes and removes matching objects.
|
|
108
|
+
*
|
|
109
|
+
* @param predicate - A function that returns `true` for objects that should be removed
|
|
110
|
+
* @returns The total number of objects removed from the quadtree
|
|
111
|
+
*/
|
|
112
|
+
remove(predicate) {
|
|
113
|
+
let removed = 0;
|
|
114
|
+
const index = this.objects.findIndex(o => predicate(o));
|
|
115
|
+
if (index !== -1) {
|
|
116
|
+
this.objects.splice(index, 1);
|
|
117
|
+
removed++;
|
|
118
|
+
}
|
|
119
|
+
if (this.children !== null) {
|
|
120
|
+
for (const child of this.children) {
|
|
121
|
+
removed += child.remove(predicate);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
this._size -= removed;
|
|
125
|
+
return removed;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Finds all objects whose bounding boxes intersect with the given range.
|
|
129
|
+
* This is the primary spatial query method for efficient object retrieval.
|
|
130
|
+
*
|
|
131
|
+
* @param range - The bounding box to query against
|
|
132
|
+
* @returns An array of all objects that intersect with the given range
|
|
133
|
+
*/
|
|
134
|
+
query(range) {
|
|
135
|
+
const results = [];
|
|
136
|
+
this._queryInto(range, results);
|
|
137
|
+
return results;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Internal method that collects query results into a pre-allocated array.
|
|
141
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
142
|
+
*
|
|
143
|
+
* @param range - The bounding box to query against
|
|
144
|
+
* @param results - The array to collect matching objects into
|
|
145
|
+
*/
|
|
146
|
+
_queryInto(range, results) {
|
|
147
|
+
if (!this.intersects(range, this.bounds)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
for (const object of this.objects) {
|
|
151
|
+
if (this.intersects(object.rotatedBoundingBox, range)) {
|
|
152
|
+
results.push(object);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (this.children !== null) {
|
|
156
|
+
for (const child of this.children) {
|
|
157
|
+
child._queryInto(range, results);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Filters all objects in the quadtree using a custom predicate function.
|
|
163
|
+
* Unlike `query`, this method checks all objects regardless of spatial location.
|
|
164
|
+
*
|
|
165
|
+
* @param predicate - A function that returns `true` for objects to include in results
|
|
166
|
+
* @returns An array of all objects that satisfy the predicate
|
|
167
|
+
*/
|
|
168
|
+
filter(predicate) {
|
|
169
|
+
const results = [];
|
|
170
|
+
this._filterInto(predicate, results);
|
|
171
|
+
return results;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Internal method that collects filter results into a pre-allocated array.
|
|
175
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
176
|
+
*
|
|
177
|
+
* @param predicate - A function that returns `true` for objects to include
|
|
178
|
+
* @param results - The array to collect matching objects into
|
|
179
|
+
*/
|
|
180
|
+
_filterInto(predicate, results) {
|
|
181
|
+
for (const obj of this.objects) {
|
|
182
|
+
if (predicate(obj)) {
|
|
183
|
+
results.push(obj);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (this.children !== null) {
|
|
187
|
+
for (const child of this.children) {
|
|
188
|
+
child._filterInto(predicate, results);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Retrieves all objects stored in the quadtree.
|
|
194
|
+
* Traverses the entire tree structure to collect every object.
|
|
195
|
+
*
|
|
196
|
+
* @returns An array containing all objects in the quadtree
|
|
197
|
+
*/
|
|
198
|
+
allObjects() {
|
|
199
|
+
const results = [];
|
|
200
|
+
this._collectAllInto(results);
|
|
201
|
+
return results;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Internal method that collects all objects into a pre-allocated array.
|
|
205
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
206
|
+
*
|
|
207
|
+
* @param results - The array to collect all objects into
|
|
208
|
+
*/
|
|
209
|
+
_collectAllInto(results) {
|
|
210
|
+
for (const obj of this.objects) {
|
|
211
|
+
results.push(obj);
|
|
212
|
+
}
|
|
213
|
+
if (this.children !== null) {
|
|
214
|
+
for (const child of this.children) {
|
|
215
|
+
child._collectAllInto(results);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Subdivides this quadtree node into four child quadrants.
|
|
221
|
+
* Called automatically when the node's capacity is exceeded.
|
|
222
|
+
* Creates children for: Northwest (NW), Northeast (NE), Southwest (SW), Southeast (SE).
|
|
223
|
+
*/
|
|
224
|
+
subdivide() {
|
|
225
|
+
const { x, y, z, width, height } = this.bounds;
|
|
226
|
+
const halfWidth = width / 2;
|
|
227
|
+
const halfHeight = height / 2;
|
|
228
|
+
// Create 4 quadrants: NW, NE, SW, SE
|
|
229
|
+
this.children = [
|
|
230
|
+
new KritzelQuadtree({ x, y, z, width: halfWidth, height: halfHeight }, this.capacity), // Northwest
|
|
231
|
+
new KritzelQuadtree({ x: x + halfWidth, y, z, width: halfWidth, height: halfHeight }, this.capacity), // Northeast
|
|
232
|
+
new KritzelQuadtree({ x, y: y + halfHeight, z, width: halfWidth, height: halfHeight }, this.capacity), // Southwest
|
|
233
|
+
new KritzelQuadtree({ x: x + halfWidth, y: y + halfHeight, z, width: halfWidth, height: halfHeight }, this.capacity), // Southeast
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Checks whether two bounding boxes intersect (overlap) each other.
|
|
238
|
+
* Uses axis-aligned bounding box (AABB) collision detection.
|
|
239
|
+
*
|
|
240
|
+
* @param a - The first bounding box
|
|
241
|
+
* @param b - The second bounding box
|
|
242
|
+
* @returns `true` if the bounding boxes overlap, `false` otherwise
|
|
243
|
+
*/
|
|
244
|
+
intersects(a, b) {
|
|
245
|
+
return !(a.x >= b.x + b.width || // a is completely to the right of b
|
|
246
|
+
a.x + a.width <= b.x || // a is completely to the left of b
|
|
247
|
+
a.y >= b.y + b.height || // a is completely below b
|
|
248
|
+
a.y + a.height <= b.y // a is completely above b
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all drawing tools in Kritzel.
|
|
3
|
+
* Provides common functionality and defines the interface that all tools must implement.
|
|
4
|
+
* Tools handle user interactions (pointer events, wheel events) and can be serialized/deserialized.
|
|
5
|
+
*/
|
|
6
|
+
export class KritzelBaseTool {
|
|
7
|
+
/** Class name identifier used for serialization/deserialization */
|
|
8
|
+
__class__ = this.constructor.name;
|
|
9
|
+
/** Identifies the tool type for config resolution (survives minification and dual-package bundling) */
|
|
10
|
+
toolType = 'base';
|
|
11
|
+
/** Human-readable name of the tool */
|
|
12
|
+
name = 'base-tool';
|
|
13
|
+
/** Reference to the Kritzel core instance for accessing store, viewport, and other core functionality */
|
|
14
|
+
_core;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of KritzelBaseTool.
|
|
17
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
18
|
+
*/
|
|
19
|
+
constructor(core) {
|
|
20
|
+
this._core = core;
|
|
21
|
+
void this._core; // Avoid unused variable warning
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Called when the tool becomes the active tool.
|
|
25
|
+
* Override in subclasses to perform initialization when the tool is selected.
|
|
26
|
+
*/
|
|
27
|
+
onActivate() {
|
|
28
|
+
// default implementation
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Called when the tool is deactivated (another tool becomes active).
|
|
32
|
+
* Override in subclasses to perform cleanup when the tool is deselected.
|
|
33
|
+
*/
|
|
34
|
+
onDeactivate() {
|
|
35
|
+
// default implementation
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Handles pointer down events (mouse click, touch start, pen down).
|
|
39
|
+
* Override in subclasses to implement tool-specific behavior when the user starts an interaction.
|
|
40
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
41
|
+
*/
|
|
42
|
+
handlePointerDown(_event) {
|
|
43
|
+
// default implementation
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Handles pointer move events (mouse move, touch move, pen move).
|
|
47
|
+
* Override in subclasses to implement tool-specific behavior during dragging or hovering.
|
|
48
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
49
|
+
*/
|
|
50
|
+
handlePointerMove(_event) {
|
|
51
|
+
// default implementation
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handles pointer up events (mouse release, touch end, pen up).
|
|
55
|
+
* Override in subclasses to implement tool-specific behavior when the user ends an interaction.
|
|
56
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
57
|
+
*/
|
|
58
|
+
handlePointerUp(_event) {
|
|
59
|
+
// default implementation
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handles mouse wheel events for zooming or scrolling.
|
|
63
|
+
* Override in subclasses to implement tool-specific wheel behavior.
|
|
64
|
+
* @param _event - The WheelEvent containing scroll delta and modifier key information
|
|
65
|
+
*/
|
|
66
|
+
handleWheel(_event) {
|
|
67
|
+
// default implementation
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Serializes the tool to a plain object for persistence or transfer.
|
|
71
|
+
* @returns An object containing the tool's class name and name property
|
|
72
|
+
*/
|
|
73
|
+
serialize() {
|
|
74
|
+
return {
|
|
75
|
+
__class__: this.__class__,
|
|
76
|
+
name: this.name,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Deserializes a plain object into this tool instance.
|
|
81
|
+
* @param object - The serialized tool data to restore
|
|
82
|
+
* @returns This tool instance with restored properties
|
|
83
|
+
*/
|
|
84
|
+
deserialize(object) {
|
|
85
|
+
Object.assign(this, object);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { KritzelEventHelper } from "../../helpers/event.helper";
|
|
2
|
+
import { KritzelPath } from "../objects/path.class";
|
|
3
|
+
import { KritzelBaseTool } from "./base-tool.class";
|
|
4
|
+
import { DEFAULT_COLOR_PALETTE } from "../../constants/color-palette.constants";
|
|
5
|
+
import { DEFAULT_STROKE_SIZES } from "../../constants/stroke-size.constants";
|
|
6
|
+
/**
|
|
7
|
+
* Brush tool for free-hand drawing on the canvas.
|
|
8
|
+
* Creates smooth paths by tracking pointer movement and rendering stroke paths.
|
|
9
|
+
* Supports mouse, touch, and pen input with configurable color, size, and opacity.
|
|
10
|
+
*/
|
|
11
|
+
export class KritzelBrushTool extends KritzelBaseTool {
|
|
12
|
+
toolType = 'brush';
|
|
13
|
+
/** The color of the brush stroke (supports theme-aware light/dark colors) */
|
|
14
|
+
color = DEFAULT_COLOR_PALETTE[0];
|
|
15
|
+
/** The width of the brush stroke in pixels */
|
|
16
|
+
size = 6;
|
|
17
|
+
/** The opacity of the brush stroke (0-1) */
|
|
18
|
+
opacity = 1;
|
|
19
|
+
/** Available color palette for the brush tool */
|
|
20
|
+
palette = [...DEFAULT_COLOR_PALETTE];
|
|
21
|
+
/** Available stroke size presets for the brush tool */
|
|
22
|
+
sizes = [...DEFAULT_STROKE_SIZES];
|
|
23
|
+
/**
|
|
24
|
+
* Minimum distance in screen pixels between two consecutive stored points.
|
|
25
|
+
* Pointer-move samples closer than this to the previously stored point are
|
|
26
|
+
* dropped. This shrinks the path's `points` array (which is fully
|
|
27
|
+
* re-serialized on every Yjs update during a stroke), reducing per-stroke
|
|
28
|
+
* websocket traffic without visible quality loss — `perfect-freehand`
|
|
29
|
+
* already smooths the rendered stroke.
|
|
30
|
+
*/
|
|
31
|
+
static MIN_POINT_DISTANCE_PX = 3;
|
|
32
|
+
/** Tracks the ID of the path currently being drawn */
|
|
33
|
+
_currentPathId = null;
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if (x, y) is far enough from the last stored point on
|
|
36
|
+
* `currentPath` to be appended. Distance is measured in the same coordinate
|
|
37
|
+
* system the points themselves are stored in (world units when
|
|
38
|
+
* lockDrawingScale is true, screen units otherwise), with the threshold
|
|
39
|
+
* scaled by `divider` so the filter is always ~1 screen pixel.
|
|
40
|
+
*
|
|
41
|
+
* Uses squared distance to avoid a per-move `Math.sqrt`.
|
|
42
|
+
*/
|
|
43
|
+
shouldAppendPoint(currentPath, x, y, divider) {
|
|
44
|
+
const points = currentPath.points;
|
|
45
|
+
if (!points || points.length === 0) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const last = points[points.length - 1];
|
|
49
|
+
const dx = x - last[0];
|
|
50
|
+
const dy = y - last[1];
|
|
51
|
+
const threshold = KritzelBrushTool.MIN_POINT_DISTANCE_PX / divider;
|
|
52
|
+
return dx * dx + dy * dy >= threshold * threshold;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new instance of KritzelBrushTool.
|
|
56
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
57
|
+
*/
|
|
58
|
+
constructor(core) {
|
|
59
|
+
super(core);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handles pointer down events to start drawing a new path.
|
|
63
|
+
* Creates a new KritzelPath object at the pointer position and adds it to the canvas.
|
|
64
|
+
* Supports both mouse (left-click) and touch/pen input.
|
|
65
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
66
|
+
*/
|
|
67
|
+
handlePointerDown(event) {
|
|
68
|
+
if (event.cancelable) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
if (event.pointerType === 'mouse') {
|
|
72
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
73
|
+
this._core.store.state.isDrawing = true;
|
|
74
|
+
const viewportScale = this._core.store.state.scale;
|
|
75
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
76
|
+
const divider = lockScale ? viewportScale : 1;
|
|
77
|
+
const x = (event.clientX - this._core.store.offsetX) / divider;
|
|
78
|
+
const y = (event.clientY - this._core.store.offsetY) / divider;
|
|
79
|
+
const path = KritzelPath.create(this._core, {
|
|
80
|
+
points: [[x, y]],
|
|
81
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
82
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
83
|
+
scale: lockScale ? 1 : viewportScale,
|
|
84
|
+
fill: this.color,
|
|
85
|
+
strokeWidth: this.size,
|
|
86
|
+
opacity: this.opacity,
|
|
87
|
+
});
|
|
88
|
+
path.isCompleted = false;
|
|
89
|
+
this._currentPathId = path.id;
|
|
90
|
+
this._core.store.objects.insert(path);
|
|
91
|
+
this._core.store.objects?.setActiveDrawingObject(path.id);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
95
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
96
|
+
if (activePointers.length === 1) {
|
|
97
|
+
const viewportScale = this._core.store.state.scale;
|
|
98
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
99
|
+
const divider = lockScale ? viewportScale : 1;
|
|
100
|
+
const x = Math.round((activePointers[0].clientX - this._core.store.offsetX) / divider);
|
|
101
|
+
const y = Math.round((activePointers[0].clientY - this._core.store.offsetY) / divider);
|
|
102
|
+
this._core.store.state.isDrawing = true;
|
|
103
|
+
const path = KritzelPath.create(this._core, {
|
|
104
|
+
points: [[x, y]],
|
|
105
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
106
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
107
|
+
scale: lockScale ? 1 : viewportScale,
|
|
108
|
+
fill: this.color,
|
|
109
|
+
strokeWidth: this.size,
|
|
110
|
+
opacity: this.opacity,
|
|
111
|
+
});
|
|
112
|
+
path.isCompleted = false;
|
|
113
|
+
this._currentPathId = path.id;
|
|
114
|
+
this._core.store.objects.insert(path);
|
|
115
|
+
this._core.store.objects?.setActiveDrawingObject(path.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Handles pointer move events to extend the current path while drawing.
|
|
121
|
+
* Adds new points to the current path as the pointer moves across the canvas.
|
|
122
|
+
* Only processes events when actively drawing (isDrawing state is true).
|
|
123
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
124
|
+
*/
|
|
125
|
+
handlePointerMove(event) {
|
|
126
|
+
if (event.cancelable) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
}
|
|
129
|
+
if (event.pointerType === 'mouse') {
|
|
130
|
+
if (this._core.store.state.isDrawing && this._currentPathId) {
|
|
131
|
+
const currentPath = this._core.store.objects.findById(this._currentPathId);
|
|
132
|
+
if (currentPath) {
|
|
133
|
+
const viewportScale = this._core.store.state.scale;
|
|
134
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
135
|
+
const divider = lockScale ? viewportScale : 1;
|
|
136
|
+
const x = (event.clientX - this._core.store.offsetX) / divider;
|
|
137
|
+
const y = (event.clientY - this._core.store.offsetY) / divider;
|
|
138
|
+
if (!this.shouldAppendPoint(currentPath, x, y, divider)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const updatedPath = KritzelPath.create(this._core, {
|
|
142
|
+
points: [...currentPath.points, [x, y]],
|
|
143
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
144
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
145
|
+
scale: lockScale ? 1 : viewportScale,
|
|
146
|
+
fill: this.color,
|
|
147
|
+
strokeWidth: this.size,
|
|
148
|
+
opacity: this.opacity,
|
|
149
|
+
});
|
|
150
|
+
updatedPath.id = currentPath.id;
|
|
151
|
+
updatedPath.workspaceId = currentPath.workspaceId;
|
|
152
|
+
updatedPath.zIndex = currentPath.zIndex;
|
|
153
|
+
updatedPath.isCompleted = false;
|
|
154
|
+
this._core.store.objects.update(updatedPath);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
159
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
160
|
+
if (activePointers.length === 1) {
|
|
161
|
+
if (this._currentPathId) {
|
|
162
|
+
const currentPath = this._core.store.objects.findById(this._currentPathId);
|
|
163
|
+
if (currentPath) {
|
|
164
|
+
const viewportScale = this._core.store.state.scale;
|
|
165
|
+
const lockScale = this._core.store.state.lockDrawingScale;
|
|
166
|
+
const divider = lockScale ? viewportScale : 1;
|
|
167
|
+
const x = Math.round((activePointers[0].clientX - this._core.store.offsetX) / divider);
|
|
168
|
+
const y = Math.round((activePointers[0].clientY - this._core.store.offsetY) / divider);
|
|
169
|
+
if (!this.shouldAppendPoint(currentPath, x, y, divider)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const updatedPath = KritzelPath.create(this._core, {
|
|
173
|
+
points: [...currentPath.points, [x, y]],
|
|
174
|
+
translateX: -this._core.store.state.translateX / divider,
|
|
175
|
+
translateY: -this._core.store.state.translateY / divider,
|
|
176
|
+
scale: lockScale ? 1 : viewportScale,
|
|
177
|
+
fill: this.color,
|
|
178
|
+
strokeWidth: this.size,
|
|
179
|
+
opacity: this.opacity,
|
|
180
|
+
});
|
|
181
|
+
updatedPath.id = currentPath.id;
|
|
182
|
+
updatedPath.workspaceId = currentPath.workspaceId;
|
|
183
|
+
updatedPath.zIndex = currentPath.zIndex;
|
|
184
|
+
updatedPath.isCompleted = false;
|
|
185
|
+
this._core.store.objects.update(updatedPath);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Handles pointer up events to complete the current path.
|
|
193
|
+
* Marks the path as completed, updates the store, and emits an objects change event.
|
|
194
|
+
* Resets the drawing state and clears the current path reference.
|
|
195
|
+
* @param event - The PointerEvent indicating the end of the drawing gesture
|
|
196
|
+
*/
|
|
197
|
+
handlePointerUp(event) {
|
|
198
|
+
if (event.cancelable) {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
}
|
|
201
|
+
if (event.pointerType === 'mouse') {
|
|
202
|
+
if (this._core.store.state.isDrawing) {
|
|
203
|
+
this._core.store.state.isDrawing = false;
|
|
204
|
+
if (this._currentPathId) {
|
|
205
|
+
const currentPath = this._core.store.objects.findById(this._currentPathId);
|
|
206
|
+
if (currentPath) {
|
|
207
|
+
currentPath.isCompleted = true;
|
|
208
|
+
this._core.store.objects.update(currentPath);
|
|
209
|
+
this._core.engine.emitObjectsChange();
|
|
210
|
+
this._core.engine.emitObjectsAdded([currentPath]);
|
|
211
|
+
}
|
|
212
|
+
this._core.store.objects?.setActiveDrawingObject(null);
|
|
213
|
+
this._currentPathId = null;
|
|
214
|
+
this._core.store.objects?.stopUndoCapturing();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
219
|
+
if (this._core.store.state.isDrawing) {
|
|
220
|
+
this._core.store.state.isDrawing = false;
|
|
221
|
+
if (this._currentPathId) {
|
|
222
|
+
const currentPath = this._core.store.objects.findById(this._currentPathId);
|
|
223
|
+
if (currentPath) {
|
|
224
|
+
currentPath.isCompleted = true;
|
|
225
|
+
this._core.store.objects.update(currentPath);
|
|
226
|
+
this._core.engine.emitObjectsChange();
|
|
227
|
+
this._core.engine.emitObjectsAdded([currentPath]);
|
|
228
|
+
}
|
|
229
|
+
this._core.store.objects?.setActiveDrawingObject(null);
|
|
230
|
+
this._currentPathId = null;
|
|
231
|
+
this._core.store.objects?.stopUndoCapturing();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|