@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,322 @@
|
|
|
1
|
+
import { KritzelBaseObject } from './base-object.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { ShapeType } from '../../enums/shape-type.enum';
|
|
4
|
+
import { KritzelPoint } from '../../interfaces/point.interface';
|
|
5
|
+
import { EditorView } from 'prosemirror-view';
|
|
6
|
+
import { ThemeAwareColor } from '../../constants/color-palette.constants';
|
|
7
|
+
import { KritzelObjectExportContext, KritzelObjectExportFormat } from '../../interfaces/object-export.interface';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for creating a KritzelShape instance.
|
|
10
|
+
*/
|
|
11
|
+
export interface KritzelShapeConfig {
|
|
12
|
+
x?: number;
|
|
13
|
+
y?: number;
|
|
14
|
+
translateX?: number;
|
|
15
|
+
translateY?: number;
|
|
16
|
+
rotation?: number;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
shapeType?: ShapeType;
|
|
20
|
+
fillColor?: ThemeAwareColor;
|
|
21
|
+
strokeColor?: ThemeAwareColor;
|
|
22
|
+
strokeWidth?: number;
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
fontColor?: ThemeAwareColor;
|
|
26
|
+
scale?: number;
|
|
27
|
+
scaleX?: number;
|
|
28
|
+
scaleY?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class KritzelShape extends KritzelBaseObject<HTMLDivElement> {
|
|
31
|
+
__class__: string;
|
|
32
|
+
shapeType: ShapeType;
|
|
33
|
+
fillColor: ThemeAwareColor;
|
|
34
|
+
strokeColor: ThemeAwareColor;
|
|
35
|
+
strokeWidth: number;
|
|
36
|
+
fontFamily: string;
|
|
37
|
+
fontSize: number;
|
|
38
|
+
fontColor: ThemeAwareColor;
|
|
39
|
+
/** Screen-space x coordinate of the shape's top-left corner (like Path.x) */
|
|
40
|
+
x: number;
|
|
41
|
+
/** Screen-space y coordinate of the shape's top-left corner (like Path.y) */
|
|
42
|
+
y: number;
|
|
43
|
+
scale?: number;
|
|
44
|
+
scaleFactor: number;
|
|
45
|
+
isDebugInfoVisible: boolean;
|
|
46
|
+
isEditable: boolean;
|
|
47
|
+
isEditing: boolean;
|
|
48
|
+
editor: EditorView | null;
|
|
49
|
+
content: any;
|
|
50
|
+
private readonly _schema;
|
|
51
|
+
uneditedObject: KritzelShape | null;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the viewBox for the shape's SVG, using screen-space coordinates.
|
|
54
|
+
* This follows the same pattern as KritzelPath.viewBox.
|
|
55
|
+
*/
|
|
56
|
+
get viewBox(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new KritzelShape instance with optional configuration.
|
|
59
|
+
* This constructor initializes the shape with default values that can be
|
|
60
|
+
* overridden by the provided configuration object.
|
|
61
|
+
*
|
|
62
|
+
* @param config - Optional configuration object for the shape
|
|
63
|
+
* @param config.x - Screen-space x coordinate of the shape's top-left corner
|
|
64
|
+
* @param config.y - Screen-space y coordinate of the shape's top-left corner
|
|
65
|
+
* @param config.translateX - World-space x translation offset
|
|
66
|
+
* @param config.translateY - World-space y translation offset
|
|
67
|
+
* @param config.width - Width of the shape in screen-space pixels
|
|
68
|
+
* @param config.height - Height of the shape in screen-space pixels
|
|
69
|
+
* @param config.shapeType - Type of shape (Rectangle, Ellipse, Triangle)
|
|
70
|
+
* @param config.fillColor - Theme-aware fill color with light and dark variants
|
|
71
|
+
* @param config.strokeColor - Theme-aware stroke color with light and dark variants
|
|
72
|
+
* @param config.strokeWidth - Width of the shape's stroke in pixels
|
|
73
|
+
* @param config.fontSize - Font size for text content in points
|
|
74
|
+
* @param config.fontFamily - Font family for text content
|
|
75
|
+
* @param config.fontColor - Theme-aware font color (auto-determined from fillColor if not specified)
|
|
76
|
+
* @param config.scale - Viewport scale factor at creation time
|
|
77
|
+
* @param config.scaleX - Horizontal scale factor for transformations
|
|
78
|
+
* @param config.scaleY - Vertical scale factor for transformations
|
|
79
|
+
*/
|
|
80
|
+
constructor(config?: KritzelShapeConfig);
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new KritzelShape with screen-space coordinates.
|
|
83
|
+
* Following the same pattern as KritzelPath.create():
|
|
84
|
+
* - x, y are screen-space coordinates of the shape's top-left corner
|
|
85
|
+
* - translateX, translateY should be set to -viewportTranslateX, -viewportTranslateY
|
|
86
|
+
* - width, height are in screen-space
|
|
87
|
+
* - scale is the viewport scale at creation time
|
|
88
|
+
*/
|
|
89
|
+
static create(core: KritzelCore, config?: {
|
|
90
|
+
x?: number;
|
|
91
|
+
y?: number;
|
|
92
|
+
translateX?: number;
|
|
93
|
+
translateY?: number;
|
|
94
|
+
rotation?: number;
|
|
95
|
+
width?: number;
|
|
96
|
+
height?: number;
|
|
97
|
+
shapeType?: ShapeType;
|
|
98
|
+
fillColor?: ThemeAwareColor;
|
|
99
|
+
strokeColor?: ThemeAwareColor;
|
|
100
|
+
strokeWidth?: number;
|
|
101
|
+
opacity?: number;
|
|
102
|
+
fontSize?: number;
|
|
103
|
+
fontFamily?: string;
|
|
104
|
+
fontColor?: ThemeAwareColor;
|
|
105
|
+
scale?: number;
|
|
106
|
+
}): KritzelShape;
|
|
107
|
+
/**
|
|
108
|
+
* Updates the translateX/Y to world coordinates based on screen-space x, y.
|
|
109
|
+
* This follows the same pattern as KritzelPath.updateDimensions().
|
|
110
|
+
*
|
|
111
|
+
* The formula: translateX = (x + initialTranslateX) / scale
|
|
112
|
+
* where initialTranslateX was -viewportTranslateX
|
|
113
|
+
*
|
|
114
|
+
* This converts screen-space position to world coordinates.
|
|
115
|
+
*/
|
|
116
|
+
updateDimensions(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Mounts the shape to a DOM element for rendering.
|
|
119
|
+
* This method attaches the shape to the provided HTML element, enabling
|
|
120
|
+
* it to be displayed in the viewport. It performs visibility checks and
|
|
121
|
+
* prevents redundant mounting operations.
|
|
122
|
+
*
|
|
123
|
+
* @param element - The HTML div element to mount the shape to
|
|
124
|
+
* @returns void
|
|
125
|
+
*/
|
|
126
|
+
mount(element: HTMLDivElement): void;
|
|
127
|
+
/**
|
|
128
|
+
* Mounts the ProseMirror text editor to a DOM element.
|
|
129
|
+
* This method attaches the rich text editor to the provided container element,
|
|
130
|
+
* applying font styling and ensuring proper text wrapping. It prevents
|
|
131
|
+
* redundant DOM operations if the editor is already mounted to the same element.
|
|
132
|
+
*
|
|
133
|
+
* @param element - The HTML div element to mount the text editor to
|
|
134
|
+
* @returns void
|
|
135
|
+
*/
|
|
136
|
+
mountTextEditor(element: HTMLDivElement): void;
|
|
137
|
+
/**
|
|
138
|
+
* Creates and initializes a ProseMirror editor instance for rich text editing.
|
|
139
|
+
* The editor is configured with a schema that supports basic text formatting
|
|
140
|
+
* and list nodes. It starts in non-editable mode and handles document changes
|
|
141
|
+
* by updating the shape's content and syncing with the store.
|
|
142
|
+
*
|
|
143
|
+
* @returns A new ProseMirror EditorView instance configured for this shape
|
|
144
|
+
*/
|
|
145
|
+
private createEditor;
|
|
146
|
+
/**
|
|
147
|
+
* Sets the text content of the shape's editor from a serialized document.
|
|
148
|
+
* This method is typically used to restore content from storage or to apply
|
|
149
|
+
* remote changes during collaboration. The 'fromRemote' meta flag prevents
|
|
150
|
+
* the change from being re-broadcast to collaborators.
|
|
151
|
+
*
|
|
152
|
+
* @param content - The serialized ProseMirror document content (JSON format)
|
|
153
|
+
* @returns void
|
|
154
|
+
*/
|
|
155
|
+
setContent(content: any): void;
|
|
156
|
+
/**
|
|
157
|
+
* Resizes the shape to the specified dimensions and position.
|
|
158
|
+
* This method updates the shape's world-space coordinates and dimensions,
|
|
159
|
+
* then triggers a store update to persist the changes. Minimum dimension
|
|
160
|
+
* constraints prevent the shape from becoming invisibly small.
|
|
161
|
+
*
|
|
162
|
+
* @param x - New world-space x coordinate for the shape's position
|
|
163
|
+
* @param y - New world-space y coordinate for the shape's position
|
|
164
|
+
* @param width - New width of the shape in pixels
|
|
165
|
+
* @param height - New height of the shape in pixels
|
|
166
|
+
* @returns void
|
|
167
|
+
*/
|
|
168
|
+
resize(x: number, y: number, width: number, height: number): void;
|
|
169
|
+
/**
|
|
170
|
+
* Focuses the text editor and optionally positions the cursor at specific coordinates.
|
|
171
|
+
* If coordinates are provided, the cursor is placed at the corresponding text position.
|
|
172
|
+
* Otherwise, the cursor is placed at the end of the document. On iOS devices,
|
|
173
|
+
* additional scrolling behavior is triggered to ensure visibility.
|
|
174
|
+
*
|
|
175
|
+
* @param coords - Optional screen coordinates to position the cursor
|
|
176
|
+
* @param coords.x - Screen x coordinate for cursor placement
|
|
177
|
+
* @param coords.y - Screen y coordinate for cursor placement
|
|
178
|
+
* @returns void
|
|
179
|
+
*/
|
|
180
|
+
focus(coords?: {
|
|
181
|
+
x: number;
|
|
182
|
+
y: number;
|
|
183
|
+
}): void;
|
|
184
|
+
/**
|
|
185
|
+
* Scrolls the editor into view on iOS devices with a slight delay.
|
|
186
|
+
* This workaround addresses iOS-specific behavior where the virtual keyboard
|
|
187
|
+
* can obscure the editor. The delay allows the keyboard to fully appear
|
|
188
|
+
* before scrolling.
|
|
189
|
+
*
|
|
190
|
+
* @returns void
|
|
191
|
+
*/
|
|
192
|
+
private scrollIntoViewOnIOS;
|
|
193
|
+
/**
|
|
194
|
+
* Enters edit mode for the shape, enabling text editing.
|
|
195
|
+
* This method stores a clone of the current state for potential undo operations,
|
|
196
|
+
* switches to the shape tool, enables the editor, and focuses at the pointer
|
|
197
|
+
* location if provided. Keyboard handling is temporarily adjusted to support
|
|
198
|
+
* text input.
|
|
199
|
+
*
|
|
200
|
+
* @param event - Optional pointer event containing the click coordinates for cursor placement
|
|
201
|
+
* @returns void
|
|
202
|
+
*/
|
|
203
|
+
edit(event?: PointerEvent): void;
|
|
204
|
+
/**
|
|
205
|
+
* Exits edit mode and saves the current text content.
|
|
206
|
+
* This method serializes the editor's document state, disables editing,
|
|
207
|
+
* removes focus from the editor, consolidates any temporary changes in the
|
|
208
|
+
* store, and emits an objects change event to notify listeners.
|
|
209
|
+
*
|
|
210
|
+
* @returns void
|
|
211
|
+
*/
|
|
212
|
+
save(): void;
|
|
213
|
+
/**
|
|
214
|
+
* Handles the Escape key while the shape's text editor is in edit mode.
|
|
215
|
+
* Implements a two-stage behavior: if the editor currently has a non-empty
|
|
216
|
+
* text selection, the selection is collapsed to a caret without exiting
|
|
217
|
+
* edit mode. If the selection is already collapsed, edit mode is exited
|
|
218
|
+
* (saving the current content), the canvas selection is cleared and the
|
|
219
|
+
* active tool is switched back to the selection tool so subsequent
|
|
220
|
+
* interactions start fresh.
|
|
221
|
+
*/
|
|
222
|
+
handleEscape(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Handles pointer down events when the shape is in edit mode.
|
|
225
|
+
* This method stops event propagation for untracked pointers to prevent
|
|
226
|
+
* the canvas from capturing text selection interactions within the editor.
|
|
227
|
+
*
|
|
228
|
+
* @param event - The pointer down event from user interaction
|
|
229
|
+
* @returns void
|
|
230
|
+
*/
|
|
231
|
+
handlePointerDown(event: PointerEvent): void;
|
|
232
|
+
/**
|
|
233
|
+
* Handles pointer move events when the shape is in edit mode.
|
|
234
|
+
* This method stops event propagation for untracked pointers to allow
|
|
235
|
+
* text selection drag operations within the editor without triggering
|
|
236
|
+
* canvas pan or other interactions.
|
|
237
|
+
*
|
|
238
|
+
* @param event - The pointer move event from user interaction
|
|
239
|
+
* @returns void
|
|
240
|
+
*/
|
|
241
|
+
handlePointerMove(event: PointerEvent): void;
|
|
242
|
+
/**
|
|
243
|
+
* Handles pointer up events when the shape is in edit mode.
|
|
244
|
+
* This method stops event propagation for untracked pointers to complete
|
|
245
|
+
* text selection operations within the editor without triggering
|
|
246
|
+
* canvas click handlers.
|
|
247
|
+
*
|
|
248
|
+
* @param event - The pointer up event from user interaction
|
|
249
|
+
* @returns void
|
|
250
|
+
*/
|
|
251
|
+
handlePointerUp(event: PointerEvent): void;
|
|
252
|
+
/**
|
|
253
|
+
* Creates a copy of this shape with a new editor instance.
|
|
254
|
+
* This method extends the base copy behavior by creating a fresh
|
|
255
|
+
* ProseMirror editor for the copied shape and restoring the text
|
|
256
|
+
* content from the original.
|
|
257
|
+
*
|
|
258
|
+
* @returns A new KritzelShape instance with copied properties and content
|
|
259
|
+
*/
|
|
260
|
+
copy(): KritzelShape;
|
|
261
|
+
/**
|
|
262
|
+
* Serializes the shape to a plain JavaScript object for storage or transmission.
|
|
263
|
+
* This method excludes non-serializable properties like the core reference,
|
|
264
|
+
* DOM elements, schema, and editor instance. The remaining properties are
|
|
265
|
+
* deep-cloned to prevent reference issues.
|
|
266
|
+
*
|
|
267
|
+
* @returns A serializable object containing all persistent shape properties
|
|
268
|
+
*/
|
|
269
|
+
serialize(): any;
|
|
270
|
+
/**
|
|
271
|
+
* Restores a shape from a serialized object representation.
|
|
272
|
+
* This method extends the base deserialization by additionally restoring
|
|
273
|
+
* the text editor content from the serialized data.
|
|
274
|
+
*
|
|
275
|
+
* @template KritzelShape - The type parameter for return type consistency
|
|
276
|
+
* @param object - The serialized shape data to restore from
|
|
277
|
+
* @returns The deserialized shape instance (this)
|
|
278
|
+
*/
|
|
279
|
+
deserialize<KritzelShape>(object: any): KritzelShape;
|
|
280
|
+
/**
|
|
281
|
+
* Lifecycle hook called after properties are updated via updateObject.
|
|
282
|
+
* This method automatically adjusts the text color based on fill color
|
|
283
|
+
* brightness to ensure readability. When the fill color changes, the font
|
|
284
|
+
* color is recalculated and the editor's styling is updated immediately.
|
|
285
|
+
*
|
|
286
|
+
* @param changedProperties - Array of property names that were modified
|
|
287
|
+
* @returns void
|
|
288
|
+
*/
|
|
289
|
+
onAfterUpdate(changedProperties: string[]): void;
|
|
290
|
+
/**
|
|
291
|
+
* Returns the clipping polygon for arrow intersection calculations.
|
|
292
|
+
* This method generates a polygon representation of the shape's outline
|
|
293
|
+
* for use in determining where arrows or connectors should terminate.
|
|
294
|
+
*
|
|
295
|
+
* The polygon includes padding for half the stroke width to ensure
|
|
296
|
+
* arrow heads don't visually overlap the shape's stroke.
|
|
297
|
+
*
|
|
298
|
+
* Shape-specific behavior:
|
|
299
|
+
* - Ellipse: Returns a 32-segment polygon approximation of the ellipse
|
|
300
|
+
* - Triangle: Returns the 3 corner points, expanded outward by stroke padding
|
|
301
|
+
* - Rectangle: Returns null to use the default rotatedPolygon from base class
|
|
302
|
+
*
|
|
303
|
+
* @returns An array of KritzelPoint objects defining the clipping polygon,
|
|
304
|
+
* or null for rectangles (which use the default implementation)
|
|
305
|
+
*/
|
|
306
|
+
getClipPolygon(): KritzelPoint[] | null;
|
|
307
|
+
/**
|
|
308
|
+
* Generates the SVG path string for rendering the shape.
|
|
309
|
+
* The path uses screen-space coordinates relative to the shape's (x, y) position.
|
|
310
|
+
* This method supports all shape types and returns the appropriate path commands.
|
|
311
|
+
*
|
|
312
|
+
* Path formats by shape type:
|
|
313
|
+
* - Rectangle: Four-point closed path (M, L, L, L, Z)
|
|
314
|
+
* - Ellipse: Two-arc closed path using the elliptical arc command (M, A, A)
|
|
315
|
+
* - Triangle: Three-point closed path with vertices at top-center, bottom-right, bottom-left
|
|
316
|
+
*
|
|
317
|
+
* @returns An SVG path data string (d attribute) for the shape
|
|
318
|
+
*/
|
|
319
|
+
getSvgPath(): string;
|
|
320
|
+
getSupportedExportFormats(): KritzelObjectExportFormat[];
|
|
321
|
+
exportAs(format: KritzelObjectExportFormat, context: KritzelObjectExportContext): Promise<string | null>;
|
|
322
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { KritzelBaseObject } from './base-object.class';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { ThemeAwareColor } from '../../constants/color-palette.constants';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for creating a KritzelText instance.
|
|
7
|
+
*/
|
|
8
|
+
export interface KritzelTextConfig {
|
|
9
|
+
text?: string;
|
|
10
|
+
translateX?: number;
|
|
11
|
+
translateY?: number;
|
|
12
|
+
fontSize?: number;
|
|
13
|
+
fontFamily?: string;
|
|
14
|
+
fontColor?: ThemeAwareColor;
|
|
15
|
+
height?: number;
|
|
16
|
+
width?: number;
|
|
17
|
+
scale?: number;
|
|
18
|
+
rotation?: number;
|
|
19
|
+
initialWidth?: number;
|
|
20
|
+
initialHeight?: number;
|
|
21
|
+
scaleX?: number;
|
|
22
|
+
scaleY?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents a text object on the canvas that supports rich text editing via ProseMirror.
|
|
26
|
+
* Extends the base object class to inherit common object properties and behaviors.
|
|
27
|
+
*/
|
|
28
|
+
export declare class KritzelText extends KritzelBaseObject<HTMLDivElement> {
|
|
29
|
+
__class__: string;
|
|
30
|
+
fontFamily: string;
|
|
31
|
+
fontSize: number;
|
|
32
|
+
fontColor: ThemeAwareColor;
|
|
33
|
+
initialWidth: number;
|
|
34
|
+
initialHeight: number;
|
|
35
|
+
scale: number;
|
|
36
|
+
scaleFactor: number;
|
|
37
|
+
isDebugInfoVisible: boolean;
|
|
38
|
+
isEditable: boolean;
|
|
39
|
+
isEditing: boolean;
|
|
40
|
+
isNewlyCreated: boolean;
|
|
41
|
+
editor: EditorView | null;
|
|
42
|
+
content: any;
|
|
43
|
+
private readonly _schema;
|
|
44
|
+
uneditedObject: KritzelText | null;
|
|
45
|
+
readonly rows: number;
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the text object contains any content.
|
|
48
|
+
* @returns `true` if the editor is empty or contains only whitespace, `false` otherwise.
|
|
49
|
+
*/
|
|
50
|
+
get isEmpty(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a new KritzelText instance with optional configuration.
|
|
53
|
+
* Can be used by consumers to create text objects programmatically:
|
|
54
|
+
* ```ts
|
|
55
|
+
* const text = new KritzelText({ text: 'Hello World', translateX: 100, translateY: 100 });
|
|
56
|
+
* await editor.addObject(text);
|
|
57
|
+
* ```
|
|
58
|
+
* @param config - Optional configuration object.
|
|
59
|
+
* @param config.text - Initial plain text content.
|
|
60
|
+
* @param config.translateX - Initial X translation position.
|
|
61
|
+
* @param config.translateY - Initial Y translation position.
|
|
62
|
+
* @param config.fontSize - Font size in points (default: 8).
|
|
63
|
+
* @param config.fontFamily - Font family name (default: 'Arial').
|
|
64
|
+
* @param config.fontColor - Theme-aware color object with light and dark values.
|
|
65
|
+
* @param config.height - Initial height of the text element.
|
|
66
|
+
* @param config.width - Initial width of the text element.
|
|
67
|
+
* @param config.scale - Scale factor for the text object.
|
|
68
|
+
* @param config.initialWidth - Initial width before scaling.
|
|
69
|
+
* @param config.initialHeight - Initial height before scaling.
|
|
70
|
+
* @param config.scaleX - Horizontal scale factor.
|
|
71
|
+
* @param config.scaleY - Vertical scale factor.
|
|
72
|
+
*/
|
|
73
|
+
constructor(config?: KritzelTextConfig);
|
|
74
|
+
/**
|
|
75
|
+
* Factory method to create a new KritzelText instance with default settings.
|
|
76
|
+
* Initializes the editor and registers the object with the core store.
|
|
77
|
+
* @param core - The KritzelCore instance managing the canvas.
|
|
78
|
+
* @param fontSize - Optional font size in points.
|
|
79
|
+
* @param fontFamily - Optional font family name.
|
|
80
|
+
* @param scale - Optional scale factor (defaults to current viewport scale).
|
|
81
|
+
* @returns A new, fully initialized KritzelText instance.
|
|
82
|
+
*/
|
|
83
|
+
static create(core: KritzelCore, fontSize?: number, fontFamily?: string, scale?: number, rotation?: number): KritzelText;
|
|
84
|
+
/**
|
|
85
|
+
* Mounts the text object to a DOM element, attaching the ProseMirror editor.
|
|
86
|
+
* Applies font styling and ensures the editor is properly rendered.
|
|
87
|
+
* @param element - The HTML div element to mount the text object into.
|
|
88
|
+
*/
|
|
89
|
+
mount(element: HTMLDivElement): void;
|
|
90
|
+
/**
|
|
91
|
+
* Creates and configures a new ProseMirror EditorView instance.
|
|
92
|
+
* Sets up the document schema, plugins, and transaction handling.
|
|
93
|
+
* @returns A configured ProseMirror EditorView instance.
|
|
94
|
+
*/
|
|
95
|
+
createEditor(): EditorView;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the content of the text editor from a serialized document structure.
|
|
98
|
+
* Used to restore content from saved state or synchronize with remote changes.
|
|
99
|
+
* @param content - The serialized ProseMirror document content in JSON format.
|
|
100
|
+
*/
|
|
101
|
+
setContent(content: any): void;
|
|
102
|
+
/**
|
|
103
|
+
* Dynamically adjusts the width and height of the text object based on content.
|
|
104
|
+
* Recalculates dimensions when content changes and handles rotation offsets
|
|
105
|
+
* to maintain proper positioning.
|
|
106
|
+
*/
|
|
107
|
+
adjustSizeOnInput(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Resizes the text object while maintaining aspect ratio through scale factor adjustment.
|
|
110
|
+
* Updates position and dimensions, then persists changes to the store.
|
|
111
|
+
* @param x - New X position (translateX value).
|
|
112
|
+
* @param y - New Y position (translateY value).
|
|
113
|
+
* @param width - Target width for the text object.
|
|
114
|
+
* @param height - Target height for the text object.
|
|
115
|
+
*/
|
|
116
|
+
resize(x: number, y: number, width: number, height: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Focuses the text editor and optionally positions the cursor at specific coordinates.
|
|
119
|
+
* Falls back to placing cursor at the end of the document if coordinates are invalid.
|
|
120
|
+
* Handles iOS-specific scrolling behavior.
|
|
121
|
+
* @param coords - Optional coordinates to position the cursor.
|
|
122
|
+
* @param coords.x - X coordinate for cursor placement.
|
|
123
|
+
* @param coords.y - Y coordinate for cursor placement.
|
|
124
|
+
*/
|
|
125
|
+
focus(coords?: {
|
|
126
|
+
x: number;
|
|
127
|
+
y: number;
|
|
128
|
+
}): void;
|
|
129
|
+
/**
|
|
130
|
+
* Scrolls the editor into view on iOS devices after a short delay.
|
|
131
|
+
* Addresses iOS-specific virtual keyboard and viewport issues.
|
|
132
|
+
*/
|
|
133
|
+
private scrollIntoViewOnIOS;
|
|
134
|
+
/**
|
|
135
|
+
* Enters edit mode for the text object, enabling content editing.
|
|
136
|
+
* Saves a snapshot of the current state, activates the text tool,
|
|
137
|
+
* enables the editor, and focuses at the pointer position.
|
|
138
|
+
* @param event - Optional pointer event containing cursor coordinates for focus placement.
|
|
139
|
+
*/
|
|
140
|
+
edit(event?: PointerEvent): void;
|
|
141
|
+
/**
|
|
142
|
+
* Exits edit mode and saves the current content.
|
|
143
|
+
* Disables the editor, persists content to the document,
|
|
144
|
+
* consolidates temporary history items, and emits change events.
|
|
145
|
+
*/
|
|
146
|
+
save(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Handles the Escape key while the text object is in edit mode.
|
|
149
|
+
* Implements a two-stage behavior: if the editor currently has a non-empty
|
|
150
|
+
* text selection, the selection is collapsed to a caret without exiting
|
|
151
|
+
* edit mode. If the selection is already collapsed, edit mode is exited
|
|
152
|
+
* (saving the current content or deleting the object if it is empty) and
|
|
153
|
+
* the canvas selection is cleared so subsequent tool actions start fresh.
|
|
154
|
+
*/
|
|
155
|
+
handleEscape(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Handles pointer down events during text editing.
|
|
158
|
+
* Stops event propagation to prevent canvas interaction while editing.
|
|
159
|
+
* @param event - The pointer down event.
|
|
160
|
+
*/
|
|
161
|
+
handlePointerDown(event: PointerEvent): void;
|
|
162
|
+
/**
|
|
163
|
+
* Handles pointer move events during text editing.
|
|
164
|
+
* Conditionally stops propagation based on whether the engine is tracking
|
|
165
|
+
* the pointer, allowing proper event flow during text creation.
|
|
166
|
+
* @param event - The pointer move event.
|
|
167
|
+
*/
|
|
168
|
+
handlePointerMove(event: PointerEvent): void;
|
|
169
|
+
/**
|
|
170
|
+
* Handles pointer up events during text editing.
|
|
171
|
+
* Conditionally stops propagation to allow the engine to clean up pointer state,
|
|
172
|
+
* preventing issues with stale pointers that could cause gesture misinterpretation.
|
|
173
|
+
* @param event - The pointer up event.
|
|
174
|
+
*/
|
|
175
|
+
handlePointerUp(event: PointerEvent): void;
|
|
176
|
+
/**
|
|
177
|
+
* Creates a deep copy of this text object, including a new editor instance.
|
|
178
|
+
* Preserves all content from the original object.
|
|
179
|
+
* @returns A new KritzelText instance with copied properties and content.
|
|
180
|
+
*/
|
|
181
|
+
copy(): KritzelText;
|
|
182
|
+
/**
|
|
183
|
+
* Serializes the text object to a plain object for storage or transmission.
|
|
184
|
+
* Excludes non-serializable properties like the core reference, editor instance,
|
|
185
|
+
* and DOM elements.
|
|
186
|
+
* @returns A plain object containing all serializable properties.
|
|
187
|
+
*/
|
|
188
|
+
serialize(): any;
|
|
189
|
+
/**
|
|
190
|
+
* Restores a text object from a serialized representation.
|
|
191
|
+
* Reconstructs the editor content from the saved document state.
|
|
192
|
+
* @template KritzelText - The return type (for type inference).
|
|
193
|
+
* @param object - The serialized object data to restore from.
|
|
194
|
+
* @returns The deserialized text object instance.
|
|
195
|
+
*/
|
|
196
|
+
deserialize<KritzelText>(object: any): KritzelText;
|
|
197
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { KritzelAsset } from '../../../interfaces/asset.interface';
|
|
2
|
+
import { KritzelAssetPutMetadata } from '../../../interfaces/asset-provider.interface';
|
|
3
|
+
import { KritzelAssetStorageConfig } from '../../../interfaces/asset-storage-config.interface';
|
|
4
|
+
import { IndexedDBAssetProvider } from './indexeddb-asset-provider.class';
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when an asset id cannot be located in any configured provider.
|
|
7
|
+
*
|
|
8
|
+
* This is distinct from transport / network errors: callers (e.g.
|
|
9
|
+
* {@link KritzelImage.ensureResolved}) use the type to decide whether a
|
|
10
|
+
* failure is permanent (asset truly missing) or transient (network blip,
|
|
11
|
+
* remote temporarily unreachable) and should be retried without
|
|
12
|
+
* burning the per-page-load attempt budget.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AssetNotFoundError extends Error {
|
|
15
|
+
readonly assetId: string;
|
|
16
|
+
constructor(assetId: string, message?: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Orchestrates asset storage across one or more providers.
|
|
20
|
+
*
|
|
21
|
+
* Responsibilities:
|
|
22
|
+
* - Instantiates providers from a {@link KritzelAssetStorageConfig}.
|
|
23
|
+
* - Always ensures an {@link IndexedDBAssetProvider} is present as the
|
|
24
|
+
* local cache / optimistic write buffer.
|
|
25
|
+
* - Implements a write-through upload pipeline: bytes are written to the
|
|
26
|
+
* local provider immediately (so UI renders instantly), and remote
|
|
27
|
+
* providers receive a copy via an in-memory retry loop with
|
|
28
|
+
* exponential backoff.
|
|
29
|
+
* - Resolves asset ids to URLs by walking providers in order; the local
|
|
30
|
+
* provider serves as a cache for remote assets.
|
|
31
|
+
*
|
|
32
|
+
* Crash / reload resilience: the "needs upload" state is stored directly
|
|
33
|
+
* on the asset's metadata record in the local IndexedDB provider (as
|
|
34
|
+
* `KritzelAsset.pendingRemotes`). On `init()` the resolver scans for any
|
|
35
|
+
* such records and re-enqueues them, so uploads that were interrupted
|
|
36
|
+
* by a reload eventually complete without requiring a separate queue DB.
|
|
37
|
+
*/
|
|
38
|
+
export declare class KritzelAssetResolver {
|
|
39
|
+
private _providers;
|
|
40
|
+
private _local;
|
|
41
|
+
/** Remote providers ordered as configured. */
|
|
42
|
+
private _remoteProviders;
|
|
43
|
+
private _initialized;
|
|
44
|
+
/**
|
|
45
|
+
* Promise that resolves when the resolver is ready to serve requests.
|
|
46
|
+
*
|
|
47
|
+
* Created lazily so that callers issuing `resolve()` / `fetchBlob()` /
|
|
48
|
+
* `put()` before {@link init} has been invoked are queued instead of
|
|
49
|
+
* rejected. This eliminates a race on reload where the renderer
|
|
50
|
+
* triggers `KritzelImage.ensureResolved()` before the engine has
|
|
51
|
+
* finished wiring up the asset storage layer.
|
|
52
|
+
*/
|
|
53
|
+
private _readyPromise;
|
|
54
|
+
private _resolveReady;
|
|
55
|
+
private _rejectReady;
|
|
56
|
+
/** In-memory retry state keyed by `${id}::${providerName}`. */
|
|
57
|
+
private _pending;
|
|
58
|
+
private _flushTimer;
|
|
59
|
+
private _destroyed;
|
|
60
|
+
private _quiet;
|
|
61
|
+
/** Dedupes concurrent resolves of the same id. */
|
|
62
|
+
private _resolvePromises;
|
|
63
|
+
/** Enables or disables resolver diagnostic logging. */
|
|
64
|
+
setShowInfo(show: boolean): void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether any remote provider is configured. Used by the engine to
|
|
67
|
+
* decide whether to warn about a missing remote provider when Yjs is
|
|
68
|
+
* configured for network sync.
|
|
69
|
+
*/
|
|
70
|
+
get hasRemoteProvider(): boolean;
|
|
71
|
+
/** Returns the local (IndexedDB) provider instance, if available. */
|
|
72
|
+
get localProvider(): IndexedDBAssetProvider | null;
|
|
73
|
+
/**
|
|
74
|
+
* Initializes the resolver with the given configuration. Idempotent.
|
|
75
|
+
*
|
|
76
|
+
* @param config - User-supplied provider list. An `IndexedDBAssetProvider`
|
|
77
|
+
* is automatically prepended when the list contains none,
|
|
78
|
+
* so local caching is always available.
|
|
79
|
+
*/
|
|
80
|
+
init(config?: KritzelAssetStorageConfig): Promise<void>;
|
|
81
|
+
/** Tears down the resolver and all providers. */
|
|
82
|
+
destroy(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Uploads a blob through the write-through pipeline.
|
|
85
|
+
*
|
|
86
|
+
* 1. The local provider stores the bytes immediately and assigns the id.
|
|
87
|
+
* 2. Remote providers are marked pending on the local metadata and
|
|
88
|
+
* scheduled via the in-memory retry loop.
|
|
89
|
+
*
|
|
90
|
+
* Callers receive the asset descriptor synchronously after the local
|
|
91
|
+
* write completes; remote replication happens in the background.
|
|
92
|
+
*/
|
|
93
|
+
put(blob: Blob, metadata: KritzelAssetPutMetadata): Promise<KritzelAsset>;
|
|
94
|
+
/**
|
|
95
|
+
* Resolves an asset id to a URL usable as `<img src>`. Providers are
|
|
96
|
+
* tried in order; the first successful response wins.
|
|
97
|
+
*
|
|
98
|
+
* Remote hits are cached into the local provider for future offline use.
|
|
99
|
+
*/
|
|
100
|
+
resolve(id: string): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Returns the raw bytes for an asset. Used for export flows that embed
|
|
103
|
+
* the bytes inline (e.g. SVG export).
|
|
104
|
+
*/
|
|
105
|
+
fetchBlob(id: string): Promise<Blob>;
|
|
106
|
+
/**
|
|
107
|
+
* Uploads a legacy data-URL and returns the new asset. Used by the
|
|
108
|
+
* migration step for existing `KritzelImage.src` payloads.
|
|
109
|
+
*/
|
|
110
|
+
putDataUrl(dataUrl: string, metadata: Omit<KritzelAssetPutMetadata, 'mimeType'> & {
|
|
111
|
+
mimeType?: string;
|
|
112
|
+
}): Promise<KritzelAsset>;
|
|
113
|
+
private logProviderConfiguration;
|
|
114
|
+
private instantiateProviders;
|
|
115
|
+
private pendingKey;
|
|
116
|
+
/**
|
|
117
|
+
* Reads pending uploads back from the local provider's metadata and
|
|
118
|
+
* seeds the in-memory retry map. Only uploads targeting remote
|
|
119
|
+
* providers that are still configured are re-enqueued.
|
|
120
|
+
*/
|
|
121
|
+
private recoverPendingUploads;
|
|
122
|
+
private scheduleFlush;
|
|
123
|
+
private flushQueue;
|
|
124
|
+
/**
|
|
125
|
+
* Removes `providerName` from the `pendingRemotes` list on the asset's
|
|
126
|
+
* metadata record. Clears the field entirely when no providers remain.
|
|
127
|
+
*/
|
|
128
|
+
private clearPendingRemote;
|
|
129
|
+
/**
|
|
130
|
+
* Returns a promise that resolves once {@link init} has completed.
|
|
131
|
+
*
|
|
132
|
+
* Callers issuing requests before initialization are queued via this
|
|
133
|
+
* promise instead of being rejected. If the resolver is destroyed
|
|
134
|
+
* before init completes, the promise rejects so callers do not hang.
|
|
135
|
+
*/
|
|
136
|
+
private ensureReady;
|
|
137
|
+
private getReadyPromise;
|
|
138
|
+
private generateUuid;
|
|
139
|
+
private dataUrlToBlob;
|
|
140
|
+
private canLogInfo;
|
|
141
|
+
}
|