@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,128 @@
|
|
|
1
|
+
import { KritzelBoundingBox } from '../../interfaces/bounding-box.interface';
|
|
2
|
+
import { KritzelBaseObject } from '../objects/base-object.class';
|
|
3
|
+
/**
|
|
4
|
+
* A quadtree data structure for efficient spatial indexing of objects.
|
|
5
|
+
* Quadtrees recursively subdivide 2D space into four quadrants to enable
|
|
6
|
+
* fast spatial queries like finding all objects within a given region.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of objects stored in the quadtree, must extend KritzelBaseObject
|
|
9
|
+
*/
|
|
10
|
+
export declare class KritzelQuadtree<T extends KritzelBaseObject<any>> {
|
|
11
|
+
private bounds;
|
|
12
|
+
private capacity;
|
|
13
|
+
private objects;
|
|
14
|
+
private children;
|
|
15
|
+
private _size;
|
|
16
|
+
/**
|
|
17
|
+
* Total number of objects in the quadtree (O(1) access).
|
|
18
|
+
* @returns The count of all objects stored in this quadtree and its children
|
|
19
|
+
*/
|
|
20
|
+
get size(): number;
|
|
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: KritzelBoundingBox, capacity?: number);
|
|
28
|
+
/**
|
|
29
|
+
* Resets the quadtree to its initial empty state.
|
|
30
|
+
* Clears all stored objects and removes all child nodes.
|
|
31
|
+
*/
|
|
32
|
+
reset(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Inserts an object into the quadtree.
|
|
35
|
+
* If the current node exceeds capacity, it will subdivide and delegate
|
|
36
|
+
* the insertion to the appropriate child quadrant.
|
|
37
|
+
*
|
|
38
|
+
* @param object - The object to insert, must have a rotatedBoundingBox property
|
|
39
|
+
* @returns `true` if the object was successfully inserted, `false` if it doesn't intersect the quadtree bounds
|
|
40
|
+
*/
|
|
41
|
+
insert(object: T): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Updates an existing object in the quadtree by matching its ID.
|
|
44
|
+
* Searches through the tree to find the object and replaces it with the new reference.
|
|
45
|
+
* Note: This does not reposition the object if its bounding box has changed.
|
|
46
|
+
*
|
|
47
|
+
* @param object - The updated object with the same ID as the one to replace
|
|
48
|
+
* @returns `true` if the object was found and updated, `false` otherwise
|
|
49
|
+
*/
|
|
50
|
+
update(object: T): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Reindexes an existing object by removing it from its current node and
|
|
53
|
+
* reinserting it based on its latest bounding box.
|
|
54
|
+
*
|
|
55
|
+
* @param object - The updated object to reindex
|
|
56
|
+
* @returns `true` if the object was found and reinserted, `false` otherwise
|
|
57
|
+
*/
|
|
58
|
+
reindex(object: T): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Removes objects from the quadtree that match the given predicate.
|
|
61
|
+
* Recursively searches through all nodes and removes matching objects.
|
|
62
|
+
*
|
|
63
|
+
* @param predicate - A function that returns `true` for objects that should be removed
|
|
64
|
+
* @returns The total number of objects removed from the quadtree
|
|
65
|
+
*/
|
|
66
|
+
remove(predicate: (object: T) => boolean): number;
|
|
67
|
+
/**
|
|
68
|
+
* Finds all objects whose bounding boxes intersect with the given range.
|
|
69
|
+
* This is the primary spatial query method for efficient object retrieval.
|
|
70
|
+
*
|
|
71
|
+
* @param range - The bounding box to query against
|
|
72
|
+
* @returns An array of all objects that intersect with the given range
|
|
73
|
+
*/
|
|
74
|
+
query(range: KritzelBoundingBox): T[];
|
|
75
|
+
/**
|
|
76
|
+
* Internal method that collects query results into a pre-allocated array.
|
|
77
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
78
|
+
*
|
|
79
|
+
* @param range - The bounding box to query against
|
|
80
|
+
* @param results - The array to collect matching objects into
|
|
81
|
+
*/
|
|
82
|
+
private _queryInto;
|
|
83
|
+
/**
|
|
84
|
+
* Filters all objects in the quadtree using a custom predicate function.
|
|
85
|
+
* Unlike `query`, this method checks all objects regardless of spatial location.
|
|
86
|
+
*
|
|
87
|
+
* @param predicate - A function that returns `true` for objects to include in results
|
|
88
|
+
* @returns An array of all objects that satisfy the predicate
|
|
89
|
+
*/
|
|
90
|
+
filter(predicate: (object: T) => boolean): T[];
|
|
91
|
+
/**
|
|
92
|
+
* Internal method that collects filter results into a pre-allocated array.
|
|
93
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
94
|
+
*
|
|
95
|
+
* @param predicate - A function that returns `true` for objects to include
|
|
96
|
+
* @param results - The array to collect matching objects into
|
|
97
|
+
*/
|
|
98
|
+
private _filterInto;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves all objects stored in the quadtree.
|
|
101
|
+
* Traverses the entire tree structure to collect every object.
|
|
102
|
+
*
|
|
103
|
+
* @returns An array containing all objects in the quadtree
|
|
104
|
+
*/
|
|
105
|
+
allObjects(): T[];
|
|
106
|
+
/**
|
|
107
|
+
* Internal method that collects all objects into a pre-allocated array.
|
|
108
|
+
* Avoids creating intermediate arrays from spread operators.
|
|
109
|
+
*
|
|
110
|
+
* @param results - The array to collect all objects into
|
|
111
|
+
*/
|
|
112
|
+
private _collectAllInto;
|
|
113
|
+
/**
|
|
114
|
+
* Subdivides this quadtree node into four child quadrants.
|
|
115
|
+
* Called automatically when the node's capacity is exceeded.
|
|
116
|
+
* Creates children for: Northwest (NW), Northeast (NE), Southwest (SW), Southeast (SE).
|
|
117
|
+
*/
|
|
118
|
+
private subdivide;
|
|
119
|
+
/**
|
|
120
|
+
* Checks whether two bounding boxes intersect (overlap) each other.
|
|
121
|
+
* Uses axis-aligned bounding box (AABB) collision detection.
|
|
122
|
+
*
|
|
123
|
+
* @param a - The first bounding box
|
|
124
|
+
* @param b - The second bounding box
|
|
125
|
+
* @returns `true` if the bounding boxes overlap, `false` otherwise
|
|
126
|
+
*/
|
|
127
|
+
private intersects;
|
|
128
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { KritzelSerializable } from '../../interfaces/serializable.interface';
|
|
2
|
+
import { KritzelToolType } from '../../interfaces/tool-type.interface';
|
|
3
|
+
import { KritzelTool } from '../../interfaces/tool.interface';
|
|
4
|
+
import { KritzelCore } from '../core/core.class';
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for all drawing tools in Kritzel.
|
|
7
|
+
* Provides common functionality and defines the interface that all tools must implement.
|
|
8
|
+
* Tools handle user interactions (pointer events, wheel events) and can be serialized/deserialized.
|
|
9
|
+
*/
|
|
10
|
+
export declare class KritzelBaseTool implements KritzelTool, KritzelSerializable {
|
|
11
|
+
/** Class name identifier used for serialization/deserialization */
|
|
12
|
+
__class__: string;
|
|
13
|
+
/** Identifies the tool type for config resolution (survives minification and dual-package bundling) */
|
|
14
|
+
toolType: KritzelToolType;
|
|
15
|
+
/** Human-readable name of the tool */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Reference to the Kritzel core instance for accessing store, viewport, and other core functionality */
|
|
18
|
+
protected readonly _core: KritzelCore;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new instance of KritzelBaseTool.
|
|
21
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
22
|
+
*/
|
|
23
|
+
constructor(core: KritzelCore);
|
|
24
|
+
/**
|
|
25
|
+
* Called when the tool becomes the active tool.
|
|
26
|
+
* Override in subclasses to perform initialization when the tool is selected.
|
|
27
|
+
*/
|
|
28
|
+
onActivate(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Called when the tool is deactivated (another tool becomes active).
|
|
31
|
+
* Override in subclasses to perform cleanup when the tool is deselected.
|
|
32
|
+
*/
|
|
33
|
+
onDeactivate(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Handles pointer down events (mouse click, touch start, pen down).
|
|
36
|
+
* Override in subclasses to implement tool-specific behavior when the user starts an interaction.
|
|
37
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
38
|
+
*/
|
|
39
|
+
handlePointerDown(_event: PointerEvent): void;
|
|
40
|
+
/**
|
|
41
|
+
* Handles pointer move events (mouse move, touch move, pen move).
|
|
42
|
+
* Override in subclasses to implement tool-specific behavior during dragging or hovering.
|
|
43
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
44
|
+
*/
|
|
45
|
+
handlePointerMove(_event: PointerEvent): void;
|
|
46
|
+
/**
|
|
47
|
+
* Handles pointer up events (mouse release, touch end, pen up).
|
|
48
|
+
* Override in subclasses to implement tool-specific behavior when the user ends an interaction.
|
|
49
|
+
* @param _event - The PointerEvent containing information about the pointer (position, type, buttons, etc.)
|
|
50
|
+
*/
|
|
51
|
+
handlePointerUp(_event: PointerEvent): void;
|
|
52
|
+
/**
|
|
53
|
+
* Handles mouse wheel events for zooming or scrolling.
|
|
54
|
+
* Override in subclasses to implement tool-specific wheel behavior.
|
|
55
|
+
* @param _event - The WheelEvent containing scroll delta and modifier key information
|
|
56
|
+
*/
|
|
57
|
+
handleWheel(_event: WheelEvent): void;
|
|
58
|
+
/**
|
|
59
|
+
* Serializes the tool to a plain object for persistence or transfer.
|
|
60
|
+
* @returns An object containing the tool's class name and name property
|
|
61
|
+
*/
|
|
62
|
+
serialize(): {
|
|
63
|
+
__class__: string;
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Deserializes a plain object into this tool instance.
|
|
68
|
+
* @param object - The serialized tool data to restore
|
|
69
|
+
* @returns This tool instance with restored properties
|
|
70
|
+
*/
|
|
71
|
+
deserialize(object: any): KritzelSerializable;
|
|
72
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { KritzelBaseTool } from './base-tool.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { ThemeAwareColor } from '../../constants/color-palette.constants';
|
|
4
|
+
/**
|
|
5
|
+
* Brush tool for free-hand drawing on the canvas.
|
|
6
|
+
* Creates smooth paths by tracking pointer movement and rendering stroke paths.
|
|
7
|
+
* Supports mouse, touch, and pen input with configurable color, size, and opacity.
|
|
8
|
+
*/
|
|
9
|
+
export declare class KritzelBrushTool extends KritzelBaseTool {
|
|
10
|
+
toolType: "brush";
|
|
11
|
+
/** The color of the brush stroke (supports theme-aware light/dark colors) */
|
|
12
|
+
color: ThemeAwareColor;
|
|
13
|
+
/** The width of the brush stroke in pixels */
|
|
14
|
+
size: number;
|
|
15
|
+
/** The opacity of the brush stroke (0-1) */
|
|
16
|
+
opacity: number;
|
|
17
|
+
/** Available color palette for the brush tool */
|
|
18
|
+
palette: ThemeAwareColor[];
|
|
19
|
+
/** Available stroke size presets for the brush tool */
|
|
20
|
+
sizes: number[];
|
|
21
|
+
/**
|
|
22
|
+
* Minimum distance in screen pixels between two consecutive stored points.
|
|
23
|
+
* Pointer-move samples closer than this to the previously stored point are
|
|
24
|
+
* dropped. This shrinks the path's `points` array (which is fully
|
|
25
|
+
* re-serialized on every Yjs update during a stroke), reducing per-stroke
|
|
26
|
+
* websocket traffic without visible quality loss — `perfect-freehand`
|
|
27
|
+
* already smooths the rendered stroke.
|
|
28
|
+
*/
|
|
29
|
+
static readonly MIN_POINT_DISTANCE_PX = 3;
|
|
30
|
+
/** Tracks the ID of the path currently being drawn */
|
|
31
|
+
private _currentPathId;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if (x, y) is far enough from the last stored point on
|
|
34
|
+
* `currentPath` to be appended. Distance is measured in the same coordinate
|
|
35
|
+
* system the points themselves are stored in (world units when
|
|
36
|
+
* lockDrawingScale is true, screen units otherwise), with the threshold
|
|
37
|
+
* scaled by `divider` so the filter is always ~1 screen pixel.
|
|
38
|
+
*
|
|
39
|
+
* Uses squared distance to avoid a per-move `Math.sqrt`.
|
|
40
|
+
*/
|
|
41
|
+
private shouldAppendPoint;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new instance of KritzelBrushTool.
|
|
44
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
45
|
+
*/
|
|
46
|
+
constructor(core: KritzelCore);
|
|
47
|
+
/**
|
|
48
|
+
* Handles pointer down events to start drawing a new path.
|
|
49
|
+
* Creates a new KritzelPath object at the pointer position and adds it to the canvas.
|
|
50
|
+
* Supports both mouse (left-click) and touch/pen input.
|
|
51
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
52
|
+
*/
|
|
53
|
+
handlePointerDown(event: PointerEvent): void;
|
|
54
|
+
/**
|
|
55
|
+
* Handles pointer move events to extend the current path while drawing.
|
|
56
|
+
* Adds new points to the current path as the pointer moves across the canvas.
|
|
57
|
+
* Only processes events when actively drawing (isDrawing state is true).
|
|
58
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
59
|
+
*/
|
|
60
|
+
handlePointerMove(event: PointerEvent): void;
|
|
61
|
+
/**
|
|
62
|
+
* Handles pointer up events to complete the current path.
|
|
63
|
+
* Marks the path as completed, updates the store, and emits an objects change event.
|
|
64
|
+
* Resets the drawing state and clears the current path reference.
|
|
65
|
+
* @param event - The PointerEvent indicating the end of the drawing gesture
|
|
66
|
+
*/
|
|
67
|
+
handlePointerUp(event: PointerEvent): void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { KritzelBaseTool } from './base-tool.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.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 declare class KritzelEraserTool extends KritzelBaseTool {
|
|
9
|
+
toolType: "eraser";
|
|
10
|
+
/** Timeout handle for delayed touch start activation to prevent accidental erasing */
|
|
11
|
+
touchStartTimeout: any;
|
|
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: KritzelCore);
|
|
17
|
+
/**
|
|
18
|
+
* Handles pointer down events to start the erasing gesture.
|
|
19
|
+
* For mouse input, immediately activates erasing on left-click.
|
|
20
|
+
* For touch/pen input, uses a delayed activation to prevent accidental erasing.
|
|
21
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
22
|
+
*/
|
|
23
|
+
handlePointerDown(event: PointerEvent): void;
|
|
24
|
+
/**
|
|
25
|
+
* Handles pointer move events to mark objects for removal during erasing.
|
|
26
|
+
* Performs hit testing on objects under the pointer and marks them for removal.
|
|
27
|
+
* Objects are visually indicated as being erased but not yet removed from the canvas.
|
|
28
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
29
|
+
*/
|
|
30
|
+
handlePointerMove(event: PointerEvent): void;
|
|
31
|
+
/**
|
|
32
|
+
* Handles pointer up events to complete the erasing gesture.
|
|
33
|
+
* Removes all objects that were marked for removal during the gesture.
|
|
34
|
+
* Clears the erasing state and emits an objects change event if any objects were removed.
|
|
35
|
+
* @param event - The PointerEvent indicating the end of the erasing gesture
|
|
36
|
+
*/
|
|
37
|
+
handlePointerUp(event: PointerEvent): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { KritzelBaseTool } from './base-tool.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
/**
|
|
4
|
+
* Image tool for importing and placing images on the canvas.
|
|
5
|
+
*
|
|
6
|
+
* Flow:
|
|
7
|
+
* 1. User picks a file.
|
|
8
|
+
* 2. Static images are compressed via `browser-image-compression` (bandwidth win).
|
|
9
|
+
* GIF files retain their original bytes so animation is preserved.
|
|
10
|
+
* 3. Intrinsic dimensions are measured from a temporary object URL.
|
|
11
|
+
* 4. Bytes are uploaded through the asset resolver (write-through:
|
|
12
|
+
* local IndexedDB immediately, remote providers in the background).
|
|
13
|
+
* 5. A `KritzelImage` is created carrying only the resulting asset id
|
|
14
|
+
* and MIME type, then added to the canvas. The renderer resolves
|
|
15
|
+
* the id to a URL via the asset resolver.
|
|
16
|
+
*/
|
|
17
|
+
export declare class KritzelImageTool extends KritzelBaseTool {
|
|
18
|
+
toolType: "image";
|
|
19
|
+
/** Hidden file input element for image selection */
|
|
20
|
+
fileInput: HTMLInputElement | null;
|
|
21
|
+
/** Maximum dimension (width or height) for image compression in pixels */
|
|
22
|
+
maxCompressionSize: number;
|
|
23
|
+
/** Diagonal offset (in world units) applied between images when multiple are imported at once */
|
|
24
|
+
multiImportOffset: number;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of KritzelImageTool.
|
|
27
|
+
* Sets up the hidden file input element for image selection.
|
|
28
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
29
|
+
*/
|
|
30
|
+
constructor(core: KritzelCore);
|
|
31
|
+
/**
|
|
32
|
+
* Called when the image tool becomes active.
|
|
33
|
+
* Automatically opens the file picker dialog.
|
|
34
|
+
*/
|
|
35
|
+
onActivate(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Opens the native file picker dialog for image selection.
|
|
38
|
+
* Does nothing if the canvas is in disabled state.
|
|
39
|
+
*/
|
|
40
|
+
private openFilePicker;
|
|
41
|
+
/**
|
|
42
|
+
* Creates and configures the hidden file input element.
|
|
43
|
+
* Sets up event listeners for file selection and cancellation.
|
|
44
|
+
*/
|
|
45
|
+
private setupFileInput;
|
|
46
|
+
/**
|
|
47
|
+
* Handles the file selection event from the file input.
|
|
48
|
+
* Compresses each selected image if necessaryand places them as a batch on the canvas.
|
|
49
|
+
* Resets the file input value after processing.
|
|
50
|
+
* @param event - The change event from the file input element
|
|
51
|
+
*/
|
|
52
|
+
private handleFileSelect;
|
|
53
|
+
/**
|
|
54
|
+
* Prepares an image file for insertion by compressing it if necessary.
|
|
55
|
+
* @param file
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
private prepareImageFile;
|
|
59
|
+
/**
|
|
60
|
+
* Adds a batch of prepared images to the canvas store and switches
|
|
61
|
+
* to the selection tool. The first image is centered in the viewport;
|
|
62
|
+
* each subsequent image is offset diagonally so multiple imports do
|
|
63
|
+
* not fully overlap. All images are selected together and a single
|
|
64
|
+
* batch change/added event is emitted.
|
|
65
|
+
*
|
|
66
|
+
* @param images - The prepared `KritzelImage` objects to add
|
|
67
|
+
*/
|
|
68
|
+
private addImagesToStore;
|
|
69
|
+
/**
|
|
70
|
+
* Handles cancellation of the file picker or errors during image processing.
|
|
71
|
+
* Switches back to the selection tool without adding any image.
|
|
72
|
+
*/
|
|
73
|
+
private handleCancel;
|
|
74
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { KritzelBaseTool } from './base-tool.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { LineArrowConfig } from '../../interfaces/arrow-head.interface';
|
|
4
|
+
import { ThemeAwareColor } from '../../constants/color-palette.constants';
|
|
5
|
+
/**
|
|
6
|
+
* Line tool for drawing straight lines on the canvas.
|
|
7
|
+
* Creates lines by tracking the start and end points of a drag gesture.
|
|
8
|
+
* Supports configurable stroke color, width, opacity, and arrow heads.
|
|
9
|
+
* Automatically switches to selection tool after line completion.
|
|
10
|
+
*/
|
|
11
|
+
export declare class KritzelLineTool extends KritzelBaseTool {
|
|
12
|
+
toolType: "line";
|
|
13
|
+
/** The stroke color of the line (supports theme-aware light/dark colors) */
|
|
14
|
+
color: ThemeAwareColor;
|
|
15
|
+
/** The stroke width of the line in pixels */
|
|
16
|
+
size: number;
|
|
17
|
+
/** The opacity of the line (0-1) */
|
|
18
|
+
opacity: number;
|
|
19
|
+
/** Available color palette for the line tool */
|
|
20
|
+
palette: ThemeAwareColor[];
|
|
21
|
+
/** Available stroke size presets for the line tool */
|
|
22
|
+
sizes: number[];
|
|
23
|
+
/** Arrow head configuration for lines created with this tool */
|
|
24
|
+
arrows?: LineArrowConfig;
|
|
25
|
+
/** X coordinate of the line's starting point */
|
|
26
|
+
private _startX;
|
|
27
|
+
/** Y coordinate of the line's starting point */
|
|
28
|
+
private _startY;
|
|
29
|
+
/** Tracks the ID of the line currently being drawn */
|
|
30
|
+
private _currentLineId;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new instance of KritzelLineTool.
|
|
33
|
+
* @param core - The KritzelCore instance that provides access to application state and functionality
|
|
34
|
+
*/
|
|
35
|
+
constructor(core: KritzelCore);
|
|
36
|
+
/**
|
|
37
|
+
* Handles pointer down events to start drawing a new line.
|
|
38
|
+
* Creates a new KritzelLine object at the pointer position with start and end points at the same location.
|
|
39
|
+
* Supports both mouse (left-click) and touch/pen input.
|
|
40
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
41
|
+
*/
|
|
42
|
+
handlePointerDown(event: PointerEvent): void;
|
|
43
|
+
/**
|
|
44
|
+
* Handles pointer move events to update the line's end point while drawing.
|
|
45
|
+
* Updates the current line's end coordinates to follow the pointer position.
|
|
46
|
+
* Only processes events when actively drawing (isDrawing state is true).
|
|
47
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
48
|
+
*/
|
|
49
|
+
handlePointerMove(event: PointerEvent): void;
|
|
50
|
+
/**
|
|
51
|
+
* Handles pointer up events to complete the current line.
|
|
52
|
+
* Marks the line as completed, updates the store, emits an objects change event,
|
|
53
|
+
* and switches to selection tool with the drawn line selected.
|
|
54
|
+
* @param event - The PointerEvent indicating the end of the drawing gesture
|
|
55
|
+
*/
|
|
56
|
+
handlePointerUp(event: PointerEvent): void;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a selection group with the drawn line, selects it, and switches to the selection tool.
|
|
59
|
+
* This provides immediate editing capability for the newly drawn line.
|
|
60
|
+
* @param line - The KritzelLine object to select
|
|
61
|
+
*/
|
|
62
|
+
private selectLineAndSwitchTool;
|
|
63
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { KritzelMoveHandler } from '../handlers/move.handler';
|
|
2
|
+
import { KritzelResizeHandler } from '../handlers/resize.handler';
|
|
3
|
+
import { KritzelRotationHandler } from '../handlers/rotation.handler';
|
|
4
|
+
import { KritzelSelectionHandler } from '../handlers/selection.handler';
|
|
5
|
+
import { KritzelBaseTool } from './base-tool.class';
|
|
6
|
+
import { KritzelHoverHandler } from '../handlers/hover.handler';
|
|
7
|
+
import { KritzelCore } from '../core/core.class';
|
|
8
|
+
import { KritzelLineHandleHandler } from '../handlers/line-handle.handler';
|
|
9
|
+
import { ToolConfigDefinition } from '../../interfaces/tool-config.interface';
|
|
10
|
+
import { ThemeAwareColor } from '../../constants/color-palette.constants';
|
|
11
|
+
import { LineArrowConfig } from '../../interfaces/arrow-head.interface';
|
|
12
|
+
/**
|
|
13
|
+
* Selection tool for selecting, moving, resizing, and rotating objects on the canvas.
|
|
14
|
+
* Provides comprehensive object manipulation capabilities including multi-select,
|
|
15
|
+
* property editing, and various transformation handles. Delegates specific interactions
|
|
16
|
+
* to specialized handlers (selection, move, resize, rotation, hover, line handle).
|
|
17
|
+
*/
|
|
18
|
+
export declare class KritzelSelectionTool extends KritzelBaseTool {
|
|
19
|
+
toolType: "selection";
|
|
20
|
+
/** Handler for selection box and object selection logic */
|
|
21
|
+
selectionHandler: KritzelSelectionHandler;
|
|
22
|
+
/** Handler for moving selected objects */
|
|
23
|
+
moveHandler: KritzelMoveHandler;
|
|
24
|
+
/** Handler for hover effects on objects */
|
|
25
|
+
hoverHandler: KritzelHoverHandler;
|
|
26
|
+
/** Handler for resizing selected objects */
|
|
27
|
+
resizeHandler: KritzelResizeHandler;
|
|
28
|
+
/** Handler for rotating selected objects */
|
|
29
|
+
rotationHandler: KritzelRotationHandler;
|
|
30
|
+
/** Handler for manipulating line start/end handles */
|
|
31
|
+
lineHandleHandler: KritzelLineHandleHandler;
|
|
32
|
+
/** Available color palette for selected objects */
|
|
33
|
+
palette: ThemeAwareColor[];
|
|
34
|
+
/**
|
|
35
|
+
* Stores a selection group that was cleared on the first finger-down of a
|
|
36
|
+
* potential pinch-zoom gesture, so it can be restored when the second finger
|
|
37
|
+
* arrives. Cleared when the touch interaction ends.
|
|
38
|
+
*/
|
|
39
|
+
private _savedSelectionGroupForPinch;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if there are any objects currently selected.
|
|
42
|
+
* @returns True if there are objects in the selection group, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
hasSelection(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the currently selected objects.
|
|
47
|
+
* @returns Array of selected objects, or empty array if no selection
|
|
48
|
+
*/
|
|
49
|
+
getSelectedObjects(): any[];
|
|
50
|
+
/**
|
|
51
|
+
* Recursively flattens a collection of objects, expanding any groups into their children.
|
|
52
|
+
* @param objects - Array of objects that may include groups
|
|
53
|
+
* @returns Flattened array with all nested group children expanded
|
|
54
|
+
*/
|
|
55
|
+
private flattenObjects;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the primary color of the selected objects.
|
|
58
|
+
* Returns the fill color for paths, stroke for lines, font color for text, or stroke color for shapes.
|
|
59
|
+
*/
|
|
60
|
+
get color(): ThemeAwareColor;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the primary color of all selected objects.
|
|
63
|
+
* Updates the appropriate color property based on object type (fill, stroke, fontColor, strokeColor).
|
|
64
|
+
*/
|
|
65
|
+
set color(value: ThemeAwareColor);
|
|
66
|
+
/**
|
|
67
|
+
* Gets the opacity of the first selected object.
|
|
68
|
+
* @returns The opacity value (0-1) or 1 if no selection
|
|
69
|
+
*/
|
|
70
|
+
get opacity(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the opacity of all selected objects.
|
|
73
|
+
* @param value - The opacity value (0-1)
|
|
74
|
+
*/
|
|
75
|
+
set opacity(value: number);
|
|
76
|
+
/**
|
|
77
|
+
* Gets the size (stroke width or font size) of the selected objects.
|
|
78
|
+
* Returns strokeWidth for paths/lines/shapes, fontSize for text objects.
|
|
79
|
+
*/
|
|
80
|
+
get size(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the size (stroke width or font size) of all selected objects.
|
|
83
|
+
* Updates strokeWidth for paths/lines/shapes and fontSize for text objects.
|
|
84
|
+
* Refreshes selection group dimensions after updating.
|
|
85
|
+
*/
|
|
86
|
+
set size(value: number);
|
|
87
|
+
/**
|
|
88
|
+
* Gets the fill color of the first selected shape.
|
|
89
|
+
* @returns The fill color or transparent if no shapes are selected
|
|
90
|
+
*/
|
|
91
|
+
get fillColor(): ThemeAwareColor;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the fill color of all selected shapes.
|
|
94
|
+
* Also updates the font color based on fill color contrast and syncs stroke color when fill is not transparent.
|
|
95
|
+
*/
|
|
96
|
+
set fillColor(value: ThemeAwareColor);
|
|
97
|
+
/**
|
|
98
|
+
* Gets the font family of the first selected text or shape object.
|
|
99
|
+
* @returns The font family name or 'Arial' as default
|
|
100
|
+
*/
|
|
101
|
+
get fontFamily(): string;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the font family of all selected text and shape objects.
|
|
104
|
+
* Refreshes selection group dimensions after updating.
|
|
105
|
+
*/
|
|
106
|
+
set fontFamily(value: string);
|
|
107
|
+
/**
|
|
108
|
+
* Gets the arrow configuration of the first selected line.
|
|
109
|
+
* @returns The arrow config or default disabled arrows if no lines are selected
|
|
110
|
+
*/
|
|
111
|
+
get arrows(): LineArrowConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Sets the arrow configuration of all selected lines.
|
|
114
|
+
* Refreshes selection group dimensions after updating.
|
|
115
|
+
*/
|
|
116
|
+
set arrows(value: LineArrowConfig);
|
|
117
|
+
/**
|
|
118
|
+
* Generates a tool configuration definition based on the types of selected objects.
|
|
119
|
+
* Determines which controls should be shown in the UI based on whether the selection
|
|
120
|
+
* contains shapes, text, lines, images, or stroke-based objects.
|
|
121
|
+
* @returns Tool configuration for the UI, or null if nothing is selected
|
|
122
|
+
*/
|
|
123
|
+
getToolConfig(): ToolConfigDefinition | null;
|
|
124
|
+
/**
|
|
125
|
+
* Refreshes the selection group's dimensions after object properties that affect size have changed.
|
|
126
|
+
* Uses requestAnimationFrame to ensure the DOM has been updated before measuring.
|
|
127
|
+
*/
|
|
128
|
+
private refreshSelectionGroupDimensions;
|
|
129
|
+
constructor(core: KritzelCore);
|
|
130
|
+
/**
|
|
131
|
+
* Handles pointer down events for selection and manipulation.
|
|
132
|
+
* Determines the type of interaction (resize handle, rotation handle, line handle, or object)
|
|
133
|
+
* and delegates to the appropriate handler. Manages selection state and supports
|
|
134
|
+
* additive selection with Shift/Ctrl modifiers.
|
|
135
|
+
* @param event - The PointerEvent containing pointer position and input type information
|
|
136
|
+
*/
|
|
137
|
+
handlePointerDown(event: PointerEvent): void;
|
|
138
|
+
/**
|
|
139
|
+
* Handles pointer move events during selection and manipulation.
|
|
140
|
+
* Delegates movement to the appropriate handler based on the current interaction state
|
|
141
|
+
* (line handle, move, hover, selection box, resize, or rotation).
|
|
142
|
+
* @param event - The PointerEvent containing the current pointer position
|
|
143
|
+
*/
|
|
144
|
+
handlePointerMove(event: PointerEvent): void;
|
|
145
|
+
/**
|
|
146
|
+
* Handles pointer up events to complete selection and manipulation operations.
|
|
147
|
+
* Delegates to all handlers to finalize their respective operations.
|
|
148
|
+
* @param event - The PointerEvent indicating the end of the interaction
|
|
149
|
+
*/
|
|
150
|
+
handlePointerUp(event: PointerEvent): void;
|
|
151
|
+
/**
|
|
152
|
+
* Gets the object at the pointer event location and wraps it in a selection group.
|
|
153
|
+
* Performs hit testing to ensure the pointer is actually over the object.
|
|
154
|
+
* @param event - The PointerEvent to get the object from
|
|
155
|
+
* @returns A KritzelSelectionGroup containing the object, or null if no object at that location
|
|
156
|
+
*/
|
|
157
|
+
private getSelectedObject;
|
|
158
|
+
/**
|
|
159
|
+
* Determines the type of resize handle at the pointer location.
|
|
160
|
+
* @param event - The PointerEvent to check for handle type
|
|
161
|
+
* @returns The KritzelHandleType if a resize handle is at the location, undefined otherwise
|
|
162
|
+
*/
|
|
163
|
+
private getHandleType;
|
|
164
|
+
/**
|
|
165
|
+
* Checks if a resize handle is at the pointer location.
|
|
166
|
+
* @param event - The PointerEvent to check
|
|
167
|
+
* @returns True if a resize handle overlay element is at the pointer location
|
|
168
|
+
*/
|
|
169
|
+
private isHandleSelected;
|
|
170
|
+
/**
|
|
171
|
+
* Checks if a rotation handle is at the pointer location.
|
|
172
|
+
* @param event - The PointerEvent to check
|
|
173
|
+
* @returns True if a rotation handle overlay element is at the pointer location
|
|
174
|
+
*/
|
|
175
|
+
private isRotationHandleSelected;
|
|
176
|
+
/**
|
|
177
|
+
* Checks if a line handle (start or end point) is at the pointer location.
|
|
178
|
+
* @param event - The PointerEvent to check
|
|
179
|
+
* @returns True if a line handle overlay element is at the pointer location
|
|
180
|
+
*/
|
|
181
|
+
private isLineHandleSelected;
|
|
182
|
+
/**
|
|
183
|
+
* Determines the type of line handle (start or end) at the pointer location.
|
|
184
|
+
* @param event - The PointerEvent to check for line handle type
|
|
185
|
+
* @returns The LineHandleType if a line handle is at the location, undefined otherwise
|
|
186
|
+
*/
|
|
187
|
+
private getLineHandleType;
|
|
188
|
+
}
|