@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,198 @@
|
|
|
1
|
+
import { KritzelSelectionGroup } from '../objects/selection-group.class';
|
|
2
|
+
import { KritzelEngineState } from '../../interfaces/engine-state.interface';
|
|
3
|
+
import { KritzelSelectionBox } from '../objects/selection-box.class';
|
|
4
|
+
import { KritzelText } from '../objects/text.class';
|
|
5
|
+
import { KritzelShape } from '../objects/shape.class';
|
|
6
|
+
import { KritzelPath } from '../objects/path.class';
|
|
7
|
+
import { KritzelLine } from '../objects/line.class';
|
|
8
|
+
import { KritzelDynamicObject } from '../objects/dynamic-object.class';
|
|
9
|
+
import { StateChangeListener, StatePropertyKey } from '../../types/state.types';
|
|
10
|
+
import { KritzelObjectMap } from '../structures/object-map.structure';
|
|
11
|
+
import { KritzelBaseObject } from '../objects/base-object.class';
|
|
12
|
+
/**
|
|
13
|
+
* Central state management store for the Kritzel engine.
|
|
14
|
+
* Provides reactive state management with change listeners, caching for frequently
|
|
15
|
+
* accessed objects, and computed properties for viewport and selection state.
|
|
16
|
+
*/
|
|
17
|
+
export declare class KritzelStore {
|
|
18
|
+
/** Internal state object containing all engine state properties */
|
|
19
|
+
private readonly _state;
|
|
20
|
+
/** Map of property keys to their registered change listeners */
|
|
21
|
+
private readonly _listeners;
|
|
22
|
+
private _cachedSelectionBox;
|
|
23
|
+
private _cachedSelectionGroup;
|
|
24
|
+
private _selectionBoxCacheValid;
|
|
25
|
+
private _selectionGroupCacheValid;
|
|
26
|
+
private _localUserId;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current engine state.
|
|
29
|
+
* @returns The mutable engine state object
|
|
30
|
+
*/
|
|
31
|
+
get state(): KritzelEngineState;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the map of all objects in the workspace.
|
|
34
|
+
* Throws an error if the objects map is not initialized, as it is required for all object management.
|
|
35
|
+
* @returns The KritzelObjectMap containing all objects
|
|
36
|
+
* @throws Error if the objects map is not initialized in the state
|
|
37
|
+
*/
|
|
38
|
+
get objects(): KritzelObjectMap<KritzelBaseObject<Element>>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the host element for the Kritzel editor.
|
|
41
|
+
* Throws an error if the host is not set, as it is required for many operations.
|
|
42
|
+
* @returns The host HTMLElement
|
|
43
|
+
* @throws Error if the host element is not set in the state
|
|
44
|
+
*/
|
|
45
|
+
get host(): HTMLElement;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the next available z-index for new objects.
|
|
48
|
+
* Calculates the maximum z-index among all non-selection objects and adds 1.
|
|
49
|
+
* @returns The next z-index value to use for new objects
|
|
50
|
+
*/
|
|
51
|
+
get currentZIndex(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if viewport boundaries are set to finite values (not Infinity).
|
|
54
|
+
*/
|
|
55
|
+
get hasViewportBoundaries(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the viewport boundary bounds for querying objects.
|
|
58
|
+
* Uses the configured boundaries, defaulting to Infinity for unset values.
|
|
59
|
+
*/
|
|
60
|
+
private get viewportBoundaryBounds();
|
|
61
|
+
/**
|
|
62
|
+
* Gets the total count of objects in the workspace.
|
|
63
|
+
* When viewport boundaries are set, returns only objects within those boundaries.
|
|
64
|
+
* @returns The total number of objects
|
|
65
|
+
*/
|
|
66
|
+
get totalObjectCount(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Gets all objects in the workspace.
|
|
69
|
+
* When viewport boundaries are set, returns only objects within those boundaries.
|
|
70
|
+
* @returns Array of all canvas objects
|
|
71
|
+
*/
|
|
72
|
+
get allObjects(): KritzelBaseObject<Element>[];
|
|
73
|
+
/**
|
|
74
|
+
* Gets all objects currently visible in the viewport.
|
|
75
|
+
* Uses spatial querying for efficient retrieval and sorts by z-index.
|
|
76
|
+
* @returns Array of objects within the current viewport, sorted by z-index ascending
|
|
77
|
+
*/
|
|
78
|
+
get objectsInViewport(): KritzelBaseObject<Element>[];
|
|
79
|
+
/**
|
|
80
|
+
* Gets all objects excluding selection-related objects (selection group and selection box).
|
|
81
|
+
* @returns Array of all regular canvas objects
|
|
82
|
+
*/
|
|
83
|
+
get allNonSelectionObjects(): KritzelBaseObject<Element>[];
|
|
84
|
+
/**
|
|
85
|
+
* Gets all currently selected objects (excluding the selection group itself).
|
|
86
|
+
* @returns Array of selected objects
|
|
87
|
+
*/
|
|
88
|
+
get selectedObjects(): KritzelBaseObject<Element>[];
|
|
89
|
+
/**
|
|
90
|
+
* Gets the current selection box if one exists.
|
|
91
|
+
* Uses caching for O(1) access after initial lookup.
|
|
92
|
+
* @returns The selection box or null if none exists
|
|
93
|
+
*/
|
|
94
|
+
get selectionBox(): KritzelSelectionBox | null;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the current local user's selection group if one exists.
|
|
97
|
+
* When a local user ID is set, returns only the selection group belonging to that user.
|
|
98
|
+
* Uses caching for O(1) access after initial lookup.
|
|
99
|
+
* @returns The local user's selection group or null if none exists
|
|
100
|
+
*/
|
|
101
|
+
get selectionGroup(): KritzelSelectionGroup | null;
|
|
102
|
+
/**
|
|
103
|
+
* Invalidate cached selection objects. Call this when selection objects are inserted or removed.
|
|
104
|
+
*/
|
|
105
|
+
invalidateSelectionCache(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Directly set the cached selection box reference for O(1) access.
|
|
108
|
+
* Use this when creating the selection box to avoid a filter lookup.
|
|
109
|
+
* @param box - The selection box to cache, or null to clear the cache
|
|
110
|
+
*/
|
|
111
|
+
setSelectionBox(box: KritzelSelectionBox | null): void;
|
|
112
|
+
/**
|
|
113
|
+
* Directly set the cached selection group reference for O(1) access.
|
|
114
|
+
* Use this when creating the selection group to avoid a filter lookup.
|
|
115
|
+
* @param group - The selection group to cache, or null to clear the cache
|
|
116
|
+
*/
|
|
117
|
+
setSelectionGroup(group: KritzelSelectionGroup | null): void;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the local user ID for scoping selection group lookups.
|
|
120
|
+
* When set, the selectionGroup getter returns only the group owned by this user.
|
|
121
|
+
* @param userId - The local user's ID, or null for non-collaborative mode
|
|
122
|
+
*/
|
|
123
|
+
setLocalUserId(userId: string | null): void;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the currently active text object being edited.
|
|
126
|
+
* @returns The text object in editing mode, or null if none
|
|
127
|
+
*/
|
|
128
|
+
get activeText(): KritzelText | null;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the currently active shape object being edited.
|
|
131
|
+
* @returns The shape object in editing mode, or null if none
|
|
132
|
+
*/
|
|
133
|
+
get activeShape(): KritzelShape | null;
|
|
134
|
+
/**
|
|
135
|
+
* Gets the currently selected dynamic object whose focused descendant is an input-like element.
|
|
136
|
+
* @returns The interactive dynamic object with focused input-like content, or null if none matches
|
|
137
|
+
*/
|
|
138
|
+
get activeInteractiveDynamicObject(): KritzelDynamicObject | null;
|
|
139
|
+
/**
|
|
140
|
+
* Gets the path currently being drawn (not yet completed).
|
|
141
|
+
* @returns The incomplete path object, or null if no path is being drawn
|
|
142
|
+
*/
|
|
143
|
+
get currentPath(): KritzelPath | null;
|
|
144
|
+
/**
|
|
145
|
+
* Gets the line currently being drawn (not yet completed).
|
|
146
|
+
* @returns The incomplete line object, or null if no line is being drawn
|
|
147
|
+
*/
|
|
148
|
+
get currentLine(): KritzelLine | null;
|
|
149
|
+
/**
|
|
150
|
+
* Gets the horizontal offset of the host element from the viewport.
|
|
151
|
+
* @returns The left position of the host element in client coordinates
|
|
152
|
+
*/
|
|
153
|
+
get offsetX(): number;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the vertical offset of the host element from the viewport.
|
|
156
|
+
* @returns The top position of the host element in client coordinates
|
|
157
|
+
*/
|
|
158
|
+
get offsetY(): number;
|
|
159
|
+
/**
|
|
160
|
+
* Checks if the engine is currently disabled.
|
|
161
|
+
* The engine is disabled when not enabled, not ready, or no active workspace exists.
|
|
162
|
+
* @returns True if the engine is disabled and should not process interactions
|
|
163
|
+
*/
|
|
164
|
+
get isDisabled(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Checks if any pointer is currently down (active).
|
|
167
|
+
* @returns True if at least one pointer is currently active
|
|
168
|
+
*/
|
|
169
|
+
get isPointerDown(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Creates a new KritzelStore instance.
|
|
172
|
+
* @param state - The initial engine state configuration
|
|
173
|
+
*/
|
|
174
|
+
constructor(state: KritzelEngineState);
|
|
175
|
+
/**
|
|
176
|
+
* Registers a listener for changes to a specific state property.
|
|
177
|
+
* The listener will be called whenever the property value changes.
|
|
178
|
+
* @typeParam K - The state property key type
|
|
179
|
+
* @param property - The property key to listen for changes on
|
|
180
|
+
* @param listener - The callback function to invoke on changes
|
|
181
|
+
*/
|
|
182
|
+
onStateChange<K extends StatePropertyKey>(property: K, listener: StateChangeListener<KritzelEngineState[K]>): void;
|
|
183
|
+
/**
|
|
184
|
+
* Gets the current value of a state property as readonly.
|
|
185
|
+
* @typeParam K - The state property key type
|
|
186
|
+
* @param property - The property key to retrieve
|
|
187
|
+
* @returns The current value of the property
|
|
188
|
+
*/
|
|
189
|
+
getState<K extends StatePropertyKey>(property: K): Readonly<KritzelEngineState[K]>;
|
|
190
|
+
/**
|
|
191
|
+
* Sets a state property value and notifies registered listeners.
|
|
192
|
+
* Only triggers listeners if the value actually changed.
|
|
193
|
+
* @typeParam K - The state property key type
|
|
194
|
+
* @param property - The property key to set
|
|
195
|
+
* @param value - The new value to assign
|
|
196
|
+
*/
|
|
197
|
+
setState<K extends StatePropertyKey>(property: K, value: KritzelEngineState[K]): void;
|
|
198
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { KritzelBaseObject } from '../objects/base-object.class';
|
|
2
|
+
import { KritzelCore } from './core.class';
|
|
3
|
+
import { KritzelViewportState } from '../../interfaces/viewport-state.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Manages viewport transformations including panning, zooming, and centering.
|
|
6
|
+
* Handles mouse, touch, and wheel events for viewport manipulation.
|
|
7
|
+
* Supports viewport boundaries and animated transitions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class KritzelViewport {
|
|
10
|
+
/** Reference to the KritzelCore instance */
|
|
11
|
+
private readonly _core;
|
|
12
|
+
/** Debounced function to persist viewport state to workspace */
|
|
13
|
+
private readonly _debounceUpdate;
|
|
14
|
+
/** Debounced function to end scaling state after pinch gestures */
|
|
15
|
+
private readonly _debounceEndScaling;
|
|
16
|
+
/** Animation frame ID for cancellable viewport animations */
|
|
17
|
+
private _animationFrameId;
|
|
18
|
+
/** Initial distance between two touch points for pinch-to-zoom */
|
|
19
|
+
initialTouchDistance: number;
|
|
20
|
+
/** Starting X position for pan/zoom gestures */
|
|
21
|
+
startX: number;
|
|
22
|
+
/** Starting Y position for pan/zoom gestures */
|
|
23
|
+
startY: number;
|
|
24
|
+
/** Minimum movement distance (in screen pixels) before broadcasting touch cursor position */
|
|
25
|
+
private static readonly TOUCH_CURSOR_BROADCAST_THRESHOLD;
|
|
26
|
+
/** Screen X position where the current touch interaction started */
|
|
27
|
+
private _touchStartScreenX;
|
|
28
|
+
/** Screen Y position where the current touch interaction started */
|
|
29
|
+
private _touchStartScreenY;
|
|
30
|
+
/** Whether the touch movement threshold has been exceeded for cursor broadcasting */
|
|
31
|
+
private _touchCursorBroadcastActive;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new KritzelViewport instance and initializes viewport state.
|
|
34
|
+
* Sets up debounced handlers for viewport updates and scaling end events.
|
|
35
|
+
* @param core - The KritzelCore instance to manage viewport for
|
|
36
|
+
* @param host - The HTML element hosting the canvas
|
|
37
|
+
*/
|
|
38
|
+
constructor(core: KritzelCore, host: HTMLElement);
|
|
39
|
+
/**
|
|
40
|
+
* Cancels any pending debounced viewport updates.
|
|
41
|
+
* Should be called before switching workspaces to prevent the old workspace's
|
|
42
|
+
* viewport state from being saved to the new workspace.
|
|
43
|
+
*/
|
|
44
|
+
cancelPendingUpdates(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clamps translateX and translateY to respect viewport boundaries.
|
|
47
|
+
* Boundaries are defined in world coordinates and converted to screen-space translate limits.
|
|
48
|
+
* @param translateX - The proposed translateX value
|
|
49
|
+
* @param translateY - The proposed translateY value
|
|
50
|
+
* @returns Clamped translate values
|
|
51
|
+
*/
|
|
52
|
+
private clampTranslate;
|
|
53
|
+
/**
|
|
54
|
+
* Calculates the effective minimum scale considering both the configured scaleMin
|
|
55
|
+
* and the minimum scale required to keep the viewport within boundaries.
|
|
56
|
+
* This prevents users from zooming out far enough to see past the boundaries.
|
|
57
|
+
* @returns The effective minimum scale value
|
|
58
|
+
*/
|
|
59
|
+
private getEffectiveMinScale;
|
|
60
|
+
/**
|
|
61
|
+
* Handles viewport resize events.
|
|
62
|
+
* Updates the stored viewport dimensions and triggers a rerender.
|
|
63
|
+
*/
|
|
64
|
+
handleResize(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Handles pointer down events for initiating viewport interactions.
|
|
67
|
+
* For mouse: Right-click starts panning mode.
|
|
68
|
+
* For touch/pen: Two-finger touch initiates pinch-to-zoom.
|
|
69
|
+
* Cancels any ongoing viewport animation when user starts interacting.
|
|
70
|
+
* @param event - The pointer down event
|
|
71
|
+
*/
|
|
72
|
+
handlePointerDown(event: PointerEvent): void;
|
|
73
|
+
/**
|
|
74
|
+
* Handles pointer move events for viewport panning and zooming.
|
|
75
|
+
* For mouse: Updates pointer position and handles right-click pan dragging.
|
|
76
|
+
* For touch/pen: Handles two-finger pinch-to-zoom with translation.
|
|
77
|
+
* @param event - The pointer move event
|
|
78
|
+
*/
|
|
79
|
+
handlePointerMove(event: PointerEvent): void;
|
|
80
|
+
/**
|
|
81
|
+
* Handles pointer up events to end viewport interactions.
|
|
82
|
+
* For mouse: Ends panning mode on right-click release.
|
|
83
|
+
* For touch/pen: Triggers debounced end of scaling when all fingers are lifted.
|
|
84
|
+
* @param event - The pointer up event
|
|
85
|
+
*/
|
|
86
|
+
handlePointerUp(event: PointerEvent): void;
|
|
87
|
+
/**
|
|
88
|
+
* Handles mouse wheel events for panning and zooming.
|
|
89
|
+
* Ctrl+wheel triggers zoom; regular wheel triggers pan.
|
|
90
|
+
* Cancels any ongoing viewport animation when user scrolls.
|
|
91
|
+
* @param event - The wheel event
|
|
92
|
+
*/
|
|
93
|
+
handleWheel(event: WheelEvent): void;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the current viewport state.
|
|
96
|
+
* @returns The current viewport position, scale, and dimensions.
|
|
97
|
+
*/
|
|
98
|
+
getViewport(): KritzelViewportState;
|
|
99
|
+
/**
|
|
100
|
+
* Converts screen-relative pixel coordinates to world coordinates.
|
|
101
|
+
* @param x - X position in screen pixels (relative to the host element)
|
|
102
|
+
* @param y - Y position in screen pixels (relative to the host element)
|
|
103
|
+
* @returns World coordinates { x, y }
|
|
104
|
+
*/
|
|
105
|
+
screenToWorld(x: number, y: number): {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Converts world coordinates to screen-relative pixel coordinates.
|
|
111
|
+
* @param x - X position in world coordinates
|
|
112
|
+
* @param y - Y position in world coordinates
|
|
113
|
+
* @returns Screen coordinates { x, y } relative to the host element
|
|
114
|
+
*/
|
|
115
|
+
worldToScreen(x: number, y: number): {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Animates the viewport to center on the given world coordinates at the specified scale.
|
|
121
|
+
* Respects scale limits and viewport boundaries.
|
|
122
|
+
* @param x - X position in world coordinates to center on
|
|
123
|
+
* @param y - Y position in world coordinates to center on
|
|
124
|
+
* @param scale - Target scale level
|
|
125
|
+
*/
|
|
126
|
+
setViewport(x: number, y: number, scale: number): void;
|
|
127
|
+
/**
|
|
128
|
+
* Animates the viewport to center on the given world coordinates without changing the scale.
|
|
129
|
+
* @param x - X position in world coordinates to center on
|
|
130
|
+
* @param y - Y position in world coordinates to center on
|
|
131
|
+
*/
|
|
132
|
+
panTo(x: number, y: number): void;
|
|
133
|
+
/**
|
|
134
|
+
* Animates the viewport to the given scale level.
|
|
135
|
+
* Optionally centers on a world point; if omitted, zooms around the viewport center.
|
|
136
|
+
* @param scale - Target scale level
|
|
137
|
+
* @param worldX - Optional X position in world coordinates to center on
|
|
138
|
+
* @param worldY - Optional Y position in world coordinates to center on
|
|
139
|
+
*/
|
|
140
|
+
zoomTo(scale: number, worldX?: number, worldY?: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Zooms in by a fixed step, centered on the current viewport center,
|
|
143
|
+
* with a smooth animation. The resulting scale is clamped to the allowed range.
|
|
144
|
+
* @param factor - Multiplicative zoom-in step
|
|
145
|
+
* @param duration - Animation duration in milliseconds
|
|
146
|
+
*/
|
|
147
|
+
zoomIn(factor: number, duration: number): void;
|
|
148
|
+
/**
|
|
149
|
+
* Zooms out by a fixed step, centered on the current viewport center,
|
|
150
|
+
* with a smooth animation. The resulting scale is clamped to the allowed range.
|
|
151
|
+
* @param factor - Multiplicative zoom-out step
|
|
152
|
+
* @param duration - Animation duration in milliseconds
|
|
153
|
+
*/
|
|
154
|
+
zoomOut(factor: number, duration: number): void;
|
|
155
|
+
/**
|
|
156
|
+
* Smoothly zooms around the viewport center, keeping the center world point
|
|
157
|
+
* fixed for the entire animation. The translation is recomputed from the fixed
|
|
158
|
+
* center point on every frame (rather than interpolated independently), which
|
|
159
|
+
* guarantees the center never drifts and the viewport does not jump.
|
|
160
|
+
* The resulting scale is clamped to the allowed range and the translation is
|
|
161
|
+
* clamped to the viewport boundaries.
|
|
162
|
+
* @param scaleFactor - Multiplicative scale factor (>1 zooms in, <1 zooms out)
|
|
163
|
+
* @param duration - Animation duration in milliseconds
|
|
164
|
+
*/
|
|
165
|
+
private animateZoomAroundViewportCenter;
|
|
166
|
+
/**
|
|
167
|
+
* Applies a single zoom step that keeps the given world point anchored to the
|
|
168
|
+
* given screen point at the specified scale, clamped to the viewport boundaries.
|
|
169
|
+
*/
|
|
170
|
+
private applyZoomAroundCenter;
|
|
171
|
+
/**
|
|
172
|
+
* Centers a given object in the viewport without changing the scale.
|
|
173
|
+
* The object's center point will be positioned at the viewport center.
|
|
174
|
+
* Respects viewport boundary constraints.
|
|
175
|
+
* @param object - The object to center in the viewport
|
|
176
|
+
*/
|
|
177
|
+
centerInViewport(object: KritzelBaseObject): void;
|
|
178
|
+
/**
|
|
179
|
+
* Centers and scales the viewport to fit a given object with 10% padding.
|
|
180
|
+
* Calculates the optimal scale to show the entire object while respecting
|
|
181
|
+
* scale limits and viewport boundaries.
|
|
182
|
+
* @param object - The object to fit in the viewport
|
|
183
|
+
*/
|
|
184
|
+
centerFitInViewport(object: KritzelBaseObject): void;
|
|
185
|
+
/**
|
|
186
|
+
* Centers the viewport on a given object and zooms out only if the object
|
|
187
|
+
* does not fit at the current scale. Never zooms in — if the object already
|
|
188
|
+
* fits, the scale is left unchanged.
|
|
189
|
+
* @param object - The object to fit in the viewport
|
|
190
|
+
*/
|
|
191
|
+
centerFitInViewportIfNeeded(object: KritzelBaseObject): void;
|
|
192
|
+
/**
|
|
193
|
+
* Zooms out and centers the viewport on a given object only if the object
|
|
194
|
+
* does not fit at the current scale. If the object already fits, the
|
|
195
|
+
* viewport is left completely unchanged.
|
|
196
|
+
* @param object - The object to check and fit in the viewport
|
|
197
|
+
*/
|
|
198
|
+
fitInViewportIfNeeded(object: KritzelBaseObject): void;
|
|
199
|
+
/**
|
|
200
|
+
* Smoothly brings a given object into view if it is not fully visible within
|
|
201
|
+
* the current viewport. Zooms out only if the object is too large to fit at
|
|
202
|
+
* the current scale; never zooms in. If the object is already fully visible,
|
|
203
|
+
* the viewport is left unchanged.
|
|
204
|
+
* @param object - The object to bring into view
|
|
205
|
+
*/
|
|
206
|
+
bringIntoViewIfNeeded(object: KritzelBaseObject): void;
|
|
207
|
+
/**
|
|
208
|
+
* Handles zoom operations triggered by wheel events with Ctrl key.
|
|
209
|
+
* Zooms around the cursor position, respecting scale limits.
|
|
210
|
+
* Also handles horizontal pan from trackpad pinch+drag gestures.
|
|
211
|
+
* @param event - The wheel event with Ctrl modifier
|
|
212
|
+
*/
|
|
213
|
+
private handleZoom;
|
|
214
|
+
/**
|
|
215
|
+
* Handles pan operations triggered by wheel events (without Ctrl).
|
|
216
|
+
* Applies a pan speed multiplier and clamps to viewport boundaries.
|
|
217
|
+
* @param event - The wheel event without Ctrl modifier
|
|
218
|
+
*/
|
|
219
|
+
private handlePan;
|
|
220
|
+
/**
|
|
221
|
+
* Cancels any ongoing viewport animation.
|
|
222
|
+
* Called when user interacts with the canvas during animation.
|
|
223
|
+
*/
|
|
224
|
+
cancelViewportAnimation(): void;
|
|
225
|
+
/**
|
|
226
|
+
* Animates the viewport to the specified position and scale.
|
|
227
|
+
* @param targetTranslateX - Target X translation
|
|
228
|
+
* @param targetTranslateY - Target Y translation
|
|
229
|
+
* @param targetScale - Target scale
|
|
230
|
+
* @param duration - Animation duration in milliseconds (default 150)
|
|
231
|
+
*/
|
|
232
|
+
animateViewportTo(targetTranslateX: number, targetTranslateY: number, targetScale: number, duration?: number): void;
|
|
233
|
+
/**
|
|
234
|
+
* Centers and fits the nearest content objects in the viewport.
|
|
235
|
+
* Finds up to maxObjects closest objects to the current viewport center
|
|
236
|
+
* and animates the viewport to show them.
|
|
237
|
+
* @param maxObjects - Maximum number of objects to consider (default 20)
|
|
238
|
+
* @returns true if content was found and viewport is animating, false if no content exists
|
|
239
|
+
*/
|
|
240
|
+
centerFitNearestContent(maxObjects?: number): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Centers and fits the provided objects in the viewport.
|
|
243
|
+
* Calculates the combined bounding box of the provided objects and optionally animates the viewport to show them.
|
|
244
|
+
* @param objects - Objects to include in the fit operation.
|
|
245
|
+
* @param animate - Whether to animate the viewport transition (default: true)
|
|
246
|
+
* @returns true if at least one object was provided and viewport was adjusted, false otherwise
|
|
247
|
+
*/
|
|
248
|
+
centerFitObjects<T extends Element>(objects: KritzelBaseObject<T>[], animate?: boolean): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Centers and fits ALL objects in the viewport, including objects not currently rendered.
|
|
251
|
+
* Calculates the combined bounding box of all objects and optionally animates the viewport to show them.
|
|
252
|
+
* @param animate - Whether to animate the viewport transition (default: true)
|
|
253
|
+
* @returns true if objects were found and viewport was adjusted, false if no objects exist
|
|
254
|
+
*/
|
|
255
|
+
centerFitAllObjects(animate?: boolean): boolean;
|
|
256
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { KritzelSerializable } from "../../interfaces/serializable.interface";
|
|
2
|
+
import type { KritzelCore } from "./core.class";
|
|
3
|
+
import type { KritzelBaseObject } from "../objects/base-object.class";
|
|
4
|
+
/** Current version of the workspace export format */
|
|
5
|
+
export declare const WORKSPACE_EXPORT_VERSION = "1.3.0";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for creating a KritzelWorkspace instance.
|
|
8
|
+
*/
|
|
9
|
+
export interface KritzelWorkspaceConfig {
|
|
10
|
+
/** Unique identifier for the workspace. Auto-generated if omitted. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Display name of the workspace. Defaults to 'New Workspace' if omitted. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Initial viewport configuration containing world-space center coordinates and scale */
|
|
15
|
+
viewport?: {
|
|
16
|
+
centerWorldX?: number;
|
|
17
|
+
centerWorldY?: number;
|
|
18
|
+
scale?: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Canvas objects for this workspace. Seeded on first initialization, and treated as the
|
|
22
|
+
* desired object set by `updateWorkspace()`. Omit to leave existing objects untouched.
|
|
23
|
+
*/
|
|
24
|
+
objects?: KritzelBaseObject<any>[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Represents a workspace in the Kritzel canvas.
|
|
28
|
+
* A workspace is an isolated canvas area with its own set of objects and viewport state.
|
|
29
|
+
* It can be serialized and deserialized for persistence and collaborative editing.
|
|
30
|
+
*/
|
|
31
|
+
export declare class KritzelWorkspace implements KritzelSerializable {
|
|
32
|
+
__class__: string;
|
|
33
|
+
/** Unique identifier for the workspace */
|
|
34
|
+
id: string;
|
|
35
|
+
/** Display name of the workspace */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Timestamp when the workspace was created */
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
/** Timestamp when the workspace was last updated */
|
|
40
|
+
updatedAt: Date;
|
|
41
|
+
/** Viewport state containing the world-space center point and zoom level */
|
|
42
|
+
viewport: {
|
|
43
|
+
centerWorldX: number;
|
|
44
|
+
centerWorldY: number;
|
|
45
|
+
scale: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Desired canvas objects. Seeded when the workspace is first initialized and applied as the
|
|
49
|
+
* full desired set by `updateWorkspace()`: `undefined` leaves objects untouched, `[]` removes all.
|
|
50
|
+
*/
|
|
51
|
+
objects?: KritzelBaseObject<any>[];
|
|
52
|
+
/** Whether the workspace is publicly accessible via a share link */
|
|
53
|
+
isPublic: boolean;
|
|
54
|
+
/** Reference to the KritzelCore instance managing this workspace */
|
|
55
|
+
_core: KritzelCore;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new KritzelWorkspace instance.
|
|
58
|
+
* @param config - Configuration options object for the workspace
|
|
59
|
+
*/
|
|
60
|
+
constructor(config?: KritzelWorkspaceConfig);
|
|
61
|
+
/**
|
|
62
|
+
* Factory method to create a workspace with a core reference.
|
|
63
|
+
* @param core - The KritzelCore instance to associate with this workspace
|
|
64
|
+
* @param obj - Object containing workspace properties (id, name, viewport)
|
|
65
|
+
* @returns A new KritzelWorkspace instance with the core reference set
|
|
66
|
+
*/
|
|
67
|
+
static create(core: KritzelCore, obj: any): KritzelWorkspace;
|
|
68
|
+
/**
|
|
69
|
+
* Adds an object to this workspace via the core engine.
|
|
70
|
+
* @param obj - The object to add to the workspace
|
|
71
|
+
*/
|
|
72
|
+
addObject(obj: any): void;
|
|
73
|
+
/**
|
|
74
|
+
* Serializes the workspace to a plain object for storage or transmission.
|
|
75
|
+
* Converts dates to ISO strings and includes the class identifier.
|
|
76
|
+
* @param options - Optional settings for serialization
|
|
77
|
+
* @param options.includeObjects - If true, includes all canvas objects in the serialized output
|
|
78
|
+
* @returns A plain object representation of the workspace
|
|
79
|
+
*/
|
|
80
|
+
serialize(options?: {
|
|
81
|
+
includeObjects?: boolean;
|
|
82
|
+
}): Record<string, unknown>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a shallow clone of this workspace, preserving the prototype chain.
|
|
85
|
+
* Useful when Stencil needs a new object reference to detect property changes.
|
|
86
|
+
*/
|
|
87
|
+
clone(): KritzelWorkspace;
|
|
88
|
+
/**
|
|
89
|
+
* Deserializes a plain object into this workspace instance.
|
|
90
|
+
* Converts ISO string dates back to Date objects.
|
|
91
|
+
* @param object - The plain object to deserialize from
|
|
92
|
+
* @returns This workspace instance with updated properties
|
|
93
|
+
*/
|
|
94
|
+
deserialize(object: any): KritzelSerializable;
|
|
95
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KritzelCore } from '../core/core.class';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for all Kritzel event handlers.
|
|
4
|
+
* Provides a common foundation with access to the core instance for derived handler classes
|
|
5
|
+
* such as key handlers, hover handlers, and context menu handlers.
|
|
6
|
+
*/
|
|
7
|
+
export declare class KritzelBaseHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Reference to the KritzelCore instance.
|
|
10
|
+
* Provides access to canvas state, store, and operations for derived handlers.
|
|
11
|
+
*/
|
|
12
|
+
protected readonly _core: KritzelCore;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of the base handler.
|
|
15
|
+
* @param core - The KritzelCore instance that provides access to canvas state and operations.
|
|
16
|
+
*/
|
|
17
|
+
constructor(core: KritzelCore);
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { KritzelBaseHandler } from './base.handler';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
/**
|
|
4
|
+
* Handles context menu interactions on the Kritzel canvas.
|
|
5
|
+
* Manages the display and positioning of context menus, selecting appropriate menu items
|
|
6
|
+
* based on whether an object is targeted or the canvas background is right-clicked.
|
|
7
|
+
*/
|
|
8
|
+
export declare class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
9
|
+
/**
|
|
10
|
+
* Menu items to display when the context menu is opened on the canvas background
|
|
11
|
+
* (i.e., when no object is selected).
|
|
12
|
+
*/
|
|
13
|
+
globalContextMenuItems: any[];
|
|
14
|
+
/**
|
|
15
|
+
* Menu items to display when the context menu is opened on a selected object.
|
|
16
|
+
*/
|
|
17
|
+
objectContextMenuItems: any[];
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new instance of the context menu handler.
|
|
20
|
+
* @param core - The KritzelCore instance that provides access to canvas state and operations.
|
|
21
|
+
* @param globalContextMenuItems - Array of menu items to show for canvas-level context menus.
|
|
22
|
+
* @param objectContextMenuItems - Array of menu items to show when right-clicking on objects.
|
|
23
|
+
*/
|
|
24
|
+
constructor(core: KritzelCore, globalContextMenuItems: any[], objectContextMenuItems: any[]);
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the active context menu items for display, translating each item's
|
|
27
|
+
* `label` through the current locale. When the label is a known
|
|
28
|
+
* {@link KritzelTermKey} the translation is used; any other string is passed
|
|
29
|
+
* through unchanged. Runs at menu-open time so the labels reflect the locale
|
|
30
|
+
* active at that moment.
|
|
31
|
+
* @returns A new array of items with resolved labels.
|
|
32
|
+
*/
|
|
33
|
+
private resolveLabels;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the active context menu items (object or global) with localized labels.
|
|
36
|
+
*/
|
|
37
|
+
private getResolvedContextMenuItems;
|
|
38
|
+
/**
|
|
39
|
+
* Handles the context menu event (typically triggered by right-click).
|
|
40
|
+
* This method performs the following operations:
|
|
41
|
+
* 1. Validates that the selection tool is active; exits early otherwise.
|
|
42
|
+
* 2. Checks and resets the `skipContextMenu` flag if set.
|
|
43
|
+
* 3. Cancels any pending drag operation on the selection tool.
|
|
44
|
+
* 4. Clears any active selection box if present.
|
|
45
|
+
* 5. If an object is clicked, creates a new selection group containing that object.
|
|
46
|
+
* 6. Determines which menu items to display (object or global context menu).
|
|
47
|
+
* 7. Calculates the menu position, ensuring it stays within viewport bounds.
|
|
48
|
+
* 8. Updates the store state to show the context menu and disables canvas interactions.
|
|
49
|
+
* @param event - The pointer event containing the click coordinates and target information.
|
|
50
|
+
* @returns void - This method does not return a value; it updates state and triggers a rerender.
|
|
51
|
+
*/
|
|
52
|
+
handleContextMenu(event: PointerEvent): void;
|
|
53
|
+
/**
|
|
54
|
+
* Programmatically opens the context menu at a specified world-coordinate position.
|
|
55
|
+
* If an objectId is provided and found, the object context menu is shown for that object.
|
|
56
|
+
* If no objectId is provided but a selection group exists, the object context menu is shown.
|
|
57
|
+
* Otherwise, the global context menu is shown.
|
|
58
|
+
* @param options.x - The X position in world (canvas) coordinates.
|
|
59
|
+
* @param options.y - The Y position in world (canvas) coordinates.
|
|
60
|
+
* @param options.objectId - Optional ID of an object to select and show the object context menu for.
|
|
61
|
+
*/
|
|
62
|
+
open(options: {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
objectId?: string;
|
|
66
|
+
}): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KritzelCore } from '../core/core.class';
|
|
2
|
+
import { KritzelBaseHandler } from './base.handler';
|
|
3
|
+
/**
|
|
4
|
+
* Handles hover interactions on the Kritzel canvas.
|
|
5
|
+
* Detects when the pointer moves over canvas objects and updates their hover state accordingly.
|
|
6
|
+
* Currently only processes mouse input, with placeholder support for touch and pen devices.
|
|
7
|
+
*/
|
|
8
|
+
export declare class KritzelHoverHandler extends KritzelBaseHandler {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new instance of the hover handler.
|
|
11
|
+
* @param core - The KritzelCore instance that provides access to canvas state and object detection.
|
|
12
|
+
*/
|
|
13
|
+
constructor(core: KritzelCore);
|
|
14
|
+
/**
|
|
15
|
+
* Handles pointer move events to detect and update object hover states.
|
|
16
|
+
* For mouse input, performs a hit test on the object under the pointer and updates
|
|
17
|
+
* its `isHovered` property based on whether the pointer coordinates intersect with the object.
|
|
18
|
+
* Touch and pen input types are recognized but not yet implemented.
|
|
19
|
+
* @param event - The pointer event containing information about the pointer type and position.
|
|
20
|
+
* @returns void - This method does not return a value; it updates object state as a side effect.
|
|
21
|
+
*/
|
|
22
|
+
handlePointerMove(event: PointerEvent): void;
|
|
23
|
+
}
|