kritzel-stencil 0.0.157 → 0.0.158
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/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/default-text-tool.config-BySzvIox.js +31267 -0
- package/dist/cjs/default-text-tool.config-BySzvIox.js.map +1 -0
- package/dist/cjs/index-Cj__YTlG.js +1650 -0
- package/dist/cjs/index-Cj__YTlG.js.map +1 -0
- package/dist/cjs/index.cjs.js +1465 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +32 -0
- package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +1 -0
- package/dist/cjs/kritzel-color_22.cjs.entry.js +20974 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/stencil.cjs.js +26 -0
- package/dist/cjs/stencil.cjs.js.map +1 -0
- package/dist/collection/classes/core/core.class.js +470 -0
- package/dist/collection/classes/core/core.class.js.map +1 -0
- package/dist/collection/classes/core/reviver.class.js +71 -0
- package/dist/collection/classes/core/reviver.class.js.map +1 -0
- package/dist/collection/classes/core/store.class.js +72 -0
- package/dist/collection/classes/core/store.class.js.map +1 -0
- package/dist/collection/classes/core/viewport.class.js +190 -0
- package/dist/collection/classes/core/viewport.class.js.map +1 -0
- package/dist/collection/classes/core/workspace.class.js +41 -0
- package/dist/collection/classes/core/workspace.class.js.map +1 -0
- package/dist/collection/classes/handlers/base.handler.js +8 -0
- package/dist/collection/classes/handlers/base.handler.js.map +1 -0
- package/dist/collection/classes/handlers/context-menu.handler.js +62 -0
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -0
- package/dist/collection/classes/handlers/hover.handler.js +19 -0
- package/dist/collection/classes/handlers/hover.handler.js.map +1 -0
- package/dist/collection/classes/handlers/key.handler.js +58 -0
- package/dist/collection/classes/handlers/key.handler.js.map +1 -0
- package/dist/collection/classes/handlers/move.handler.js +149 -0
- package/dist/collection/classes/handlers/move.handler.js.map +1 -0
- package/dist/collection/classes/handlers/resize.handler.js +184 -0
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -0
- package/dist/collection/classes/handlers/rotation.handler.js +116 -0
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -0
- package/dist/collection/classes/handlers/selection.handler.js +246 -0
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -0
- package/dist/collection/classes/objects/base-object.class.js +232 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -0
- package/dist/collection/classes/objects/custom-element.class.js +62 -0
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -0
- package/dist/collection/classes/objects/image.class.js +56 -0
- package/dist/collection/classes/objects/image.class.js.map +1 -0
- package/dist/collection/classes/objects/path.class.js +284 -0
- package/dist/collection/classes/objects/path.class.js.map +1 -0
- package/dist/collection/classes/objects/selection-box.class.js +19 -0
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -0
- package/dist/collection/classes/objects/selection-group.class.js +226 -0
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -0
- package/dist/collection/classes/objects/text.class.js +261 -0
- package/dist/collection/classes/objects/text.class.js.map +1 -0
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js +93 -0
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +232 -0
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +35 -0
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/websocket-sync-provider.class.js +89 -0
- package/dist/collection/classes/providers/websocket-sync-provider.class.js.map +1 -0
- package/dist/{stencil/icon-registry.class-BtT8riKh.js → collection/classes/registries/icon-registry.class.js} +2 -6
- package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
- package/dist/collection/classes/registries/tool.registry.js +18 -0
- package/dist/collection/classes/registries/tool.registry.js.map +1 -0
- package/dist/collection/classes/structures/app-state-map.structure.js +189 -0
- package/dist/collection/classes/structures/app-state-map.structure.js.map +1 -0
- package/dist/collection/classes/structures/object-map.structure.js +328 -0
- package/dist/collection/classes/structures/object-map.structure.js.map +1 -0
- package/dist/collection/classes/structures/quadtree.structure.js +113 -0
- package/dist/collection/classes/structures/quadtree.structure.js.map +1 -0
- package/dist/collection/classes/tools/base-tool.class.js +38 -0
- package/dist/collection/classes/tools/base-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/brush-tool.class.js +133 -0
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/eraser-tool.class.js +85 -0
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/image-tool.class.js +83 -0
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/selection-tool.class.js +164 -0
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/text-tool.class.js +108 -0
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -0
- package/dist/collection/collection-manifest.json +34 -0
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -0
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +153 -0
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +34 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +928 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +73 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +1630 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -0
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.css +44 -0
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +98 -0
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -0
- package/dist/collection/components/shared/kritzel-color/kritzel-color.css +21 -0
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +107 -0
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -0
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +46 -0
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +145 -0
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -0
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +53 -0
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +218 -0
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -0
- package/dist/collection/components/shared/kritzel-font/kritzel-font.css +10 -0
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +90 -0
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -0
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +48 -0
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +114 -0
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -0
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +30 -0
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +110 -0
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -0
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +18 -0
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +94 -0
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +27 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +291 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -0
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +145 -0
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +280 -0
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -0
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +310 -0
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -0
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +78 -0
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +406 -0
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -0
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +28 -0
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +89 -0
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -0
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +17 -0
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +251 -0
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -0
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +55 -0
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +172 -0
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -0
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +19 -0
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +135 -0
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -0
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.css +19 -0
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +115 -0
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -0
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +127 -0
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +312 -0
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +44 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +111 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -0
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.css +5 -0
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +255 -0
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -0
- package/dist/collection/configs/default-brush-tool.config.js +60 -0
- package/dist/collection/configs/default-brush-tool.config.js.map +1 -0
- package/dist/collection/configs/default-engine-config.js +53 -0
- package/dist/collection/configs/default-engine-config.js.map +1 -0
- package/dist/collection/configs/default-sync.config.js +10 -0
- package/dist/collection/configs/default-sync.config.js.map +1 -0
- package/dist/collection/configs/default-text-tool.config.js +32 -0
- package/dist/collection/configs/default-text-tool.config.js.map +1 -0
- package/dist/collection/constants/core.constants.js +2 -0
- package/dist/collection/constants/core.constants.js.map +1 -0
- package/dist/collection/constants/engine.constants.js +3 -0
- package/dist/collection/constants/engine.constants.js.map +1 -0
- package/dist/collection/enums/event-button.enum.js +7 -0
- package/dist/collection/enums/event-button.enum.js.map +1 -0
- package/dist/collection/enums/handle-type.enum.js +8 -0
- package/dist/collection/enums/handle-type.enum.js.map +1 -0
- package/dist/collection/helpers/class.helper.js +6 -0
- package/dist/collection/helpers/class.helper.js.map +1 -0
- package/dist/collection/helpers/devices.helper.js +26 -0
- package/dist/collection/helpers/devices.helper.js.map +1 -0
- package/dist/collection/helpers/event.helper.js +51 -0
- package/dist/collection/helpers/event.helper.js.map +1 -0
- package/dist/collection/helpers/geometry.helper.js +53 -0
- package/dist/collection/helpers/geometry.helper.js.map +1 -0
- package/dist/collection/helpers/html.helper.js +64 -0
- package/dist/{stencil/html.helper-C6qB08BS.js.map → collection/helpers/html.helper.js.map} +1 -1
- package/dist/collection/helpers/keyboard.helper.js +49 -0
- package/dist/collection/helpers/keyboard.helper.js.map +1 -0
- package/dist/collection/helpers/math.helper.js +6 -0
- package/dist/collection/helpers/math.helper.js.map +1 -0
- package/dist/collection/helpers/object.helper.js +12 -0
- package/dist/collection/helpers/object.helper.js.map +1 -0
- package/dist/collection/index.js +30 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/interfaces/bounding-box.interface.js +2 -0
- package/dist/collection/interfaces/bounding-box.interface.js.map +1 -0
- package/dist/collection/interfaces/clonable.interface.js +2 -0
- package/dist/collection/interfaces/clonable.interface.js.map +1 -0
- package/dist/collection/interfaces/context-menu-item.interface.js +2 -0
- package/dist/collection/interfaces/context-menu-item.interface.js.map +1 -0
- package/dist/collection/interfaces/debug-info.interface.js +2 -0
- package/dist/collection/interfaces/debug-info.interface.js.map +1 -0
- package/dist/collection/interfaces/engine-state.interface.js +2 -0
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -0
- package/dist/collection/interfaces/menu-item.interface.js +2 -0
- package/dist/collection/interfaces/menu-item.interface.js.map +1 -0
- package/dist/collection/interfaces/object.interface.js +2 -0
- package/dist/collection/interfaces/object.interface.js.map +1 -0
- package/dist/collection/interfaces/path-options.interface.js +2 -0
- package/dist/collection/interfaces/path-options.interface.js.map +1 -0
- package/dist/collection/interfaces/point.interface.js +2 -0
- package/dist/collection/interfaces/point.interface.js.map +1 -0
- package/dist/collection/interfaces/polygon.interface.js +2 -0
- package/dist/collection/interfaces/polygon.interface.js.map +1 -0
- package/dist/collection/interfaces/selection-state.interface.js +2 -0
- package/dist/collection/interfaces/selection-state.interface.js.map +1 -0
- package/dist/collection/interfaces/serializable.interface.js +2 -0
- package/dist/collection/interfaces/serializable.interface.js.map +1 -0
- package/dist/collection/interfaces/shortcut.interface.js +2 -0
- package/dist/collection/interfaces/shortcut.interface.js.map +1 -0
- package/dist/collection/interfaces/sync-config.interface.js +2 -0
- package/dist/collection/interfaces/sync-config.interface.js.map +1 -0
- package/dist/collection/interfaces/sync-provider.interface.js +2 -0
- package/dist/collection/interfaces/sync-provider.interface.js.map +1 -0
- package/dist/collection/interfaces/tool.interface.js +2 -0
- package/dist/collection/interfaces/tool.interface.js.map +1 -0
- package/dist/collection/interfaces/toolbar-control.interface.js +2 -0
- package/dist/collection/interfaces/toolbar-control.interface.js.map +1 -0
- package/dist/collection/interfaces/undo-state.interface.js +2 -0
- package/dist/collection/interfaces/undo-state.interface.js.map +1 -0
- package/dist/collection/types/deep-readonly.type.js +2 -0
- package/dist/collection/types/deep-readonly.type.js.map +1 -0
- package/dist/collection/types/state.types.js +2 -0
- package/dist/collection/types/state.types.js.map +1 -0
- package/dist/components/index.js +1477 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/kritzel-brush-style.js +67 -0
- package/dist/components/kritzel-brush-style.js.map +1 -0
- package/dist/components/kritzel-color-palette.js +9 -0
- package/dist/components/kritzel-color-palette.js.map +1 -0
- package/dist/components/kritzel-color.js +9 -0
- package/dist/components/kritzel-color.js.map +1 -0
- package/dist/components/kritzel-context-menu.js +9 -0
- package/dist/components/kritzel-context-menu.js.map +1 -0
- package/dist/components/kritzel-control-brush-config.js +9 -0
- package/dist/components/kritzel-control-brush-config.js.map +1 -0
- package/dist/components/kritzel-control-text-config.js +9 -0
- package/dist/components/kritzel-control-text-config.js.map +1 -0
- package/dist/components/kritzel-controls.js +9 -0
- package/dist/components/kritzel-controls.js.map +1 -0
- package/dist/components/kritzel-cursor-trail.js +9 -0
- package/dist/components/kritzel-cursor-trail.js.map +1 -0
- package/dist/components/kritzel-dropdown.js +9 -0
- package/dist/components/kritzel-dropdown.js.map +1 -0
- package/dist/components/kritzel-editor.js +516 -0
- package/dist/components/kritzel-editor.js.map +1 -0
- package/dist/components/kritzel-engine.js +9 -0
- package/dist/components/kritzel-engine.js.map +1 -0
- package/dist/components/kritzel-font-family.js +9 -0
- package/dist/components/kritzel-font-family.js.map +1 -0
- package/dist/components/kritzel-font-size.js +9 -0
- package/dist/components/kritzel-font-size.js.map +1 -0
- package/dist/components/kritzel-font.js +9 -0
- package/dist/components/kritzel-font.js.map +1 -0
- package/dist/components/kritzel-icon.js +9 -0
- package/dist/components/kritzel-icon.js.map +1 -0
- package/dist/components/kritzel-menu-item.js +9 -0
- package/dist/components/kritzel-menu-item.js.map +1 -0
- package/dist/components/kritzel-menu.js +9 -0
- package/dist/components/kritzel-menu.js.map +1 -0
- package/dist/components/kritzel-portal.js +9 -0
- package/dist/components/kritzel-portal.js.map +1 -0
- package/dist/components/kritzel-split-button.js +9 -0
- package/dist/components/kritzel-split-button.js.map +1 -0
- package/dist/components/kritzel-stroke-size.js +9 -0
- package/dist/components/kritzel-stroke-size.js.map +1 -0
- package/dist/components/kritzel-tooltip.js +9 -0
- package/dist/components/kritzel-tooltip.js.map +1 -0
- package/dist/components/kritzel-utility-panel.js +9 -0
- package/dist/components/kritzel-utility-panel.js.map +1 -0
- package/dist/components/kritzel-workspace-manager.js +9 -0
- package/dist/components/kritzel-workspace-manager.js.map +1 -0
- package/dist/{stencil/kritzel-controls.entry.js → components/p-1lIHoOlH.js} +115 -17
- package/dist/components/p-1lIHoOlH.js.map +1 -0
- package/dist/{stencil/object.helper-B0kd2rUI.js → components/p-B0kd2rUI.js} +2 -2
- package/dist/components/p-B0kd2rUI.js.map +1 -0
- package/dist/components/p-B4kxkVe-.js +55 -0
- package/dist/components/p-B4kxkVe-.js.map +1 -0
- package/dist/components/p-BQg4YML7.js +106 -0
- package/dist/components/p-BQg4YML7.js.map +1 -0
- package/dist/{stencil/kritzel-font-family.entry.js → components/p-BgznZoBH.js} +37 -9
- package/dist/components/p-BgznZoBH.js.map +1 -0
- package/dist/components/p-Bhtn9qay.js +98 -0
- package/dist/components/p-Bhtn9qay.js.map +1 -0
- package/dist/{stencil/kritzel-context-menu-GdU9xEKC.js → components/p-C2sWlNsJ.js} +41 -12
- package/dist/components/p-C2sWlNsJ.js.map +1 -0
- package/dist/{stencil/html.helper-C6qB08BS.js → components/p-C6qB08BS.js} +2 -2
- package/dist/components/p-C6qB08BS.js.map +1 -0
- package/dist/{stencil/text-tool.class-C0GbC5zQ.js → components/p-CBYBurdY.js} +25 -729
- package/dist/components/p-CBYBurdY.js.map +1 -0
- package/dist/{stencil/kritzel-dropdown.entry.js → components/p-CIXPLjCu.js} +39 -9
- package/dist/components/p-CIXPLjCu.js.map +1 -0
- package/dist/{stencil/kritzel-workspace-manager.entry.js → components/p-CK6no3mi.js} +68 -13
- package/dist/components/p-CK6no3mi.js.map +1 -0
- package/dist/{stencil/kritzel-cursor-trail.entry.js → components/p-CLt3HMl6.js} +33 -10
- package/dist/components/p-CLt3HMl6.js.map +1 -0
- package/dist/{stencil/kritzel-tooltip.entry.js → components/p-CTP479Lf.js} +39 -11
- package/dist/components/p-CTP479Lf.js.map +1 -0
- package/dist/{stencil/kritzel-menu-item.entry.js → components/p-CsA9M6me.js} +174 -16
- package/dist/components/p-CsA9M6me.js.map +1 -0
- package/dist/components/p-CwkUrTy1.js +1367 -0
- package/dist/components/p-CwkUrTy1.js.map +1 -0
- package/dist/{stencil/kritzel-color-palette.entry.js → components/p-D1uj4A4F.js} +39 -9
- package/dist/components/p-D1uj4A4F.js.map +1 -0
- package/dist/{stencil/kritzel-color.entry.js → components/p-D4yvhd1d.js} +30 -8
- package/dist/components/p-D4yvhd1d.js.map +1 -0
- package/dist/{stencil/kritzel-portal.entry.js → components/p-D5Wq4x4r.js} +37 -11
- package/dist/components/p-D5Wq4x4r.js.map +1 -0
- package/dist/{stencil/event-button.enum-D8W6LE-c.js → components/p-D8W6LE-c.js} +2 -2
- package/dist/components/p-D8W6LE-c.js.map +1 -0
- package/dist/{stencil/kritzel-utility-panel.entry.js → components/p-DAfkuR8U.js} +38 -11
- package/dist/components/p-DAfkuR8U.js.map +1 -0
- package/dist/components/p-DDmSxM5f.js +57 -0
- package/dist/{stencil/kritzel-font-size.entry.esm.js.map → components/p-DDmSxM5f.js.map} +1 -1
- package/dist/components/p-Ddh40W3x.js +103 -0
- package/dist/components/p-Ddh40W3x.js.map +1 -0
- package/dist/components/p-DjTEcPMZ.js +35610 -0
- package/dist/components/p-DjTEcPMZ.js.map +1 -0
- package/dist/{stencil/kritzel-split-button.entry.js → components/p-TdCTkEu0.js} +72 -18
- package/dist/components/p-TdCTkEu0.js.map +1 -0
- package/dist/{stencil/devices.helper-l10It7Nm.js → components/p-l10It7Nm.js} +2 -2
- package/dist/components/p-l10It7Nm.js.map +1 -0
- package/dist/{stencil/workspace.class-n789Y3S-.js → components/p-n789Y3S-.js} +2 -2
- package/dist/components/p-n789Y3S-.js.map +1 -0
- package/dist/components/p-uuRJU2R1.js +46 -0
- package/dist/components/p-uuRJU2R1.js.map +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/default-text-tool.config-2YFQA3SF.js +31208 -0
- package/dist/esm/default-text-tool.config-2YFQA3SF.js.map +1 -0
- package/dist/esm/index-SGde3HXB.js +1623 -0
- package/dist/esm/index-SGde3HXB.js.map +1 -0
- package/dist/esm/index.js +1449 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/{stencil → esm}/kritzel-brush-style.entry.js +3 -3
- package/dist/esm/kritzel-brush-style.entry.js.map +1 -0
- package/dist/{stencil/kritzel-engine.entry.js → esm/kritzel-color_22.entry.js} +1805 -72
- package/dist/esm/loader.js +12 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/stencil.js +22 -0
- package/dist/esm/stencil.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil/index.esm.js +2 -18
- package/dist/stencil/index.esm.js.map +1 -1
- package/dist/stencil/loader.esm.js.map +1 -1
- package/dist/stencil/p-14102a0c.entry.js +10 -0
- package/dist/stencil/p-14102a0c.entry.js.map +1 -0
- package/dist/stencil/p-2YFQA3SF.js +2 -0
- package/dist/stencil/p-2YFQA3SF.js.map +1 -0
- package/dist/stencil/p-DQuL1Twl.js +2 -0
- package/dist/stencil/p-DQuL1Twl.js.map +1 -0
- package/dist/stencil/p-SGde3HXB.js +3 -0
- package/dist/stencil/p-SGde3HXB.js.map +1 -0
- package/dist/stencil/p-d702c5af.entry.js +2 -0
- package/dist/stencil/p-d702c5af.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +2 -48
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/stencil/default-text-tool.config-DKpRP4XR.js +0 -1441
- package/dist/stencil/default-text-tool.config-DKpRP4XR.js.map +0 -1
- package/dist/stencil/devices.helper-l10It7Nm.js.map +0 -1
- package/dist/stencil/engine.constants-DsjjAmnl.js +0 -7
- package/dist/stencil/engine.constants-DsjjAmnl.js.map +0 -1
- package/dist/stencil/event-button.enum-D8W6LE-c.js.map +0 -1
- package/dist/stencil/icon-registry.class-BtT8riKh.js.map +0 -1
- package/dist/stencil/index-DniO_INI.js +0 -4395
- package/dist/stencil/index-DniO_INI.js.map +0 -1
- package/dist/stencil/kritzel-color-palette.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-color.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-context-menu-BYgOEy-i.js +0 -66
- package/dist/stencil/kritzel-context-menu-BYgOEy-i.js.map +0 -1
- package/dist/stencil/kritzel-context-menu-GdU9xEKC.js.map +0 -1
- package/dist/stencil/kritzel-context-menu.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-context-menu.entry.js +0 -3
- package/dist/stencil/kritzel-control-brush-config.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-control-brush-config.entry.js +0 -54
- package/dist/stencil/kritzel-control-text-config.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-control-text-config.entry.js +0 -42
- package/dist/stencil/kritzel-controls.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-cursor-trail.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-dropdown.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-editor.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-editor.entry.js +0 -248
- package/dist/stencil/kritzel-engine.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-font-family.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-font-size.entry.js +0 -28
- package/dist/stencil/kritzel-font.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-font.entry.js +0 -23
- package/dist/stencil/kritzel-icon.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-icon.entry.js +0 -29
- package/dist/stencil/kritzel-menu-item.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-menu.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-menu.entry.js +0 -72
- package/dist/stencil/kritzel-portal.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-split-button.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-stroke-size.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-stroke-size.entry.js +0 -27
- package/dist/stencil/kritzel-tooltip.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-utility-panel.entry.esm.js.map +0 -1
- package/dist/stencil/kritzel-workspace-manager.entry.esm.js.map +0 -1
- package/dist/stencil/object.helper-B0kd2rUI.js.map +0 -1
- package/dist/stencil/sync-config.interface-lKfyG1EN.js +0 -19839
- package/dist/stencil/sync-config.interface-lKfyG1EN.js.map +0 -1
- package/dist/stencil/text-tool.class-C0GbC5zQ.js.map +0 -1
- package/dist/stencil/workspace.class-n789Y3S-.js.map +0 -1
|
@@ -1,15 +1,865 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-SGde3HXB.js';
|
|
2
|
+
import { T as KritzelDevicesHelper, G as KritzelBrushTool, L as KritzelTextTool, U as KritzelMouseButton, M as KritzelSelectionTool, R as DEFAULT_BRUSH_CONFIG, I as KritzelEraserTool, S as DEFAULT_TEXT_CONFIG, J as KritzelImageTool, Q as KritzelWorkspace, V as KritzelKeyboardHelper, W as KritzelBaseHandler, X as KritzelToolRegistry, Y as KritzelSelectionBox, Z as KritzelSelectionGroup, _ as KritzelBaseObject, F as KritzelImage, K as KritzelText, E as KritzelPath, $ as Doc, a0 as DEFAULT_SYNC_CONFIG, a1 as UndoManager, P as KritzelAppStateMap, a2 as ObjectHelper, a3 as KritzelEventHelper, a4 as KritzelBaseTool } from './default-text-tool.config-2YFQA3SF.js';
|
|
3
|
+
|
|
4
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
|
+
|
|
6
|
+
const kritzelColorCss = ":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";
|
|
7
|
+
|
|
8
|
+
const KritzelColor = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
registerInstance(this, hostRef);
|
|
11
|
+
}
|
|
12
|
+
value;
|
|
13
|
+
size = 24;
|
|
14
|
+
isLightColor(hexColor) {
|
|
15
|
+
if (!hexColor)
|
|
16
|
+
return false;
|
|
17
|
+
let r = 0, g = 0, b = 0;
|
|
18
|
+
let sanitizedHex = hexColor.startsWith('#') ? hexColor.slice(1) : hexColor;
|
|
19
|
+
if (sanitizedHex.length === 3) {
|
|
20
|
+
r = parseInt(sanitizedHex[0] + sanitizedHex[0], 16);
|
|
21
|
+
g = parseInt(sanitizedHex[1] + sanitizedHex[1], 16);
|
|
22
|
+
b = parseInt(sanitizedHex[2] + sanitizedHex[2], 16);
|
|
23
|
+
}
|
|
24
|
+
else if (sanitizedHex.length === 6) {
|
|
25
|
+
r = parseInt(sanitizedHex.substring(0, 2), 16);
|
|
26
|
+
g = parseInt(sanitizedHex.substring(2, 4), 16);
|
|
27
|
+
b = parseInt(sanitizedHex.substring(4, 6), 16);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
36
|
+
return luminance > 220;
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
const isColorVeryLight = this.isLightColor(this.value);
|
|
40
|
+
return (h(Host, { key: '000e54c604c8ceca2c44365e95ec1f5bfb1b729a' }, h("div", { key: '77b2abeae70e4a80714e1364eb4e11e67f16d066', class: "checkerboard-bg", style: {
|
|
41
|
+
width: `${this.size}px`,
|
|
42
|
+
height: `${this.size}px`,
|
|
43
|
+
borderRadius: '50%',
|
|
44
|
+
display: 'inline-block',
|
|
45
|
+
position: 'relative',
|
|
46
|
+
} }, h("div", { key: 'df71720cf51d845a36598499adb900a30770c503', class: {
|
|
47
|
+
'color-circle': true,
|
|
48
|
+
'white': isColorVeryLight,
|
|
49
|
+
}, style: {
|
|
50
|
+
backgroundColor: this.value,
|
|
51
|
+
width: `${this.size}px`,
|
|
52
|
+
height: `${this.size}px`,
|
|
53
|
+
borderRadius: '50%',
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
top: '0',
|
|
56
|
+
left: '0',
|
|
57
|
+
display: 'inline-block',
|
|
58
|
+
} }))));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
KritzelColor.style = kritzelColorCss;
|
|
62
|
+
|
|
63
|
+
const kritzelColorPaletteCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;width:100%;box-sizing:border-box}.color-grid{width:100%;display:grid;grid-template-columns:repeat(6, 32px);gap:8px;justify-items:center;overflow:hidden;height:40px;transition:height 0.1s ease-in-out}.color-grid.expanded{height:500px}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.color-container:hover{background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.color-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-color-palette-selected-background-color)}";
|
|
64
|
+
|
|
65
|
+
const KritzelColorPalette = class {
|
|
66
|
+
constructor(hostRef) {
|
|
67
|
+
registerInstance(this, hostRef);
|
|
68
|
+
this.colorChange = createEvent(this, "colorChange");
|
|
69
|
+
}
|
|
70
|
+
colors = [];
|
|
71
|
+
selectedColor = null;
|
|
72
|
+
isExpanded = false;
|
|
73
|
+
isOpaque = false;
|
|
74
|
+
colorChange;
|
|
75
|
+
handleColorClick(color) {
|
|
76
|
+
this.selectedColor = color;
|
|
77
|
+
this.colorChange.emit(color);
|
|
78
|
+
}
|
|
79
|
+
calculateHeight() {
|
|
80
|
+
const colorsPerRow = 6;
|
|
81
|
+
const rowHeight = 32;
|
|
82
|
+
const gap = 8;
|
|
83
|
+
const rowCount = Math.ceil(this.colors.length / colorsPerRow);
|
|
84
|
+
return `${rowCount * rowHeight + (rowCount - 1) * gap}px`;
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
const displayedColors = this.isExpanded ? this.colors : this.colors.slice(0, 6);
|
|
88
|
+
const expandedHeight = this.isExpanded ? this.calculateHeight() : '32px';
|
|
89
|
+
return (h(Host, { key: 'd533725a8ab2019ae963959727283fbbf833c56a' }, h("div", { key: '7fb50c16d79e9b7330100b0f4e116f8f07b20827', class: {
|
|
90
|
+
'color-grid': true,
|
|
91
|
+
'expanded': this.isExpanded,
|
|
92
|
+
}, style: {
|
|
93
|
+
height: expandedHeight,
|
|
94
|
+
} }, displayedColors.map(color => (h("div", { tabIndex: 0, class: {
|
|
95
|
+
'color-container': true,
|
|
96
|
+
'selected': this.selectedColor === color,
|
|
97
|
+
}, onClick: () => this.handleColorClick(color) }, h("kritzel-color", { value: color })))))));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
KritzelColorPalette.style = kritzelColorPaletteCss;
|
|
101
|
+
|
|
102
|
+
const kritzelContextMenuCss = ":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius, 12px);box-shadow:var(--kritzel-context-menu-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12));border:var(--kritzel-context-menu-border, 1px solid #ebebeb);padding:var(--kritzel-context-menu-padding,4px)}.menu-item{display:flex;align-items:center;gap:var(--kritzel-context-menu-item-gap, 8px);background:none;border:none;text-align:left;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);white-space:nowrap;-webkit-tap-highlight-color:transparent}.menu-item:not(.disabled):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);cursor:default}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.label{flex-grow:1}";
|
|
103
|
+
|
|
104
|
+
const KritzelContextMenu = class {
|
|
105
|
+
constructor(hostRef) {
|
|
106
|
+
registerInstance(this, hostRef);
|
|
107
|
+
this.actionSelected = createEvent(this, "actionSelected");
|
|
108
|
+
this.close = createEvent(this, "close");
|
|
109
|
+
}
|
|
110
|
+
get host() { return getElement(this); }
|
|
111
|
+
items;
|
|
112
|
+
onItemsChanged() {
|
|
113
|
+
this.updateMenuItems();
|
|
114
|
+
}
|
|
115
|
+
objects;
|
|
116
|
+
actionSelected;
|
|
117
|
+
close;
|
|
118
|
+
processedItems = [];
|
|
119
|
+
handleOutsideClick(event) {
|
|
120
|
+
const path = event.composedPath();
|
|
121
|
+
if (!path.includes(this.host)) {
|
|
122
|
+
this.close.emit();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
componentWillLoad() {
|
|
126
|
+
this.updateMenuItems();
|
|
127
|
+
}
|
|
128
|
+
handleItemClick(item, isDisabled) {
|
|
129
|
+
if (!isDisabled) {
|
|
130
|
+
this.actionSelected.emit(item);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async updateMenuItems() {
|
|
134
|
+
const processed = [];
|
|
135
|
+
for (const item of this.items) {
|
|
136
|
+
const isVisible = await this.evaluateProperty(item.visible, true);
|
|
137
|
+
if (isVisible) {
|
|
138
|
+
const isDisabled = await this.evaluateProperty(item.disabled, false);
|
|
139
|
+
processed.push({ item, isDisabled });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.processedItems = processed;
|
|
143
|
+
}
|
|
144
|
+
async evaluateProperty(value, defaultValue) {
|
|
145
|
+
if (typeof value === 'boolean') {
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
if (typeof value === 'function') {
|
|
149
|
+
return await Promise.resolve(value(null, this.objects));
|
|
150
|
+
}
|
|
151
|
+
return defaultValue;
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
return (h(Host, { key: '45b9652285f9c3fe7568cbe222667d23c151622f' }, h("div", { key: '9aecc01027f297fa4d991780efaaf51b8d4542dc', class: "menu-container" }, this.processedItems.map(({ item, isDisabled }, index) => (h("button", { key: `${item.label}-${index}`, class: { 'menu-item': true, 'disabled': isDisabled }, onClick: () => this.handleItemClick(item, isDisabled), disabled: isDisabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)))))));
|
|
155
|
+
}
|
|
156
|
+
static get watchers() { return {
|
|
157
|
+
"items": ["onItemsChanged"]
|
|
158
|
+
}; }
|
|
159
|
+
};
|
|
160
|
+
KritzelContextMenu.style = kritzelContextMenuCss;
|
|
161
|
+
|
|
162
|
+
const kritzelControlBrushConfigCss = ":host{display:flex;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
|
|
163
|
+
|
|
164
|
+
const KritzelControlBrushConfig = class {
|
|
165
|
+
constructor(hostRef) {
|
|
166
|
+
registerInstance(this, hostRef);
|
|
167
|
+
this.toolChange = createEvent(this, "toolChange");
|
|
168
|
+
}
|
|
169
|
+
tool;
|
|
170
|
+
handleToolChange(newTool) {
|
|
171
|
+
this.palette = newTool.palettes[newTool.type];
|
|
172
|
+
}
|
|
173
|
+
isExpanded = false;
|
|
174
|
+
toolChange;
|
|
175
|
+
palette = [];
|
|
176
|
+
componentWillLoad() {
|
|
177
|
+
this.palette = this.tool.palettes[this.tool.type];
|
|
178
|
+
}
|
|
179
|
+
handleToggleExpand() {
|
|
180
|
+
this.isExpanded = !this.isExpanded;
|
|
181
|
+
}
|
|
182
|
+
handleTypeChange(event) {
|
|
183
|
+
this.palette = this.tool.palettes[event.detail];
|
|
184
|
+
this.tool.type = event.detail;
|
|
185
|
+
this.tool.color = this.palette[0];
|
|
186
|
+
this.toolChange.emit(this.tool);
|
|
187
|
+
}
|
|
188
|
+
handleColorChange(event) {
|
|
189
|
+
this.tool.color = event.detail;
|
|
190
|
+
this.toolChange.emit(this.tool);
|
|
191
|
+
}
|
|
192
|
+
handleSizeChange(event) {
|
|
193
|
+
this.tool.size = event.detail;
|
|
194
|
+
this.toolChange.emit(this.tool);
|
|
195
|
+
}
|
|
196
|
+
render() {
|
|
197
|
+
return (h(Host, { key: '4b060826312e6d5a2117f5ba9522553af9b02d6f' }, h("div", { key: '0975a250184d5bb2d38cc60263bd718157230d8c', style: {
|
|
198
|
+
display: 'flex',
|
|
199
|
+
flexDirection: 'row',
|
|
200
|
+
alignItems: this.isExpanded ? 'flex-start' : 'center',
|
|
201
|
+
justifyContent: 'flex-start',
|
|
202
|
+
width: '100%',
|
|
203
|
+
gap: '8px',
|
|
204
|
+
} }, h("kritzel-color-palette", { key: 'df84a6fdda01bc7bf3aff42e3b88c4bd9dca500f', colors: this.palette, selectedColor: this.tool.color, isExpanded: this.isExpanded, isOpaque: true, onColorChange: color => this.handleColorChange(color) }), h("button", { key: 'e43c19612807fc4f9cd1bf04f4fb79a048cfd62b', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand', style: this.palette.length > 6 ? { visibillity: 'visible' } : { visibility: 'hidden' } }, h("kritzel-icon", { key: '915cce6c4744ad175f3836c946330882de840880', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-stroke-size", { key: 'c07eebae3ba1785e2644c6b5a22d23f76be950fb', selectedSize: this.tool.size, onSizeChange: event => this.handleSizeChange(event) })));
|
|
205
|
+
}
|
|
206
|
+
static get watchers() { return {
|
|
207
|
+
"tool": ["handleToolChange"]
|
|
208
|
+
}; }
|
|
209
|
+
};
|
|
210
|
+
KritzelControlBrushConfig.style = kritzelControlBrushConfigCss;
|
|
211
|
+
|
|
212
|
+
const kritzelControlTextConfigCss = ":host{display:block;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
|
|
213
|
+
|
|
214
|
+
const KritzelControlTextConfig = class {
|
|
215
|
+
constructor(hostRef) {
|
|
216
|
+
registerInstance(this, hostRef);
|
|
217
|
+
this.toolChange = createEvent(this, "toolChange");
|
|
218
|
+
}
|
|
219
|
+
tool;
|
|
220
|
+
isExpanded = false;
|
|
221
|
+
toolChange;
|
|
222
|
+
handleToggleExpand() {
|
|
223
|
+
this.isExpanded = !this.isExpanded;
|
|
224
|
+
}
|
|
225
|
+
handleFamilyChange(event) {
|
|
226
|
+
this.tool.fontFamily = event.detail;
|
|
227
|
+
this.toolChange.emit(this.tool);
|
|
228
|
+
}
|
|
229
|
+
handleColorChange(event) {
|
|
230
|
+
this.tool.fontColor = event.detail;
|
|
231
|
+
this.toolChange.emit(this.tool);
|
|
232
|
+
}
|
|
233
|
+
handleSizeChange(event) {
|
|
234
|
+
this.tool.fontSize = event.detail;
|
|
235
|
+
this.toolChange.emit(this.tool);
|
|
236
|
+
}
|
|
237
|
+
render() {
|
|
238
|
+
return (h(Host, { key: '82e611092700f057bd36823e7f7503fe7a0423ed' }, h("div", { key: '37ed39adeeeb58981a917918cd185e96d589e973', style: {
|
|
239
|
+
display: 'flex',
|
|
240
|
+
flexDirection: 'row',
|
|
241
|
+
alignItems: 'center',
|
|
242
|
+
justifyContent: 'flex-start',
|
|
243
|
+
width: '100%',
|
|
244
|
+
gap: '8px',
|
|
245
|
+
} }, h("kritzel-font-family", { key: 'cd8afc5c4a1eee087610cd3d5a6c05210cfda6b3', selectedFontFamily: this.tool.fontFamily, onFontFamilyChange: event => this.handleFamilyChange(event) }), h("button", { key: '085f1bba060bde27a7b64dc5477bb51305b76235', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand' }, h("kritzel-icon", { key: '3ff8fec207120e67f43315c6dace72fc2f6bd0f1', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-color-palette", { key: '2e29d01a6b5c0e4a8ec347e63b6a2698c282db40', colors: this.tool.palette, selectedColor: this.tool.fontColor, isExpanded: this.isExpanded, onColorChange: event => this.handleColorChange(event) }), h("kritzel-font-size", { key: 'c972068f1251d66e756b8de72fbdd1b6002d1daa', selectedSize: this.tool.fontSize, fontFamily: this.tool.fontFamily, onSizeChange: event => this.handleSizeChange(event) })));
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
249
|
+
|
|
250
|
+
const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}:host(.mobile){--kritzel-controls-control-hover-background-color:transparent;--kritzel-controls-control-active-background-color:transparent}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 16px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #ebebeb);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 12px);padding:var(--kritzel-controls-control-padding, 8px);border:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:focus,.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #007AFF) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-control.selected:focus{background-color:var(--kritzel-controls-control-selected-background-color, #007bffe3) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer;border-radius:50%}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:56px;left:50%;transform:translateX(-50%);z-index:10001}";
|
|
251
|
+
|
|
252
|
+
const KritzelControls = class {
|
|
253
|
+
constructor(hostRef) {
|
|
254
|
+
registerInstance(this, hostRef);
|
|
255
|
+
this.isControlsReady = createEvent(this, "isControlsReady");
|
|
256
|
+
}
|
|
257
|
+
get host() { return getElement(this); }
|
|
258
|
+
controls = [];
|
|
259
|
+
activeControl = null;
|
|
260
|
+
isUtilityPanelVisible = true;
|
|
261
|
+
undoState = null;
|
|
262
|
+
isControlsReady;
|
|
263
|
+
firstConfig = null;
|
|
264
|
+
isTooltipVisible = false;
|
|
265
|
+
isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
266
|
+
handleDocumentClick(event) {
|
|
267
|
+
const element = event.target;
|
|
268
|
+
if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
this.isTooltipVisible = false;
|
|
272
|
+
}
|
|
273
|
+
handleKeyDown(event) {
|
|
274
|
+
if (event.key === 'Escape') {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
this.closeTooltip();
|
|
277
|
+
this.kritzelEngine?.enable();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async handleActiveToolChange(event) {
|
|
281
|
+
this.activeControl = this.controls.find(control => control.tool === event.detail) || null;
|
|
282
|
+
}
|
|
283
|
+
async closeTooltip() {
|
|
284
|
+
this.isTooltipVisible = false;
|
|
285
|
+
}
|
|
286
|
+
kritzelEngine = null;
|
|
287
|
+
tooltipRef = null;
|
|
288
|
+
get activeToolAsTextTool() {
|
|
289
|
+
return this.activeControl?.tool;
|
|
290
|
+
}
|
|
291
|
+
get activeToolAsBrushTool() {
|
|
292
|
+
return this.activeControl?.tool;
|
|
293
|
+
}
|
|
294
|
+
async componentWillLoad() {
|
|
295
|
+
await this.initializeEngine();
|
|
296
|
+
await this.initializeTools();
|
|
297
|
+
this.isControlsReady.emit();
|
|
298
|
+
}
|
|
299
|
+
async initializeEngine() {
|
|
300
|
+
await customElements.whenDefined('kritzel-engine');
|
|
301
|
+
this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');
|
|
302
|
+
if (!this.kritzelEngine) {
|
|
303
|
+
throw new Error('kritzel-engine not found in parent element.');
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async initializeTools() {
|
|
307
|
+
for (const c of this.controls) {
|
|
308
|
+
if (c.type === 'tool' && c.tool) {
|
|
309
|
+
c.tool = await this.kritzelEngine.registerTool(c.name, c.tool, c.config);
|
|
310
|
+
}
|
|
311
|
+
if (c.type === 'tool' && c.isDefault && c.tool) {
|
|
312
|
+
await this.kritzelEngine.changeActiveTool(c.tool);
|
|
313
|
+
this.activeControl = c;
|
|
314
|
+
}
|
|
315
|
+
if (c.type === 'config') {
|
|
316
|
+
if (this.firstConfig === null) {
|
|
317
|
+
this.firstConfig = c;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
console.warn('Only one config control is allowed. The first one will be used.');
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async handleControlClick(control) {
|
|
326
|
+
this.activeControl = control;
|
|
327
|
+
if (this.activeControl.type === 'tool') {
|
|
328
|
+
await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
handleConfigClick(event) {
|
|
332
|
+
event.stopPropagation();
|
|
333
|
+
this.isTooltipVisible = !this.isTooltipVisible;
|
|
334
|
+
if (this.isTooltipVisible) {
|
|
335
|
+
this.kritzelEngine?.disable();
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
this.kritzelEngine?.enable();
|
|
339
|
+
}
|
|
340
|
+
setTimeout(() => {
|
|
341
|
+
this.tooltipRef?.focusContent();
|
|
342
|
+
}, 100);
|
|
343
|
+
}
|
|
344
|
+
async handleToolChange(event) {
|
|
345
|
+
this.activeControl = { ...this.activeControl, tool: event.detail };
|
|
346
|
+
await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
|
|
347
|
+
}
|
|
348
|
+
handleTooltipClosed() {
|
|
349
|
+
this.isTooltipVisible = false;
|
|
350
|
+
this.kritzelEngine?.enable();
|
|
351
|
+
}
|
|
352
|
+
render() {
|
|
353
|
+
const hasNoConfig = this.activeControl?.config === undefined || this.activeControl?.config === null;
|
|
354
|
+
return (h(Host, { key: '6ea9de8d541e3fc02c5ceeebf4c2c5fb4d8ad926', class: {
|
|
355
|
+
mobile: this.isTouchDevice,
|
|
356
|
+
} }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '7506b42f05c3f49aa5c936d267c5de44b3ebb9cd', style: {
|
|
357
|
+
position: 'absolute',
|
|
358
|
+
bottom: '56px',
|
|
359
|
+
left: '12px',
|
|
360
|
+
}, undoState: this.undoState, onUndo: () => this.kritzelEngine?.undo(), onRedo: () => this.kritzelEngine?.redo(), onDelete: () => this.kritzelEngine?.delete() })), h("div", { key: '1299fce4adea3f9a529bbaf73d35e2676b6850e4', class: "kritzel-controls" }, this.controls.map(control => {
|
|
361
|
+
if (control.type === 'tool') {
|
|
362
|
+
return (h("button", { class: {
|
|
363
|
+
'kritzel-control': true,
|
|
364
|
+
'selected': this.activeControl?.name === control?.name,
|
|
365
|
+
}, key: control.name, onClick: _event => this.handleControlClick?.(control) }, h("kritzel-icon", { name: control.icon })));
|
|
366
|
+
}
|
|
367
|
+
if (control.type === 'divider') {
|
|
368
|
+
return h("div", { class: "kritzel-divider", key: control.name });
|
|
369
|
+
}
|
|
370
|
+
if (control.type === 'config' && control.name === this.firstConfig?.name && this.activeControl) {
|
|
371
|
+
return (h("div", { class: "kritzel-config-container", key: control.name }, h("kritzel-tooltip", { ref: el => (this.tooltipRef = el), isVisible: this.isTooltipVisible, anchorElement: this.host.shadowRoot?.querySelector('.kritzel-config-container'), onTooltipClosed: () => this.handleTooltipClosed() }, h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => this.handleToolChange?.(event) })), this.activeControl.name === 'text' && (h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => this.handleToolChange?.(event) })))), h("div", { tabIndex: 0, class: "kritzel-config", onClick: event => this.handleConfigClick?.(event), onKeyDown: event => {
|
|
372
|
+
if (event.key === 'Enter') {
|
|
373
|
+
this.handleConfigClick?.(event);
|
|
374
|
+
}
|
|
375
|
+
}, style: {
|
|
376
|
+
cursor: this.activeControl.config ? 'pointer' : 'default',
|
|
377
|
+
pointerEvents: hasNoConfig ? 'none' : 'auto',
|
|
378
|
+
} }, this.activeControl.tool instanceof KritzelBrushTool && (h("div", { class: "color-container" }, h("kritzel-color", { value: this.activeToolAsBrushTool?.color, size: this.activeToolAsBrushTool?.size, style: {
|
|
379
|
+
borderRadius: '50%',
|
|
380
|
+
border: 'none',
|
|
381
|
+
} }))), this.activeControl.tool instanceof KritzelTextTool && (h("div", { class: "font-container" }, h("kritzel-font", { fontFamily: this.activeToolAsTextTool?.fontFamily, size: this.activeToolAsTextTool?.fontSize, color: this.activeToolAsTextTool?.fontColor }))), hasNoConfig && h("div", { class: "no-config" }))));
|
|
382
|
+
}
|
|
383
|
+
}))));
|
|
384
|
+
}
|
|
385
|
+
static get assetsDirs() { return ["../assets"]; }
|
|
386
|
+
};
|
|
387
|
+
KritzelControls.style = kritzelControlsCss;
|
|
388
|
+
|
|
389
|
+
const kritzelCursorTrailCss = ":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:9000}";
|
|
390
|
+
|
|
391
|
+
const KritzelCursorTrail = class {
|
|
392
|
+
constructor(hostRef) {
|
|
393
|
+
registerInstance(this, hostRef);
|
|
394
|
+
}
|
|
395
|
+
core;
|
|
396
|
+
cursorTrailPoints = [];
|
|
397
|
+
isLeftButtonDown = false;
|
|
398
|
+
handleMouseDown(ev) {
|
|
399
|
+
if (ev.pointerType === 'mouse') {
|
|
400
|
+
if (ev.button === KritzelMouseButton.Left) {
|
|
401
|
+
this.isLeftButtonDown = true;
|
|
402
|
+
this.cursorTrailPoints = [];
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (ev.pointerType === 'touch') {
|
|
406
|
+
if (this.core.store.state.pointers.size === 1) {
|
|
407
|
+
this.isLeftButtonDown = true;
|
|
408
|
+
this.cursorTrailPoints = [];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
handlePointerMove(ev) {
|
|
413
|
+
if (!this.isLeftButtonDown) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const newPoint = { x: ev.clientX, y: ev.clientY, timestamp: Date.now() };
|
|
417
|
+
const updatedTrail = [newPoint, ...this.cursorTrailPoints];
|
|
418
|
+
if (updatedTrail.length > this.MAX_TRAIL_POINTS) {
|
|
419
|
+
this.cursorTrailPoints = updatedTrail.slice(0, this.MAX_TRAIL_POINTS);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this.cursorTrailPoints = updatedTrail;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
handlePointerUp(ev) {
|
|
426
|
+
if (ev.pointerType === 'mouse') {
|
|
427
|
+
if (ev.button === KritzelMouseButton.Left) {
|
|
428
|
+
this.isLeftButtonDown = false;
|
|
429
|
+
this.cursorTrailPoints = [];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (ev.pointerType === 'touch') {
|
|
433
|
+
if (this.core.store.state.pointers.size === 0) {
|
|
434
|
+
this.isLeftButtonDown = false;
|
|
435
|
+
this.cursorTrailPoints = [];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
trailCleanupIntervalId;
|
|
440
|
+
TRAIL_DURATION_MS = 100;
|
|
441
|
+
MAX_TRAIL_POINTS = 50;
|
|
442
|
+
componentDidLoad() {
|
|
443
|
+
this.trailCleanupIntervalId = window.setInterval(() => {
|
|
444
|
+
const now = Date.now();
|
|
445
|
+
const newTrailPoints = this.cursorTrailPoints.filter(p => now - p.timestamp < this.TRAIL_DURATION_MS);
|
|
446
|
+
if (newTrailPoints.length !== this.cursorTrailPoints.length) {
|
|
447
|
+
this.cursorTrailPoints = newTrailPoints;
|
|
448
|
+
}
|
|
449
|
+
}, 50);
|
|
450
|
+
}
|
|
451
|
+
disconnectedCallback() {
|
|
452
|
+
if (this.trailCleanupIntervalId) {
|
|
453
|
+
window.clearInterval(this.trailCleanupIntervalId);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
render() {
|
|
457
|
+
return (h(Host, { key: '10ef620f19d72a8a5c3a12d0d98686bc69308a30' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: 'd03403051e53422aaa28d6360aaa9c0391e3ef6a', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
458
|
+
position: 'absolute',
|
|
459
|
+
left: '0',
|
|
460
|
+
top: '0',
|
|
461
|
+
width: '100%',
|
|
462
|
+
height: '100%',
|
|
463
|
+
pointerEvents: 'none',
|
|
464
|
+
opacity: 'var(--kritzel-cursor-trail-opacity, 0.6)',
|
|
465
|
+
zIndex: '9000',
|
|
466
|
+
} }, this.cursorTrailPoints.slice(1).map((point, index) => {
|
|
467
|
+
const prevPoint = this.cursorTrailPoints[index];
|
|
468
|
+
const now = Date.now();
|
|
469
|
+
const age = now - point.timestamp;
|
|
470
|
+
const progress = Math.max(0, Math.min(1, age / this.TRAIL_DURATION_MS));
|
|
471
|
+
if (progress >= 1)
|
|
472
|
+
return null;
|
|
473
|
+
const baseStrokeWidth = Math.max(2, 15 * (1 - progress));
|
|
474
|
+
return (h("line", { key: `trail-segment-${point.timestamp}`, x1: prevPoint.x.toString(), y1: prevPoint.y.toString(), x2: point.x.toString(), y2: point.y.toString(), stroke: "var(--kritzel-cursor-trail-color, rgb(228, 228, 228))", "stroke-width": baseStrokeWidth.toString(), "stroke-linecap": "round" }));
|
|
475
|
+
})))));
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
KritzelCursorTrail.style = kritzelCursorTrailCss;
|
|
479
|
+
|
|
480
|
+
const kritzelDropdownCss = ":host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23333333\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"/></svg>');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}";
|
|
481
|
+
|
|
482
|
+
const KritzelDropdown = class {
|
|
483
|
+
constructor(hostRef) {
|
|
484
|
+
registerInstance(this, hostRef);
|
|
485
|
+
this.valueChanged = createEvent(this, "valueChanged");
|
|
486
|
+
}
|
|
487
|
+
options = [];
|
|
488
|
+
optionsChanged() {
|
|
489
|
+
this.updateInternalValue(this.internalValue, true);
|
|
490
|
+
}
|
|
491
|
+
value;
|
|
492
|
+
externalValueChanged(newValue) {
|
|
493
|
+
if (newValue !== this.internalValue) {
|
|
494
|
+
this.updateInternalValue(newValue, false);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
width;
|
|
498
|
+
selectStyles = {};
|
|
499
|
+
internalValue;
|
|
500
|
+
hasSuffixContent = false;
|
|
501
|
+
hasPrefixContent = false;
|
|
502
|
+
valueChanged;
|
|
503
|
+
suffixSlotElement;
|
|
504
|
+
prefixSlotElement;
|
|
505
|
+
componentWillLoad() {
|
|
506
|
+
this.updateInternalValue(this.value, false);
|
|
507
|
+
this.evaluateSuffixContent();
|
|
508
|
+
this.evaluatePrefixContent();
|
|
509
|
+
}
|
|
510
|
+
updateInternalValue(proposedValue, emitChange) {
|
|
511
|
+
let finalValue = proposedValue;
|
|
512
|
+
if (this.options && this.options.length > 0) {
|
|
513
|
+
const isValidValue = this.options.some(opt => opt.value === finalValue);
|
|
514
|
+
if (!finalValue || !isValidValue) {
|
|
515
|
+
finalValue = this.options[0].value;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
finalValue = undefined;
|
|
520
|
+
}
|
|
521
|
+
if (this.internalValue !== finalValue) {
|
|
522
|
+
this.internalValue = finalValue;
|
|
523
|
+
if (emitChange || (proposedValue !== finalValue && proposedValue !== undefined)) {
|
|
524
|
+
this.valueChanged.emit(this.internalValue);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
handleSelectChange = (event) => {
|
|
529
|
+
const newValue = event.target.value;
|
|
530
|
+
if (this.internalValue !== newValue) {
|
|
531
|
+
this.internalValue = newValue;
|
|
532
|
+
this.valueChanged.emit(this.internalValue);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
evaluateSuffixContent = () => {
|
|
536
|
+
if (this.suffixSlotElement) {
|
|
537
|
+
const newHasContent = this.suffixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
538
|
+
if (this.hasSuffixContent !== newHasContent) {
|
|
539
|
+
this.hasSuffixContent = newHasContent;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
if (this.hasSuffixContent !== false) {
|
|
544
|
+
this.hasSuffixContent = false;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
evaluatePrefixContent = () => {
|
|
549
|
+
if (this.prefixSlotElement) {
|
|
550
|
+
const newHasContent = this.prefixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
551
|
+
if (this.hasPrefixContent !== newHasContent) {
|
|
552
|
+
this.hasPrefixContent = newHasContent;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
if (this.hasPrefixContent !== false) {
|
|
557
|
+
this.hasPrefixContent = false;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
render() {
|
|
562
|
+
const selectClasses = {
|
|
563
|
+
'custom-select': true,
|
|
564
|
+
'has-suffix-border': this.hasSuffixContent,
|
|
565
|
+
'has-prefix-border': this.hasPrefixContent,
|
|
566
|
+
};
|
|
567
|
+
return (h(Host, { key: 'f24911715685ced571843ba7be6631248c8519b7' }, h("div", { key: '520fdb74afdef8bd5228f76074e51981f44b910d', class: "dropdown-wrapper" }, h("slot", { key: 'cf6628437946b57ad0b27c066639e0b64b5a28f8', name: "prefix", ref: el => (this.prefixSlotElement = el), onSlotchange: this.evaluatePrefixContent }), h("select", { key: '3203ccd5b9c8b84e8f41bddfcb07786e879f0035', class: selectClasses, style: { ...this.selectStyles, width: this.width }, onInput: this.handleSelectChange }, this.options.map(option => (h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), h("slot", { key: 'd0abb52e082db81860c09d2c48b7c065adb406f3', name: "suffix", ref: el => (this.suffixSlotElement = el), onSlotchange: this.evaluateSuffixContent }))));
|
|
568
|
+
}
|
|
569
|
+
static get watchers() { return {
|
|
570
|
+
"options": ["optionsChanged"],
|
|
571
|
+
"value": ["externalValueChanged"]
|
|
572
|
+
}; }
|
|
573
|
+
};
|
|
574
|
+
KritzelDropdown.style = kritzelDropdownCss;
|
|
575
|
+
|
|
576
|
+
class KritzelIconRegistry {
|
|
577
|
+
static registry = new Map();
|
|
578
|
+
static register(name, svgContent) {
|
|
579
|
+
if (this.registry.has(name)) {
|
|
580
|
+
console.warn(`[IconRegistry] Icon "${name}" is already registered. It will be overwritten.`);
|
|
581
|
+
}
|
|
582
|
+
this.registry.set(name, svgContent);
|
|
583
|
+
}
|
|
584
|
+
static get(name) {
|
|
585
|
+
return this.registry.get(name);
|
|
586
|
+
}
|
|
587
|
+
static registerIcons(icons) {
|
|
588
|
+
for (const name in icons) {
|
|
589
|
+
if (Object.prototype.hasOwnProperty.call(icons, name)) {
|
|
590
|
+
this.register(name, icons[name]);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
static has(name) {
|
|
595
|
+
return this.registry.has(name);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
KritzelIconRegistry.registerIcons({
|
|
599
|
+
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
|
|
600
|
+
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
|
|
601
|
+
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
|
|
602
|
+
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
|
|
603
|
+
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
|
|
604
|
+
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
|
|
605
|
+
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
|
|
606
|
+
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
|
|
607
|
+
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
608
|
+
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
|
|
609
|
+
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
|
|
610
|
+
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
|
|
611
|
+
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
|
|
612
|
+
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
|
|
613
|
+
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
|
|
614
|
+
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
|
|
615
|
+
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
|
|
616
|
+
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>',
|
|
617
|
+
'plus': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus-icon lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>',
|
|
618
|
+
'ellipsis-vertical': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis-vertical-icon lucide-ellipsis-vertical"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>',
|
|
619
|
+
'x': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
620
|
+
'check': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
const ABSOLUTE_SCALE_MAX = 1000;
|
|
624
|
+
const ABSOLUTE_SCALE_MIN = 0.0001;
|
|
625
|
+
|
|
626
|
+
const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-workspace-manager{position:absolute;top:var(--kritzel-editor-workspace-manager-top, 14px);left:var(--kritzel-editor-workspace-manager-left, 14px)}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}";
|
|
627
|
+
|
|
628
|
+
const KritzelEditor = class {
|
|
629
|
+
constructor(hostRef) {
|
|
630
|
+
registerInstance(this, hostRef);
|
|
631
|
+
this.isReady = createEvent(this, "isReady");
|
|
632
|
+
this.objectsChange = createEvent(this, "objectsChange");
|
|
633
|
+
this.undoStateChange = createEvent(this, "undoStateChange");
|
|
634
|
+
}
|
|
635
|
+
get host() { return getElement(this); }
|
|
636
|
+
scaleMax = ABSOLUTE_SCALE_MAX;
|
|
637
|
+
scaleMin = ABSOLUTE_SCALE_MIN;
|
|
638
|
+
controls = [
|
|
639
|
+
{
|
|
640
|
+
name: 'selection',
|
|
641
|
+
type: 'tool',
|
|
642
|
+
isDefault: true,
|
|
643
|
+
tool: KritzelSelectionTool,
|
|
644
|
+
icon: 'cursor',
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
name: 'brush',
|
|
648
|
+
type: 'tool',
|
|
649
|
+
tool: KritzelBrushTool,
|
|
650
|
+
icon: 'pen',
|
|
651
|
+
config: DEFAULT_BRUSH_CONFIG,
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: 'eraser',
|
|
655
|
+
type: 'tool',
|
|
656
|
+
tool: KritzelEraserTool,
|
|
657
|
+
icon: 'eraser',
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: 'text',
|
|
661
|
+
type: 'tool',
|
|
662
|
+
tool: KritzelTextTool,
|
|
663
|
+
icon: 'type',
|
|
664
|
+
config: DEFAULT_TEXT_CONFIG,
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: 'image',
|
|
668
|
+
type: 'tool',
|
|
669
|
+
tool: KritzelImageTool,
|
|
670
|
+
icon: 'image',
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
name: 'divider',
|
|
674
|
+
type: 'divider',
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: 'config',
|
|
678
|
+
type: 'config',
|
|
679
|
+
},
|
|
680
|
+
];
|
|
681
|
+
globalContextMenuItems = [
|
|
682
|
+
{
|
|
683
|
+
label: 'Paste',
|
|
684
|
+
icon: 'paste',
|
|
685
|
+
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
686
|
+
action: menu => this.engineRef.paste(menu.x, menu.y),
|
|
687
|
+
},
|
|
688
|
+
{ label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
|
|
689
|
+
];
|
|
690
|
+
objectContextMenuItems = [
|
|
691
|
+
{ label: 'Copy', icon: 'copy', action: () => this.engineRef.copy() },
|
|
692
|
+
{
|
|
693
|
+
label: 'Paste',
|
|
694
|
+
icon: 'paste',
|
|
695
|
+
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
696
|
+
action: (menu, _) => this.engineRef.paste(menu.x, menu.y),
|
|
697
|
+
},
|
|
698
|
+
{ label: 'Delete', icon: 'delete', action: () => this.engineRef.delete() },
|
|
699
|
+
{ label: 'Bring to Front', icon: 'bring-to-front', action: () => this.engineRef.bringToFront() },
|
|
700
|
+
{ label: 'Send to Back', icon: 'send-to-back', action: () => this.engineRef.sendToBack() },
|
|
701
|
+
];
|
|
702
|
+
customSvgIcons = {};
|
|
703
|
+
isControlsVisible = true;
|
|
704
|
+
isUtilityPanelVisible = true;
|
|
705
|
+
syncConfig;
|
|
706
|
+
isReady;
|
|
707
|
+
objectsChange;
|
|
708
|
+
undoStateChange;
|
|
709
|
+
isEngineReady = false;
|
|
710
|
+
isControlsReady = false;
|
|
711
|
+
isWorkspaceManagerReady = false;
|
|
712
|
+
workspaces = [];
|
|
713
|
+
activeWorkspace;
|
|
714
|
+
isVirtualKeyboardOpen = false;
|
|
715
|
+
undoState = null;
|
|
716
|
+
onIsEngineReady(newValue) {
|
|
717
|
+
if (newValue && this.isControlsReady) {
|
|
718
|
+
this.checkIsReady();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
onIsControlsReady(newValue) {
|
|
722
|
+
if (newValue && this.isEngineReady) {
|
|
723
|
+
this.checkIsReady();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
onWorkspacesChange(newWorkspaces) {
|
|
727
|
+
if (this.activeWorkspace) {
|
|
728
|
+
const updatedActiveWorkspace = newWorkspaces.find(ws => ws.id === this.activeWorkspace.id);
|
|
729
|
+
if (updatedActiveWorkspace && updatedActiveWorkspace !== this.activeWorkspace) {
|
|
730
|
+
this.activeWorkspace = updatedActiveWorkspace;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
onTouchStart(event) {
|
|
735
|
+
if (event.cancelable) {
|
|
736
|
+
event.preventDefault();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
async getObjectById(id) {
|
|
740
|
+
return this.engineRef.getObjectById(id);
|
|
741
|
+
}
|
|
742
|
+
async addObject(object) {
|
|
743
|
+
return this.engineRef.addObject(object);
|
|
744
|
+
}
|
|
745
|
+
async updateObject(object, updatedProperties) {
|
|
746
|
+
return this.engineRef.updateObject(object, updatedProperties);
|
|
747
|
+
}
|
|
748
|
+
async removeObject(object) {
|
|
749
|
+
return this.engineRef.removeObject(object);
|
|
750
|
+
}
|
|
751
|
+
async getSelectedObjects() {
|
|
752
|
+
return this.engineRef.getSelectedObjects();
|
|
753
|
+
}
|
|
754
|
+
async selectObjects(objects) {
|
|
755
|
+
return this.engineRef.selectObjects(objects);
|
|
756
|
+
}
|
|
757
|
+
async selectAllObjectsInViewport() {
|
|
758
|
+
return this.engineRef.selectAllObjectsInViewport();
|
|
759
|
+
}
|
|
760
|
+
async clearSelection() {
|
|
761
|
+
this.engineRef.clearSelection();
|
|
762
|
+
}
|
|
763
|
+
async centerObjectInViewport(object) {
|
|
764
|
+
return this.engineRef.centerObjectInViewport(object);
|
|
765
|
+
}
|
|
766
|
+
async createWorkspace(name, viewport) {
|
|
767
|
+
const workspace = new KritzelWorkspace(`workspace-${Date.now()}`, name, viewport);
|
|
768
|
+
return this.engineRef.createWorkspace(workspace);
|
|
769
|
+
}
|
|
770
|
+
async updateWorkspace(workspace) {
|
|
771
|
+
return this.engineRef.updateWorkspace(workspace);
|
|
772
|
+
}
|
|
773
|
+
async deleteWorkspace(workspace) {
|
|
774
|
+
return this.engineRef.deleteWorkspace(workspace);
|
|
775
|
+
}
|
|
776
|
+
async getWorkspaces() {
|
|
777
|
+
return this.engineRef.getWorkspaces();
|
|
778
|
+
}
|
|
779
|
+
async getActiveWorkspace() {
|
|
780
|
+
return this.engineRef.getActiveWorkspace();
|
|
781
|
+
}
|
|
782
|
+
engineRef;
|
|
783
|
+
controlsRef;
|
|
784
|
+
splitButtonRef;
|
|
785
|
+
componentDidLoad() {
|
|
786
|
+
this.registerCustomSvgIcons();
|
|
787
|
+
this.listenForMobileKeyboard();
|
|
788
|
+
this.setOsSpecificCssVariables();
|
|
789
|
+
}
|
|
790
|
+
async checkIsReady() {
|
|
791
|
+
await customElements.whenDefined('kritzel-editor');
|
|
792
|
+
await customElements.whenDefined('kritzel-workspace-manager');
|
|
793
|
+
await customElements.whenDefined('kritzel-controls');
|
|
794
|
+
await customElements.whenDefined('kritzel-engine');
|
|
795
|
+
if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
this.isReady.emit(this.host);
|
|
799
|
+
}
|
|
800
|
+
onEngineReady(event) {
|
|
801
|
+
this.isEngineReady = true;
|
|
802
|
+
this.activeWorkspace = event.detail.activeWorkspace;
|
|
803
|
+
this.workspaces = event.detail.workspaces;
|
|
804
|
+
}
|
|
805
|
+
handleWorkspacesChange(event) {
|
|
806
|
+
this.workspaces = event.detail;
|
|
807
|
+
}
|
|
808
|
+
handleObjectsChange(event) {
|
|
809
|
+
this.objectsChange.emit(event.detail);
|
|
810
|
+
}
|
|
811
|
+
handleUndoStateChange(event) {
|
|
812
|
+
this.undoStateChange.emit(event.detail);
|
|
813
|
+
this.undoState = event.detail;
|
|
814
|
+
}
|
|
815
|
+
registerCustomSvgIcons() {
|
|
816
|
+
for (const [name, svg] of Object.entries(this.customSvgIcons)) {
|
|
817
|
+
KritzelIconRegistry.register(name, svg);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
listenForMobileKeyboard() {
|
|
821
|
+
KritzelKeyboardHelper.onKeyboardVisibleChanged(isOpen => {
|
|
822
|
+
this.isVirtualKeyboardOpen = isOpen;
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
setOsSpecificCssVariables() {
|
|
826
|
+
const os = KritzelDevicesHelper.detectOS();
|
|
827
|
+
switch (os) {
|
|
828
|
+
case 'iOS':
|
|
829
|
+
// iOS specific adjustments
|
|
830
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-top', '14px');
|
|
831
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-left', '14px');
|
|
832
|
+
this.host.style.setProperty('--kritzel-editor-controls-bottom', '14px');
|
|
833
|
+
this.host.style.setProperty('--kritzel-editor-controls-transition', 'cubic-bezier(0.25, 0.1, 0.25, 1.0)');
|
|
834
|
+
this.host.style.setProperty('--kritzel-editor-controls-transform', 'translateY(200%)');
|
|
835
|
+
this.host.style.setProperty('--kritzel-editor-controls-transition-duration', '0.25s');
|
|
836
|
+
break;
|
|
837
|
+
case 'Android':
|
|
838
|
+
// Android specific adjustments
|
|
839
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-top', '14px');
|
|
840
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-left', '14px');
|
|
841
|
+
this.host.style.setProperty('--kritzel-editor-controls-bottom', '24px');
|
|
842
|
+
break;
|
|
843
|
+
default:
|
|
844
|
+
// Default for Windows/Linux
|
|
845
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-top', '14px');
|
|
846
|
+
this.host.style.setProperty('--kritzel-editor-workspace-manager-left', '14px');
|
|
847
|
+
this.host.style.setProperty('--kritzel-editor-controls-bottom', '14px');
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
render() {
|
|
852
|
+
return (h(Host, { key: '87983fe2d4fcdbf226851190e7529f12e7b5fdbf' }, h("kritzel-workspace-manager", { key: 'a1e0f522a7075ef4e2b5eab47dab5dc77098b402', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-engine", { key: '18e78080712e53ead39ff07e43b7035e43a096f2', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, syncConfig: this.syncConfig, scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onObjectsChange: event => this.handleObjectsChange(event), onUndoStateChange: event => this.handleUndoStateChange(event) }), h("kritzel-controls", { key: '5ffaebbbeecbeebab050b3f990d027c6653a1940', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, onIsControlsReady: () => (this.isControlsReady = true) })));
|
|
853
|
+
}
|
|
854
|
+
static get watchers() { return {
|
|
855
|
+
"isEngineReady": ["onIsEngineReady"],
|
|
856
|
+
"isControlsReady": ["onIsControlsReady"],
|
|
857
|
+
"workspaces": ["onWorkspacesChange"]
|
|
858
|
+
}; }
|
|
859
|
+
};
|
|
860
|
+
KritzelEditor.style = kritzelEditorCss;
|
|
861
|
+
|
|
862
|
+
var lodash$1 = {exports: {}};
|
|
13
863
|
|
|
14
864
|
/**
|
|
15
865
|
* @license
|
|
@@ -19,15 +869,15 @@ var lodash$2 = {exports: {}};
|
|
|
19
869
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
20
870
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
21
871
|
*/
|
|
22
|
-
var lodash
|
|
872
|
+
var lodash = lodash$1.exports;
|
|
23
873
|
|
|
24
874
|
var hasRequiredLodash;
|
|
25
875
|
|
|
26
876
|
function requireLodash () {
|
|
27
|
-
if (hasRequiredLodash) return lodash$
|
|
877
|
+
if (hasRequiredLodash) return lodash$1.exports;
|
|
28
878
|
hasRequiredLodash = 1;
|
|
29
879
|
(function (module, exports) {
|
|
30
|
-
|
|
880
|
+
(function() {
|
|
31
881
|
|
|
32
882
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
33
883
|
var undefined$1;
|
|
@@ -457,7 +1307,7 @@ function requireLodash () {
|
|
|
457
1307
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|
458
1308
|
|
|
459
1309
|
/** Detect free variable `exports`. */
|
|
460
|
-
var freeExports =
|
|
1310
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
461
1311
|
|
|
462
1312
|
/** Detect free variable `module`. */
|
|
463
1313
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
@@ -4317,7 +5167,7 @@ function requireLodash () {
|
|
|
4317
5167
|
return symbolToString ? symbolToString.call(value) : '';
|
|
4318
5168
|
}
|
|
4319
5169
|
var result = (value + '');
|
|
4320
|
-
return (result == '0' && (1 / value) == -
|
|
5170
|
+
return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
|
|
4321
5171
|
}
|
|
4322
5172
|
|
|
4323
5173
|
/**
|
|
@@ -5472,7 +6322,7 @@ function requireLodash () {
|
|
|
5472
6322
|
bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
|
|
5473
6323
|
|
|
5474
6324
|
if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
|
|
5475
|
-
bitmask &=
|
|
6325
|
+
bitmask &= -4;
|
|
5476
6326
|
}
|
|
5477
6327
|
var newData = [
|
|
5478
6328
|
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
|
@@ -5575,7 +6425,7 @@ function requireLodash () {
|
|
|
5575
6425
|
}
|
|
5576
6426
|
var length = partials ? partials.length : 0;
|
|
5577
6427
|
if (!length) {
|
|
5578
|
-
bitmask &=
|
|
6428
|
+
bitmask &= -97;
|
|
5579
6429
|
partials = holders = undefined$1;
|
|
5580
6430
|
}
|
|
5581
6431
|
ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0);
|
|
@@ -5608,7 +6458,7 @@ function requireLodash () {
|
|
|
5608
6458
|
: nativeMax(newData[9] - length, 0);
|
|
5609
6459
|
|
|
5610
6460
|
if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
|
|
5611
|
-
bitmask &=
|
|
6461
|
+
bitmask &= -25;
|
|
5612
6462
|
}
|
|
5613
6463
|
if (!bitmask || bitmask == WRAP_BIND_FLAG) {
|
|
5614
6464
|
var result = createBind(func, bitmask, thisArg);
|
|
@@ -6840,7 +7690,7 @@ function requireLodash () {
|
|
|
6840
7690
|
return value;
|
|
6841
7691
|
}
|
|
6842
7692
|
var result = (value + '');
|
|
6843
|
-
return (result == '0' && (1 / value) == -
|
|
7693
|
+
return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
|
|
6844
7694
|
}
|
|
6845
7695
|
|
|
6846
7696
|
/**
|
|
@@ -12182,7 +13032,7 @@ function requireLodash () {
|
|
|
12182
13032
|
* // => false
|
|
12183
13033
|
*/
|
|
12184
13034
|
function isSafeInteger(value) {
|
|
12185
|
-
return isInteger(value) && value >= -
|
|
13035
|
+
return isInteger(value) && value >= -9007199254740991 && value <= MAX_SAFE_INTEGER;
|
|
12186
13036
|
}
|
|
12187
13037
|
|
|
12188
13038
|
/**
|
|
@@ -12449,7 +13299,7 @@ function requireLodash () {
|
|
|
12449
13299
|
return value === 0 ? value : 0;
|
|
12450
13300
|
}
|
|
12451
13301
|
value = toNumber(value);
|
|
12452
|
-
if (value === INFINITY || value === -
|
|
13302
|
+
if (value === INFINITY || value === -Infinity) {
|
|
12453
13303
|
var sign = (value < 0 ? -1 : 1);
|
|
12454
13304
|
return sign * MAX_INTEGER;
|
|
12455
13305
|
}
|
|
@@ -12618,7 +13468,7 @@ function requireLodash () {
|
|
|
12618
13468
|
*/
|
|
12619
13469
|
function toSafeInteger(value) {
|
|
12620
13470
|
return value
|
|
12621
|
-
? baseClamp(toInteger(value), -
|
|
13471
|
+
? baseClamp(toInteger(value), -9007199254740991, MAX_SAFE_INTEGER)
|
|
12622
13472
|
: (value === 0 ? value : 0);
|
|
12623
13473
|
}
|
|
12624
13474
|
|
|
@@ -17203,21 +18053,7 @@ function requireLodash () {
|
|
|
17203
18053
|
var _ = runInContext();
|
|
17204
18054
|
|
|
17205
18055
|
// Some AMD build optimizers, like r.js, check for condition patterns like:
|
|
17206
|
-
if (
|
|
17207
|
-
// Expose Lodash on the global object to prevent errors when Lodash is
|
|
17208
|
-
// loaded by a script tag in the presence of an AMD loader.
|
|
17209
|
-
// See http://requirejs.org/docs/errors.html#mismatch for more details.
|
|
17210
|
-
// Use `_.noConflict` to remove Lodash from the global object.
|
|
17211
|
-
root._ = _;
|
|
17212
|
-
|
|
17213
|
-
// Define as an anonymous module so, through path mapping, it can be
|
|
17214
|
-
// referenced as the "underscore" module.
|
|
17215
|
-
undefined$1(function() {
|
|
17216
|
-
return _;
|
|
17217
|
-
});
|
|
17218
|
-
}
|
|
17219
|
-
// Check for `exports` after `define` in case a build optimizer adds it.
|
|
17220
|
-
else if (freeModule) {
|
|
18056
|
+
if (freeModule) {
|
|
17221
18057
|
// Export for Node.js.
|
|
17222
18058
|
(freeModule.exports = _)._ = _;
|
|
17223
18059
|
// Export for CommonJS support.
|
|
@@ -17227,13 +18063,12 @@ function requireLodash () {
|
|
|
17227
18063
|
// Export to the global object.
|
|
17228
18064
|
root._ = _;
|
|
17229
18065
|
}
|
|
17230
|
-
}.call(lodash
|
|
17231
|
-
} (lodash$
|
|
17232
|
-
return lodash$
|
|
18066
|
+
}.call(lodash));
|
|
18067
|
+
} (lodash$1, lodash$1.exports));
|
|
18068
|
+
return lodash$1.exports;
|
|
17233
18069
|
}
|
|
17234
18070
|
|
|
17235
18071
|
var lodashExports = requireLodash();
|
|
17236
|
-
var lodash = /*@__PURE__*/getDefaultExportFromCjs(lodashExports);
|
|
17237
18072
|
|
|
17238
18073
|
class KritzelViewport {
|
|
17239
18074
|
_core;
|
|
@@ -17655,17 +18490,7 @@ class KritzelCustomElement extends KritzelBaseObject {
|
|
|
17655
18490
|
copiedObject.element = this.element.cloneNode(true);
|
|
17656
18491
|
return copiedObject;
|
|
17657
18492
|
}
|
|
17658
|
-
}
|
|
17659
|
-
|
|
17660
|
-
/**
|
|
17661
|
-
* @fileoverview entry point for your component library
|
|
17662
|
-
*
|
|
17663
|
-
* This is the entry point for your component library. Use this file to export utilities,
|
|
17664
|
-
* constants or data structure that accompany your components.
|
|
17665
|
-
*
|
|
17666
|
-
* DO NOT use this file to export your components. Instead, use the recommended approaches
|
|
17667
|
-
* to consume components of this package as outlined in the `README.md`.
|
|
17668
|
-
*/
|
|
18493
|
+
}
|
|
17669
18494
|
|
|
17670
18495
|
class KritzelReviver {
|
|
17671
18496
|
_core;
|
|
@@ -18110,12 +18935,9 @@ class KritzelObjectMap {
|
|
|
18110
18935
|
// We'll need to undo them all, then redo as a single transaction
|
|
18111
18936
|
const itemsToConsolidate = Math.min(this._temporaryItemsCount, stackLength);
|
|
18112
18937
|
if (itemsToConsolidate > 1) {
|
|
18113
|
-
// Store the current state before undoing
|
|
18114
|
-
const undoneItems = [];
|
|
18115
18938
|
// Undo all temporary items
|
|
18116
18939
|
for (let i = 0; i < itemsToConsolidate; i++) {
|
|
18117
18940
|
if (this._undoManager.canUndo()) {
|
|
18118
|
-
undoneItems.push(this._undoManager.undoStack[this._undoManager.undoStack.length - 1]);
|
|
18119
18941
|
this._undoManager.undo();
|
|
18120
18942
|
}
|
|
18121
18943
|
}
|
|
@@ -18129,10 +18951,6 @@ class KritzelObjectMap {
|
|
|
18129
18951
|
}
|
|
18130
18952
|
}, 'local');
|
|
18131
18953
|
}
|
|
18132
|
-
else if (itemsToConsolidate === 1) {
|
|
18133
|
-
// If only one temporary item, just change its origin to 'local'
|
|
18134
|
-
// This is implicit - next transaction will be separate
|
|
18135
|
-
}
|
|
18136
18954
|
this._temporaryItemsCount = 0;
|
|
18137
18955
|
}
|
|
18138
18956
|
/**
|
|
@@ -18973,12 +19791,12 @@ const KritzelEngine = class {
|
|
|
18973
19791
|
}
|
|
18974
19792
|
constructor(hostRef) {
|
|
18975
19793
|
registerInstance(this, hostRef);
|
|
18976
|
-
this.isEngineReady = createEvent(this, "isEngineReady"
|
|
18977
|
-
this.activeToolChange = createEvent(this, "activeToolChange"
|
|
18978
|
-
this.workspacesChange = createEvent(this, "workspacesChange"
|
|
18979
|
-
this.longpress = createEvent(this, "longpress"
|
|
18980
|
-
this.objectsChange = createEvent(this, "objectsChange"
|
|
18981
|
-
this.undoStateChange = createEvent(this, "undoStateChange"
|
|
19794
|
+
this.isEngineReady = createEvent(this, "isEngineReady");
|
|
19795
|
+
this.activeToolChange = createEvent(this, "activeToolChange");
|
|
19796
|
+
this.workspacesChange = createEvent(this, "workspacesChange");
|
|
19797
|
+
this.longpress = createEvent(this, "longpress");
|
|
19798
|
+
this.objectsChange = createEvent(this, "objectsChange");
|
|
19799
|
+
this.undoStateChange = createEvent(this, "undoStateChange");
|
|
18982
19800
|
this.core = new KritzelCore(this);
|
|
18983
19801
|
}
|
|
18984
19802
|
disconnectedCallback() {
|
|
@@ -19066,7 +19884,7 @@ const KritzelEngine = class {
|
|
|
19066
19884
|
else {
|
|
19067
19885
|
console.log(`[Performance] Getting visible objects took ${elapsed.toFixed(2)}ms (${visibleObjects.length} objects visible) [${this.visibleObjectsTimings.length}/25 samples]`);
|
|
19068
19886
|
}
|
|
19069
|
-
return (h(Host, { key: '
|
|
19887
|
+
return (h(Host, { key: 'f59e309c44cf9d056c17df5bae809227b0da6014' }, this.core.store.state.debugInfo.showViewportInfo && (h("div", { key: '2e22b7eb72f8eea9b7aafb5b54d82039931fb1dd', class: "debug-panel" }, h("div", { key: 'd003aff63c05fa5889ae73448c603e4461bdcb68' }, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", { key: '62c6c30e81f284904e159b8abbc643527cd760ee' }, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", { key: 'e6e80882c725104d52fab8da9a8b1f9e52c28202' }, "TranslateX: ", this.core.store.state?.translateX), h("div", { key: 'c88da5777f20f6b93f22cd78d624bd3673fa3fbd' }, "TranslateY: ", this.core.store.state?.translateY), h("div", { key: '19d293c9e537961dc0dd47ff138608eccc84b9c0' }, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", { key: '747c1d0b46a918aafa8da3bff094d08b321ab638' }, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", { key: 'a0a89524a87a8a5a438077c77c53c63bfbc02358' }, "PointerCount: ", this.core.store.state.pointers.size), h("div", { key: 'b4b385704c802a78cd959998cff0bf61dad6a54c' }, "Scale: ", this.core.store.state?.scale), h("div", { key: '8933716cedc4d45092e6810adb8fbad1a1c80af3' }, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", { key: '407c5a3ca4b73e13f2f11e36b20792231e512e43' }, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", { key: '8c81eccee3d1b13ded8cb3e47a275df585cfb276' }, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", { key: '8af988839b1712024a692d554021c9a6b5c95ea1' }, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", { key: '6b29e356911a7f6a8b7ec349323974c0160c99a9' }, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", { key: 'd47293ba022498e1e91d3b44d668bb5b09120cc0' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '135e1930f98d56018367fb2653a4564b4b01ea5a' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: 'bccac5527134ed4eb2308c96a056bad7ad47b479' }, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '8a18e170e35f1a7cf889b6c9fcb44a2ea9b4b73e' }, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '88e357566ef307d1c274a75994de95f1682497b4' }, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '48cefe71eb0c4676f9a708a6857500b68f5e5e6c' }, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", { key: '0646a93553cb9ca21f27c876314104efec7f7b4d' }, "PointerX: ", this.core.store.state?.pointerX), h("div", { key: '18cf01af3a33b87f26215921f8d67cae13743f68' }, "PointerY: ", this.core.store.state?.pointerY), h("div", { key: '3a250d4b06489eeea5a8765675bab0f1bad358ce' }, "SelectedObjects: ", this.core.store.selectionGroup?.objects.length || 0), h("div", { key: 'c5f9bc07eb57de8de922efcf2646ace75fb48a7e' }, "ViewportCenter: (", viewportCenterX.toFixed(2), ", ", viewportCenterY.toFixed(2), ")"))), h("div", { key: '25d849d5d92785d0545fcd54d0d94bbf5713b6b4', id: "origin", class: "origin", style: {
|
|
19070
19888
|
transform: `matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`,
|
|
19071
19889
|
} }, visibleObjects?.map(object => {
|
|
19072
19890
|
return (h("div", { key: object.id, style: {
|
|
@@ -19193,7 +20011,7 @@ const KritzelEngine = class {
|
|
|
19193
20011
|
cursor: 'grab',
|
|
19194
20012
|
paintOrder: 'fill',
|
|
19195
20013
|
} }))))));
|
|
19196
|
-
})), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '
|
|
20014
|
+
})), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: 'f4b97e66c853c2f81ca64e9c7726d83259aa01ea', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.selectionGroup?.objects || [], style: {
|
|
19197
20015
|
position: 'fixed',
|
|
19198
20016
|
left: `${this.core.store.state.contextMenuX}px`,
|
|
19199
20017
|
top: `${this.core.store.state.contextMenuY}px`,
|
|
@@ -19204,7 +20022,7 @@ const KritzelEngine = class {
|
|
|
19204
20022
|
y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
|
|
19205
20023
|
}, this.core.store.selectionGroup?.objects);
|
|
19206
20024
|
this.hideContextMenu();
|
|
19207
|
-
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
20025
|
+
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: 'f277db501d71eead62de569c1955acf0c9a4f386', core: this.core })));
|
|
19208
20026
|
}
|
|
19209
20027
|
static get watchers() { return {
|
|
19210
20028
|
"workspace": ["onWorkspaceChange"],
|
|
@@ -19214,5 +20032,920 @@ const KritzelEngine = class {
|
|
|
19214
20032
|
};
|
|
19215
20033
|
KritzelEngine.style = kritzelEngineCss;
|
|
19216
20034
|
|
|
19217
|
-
|
|
19218
|
-
|
|
20035
|
+
const kritzelFontCss = ":host{display:block}.font-preview{color:var(--kritzel-font-size-text-color, #333333);line-height:1;text-align:center;font-weight:bold}";
|
|
20036
|
+
|
|
20037
|
+
const KritzelFont = class {
|
|
20038
|
+
constructor(hostRef) {
|
|
20039
|
+
registerInstance(this, hostRef);
|
|
20040
|
+
}
|
|
20041
|
+
fontFamily = 'Arial, sans-serif';
|
|
20042
|
+
size = 24;
|
|
20043
|
+
color = '#000000';
|
|
20044
|
+
render() {
|
|
20045
|
+
return (h(Host, { key: '0a6f1d1326e9dde84a4122d79f75dc1c75ffe0fb' }, h("div", { key: '88a342d01c4150cd4fc5dacca23f7b9904edca52', class: "font-preview", style: {
|
|
20046
|
+
fontFamily: this.fontFamily,
|
|
20047
|
+
fontSize: `${this.size}px`,
|
|
20048
|
+
color: this.color
|
|
20049
|
+
} }, "A")));
|
|
20050
|
+
}
|
|
20051
|
+
};
|
|
20052
|
+
KritzelFont.style = kritzelFontCss;
|
|
20053
|
+
|
|
20054
|
+
const kritzelFontFamilyCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.font-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:pointer;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}.font-style-button.italic-text{font-style:italic}";
|
|
20055
|
+
|
|
20056
|
+
const KritzelFontFamily = class {
|
|
20057
|
+
constructor(hostRef) {
|
|
20058
|
+
registerInstance(this, hostRef);
|
|
20059
|
+
this.fontFamilyChange = createEvent(this, "fontFamilyChange");
|
|
20060
|
+
}
|
|
20061
|
+
fontOptions = [
|
|
20062
|
+
{ value: 'arial', label: 'Arial' },
|
|
20063
|
+
{ value: 'verdana', label: 'Verdana' },
|
|
20064
|
+
{ value: 'helvetica', label: 'Helvetica' },
|
|
20065
|
+
{ value: 'tahoma', label: 'Tahoma' },
|
|
20066
|
+
{ value: 'trebuchet ms', label: 'Trebuchet MS' },
|
|
20067
|
+
{ value: 'times new roman', label: 'Times New Roman' },
|
|
20068
|
+
{ value: 'georgia', label: 'Georgia' },
|
|
20069
|
+
{ value: 'garamond', label: 'Garamond' },
|
|
20070
|
+
{ value: 'courier new', label: 'Courier New' },
|
|
20071
|
+
{ value: 'brush script mt', label: 'Brush Script MT' },
|
|
20072
|
+
];
|
|
20073
|
+
selectedFontFamily;
|
|
20074
|
+
fontFamilyChange;
|
|
20075
|
+
componentWillLoad() {
|
|
20076
|
+
if (this.fontOptions && this.fontOptions.length > 0) {
|
|
20077
|
+
const isValidCurrentFont = this.fontOptions.some(opt => opt.value === this.selectedFontFamily);
|
|
20078
|
+
if (!this.selectedFontFamily || !isValidCurrentFont) {
|
|
20079
|
+
this.selectedFontFamily = this.fontOptions[0].value;
|
|
20080
|
+
}
|
|
20081
|
+
}
|
|
20082
|
+
}
|
|
20083
|
+
handleDropdownValueChange = (event) => {
|
|
20084
|
+
this.fontFamilyChange.emit(event.detail);
|
|
20085
|
+
};
|
|
20086
|
+
render() {
|
|
20087
|
+
const dropdownOptions = this.fontOptions.map(option => ({
|
|
20088
|
+
value: option.value,
|
|
20089
|
+
label: option.label,
|
|
20090
|
+
style: { fontFamily: option.value },
|
|
20091
|
+
}));
|
|
20092
|
+
return (h(Host, { key: '27d14ddb4a57b9cd7b936047b6ea6a9251a1ab27' }, h("kritzel-dropdown", { key: '20ea042c9a907dc1ac5e16a589a8856f87389e36', options: dropdownOptions, value: this.selectedFontFamily, onValueChanged: this.handleDropdownValueChange, selectStyles: { fontFamily: this.selectedFontFamily } }, h("button", { key: 'f63fed16477a327aadaeb54feefe35df1780e37d', class: "font-style-button", slot: "suffix" }, "B"), h("button", { key: '13b3089606c2e83b256ed2cec6513a9911016754', class: "font-style-button italic-text", slot: "suffix" }, "I"))));
|
|
20093
|
+
}
|
|
20094
|
+
};
|
|
20095
|
+
KritzelFontFamily.style = kritzelFontFamilyCss;
|
|
20096
|
+
|
|
20097
|
+
const kritzelFontSizeCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:4px;cursor:pointer;border:2px solid transparent;box-sizing:border-box;border-radius:50%}.size-container:hover{background-color:var(--kritzel-font-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-font-size-selected-background-color, #e0e0e0)}";
|
|
20098
|
+
|
|
20099
|
+
const KritzelFontSize = class {
|
|
20100
|
+
constructor(hostRef) {
|
|
20101
|
+
registerInstance(this, hostRef);
|
|
20102
|
+
this.sizeChange = createEvent(this, "sizeChange");
|
|
20103
|
+
}
|
|
20104
|
+
sizes = [8, 10, 12, 16, 20, 24];
|
|
20105
|
+
selectedSize = null;
|
|
20106
|
+
fontFamily = 'Arial';
|
|
20107
|
+
sizeChange;
|
|
20108
|
+
handleSizeClick(size) {
|
|
20109
|
+
this.selectedSize = size;
|
|
20110
|
+
this.sizeChange.emit(size);
|
|
20111
|
+
}
|
|
20112
|
+
render() {
|
|
20113
|
+
return (h(Host, { key: '9f3d851d443352f7437116cf91eff8d8de41e322' }, this.sizes.map(size => (h("div", { class: {
|
|
20114
|
+
'size-container': true,
|
|
20115
|
+
'selected': this.selectedSize === size,
|
|
20116
|
+
}, onClick: () => this.handleSizeClick(size) }, h("kritzel-font", { fontFamily: this.fontFamily, size: size }))))));
|
|
20117
|
+
}
|
|
20118
|
+
};
|
|
20119
|
+
KritzelFontSize.style = kritzelFontSizeCss;
|
|
20120
|
+
|
|
20121
|
+
const kritzelIconCss = ":host{display:inline-flex;justify-content:center;align-items:center;color:var(--kritzel-icon-color, inherited)}span{display:flex;align-items:center;width:100%;height:100%;}span>svg{width:100%;height:100%}";
|
|
20122
|
+
|
|
20123
|
+
const KritzelIcon = class {
|
|
20124
|
+
constructor(hostRef) {
|
|
20125
|
+
registerInstance(this, hostRef);
|
|
20126
|
+
}
|
|
20127
|
+
name;
|
|
20128
|
+
label;
|
|
20129
|
+
size = 24;
|
|
20130
|
+
render() {
|
|
20131
|
+
const svgContent = KritzelIconRegistry.get(this.name);
|
|
20132
|
+
if (!svgContent) {
|
|
20133
|
+
console.error(`[kritzel-icon] Icon "${this.name}" not found in registry.`);
|
|
20134
|
+
return h("span", { class: "error-icon", "aria-label": `Error: Icon ${this.name} not found` }, "?");
|
|
20135
|
+
}
|
|
20136
|
+
const styles = {
|
|
20137
|
+
width: `${this.size}px`,
|
|
20138
|
+
height: `${this.size}px`,
|
|
20139
|
+
};
|
|
20140
|
+
return (h(Host, { style: styles }, h("span", { "aria-hidden": !this.label, role: this.label ? 'img' : undefined, "aria-label": this.label, innerHTML: svgContent })));
|
|
20141
|
+
}
|
|
20142
|
+
};
|
|
20143
|
+
KritzelIcon.style = kritzelIconCss;
|
|
20144
|
+
|
|
20145
|
+
const kritzelMenuCss = ":host{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-menu-background-color, #ffffff);width:var(--kritzel-menu-width, 200px);padding:var(--kritzel-menu-padding, 8px);border-radius:var(--kritzel-menu-border-radius, 12px);box-shadow:var(--kritzel-menu-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-menu-border, 1px solid #ebebeb);z-index:2;gap:var(--kritzel-menu-gap, 4px);overflow-y:auto;scrollbar-color:#ebebeb transparent;scrollbar-width:thin;max-height:300px}.has-open-child-overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:3}";
|
|
20146
|
+
|
|
20147
|
+
const KritzelMenu = class {
|
|
20148
|
+
constructor(hostRef) {
|
|
20149
|
+
registerInstance(this, hostRef);
|
|
20150
|
+
this.itemSelect = createEvent(this, "itemSelect");
|
|
20151
|
+
this.itemSave = createEvent(this, "itemSave");
|
|
20152
|
+
this.itemCancel = createEvent(this, "itemCancel");
|
|
20153
|
+
this.itemToggleChildMenu = createEvent(this, "itemToggleChildMenu");
|
|
20154
|
+
this.itemCloseChildMenu = createEvent(this, "itemCloseChildMenu");
|
|
20155
|
+
this.close = createEvent(this, "close");
|
|
20156
|
+
}
|
|
20157
|
+
get host() { return getElement(this); }
|
|
20158
|
+
items;
|
|
20159
|
+
parent = null;
|
|
20160
|
+
itemSelect;
|
|
20161
|
+
itemSave;
|
|
20162
|
+
itemCancel;
|
|
20163
|
+
itemToggleChildMenu;
|
|
20164
|
+
itemCloseChildMenu;
|
|
20165
|
+
close;
|
|
20166
|
+
selectedIndex = null;
|
|
20167
|
+
async setScrollTop(scrollTop) {
|
|
20168
|
+
this.host.scrollTop = scrollTop;
|
|
20169
|
+
this.host.scrollTo({ top: scrollTop, behavior: 'auto' });
|
|
20170
|
+
}
|
|
20171
|
+
async setFocus() {
|
|
20172
|
+
const firstItem = this.host.shadowRoot.querySelector('kritzel-menu-item');
|
|
20173
|
+
if (firstItem) {
|
|
20174
|
+
firstItem.focus();
|
|
20175
|
+
}
|
|
20176
|
+
}
|
|
20177
|
+
get openChildMenuItem() {
|
|
20178
|
+
return this.items.find(item => item.isChildMenuOpen);
|
|
20179
|
+
}
|
|
20180
|
+
get editingMenuItem() {
|
|
20181
|
+
return this.items.find(item => item.isEditing);
|
|
20182
|
+
}
|
|
20183
|
+
onOverlayClick = (event) => {
|
|
20184
|
+
event.stopPropagation();
|
|
20185
|
+
this.itemCloseChildMenu.emit(this.openChildMenuItem);
|
|
20186
|
+
};
|
|
20187
|
+
handleItemSelect = (event) => {
|
|
20188
|
+
event.stopPropagation();
|
|
20189
|
+
this.itemSelect.emit(event.detail);
|
|
20190
|
+
};
|
|
20191
|
+
handleSave = (event) => {
|
|
20192
|
+
event.stopPropagation();
|
|
20193
|
+
this.itemSave.emit(event.detail);
|
|
20194
|
+
};
|
|
20195
|
+
handleCancel = (event) => {
|
|
20196
|
+
event.stopPropagation();
|
|
20197
|
+
this.itemCancel.emit(event.detail);
|
|
20198
|
+
};
|
|
20199
|
+
handleToggleChildMenu = (event) => {
|
|
20200
|
+
event.stopPropagation();
|
|
20201
|
+
this.itemToggleChildMenu.emit(event.detail);
|
|
20202
|
+
};
|
|
20203
|
+
handleCloseChildMenu = (event) => {
|
|
20204
|
+
event.stopPropagation();
|
|
20205
|
+
this.itemCloseChildMenu.emit(event.detail);
|
|
20206
|
+
};
|
|
20207
|
+
render() {
|
|
20208
|
+
return (h(Host, { key: 'be122cb0ecff3227d9e69997de76a73940a61860', tabIndex: 0, onClick: e => e.stopPropagation() }, this.openChildMenuItem && h("div", { key: 'ae10bec61e5c5e1a29b444cb7378f15c6692f3b6', class: "has-open-child-overlay", onClick: this.onOverlayClick }), this.items.map(item => (h("kritzel-menu-item", { key: item.id, item: item, parent: this.parent, style: { pointerEvents: this.editingMenuItem && !item.isEditing ? 'none' : 'auto' }, onItemSelect: this.handleItemSelect, onItemSave: this.handleSave, onItemCancel: this.handleCancel, onItemToggleChildMenu: this.handleToggleChildMenu, onItemCloseChildMenu: this.handleCloseChildMenu })))));
|
|
20209
|
+
}
|
|
20210
|
+
};
|
|
20211
|
+
KritzelMenu.style = kritzelMenuCss;
|
|
20212
|
+
|
|
20213
|
+
const kritzelMenuItemCss = ":host{position:relative;display:flex;align-items:center;justify-content:space-between;width:100%;padding:var(--kritzel-menu-item-padding, 8px);box-sizing:border-box;gap:16px;height:var(--kritzel-menu-item-height, 40px);min-height:var(--kritzel-menu-item-min-height, 40px);font-family:sans-serif;font-size:var(--kritzel-menu-item-font-size, 14px);color:var(--kritzel-menu-item-color, #333333);border-radius:var(--kritzel-menu-item-border-radius, 12px);cursor:default}:host(:hover) .menu-item-overlay,:host(:focus-within) .menu-item-overlay{background-color:var(--kritzel-menu-item-overlay-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff);color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected.editing){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}:host(.selected) .edit-input{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-selected-color, #ffffff)}kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-color, #333333)}:host(.selected) .edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, rgba(255, 255, 255, 0.16))}:host(.editing){background-color:var(--kritzel-menu-item-editing-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.disabled){opacity:0.5;pointer-events:none !important}:host(.child-open){background-color:var(--kritzel-menu-item-child-open-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.child-open.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}.menu-item-overlay{position:absolute;inset:0;background-color:transparent;z-index:0;pointer-events:none;border-radius:var(--kritzel-menu-item-border-radius, 12px)}.menu-item-content{display:flex;align-items:center;gap:8px;position:relative;z-index:1;height:100%}.left{justify-content:flex-start;flex:1;min-width:0}.left>div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.right{justify-content:flex-end}.edit-input{flex:1;height:var(--kritzel-menu-item-input-height, 24px);padding:0;background-color:transparent;border-radius:0;border:none;border-bottom:1px solid var(--kritzel-menu-item-input-border, #ccc);font-size:var(--kritzel-context-menu-item-font-size, 14px);width:100%;min-width:0;box-sizing:border-box;outline:none}.edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, #007bff);color:var(--kritzel-menu-item-input-selection-text-color, #ffffff)}.action-button{padding:4px;border-radius:8px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;background-color:transparent;background:transparent;-webkit-tap-highlight-color:transparent}.action-button:hover,.action-button:focus{background-color:var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.action-button.disabled{pointer-events:none;opacity:0.5}";
|
|
20214
|
+
|
|
20215
|
+
const KritzelMenuItem = class {
|
|
20216
|
+
constructor(hostRef) {
|
|
20217
|
+
registerInstance(this, hostRef);
|
|
20218
|
+
this.itemSelect = createEvent(this, "itemSelect");
|
|
20219
|
+
this.itemSave = createEvent(this, "itemSave");
|
|
20220
|
+
this.itemCancel = createEvent(this, "itemCancel");
|
|
20221
|
+
this.itemToggleChildMenu = createEvent(this, "itemToggleChildMenu");
|
|
20222
|
+
this.itemCloseChildMenu = createEvent(this, "itemCloseChildMenu");
|
|
20223
|
+
}
|
|
20224
|
+
get host() { return getElement(this); }
|
|
20225
|
+
item;
|
|
20226
|
+
onItemChange(newValue, oldValue) {
|
|
20227
|
+
if (newValue !== oldValue) {
|
|
20228
|
+
this.isDirty = false;
|
|
20229
|
+
}
|
|
20230
|
+
}
|
|
20231
|
+
parent = null;
|
|
20232
|
+
itemSelect;
|
|
20233
|
+
itemSave;
|
|
20234
|
+
itemCancel;
|
|
20235
|
+
itemToggleChildMenu;
|
|
20236
|
+
itemCloseChildMenu;
|
|
20237
|
+
isDirty = false;
|
|
20238
|
+
inputRef;
|
|
20239
|
+
focusInput() {
|
|
20240
|
+
if (this.item.isEditing && this.inputRef && !this.isDirty) {
|
|
20241
|
+
this.inputRef.focus();
|
|
20242
|
+
if (KritzelDevicesHelper.isIOS()) {
|
|
20243
|
+
const length = this.inputRef.value.length;
|
|
20244
|
+
this.inputRef.setSelectionRange(length, length);
|
|
20245
|
+
}
|
|
20246
|
+
else {
|
|
20247
|
+
this.inputRef.select();
|
|
20248
|
+
}
|
|
20249
|
+
}
|
|
20250
|
+
}
|
|
20251
|
+
componentDidLoad() {
|
|
20252
|
+
this.setDeviceSpecificStyles();
|
|
20253
|
+
this.focusInput();
|
|
20254
|
+
}
|
|
20255
|
+
componentDidUpdate() {
|
|
20256
|
+
this.focusInput();
|
|
20257
|
+
}
|
|
20258
|
+
setDeviceSpecificStyles = () => {
|
|
20259
|
+
const isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
20260
|
+
if (isTouchDevice) {
|
|
20261
|
+
this.host.style.setProperty('--kritzel-menu-item-overlay-background-color', 'transparent');
|
|
20262
|
+
this.host.style.setProperty('--kritzel-menu-item-button-hover-background-color', 'transparent');
|
|
20263
|
+
}
|
|
20264
|
+
};
|
|
20265
|
+
handleItemSelect = (event) => {
|
|
20266
|
+
event.stopPropagation();
|
|
20267
|
+
this.itemSelect.emit({ item: this.item, parent: this.parent });
|
|
20268
|
+
};
|
|
20269
|
+
handleInputChange = (event) => {
|
|
20270
|
+
event.stopPropagation();
|
|
20271
|
+
const target = event.target;
|
|
20272
|
+
this.item.label = target.value;
|
|
20273
|
+
this.isDirty = true;
|
|
20274
|
+
};
|
|
20275
|
+
handleSave = (event) => {
|
|
20276
|
+
event.stopPropagation();
|
|
20277
|
+
this.host.focus();
|
|
20278
|
+
this.itemSave.emit(this.item);
|
|
20279
|
+
};
|
|
20280
|
+
handleCancel = (event) => {
|
|
20281
|
+
event.stopPropagation();
|
|
20282
|
+
this.host.focus();
|
|
20283
|
+
this.itemCancel.emit(this.item);
|
|
20284
|
+
};
|
|
20285
|
+
handleMenuToggle = (event) => {
|
|
20286
|
+
event.stopPropagation();
|
|
20287
|
+
this.itemToggleChildMenu.emit({ item: this.item, childMenuAnchor: event.target });
|
|
20288
|
+
};
|
|
20289
|
+
handleMenuClose = () => {
|
|
20290
|
+
this.itemCloseChildMenu.emit(this.item);
|
|
20291
|
+
};
|
|
20292
|
+
renderViewMode() {
|
|
20293
|
+
return [
|
|
20294
|
+
h("div", { class: "menu-item-content left" }, h("div", null, this.item.label)),
|
|
20295
|
+
h("div", { class: "menu-item-content right" }, this.item.children &&
|
|
20296
|
+
this.item.children.length > 0 && [
|
|
20297
|
+
h("button", { id: "child-menu-toggle", class: "action-button", onClick: this.handleMenuToggle, disabled: this.item.isDisabled }, h("kritzel-icon", { name: "ellipsis-vertical", size: 16 })),
|
|
20298
|
+
h("kritzel-portal", { anchor: this.item.childMenuAnchor, offsetY: 4, onClose: this.handleMenuClose }, h("kritzel-menu", { items: this.item.children, parent: this.item, onItemSelect: event => this.itemSelect.emit(event.detail), onItemSave: event => this.itemSave.emit(event.detail), onItemCancel: event => this.itemCancel.emit(event.detail), onClose: this.handleMenuClose })),
|
|
20299
|
+
]),
|
|
20300
|
+
];
|
|
20301
|
+
}
|
|
20302
|
+
renderEditMode() {
|
|
20303
|
+
return [
|
|
20304
|
+
h("div", { class: "menu-item-content left" }, h("input", { ref: el => (this.inputRef = el), type: "text", class: "edit-input", value: this.item.label, onInput: this.handleInputChange })),
|
|
20305
|
+
h("div", { class: "menu-item-content right" }, h("div", { tabIndex: 0, class: "action-button", onClick: this.handleCancel }, h("kritzel-icon", { name: "x", size: 16 })), h("div", { tabIndex: !this.isDirty && !this.item.isNewItem ? -1 : 0, class: { 'action-button': true, 'disabled': !this.isDirty && !this.item.isNewItem }, onClick: this.handleSave }, h("kritzel-icon", { name: "check", size: 16 }))),
|
|
20306
|
+
];
|
|
20307
|
+
}
|
|
20308
|
+
render() {
|
|
20309
|
+
return (h(Host, { key: '9df3acdaff753e3ed910f848c98e8ad73e2b5f5c', tabIndex: this.item.isDisabled ? -1 : 0, class: {
|
|
20310
|
+
'selected': this.item.isSelected,
|
|
20311
|
+
'editing': this.item.isEditing,
|
|
20312
|
+
'disabled': this.item.isDisabled,
|
|
20313
|
+
'child-open': this.item.isChildMenuOpen,
|
|
20314
|
+
}, onClick: this.handleItemSelect }, h("div", { key: 'bb73e5c0c3dd87efabcaa0b53d20c7c477b34aa1', class: "menu-item-overlay" }), this.item.isEditing ? this.renderEditMode() : this.renderViewMode()));
|
|
20315
|
+
}
|
|
20316
|
+
static get watchers() { return {
|
|
20317
|
+
"item": ["onItemChange"]
|
|
20318
|
+
}; }
|
|
20319
|
+
};
|
|
20320
|
+
KritzelMenuItem.style = kritzelMenuItemCss;
|
|
20321
|
+
|
|
20322
|
+
class KritzelHTMLHelper {
|
|
20323
|
+
static getNumericValueFromStyle(element, property) {
|
|
20324
|
+
const value = window.getComputedStyle(element).getPropertyValue(property);
|
|
20325
|
+
return parseFloat(value) || 0;
|
|
20326
|
+
}
|
|
20327
|
+
static getScrollableParent(element) {
|
|
20328
|
+
if (!element) {
|
|
20329
|
+
return window;
|
|
20330
|
+
}
|
|
20331
|
+
const parent = element.parentNode?.host ?? element.parentElement;
|
|
20332
|
+
if (!parent || parent.tagName === 'BODY') {
|
|
20333
|
+
return window;
|
|
20334
|
+
}
|
|
20335
|
+
const style = window.getComputedStyle(parent);
|
|
20336
|
+
if (style.overflow === 'auto' || style.overflowY === 'auto' || style.overflow === 'scroll' || style.overflowY === 'scroll') {
|
|
20337
|
+
return parent;
|
|
20338
|
+
}
|
|
20339
|
+
return this.getScrollableParent(parent);
|
|
20340
|
+
}
|
|
20341
|
+
static isElementInViewport(element) {
|
|
20342
|
+
if (!element) {
|
|
20343
|
+
return false;
|
|
20344
|
+
}
|
|
20345
|
+
const scrollableParent = this.getScrollableParent(element);
|
|
20346
|
+
const rect = element.getBoundingClientRect();
|
|
20347
|
+
if (scrollableParent === window) {
|
|
20348
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
20349
|
+
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
20350
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= viewportHeight && rect.right <= viewportWidth;
|
|
20351
|
+
}
|
|
20352
|
+
const parentRect = scrollableParent.getBoundingClientRect();
|
|
20353
|
+
return rect.top >= parentRect.top && rect.left >= parentRect.left && rect.bottom <= parentRect.bottom && rect.right <= parentRect.right;
|
|
20354
|
+
}
|
|
20355
|
+
static getFocusableElements(root) {
|
|
20356
|
+
if (!root)
|
|
20357
|
+
return [];
|
|
20358
|
+
const focusableElements = [];
|
|
20359
|
+
const focusableSelector = 'a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details, [tabindex]:not([tabindex="-1"])';
|
|
20360
|
+
const isVisible = (el) => {
|
|
20361
|
+
return el.offsetParent !== null;
|
|
20362
|
+
};
|
|
20363
|
+
const find = (element) => {
|
|
20364
|
+
// Check if the element itself is focusable
|
|
20365
|
+
if (element instanceof HTMLElement && element.matches(focusableSelector) && !element.hasAttribute('disabled') && isVisible(element)) {
|
|
20366
|
+
focusableElements.push(element);
|
|
20367
|
+
}
|
|
20368
|
+
// Traverse shadow DOM
|
|
20369
|
+
if (element.shadowRoot) {
|
|
20370
|
+
Array.from(element.shadowRoot.children).forEach(find);
|
|
20371
|
+
}
|
|
20372
|
+
// Traverse slotted content
|
|
20373
|
+
if (element.tagName === 'SLOT') {
|
|
20374
|
+
element.assignedElements({ flatten: true }).forEach(find);
|
|
20375
|
+
}
|
|
20376
|
+
// Traverse light DOM children if there is no shadow root
|
|
20377
|
+
if (!element.shadowRoot) {
|
|
20378
|
+
Array.from(element.children).forEach(find);
|
|
20379
|
+
}
|
|
20380
|
+
};
|
|
20381
|
+
find(root);
|
|
20382
|
+
return focusableElements;
|
|
20383
|
+
}
|
|
20384
|
+
}
|
|
20385
|
+
|
|
20386
|
+
const KritzelPortal = class {
|
|
20387
|
+
constructor(hostRef) {
|
|
20388
|
+
registerInstance(this, hostRef);
|
|
20389
|
+
this.close = createEvent(this, "close");
|
|
20390
|
+
}
|
|
20391
|
+
get host() { return getElement(this); }
|
|
20392
|
+
anchor;
|
|
20393
|
+
anchorChanged(newValue) {
|
|
20394
|
+
if (newValue) {
|
|
20395
|
+
this.openPortal();
|
|
20396
|
+
this.calculatePosition();
|
|
20397
|
+
if (this.autoFocus) {
|
|
20398
|
+
this.focusFirstElement();
|
|
20399
|
+
}
|
|
20400
|
+
}
|
|
20401
|
+
else {
|
|
20402
|
+
this.closePortal();
|
|
20403
|
+
}
|
|
20404
|
+
}
|
|
20405
|
+
offsetX;
|
|
20406
|
+
offsetY;
|
|
20407
|
+
autoFocus = true;
|
|
20408
|
+
close;
|
|
20409
|
+
handleOutsideClick(event) {
|
|
20410
|
+
event.stopPropagation();
|
|
20411
|
+
const isLastPortal = this.lastAddedPortal === this.portal;
|
|
20412
|
+
if (!isLastPortal)
|
|
20413
|
+
return;
|
|
20414
|
+
const target = event.target;
|
|
20415
|
+
if (!this.host.contains(target)) {
|
|
20416
|
+
this.close.emit();
|
|
20417
|
+
this.closePortal();
|
|
20418
|
+
}
|
|
20419
|
+
}
|
|
20420
|
+
handleKeyDown(event) {
|
|
20421
|
+
event.stopPropagation();
|
|
20422
|
+
const isLastPortal = this.lastAddedPortal === this.portal;
|
|
20423
|
+
if (!isLastPortal)
|
|
20424
|
+
return;
|
|
20425
|
+
if (event.key === 'Escape') {
|
|
20426
|
+
this.anchor.focus();
|
|
20427
|
+
this.close.emit();
|
|
20428
|
+
this.closePortal();
|
|
20429
|
+
}
|
|
20430
|
+
if (event.key === 'Tab') {
|
|
20431
|
+
this.trapFocus(event);
|
|
20432
|
+
}
|
|
20433
|
+
if (event.key === 'Enter') {
|
|
20434
|
+
const activeElement = this.getDeepActiveElement();
|
|
20435
|
+
if (activeElement?.click) {
|
|
20436
|
+
event.preventDefault();
|
|
20437
|
+
activeElement.click();
|
|
20438
|
+
}
|
|
20439
|
+
}
|
|
20440
|
+
}
|
|
20441
|
+
handleResize() {
|
|
20442
|
+
this.calculatePosition();
|
|
20443
|
+
}
|
|
20444
|
+
handleWindowScroll() {
|
|
20445
|
+
const isInViewport = KritzelHTMLHelper.isElementInViewport(this.anchor);
|
|
20446
|
+
if (!isInViewport) {
|
|
20447
|
+
this.anchor?.blur();
|
|
20448
|
+
this.closePortal();
|
|
20449
|
+
return;
|
|
20450
|
+
}
|
|
20451
|
+
this.calculatePosition();
|
|
20452
|
+
}
|
|
20453
|
+
portal;
|
|
20454
|
+
id = `portal-${ObjectHelper.generateUUID()}`;
|
|
20455
|
+
defaultOffset = 0;
|
|
20456
|
+
minLeft = 0;
|
|
20457
|
+
focusFirstElement() {
|
|
20458
|
+
requestAnimationFrame(() => {
|
|
20459
|
+
this.firstFocusableElement?.focus?.();
|
|
20460
|
+
});
|
|
20461
|
+
}
|
|
20462
|
+
getDeepActiveElement() {
|
|
20463
|
+
let activeEl = document.activeElement;
|
|
20464
|
+
while (activeEl?.shadowRoot?.activeElement) {
|
|
20465
|
+
activeEl = activeEl.shadowRoot.activeElement;
|
|
20466
|
+
}
|
|
20467
|
+
return activeEl;
|
|
20468
|
+
}
|
|
20469
|
+
trapFocus(event) {
|
|
20470
|
+
const focusableElements = KritzelHTMLHelper.getFocusableElements(this.host);
|
|
20471
|
+
if (focusableElements.length === 0)
|
|
20472
|
+
return;
|
|
20473
|
+
const firstFocusable = focusableElements[0];
|
|
20474
|
+
const lastFocusable = focusableElements[focusableElements.length - 1];
|
|
20475
|
+
const activeElement = this.getDeepActiveElement();
|
|
20476
|
+
if (event.shiftKey) {
|
|
20477
|
+
/* shift + tab */
|
|
20478
|
+
if (activeElement === firstFocusable) {
|
|
20479
|
+
lastFocusable.focus();
|
|
20480
|
+
event.preventDefault();
|
|
20481
|
+
}
|
|
20482
|
+
}
|
|
20483
|
+
else {
|
|
20484
|
+
/* tab */
|
|
20485
|
+
if (activeElement === lastFocusable) {
|
|
20486
|
+
firstFocusable.focus();
|
|
20487
|
+
event.preventDefault();
|
|
20488
|
+
}
|
|
20489
|
+
}
|
|
20490
|
+
}
|
|
20491
|
+
get firstFocusableElement() {
|
|
20492
|
+
const slotEl = this.host.shadowRoot?.querySelector('slot');
|
|
20493
|
+
const firstAssigned = slotEl?.assignedElements({ flatten: true })[0];
|
|
20494
|
+
if (!firstAssigned)
|
|
20495
|
+
return null;
|
|
20496
|
+
const focusable = KritzelHTMLHelper.getFocusableElements(firstAssigned);
|
|
20497
|
+
return focusable[0] ?? firstAssigned;
|
|
20498
|
+
}
|
|
20499
|
+
get lastAddedPortal() {
|
|
20500
|
+
const portals = Array.from(document.querySelectorAll('[id^="portal-"]'));
|
|
20501
|
+
return portals.length ? portals[portals.length - 1] : null;
|
|
20502
|
+
}
|
|
20503
|
+
calculateLeft() {
|
|
20504
|
+
if (!this.anchor || !this.portal)
|
|
20505
|
+
return 0;
|
|
20506
|
+
const refRect = this.anchor.getBoundingClientRect();
|
|
20507
|
+
const portalRect = this.portal.getBoundingClientRect();
|
|
20508
|
+
const offset = this.offsetX ?? this.defaultOffset;
|
|
20509
|
+
let left = refRect.left + offset;
|
|
20510
|
+
const maxLeft = window.innerWidth - portalRect.width - this.minLeft;
|
|
20511
|
+
if (left < this.minLeft)
|
|
20512
|
+
left = this.minLeft;
|
|
20513
|
+
if (left > maxLeft)
|
|
20514
|
+
left = maxLeft;
|
|
20515
|
+
return Math.round(left + window.scrollX);
|
|
20516
|
+
}
|
|
20517
|
+
calculateTop() {
|
|
20518
|
+
if (!this.anchor || !this.portal)
|
|
20519
|
+
return 0;
|
|
20520
|
+
const refRect = this.anchor.getBoundingClientRect();
|
|
20521
|
+
const portalRect = this.portal.getBoundingClientRect();
|
|
20522
|
+
const offset = this.offsetY ?? this.defaultOffset;
|
|
20523
|
+
let top = refRect.bottom + offset;
|
|
20524
|
+
if (top + portalRect.height > window.innerHeight) {
|
|
20525
|
+
top = refRect.top - portalRect.height - offset;
|
|
20526
|
+
}
|
|
20527
|
+
return Math.round(top + window.scrollY);
|
|
20528
|
+
}
|
|
20529
|
+
openPortal() {
|
|
20530
|
+
this.portal = document.createElement('div');
|
|
20531
|
+
this.portal.setAttribute('id', this.id);
|
|
20532
|
+
this.portal.style.zIndex = '1';
|
|
20533
|
+
this.portal.style.position = 'absolute';
|
|
20534
|
+
this.portal.style.top = '0px';
|
|
20535
|
+
this.portal.style.left = '0px';
|
|
20536
|
+
this.portal.appendChild(this.host);
|
|
20537
|
+
document.body.append(this.portal);
|
|
20538
|
+
}
|
|
20539
|
+
closePortal() {
|
|
20540
|
+
const portal = document.getElementById(this.id);
|
|
20541
|
+
if (!portal)
|
|
20542
|
+
return;
|
|
20543
|
+
document.body.removeChild(portal);
|
|
20544
|
+
this.host.remove();
|
|
20545
|
+
}
|
|
20546
|
+
calculatePosition() {
|
|
20547
|
+
if (!this.anchor || !this.portal)
|
|
20548
|
+
return;
|
|
20549
|
+
const top = this.calculateTop();
|
|
20550
|
+
const left = this.calculateLeft();
|
|
20551
|
+
this.portal.style.top = `${top}px`;
|
|
20552
|
+
this.portal.style.left = `${left}px`;
|
|
20553
|
+
}
|
|
20554
|
+
render() {
|
|
20555
|
+
return (h(Host, { key: '9c5cdf7126ff1148dd2364cce9d2524862e27d13', style: { display: this.anchor ? 'block' : 'none' } }, h("slot", { key: '209a77246fedcea0c24882605487452ff5cc62ce' })));
|
|
20556
|
+
}
|
|
20557
|
+
static get watchers() { return {
|
|
20558
|
+
"anchor": ["anchorChanged"]
|
|
20559
|
+
}; }
|
|
20560
|
+
};
|
|
20561
|
+
|
|
20562
|
+
const kritzelSplitButtonCss = ":host{position:relative;display:flex;align-items:center;font-family:sans-serif;z-index:1;padding:var(--kritzel-split-button-padding, 4px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-split-button-border, 1px solid #ebebeb);gap:var(--kritzel-split-button-gap, 4px)}:host(.mobile){--kritzel-split-button-hover-background-color:transparent}button{border:none;background-color:transparent;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;text-align:center;display:flex;align-items:center;justify-content:center;pointer-events:all;-webkit-tap-highlight-color:transparent}.split-main-button,.split-menu-button{height:auto;display:flex;align-items:center;padding:var(--kritzel-split-button-padding, 8px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);font-size:var(--kritzel-split-button-font-size, 14px)}.split-main-button:hover,.split-menu-button:hover{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button:focus,.split-menu-button:focus{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button{gap:var(--kritzel-split-button-gap, 4px)}.split-menu-button{border-left:none;justify-content:center}.split-divider{width:var(--kritzel-split-button-divider-width, 1px);height:24px;background-color:var(--kritzel-split-button-divider-background-color, hsl(0, 0%, 0%, 4.3%))}:disabled{pointer-events:none;opacity:0.5}";
|
|
20563
|
+
|
|
20564
|
+
const KritzelSplitButton = class {
|
|
20565
|
+
constructor(hostRef) {
|
|
20566
|
+
registerInstance(this, hostRef);
|
|
20567
|
+
this.mainButtonClick = createEvent(this, "mainButtonClick");
|
|
20568
|
+
this.itemSelect = createEvent(this, "itemSelect");
|
|
20569
|
+
this.itemSave = createEvent(this, "itemSave");
|
|
20570
|
+
this.itemCancel = createEvent(this, "itemCancel");
|
|
20571
|
+
this.itemToggleChildMenu = createEvent(this, "itemToggleChildMenu");
|
|
20572
|
+
this.itemCloseChildMenu = createEvent(this, "itemCloseChildMenu");
|
|
20573
|
+
this.menuOpen = createEvent(this, "menuOpen");
|
|
20574
|
+
this.menuClose = createEvent(this, "menuClose");
|
|
20575
|
+
}
|
|
20576
|
+
get host() { return getElement(this); }
|
|
20577
|
+
buttonIcon = 'plus';
|
|
20578
|
+
dropdownIcon = 'chevron-down';
|
|
20579
|
+
items = [];
|
|
20580
|
+
mainButtonDisabled = false;
|
|
20581
|
+
menuButtonDisabled = false;
|
|
20582
|
+
mainButtonClick;
|
|
20583
|
+
itemSelect;
|
|
20584
|
+
itemSave;
|
|
20585
|
+
itemCancel;
|
|
20586
|
+
itemToggleChildMenu;
|
|
20587
|
+
itemCloseChildMenu;
|
|
20588
|
+
menuOpen;
|
|
20589
|
+
menuClose;
|
|
20590
|
+
isMenuOpen = false;
|
|
20591
|
+
isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
20592
|
+
anchorElement;
|
|
20593
|
+
menuScrollTop = 0;
|
|
20594
|
+
splitMenuButtonRef;
|
|
20595
|
+
menuRef;
|
|
20596
|
+
async open() {
|
|
20597
|
+
if (this.isMenuOpen)
|
|
20598
|
+
return;
|
|
20599
|
+
this.isMenuOpen = true;
|
|
20600
|
+
this.anchorElement = this.host;
|
|
20601
|
+
this.menuOpen.emit();
|
|
20602
|
+
}
|
|
20603
|
+
async focusMenu() {
|
|
20604
|
+
if (this.menuRef) {
|
|
20605
|
+
await this.menuRef.setFocus();
|
|
20606
|
+
}
|
|
20607
|
+
}
|
|
20608
|
+
handleButtonClick = (event) => {
|
|
20609
|
+
event.stopPropagation();
|
|
20610
|
+
this.mainButtonClick.emit();
|
|
20611
|
+
};
|
|
20612
|
+
toggleMenu = (event) => {
|
|
20613
|
+
event.stopPropagation();
|
|
20614
|
+
if (this.isMenuOpen) {
|
|
20615
|
+
this.closeMenu();
|
|
20616
|
+
}
|
|
20617
|
+
else {
|
|
20618
|
+
this.openMenu(event);
|
|
20619
|
+
}
|
|
20620
|
+
};
|
|
20621
|
+
openMenu = (event) => {
|
|
20622
|
+
event.stopPropagation();
|
|
20623
|
+
this.isMenuOpen = true;
|
|
20624
|
+
this.anchorElement = this.host;
|
|
20625
|
+
this.menuOpen.emit();
|
|
20626
|
+
requestAnimationFrame(() => {
|
|
20627
|
+
this.menuRef?.setScrollTop(this.menuScrollTop);
|
|
20628
|
+
});
|
|
20629
|
+
};
|
|
20630
|
+
closeMenu = () => {
|
|
20631
|
+
this.isMenuOpen = false;
|
|
20632
|
+
this.anchorElement = null;
|
|
20633
|
+
this.splitMenuButtonRef?.blur();
|
|
20634
|
+
this.menuClose.emit();
|
|
20635
|
+
};
|
|
20636
|
+
handleItemSelect = event => {
|
|
20637
|
+
this.itemSelect.emit(event.detail);
|
|
20638
|
+
};
|
|
20639
|
+
handleItemSave = event => {
|
|
20640
|
+
this.itemSave.emit(event.detail);
|
|
20641
|
+
};
|
|
20642
|
+
handleItemCancel = event => {
|
|
20643
|
+
this.itemCancel.emit(event.detail);
|
|
20644
|
+
};
|
|
20645
|
+
handleItemToggleChildMenu = event => {
|
|
20646
|
+
this.itemToggleChildMenu.emit(event.detail);
|
|
20647
|
+
};
|
|
20648
|
+
handleItemCloseChildMenu = event => {
|
|
20649
|
+
this.itemCloseChildMenu.emit(event.detail);
|
|
20650
|
+
};
|
|
20651
|
+
handleScroll = event => {
|
|
20652
|
+
this.menuScrollTop = event.target.scrollTop;
|
|
20653
|
+
};
|
|
20654
|
+
render() {
|
|
20655
|
+
return (h(Host, { key: '4ff7809dd62c1dd60600fda592aeac43cd9bc74c', class: { mobile: this.isTouchDevice } }, h("button", { key: 'db6485fabcffdd75a25d178aca7b653af499a90c', class: "split-main-button", tabIndex: 0, onClick: this.handleButtonClick, disabled: this.mainButtonDisabled }, this.buttonIcon && h("kritzel-icon", { key: '4001a4e23ef53bec2a578310de8c8b593d7b266c', name: this.buttonIcon })), h("div", { key: '8ff86d3c01a48b06afca77dd066518efa3589cb1', class: "split-divider" }), h("button", { key: 'f1c40edbec3756a7f3681de4e8d0f1981dd312a4', ref: el => (this.splitMenuButtonRef = el), class: "split-menu-button", tabIndex: 0, onClick: this.toggleMenu, disabled: this.menuButtonDisabled }, h("kritzel-icon", { key: '0ddb89976632ae7454e66504f8bab3fd5072c252', name: this.dropdownIcon })), h("kritzel-portal", { key: '64531ffd6ac847fd1a99e32aceefea9f18088992', anchor: this.anchorElement, offsetY: 4, onClose: this.closeMenu }, h("kritzel-menu", { key: 'f3b86cb71e5ba39e8f98e26b3669416e2cdb4802', ref: el => (this.menuRef = el), items: this.items, onItemSelect: this.handleItemSelect, onItemSave: this.handleItemSave, onItemCancel: this.handleItemCancel, onItemToggleChildMenu: this.handleItemToggleChildMenu, onItemCloseChildMenu: this.handleItemCloseChildMenu, onClose: this.closeMenu, onScroll: this.handleScroll }))));
|
|
20656
|
+
}
|
|
20657
|
+
};
|
|
20658
|
+
KritzelSplitButton.style = kritzelSplitButtonCss;
|
|
20659
|
+
|
|
20660
|
+
const kritzelStrokeSizeCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.size-container:hover{background-color:var(--kritzel-stroke-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-stroke-size-selected-background-color, #ebebeb)}";
|
|
20661
|
+
|
|
20662
|
+
const KritzelStrokeSize = class {
|
|
20663
|
+
constructor(hostRef) {
|
|
20664
|
+
registerInstance(this, hostRef);
|
|
20665
|
+
this.sizeChange = createEvent(this, "sizeChange");
|
|
20666
|
+
}
|
|
20667
|
+
sizes = [4, 6, 8, 12, 16, 24];
|
|
20668
|
+
selectedSize = null;
|
|
20669
|
+
sizeChange;
|
|
20670
|
+
handleSizeClick(size) {
|
|
20671
|
+
this.selectedSize = size;
|
|
20672
|
+
this.sizeChange.emit(size);
|
|
20673
|
+
}
|
|
20674
|
+
render() {
|
|
20675
|
+
return (h(Host, { key: '74579e34c23725e22927afe371c1f7925903720a' }, this.sizes.map(size => (h("div", { tabIndex: 0, class: {
|
|
20676
|
+
'size-container': true,
|
|
20677
|
+
'selected': this.selectedSize === size,
|
|
20678
|
+
}, onClick: () => this.handleSizeClick(size) }, h("kritzel-color", { value: '#000000', size: size }))))));
|
|
20679
|
+
}
|
|
20680
|
+
};
|
|
20681
|
+
KritzelStrokeSize.style = kritzelStrokeSizeCss;
|
|
20682
|
+
|
|
20683
|
+
const kritzelTooltipCss = ":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";
|
|
20684
|
+
|
|
20685
|
+
const MOBILE_BREAKPOINT = 768;
|
|
20686
|
+
const KritzelTooltip = class {
|
|
20687
|
+
constructor(hostRef) {
|
|
20688
|
+
registerInstance(this, hostRef);
|
|
20689
|
+
this.tooltipClosed = createEvent(this, "tooltipClosed");
|
|
20690
|
+
}
|
|
20691
|
+
get host() { return getElement(this); }
|
|
20692
|
+
isVisible = false;
|
|
20693
|
+
anchorElement;
|
|
20694
|
+
arrowSize = 8;
|
|
20695
|
+
offsetY = 24;
|
|
20696
|
+
tooltipClosed;
|
|
20697
|
+
positionX = 0;
|
|
20698
|
+
arrowOffset = '0px';
|
|
20699
|
+
isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
20700
|
+
handleOutsideClick(event) {
|
|
20701
|
+
if (!this.isVisible)
|
|
20702
|
+
return;
|
|
20703
|
+
const target = event.target;
|
|
20704
|
+
if (!this.host.contains(target)) {
|
|
20705
|
+
this.tooltipClosed.emit();
|
|
20706
|
+
}
|
|
20707
|
+
}
|
|
20708
|
+
handleWindowResize() {
|
|
20709
|
+
this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
20710
|
+
this.calculateAdjustedPosition();
|
|
20711
|
+
}
|
|
20712
|
+
async focusContent() {
|
|
20713
|
+
const focusableElements = KritzelHTMLHelper.getFocusableElements(this.host);
|
|
20714
|
+
if (focusableElements.length > 0) {
|
|
20715
|
+
focusableElements[0].focus();
|
|
20716
|
+
}
|
|
20717
|
+
}
|
|
20718
|
+
componentDidLoad() {
|
|
20719
|
+
this.focusSlottedContent();
|
|
20720
|
+
}
|
|
20721
|
+
componentWillLoad() {
|
|
20722
|
+
this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
20723
|
+
this.calculateAdjustedPosition();
|
|
20724
|
+
}
|
|
20725
|
+
componentWillUpdate() {
|
|
20726
|
+
this.calculateAdjustedPosition();
|
|
20727
|
+
}
|
|
20728
|
+
focusSlottedContent() {
|
|
20729
|
+
const slot = this.host.shadowRoot?.querySelector('slot');
|
|
20730
|
+
const assignedElements = slot?.assignedElements() || [];
|
|
20731
|
+
if (assignedElements.length > 0) {
|
|
20732
|
+
const firstElement = assignedElements[0];
|
|
20733
|
+
firstElement.focus();
|
|
20734
|
+
}
|
|
20735
|
+
}
|
|
20736
|
+
calculateAdjustedPosition() {
|
|
20737
|
+
if (this.isVisible && this.anchorElement) {
|
|
20738
|
+
const anchorRect = this.anchorElement.getBoundingClientRect();
|
|
20739
|
+
const tooltipContent = this.host.shadowRoot?.querySelector('.tooltip-content');
|
|
20740
|
+
if (!this.isMobileView) {
|
|
20741
|
+
this.positionX = anchorRect.left + anchorRect.width / 2;
|
|
20742
|
+
this.arrowOffset = `calc(${50}% - ${this.arrowSize}px)`;
|
|
20743
|
+
}
|
|
20744
|
+
else {
|
|
20745
|
+
const tooltipRect = tooltipContent.getBoundingClientRect();
|
|
20746
|
+
this.positionX = anchorRect.left + anchorRect.width / 2 - tooltipRect.width / 2;
|
|
20747
|
+
this.arrowOffset = `${anchorRect.left + anchorRect.width / 2 - tooltipRect.left - this.arrowSize}px`;
|
|
20748
|
+
}
|
|
20749
|
+
}
|
|
20750
|
+
}
|
|
20751
|
+
render() {
|
|
20752
|
+
return (h(Host, { key: '72a6356a43a15a7abc9a46b0d22c3c62217791e8', style: {
|
|
20753
|
+
position: 'fixed',
|
|
20754
|
+
zIndex: '9999',
|
|
20755
|
+
transition: 'opacity 0.3s ease-in-out, transform 0.3s ease-in-out',
|
|
20756
|
+
visibility: this.isVisible ? 'visible' : 'hidden',
|
|
20757
|
+
left: !this.isMobileView ? `${this.positionX}px` : '50%',
|
|
20758
|
+
marginBottom: `${this.offsetY + this.arrowSize}px`,
|
|
20759
|
+
} }, h("div", { key: '75f5350f23ada0eee009279eddd7d25273ad3740', class: "tooltip-content", onClick: event => event.stopPropagation() }, h("slot", { key: 'ad999154289e933cac1fdc13392de2aec78811a8' }), h("div", { key: '6be3f5c24d42898920c339be2cd2f3dd8a82fa80', class: "tooltip-arrow-wrapper", style: {
|
|
20760
|
+
position: 'fixed',
|
|
20761
|
+
left: this.arrowOffset,
|
|
20762
|
+
bottom: `-${this.arrowSize * 2}px`,
|
|
20763
|
+
} }, h("div", { key: '37397c6245dd6b0def23e2611d118e0c4f5860ef', class: "tooltip-arrow", style: {
|
|
20764
|
+
borderLeft: `${this.arrowSize}px solid transparent`,
|
|
20765
|
+
borderRight: `${this.arrowSize}px solid transparent`,
|
|
20766
|
+
borderTop: `${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,
|
|
20767
|
+
filter: 'drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))',
|
|
20768
|
+
} }), h("div", { key: 'dbf009c371d46ef0a36e27771758c66e817d9b22', class: "tooltip-arrow-rect", style: {
|
|
20769
|
+
position: 'relative',
|
|
20770
|
+
width: `${this.arrowSize * 2}px`,
|
|
20771
|
+
height: `${this.arrowSize}px`,
|
|
20772
|
+
backgroundColor: 'var(--kritzel-controls-tooltip-background-color, #ffffff)',
|
|
20773
|
+
bottom: `${this.arrowSize * 2}px`,
|
|
20774
|
+
} })))));
|
|
20775
|
+
}
|
|
20776
|
+
};
|
|
20777
|
+
KritzelTooltip.style = kritzelTooltipCss;
|
|
20778
|
+
|
|
20779
|
+
const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent;border-radius:var(--kritzel-utility-panel-button-border-radius, 8px)}.utility-button:hover,.utility-button:focus-visible{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.utility-button:disabled{opacity:0.4;cursor:not-allowed;pointer-events:none}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";
|
|
20780
|
+
|
|
20781
|
+
const KritzelUtilityPanel = class {
|
|
20782
|
+
constructor(hostRef) {
|
|
20783
|
+
registerInstance(this, hostRef);
|
|
20784
|
+
this.undo = createEvent(this, "undo");
|
|
20785
|
+
this.redo = createEvent(this, "redo");
|
|
20786
|
+
this.delete = createEvent(this, "delete");
|
|
20787
|
+
}
|
|
20788
|
+
undoState = null;
|
|
20789
|
+
undo;
|
|
20790
|
+
redo;
|
|
20791
|
+
delete;
|
|
20792
|
+
handleUndo(event) {
|
|
20793
|
+
if (event.cancelable) {
|
|
20794
|
+
event.preventDefault();
|
|
20795
|
+
event.stopPropagation();
|
|
20796
|
+
this.undo.emit();
|
|
20797
|
+
}
|
|
20798
|
+
}
|
|
20799
|
+
handleRedo(event) {
|
|
20800
|
+
event.preventDefault();
|
|
20801
|
+
event.stopPropagation();
|
|
20802
|
+
this.redo.emit();
|
|
20803
|
+
}
|
|
20804
|
+
render() {
|
|
20805
|
+
return (h(Host, { key: '47e35a4c61d2807d220888eb90e325e24b9baf90' }, h("button", { key: '4e6ec69fc83242a9c1340a31351da1cccd90b1ba', class: "utility-button", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: '57bf4920ff9f0b2de8b0c1625dd844bba0c7f66d', name: "undo" })), h("button", { key: '759b9d13a679455fccd00e3d8c84e51b184659df', class: "utility-button", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: 'f3650d9dcf0c09086ec707443deb6055f7a709ec', name: "redo" })), h("div", { key: 'f414bc1d4be24a1f48d77911db4b9064c898ed8d', class: "utility-separator" }), h("button", { key: 'f542539422b6040bc7b90ceccad075e8f7150a4e', class: "utility-button" }, h("kritzel-icon", { key: 'da8e3cfe848384c3bb984b34d7ad9a6c9c1feba8', name: "delete", onClick: () => this.delete.emit() }))));
|
|
20806
|
+
}
|
|
20807
|
+
};
|
|
20808
|
+
KritzelUtilityPanel.style = kritzelUtilityPanelCss;
|
|
20809
|
+
|
|
20810
|
+
const kritzelWorkspaceManagerCss = ":host{display:flex;flex-direction:column;z-index:1}";
|
|
20811
|
+
|
|
20812
|
+
const KritzelWorkspaceManager = class {
|
|
20813
|
+
constructor(hostRef) {
|
|
20814
|
+
registerInstance(this, hostRef);
|
|
20815
|
+
this.isWorkspaceManagerReady = createEvent(this, "isWorkspaceManagerReady");
|
|
20816
|
+
this.workspaceChange = createEvent(this, "workspaceChange");
|
|
20817
|
+
}
|
|
20818
|
+
get host() { return getElement(this); }
|
|
20819
|
+
activeWorkspace;
|
|
20820
|
+
workspaces = [];
|
|
20821
|
+
isWorkspaceManagerReady;
|
|
20822
|
+
workspaceChange;
|
|
20823
|
+
childMenuAnchor = null;
|
|
20824
|
+
openChildMenuItem = null;
|
|
20825
|
+
newWorkspace = null;
|
|
20826
|
+
editingItemId = null;
|
|
20827
|
+
handleWheel(event) {
|
|
20828
|
+
if (event.ctrlKey) {
|
|
20829
|
+
event.preventDefault();
|
|
20830
|
+
}
|
|
20831
|
+
}
|
|
20832
|
+
kritzelEngineRef = null;
|
|
20833
|
+
splitButtonRef;
|
|
20834
|
+
get sortedWorkspaces() {
|
|
20835
|
+
return [this.newWorkspace, ...this.workspaces].filter(ws => ws != null).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
20836
|
+
}
|
|
20837
|
+
async componentWillLoad() {
|
|
20838
|
+
await this.initializeEngine();
|
|
20839
|
+
this.isWorkspaceManagerReady.emit();
|
|
20840
|
+
}
|
|
20841
|
+
async initializeEngine() {
|
|
20842
|
+
await customElements.whenDefined('kritzel-engine');
|
|
20843
|
+
this.kritzelEngineRef = this.host.parentElement.querySelector('kritzel-engine');
|
|
20844
|
+
if (!this.kritzelEngineRef) {
|
|
20845
|
+
throw new Error('kritzel-engine not found in parent element.');
|
|
20846
|
+
}
|
|
20847
|
+
}
|
|
20848
|
+
async select(item, parent) {
|
|
20849
|
+
if (this.editingItemId) {
|
|
20850
|
+
return;
|
|
20851
|
+
}
|
|
20852
|
+
if (item.action) {
|
|
20853
|
+
item.action(item, parent);
|
|
20854
|
+
return;
|
|
20855
|
+
}
|
|
20856
|
+
this.workspaceChange.emit(item.value);
|
|
20857
|
+
}
|
|
20858
|
+
async add() {
|
|
20859
|
+
await this.splitButtonRef.open();
|
|
20860
|
+
this.newWorkspace = new KritzelWorkspace(ObjectHelper.generateUUID(), 'New Workspace');
|
|
20861
|
+
this.editingItemId = this.newWorkspace.id;
|
|
20862
|
+
}
|
|
20863
|
+
edit(item) {
|
|
20864
|
+
this.openChildMenuItem = null;
|
|
20865
|
+
this.childMenuAnchor = null;
|
|
20866
|
+
requestAnimationFrame(() => {
|
|
20867
|
+
this.editingItemId = item.id;
|
|
20868
|
+
});
|
|
20869
|
+
}
|
|
20870
|
+
async save(item) {
|
|
20871
|
+
if (this.newWorkspace) {
|
|
20872
|
+
this.newWorkspace.name = item.label;
|
|
20873
|
+
await this.kritzelEngineRef.createWorkspace(this.newWorkspace);
|
|
20874
|
+
this.workspaceChange.emit(this.newWorkspace);
|
|
20875
|
+
}
|
|
20876
|
+
else {
|
|
20877
|
+
const workspace = item.value;
|
|
20878
|
+
workspace.name = item.label;
|
|
20879
|
+
await this.kritzelEngineRef.updateWorkspace(workspace);
|
|
20880
|
+
}
|
|
20881
|
+
this.editingItemId = null;
|
|
20882
|
+
this.newWorkspace = null;
|
|
20883
|
+
}
|
|
20884
|
+
cancel() {
|
|
20885
|
+
this.newWorkspace = null;
|
|
20886
|
+
this.editingItemId = null;
|
|
20887
|
+
}
|
|
20888
|
+
async delete(item) {
|
|
20889
|
+
this.openChildMenuItem = null;
|
|
20890
|
+
this.childMenuAnchor = null;
|
|
20891
|
+
await this.kritzelEngineRef.deleteWorkspace(item.value);
|
|
20892
|
+
if (item.value.id === this.activeWorkspace?.id) {
|
|
20893
|
+
this.activeWorkspace = this.sortedWorkspaces.find(ws => ws.id !== item.value.id) || null;
|
|
20894
|
+
this.workspaceChange.emit(this.activeWorkspace);
|
|
20895
|
+
}
|
|
20896
|
+
await this.splitButtonRef.focusMenu();
|
|
20897
|
+
}
|
|
20898
|
+
toggleChildMenu(item, anchor) {
|
|
20899
|
+
this.openChildMenuItem = item;
|
|
20900
|
+
this.childMenuAnchor = anchor;
|
|
20901
|
+
}
|
|
20902
|
+
closeChildMenu() {
|
|
20903
|
+
this.openChildMenuItem = null;
|
|
20904
|
+
this.childMenuAnchor = null;
|
|
20905
|
+
}
|
|
20906
|
+
handleMenuOpen() {
|
|
20907
|
+
this.kritzelEngineRef.disable();
|
|
20908
|
+
}
|
|
20909
|
+
handleMenuClose() {
|
|
20910
|
+
this.cancel();
|
|
20911
|
+
this.closeChildMenu();
|
|
20912
|
+
this.kritzelEngineRef.enable();
|
|
20913
|
+
}
|
|
20914
|
+
render() {
|
|
20915
|
+
const menuItems = this.sortedWorkspaces
|
|
20916
|
+
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
|
|
20917
|
+
.filter(ws => ws !== null)
|
|
20918
|
+
.map(ws => {
|
|
20919
|
+
return {
|
|
20920
|
+
id: ws.id,
|
|
20921
|
+
label: ws.name,
|
|
20922
|
+
value: ws,
|
|
20923
|
+
isEditing: this.editingItemId === ws.id,
|
|
20924
|
+
isSelected: this.activeWorkspace?.id === ws.id,
|
|
20925
|
+
isNewItem: this.newWorkspace?.id === ws.id,
|
|
20926
|
+
isChildMenuOpen: this.openChildMenuItem?.id === ws.id,
|
|
20927
|
+
childMenuAnchor: this.openChildMenuItem?.id === ws.id ? this.childMenuAnchor : null,
|
|
20928
|
+
children: [
|
|
20929
|
+
{
|
|
20930
|
+
id: `${ws.id}-rename`,
|
|
20931
|
+
label: 'Rename',
|
|
20932
|
+
value: 'rename',
|
|
20933
|
+
action: (_item, parent) => this.edit(parent),
|
|
20934
|
+
},
|
|
20935
|
+
{
|
|
20936
|
+
id: `${ws.id}-delete`,
|
|
20937
|
+
label: 'Delete',
|
|
20938
|
+
value: 'delete',
|
|
20939
|
+
isDisabled: this.sortedWorkspaces.length <= 1,
|
|
20940
|
+
action: (_item, parent) => this.delete(parent),
|
|
20941
|
+
},
|
|
20942
|
+
],
|
|
20943
|
+
};
|
|
20944
|
+
});
|
|
20945
|
+
return (h(Host, null, h("kritzel-split-button", { ref: el => (this.splitButtonRef = el), items: menuItems, mainButtonDisabled: this.editingItemId != null, onMainButtonClick: () => this.add(), onItemSelect: event => this.select(event.detail.item, event.detail.parent), onItemToggleChildMenu: event => this.toggleChildMenu(event.detail.item, event.detail.childMenuAnchor), onItemSave: event => this.save(event.detail), onItemCancel: () => this.cancel(), onItemCloseChildMenu: () => this.closeChildMenu(), onMenuOpen: () => this.handleMenuOpen(), onMenuClose: () => this.handleMenuClose() })));
|
|
20946
|
+
}
|
|
20947
|
+
};
|
|
20948
|
+
KritzelWorkspaceManager.style = kritzelWorkspaceManagerCss;
|
|
20949
|
+
|
|
20950
|
+
export { KritzelColor as kritzel_color, KritzelColorPalette as kritzel_color_palette, KritzelContextMenu as kritzel_context_menu, KritzelControlBrushConfig as kritzel_control_brush_config, KritzelControlTextConfig as kritzel_control_text_config, KritzelControls as kritzel_controls, KritzelCursorTrail as kritzel_cursor_trail, KritzelDropdown as kritzel_dropdown, KritzelEditor as kritzel_editor, KritzelEngine as kritzel_engine, KritzelFont as kritzel_font, KritzelFontFamily as kritzel_font_family, KritzelFontSize as kritzel_font_size, KritzelIcon as kritzel_icon, KritzelMenu as kritzel_menu, KritzelMenuItem as kritzel_menu_item, KritzelPortal as kritzel_portal, KritzelSplitButton as kritzel_split_button, KritzelStrokeSize as kritzel_stroke_size, KritzelTooltip as kritzel_tooltip, KritzelUtilityPanel as kritzel_utility_panel, KritzelWorkspaceManager as kritzel_workspace_manager };
|
|
20951
|
+
//# sourceMappingURL=kritzel-color.kritzel-color-palette.kritzel-context-menu.kritzel-control-brush-config.kritzel-control-text-config.kritzel-controls.kritzel-cursor-trail.kritzel-dropdown.kritzel-editor.kritzel-engine.kritzel-font.kritzel-font-family.kritzel-font-size.kritzel-icon.kritzel-menu.kritzel-menu-item.kritzel-portal.kritzel-split-button.kritzel-stroke-size.kritzel-tooltip.kritzel-utility-panel.kritzel-workspace-manager.entry.js.map
|