@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,112 @@
|
|
|
1
|
+
import { ObjectHelper } from "../../helpers/object.helper";
|
|
2
|
+
/** Current version of the workspace export format */
|
|
3
|
+
export const WORKSPACE_EXPORT_VERSION = '1.3.0';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a workspace in the Kritzel canvas.
|
|
6
|
+
* A workspace is an isolated canvas area with its own set of objects and viewport state.
|
|
7
|
+
* It can be serialized and deserialized for persistence and collaborative editing.
|
|
8
|
+
*/
|
|
9
|
+
export class KritzelWorkspace {
|
|
10
|
+
__class__ = 'KritzelWorkspace';
|
|
11
|
+
/** Unique identifier for the workspace */
|
|
12
|
+
id;
|
|
13
|
+
/** Display name of the workspace */
|
|
14
|
+
name;
|
|
15
|
+
/** Timestamp when the workspace was created */
|
|
16
|
+
createdAt;
|
|
17
|
+
/** Timestamp when the workspace was last updated */
|
|
18
|
+
updatedAt;
|
|
19
|
+
/** Viewport state containing the world-space center point and zoom level */
|
|
20
|
+
viewport;
|
|
21
|
+
/**
|
|
22
|
+
* Desired canvas objects. Seeded when the workspace is first initialized and applied as the
|
|
23
|
+
* full desired set by `updateWorkspace()`: `undefined` leaves objects untouched, `[]` removes all.
|
|
24
|
+
*/
|
|
25
|
+
objects;
|
|
26
|
+
/** Whether the workspace is publicly accessible via a share link */
|
|
27
|
+
isPublic;
|
|
28
|
+
/** Reference to the KritzelCore instance managing this workspace */
|
|
29
|
+
_core;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new KritzelWorkspace instance.
|
|
32
|
+
* @param config - Configuration options object for the workspace
|
|
33
|
+
*/
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.id = config?.id ?? ObjectHelper.generateUUID();
|
|
36
|
+
this.name = config?.name ?? 'New Workspace';
|
|
37
|
+
this.createdAt = new Date();
|
|
38
|
+
this.updatedAt = new Date();
|
|
39
|
+
this.viewport = {
|
|
40
|
+
centerWorldX: config?.viewport?.centerWorldX ?? 0,
|
|
41
|
+
centerWorldY: config?.viewport?.centerWorldY ?? 0,
|
|
42
|
+
scale: config?.viewport?.scale ?? 1,
|
|
43
|
+
};
|
|
44
|
+
this.objects = config?.objects;
|
|
45
|
+
this.isPublic = false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Factory method to create a workspace with a core reference.
|
|
49
|
+
* @param core - The KritzelCore instance to associate with this workspace
|
|
50
|
+
* @param obj - Object containing workspace properties (id, name, viewport)
|
|
51
|
+
* @returns A new KritzelWorkspace instance with the core reference set
|
|
52
|
+
*/
|
|
53
|
+
static create(core, obj) {
|
|
54
|
+
const workspace = new KritzelWorkspace({
|
|
55
|
+
id: obj.id,
|
|
56
|
+
name: obj.name,
|
|
57
|
+
viewport: obj.viewport,
|
|
58
|
+
});
|
|
59
|
+
workspace._core = core;
|
|
60
|
+
return workspace;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Adds an object to this workspace via the core engine.
|
|
64
|
+
* @param obj - The object to add to the workspace
|
|
65
|
+
*/
|
|
66
|
+
addObject(obj) {
|
|
67
|
+
this._core.engine.addObject(obj);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Serializes the workspace to a plain object for storage or transmission.
|
|
71
|
+
* Converts dates to ISO strings and includes the class identifier.
|
|
72
|
+
* @param options - Optional settings for serialization
|
|
73
|
+
* @param options.includeObjects - If true, includes all canvas objects in the serialized output
|
|
74
|
+
* @returns A plain object representation of the workspace
|
|
75
|
+
*/
|
|
76
|
+
serialize(options) {
|
|
77
|
+
const serialized = {
|
|
78
|
+
__class__: this.__class__,
|
|
79
|
+
version: WORKSPACE_EXPORT_VERSION,
|
|
80
|
+
id: this.id,
|
|
81
|
+
name: this.name,
|
|
82
|
+
createdAt: this.createdAt.toISOString(),
|
|
83
|
+
updatedAt: this.updatedAt.toISOString(),
|
|
84
|
+
viewport: this.viewport,
|
|
85
|
+
isPublic: this.isPublic,
|
|
86
|
+
};
|
|
87
|
+
if (options?.includeObjects && this._core) {
|
|
88
|
+
const allObjects = this._core.store.allNonSelectionObjects;
|
|
89
|
+
serialized.objects = allObjects.map(obj => obj.serialize());
|
|
90
|
+
}
|
|
91
|
+
return serialized;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates a shallow clone of this workspace, preserving the prototype chain.
|
|
95
|
+
* Useful when Stencil needs a new object reference to detect property changes.
|
|
96
|
+
*/
|
|
97
|
+
clone() {
|
|
98
|
+
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Deserializes a plain object into this workspace instance.
|
|
102
|
+
* Converts ISO string dates back to Date objects.
|
|
103
|
+
* @param object - The plain object to deserialize from
|
|
104
|
+
* @returns This workspace instance with updated properties
|
|
105
|
+
*/
|
|
106
|
+
deserialize(object) {
|
|
107
|
+
Object.assign(this, object);
|
|
108
|
+
this.createdAt = new Date(object.createdAt);
|
|
109
|
+
this.updatedAt = new Date(object.updatedAt);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all Kritzel event handlers.
|
|
3
|
+
* Provides a common foundation with access to the core instance for derived handler classes
|
|
4
|
+
* such as key handlers, hover handlers, and context menu handlers.
|
|
5
|
+
*/
|
|
6
|
+
export class KritzelBaseHandler {
|
|
7
|
+
/**
|
|
8
|
+
* Reference to the KritzelCore instance.
|
|
9
|
+
* Provides access to canvas state, store, and operations for derived handlers.
|
|
10
|
+
*/
|
|
11
|
+
_core;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new instance of the base handler.
|
|
14
|
+
* @param core - The KritzelCore instance that provides access to canvas state and operations.
|
|
15
|
+
*/
|
|
16
|
+
constructor(core) {
|
|
17
|
+
this._core = core;
|
|
18
|
+
void this._core; // Avoid unused variable warning
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { KritzelSelectionGroup } from "../objects/selection-group.class";
|
|
2
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
3
|
+
import { KritzelSelectionBox } from "../objects/selection-box.class";
|
|
4
|
+
/**
|
|
5
|
+
* Handles context menu interactions on the Kritzel canvas.
|
|
6
|
+
* Manages the display and positioning of context menus, selecting appropriate menu items
|
|
7
|
+
* based on whether an object is targeted or the canvas background is right-clicked.
|
|
8
|
+
*/
|
|
9
|
+
export class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
10
|
+
/**
|
|
11
|
+
* Menu items to display when the context menu is opened on the canvas background
|
|
12
|
+
* (i.e., when no object is selected).
|
|
13
|
+
*/
|
|
14
|
+
globalContextMenuItems = [];
|
|
15
|
+
/**
|
|
16
|
+
* Menu items to display when the context menu is opened on a selected object.
|
|
17
|
+
*/
|
|
18
|
+
objectContextMenuItems = [];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new instance of the context menu handler.
|
|
21
|
+
* @param core - The KritzelCore instance that provides access to canvas state and operations.
|
|
22
|
+
* @param globalContextMenuItems - Array of menu items to show for canvas-level context menus.
|
|
23
|
+
* @param objectContextMenuItems - Array of menu items to show when right-clicking on objects.
|
|
24
|
+
*/
|
|
25
|
+
constructor(core, globalContextMenuItems, objectContextMenuItems) {
|
|
26
|
+
super(core);
|
|
27
|
+
this.globalContextMenuItems = globalContextMenuItems;
|
|
28
|
+
this.objectContextMenuItems = objectContextMenuItems;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the active context menu items for display, translating each item's
|
|
32
|
+
* `label` through the current locale. When the label is a known
|
|
33
|
+
* {@link KritzelTermKey} the translation is used; any other string is passed
|
|
34
|
+
* through unchanged. Runs at menu-open time so the labels reflect the locale
|
|
35
|
+
* active at that moment.
|
|
36
|
+
* @returns A new array of items with resolved labels.
|
|
37
|
+
*/
|
|
38
|
+
resolveLabels(items) {
|
|
39
|
+
return items.map(item => ({
|
|
40
|
+
...item,
|
|
41
|
+
label: this._core.localizationManager.translate(item.label),
|
|
42
|
+
children: item.children ? this.resolveLabels(item.children) : undefined,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the active context menu items (object or global) with localized labels.
|
|
47
|
+
*/
|
|
48
|
+
getResolvedContextMenuItems() {
|
|
49
|
+
const items = this._core.store.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
50
|
+
return this.resolveLabels(items);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Handles the context menu event (typically triggered by right-click).
|
|
54
|
+
* This method performs the following operations:
|
|
55
|
+
* 1. Validates that the selection tool is active; exits early otherwise.
|
|
56
|
+
* 2. Checks and resets the `skipContextMenu` flag if set.
|
|
57
|
+
* 3. Cancels any pending drag operation on the selection tool.
|
|
58
|
+
* 4. Clears any active selection box if present.
|
|
59
|
+
* 5. If an object is clicked, creates a new selection group containing that object.
|
|
60
|
+
* 6. Determines which menu items to display (object or global context menu).
|
|
61
|
+
* 7. Calculates the menu position, ensuring it stays within viewport bounds.
|
|
62
|
+
* 8. Updates the store state to show the context menu and disables canvas interactions.
|
|
63
|
+
* @param event - The pointer event containing the click coordinates and target information.
|
|
64
|
+
* @returns void - This method does not return a value; it updates state and triggers a rerender.
|
|
65
|
+
*/
|
|
66
|
+
handleContextMenu(event) {
|
|
67
|
+
if (this._core.store.state.activeTool?.toolType !== 'selection') {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (this._core.store.state.skipContextMenu) {
|
|
71
|
+
this._core.store.state.skipContextMenu = false;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const selectionTool = this._core.store.state.activeTool;
|
|
75
|
+
selectionTool?.moveHandler?.cancelPendingDrag();
|
|
76
|
+
if (this._core.store.selectionBox) {
|
|
77
|
+
this._core.store.objects.remove(object => object instanceof KritzelSelectionBox);
|
|
78
|
+
this._core.store.setSelectionBox(null);
|
|
79
|
+
this._core.store.state.isSelecting = false;
|
|
80
|
+
}
|
|
81
|
+
const selectedObject = this._core.getObjectFromPointerEvent(event, '.object');
|
|
82
|
+
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup) && !(selectedObject instanceof KritzelSelectionBox)) {
|
|
83
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
84
|
+
selectionGroup.addOrRemove(selectedObject);
|
|
85
|
+
selectionGroup.isSelected = true;
|
|
86
|
+
selectionGroup.rotation = selectedObject.rotation;
|
|
87
|
+
this._core.store.state.isSelecting = false;
|
|
88
|
+
const currentSelectionGroup = this._core.store.selectionGroup;
|
|
89
|
+
if (currentSelectionGroup) {
|
|
90
|
+
this._core.removeSelectionGroup();
|
|
91
|
+
}
|
|
92
|
+
this._core.addSelectionGroup(selectionGroup);
|
|
93
|
+
this._core.rerender();
|
|
94
|
+
}
|
|
95
|
+
this._core.store.state.contextMenuItems = this.getResolvedContextMenuItems();
|
|
96
|
+
const clickX = event.clientX - this._core.store.offsetX;
|
|
97
|
+
const clickY = event.clientY - this._core.store.offsetY;
|
|
98
|
+
const { translateX, translateY, scale } = this._core.store.state;
|
|
99
|
+
this._core.store.state.contextMenuWorldX = (clickX - translateX) / scale;
|
|
100
|
+
this._core.store.state.contextMenuWorldY = (clickY - translateY) / scale;
|
|
101
|
+
let x = clickX;
|
|
102
|
+
let y = clickY;
|
|
103
|
+
const menuWidthEstimate = 150;
|
|
104
|
+
const margin = 10;
|
|
105
|
+
if (x + menuWidthEstimate > this._core.store.state.viewportWidth - margin) {
|
|
106
|
+
x = this._core.store.state.viewportWidth - menuWidthEstimate - margin;
|
|
107
|
+
}
|
|
108
|
+
x = Math.max(margin, x);
|
|
109
|
+
y = Math.max(margin, y);
|
|
110
|
+
this._core.store.state.contextMenuX = x;
|
|
111
|
+
this._core.store.state.contextMenuY = y;
|
|
112
|
+
this._core.store.state.isContextMenuVisible = true;
|
|
113
|
+
this._core.store.state.isEnabled = false;
|
|
114
|
+
this._core.rerender();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Programmatically opens the context menu at a specified world-coordinate position.
|
|
118
|
+
* If an objectId is provided and found, the object context menu is shown for that object.
|
|
119
|
+
* If no objectId is provided but a selection group exists, the object context menu is shown.
|
|
120
|
+
* Otherwise, the global context menu is shown.
|
|
121
|
+
* @param options.x - The X position in world (canvas) coordinates.
|
|
122
|
+
* @param options.y - The Y position in world (canvas) coordinates.
|
|
123
|
+
* @param options.objectId - Optional ID of an object to select and show the object context menu for.
|
|
124
|
+
*/
|
|
125
|
+
open(options) {
|
|
126
|
+
const { x, y, objectId } = options;
|
|
127
|
+
if (this._core.store.state.activeTool?.toolType === 'selection') {
|
|
128
|
+
const selectionTool = this._core.store.state.activeTool;
|
|
129
|
+
selectionTool?.moveHandler?.cancelPendingDrag();
|
|
130
|
+
}
|
|
131
|
+
if (this._core.store.selectionBox) {
|
|
132
|
+
this._core.store.objects.remove(object => object instanceof KritzelSelectionBox);
|
|
133
|
+
this._core.store.setSelectionBox(null);
|
|
134
|
+
this._core.store.state.isSelecting = false;
|
|
135
|
+
}
|
|
136
|
+
if (objectId) {
|
|
137
|
+
const targetObject = this._core.store.allObjects.find(obj => obj.id === objectId);
|
|
138
|
+
if (targetObject && !(targetObject instanceof KritzelSelectionGroup) && !(targetObject instanceof KritzelSelectionBox)) {
|
|
139
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
140
|
+
selectionGroup.addOrRemove(targetObject);
|
|
141
|
+
selectionGroup.isSelected = true;
|
|
142
|
+
selectionGroup.rotation = targetObject.rotation;
|
|
143
|
+
this._core.store.state.isSelecting = false;
|
|
144
|
+
const currentSelectionGroup = this._core.store.selectionGroup;
|
|
145
|
+
if (currentSelectionGroup) {
|
|
146
|
+
this._core.removeSelectionGroup();
|
|
147
|
+
}
|
|
148
|
+
this._core.addSelectionGroup(selectionGroup);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this._core.store.state.contextMenuItems = this.getResolvedContextMenuItems();
|
|
152
|
+
this._core.store.state.contextMenuWorldX = x;
|
|
153
|
+
this._core.store.state.contextMenuWorldY = y;
|
|
154
|
+
const { translateX, translateY, scale } = this._core.store.state;
|
|
155
|
+
let screenX = x * scale + translateX;
|
|
156
|
+
let screenY = y * scale + translateY;
|
|
157
|
+
const menuWidthEstimate = 150;
|
|
158
|
+
const margin = 10;
|
|
159
|
+
if (screenX + menuWidthEstimate > this._core.store.state.viewportWidth - margin) {
|
|
160
|
+
screenX = this._core.store.state.viewportWidth - menuWidthEstimate - margin;
|
|
161
|
+
}
|
|
162
|
+
screenX = Math.max(margin, screenX);
|
|
163
|
+
screenY = Math.max(margin, screenY);
|
|
164
|
+
this._core.store.state.contextMenuX = screenX;
|
|
165
|
+
this._core.store.state.contextMenuY = screenY;
|
|
166
|
+
this._core.store.state.isContextMenuVisible = true;
|
|
167
|
+
this._core.store.state.isEnabled = false;
|
|
168
|
+
this._core.rerender();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
2
|
+
/**
|
|
3
|
+
* Handles hover interactions on the Kritzel canvas.
|
|
4
|
+
* Detects when the pointer moves over canvas objects and updates their hover state accordingly.
|
|
5
|
+
* Currently only processes mouse input, with placeholder support for touch and pen devices.
|
|
6
|
+
*/
|
|
7
|
+
export class KritzelHoverHandler extends KritzelBaseHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new instance of the hover handler.
|
|
10
|
+
* @param core - The KritzelCore instance that provides access to canvas state and object detection.
|
|
11
|
+
*/
|
|
12
|
+
constructor(core) {
|
|
13
|
+
super(core);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Handles pointer move events to detect and update object hover states.
|
|
17
|
+
* For mouse input, performs a hit test on the object under the pointer and updates
|
|
18
|
+
* its `isHovered` property based on whether the pointer coordinates intersect with the object.
|
|
19
|
+
* Touch and pen input types are recognized but not yet implemented.
|
|
20
|
+
* @param event - The pointer event containing information about the pointer type and position.
|
|
21
|
+
* @returns void - This method does not return a value; it updates object state as a side effect.
|
|
22
|
+
*/
|
|
23
|
+
handlePointerMove(event) {
|
|
24
|
+
if (event.pointerType === 'mouse') {
|
|
25
|
+
const hoveredObject = this._core.getObjectFromPointerEvent(event, '.object');
|
|
26
|
+
if (!hoveredObject)
|
|
27
|
+
return;
|
|
28
|
+
const x = this._core.store.state.pointerX;
|
|
29
|
+
const y = this._core.store.state.pointerY;
|
|
30
|
+
hoveredObject.isHovered = hoveredObject.hitTest(x, y);
|
|
31
|
+
}
|
|
32
|
+
if (event.pointerType === 'touch' || event.pointerType === 'pen') {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { KritzelBaseHandler } from "./base.handler";
|
|
2
|
+
/** The amount of pixels to move an object when using arrow key nudging. */
|
|
3
|
+
const NUDGE_AMOUNT = 10;
|
|
4
|
+
/**
|
|
5
|
+
* Handles keyboard events and manages keyboard shortcuts for the Kritzel canvas.
|
|
6
|
+
* Provides functionality for tool switching, object manipulation,
|
|
7
|
+
* undo/redo, and navigation via keyboard input.
|
|
8
|
+
*/
|
|
9
|
+
export class KritzelKeyHandler extends KritzelBaseHandler {
|
|
10
|
+
/**
|
|
11
|
+
* Array of registered keyboard shortcuts with their associated actions.
|
|
12
|
+
* Each shortcut defines the key combination, display label, category, optional condition, and action to execute.
|
|
13
|
+
*/
|
|
14
|
+
shortcuts = [
|
|
15
|
+
// General
|
|
16
|
+
{
|
|
17
|
+
key: 'Escape',
|
|
18
|
+
label: 'Clear Selection',
|
|
19
|
+
category: 'General',
|
|
20
|
+
condition: c => !!c.store.activeText || !!c.store.activeShape || !!c.store.selectionGroup,
|
|
21
|
+
action: c => {
|
|
22
|
+
if (c.store.activeText) {
|
|
23
|
+
c.store.activeText.handleEscape();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (c.store.activeShape) {
|
|
27
|
+
c.store.activeShape.handleEscape();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
c.clearSelection();
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{ key: 'Delete', label: 'Delete Selected', category: 'General', condition: c => !!c.store.selectionGroup, action: c => c.delete() },
|
|
34
|
+
{ key: 'a', ctrl: true, label: 'Select All in Viewport', category: 'General', action: c => c.selectAllObjectsInViewport() },
|
|
35
|
+
{ key: 'A', ctrl: true, shift: true, label: 'Select All Objects', category: 'General', action: c => c.selectAllObjects() },
|
|
36
|
+
// Undo/Redo
|
|
37
|
+
{ key: 'z', ctrl: true, label: 'Undo', category: 'Undo/Redo', action: c => c.undo() },
|
|
38
|
+
{ key: 'y', ctrl: true, label: 'Redo', category: 'Undo/Redo', action: c => c.redo() },
|
|
39
|
+
// Tool selection (Ctrl+1-9)
|
|
40
|
+
{ key: '1', ctrl: true, label: 'Tool 1', category: 'Tool Selection', action: () => this.switchToolByIndex(0) },
|
|
41
|
+
{ key: '2', ctrl: true, label: 'Tool 2', category: 'Tool Selection', action: () => this.switchToolByIndex(1) },
|
|
42
|
+
{ key: '3', ctrl: true, label: 'Tool 3', category: 'Tool Selection', action: () => this.switchToolByIndex(2) },
|
|
43
|
+
{ key: '4', ctrl: true, label: 'Tool 4', category: 'Tool Selection', action: () => this.switchToolByIndex(3) },
|
|
44
|
+
{ key: '5', ctrl: true, label: 'Tool 5', category: 'Tool Selection', action: () => this.switchToolByIndex(4) },
|
|
45
|
+
{ key: '6', ctrl: true, label: 'Tool 6', category: 'Tool Selection', action: () => this.switchToolByIndex(5) },
|
|
46
|
+
{ key: '7', ctrl: true, label: 'Tool 7', category: 'Tool Selection', action: () => this.switchToolByIndex(6) },
|
|
47
|
+
{ key: '8', ctrl: true, label: 'Tool 8', category: 'Tool Selection', action: () => this.switchToolByIndex(7) },
|
|
48
|
+
{ key: '9', ctrl: true, label: 'Tool 9', category: 'Tool Selection', action: () => this.switchToolByIndex(8) },
|
|
49
|
+
// Object layering
|
|
50
|
+
{ key: '+', ctrl: true, label: 'Bring Forward', category: 'Object Layering', condition: c => !!c.store.selectionGroup, action: c => c.bringForward() },
|
|
51
|
+
{ key: '-', ctrl: true, label: 'Send Backward', category: 'Object Layering', condition: c => !!c.store.selectionGroup, action: c => c.sendBackward() },
|
|
52
|
+
{ key: '*', shift: true, label: 'Bring to Front', category: 'Object Layering', condition: c => !!c.store.selectionGroup, action: c => c.bringToFront() },
|
|
53
|
+
{ key: '_', shift: true, label: 'Send to Back', category: 'Object Layering', condition: c => !!c.store.selectionGroup, action: c => c.sendToBack() },
|
|
54
|
+
// Grouping
|
|
55
|
+
{ key: 'g', ctrl: true, label: 'Group', category: 'Grouping', condition: c => !!c.store.selectionGroup && c.store.selectionGroup.objects.length >= 2, action: c => c.group() },
|
|
56
|
+
{ key: 'G', ctrl: true, shift: true, label: 'Ungroup', category: 'Grouping', condition: c => !!c.store.selectionGroup, action: c => c.ungroup() },
|
|
57
|
+
// Movement
|
|
58
|
+
{
|
|
59
|
+
key: 'ArrowUp',
|
|
60
|
+
label: 'Move Object Up',
|
|
61
|
+
category: 'Movement',
|
|
62
|
+
condition: c => !!c.store.selectionGroup,
|
|
63
|
+
action: c => {
|
|
64
|
+
c.store.selectionGroup.move(0, 0, 0, NUDGE_AMOUNT);
|
|
65
|
+
c.rerender();
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: 'ArrowDown',
|
|
70
|
+
label: 'Move Object Down',
|
|
71
|
+
category: 'Movement',
|
|
72
|
+
condition: c => !!c.store.selectionGroup,
|
|
73
|
+
action: c => {
|
|
74
|
+
c.store.selectionGroup.move(0, NUDGE_AMOUNT, 0, 0);
|
|
75
|
+
c.rerender();
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: 'ArrowLeft',
|
|
80
|
+
label: 'Move Object Left',
|
|
81
|
+
category: 'Movement',
|
|
82
|
+
condition: c => !!c.store.selectionGroup,
|
|
83
|
+
action: c => {
|
|
84
|
+
c.store.selectionGroup.move(0, 0, NUDGE_AMOUNT, 0);
|
|
85
|
+
c.rerender();
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 'ArrowRight',
|
|
90
|
+
label: 'Move Object Right',
|
|
91
|
+
category: 'Movement',
|
|
92
|
+
condition: c => !!c.store.selectionGroup,
|
|
93
|
+
action: c => {
|
|
94
|
+
c.store.selectionGroup.move(NUDGE_AMOUNT, 0, 0, 0);
|
|
95
|
+
c.rerender();
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new instance of the key handler.
|
|
101
|
+
* @param core - The KritzelCore instance that provides access to the canvas state and operations.
|
|
102
|
+
*/
|
|
103
|
+
constructor(core) {
|
|
104
|
+
super(core);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Switches the active tool to the tool at the specified index in the tool registry.
|
|
108
|
+
* Deselects all objects and activates the new tool if found.
|
|
109
|
+
* @param index - The zero-based index of the tool to activate from the tool registry.
|
|
110
|
+
*/
|
|
111
|
+
switchToolByIndex(index) {
|
|
112
|
+
const toolInstance = this._core.toolRegistry.getToolByIndex(index);
|
|
113
|
+
if (toolInstance) {
|
|
114
|
+
this._core.store.setState('activeTool', toolInstance);
|
|
115
|
+
this._core.deselectAllObjects();
|
|
116
|
+
toolInstance.onActivate();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Handles keydown events and executes matching keyboard shortcuts.
|
|
121
|
+
* Updates the Ctrl key state in the store and finds matching shortcuts based on
|
|
122
|
+
* the pressed key combination and any defined conditions.
|
|
123
|
+
* @param event - The keyboard event triggered by the user pressing a key.
|
|
124
|
+
*/
|
|
125
|
+
handleKeyDown(event) {
|
|
126
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
127
|
+
// While a text or shape's text editor is being edited, let ProseMirror /
|
|
128
|
+
// the browser handle keys natively (Ctrl+A, Ctrl+C, arrows, etc.) instead
|
|
129
|
+
// of running global canvas shortcuts. Escape is the one exception — it
|
|
130
|
+
// still runs through the shortcut system so it can collapse the text
|
|
131
|
+
// selection (handled inside the shortcut's action).
|
|
132
|
+
if ((this._core.store.activeText || this._core.store.activeShape || this._core.store.activeInteractiveDynamicObject) && event.key !== 'Escape') {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const shortcut = this.shortcuts.find(s => s.key === event.key && !!s.ctrl === event.ctrlKey && !!s.shift === event.shiftKey && (!s.condition || s.condition(this._core)));
|
|
136
|
+
if (shortcut) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
shortcut.action(this._core);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handles keyup events and updates the Ctrl key state.
|
|
143
|
+
* @param event - The keyboard event triggered by the user releasing a key.
|
|
144
|
+
*/
|
|
145
|
+
handleKeyUp(event) {
|
|
146
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Returns a list of all registered shortcuts suitable for display in a UI help dialog.
|
|
150
|
+
* Excludes the action and condition properties to provide only the display-relevant information.
|
|
151
|
+
* @returns An array of shortcut objects containing key, modifiers, label, and category.
|
|
152
|
+
*/
|
|
153
|
+
getDisplayableShortcuts() {
|
|
154
|
+
return this.shortcuts.map(({ key, ctrl, shift, label, category }) => ({
|
|
155
|
+
key,
|
|
156
|
+
ctrl,
|
|
157
|
+
shift,
|
|
158
|
+
label,
|
|
159
|
+
category,
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
}
|