kritzel-stencil 0.0.127 → 0.0.129
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/{index-BacMQbNR.js → index-C7Read21.js} +165 -82
- package/dist/cjs/index-C7Read21.js.map +1 -0
- package/dist/cjs/{index-C05uAr89.js → index-CUSIflVf.js} +12 -6
- package/dist/cjs/index-CUSIflVf.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -3
- package/dist/cjs/{kritzel-brush-style_18.cjs.entry.js → kritzel-brush-style_22.cjs.entry.js} +997 -211
- package/dist/cjs/loader.cjs.js +2 -4
- package/dist/cjs/stencil.cjs.js +3 -5
- package/dist/cjs/stencil.cjs.js.map +1 -1
- package/dist/collection/classes/commands/add-object.command.js +5 -2
- package/dist/collection/classes/commands/add-object.command.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/base.command.js +2 -2
- package/dist/collection/classes/commands/base.command.js.map +1 -1
- package/dist/collection/classes/commands/batch.command.js +2 -2
- package/dist/collection/classes/commands/batch.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +5 -2
- package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +5 -2
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/commands/update-viewport.command.js +2 -2
- package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
- package/dist/collection/classes/database.class.js +227 -0
- package/dist/collection/classes/database.class.js.map +1 -0
- package/dist/collection/classes/handlers/key.handler.js +0 -1
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +18 -2
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +10 -2
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +18 -2
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/history.class.js +18 -5
- package/dist/collection/classes/history.class.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +1 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +1 -0
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +1 -0
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +1 -0
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +1 -0
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +1 -0
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +7 -4
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/registries/icon-registry.class.js +5 -1
- package/dist/collection/classes/registries/icon-registry.class.js.map +1 -1
- package/dist/collection/classes/store.class.js +143 -20
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/classes/structures/octree.structure.js +4 -0
- package/dist/collection/classes/structures/octree.structure.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +3 -0
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +2 -2
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/classes/viewport.class.js +4 -0
- package/dist/collection/classes/viewport.class.js.map +1 -1
- package/dist/collection/classes/workspace.class.js +10 -0
- package/dist/collection/classes/workspace.class.js.map +1 -0
- package/dist/collection/collection-manifest.json +6 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +5 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +14 -16
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +235 -39
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +1 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +179 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +288 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -0
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +218 -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 +327 -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 +2 -2
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +24 -61
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +8 -11
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +29 -17
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- 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 +212 -0
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -0
- package/dist/collection/configs/default-engine-state.js +5 -2
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/class.helper.js +1 -1
- package/dist/collection/helpers/class.helper.js.map +1 -1
- package/dist/collection/helpers/html.helper.js +30 -1
- package/dist/collection/helpers/html.helper.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +1 -1
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/interfaces/command.interface.js.map +1 -1
- package/dist/collection/interfaces/debug-info.interface.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- 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.map +1 -1
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +7 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/kritzel-brush-style.js +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +79 -49
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-menu.d.ts +11 -0
- package/dist/components/kritzel-menu.js +9 -0
- package/dist/components/kritzel-menu.js.map +1 -0
- package/dist/components/kritzel-portal.d.ts +11 -0
- package/dist/components/kritzel-portal.js +9 -0
- package/dist/components/kritzel-portal.js.map +1 -0
- package/dist/components/kritzel-split-button.d.ts +11 -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 +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.d.ts +11 -0
- package/dist/components/kritzel-workspace-manager.js +9 -0
- package/dist/components/kritzel-workspace-manager.js.map +1 -0
- package/dist/components/{p-DfJEh7HZ.js → p-5CJxFNEE.js} +9 -7
- package/dist/components/p-5CJxFNEE.js.map +1 -0
- package/dist/components/{p-ljdIU3DL.js → p-B7VrEdgP.js} +63 -63
- package/dist/components/p-B7VrEdgP.js.map +1 -0
- package/dist/components/{p-DJc6_PyL.js → p-BAPUTr3K.js} +10 -8
- package/dist/components/p-BAPUTr3K.js.map +1 -0
- package/dist/components/{p-CtiROna-.js → p-BLmFBe2a.js} +12 -6
- package/dist/components/p-BLmFBe2a.js.map +1 -0
- package/dist/components/p-BU2q3PRS.js +84 -0
- package/dist/components/p-BU2q3PRS.js.map +1 -0
- package/dist/components/{p-Dp8hrISj.js → p-BZ-j_4CK.js} +8 -6
- package/dist/components/p-BZ-j_4CK.js.map +1 -0
- package/dist/components/{p-BhC-Et5I.js → p-BaKb8ZLg.js} +16 -14
- package/dist/components/p-BaKb8ZLg.js.map +1 -0
- package/dist/components/p-Bb6od8He.js +42 -0
- package/dist/components/p-Bb6od8He.js.map +1 -0
- package/dist/components/{p-DcvujuV_.js → p-BcQTDgzV.js} +10 -8
- package/dist/components/p-BcQTDgzV.js.map +1 -0
- package/dist/components/p-BeVv4o5c.js +14 -0
- package/dist/components/p-BeVv4o5c.js.map +1 -0
- package/dist/components/p-BmJbJwkH.js +167 -0
- package/dist/components/p-BmJbJwkH.js.map +1 -0
- package/dist/components/{p-DJN0U8pI.js → p-BqrTPNyu.js} +10 -7
- package/dist/components/p-BqrTPNyu.js.map +1 -0
- package/dist/components/{p-NZJPrwJV.js → p-BvlGgLAQ.js} +7 -5
- package/dist/components/p-BvlGgLAQ.js.map +1 -0
- package/dist/components/{p-BOUCnklW.js → p-BzSz74Ci.js} +9 -7
- package/dist/components/p-BzSz74Ci.js.map +1 -0
- package/dist/components/p-C6OxvITm.js +168 -0
- package/dist/components/p-C6OxvITm.js.map +1 -0
- package/dist/components/p-CJKA5zIE.js +10 -0
- package/dist/components/p-CJKA5zIE.js.map +1 -0
- package/dist/components/{p-CudOuOAW.js → p-D-zg05gA.js} +558 -126
- package/dist/components/p-D-zg05gA.js.map +1 -0
- package/dist/components/p-D8W6LE-c.js.map +1 -1
- package/dist/components/p-Dozs0Zfn.js +115 -0
- package/dist/components/p-Dozs0Zfn.js.map +1 -0
- package/dist/components/{p-EQo4-DJT.js → p-DtmZW6eP.js} +8 -6
- package/dist/components/p-DtmZW6eP.js.map +1 -0
- package/dist/components/{p-C9usqwb5.js → p-V4ui5aWj.js} +9 -7
- package/dist/components/p-V4ui5aWj.js.map +1 -0
- package/dist/components/{p-BubFkS0u.js → p-_ntxNi8v.js} +9 -7
- package/dist/components/p-_ntxNi8v.js.map +1 -0
- package/dist/components/{p-BkFzf8vg.js → p-a7KmQzo4.js} +15 -13
- package/dist/components/p-a7KmQzo4.js.map +1 -0
- package/dist/components/p-aaxf-h5S.js +159 -0
- package/dist/components/p-aaxf-h5S.js.map +1 -0
- package/dist/components/{p-CmlcJ8Kw.js → p-jG1e48OE.js} +11 -9
- package/dist/components/p-jG1e48OE.js.map +1 -0
- package/dist/components/{p-D5a8vnRF.js → p-rQeWFfPG.js} +10 -8
- package/dist/components/p-rQeWFfPG.js.map +1 -0
- package/dist/components/{p-DSWoCkxm.js → p-yZFrTtMQ.js} +43 -40
- package/dist/components/p-yZFrTtMQ.js.map +1 -0
- package/dist/esm/{index-D37FADaF.js → index-J4NpPimy.js} +163 -83
- package/dist/esm/index-J4NpPimy.js.map +1 -0
- package/dist/esm/{index-BGl8znzE.js → index-NiIEUDzj.js} +12 -6
- package/dist/esm/index-NiIEUDzj.js.map +1 -0
- package/dist/esm/index.js +1 -3
- package/dist/esm/{kritzel-brush-style_18.entry.js → kritzel-brush-style_22.entry.js} +987 -205
- package/dist/esm/loader.js +3 -5
- package/dist/esm/stencil.js +4 -6
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-43202395.entry.js +2 -0
- package/dist/stencil/p-43202395.entry.js.map +1 -0
- package/dist/stencil/p-J4NpPimy.js +2 -0
- package/dist/stencil/p-J4NpPimy.js.map +1 -0
- package/dist/stencil/{p-BGl8znzE.js → p-NiIEUDzj.js} +3 -3
- package/dist/stencil/p-NiIEUDzj.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/commands/add-object.command.d.ts +1 -1
- package/dist/types/classes/commands/add-selection-group.command.d.ts +1 -1
- package/dist/types/classes/commands/base.command.d.ts +2 -2
- package/dist/types/classes/commands/batch.command.d.ts +1 -1
- package/dist/types/classes/commands/move-selection-group.command.d.ts +1 -1
- package/dist/types/classes/commands/remove-object.command.d.ts +1 -1
- package/dist/types/classes/commands/remove-selection-group.command.d.ts +1 -1
- package/dist/types/classes/commands/resize-selection-group.command.d.ts +1 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
- package/dist/types/classes/commands/update-object.command.d.ts +1 -1
- package/dist/types/classes/commands/update-viewport.command.d.ts +1 -1
- package/dist/types/classes/database.class.d.ts +28 -0
- package/dist/types/classes/history.class.d.ts +1 -0
- package/dist/types/classes/objects/base-object.class.d.ts +1 -0
- package/dist/types/classes/objects/text.class.d.ts +1 -1
- package/dist/types/classes/store.class.d.ts +19 -2
- package/dist/types/classes/structures/octree.structure.d.ts +1 -0
- package/dist/types/classes/workspace.class.d.ts +16 -0
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +6 -1
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +12 -2
- package/dist/types/components/shared/kritzel-menu/kritzel-menu.d.ts +26 -0
- package/dist/types/components/shared/kritzel-portal/kritzel-portal.d.ts +24 -0
- package/dist/types/components/shared/kritzel-split-button/kritzel-split-button.d.ts +25 -0
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +3 -4
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +2 -1
- package/dist/types/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +25 -0
- package/dist/types/components.d.ts +250 -2
- package/dist/types/helpers/html.helper.d.ts +3 -1
- package/dist/types/interfaces/command.interface.d.ts +1 -1
- package/dist/types/interfaces/debug-info.interface.d.ts +1 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +3 -0
- package/dist/types/interfaces/menu-item.interface.d.ts +9 -0
- package/dist/types/interfaces/object.interface.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +21 -0
- package/package.json +2 -1
- package/dist/cjs/index-BacMQbNR.js.map +0 -1
- package/dist/cjs/index-C05uAr89.js.map +0 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +0 -1
- package/dist/components/p-2gNwfcSP.js +0 -119
- package/dist/components/p-2gNwfcSP.js.map +0 -1
- package/dist/components/p-BOUCnklW.js.map +0 -1
- package/dist/components/p-BhC-Et5I.js.map +0 -1
- package/dist/components/p-BkFzf8vg.js.map +0 -1
- package/dist/components/p-BubFkS0u.js.map +0 -1
- package/dist/components/p-C9usqwb5.js.map +0 -1
- package/dist/components/p-CmlcJ8Kw.js.map +0 -1
- package/dist/components/p-CtiROna-.js.map +0 -1
- package/dist/components/p-CudOuOAW.js.map +0 -1
- package/dist/components/p-D5a8vnRF.js.map +0 -1
- package/dist/components/p-DJN0U8pI.js.map +0 -1
- package/dist/components/p-DJc6_PyL.js.map +0 -1
- package/dist/components/p-DSWoCkxm.js.map +0 -1
- package/dist/components/p-DcvujuV_.js.map +0 -1
- package/dist/components/p-DfJEh7HZ.js.map +0 -1
- package/dist/components/p-Dp8hrISj.js.map +0 -1
- package/dist/components/p-EQo4-DJT.js.map +0 -1
- package/dist/components/p-NZJPrwJV.js.map +0 -1
- package/dist/components/p-ljdIU3DL.js.map +0 -1
- package/dist/esm/index-BGl8znzE.js.map +0 -1
- package/dist/esm/index-D37FADaF.js.map +0 -1
- package/dist/esm/kritzel-brush-style_18.entry.js.map +0 -1
- package/dist/stencil/p-BGl8znzE.js.map +0 -1
- package/dist/stencil/p-D37FADaF.js +0 -2
- package/dist/stencil/p-D37FADaF.js.map +0 -1
- package/dist/stencil/p-e6ac7fc6.entry.js +0 -2
- package/dist/stencil/p-e6ac7fc6.entry.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-
|
|
2
|
-
import { K as KritzelBrushTool, a as KritzelTextTool, b as KritzelMouseButton, c as KritzelSelectionTool, D as DEFAULT_BRUSH_CONFIG, d as KritzelEraserTool, e as DEFAULT_TEXT_CONFIG, f as KritzelImageTool, g as KritzelEventHelper, h as KritzelBaseCommand, i as KritzelSelectionGroup, j as KrtizelSelectionBox, R as RemoveSelectionGroupCommand,
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-NiIEUDzj.js';
|
|
2
|
+
import { K as KritzelBrushTool, a as KritzelTextTool, b as KritzelMouseButton, c as KritzelSelectionTool, D as DEFAULT_BRUSH_CONFIG, d as KritzelEraserTool, e as DEFAULT_TEXT_CONFIG, f as KritzelImageTool, g as KritzelEventHelper, h as KritzelBaseCommand, i as KritzelSelectionGroup, j as KrtizelSelectionBox, O as ObjectHelper, k as KritzelReviver, R as RemoveSelectionGroupCommand, l as RemoveObjectCommand, B as BatchCommand, A as AddObjectCommand, m as AddSelectionGroupCommand, n as KritzelToolRegistry, U as UpdateObjectCommand, o as KritzelBaseHandler, p as KritzelBaseTool, q as KritzelKeyboardHelper } from './index-J4NpPimy.js';
|
|
3
3
|
|
|
4
4
|
const kritzelBrushStyleCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.brush-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:default;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)}";
|
|
5
5
|
|
|
@@ -59,13 +59,13 @@ const KritzelColor = class {
|
|
|
59
59
|
}
|
|
60
60
|
render() {
|
|
61
61
|
const isColorVeryLight = this.isLightColor(this.value);
|
|
62
|
-
return (h(Host, { key: '
|
|
62
|
+
return (h(Host, { key: '1468f3502f7d10d182ac72a05ce4b1e520353f8a' }, h("div", { key: 'd30d47667b1b72a970c4ee0da887dd59a663eae7', class: "checkerboard-bg", style: {
|
|
63
63
|
width: `${this.size}px`,
|
|
64
64
|
height: `${this.size}px`,
|
|
65
65
|
borderRadius: '50%',
|
|
66
66
|
display: 'inline-block',
|
|
67
67
|
position: 'relative',
|
|
68
|
-
} }, h("div", { key: '
|
|
68
|
+
} }, h("div", { key: '073fd85967e53b609103a9fe47028bcda849e5ec', class: {
|
|
69
69
|
'color-circle': true,
|
|
70
70
|
'white': isColorVeryLight,
|
|
71
71
|
}, style: {
|
|
@@ -82,7 +82,7 @@ const KritzelColor = class {
|
|
|
82
82
|
};
|
|
83
83
|
KritzelColor.style = kritzelColorCss;
|
|
84
84
|
|
|
85
|
-
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, #
|
|
85
|
+
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)}";
|
|
86
86
|
|
|
87
87
|
const KritzelColorPalette = class {
|
|
88
88
|
constructor(hostRef) {
|
|
@@ -107,7 +107,7 @@ const KritzelColorPalette = class {
|
|
|
107
107
|
render() {
|
|
108
108
|
const displayedColors = this.isExpanded ? this.colors : this.colors.slice(0, 6);
|
|
109
109
|
const expandedHeight = this.isExpanded ? this.calculateHeight() : '32px';
|
|
110
|
-
return (h(Host, { key: '
|
|
110
|
+
return (h(Host, { key: 'dddc32b0904800092d45727e833181af32eb8766' }, h("div", { key: '293cbed8e9c62b5f409b7dcdca0df5de9d65b758', class: {
|
|
111
111
|
'color-grid': true,
|
|
112
112
|
'expanded': this.isExpanded,
|
|
113
113
|
}, style: {
|
|
@@ -120,83 +120,47 @@ const KritzelColorPalette = class {
|
|
|
120
120
|
};
|
|
121
121
|
KritzelColorPalette.style = kritzelColorPaletteCss;
|
|
122
122
|
|
|
123
|
-
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 #
|
|
123
|
+
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}";
|
|
124
124
|
|
|
125
125
|
const KritzelContextMenu = class {
|
|
126
126
|
constructor(hostRef) {
|
|
127
127
|
registerInstance(this, hostRef);
|
|
128
128
|
this.actionSelected = createEvent(this, "actionSelected");
|
|
129
|
-
this.
|
|
130
|
-
this.visibleItems = [];
|
|
129
|
+
this.processedItems = [];
|
|
131
130
|
}
|
|
132
131
|
componentWillLoad() {
|
|
133
|
-
this.
|
|
134
|
-
this.resolveDisabledStates();
|
|
132
|
+
this.updateMenuItems();
|
|
135
133
|
}
|
|
136
134
|
onItemsChanged() {
|
|
137
|
-
this.
|
|
138
|
-
this.resolveDisabledStates();
|
|
135
|
+
this.updateMenuItems();
|
|
139
136
|
}
|
|
140
|
-
handleItemClick(item,
|
|
141
|
-
if (!
|
|
137
|
+
handleItemClick(item, isDisabled) {
|
|
138
|
+
if (!isDisabled) {
|
|
142
139
|
this.actionSelected.emit(item);
|
|
143
140
|
}
|
|
144
141
|
}
|
|
145
|
-
async
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
else {
|
|
159
|
-
isVisible = result;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return { item, index, isVisible };
|
|
164
|
-
});
|
|
165
|
-
const visibilityResults = await Promise.all(visibilityPromises);
|
|
166
|
-
visibilityResults.forEach(({ item, isVisible }) => {
|
|
142
|
+
async evaluateProperty(value, defaultValue) {
|
|
143
|
+
if (typeof value === 'boolean') {
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
if (typeof value === 'function') {
|
|
147
|
+
return await Promise.resolve(value(null, this.objects));
|
|
148
|
+
}
|
|
149
|
+
return defaultValue;
|
|
150
|
+
}
|
|
151
|
+
async updateMenuItems() {
|
|
152
|
+
const processed = [];
|
|
153
|
+
for (const item of this.items) {
|
|
154
|
+
const isVisible = await this.evaluateProperty(item.visible, true);
|
|
167
155
|
if (isVisible) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
this.visibleItems = visibleItems;
|
|
172
|
-
}
|
|
173
|
-
async resolveDisabledStates() {
|
|
174
|
-
const newStates = new Map();
|
|
175
|
-
const disabledPromises = this.visibleItems.map(async (item, index) => {
|
|
176
|
-
let isDisabled = false;
|
|
177
|
-
if (typeof item.disabled === 'boolean') {
|
|
178
|
-
isDisabled = item.disabled;
|
|
156
|
+
const isDisabled = await this.evaluateProperty(item.disabled, false);
|
|
157
|
+
processed.push({ item, isDisabled });
|
|
179
158
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (result instanceof Promise) {
|
|
183
|
-
isDisabled = await result;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
isDisabled = result;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
newStates.set(index, isDisabled);
|
|
190
|
-
});
|
|
191
|
-
await Promise.all(disabledPromises);
|
|
192
|
-
this.disabledStates = new Map(newStates);
|
|
159
|
+
}
|
|
160
|
+
this.processedItems = processed;
|
|
193
161
|
}
|
|
194
162
|
render() {
|
|
195
|
-
return (h(Host, { key: '
|
|
196
|
-
var _a;
|
|
197
|
-
const isDisabled = (_a = this.disabledStates.get(index)) !== null && _a !== void 0 ? _a : false;
|
|
198
|
-
return (h("button", { key: `${item.label}-${index}`, class: { 'menu-item': true, 'disabled': isDisabled }, onClick: () => this.handleItemClick(item, index), onTouchStart: () => this.handleItemClick(item, index), disabled: isDisabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)));
|
|
199
|
-
}))));
|
|
163
|
+
return (h(Host, { key: '96569454f806a6d17380315b4d0200236fe22550' }, h("div", { key: '0e5899a2901e1e9ab9d657824e105121ce785bdc', 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), onTouchStart: () => this.handleItemClick(item, isDisabled), disabled: isDisabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)))))));
|
|
200
164
|
}
|
|
201
165
|
get hostElement() { return getElement(this); }
|
|
202
166
|
static get watchers() { return {
|
|
@@ -238,14 +202,14 @@ const KritzelControlBrushConfig = class {
|
|
|
238
202
|
this.toolChange.emit(this.tool);
|
|
239
203
|
}
|
|
240
204
|
render() {
|
|
241
|
-
return (h(Host, { key: '
|
|
205
|
+
return (h(Host, { key: 'd099d1c6722678fdfb06c34eb0860e8819dd17ca' }, h("div", { key: '0856f0150666415ee452a0fcec5c76b6d25b82c4', style: {
|
|
242
206
|
display: 'flex',
|
|
243
207
|
flexDirection: 'row',
|
|
244
208
|
alignItems: 'center',
|
|
245
209
|
justifyContent: 'flex-start',
|
|
246
210
|
width: '100%',
|
|
247
211
|
gap: '8px',
|
|
248
|
-
} }, h("kritzel-brush-style", { key: '
|
|
212
|
+
} }, h("kritzel-brush-style", { key: '364e6026d1b280a02c3618c7ded11f40c7e3cba4', type: this.tool.type, onTypeChange: event => this.handleTypeChange(event) }), h("button", { key: 'fc58c9ceb9e92ef8c79836e686b9a64653f91210', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand', style: this.palette.length > 6 ? { visibillity: 'visible' } : { visibility: 'hidden' } }, h("kritzel-icon", { key: 'ab219c72a9ace56853c725ba75767be2079a3c10', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-color-palette", { key: '8757c754217a3de88dad2c465ff748571716ae64', colors: this.palette, selectedColor: this.tool.color, isExpanded: this.isExpanded, isOpaque: true, onColorChange: color => this.handleColorChange(color) }), h("kritzel-stroke-size", { key: '056b227dd9a92b06588816739b55a80f5ce80835', selectedSize: this.tool.size, onSizeChange: event => this.handleSizeChange(event) })));
|
|
249
213
|
}
|
|
250
214
|
static get watchers() { return {
|
|
251
215
|
"tool": ["handleToolChange"]
|
|
@@ -277,14 +241,14 @@ const KritzelControlTextConfig = class {
|
|
|
277
241
|
this.toolChange.emit(this.tool);
|
|
278
242
|
}
|
|
279
243
|
render() {
|
|
280
|
-
return (h(Host, { key: '
|
|
244
|
+
return (h(Host, { key: 'f0d35cc43f1fe58a5a26f21dad99f1a733b66cce' }, h("div", { key: 'efc7d31c11460015a41185b4215e9ff45970abdd', style: {
|
|
281
245
|
display: 'flex',
|
|
282
246
|
flexDirection: 'row',
|
|
283
247
|
alignItems: 'center',
|
|
284
248
|
justifyContent: 'flex-start',
|
|
285
249
|
width: '100%',
|
|
286
250
|
gap: '8px',
|
|
287
|
-
} }, h("kritzel-font-family", { key: '
|
|
251
|
+
} }, h("kritzel-font-family", { key: '7f7d3ccb061d4b0e5e0f181ba4224f3de430a88c', selectedFontFamily: this.tool.fontFamily, onFontFamilyChange: event => this.handleFamilyChange(event) }), h("button", { key: '6676fcfa245874d54fa9933888c242c6f611c58c', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand' }, h("kritzel-icon", { key: '0734f636889c77f9087a2de2899a28ebd8df30a2', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-color-palette", { key: '68373ef79578d6a73028da681f1e3b0e8e3e5874', colors: this.tool.palette, selectedColor: this.tool.fontColor, isExpanded: this.isExpanded, onColorChange: event => this.handleColorChange(event) }), h("kritzel-font-size", { key: '56e6828f6ceaac3d37910b7d092a30bacbd84519', selectedSize: this.tool.fontSize, fontFamily: this.tool.fontFamily, onSizeChange: event => this.handleSizeChange(event) })));
|
|
288
252
|
}
|
|
289
253
|
};
|
|
290
254
|
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
@@ -295,7 +259,7 @@ class KritzelDevicesHelper {
|
|
|
295
259
|
}
|
|
296
260
|
}
|
|
297
261
|
|
|
298
|
-
const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.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 #
|
|
262
|
+
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;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.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-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}.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:66px;left:50%;transform:translateX(-50%);z-index:10001}";
|
|
299
263
|
|
|
300
264
|
const KritzelControls = class {
|
|
301
265
|
constructor(hostRef) {
|
|
@@ -309,23 +273,28 @@ const KritzelControls = class {
|
|
|
309
273
|
this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
310
274
|
this.kritzelEngine = null;
|
|
311
275
|
}
|
|
312
|
-
|
|
313
|
-
var _a;
|
|
314
|
-
this.activeControl = this.controls.find(control => control.tool === event.detail) || null;
|
|
315
|
-
await ((_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.setFocus());
|
|
316
|
-
}
|
|
317
|
-
handleClick(event) {
|
|
276
|
+
handleDocumentClick(event) {
|
|
318
277
|
const element = event.target;
|
|
319
278
|
if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
|
|
320
279
|
return;
|
|
321
280
|
}
|
|
322
281
|
this.isTooltipVisible = false;
|
|
323
|
-
this.kritzelEngine.enable();
|
|
324
282
|
}
|
|
325
|
-
|
|
283
|
+
handleKeyDown(event) {
|
|
326
284
|
var _a;
|
|
285
|
+
if (event.key === 'Escape') {
|
|
286
|
+
event.preventDefault();
|
|
287
|
+
this.closeTooltip();
|
|
288
|
+
(_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
async handleActiveToolChange(event) {
|
|
292
|
+
var _a;
|
|
293
|
+
this.activeControl = this.controls.find(control => control.tool === event.detail) || null;
|
|
294
|
+
await ((_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.setFocus());
|
|
295
|
+
}
|
|
296
|
+
async closeTooltip() {
|
|
327
297
|
this.isTooltipVisible = false;
|
|
328
|
-
(_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
329
298
|
}
|
|
330
299
|
get activeToolAsTextTool() {
|
|
331
300
|
var _a;
|
|
@@ -373,9 +342,10 @@ const KritzelControls = class {
|
|
|
373
342
|
}
|
|
374
343
|
}
|
|
375
344
|
handleConfigClick(event) {
|
|
345
|
+
var _a;
|
|
376
346
|
event.stopPropagation();
|
|
377
347
|
this.isTooltipVisible = !this.isTooltipVisible;
|
|
378
|
-
this.kritzelEngine.disable();
|
|
348
|
+
(_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.disable();
|
|
379
349
|
}
|
|
380
350
|
async handleToolChange(event) {
|
|
381
351
|
this.activeControl = Object.assign(Object.assign({}, this.activeControl), { tool: event.detail });
|
|
@@ -384,13 +354,13 @@ const KritzelControls = class {
|
|
|
384
354
|
render() {
|
|
385
355
|
var _a, _b;
|
|
386
356
|
const hasNoConfig = ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.config) === undefined || ((_b = this.activeControl) === null || _b === void 0 ? void 0 : _b.config) === null;
|
|
387
|
-
return (h(Host, { key: '
|
|
357
|
+
return (h(Host, { key: 'af04746b6eaa04a51482cd9d25ba3ab303d631f1', class: {
|
|
388
358
|
mobile: this.isTouchDevice,
|
|
389
|
-
} }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '
|
|
359
|
+
} }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: 'd6ecb1087a332162f3fc809ed4321fc48f72c3e7', style: {
|
|
390
360
|
position: 'absolute',
|
|
391
361
|
bottom: '56px',
|
|
392
362
|
left: '12px',
|
|
393
|
-
}, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } })), h("div", { key: '
|
|
363
|
+
}, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } })), h("div", { key: '34723e47249d53fd544848d2d577deba4df1f131', class: "kritzel-controls" }, this.controls.map(control => {
|
|
394
364
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
395
365
|
if (control.type === 'tool') {
|
|
396
366
|
return (h("button", { class: {
|
|
@@ -483,7 +453,7 @@ const KritzelCursorTrail = class {
|
|
|
483
453
|
}
|
|
484
454
|
}
|
|
485
455
|
render() {
|
|
486
|
-
return (h(Host, { key: '
|
|
456
|
+
return (h(Host, { key: 'c519ab89ffb793de887a870bafe8772f7584f097' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: 'db7ac0975c5a39c0b68d8fd4af4edd4d15f439f3', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
487
457
|
position: 'absolute',
|
|
488
458
|
left: '0',
|
|
489
459
|
top: '0',
|
|
@@ -636,13 +606,17 @@ KritzelIconRegistry.registerIcons({
|
|
|
636
606
|
'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>',
|
|
637
607
|
'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>',
|
|
638
608
|
'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>',
|
|
639
|
-
'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>'
|
|
609
|
+
'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>',
|
|
610
|
+
'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>',
|
|
611
|
+
'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>',
|
|
612
|
+
'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>',
|
|
613
|
+
'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>'
|
|
640
614
|
});
|
|
641
615
|
|
|
642
616
|
const ABSOLUTE_SCALE_MAX = 1000;
|
|
643
617
|
const ABSOLUTE_SCALE_MIN = 0.0001;
|
|
644
618
|
|
|
645
|
-
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-controls{position:absolute;bottom:28px}";
|
|
619
|
+
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:14px;left:14px}kritzel-controls{position:absolute;bottom:28px}";
|
|
646
620
|
|
|
647
621
|
const KritzelEditor = class {
|
|
648
622
|
constructor(hostRef) {
|
|
@@ -732,6 +706,8 @@ const KritzelEditor = class {
|
|
|
732
706
|
this.isUtilityPanelVisible = true;
|
|
733
707
|
this.isEngineReady = false;
|
|
734
708
|
this.isControlsReady = false;
|
|
709
|
+
this.isWorkspaceManagerReady = false;
|
|
710
|
+
this.workspaces = [];
|
|
735
711
|
}
|
|
736
712
|
onIsEngineReady(newValue) {
|
|
737
713
|
if (newValue && this.isControlsReady) {
|
|
@@ -775,32 +751,31 @@ const KritzelEditor = class {
|
|
|
775
751
|
event.preventDefault();
|
|
776
752
|
}
|
|
777
753
|
}
|
|
778
|
-
handleKeyDown(event) {
|
|
779
|
-
var _a;
|
|
780
|
-
if (event.key === 'Escape') {
|
|
781
|
-
event.preventDefault();
|
|
782
|
-
(_a = this.controlsRef) === null || _a === void 0 ? void 0 : _a.closeTooltip();
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
754
|
componentDidLoad() {
|
|
786
755
|
this.registerCustomSvgIcons();
|
|
787
756
|
}
|
|
788
757
|
async checkIsReady() {
|
|
789
758
|
await customElements.whenDefined('kritzel-editor');
|
|
759
|
+
await customElements.whenDefined('kritzel-workspace-manager');
|
|
790
760
|
await customElements.whenDefined('kritzel-controls');
|
|
791
761
|
await customElements.whenDefined('kritzel-engine');
|
|
792
|
-
if (!this.isEngineReady || !this.isControlsReady) {
|
|
762
|
+
if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady) {
|
|
793
763
|
return;
|
|
794
764
|
}
|
|
795
765
|
this.isReady.emit(this.host);
|
|
796
766
|
}
|
|
767
|
+
onEngineReady(event) {
|
|
768
|
+
this.isEngineReady = true;
|
|
769
|
+
this.activeWorkspace = event.detail.activeWorkspace;
|
|
770
|
+
this.workspaces = event.detail.workspaces;
|
|
771
|
+
}
|
|
797
772
|
registerCustomSvgIcons() {
|
|
798
773
|
for (const [name, svg] of Object.entries(this.customSvgIcons)) {
|
|
799
774
|
KritzelIconRegistry.register(name, svg);
|
|
800
775
|
}
|
|
801
776
|
}
|
|
802
777
|
render() {
|
|
803
|
-
return (h(Host, { key: '
|
|
778
|
+
return (h(Host, { key: '9fe00d70c1a875076e545ca447e2f8d817ebb2fd' }, h("kritzel-workspace-manager", { key: 'ca9ce9f8f277e92f78315e7eaba2bc523da5b9cb', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => this.activeWorkspace = event.detail, onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-engine", { key: '098a4690198f0678e7b4c6c897f86ad1698f510f', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.workspaces = event.detail }), h("kritzel-controls", { key: 'e1795f5a7460617628c09766f213c212e48f25e5', ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, style: this.isControlsVisible ? { display: 'flex' } : { display: 'none' }, onIsControlsReady: () => (this.isControlsReady = true) })));
|
|
804
779
|
}
|
|
805
780
|
get host() { return getElement(this); }
|
|
806
781
|
static get watchers() { return {
|
|
@@ -871,6 +846,7 @@ class KritzelViewport {
|
|
|
871
846
|
this._store.state.hasViewportChanged = true;
|
|
872
847
|
this._store.state.skipContextMenu = true;
|
|
873
848
|
this._store.rerender();
|
|
849
|
+
this._store.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
874
850
|
}
|
|
875
851
|
}
|
|
876
852
|
if (event.pointerType === 'touch') {
|
|
@@ -906,6 +882,7 @@ class KritzelViewport {
|
|
|
906
882
|
this.startY = midpointY;
|
|
907
883
|
this._store.state.hasViewportChanged = true;
|
|
908
884
|
this._store.rerender();
|
|
885
|
+
this._store.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
909
886
|
}
|
|
910
887
|
}
|
|
911
888
|
}
|
|
@@ -946,6 +923,7 @@ class KritzelViewport {
|
|
|
946
923
|
this._store.state.translateY -= translateYAdjustment;
|
|
947
924
|
this._store.state.hasViewportChanged = true;
|
|
948
925
|
this._store.rerender();
|
|
926
|
+
this._store.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
949
927
|
}
|
|
950
928
|
handlePan(event) {
|
|
951
929
|
const panSpeed = 0.8;
|
|
@@ -953,12 +931,13 @@ class KritzelViewport {
|
|
|
953
931
|
this._store.state.translateY -= event.deltaY * panSpeed;
|
|
954
932
|
this._store.state.hasViewportChanged = true;
|
|
955
933
|
this._store.rerender();
|
|
934
|
+
this._store.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
956
935
|
}
|
|
957
936
|
}
|
|
958
937
|
|
|
959
938
|
class UpdateViewportCommand extends KritzelBaseCommand {
|
|
960
|
-
constructor(store, initiator, previousViewport) {
|
|
961
|
-
super(store, initiator);
|
|
939
|
+
constructor(store, initiator, previousViewport, skipHistory = false) {
|
|
940
|
+
super(store, initiator, skipHistory);
|
|
962
941
|
this.previousViewport = previousViewport;
|
|
963
942
|
this.currentViewport = {
|
|
964
943
|
scale: this._store.state.scale,
|
|
@@ -1036,16 +1015,29 @@ class KritzelHistory {
|
|
|
1036
1015
|
translateY: this._store.state.translateY,
|
|
1037
1016
|
};
|
|
1038
1017
|
}
|
|
1018
|
+
reset() {
|
|
1019
|
+
this.undoStack.clear();
|
|
1020
|
+
this.redoStack.clear();
|
|
1021
|
+
this.previousViewport = {
|
|
1022
|
+
scale: this._store.state.scale,
|
|
1023
|
+
scaleStep: this._store.state.scaleStep,
|
|
1024
|
+
translateX: this._store.state.translateX,
|
|
1025
|
+
translateY: this._store.state.translateY
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1039
1028
|
executeCommand(command) {
|
|
1040
1029
|
if (this._store.state.hasViewportChanged) {
|
|
1041
1030
|
this.addUpdateViewportCommand();
|
|
1042
1031
|
}
|
|
1043
1032
|
command.execute();
|
|
1044
|
-
if (
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
this.
|
|
1033
|
+
if (command.skipHistory === false) {
|
|
1034
|
+
if (this._store.state.debugInfo.logCommands) {
|
|
1035
|
+
console.info('add', command);
|
|
1036
|
+
}
|
|
1037
|
+
this.undoStack.add(command);
|
|
1038
|
+
if (this.redoStack.isEmpty() === false) {
|
|
1039
|
+
this.redoStack.clear();
|
|
1040
|
+
}
|
|
1049
1041
|
}
|
|
1050
1042
|
this._store.rerender();
|
|
1051
1043
|
}
|
|
@@ -1100,6 +1092,10 @@ class KritzelOctree {
|
|
|
1100
1092
|
this.bounds = bounds;
|
|
1101
1093
|
this.capacity = capacity;
|
|
1102
1094
|
}
|
|
1095
|
+
reset() {
|
|
1096
|
+
this.objects = [];
|
|
1097
|
+
this.children = null;
|
|
1098
|
+
}
|
|
1103
1099
|
insert(object) {
|
|
1104
1100
|
if (!this.intersects(object.rotatedBoundingBox, this.bounds)) {
|
|
1105
1101
|
return false;
|
|
@@ -1204,35 +1200,8 @@ class KritzelOctree {
|
|
|
1204
1200
|
}
|
|
1205
1201
|
}
|
|
1206
1202
|
|
|
1207
|
-
class UpdateObjectCommand extends KritzelBaseCommand {
|
|
1208
|
-
constructor(store, initiator, object, updatedProperties) {
|
|
1209
|
-
super(store, initiator);
|
|
1210
|
-
this.object = object;
|
|
1211
|
-
this.updatedProperties = updatedProperties;
|
|
1212
|
-
this.previousProperties = {};
|
|
1213
|
-
for (const key in updatedProperties) {
|
|
1214
|
-
if (updatedProperties.hasOwnProperty(key)) {
|
|
1215
|
-
this.previousProperties[key] = this.object[key];
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
execute() {
|
|
1220
|
-
for (const key in this.updatedProperties) {
|
|
1221
|
-
if (this.updatedProperties.hasOwnProperty(key)) {
|
|
1222
|
-
this.object[key] = this.updatedProperties[key];
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
undo() {
|
|
1227
|
-
for (const key in this.previousProperties) {
|
|
1228
|
-
if (this.previousProperties.hasOwnProperty(key)) {
|
|
1229
|
-
this.object[key] = this.previousProperties[key];
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
1203
|
const DEFAULT_ENGINE_STATE = {
|
|
1204
|
+
activeWorkspace: null,
|
|
1236
1205
|
activeTool: null,
|
|
1237
1206
|
activeText: null,
|
|
1238
1207
|
currentPath: null,
|
|
@@ -1266,6 +1235,7 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
1266
1235
|
showObjectInfo: false,
|
|
1267
1236
|
showViewportInfo: false,
|
|
1268
1237
|
logCommands: false,
|
|
1238
|
+
logDatabase: false,
|
|
1269
1239
|
},
|
|
1270
1240
|
host: null,
|
|
1271
1241
|
pointerX: 0,
|
|
@@ -1273,7 +1243,7 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
1273
1243
|
scale: 1,
|
|
1274
1244
|
scaleMax: 1,
|
|
1275
1245
|
scaleMin: 1,
|
|
1276
|
-
scaleStep: 0.
|
|
1246
|
+
scaleStep: 0.075,
|
|
1277
1247
|
startX: 0,
|
|
1278
1248
|
startY: 0,
|
|
1279
1249
|
translateX: 0,
|
|
@@ -1287,13 +1257,254 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
1287
1257
|
historyBufferSize: 1000,
|
|
1288
1258
|
longTouchTimeout: null,
|
|
1289
1259
|
longTouchDelay: 300,
|
|
1290
|
-
pointers: new Map()
|
|
1260
|
+
pointers: new Map(),
|
|
1261
|
+
workspaces: [],
|
|
1291
1262
|
};
|
|
1292
1263
|
|
|
1264
|
+
class KritzelDatabase {
|
|
1265
|
+
constructor(dbName, dbVersion, isLoggingEnabled = false) {
|
|
1266
|
+
this.db = null;
|
|
1267
|
+
this.dbName = dbName;
|
|
1268
|
+
this.dbVersion = dbVersion;
|
|
1269
|
+
this.isLoggingEnabled = isLoggingEnabled;
|
|
1270
|
+
}
|
|
1271
|
+
async open(stores) {
|
|
1272
|
+
return new Promise((resolve, reject) => {
|
|
1273
|
+
if (this.db) {
|
|
1274
|
+
resolve();
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
if (this.isLoggingEnabled) {
|
|
1278
|
+
console.log(`[IndexedDB] Opening database: ${this.dbName}, version: ${this.dbVersion}`);
|
|
1279
|
+
}
|
|
1280
|
+
const request = indexedDB.open(this.dbName, this.dbVersion);
|
|
1281
|
+
request.onerror = () => {
|
|
1282
|
+
console.error('IndexedDB error:', request.error);
|
|
1283
|
+
reject(request.error);
|
|
1284
|
+
};
|
|
1285
|
+
request.onsuccess = () => {
|
|
1286
|
+
this.db = request.result;
|
|
1287
|
+
if (this.isLoggingEnabled) {
|
|
1288
|
+
console.log(`[IndexedDB] Database opened successfully.`);
|
|
1289
|
+
}
|
|
1290
|
+
resolve();
|
|
1291
|
+
};
|
|
1292
|
+
request.onupgradeneeded = event => {
|
|
1293
|
+
if (this.isLoggingEnabled) {
|
|
1294
|
+
console.log(`[IndexedDB] Upgrade needed for database: ${this.dbName}`);
|
|
1295
|
+
}
|
|
1296
|
+
const db = event.target.result;
|
|
1297
|
+
stores.forEach(storeConfig => {
|
|
1298
|
+
if (!db.objectStoreNames.contains(storeConfig.name)) {
|
|
1299
|
+
if (this.isLoggingEnabled) {
|
|
1300
|
+
console.log(`[IndexedDB] Creating store: ${storeConfig.name}`);
|
|
1301
|
+
}
|
|
1302
|
+
const store = db.createObjectStore(storeConfig.name, storeConfig.options);
|
|
1303
|
+
if (storeConfig.indices) {
|
|
1304
|
+
storeConfig.indices.forEach(index => {
|
|
1305
|
+
if (this.isLoggingEnabled) {
|
|
1306
|
+
console.log(`[IndexedDB] Creating index: ${index.name} on store: ${storeConfig.name}`);
|
|
1307
|
+
}
|
|
1308
|
+
store.createIndex(index.name, index.keyPath, index.options);
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
};
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
close() {
|
|
1317
|
+
if (this.db) {
|
|
1318
|
+
if (this.isLoggingEnabled) {
|
|
1319
|
+
console.log(`[IndexedDB] Closing database: ${this.dbName}`);
|
|
1320
|
+
}
|
|
1321
|
+
this.db.close();
|
|
1322
|
+
this.db = null;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
async add(storeName, item) {
|
|
1326
|
+
if (this.isLoggingEnabled) {
|
|
1327
|
+
console.log('[IndexedDB] Add:', { storeName, item });
|
|
1328
|
+
}
|
|
1329
|
+
return this.executeTransaction(storeName, 'readwrite', store => store.add(item));
|
|
1330
|
+
}
|
|
1331
|
+
async get(storeName, key) {
|
|
1332
|
+
if (this.isLoggingEnabled) {
|
|
1333
|
+
console.log('[IndexedDB] Get:', { storeName, key });
|
|
1334
|
+
}
|
|
1335
|
+
return this.executeTransaction(storeName, 'readonly', store => store.get(key));
|
|
1336
|
+
}
|
|
1337
|
+
async getAll(storeName) {
|
|
1338
|
+
if (this.isLoggingEnabled) {
|
|
1339
|
+
console.log('[IndexedDB] GetAll:', { storeName });
|
|
1340
|
+
}
|
|
1341
|
+
return this.executeTransaction(storeName, 'readonly', store => store.getAll());
|
|
1342
|
+
}
|
|
1343
|
+
async update(storeName, item) {
|
|
1344
|
+
if (this.isLoggingEnabled) {
|
|
1345
|
+
console.log('[IndexedDB] Update:', { storeName, item });
|
|
1346
|
+
}
|
|
1347
|
+
return this.executeTransaction(storeName, 'readwrite', store => store.put(item));
|
|
1348
|
+
}
|
|
1349
|
+
async delete(storeName, key) {
|
|
1350
|
+
if (this.isLoggingEnabled) {
|
|
1351
|
+
console.log('[IndexedDB] Delete:', { storeName, key });
|
|
1352
|
+
}
|
|
1353
|
+
return this.executeTransaction(storeName, 'readwrite', store => store.delete(key));
|
|
1354
|
+
}
|
|
1355
|
+
async deleteByRange(storeName, range) {
|
|
1356
|
+
if (this.isLoggingEnabled) {
|
|
1357
|
+
console.log('[IndexedDB] DeleteByRange:', { storeName, range });
|
|
1358
|
+
}
|
|
1359
|
+
return this.executeTransaction(storeName, 'readwrite', store => store.delete(range));
|
|
1360
|
+
}
|
|
1361
|
+
async getAllByRange(storeName, range) {
|
|
1362
|
+
if (this.isLoggingEnabled) {
|
|
1363
|
+
console.log('[IndexedDB] GetAllByRange:', { storeName, range });
|
|
1364
|
+
}
|
|
1365
|
+
return this.executeTransaction(storeName, 'readonly', store => {
|
|
1366
|
+
return store.getAll(range);
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
async getAllByIndex(storeName, indexName, query) {
|
|
1370
|
+
if (this.isLoggingEnabled) {
|
|
1371
|
+
console.log('[IndexedDB] GetAllByIndex:', { storeName, indexName, query });
|
|
1372
|
+
}
|
|
1373
|
+
return this.executeTransaction(storeName, 'readonly', store => {
|
|
1374
|
+
const index = store.index(indexName);
|
|
1375
|
+
return index.getAll(query);
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
async executeTransaction(storeName, mode, action) {
|
|
1379
|
+
if (!this.db) {
|
|
1380
|
+
throw new Error('Database is not open.');
|
|
1381
|
+
}
|
|
1382
|
+
return new Promise((resolve, reject) => {
|
|
1383
|
+
const transaction = this.db.transaction(storeName, mode);
|
|
1384
|
+
const store = transaction.objectStore(storeName);
|
|
1385
|
+
const request = action(store);
|
|
1386
|
+
let requestResult;
|
|
1387
|
+
transaction.oncomplete = () => {
|
|
1388
|
+
resolve(requestResult);
|
|
1389
|
+
};
|
|
1390
|
+
transaction.onabort = () => {
|
|
1391
|
+
var _a;
|
|
1392
|
+
reject((_a = transaction.error) !== null && _a !== void 0 ? _a : new Error('Transaction aborted'));
|
|
1393
|
+
};
|
|
1394
|
+
transaction.onerror = () => {
|
|
1395
|
+
reject(transaction.error);
|
|
1396
|
+
};
|
|
1397
|
+
request.onsuccess = () => {
|
|
1398
|
+
requestResult = request.result;
|
|
1399
|
+
};
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
async batch(actions) {
|
|
1403
|
+
if (!this.db) {
|
|
1404
|
+
throw new Error('Database is not open.');
|
|
1405
|
+
}
|
|
1406
|
+
const storeNames = await this.extractStoreNamesFromActions(actions);
|
|
1407
|
+
if (this.isLoggingEnabled) {
|
|
1408
|
+
console.log('[IndexedDB] Starting batch transaction:', { storeNames });
|
|
1409
|
+
}
|
|
1410
|
+
return new Promise((resolve, reject) => {
|
|
1411
|
+
const transaction = this.db.transaction(storeNames, 'readwrite');
|
|
1412
|
+
const results = [];
|
|
1413
|
+
const promises = [];
|
|
1414
|
+
const tempDbInstance = {
|
|
1415
|
+
add: (storeName, item) => this.add(storeName, item),
|
|
1416
|
+
get: (storeName, key) => this.get(storeName, key),
|
|
1417
|
+
getAll: (storeName) => this.getAll(storeName),
|
|
1418
|
+
update: (storeName, item) => this.update(storeName, item),
|
|
1419
|
+
delete: (storeName, key) => this.delete(storeName, key),
|
|
1420
|
+
deleteByRange: (storeName, range) => this.deleteByRange(storeName, range),
|
|
1421
|
+
getAllByRange: (storeName, range) => this.getAllByRange(storeName, range),
|
|
1422
|
+
getAllByIndex: (storeName, indexName, query) => this.getAllByIndex(storeName, indexName, query),
|
|
1423
|
+
executeTransaction: (storeName, mode, action) => {
|
|
1424
|
+
return new Promise((resolveRequest, rejectRequest) => {
|
|
1425
|
+
if (this.isLoggingEnabled) {
|
|
1426
|
+
console.log('[IndexedDB] Executing batch action:', { storeName, mode });
|
|
1427
|
+
}
|
|
1428
|
+
const store = transaction.objectStore(storeName);
|
|
1429
|
+
const request = action(store);
|
|
1430
|
+
request.onsuccess = () => {
|
|
1431
|
+
if (this.isLoggingEnabled) {
|
|
1432
|
+
console.log('[IndexedDB] Batch action request successful:', { result: request.result });
|
|
1433
|
+
}
|
|
1434
|
+
resolveRequest(request.result);
|
|
1435
|
+
};
|
|
1436
|
+
request.onerror = () => {
|
|
1437
|
+
console.error('[IndexedDB] Batch action request error:', request.error);
|
|
1438
|
+
rejectRequest(request.error);
|
|
1439
|
+
};
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
};
|
|
1443
|
+
transaction.oncomplete = () => {
|
|
1444
|
+
if (this.isLoggingEnabled) {
|
|
1445
|
+
console.log('[IndexedDB] Batch transaction complete.');
|
|
1446
|
+
}
|
|
1447
|
+
Promise.all(promises).then(() => resolve(results));
|
|
1448
|
+
};
|
|
1449
|
+
transaction.onabort = () => {
|
|
1450
|
+
var _a;
|
|
1451
|
+
console.error('[IndexedDB] Batch transaction aborted:', transaction.error);
|
|
1452
|
+
reject((_a = transaction.error) !== null && _a !== void 0 ? _a : new Error('Transaction aborted'));
|
|
1453
|
+
};
|
|
1454
|
+
transaction.onerror = () => {
|
|
1455
|
+
console.error('[IndexedDB] Batch transaction error:', transaction.error);
|
|
1456
|
+
reject(transaction.error);
|
|
1457
|
+
};
|
|
1458
|
+
actions.forEach((action, index) => {
|
|
1459
|
+
const promise = action(tempDbInstance)
|
|
1460
|
+
.then(result => {
|
|
1461
|
+
results[index] = result;
|
|
1462
|
+
})
|
|
1463
|
+
.catch(err => {
|
|
1464
|
+
if (!transaction.error) {
|
|
1465
|
+
transaction.abort();
|
|
1466
|
+
}
|
|
1467
|
+
reject(err);
|
|
1468
|
+
});
|
|
1469
|
+
promises.push(promise);
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
async extractStoreNamesFromActions(actions) {
|
|
1474
|
+
const storeNamesSet = new Set();
|
|
1475
|
+
const storeNameCollector = new Proxy(this, {
|
|
1476
|
+
get: (target, prop) => {
|
|
1477
|
+
if (['add', 'get', 'getAll', 'update', 'delete', 'deleteByRange', 'getAllByRange', 'getAllByIndex'].includes(prop)) {
|
|
1478
|
+
return (storeName) => {
|
|
1479
|
+
storeNamesSet.add(storeName);
|
|
1480
|
+
return Promise.resolve();
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
return target[prop];
|
|
1484
|
+
},
|
|
1485
|
+
});
|
|
1486
|
+
await Promise.all(actions.map(action => action(storeNameCollector)));
|
|
1487
|
+
return Array.from(storeNamesSet);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
class KritzelWorkspace {
|
|
1492
|
+
constructor(id, name, viewport = { translateX: 0, translateY: 0, scale: 1 }) {
|
|
1493
|
+
this.id = id;
|
|
1494
|
+
this.name = name;
|
|
1495
|
+
this.createdAt = new Date();
|
|
1496
|
+
this.updatedAt = new Date();
|
|
1497
|
+
this.viewport = viewport;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1293
1501
|
class KritzelStore {
|
|
1294
1502
|
get history() {
|
|
1295
1503
|
return this._history;
|
|
1296
1504
|
}
|
|
1505
|
+
get database() {
|
|
1506
|
+
return this._database;
|
|
1507
|
+
}
|
|
1297
1508
|
get state() {
|
|
1298
1509
|
return this._state;
|
|
1299
1510
|
}
|
|
@@ -1312,12 +1523,16 @@ class KritzelStore {
|
|
|
1312
1523
|
get offsetY() {
|
|
1313
1524
|
return this._state.host.getBoundingClientRect().top;
|
|
1314
1525
|
}
|
|
1526
|
+
get isDisabled() {
|
|
1527
|
+
return this._state.isEnabled === false || this._state.isReady === false || this._state.activeWorkspace === null;
|
|
1528
|
+
}
|
|
1315
1529
|
constructor(kritzelEngine) {
|
|
1316
1530
|
this._listeners = new Map();
|
|
1317
1531
|
this.objects = [];
|
|
1318
1532
|
this._state = DEFAULT_ENGINE_STATE;
|
|
1319
1533
|
this._kritzelEngine = kritzelEngine;
|
|
1320
1534
|
this._history = new KritzelHistory(this);
|
|
1535
|
+
this._database = new KritzelDatabase('kritzelDB', 1, this._state.debugInfo.logDatabase);
|
|
1321
1536
|
this._state.objectsOctree = new KritzelOctree({
|
|
1322
1537
|
x: -Infinity,
|
|
1323
1538
|
y: -Infinity,
|
|
@@ -1327,16 +1542,135 @@ class KritzelStore {
|
|
|
1327
1542
|
depth: Infinity,
|
|
1328
1543
|
});
|
|
1329
1544
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1545
|
+
async initializeDatabase() {
|
|
1546
|
+
await this._database.open([
|
|
1547
|
+
{
|
|
1548
|
+
name: 'objects',
|
|
1549
|
+
options: { keyPath: ['workspaceId', 'id'] },
|
|
1550
|
+
},
|
|
1551
|
+
{ name: 'workspaces', options: { keyPath: 'id' } },
|
|
1552
|
+
]);
|
|
1553
|
+
this.rerender();
|
|
1554
|
+
}
|
|
1555
|
+
async initializeWorkspace(workspace) {
|
|
1556
|
+
var _a;
|
|
1557
|
+
const workspaces = await this.getWorkspaces();
|
|
1558
|
+
const mostRecentWorkspace = [...workspaces].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0];
|
|
1559
|
+
const fallbackWorkspace = new KritzelWorkspace(ObjectHelper.generateUUID(), 'New Workspace');
|
|
1560
|
+
this._state.activeWorkspace = (_a = workspace !== null && workspace !== void 0 ? workspace : mostRecentWorkspace) !== null && _a !== void 0 ? _a : fallbackWorkspace;
|
|
1561
|
+
const isExistingWorkspace = await this.getWorkspace(this._state.activeWorkspace.id);
|
|
1562
|
+
if (isExistingWorkspace) {
|
|
1563
|
+
await this.updateWorkspace(this._state.activeWorkspace);
|
|
1564
|
+
}
|
|
1565
|
+
else {
|
|
1566
|
+
await this.createWorkspace(this._state.activeWorkspace);
|
|
1567
|
+
}
|
|
1568
|
+
this._state.workspaces = await this.getWorkspaces();
|
|
1569
|
+
this.state.translateX = this._state.activeWorkspace.viewport.translateX;
|
|
1570
|
+
this.state.translateY = this._state.activeWorkspace.viewport.translateY;
|
|
1571
|
+
this.state.scale = this._state.activeWorkspace.viewport.scale;
|
|
1572
|
+
await this.initializeWorkspaceObjects(this._state.activeWorkspace.id);
|
|
1573
|
+
}
|
|
1574
|
+
async initializeWorkspaceObjects(workspaceId) {
|
|
1575
|
+
this._state.objectsOctree.reset();
|
|
1576
|
+
this._history.reset();
|
|
1577
|
+
const objectsFromDb = await this._database.getAllByRange('objects', IDBKeyRange.bound([workspaceId], [workspaceId, '\uffff']));
|
|
1578
|
+
const reviver = new KritzelReviver(this);
|
|
1579
|
+
objectsFromDb.forEach(element => {
|
|
1580
|
+
const revivedObject = reviver.revive(element);
|
|
1581
|
+
this._state.objectsOctree.insert(revivedObject);
|
|
1582
|
+
});
|
|
1583
|
+
this.rerender();
|
|
1584
|
+
}
|
|
1585
|
+
async updateWorkspaceViewport(translateX, translateY, scale) {
|
|
1586
|
+
if (!this.state.activeWorkspace) {
|
|
1587
|
+
throw new Error('Workspace not initialized');
|
|
1588
|
+
}
|
|
1589
|
+
this.state.activeWorkspace.viewport = {
|
|
1590
|
+
translateX,
|
|
1591
|
+
translateY,
|
|
1592
|
+
scale,
|
|
1338
1593
|
};
|
|
1339
|
-
this.
|
|
1594
|
+
this.state.activeWorkspace.updatedAt = new Date();
|
|
1595
|
+
await this._database.update('workspaces', this.state.activeWorkspace);
|
|
1596
|
+
}
|
|
1597
|
+
async addObjectToDatabase(object) {
|
|
1598
|
+
if (!this._database) {
|
|
1599
|
+
throw new Error('Database not initialized');
|
|
1600
|
+
}
|
|
1601
|
+
if (!this.state.activeWorkspace) {
|
|
1602
|
+
throw new Error('Workspace not initialized');
|
|
1603
|
+
}
|
|
1604
|
+
this.state.activeWorkspace.updatedAt = new Date();
|
|
1605
|
+
await this._database.batch([db => db.add('objects', object), db => db.update('workspaces', this.state.activeWorkspace)]).catch(err => {
|
|
1606
|
+
console.error('Error adding object to database:', err);
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
async updateObjectInDatabase(object) {
|
|
1610
|
+
if (!this._database) {
|
|
1611
|
+
throw new Error('Database not initialized');
|
|
1612
|
+
}
|
|
1613
|
+
if (!this.state.activeWorkspace) {
|
|
1614
|
+
throw new Error('Workspace not initialized');
|
|
1615
|
+
}
|
|
1616
|
+
this.state.activeWorkspace.updatedAt = new Date();
|
|
1617
|
+
await this._database.batch([db => db.update('objects', object), db => db.update('workspaces', this.state.activeWorkspace)]).catch(err => {
|
|
1618
|
+
console.error('Error updating object in database:', err);
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
async deleteObjectFromDatabase(objectId) {
|
|
1622
|
+
if (!this._database) {
|
|
1623
|
+
throw new Error('Database not initialized');
|
|
1624
|
+
}
|
|
1625
|
+
if (!this.state.activeWorkspace) {
|
|
1626
|
+
throw new Error('Workspace not initialized');
|
|
1627
|
+
}
|
|
1628
|
+
this.state.activeWorkspace.updatedAt = new Date();
|
|
1629
|
+
await this._database.batch([db => db.delete('objects', [this.state.activeWorkspace.id, objectId]), db => db.update('workspaces', this.state.activeWorkspace)]).catch(err => {
|
|
1630
|
+
console.error('Error deleting object from database:', err);
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
getWorkspace(id) {
|
|
1634
|
+
if (!this._database) {
|
|
1635
|
+
throw new Error('Database not initialized');
|
|
1636
|
+
}
|
|
1637
|
+
return this._database.get('workspaces', id);
|
|
1638
|
+
}
|
|
1639
|
+
getWorkspaces() {
|
|
1640
|
+
if (!this._database) {
|
|
1641
|
+
throw new Error('Database not initialized');
|
|
1642
|
+
}
|
|
1643
|
+
return this._database.getAll('workspaces');
|
|
1644
|
+
}
|
|
1645
|
+
async createWorkspace(workspace) {
|
|
1646
|
+
if (!this._database) {
|
|
1647
|
+
throw new Error('Database not initialized');
|
|
1648
|
+
}
|
|
1649
|
+
workspace.createdAt = new Date();
|
|
1650
|
+
workspace.updatedAt = new Date();
|
|
1651
|
+
await this._database.add('workspaces', workspace);
|
|
1652
|
+
this.state.workspaces.push(workspace);
|
|
1653
|
+
}
|
|
1654
|
+
async updateWorkspace(workspace) {
|
|
1655
|
+
if (!this._database) {
|
|
1656
|
+
throw new Error('Database not initialized');
|
|
1657
|
+
}
|
|
1658
|
+
workspace.updatedAt = new Date();
|
|
1659
|
+
await this._database.update('workspaces', workspace);
|
|
1660
|
+
const index = this.state.workspaces.findIndex(w => w.id === workspace.id);
|
|
1661
|
+
if (index !== -1) {
|
|
1662
|
+
this.state.workspaces[index] = workspace;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
async deleteWorkspace(workspace) {
|
|
1666
|
+
if (!this._database) {
|
|
1667
|
+
throw new Error('Database not initialized');
|
|
1668
|
+
}
|
|
1669
|
+
const objectRange = IDBKeyRange.bound([workspace.id], [workspace.id, '\uffff']);
|
|
1670
|
+
await this._database.deleteByRange('objects', objectRange);
|
|
1671
|
+
await this._database.delete('workspaces', workspace.id);
|
|
1672
|
+
}
|
|
1673
|
+
rerender() {
|
|
1340
1674
|
if (this._kritzelEngine) {
|
|
1341
1675
|
this._kritzelEngine.forceUpdate++;
|
|
1342
1676
|
}
|
|
@@ -1378,17 +1712,11 @@ class KritzelStore {
|
|
|
1378
1712
|
const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];
|
|
1379
1713
|
this.history.executeCommand(new BatchCommand(this, this.state.selectionGroup, commands));
|
|
1380
1714
|
}
|
|
1381
|
-
deleteObject(id,
|
|
1715
|
+
deleteObject(id, skipHistory = false) {
|
|
1382
1716
|
const object = this.findObjectById(id);
|
|
1383
1717
|
if (object) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
this.history.executeCommand(removeObjectCommand);
|
|
1387
|
-
}
|
|
1388
|
-
else {
|
|
1389
|
-
this._state.objectsOctree.remove(obj => obj.id === id);
|
|
1390
|
-
this.rerender();
|
|
1391
|
-
}
|
|
1718
|
+
const removeObjectCommand = new RemoveObjectCommand(this, this, object, skipHistory);
|
|
1719
|
+
this.history.executeCommand(removeObjectCommand);
|
|
1392
1720
|
}
|
|
1393
1721
|
}
|
|
1394
1722
|
copy() {
|
|
@@ -1502,8 +1830,7 @@ class KritzelStore {
|
|
|
1502
1830
|
}
|
|
1503
1831
|
resetActiveText() {
|
|
1504
1832
|
if (this.state.activeText && this.state.activeText.value === ' ') {
|
|
1505
|
-
this.deleteObject(this.state.activeText.id,
|
|
1506
|
-
this.history.undoStack.pop();
|
|
1833
|
+
this.deleteObject(this.state.activeText.id, true);
|
|
1507
1834
|
}
|
|
1508
1835
|
this.state.activeText = null;
|
|
1509
1836
|
}
|
|
@@ -1570,7 +1897,6 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
1570
1897
|
}
|
|
1571
1898
|
handleKeyDown(event) {
|
|
1572
1899
|
if (this._store.state.isFocused === false) {
|
|
1573
|
-
event.preventDefault();
|
|
1574
1900
|
return;
|
|
1575
1901
|
}
|
|
1576
1902
|
this._store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
@@ -1689,13 +2015,18 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
1689
2015
|
|
|
1690
2016
|
class KritzelClassHelper {
|
|
1691
2017
|
static isInstanceOf(object, className) {
|
|
1692
|
-
return object.__class__ === className;
|
|
2018
|
+
return !!object && object.__class__ === className;
|
|
1693
2019
|
}
|
|
1694
2020
|
}
|
|
1695
2021
|
|
|
1696
2022
|
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
|
|
1697
2023
|
|
|
1698
2024
|
const KritzelEngine = class {
|
|
2025
|
+
onWorkspaceChange(newWorkspace) {
|
|
2026
|
+
if (newWorkspace) {
|
|
2027
|
+
this.store.initializeWorkspace(newWorkspace);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
1699
2030
|
validateScaleMax(newValue) {
|
|
1700
2031
|
if (newValue > ABSOLUTE_SCALE_MAX) {
|
|
1701
2032
|
console.warn(`scaleMax cannot be greater than ${ABSOLUTE_SCALE_MAX}.`);
|
|
@@ -1726,6 +2057,7 @@ const KritzelEngine = class {
|
|
|
1726
2057
|
registerInstance(this, hostRef);
|
|
1727
2058
|
this.isEngineReady = createEvent(this, "isEngineReady");
|
|
1728
2059
|
this.activeToolChange = createEvent(this, "activeToolChange");
|
|
2060
|
+
this.workspacesChange = createEvent(this, "workspacesChange");
|
|
1729
2061
|
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
1730
2062
|
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
1731
2063
|
this.forceUpdate = 0;
|
|
@@ -1736,18 +2068,23 @@ const KritzelEngine = class {
|
|
|
1736
2068
|
this.validateScaleMax(this.scaleMax);
|
|
1737
2069
|
this.validateScaleMin(this.scaleMin);
|
|
1738
2070
|
}
|
|
1739
|
-
componentDidLoad() {
|
|
2071
|
+
async componentDidLoad() {
|
|
1740
2072
|
this.contextMenuHandler = new KritzelContextMenuHandler(this.store, this.globalContextMenuItems, this.objectContextMenuItems);
|
|
1741
2073
|
this.keyHandler = new KritzelKeyHandler(this.store);
|
|
1742
2074
|
this.viewport = new KritzelViewport(this.store, this.host);
|
|
1743
2075
|
this._registerStateChangeListeners();
|
|
2076
|
+
await this.store.initializeDatabase();
|
|
2077
|
+
await this.store.initializeWorkspace(this.workspace);
|
|
1744
2078
|
if (this.store.state.isReady === false) {
|
|
1745
2079
|
this.store.state.isReady = true;
|
|
1746
|
-
this.isEngineReady.emit();
|
|
2080
|
+
this.isEngineReady.emit(this.store.state);
|
|
1747
2081
|
}
|
|
1748
2082
|
}
|
|
1749
2083
|
handleWheel(ev) {
|
|
1750
2084
|
var _a, _b;
|
|
2085
|
+
if (this.store.isDisabled) {
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
1751
2088
|
if (this.store.state.isContextMenuVisible) {
|
|
1752
2089
|
this.hideContextMenu();
|
|
1753
2090
|
}
|
|
@@ -1756,11 +2093,11 @@ const KritzelEngine = class {
|
|
|
1756
2093
|
}
|
|
1757
2094
|
handlePointerDown(ev) {
|
|
1758
2095
|
var _a, _b;
|
|
1759
|
-
if (
|
|
1760
|
-
this.hideContextMenu();
|
|
2096
|
+
if (this.store.isDisabled) {
|
|
1761
2097
|
return;
|
|
1762
2098
|
}
|
|
1763
|
-
if (this.store.state.
|
|
2099
|
+
if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
|
|
2100
|
+
this.hideContextMenu();
|
|
1764
2101
|
return;
|
|
1765
2102
|
}
|
|
1766
2103
|
KritzelEventHelper.onLongTouchPress(ev, (event) => {
|
|
@@ -1776,7 +2113,7 @@ const KritzelEngine = class {
|
|
|
1776
2113
|
}
|
|
1777
2114
|
handlePointerMove(ev) {
|
|
1778
2115
|
var _a, _b;
|
|
1779
|
-
if (this.store.
|
|
2116
|
+
if (this.store.isDisabled) {
|
|
1780
2117
|
return;
|
|
1781
2118
|
}
|
|
1782
2119
|
this.store.state.pointers.set(ev.pointerId, ev);
|
|
@@ -1785,7 +2122,7 @@ const KritzelEngine = class {
|
|
|
1785
2122
|
}
|
|
1786
2123
|
handlePointerUp(ev) {
|
|
1787
2124
|
var _a, _b;
|
|
1788
|
-
if (this.store.
|
|
2125
|
+
if (this.store.isDisabled) {
|
|
1789
2126
|
return;
|
|
1790
2127
|
}
|
|
1791
2128
|
this.store.state.pointers.delete(ev.pointerId);
|
|
@@ -1795,7 +2132,7 @@ const KritzelEngine = class {
|
|
|
1795
2132
|
}
|
|
1796
2133
|
handlePointerCancel(ev) {
|
|
1797
2134
|
var _a, _b;
|
|
1798
|
-
if (this.store.
|
|
2135
|
+
if (this.store.isDisabled) {
|
|
1799
2136
|
return;
|
|
1800
2137
|
}
|
|
1801
2138
|
this.host.releasePointerCapture(ev.pointerId);
|
|
@@ -1805,7 +2142,7 @@ const KritzelEngine = class {
|
|
|
1805
2142
|
}
|
|
1806
2143
|
handleContextMenu(ev) {
|
|
1807
2144
|
ev.preventDefault();
|
|
1808
|
-
if (this.store.
|
|
2145
|
+
if (this.store.isDisabled) {
|
|
1809
2146
|
return;
|
|
1810
2147
|
}
|
|
1811
2148
|
if (ev.pointerType === 'touch') {
|
|
@@ -1823,6 +2160,9 @@ const KritzelEngine = class {
|
|
|
1823
2160
|
this.keyHandler.handleKeyUp(ev);
|
|
1824
2161
|
}
|
|
1825
2162
|
updateFocus(ev) {
|
|
2163
|
+
if (this.store.isDisabled) {
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
1826
2166
|
const rect = this.store.state.host.getBoundingClientRect();
|
|
1827
2167
|
const isInside = ev.clientX >= rect.left && ev.clientX <= rect.right && ev.clientY >= rect.top && ev.clientY <= rect.bottom;
|
|
1828
2168
|
const path = ev.composedPath();
|
|
@@ -1830,6 +2170,9 @@ const KritzelEngine = class {
|
|
|
1830
2170
|
const isInKritzelEngine = path.includes(kritzelEngineElement || this.host);
|
|
1831
2171
|
this.store.setState('isFocused', isInside && isInKritzelEngine);
|
|
1832
2172
|
}
|
|
2173
|
+
handleClick() {
|
|
2174
|
+
this.enable();
|
|
2175
|
+
}
|
|
1833
2176
|
async registerTool(toolName, toolClass, toolConfig) {
|
|
1834
2177
|
if (typeof toolClass !== 'function' || !(toolClass.prototype instanceof KritzelBaseTool)) {
|
|
1835
2178
|
console.error(`Failed to register tool "${toolName}": Tool class must be a constructor function`);
|
|
@@ -1951,6 +2294,24 @@ const KritzelEngine = class {
|
|
|
1951
2294
|
var _a;
|
|
1952
2295
|
return ((_a = this.store.state.copiedObjects) === null || _a === void 0 ? void 0 : _a.objects) || [];
|
|
1953
2296
|
}
|
|
2297
|
+
async createWorkspace(workspace) {
|
|
2298
|
+
return this.store.createWorkspace(workspace).then(() => {
|
|
2299
|
+
this.workspacesChange.emit(this.store.state.workspaces);
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
async updateWorkspace(workspace) {
|
|
2303
|
+
return this.store.updateWorkspace(workspace).then(() => {
|
|
2304
|
+
this.workspacesChange.emit(this.store.state.workspaces);
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
async deleteWorkspace(workspace) {
|
|
2308
|
+
return this.store.deleteWorkspace(workspace).then(() => {
|
|
2309
|
+
this.workspacesChange.emit(this.store.state.workspaces.filter(ws => ws.id !== workspace.id));
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
async getWorkspaces() {
|
|
2313
|
+
return this.store.getWorkspaces();
|
|
2314
|
+
}
|
|
1954
2315
|
_registerStateChangeListeners() {
|
|
1955
2316
|
this.store.onStateChange('activeTool', this._handleActiveToolChange.bind(this));
|
|
1956
2317
|
this.store.onStateChange('isFocused', this._handleIsFocusedChange.bind(this));
|
|
@@ -1969,25 +2330,27 @@ const KritzelEngine = class {
|
|
|
1969
2330
|
}
|
|
1970
2331
|
}
|
|
1971
2332
|
render() {
|
|
1972
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
2333
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
1973
2334
|
const computedStyle = window.getComputedStyle(this.host);
|
|
1974
2335
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
1975
2336
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
1976
2337
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
1977
|
-
return (h(Host, { key: '
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
_o.
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2338
|
+
return (h(Host, { key: 'c7e747aa6106e7904cf9f44db37fa285a6fb4434' }, h("div", { key: 'b75652ab9f9531dce765cbe448ad3131c172d06a', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: 'fd1355bd640b9296949f6bbcf084589578654db6' }, "ActiveWorkspaceId: ", (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeWorkspace) === null || _b === void 0 ? void 0 :
|
|
2339
|
+
_b.id), h("div", { key: '8520e3e774e97ebc42ee86401fbfbafbe41c88e8' }, "ActiveWorkspaceName: ", (_d = (_c = this.store.state) === null || _c === void 0 ? void 0 : _c.activeWorkspace) === null || _d === void 0 ? void 0 :
|
|
2340
|
+
_d.name), h("div", { key: 'f247b4d76cd018e787a9b59829deedeb6c5c5272' }, "TranslateX: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
2341
|
+
_e.translateX), h("div", { key: 'e0438479bc9e950ef2cbe88ed0aa0b8ec1888890' }, "TranslateY: ", (_f = this.store.state) === null || _f === void 0 ? void 0 :
|
|
2342
|
+
_f.translateY), h("div", { key: '1735fde66588e285039bcc090dee71630608d666' }, "ViewportWidth: ", (_g = this.store.state) === null || _g === void 0 ? void 0 :
|
|
2343
|
+
_g.viewportWidth), h("div", { key: '15f8b3305c27a395b8aa6463c5acec42bb3e3ddd' }, "ViewportHeight: ", (_h = this.store.state) === null || _h === void 0 ? void 0 :
|
|
2344
|
+
_h.viewportHeight), h("div", { key: 'd2e39bae191c7256967d0140f38e75dccf95f24c' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: 'cd3f53ff4a8f119a2ef975133f69fc3798fe0f71' }, "Scale: ", (_j = this.store.state) === null || _j === void 0 ? void 0 :
|
|
2345
|
+
_j.scale), h("div", { key: 'b1f8c77589a80fe49d0947602bda46438921f7a8' }, "ActiveTool: ", (_l = (_k = this.store.state) === null || _k === void 0 ? void 0 : _k.activeTool) === null || _l === void 0 ? void 0 :
|
|
2346
|
+
_l.name), h("div", { key: '41cd94f58f71cd5c1cffc679ada5fc51f6ceeea7' }, "HasViewportChanged: ", ((_m = this.store.state) === null || _m === void 0 ? void 0 : _m.hasViewportChanged) ? 'true' : 'false'), h("div", { key: 'bf8495bb924673aad3a9ca57ed0bf9ac23874dfb' }, "IsEnabled: ", ((_o = this.store.state) === null || _o === void 0 ? void 0 : _o.isEnabled) ? 'true' : 'false'), h("div", { key: '3823936f5b46b100742f94fac8d7e87ed93ddb58' }, "IsScaling: ", ((_p = this.store.state) === null || _p === void 0 ? void 0 : _p.isScaling) ? 'true' : 'false'), h("div", { key: '62eb836fff78b050cdab8cbef54f88f9d5b644ba' }, "IsPanning: ", ((_q = this.store.state) === null || _q === void 0 ? void 0 : _q.isPanning) ? 'true' : 'false'), h("div", { key: 'dac6b8d18ae8f6317bdd318ad48a9612f9942613' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: 'af232e2cd738e255029f5611531c246ac63a28ce' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '95a44fef4b6befe95bfadfc62957103b48bf76b6' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: 'e8162d4de449a0d6756c2f540fca28353c193438' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '4440d023cd4982c834736e06863698c3baf72353' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'd3e467dd18e53850df4d5bedf2b69f54b1fbe5c6' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: 'df6e4bca16cbe4346786a544d6f6c53d87bdb699' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: '532aebf1ff35cc578f12e36cdaf00713ffc76b97' }, "PointerX: ", (_r = this.store.state) === null || _r === void 0 ? void 0 :
|
|
2347
|
+
_r.pointerX), h("div", { key: 'f710f8c8d27979da4a40e50452e2cdd63cdefa98' }, "PointerY: ", (_s = this.store.state) === null || _s === void 0 ? void 0 :
|
|
2348
|
+
_s.pointerY), h("div", { key: '0175010e1d5a22be81ca0b2d88dd1aff217eacfd' }, "SelectedObjects: ", ((_t = this.store.state.selectionGroup) === null || _t === void 0 ? void 0 : _t.objects.length) || 0)), h("div", { key: 'dc2964c479405ed147bd5f090e24262595a474e2', id: "origin", class: "origin", style: {
|
|
2349
|
+
transform: `matrix(${(_u = this.store.state) === null || _u === void 0 ? void 0 : _u.scale}, 0, 0, ${(_v = this.store.state) === null || _v === void 0 ? void 0 : _v.scale}, ${(_w = this.store.state) === null || _w === void 0 ? void 0 : _w.translateX}, ${(_x = this.store.state) === null || _x === void 0 ? void 0 : _x.translateY})`,
|
|
2350
|
+
} }, (_y = this.store.state.objectsOctree.allObjects()) === null || _y === void 0 ? void 0 :
|
|
2351
|
+
_y.map(object => {
|
|
1989
2352
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1990
|
-
return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg",
|
|
2353
|
+
return (h("div", { key: object.id, style: { display: object.isInViewport() ? 'block' : 'none', transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", id: object.id, class: "object", style: {
|
|
1991
2354
|
height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
|
|
1992
2355
|
width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
|
|
1993
2356
|
left: '0',
|
|
@@ -2006,17 +2369,17 @@ const KritzelEngine = class {
|
|
|
2006
2369
|
borderStyle: 'solid',
|
|
2007
2370
|
padding: object.padding + 'px',
|
|
2008
2371
|
overflow: 'visible',
|
|
2009
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => el ? object.mount(el) : object.unmount(), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2372
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => (el ? object.mount(el) : object.unmount()), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2010
2373
|
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
2011
2374
|
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
2012
2375
|
position: 'absolute',
|
|
2013
2376
|
overflow: 'visible',
|
|
2014
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => el ? object.mount(el) : object.unmount(), src: object.src, style: {
|
|
2377
|
+
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => (el ? object.mount(el) : object.unmount()), src: object.src, style: {
|
|
2015
2378
|
width: '100%',
|
|
2016
2379
|
height: '100%',
|
|
2017
2380
|
userSelect: 'none',
|
|
2018
2381
|
pointerEvents: 'none',
|
|
2019
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => el ? object.mount(el) : object.unmount(), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
2382
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => (el ? object.mount(el) : object.unmount()), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
2020
2383
|
width: '100%',
|
|
2021
2384
|
height: '100%',
|
|
2022
2385
|
color: object.fontColor,
|
|
@@ -2032,16 +2395,16 @@ const KritzelEngine = class {
|
|
|
2032
2395
|
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
2033
2396
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
2034
2397
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
2035
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2398
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => (el ? object.mount(el) : object.unmount()), style: {
|
|
2036
2399
|
width: '100%',
|
|
2037
2400
|
height: '100%',
|
|
2038
2401
|
pointerEvents: 'auto',
|
|
2039
2402
|
overflow: 'hidden',
|
|
2040
2403
|
display: 'block',
|
|
2041
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2404
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (h("div", { ref: el => (el ? object.mount(el) : object.unmount()), style: {
|
|
2042
2405
|
width: '100%',
|
|
2043
2406
|
height: '100%',
|
|
2044
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2407
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => (el ? object.mount(el) : object.unmount()), style: {
|
|
2045
2408
|
width: '100%',
|
|
2046
2409
|
height: '100%',
|
|
2047
2410
|
} }))), h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
@@ -2085,17 +2448,17 @@ const KritzelEngine = class {
|
|
|
2085
2448
|
fill: 'transparent',
|
|
2086
2449
|
cursor: 'grab',
|
|
2087
2450
|
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation), h("div", { style: { whiteSpace: 'nowrap' } }, "x: ", object.x), h("div", { style: { whiteSpace: 'nowrap' } }, "y: ", object.y)))))));
|
|
2088
|
-
}), h("svg", { key: '
|
|
2089
|
-
height: (
|
|
2090
|
-
width: (
|
|
2451
|
+
}), h("svg", { key: '86f9a08bea3ac2d261b14b2eec471fafd20ca11f', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2452
|
+
height: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.height.toString(),
|
|
2453
|
+
width: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.width.toString(),
|
|
2091
2454
|
left: '0',
|
|
2092
2455
|
top: '0',
|
|
2093
|
-
zIndex: (
|
|
2456
|
+
zIndex: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.zIndex.toString(),
|
|
2094
2457
|
position: 'absolute',
|
|
2095
|
-
transform: (
|
|
2458
|
+
transform: (_2 = this.store.state.currentPath) === null || _2 === void 0 ? void 0 : _2.transformationMatrix,
|
|
2096
2459
|
transformOrigin: 'top left',
|
|
2097
2460
|
overflow: 'visible',
|
|
2098
|
-
}, viewBox: (
|
|
2461
|
+
}, viewBox: (_3 = this.store.state.currentPath) === null || _3 === void 0 ? void 0 : _3.viewBox }, h("path", { key: '66ebcf1791c993d62b34a2e4da1d4279428a17dd', d: (_4 = this.store.state.currentPath) === null || _4 === void 0 ? void 0 : _4.d, fill: (_5 = this.store.state.currentPath) === null || _5 === void 0 ? void 0 : _5.fill, stroke: (_6 = this.store.state.currentPath) === null || _6 === void 0 ? void 0 : _6.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: 'af91784e3afc84b71d5186237d287c31d472d80a', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, objects: ((_7 = this.store.state.selectionGroup) === null || _7 === void 0 ? void 0 : _7.objects) || [], style: {
|
|
2099
2462
|
position: 'fixed',
|
|
2100
2463
|
left: `${this.store.state.contextMenuX}px`,
|
|
2101
2464
|
top: `${this.store.state.contextMenuY}px`,
|
|
@@ -2107,10 +2470,11 @@ const KritzelEngine = class {
|
|
|
2107
2470
|
y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
|
|
2108
2471
|
}, (_a = this.store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects);
|
|
2109
2472
|
this.hideContextMenu();
|
|
2110
|
-
} })), ((
|
|
2473
|
+
} })), ((_8 = this.store.state) === null || _8 === void 0 ? void 0 : _8.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '573a4422b742044df5f240b260bc66e83d004520', store: this.store })));
|
|
2111
2474
|
}
|
|
2112
2475
|
get host() { return getElement(this); }
|
|
2113
2476
|
static get watchers() { return {
|
|
2477
|
+
"workspace": ["onWorkspaceChange"],
|
|
2114
2478
|
"scaleMax": ["validateScaleMax"],
|
|
2115
2479
|
"scaleMin": ["validateScaleMin"]
|
|
2116
2480
|
}; }
|
|
@@ -2127,7 +2491,7 @@ const KritzelFont = class {
|
|
|
2127
2491
|
this.color = '#000000';
|
|
2128
2492
|
}
|
|
2129
2493
|
render() {
|
|
2130
|
-
return (h(Host, { key: '
|
|
2494
|
+
return (h(Host, { key: 'd318355704f1bf66468dd793e5e38da827076d3b' }, h("div", { key: '447b4fba97f5d1900060859943438733667aed08', class: "font-preview", style: {
|
|
2131
2495
|
fontFamily: this.fontFamily,
|
|
2132
2496
|
fontSize: `${this.size}px`,
|
|
2133
2497
|
color: this.color
|
|
@@ -2172,12 +2536,12 @@ const KritzelFontFamily = class {
|
|
|
2172
2536
|
label: option.label,
|
|
2173
2537
|
style: { fontFamily: option.value },
|
|
2174
2538
|
}));
|
|
2175
|
-
return (h(Host, { key: '
|
|
2539
|
+
return (h(Host, { key: '801b1dbc2b7da7d00fb00ed6a8d8ee7be3e9ef17' }, h("kritzel-dropdown", { key: '5f774c0b31ca16a1c8acda1c73ea3aacc2784649', options: dropdownOptions, value: this.selectedFontFamily, onValueChanged: this.handleDropdownValueChange, selectStyles: { fontFamily: this.selectedFontFamily } }, h("button", { key: '3c101155ff08854f665750f8988fb3691a77c04a', class: "font-style-button", slot: "suffix" }, "B"), h("button", { key: '48d2ead137a8a35f06fb8b5487431e2ce613c755', class: "font-style-button italic-text", slot: "suffix" }, "I"))));
|
|
2176
2540
|
}
|
|
2177
2541
|
};
|
|
2178
2542
|
KritzelFontFamily.style = kritzelFontFamilyCss;
|
|
2179
2543
|
|
|
2180
|
-
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, #
|
|
2544
|
+
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)}";
|
|
2181
2545
|
|
|
2182
2546
|
const KritzelFontSize = class {
|
|
2183
2547
|
constructor(hostRef) {
|
|
@@ -2192,7 +2556,7 @@ const KritzelFontSize = class {
|
|
|
2192
2556
|
this.sizeChange.emit(size);
|
|
2193
2557
|
}
|
|
2194
2558
|
render() {
|
|
2195
|
-
return (h(Host, { key: '
|
|
2559
|
+
return (h(Host, { key: '08571feed86b37208956608b170ca1f782b7fb18' }, this.sizes.map(size => (h("div", { class: {
|
|
2196
2560
|
'size-container': true,
|
|
2197
2561
|
'selected': this.selectedSize === size,
|
|
2198
2562
|
}, onClick: () => this.handleSizeClick(size) }, h("kritzel-font", { fontFamily: this.fontFamily, size: size }))))));
|
|
@@ -2222,7 +2586,322 @@ const KritzelIcon = class {
|
|
|
2222
2586
|
};
|
|
2223
2587
|
KritzelIcon.style = kritzelIconCss;
|
|
2224
2588
|
|
|
2225
|
-
const
|
|
2589
|
+
const kritzelMenuCss = ":host{display:flex;flex-direction:column;min-width:180px;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 12px);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:2;gap:var(--kritzel-menu-item-gap, 4px);overflow-y:auto;scrollbar-color:#ebebeb transparent;scrollbar-width:thin}:host(.mobile){--kritzel-menu-item-button-hover-background-color:transparent;--kritzel-menu-item-button-focus-background-color:transparent}button{all:unset;background:transparent;border:0;padding:0;margin:0;font:inherit;color:inherit;line-height:inherit;text-align:inherit;cursor:pointer;appearance:none;-webkit-appearance:none;-moz-appearance:none;border-radius:0;-webkit-tap-highlight-color:transparent}button:focus{outline:none}:host(:focus){outline:none}.menu-item{display:flex;align-items:center;justify-content:space-between;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-family:sans-serif;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);gap:var(--kritzel-context-menu-item-gap, 12px)}.menu-item:focus,.menu-item:focus-within{outline:none;background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menu-item:not(.disabled):not(.active):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):not(.active):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.active{color:var(--kritzel-controls-background-color, #ffffff);background-color:var(--kritzel-controls-control-selected-background-color, #007aff)}.menu-item.active kritzel-icon{filter:brightness(0) invert(1)}.menu-item.active:hover{background-color:var(--kritzel-controls-control-selected-hover-background-color, #0075f1)}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);background-color:transparent;cursor:default}.menu-item.child-open{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%)) !important}.menu-item.active.menu-item.child-open{background-color:var(--kritzel-controls-control-selected-active-background-color, #0075f1) !important}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.menu-item.edit-mode input{background:transparent;border:none;outline:none;font-size:inherit;font-family:inherit;color:inherit;padding:0;width:100%;padding:2px 0px;border-bottom:1px solid var(--kritzel-context-menu-item-color, #333333)}.menu-item.active.edit-mode input{border-bottom:1px solid var(--kritzel-controls-background-color, #ffffff)}.menu-item.edit-mode input::selection{background-color:var(--kritzel-controls-control-selected-background-color, #007aff);border-radius:4px;color:var(--kritzel-controls-background-color, #ffffff)}.menu-item.active.edit-mode input::selection{background-color:var(--kritzel-menu-item-selected-input-background-color, #ffffff34)}.menu-item.edit-mode{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item.edit-mode.active{background-color:var(--kritzel-context-menu-item-hover-background-color, #007aff)}.menu-item-button{background:transparent;border:none;outline:none;cursor:pointer;padding:4px;border-radius:8px;display:flex;align-items:center;justify-content:center}.menu-item-button:hover{background-color:var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item-button:focus{background-color:var(--kritzel-menu-item-button-focus-background-color, hsl(0, 0%, 0%, 4.3%))}.edit-container,.view-container{width:100%;display:flex;align-items:center;justify-content:space-between;gap:var(--kritzel-context-menu-item-gap, 4px)}";
|
|
2590
|
+
|
|
2591
|
+
const KritzelMenu = class {
|
|
2592
|
+
constructor(hostRef) {
|
|
2593
|
+
registerInstance(this, hostRef);
|
|
2594
|
+
this.close = createEvent(this, "close");
|
|
2595
|
+
this.items = [];
|
|
2596
|
+
this.parentIndex = null;
|
|
2597
|
+
this.parent = null;
|
|
2598
|
+
this.activeItemIndex = null;
|
|
2599
|
+
this.editingIndex = null;
|
|
2600
|
+
this.openChildMenuIndex = null;
|
|
2601
|
+
this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
2602
|
+
this.childMenuAnchor = null;
|
|
2603
|
+
this.childMenu = null;
|
|
2604
|
+
this.cancelButton = null;
|
|
2605
|
+
this.saveButton = null;
|
|
2606
|
+
}
|
|
2607
|
+
onEditingIndexChange(newValue) {
|
|
2608
|
+
if (newValue === null) {
|
|
2609
|
+
this.openChildMenuIndex = null;
|
|
2610
|
+
this.editInput = undefined;
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
handleWindowClick(event) {
|
|
2615
|
+
requestAnimationFrame(() => {
|
|
2616
|
+
if (this.childMenu === null) {
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const target = event.target;
|
|
2620
|
+
if (!target.contains(this.childMenu)) {
|
|
2621
|
+
this.openChildMenuIndex = null;
|
|
2622
|
+
}
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
handleEscape(event) {
|
|
2626
|
+
var _a;
|
|
2627
|
+
if (event.key === 'Escape') {
|
|
2628
|
+
if (this.openChildMenuIndex !== null) {
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
if (this.editingIndex !== null) {
|
|
2632
|
+
(_a = this.cancelButton) === null || _a === void 0 ? void 0 : _a.click();
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
this.close.emit();
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
handleEnter(event) {
|
|
2639
|
+
var _a;
|
|
2640
|
+
if (event.key === 'Enter') {
|
|
2641
|
+
if (this.editingIndex !== null) {
|
|
2642
|
+
(_a = this.saveButton) === null || _a === void 0 ? void 0 : _a.click();
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
componentDidLoad() {
|
|
2648
|
+
requestAnimationFrame(() => {
|
|
2649
|
+
this.host.focus();
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
isViewMode(index) {
|
|
2653
|
+
return this.editingIndex !== index;
|
|
2654
|
+
}
|
|
2655
|
+
handleSelect(item) {
|
|
2656
|
+
var _a;
|
|
2657
|
+
if (item.disabled || this.editingIndex !== null || this.openChildMenuIndex !== null) {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
(_a = item.select) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
2661
|
+
}
|
|
2662
|
+
render() {
|
|
2663
|
+
return (h(Host, { key: 'b5321fa13564d847a9432eb26e777d33f4b8412c', tabIndex: 0, class: { mobile: this.isTouchDevice } }, this.items.map((item, index) => (h("button", { tabIndex: 0, class: {
|
|
2664
|
+
'menu-item': true,
|
|
2665
|
+
'disabled': item.disabled,
|
|
2666
|
+
'inactive': this.openChildMenuIndex !== null && this.openChildMenuIndex !== index,
|
|
2667
|
+
'child-open': this.openChildMenuIndex === index,
|
|
2668
|
+
'edit-mode': this.editingIndex === index,
|
|
2669
|
+
'active': this.activeItemIndex === index,
|
|
2670
|
+
}, style: {
|
|
2671
|
+
pointerEvents: (this.editingIndex !== null && this.editingIndex !== index) || (this.openChildMenuIndex !== null && this.openChildMenuIndex !== index) ? 'none' : 'auto',
|
|
2672
|
+
}, onClick: () => this.handleSelect(item) }, this.isViewMode(index) === true && (h("div", { class: "view-container" }, h("span", { class: "menu-item-label" }, item.label), h("div", null, item.children && item.children.length > 0 && (h("button", { class: "menu-item-button", tabIndex: 0, onClick: event => {
|
|
2673
|
+
if (this.editingIndex !== null)
|
|
2674
|
+
return;
|
|
2675
|
+
event.stopPropagation();
|
|
2676
|
+
this.childMenuAnchor = this.openChildMenuIndex === index ? null : event.currentTarget;
|
|
2677
|
+
this.openChildMenuIndex = this.openChildMenuIndex === index ? null : index;
|
|
2678
|
+
} }, h("kritzel-icon", { name: "ellipsis-vertical", size: 16 }))), this.openChildMenuIndex === index && (h("kritzel-portal", { anchor: this.childMenuAnchor, offsetY: 4, onClose: () => (this.openChildMenuIndex = null) }, h("kritzel-menu", { ref: el => {
|
|
2679
|
+
this.childMenu = el;
|
|
2680
|
+
}, style: { minWidth: '100px' }, items: item.children, parentIndex: index, parent: item, onClose: () => {
|
|
2681
|
+
var _a;
|
|
2682
|
+
this.openChildMenuIndex = null;
|
|
2683
|
+
(_a = this.childMenuAnchor) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2684
|
+
} })))))), this.isViewMode(index) === false && (h("div", { class: "edit-container" }, h("input", { tabIndex: 0, ref: el => {
|
|
2685
|
+
this.editInput = el;
|
|
2686
|
+
requestAnimationFrame(() => {
|
|
2687
|
+
var _a, _b;
|
|
2688
|
+
(_a = this.editInput) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2689
|
+
(_b = this.editInput) === null || _b === void 0 ? void 0 : _b.select();
|
|
2690
|
+
});
|
|
2691
|
+
}, type: "text", name: 'menu-item-' + index, value: item.label, onInput: e => (item.label = e.target.value) }), h("div", { style: { display: 'flex', gap: '8px' } }, h("div", { class: "menu-item-button", ref: el => (this.cancelButton = el), tabIndex: 0, onClick: () => {
|
|
2692
|
+
var _a;
|
|
2693
|
+
(_a = item.cancel) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
2694
|
+
} }, h("kritzel-icon", { name: "x", size: 16 })), h("div", { class: "menu-item-button", ref: el => (this.saveButton = el), tabIndex: 0, onClick: () => {
|
|
2695
|
+
var _a;
|
|
2696
|
+
(_a = item.save) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
2697
|
+
} }, h("kritzel-icon", { name: "check", size: 16 }))))))))));
|
|
2698
|
+
}
|
|
2699
|
+
get host() { return getElement(this); }
|
|
2700
|
+
static get watchers() { return {
|
|
2701
|
+
"editingIndex": ["onEditingIndexChange"]
|
|
2702
|
+
}; }
|
|
2703
|
+
};
|
|
2704
|
+
KritzelMenu.style = kritzelMenuCss;
|
|
2705
|
+
|
|
2706
|
+
class KritzelHTMLHelper {
|
|
2707
|
+
static getNumericValueFromStyle(element, property) {
|
|
2708
|
+
const value = window.getComputedStyle(element).getPropertyValue(property);
|
|
2709
|
+
return parseFloat(value) || 0;
|
|
2710
|
+
}
|
|
2711
|
+
static getScrollableParent(element) {
|
|
2712
|
+
var _a, _b;
|
|
2713
|
+
if (!element) {
|
|
2714
|
+
return window;
|
|
2715
|
+
}
|
|
2716
|
+
const parent = (_b = (_a = element.parentNode) === null || _a === void 0 ? void 0 : _a.host) !== null && _b !== void 0 ? _b : element.parentElement;
|
|
2717
|
+
if (!parent || parent.tagName === 'BODY') {
|
|
2718
|
+
return window;
|
|
2719
|
+
}
|
|
2720
|
+
const style = window.getComputedStyle(parent);
|
|
2721
|
+
if (style.overflow === 'auto' || style.overflowY === 'auto' || style.overflow === 'scroll' || style.overflowY === 'scroll') {
|
|
2722
|
+
return parent;
|
|
2723
|
+
}
|
|
2724
|
+
return this.getScrollableParent(parent);
|
|
2725
|
+
}
|
|
2726
|
+
static isElementInViewport(element) {
|
|
2727
|
+
if (!element) {
|
|
2728
|
+
return false;
|
|
2729
|
+
}
|
|
2730
|
+
const scrollableParent = this.getScrollableParent(element);
|
|
2731
|
+
const rect = element.getBoundingClientRect();
|
|
2732
|
+
if (scrollableParent === window) {
|
|
2733
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
2734
|
+
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
2735
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= viewportHeight && rect.right <= viewportWidth;
|
|
2736
|
+
}
|
|
2737
|
+
const parentRect = scrollableParent.getBoundingClientRect();
|
|
2738
|
+
return rect.top >= parentRect.top && rect.left >= parentRect.left && rect.bottom <= parentRect.bottom && rect.right <= parentRect.right;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
const DEFAULT_OFFSET = 0;
|
|
2743
|
+
const MIN_LEFT_POSITION = 0;
|
|
2744
|
+
const Z_INDEX = '9005';
|
|
2745
|
+
const ID_PORTAL = 'portal';
|
|
2746
|
+
const KritzelPortal = class {
|
|
2747
|
+
constructor(hostRef) {
|
|
2748
|
+
registerInstance(this, hostRef);
|
|
2749
|
+
this.close = createEvent(this, "close");
|
|
2750
|
+
this.autoFocus = true;
|
|
2751
|
+
this.moved = false;
|
|
2752
|
+
this.handleScroll = () => {
|
|
2753
|
+
const isAnchorInViewport = KritzelHTMLHelper.isElementInViewport(this.anchor);
|
|
2754
|
+
if (!isAnchorInViewport) {
|
|
2755
|
+
this.close.emit();
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2758
|
+
this.calculatePosition();
|
|
2759
|
+
};
|
|
2760
|
+
}
|
|
2761
|
+
anchorChanged(newValue) {
|
|
2762
|
+
if (newValue) {
|
|
2763
|
+
this.calculatePosition();
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
handleResize() {
|
|
2767
|
+
this.calculatePosition();
|
|
2768
|
+
}
|
|
2769
|
+
calculateLeft() {
|
|
2770
|
+
var _a;
|
|
2771
|
+
if (!this.anchor || !this.portal)
|
|
2772
|
+
return 0;
|
|
2773
|
+
const refRect = this.anchor.getBoundingClientRect();
|
|
2774
|
+
const portalRect = this.portal.getBoundingClientRect();
|
|
2775
|
+
const offset = (_a = this.offsetX) !== null && _a !== void 0 ? _a : DEFAULT_OFFSET;
|
|
2776
|
+
let left = refRect.left + offset;
|
|
2777
|
+
const maxLeft = window.innerWidth - portalRect.width - MIN_LEFT_POSITION;
|
|
2778
|
+
if (left < MIN_LEFT_POSITION)
|
|
2779
|
+
left = MIN_LEFT_POSITION;
|
|
2780
|
+
if (left > maxLeft)
|
|
2781
|
+
left = maxLeft;
|
|
2782
|
+
return Math.round(left + window.scrollX);
|
|
2783
|
+
}
|
|
2784
|
+
calculateTop() {
|
|
2785
|
+
var _a;
|
|
2786
|
+
if (!this.anchor || !this.portal)
|
|
2787
|
+
return 0;
|
|
2788
|
+
const refRect = this.anchor.getBoundingClientRect();
|
|
2789
|
+
const portalRect = this.portal.getBoundingClientRect();
|
|
2790
|
+
const offset = (_a = this.offsetY) !== null && _a !== void 0 ? _a : DEFAULT_OFFSET;
|
|
2791
|
+
let top = refRect.bottom + offset;
|
|
2792
|
+
if (top + portalRect.height > window.innerHeight) {
|
|
2793
|
+
top = refRect.top - portalRect.height - offset;
|
|
2794
|
+
}
|
|
2795
|
+
return Math.round(top + window.scrollY);
|
|
2796
|
+
}
|
|
2797
|
+
createPortal() {
|
|
2798
|
+
this.portal = document.createElement('div');
|
|
2799
|
+
this.portal.setAttribute('id', ID_PORTAL);
|
|
2800
|
+
this.portal.style.zIndex = Z_INDEX;
|
|
2801
|
+
this.portal.style.position = 'absolute';
|
|
2802
|
+
this.portal.style.top = '0px';
|
|
2803
|
+
this.portal.style.left = '0px';
|
|
2804
|
+
document.body.append(this.portal);
|
|
2805
|
+
}
|
|
2806
|
+
moveElementToPortal() {
|
|
2807
|
+
this.portal.appendChild(this.element);
|
|
2808
|
+
this.moved = true;
|
|
2809
|
+
}
|
|
2810
|
+
calculatePosition() {
|
|
2811
|
+
if (!this.anchor || !this.portal)
|
|
2812
|
+
return;
|
|
2813
|
+
const top = this.calculateTop();
|
|
2814
|
+
const left = this.calculateLeft();
|
|
2815
|
+
this.portal.style.top = `${top}px`;
|
|
2816
|
+
this.portal.style.left = `${left}px`;
|
|
2817
|
+
}
|
|
2818
|
+
componentWillLoad() {
|
|
2819
|
+
this.createPortal();
|
|
2820
|
+
}
|
|
2821
|
+
componentDidLoad() {
|
|
2822
|
+
var _a;
|
|
2823
|
+
this.moveElementToPortal();
|
|
2824
|
+
if (this.anchor) {
|
|
2825
|
+
this.calculatePosition();
|
|
2826
|
+
this.scrollableParent = KritzelHTMLHelper.getScrollableParent(this.anchor);
|
|
2827
|
+
(_a = this.scrollableParent) === null || _a === void 0 ? void 0 : _a.addEventListener('scroll', this.handleScroll);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
disconnectedCallback() {
|
|
2831
|
+
var _a;
|
|
2832
|
+
this.moved ? this.portal.remove() : (this.moved = true);
|
|
2833
|
+
(_a = this.scrollableParent) === null || _a === void 0 ? void 0 : _a.removeEventListener('scroll', this.handleScroll);
|
|
2834
|
+
}
|
|
2835
|
+
render() {
|
|
2836
|
+
return (h(Host, { key: 'e39525c3e9ddbf738b63ac0c08d8c1e2264783b1', ref: el => (this.element = el) }, h("slot", { key: '95202c5bea32c77dc1dde0a12a58ac9bcebd8812' })));
|
|
2837
|
+
}
|
|
2838
|
+
static get watchers() { return {
|
|
2839
|
+
"anchor": ["anchorChanged"]
|
|
2840
|
+
}; }
|
|
2841
|
+
};
|
|
2842
|
+
|
|
2843
|
+
const kritzelSplitButtonCss = ":host{position:relative;display:flex;align-items:center;font-family:sans-serif;z-index:1;padding:var(--kritzel-controls-padding, 4px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 12px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #ebebeb);gap:var(--kritzel-context-menu-item-gap, 4px)}:host(:focus){outline:none}:host(.mobile){--kritzel-context-menu-item-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-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 12px);font-size:var(--kritzel-context-menu-item-font-size, 14px)}.split-main-button:hover,.split-menu-button:hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button:focus,.split-menu-button:focus{outline:none;background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button{gap:var(--kritzel-context-menu-item-gap, 4px)}.split-menu-button{border-left:none;justify-content:center}.split-divider{width:var(--kritzel-controls-divider-width, 1px);height:24px;background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}";
|
|
2844
|
+
|
|
2845
|
+
const KritzelSplitButton = class {
|
|
2846
|
+
constructor(hostRef) {
|
|
2847
|
+
registerInstance(this, hostRef);
|
|
2848
|
+
this.buttonClick = createEvent(this, "buttonClick");
|
|
2849
|
+
this.optionSelect = createEvent(this, "optionSelect");
|
|
2850
|
+
this.menuOpened = createEvent(this, "menuOpened");
|
|
2851
|
+
this.menuClosed = createEvent(this, "menuClosed");
|
|
2852
|
+
this.dropdownIcon = 'chevron-down';
|
|
2853
|
+
this.options = [];
|
|
2854
|
+
this.disabled = false;
|
|
2855
|
+
this.activeItemIndex = null;
|
|
2856
|
+
this.editingIndex = null;
|
|
2857
|
+
this.isMenuOpen = false;
|
|
2858
|
+
this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
2859
|
+
this.handleDocumentClick = (event) => {
|
|
2860
|
+
const path = (event.composedPath && event.composedPath()) || [];
|
|
2861
|
+
const clickedInside = path.some(node => (node === null || node === void 0 ? void 0 : node.tagName) === 'KRITZEL-SPLIT-BUTTON' || (node === null || node === void 0 ? void 0 : node.tagName) === 'KRITZEL-MENU');
|
|
2862
|
+
if (!clickedInside) {
|
|
2863
|
+
this.closeMenu();
|
|
2864
|
+
}
|
|
2865
|
+
else if (this.isMenuOpen) {
|
|
2866
|
+
document.addEventListener('click', this.handleDocumentClick, { once: true });
|
|
2867
|
+
}
|
|
2868
|
+
};
|
|
2869
|
+
this.toggleMenu = () => {
|
|
2870
|
+
if (this.isMenuOpen) {
|
|
2871
|
+
this.closeMenu();
|
|
2872
|
+
}
|
|
2873
|
+
else {
|
|
2874
|
+
this.openMenu();
|
|
2875
|
+
}
|
|
2876
|
+
};
|
|
2877
|
+
this.handleButtonClick = () => {
|
|
2878
|
+
if (!this.disabled) {
|
|
2879
|
+
this.buttonClick.emit();
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
async openMenu() {
|
|
2884
|
+
if (this.disabled || this.isMenuOpen)
|
|
2885
|
+
return;
|
|
2886
|
+
this.isMenuOpen = true;
|
|
2887
|
+
this.menuOpened.emit();
|
|
2888
|
+
document.addEventListener('click', this.handleDocumentClick, { once: true });
|
|
2889
|
+
}
|
|
2890
|
+
async closeMenu() {
|
|
2891
|
+
if (this.disabled || !this.isMenuOpen)
|
|
2892
|
+
return;
|
|
2893
|
+
this.isMenuOpen = false;
|
|
2894
|
+
this.menuClosed.emit();
|
|
2895
|
+
this.host.focus();
|
|
2896
|
+
}
|
|
2897
|
+
render() {
|
|
2898
|
+
return (h(Host, { key: '1c0010ff46e3e6ac4753f332e683752f82bfb699', tabIndex: 0, class: { mobile: this.isTouchDevice } }, h("button", { key: 'b9e60cea56197641c15a58a3899d09a604a0ca20', class: "split-main-button", tabIndex: 0, onClick: this.handleButtonClick, disabled: this.disabled }, this.buttonIcon && h("kritzel-icon", { key: '3bd9a97e9511eb734665bd45e646f68d9cdcafc5', name: this.buttonIcon }), this.buttonText && (h("span", { key: 'f4a7bbd42bfdf8b748167b439a25ec7cc9f72ecf' }, this.buttonText, " (", this.options.length, ")"))), h("div", { key: 'bd6ce66c2debee87fa78904730a7fa09bcfe6514', class: "split-divider" }), h("button", { key: '5a7b918856ebfc77dd8aa290acb62f4fceaff2b3', ref: el => (this.splitMenuButton = el), class: "split-menu-button", tabIndex: 0, onClick: this.toggleMenu, disabled: this.disabled }, h("kritzel-icon", { key: '28ab4da8d1c4703f0df6551dd85791528b6af793', name: this.dropdownIcon })), h("kritzel-portal", { key: '72746c9acfcbdc56f2a053662d3f1e8596d71eb9', anchor: this.host, offsetY: 4 }, this.isMenuOpen && (h("kritzel-menu", { key: '98af211f4dbc21c4a5fd7223c9441a54451b38a2', style: { maxHeight: '300px', width: '180px' }, items: this.options, activeItemIndex: this.activeItemIndex, editingIndex: this.editingIndex, onClose: () => this.closeMenu() })))));
|
|
2899
|
+
}
|
|
2900
|
+
get host() { return getElement(this); }
|
|
2901
|
+
};
|
|
2902
|
+
KritzelSplitButton.style = kritzelSplitButtonCss;
|
|
2903
|
+
|
|
2904
|
+
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)}";
|
|
2226
2905
|
|
|
2227
2906
|
const KritzelStrokeSize = class {
|
|
2228
2907
|
constructor(hostRef) {
|
|
@@ -2236,7 +2915,7 @@ const KritzelStrokeSize = class {
|
|
|
2236
2915
|
this.sizeChange.emit(size);
|
|
2237
2916
|
}
|
|
2238
2917
|
render() {
|
|
2239
|
-
return (h(Host, { key: '
|
|
2918
|
+
return (h(Host, { key: '0185d3243c35c49169324c98f87df6a286fc3d31' }, this.sizes.map(size => (h("div", { class: {
|
|
2240
2919
|
'size-container': true,
|
|
2241
2920
|
'selected': this.selectedSize === size,
|
|
2242
2921
|
}, onClick: () => this.handleSizeClick(size) }, h("kritzel-color", { value: '#000000', size: size }))))));
|
|
@@ -2285,23 +2964,23 @@ const KritzelTooltip = class {
|
|
|
2285
2964
|
}
|
|
2286
2965
|
}
|
|
2287
2966
|
render() {
|
|
2288
|
-
return (h(Host, { key: '
|
|
2967
|
+
return (h(Host, { key: '7610e8185e037813cc363daa3212a4164a20daaf', style: {
|
|
2289
2968
|
position: 'fixed',
|
|
2290
2969
|
zIndex: '9999',
|
|
2291
2970
|
transition: 'opacity 0.3s ease-in-out, transform 0.3s ease-in-out',
|
|
2292
2971
|
visibility: this.isVisible ? 'visible' : 'hidden',
|
|
2293
2972
|
left: !this.isMobileView ? `${this.positionX}px` : '50%',
|
|
2294
2973
|
marginBottom: `${this.offsetY + this.arrowSize}px`,
|
|
2295
|
-
} }, h("div", { key: '
|
|
2974
|
+
} }, h("div", { key: 'bd5c1f0f7ff3afddfcf2469277189d026e79b453', class: "tooltip-content", onClick: event => event.stopPropagation() }, h("slot", { key: '547e5a8fcb8131225461881a1ad0125fa4b0d55b' }), h("div", { key: 'de1d30c31667a81a36873d32bec20fcc911ec89f', class: "tooltip-arrow-wrapper", style: {
|
|
2296
2975
|
position: 'fixed',
|
|
2297
2976
|
left: this.arrowOffset,
|
|
2298
2977
|
bottom: `-${this.arrowSize * 2}px`,
|
|
2299
|
-
} }, h("div", { key: '
|
|
2978
|
+
} }, h("div", { key: 'ebbf83bd4d35e252b0258a7c81ebcef48ac10004', class: "tooltip-arrow", style: {
|
|
2300
2979
|
borderLeft: `${this.arrowSize}px solid transparent`,
|
|
2301
2980
|
borderRight: `${this.arrowSize}px solid transparent`,
|
|
2302
2981
|
borderTop: `${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,
|
|
2303
2982
|
filter: 'drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))',
|
|
2304
|
-
} }), h("div", { key: '
|
|
2983
|
+
} }), h("div", { key: '918ca46c438657dc4f72ccc73f81d58076d637c5', class: "tooltip-arrow-rect", style: {
|
|
2305
2984
|
position: 'relative',
|
|
2306
2985
|
width: `${this.arrowSize * 2}px`,
|
|
2307
2986
|
height: `${this.arrowSize}px`,
|
|
@@ -2335,12 +3014,115 @@ const KritzelUtilityPanel = class {
|
|
|
2335
3014
|
this.redo.emit();
|
|
2336
3015
|
}
|
|
2337
3016
|
render() {
|
|
2338
|
-
return (h(Host, { key: '
|
|
3017
|
+
return (h(Host, { key: 'cf7b5c501b6535fda22b17ea218e90bd60223c6e' }, h("button", { key: '05db2cee7f2e191674167ef503e70718200bf904', class: "utility-button", onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: '10412c038b9d4e66851c8a0c9b51b99607bac397', name: "undo" })), h("button", { key: 'edf0289de8ce5cddd9341bc1855eae095274226c', class: "utility-button", onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: '46263e3d3f166b224c9a18ba383085e020fac51a', name: "redo" })), h("div", { key: '3a6c0eca21f44887683d6308ca5741b095eceb77', class: "utility-separator" }), h("button", { key: 'ced83e0c47fc920edabdc5b3379a8805f1827374', class: "utility-button" }, h("kritzel-icon", { key: 'd49c6412d778d34fe21e86482f2114631621106a', name: "delete", onClick: () => this.delete.emit() }))));
|
|
2339
3018
|
}
|
|
2340
3019
|
};
|
|
2341
3020
|
KritzelUtilityPanel.style = kritzelUtilityPanelCss;
|
|
2342
3021
|
|
|
2343
|
-
|
|
2344
|
-
|
|
3022
|
+
const kritzelWorkspaceManagerCss = ":host{display:flex;flex-direction:column;z-index:1}";
|
|
3023
|
+
|
|
3024
|
+
const KritzelWorkspaceManager = class {
|
|
3025
|
+
constructor(hostRef) {
|
|
3026
|
+
registerInstance(this, hostRef);
|
|
3027
|
+
this.isWorkspaceManagerReady = createEvent(this, "isWorkspaceManagerReady");
|
|
3028
|
+
this.workspaceChange = createEvent(this, "workspaceChange");
|
|
3029
|
+
this.workspaces = [];
|
|
3030
|
+
this.editingIndex = null;
|
|
3031
|
+
this.newWorkspace = null;
|
|
3032
|
+
this.kritzelEngine = null;
|
|
3033
|
+
this.handleNewWorkspace = async () => {
|
|
3034
|
+
var _a;
|
|
3035
|
+
await ((_a = this.splitButtonRef) === null || _a === void 0 ? void 0 : _a.openMenu());
|
|
3036
|
+
requestAnimationFrame(() => {
|
|
3037
|
+
this.newWorkspace = new KritzelWorkspace(ObjectHelper.generateUUID(), 'New Workspace');
|
|
3038
|
+
this.editingIndex = 0;
|
|
3039
|
+
});
|
|
3040
|
+
};
|
|
3041
|
+
this.handleMenuClosed = () => {
|
|
3042
|
+
this.editingIndex = null;
|
|
3043
|
+
this.newWorkspace = null;
|
|
3044
|
+
};
|
|
3045
|
+
this.handleSave = async (item) => {
|
|
3046
|
+
const workspace = item.value;
|
|
3047
|
+
const updatedWorkspace = Object.assign(Object.assign({}, workspace), { name: item.label });
|
|
3048
|
+
if (this.newWorkspace) {
|
|
3049
|
+
await this.kritzelEngine.createWorkspace(updatedWorkspace);
|
|
3050
|
+
this.editingIndex = null;
|
|
3051
|
+
this.newWorkspace = null;
|
|
3052
|
+
this.selectWorkspace(updatedWorkspace);
|
|
3053
|
+
}
|
|
3054
|
+
else {
|
|
3055
|
+
await this.kritzelEngine.updateWorkspace(updatedWorkspace);
|
|
3056
|
+
this.editingIndex = null;
|
|
3057
|
+
this.newWorkspace = null;
|
|
3058
|
+
}
|
|
3059
|
+
};
|
|
3060
|
+
this.handleRename = (index) => {
|
|
3061
|
+
this.editingIndex = index;
|
|
3062
|
+
};
|
|
3063
|
+
this.handleDelete = async (workspaceToDelete) => {
|
|
3064
|
+
var _a;
|
|
3065
|
+
await this.kritzelEngine.deleteWorkspace(workspaceToDelete);
|
|
3066
|
+
if (((_a = this.activeWorkspace) === null || _a === void 0 ? void 0 : _a.id) === workspaceToDelete.id) {
|
|
3067
|
+
const newActiveWorkspace = this.sortedWorkspaces.find(w => w.id !== workspaceToDelete.id) || null;
|
|
3068
|
+
this.selectWorkspace(newActiveWorkspace);
|
|
3069
|
+
}
|
|
3070
|
+
};
|
|
3071
|
+
}
|
|
3072
|
+
get sortedWorkspaces() {
|
|
3073
|
+
const uniqueWorkspaces = [...new Map(this.workspaces.map(workspace => [workspace.id, workspace])).values()];
|
|
3074
|
+
return [this.newWorkspace, ...uniqueWorkspaces].filter(ws => ws !== null).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
3075
|
+
}
|
|
3076
|
+
get activeItemIndex() {
|
|
3077
|
+
return this.sortedWorkspaces.findIndex(ws => { var _a; return ws.id === ((_a = this.activeWorkspace) === null || _a === void 0 ? void 0 : _a.id); });
|
|
3078
|
+
}
|
|
3079
|
+
async componentWillLoad() {
|
|
3080
|
+
await this.initializeEngine();
|
|
3081
|
+
this.isWorkspaceManagerReady.emit();
|
|
3082
|
+
}
|
|
3083
|
+
async initializeEngine() {
|
|
3084
|
+
await customElements.whenDefined('kritzel-engine');
|
|
3085
|
+
this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');
|
|
3086
|
+
if (!this.kritzelEngine) {
|
|
3087
|
+
throw new Error('kritzel-engine not found in parent element.');
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
handleSelect(workspace) {
|
|
3091
|
+
this.selectWorkspace(workspace);
|
|
3092
|
+
}
|
|
3093
|
+
selectWorkspace(workspace) {
|
|
3094
|
+
debugger;
|
|
3095
|
+
if (this.editingIndex !== null)
|
|
3096
|
+
return;
|
|
3097
|
+
this.activeWorkspace = this.sortedWorkspaces.find(ws => ws.id === workspace.id);
|
|
3098
|
+
this.workspaceChange.emit(workspace);
|
|
3099
|
+
}
|
|
3100
|
+
render() {
|
|
3101
|
+
const workspaceSelectionOptions = this.sortedWorkspaces.map((ws, index) => ({
|
|
3102
|
+
label: ws.name,
|
|
3103
|
+
value: ws,
|
|
3104
|
+
select: () => this.handleSelect(ws),
|
|
3105
|
+
cancel: this.handleMenuClosed,
|
|
3106
|
+
save: this.handleSave,
|
|
3107
|
+
children: [
|
|
3108
|
+
{
|
|
3109
|
+
label: 'Rename',
|
|
3110
|
+
value: 'rename',
|
|
3111
|
+
select: () => this.handleRename(index),
|
|
3112
|
+
},
|
|
3113
|
+
{
|
|
3114
|
+
label: 'Delete',
|
|
3115
|
+
value: 'delete',
|
|
3116
|
+
disabled: this.sortedWorkspaces.length <= 1,
|
|
3117
|
+
select: () => this.handleDelete(ws),
|
|
3118
|
+
},
|
|
3119
|
+
],
|
|
3120
|
+
}));
|
|
3121
|
+
return (h(Host, { key: '4d060aee853a47ea451f707c6de345b6efcbd678' }, h("kritzel-split-button", { key: 'cb52b41b25c7ddc8584e96a2151efc6406166e99', ref: el => (this.splitButtonRef = el), buttonIcon: "plus", options: workspaceSelectionOptions, activeItemIndex: this.activeItemIndex, editingIndex: this.editingIndex, onButtonClick: this.handleNewWorkspace, onMenuClosed: this.handleMenuClosed })));
|
|
3122
|
+
}
|
|
3123
|
+
get host() { return getElement(this); }
|
|
3124
|
+
};
|
|
3125
|
+
KritzelWorkspaceManager.style = kritzelWorkspaceManagerCss;
|
|
2345
3126
|
|
|
2346
|
-
|
|
3127
|
+
export { KritzelBrushStyle as kritzel_brush_style, 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, 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 };
|
|
3128
|
+
//# sourceMappingURL=kritzel-brush-style.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-portal.kritzel-split-button.kritzel-stroke-size.kritzel-tooltip.kritzel-utility-panel.kritzel-workspace-manager.entry.js.map
|