kritzel-stencil 0.0.125 → 0.0.126
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/{components/p-BJOf0PsO.js → stencil/brush-tool.class-D1U3x9_Y.js} +51 -7
- package/dist/stencil/brush-tool.class-D1U3x9_Y.js.map +1 -0
- package/dist/{collection/configs/default-brush-tool.config.js → stencil/default-text-tool.config-DvOZmpuR.js} +38 -2
- package/dist/stencil/default-text-tool.config-DvOZmpuR.js.map +1 -0
- package/dist/stencil/engine.constants-DsjjAmnl.js +7 -0
- package/dist/stencil/engine.constants-DsjjAmnl.js.map +1 -0
- package/dist/{components/p-D8W6LE-c.js → stencil/event-button.enum-D8W6LE-c.js} +2 -2
- package/dist/stencil/event-button.enum-D8W6LE-c.js.map +1 -0
- package/dist/{collection/classes/registries/icon-registry.class.js → stencil/icon-registry.class-Bw5YkOTi.js} +6 -2
- package/dist/stencil/icon-registry.class-Bw5YkOTi.js.map +1 -0
- package/dist/stencil/image-tool.class-uKAmXFSl.js +1341 -0
- package/dist/stencil/image-tool.class-uKAmXFSl.js.map +1 -0
- package/dist/stencil/index-Df69oUcb.js +4334 -0
- package/dist/stencil/index-Df69oUcb.js.map +1 -0
- package/dist/stencil/index.esm.js +16 -1
- package/dist/stencil/index.esm.js.map +1 -1
- package/dist/stencil/kritzel-brush-style.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-brush-style.entry.js +31 -0
- package/dist/stencil/kritzel-brush-style.entry.js.map +1 -0
- package/dist/stencil/kritzel-color-palette.entry.esm.js.map +1 -0
- package/dist/{components/p-Bn5P7YQn.js → stencil/kritzel-color-palette.entry.js} +11 -37
- package/dist/stencil/kritzel-color-palette.entry.js.map +1 -0
- package/dist/stencil/kritzel-color.entry.esm.js.map +1 -0
- package/dist/{components/p-D0sLslUq.js → stencil/kritzel-color.entry.js} +11 -29
- package/dist/stencil/kritzel-color.entry.js.map +1 -0
- package/dist/{components/p-BY8BWGge.js → stencil/kritzel-context-menu-B2p1_Ffh.js} +12 -40
- package/dist/stencil/kritzel-context-menu-B2p1_Ffh.js.map +1 -0
- package/dist/stencil/kritzel-context-menu-DPHV6MRm.js +91 -0
- package/dist/stencil/kritzel-context-menu-DPHV6MRm.js.map +1 -0
- package/dist/stencil/kritzel-context-menu.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-context-menu.entry.js +5 -0
- package/dist/stencil/kritzel-context-menu.entry.js.map +1 -0
- package/dist/stencil/kritzel-control-brush-config.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-control-brush-config.entry.js +54 -0
- package/dist/stencil/kritzel-control-brush-config.entry.js.map +1 -0
- package/dist/stencil/kritzel-control-text-config.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-control-text-config.entry.js +42 -0
- package/dist/stencil/kritzel-control-text-config.entry.js.map +1 -0
- package/dist/stencil/kritzel-controls.entry.esm.js.map +1 -0
- package/dist/{components/p-CBCFr_x3.js → stencil/kritzel-controls.entry.js} +16 -116
- package/dist/stencil/kritzel-controls.entry.js.map +1 -0
- package/dist/stencil/kritzel-cursor-trail.entry.esm.js.map +1 -0
- package/dist/{components/p-Cw2ATHMj.js → stencil/kritzel-cursor-trail.entry.js} +11 -30
- package/dist/stencil/kritzel-cursor-trail.entry.js.map +1 -0
- package/dist/stencil/kritzel-dropdown.entry.esm.js.map +1 -0
- package/dist/{components/p-NZJPrwJV.js → stencil/kritzel-dropdown.entry.js} +11 -37
- package/dist/stencil/kritzel-dropdown.entry.js.map +1 -0
- package/dist/stencil/kritzel-editor.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-editor.entry.js +180 -0
- package/dist/stencil/kritzel-editor.entry.js.map +1 -0
- package/dist/stencil/kritzel-engine.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-engine.entry.js +1318 -0
- package/dist/stencil/kritzel-engine.entry.js.map +1 -0
- package/dist/stencil/kritzel-font-family.entry.esm.js.map +1 -0
- package/dist/{components/p-CF8ziFc4.js → stencil/kritzel-font-family.entry.js} +11 -35
- package/dist/stencil/kritzel-font-family.entry.js.map +1 -0
- package/dist/stencil/kritzel-font-size.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-font-size.entry.js +29 -0
- package/dist/stencil/kritzel-font-size.entry.js.map +1 -0
- package/dist/stencil/kritzel-font.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-font.entry.js +25 -0
- package/dist/stencil/kritzel-font.entry.js.map +1 -0
- package/dist/stencil/kritzel-icon.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-icon.entry.js +29 -0
- package/dist/stencil/kritzel-icon.entry.js.map +1 -0
- package/dist/stencil/kritzel-stroke-size.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-stroke-size.entry.js +28 -0
- package/dist/stencil/kritzel-stroke-size.entry.js.map +1 -0
- package/dist/stencil/kritzel-tooltip.entry.esm.js.map +1 -0
- package/dist/{components/p-DpiklJU9.js → stencil/kritzel-tooltip.entry.js} +14 -37
- package/dist/stencil/kritzel-tooltip.entry.js.map +1 -0
- package/dist/stencil/kritzel-utility-panel.entry.esm.js.map +1 -0
- package/dist/stencil/kritzel-utility-panel.entry.js +33 -0
- package/dist/stencil/kritzel-utility-panel.entry.js.map +1 -0
- package/dist/stencil/loader.esm.js.map +1 -1
- package/dist/stencil/stencil.esm.js +49 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +2 -2
- package/dist/types/components.d.ts +4 -4
- package/package.json +1 -1
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -8
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
- package/dist/cjs/index-C05uAr89.js +0 -1591
- package/dist/cjs/index-C05uAr89.js.map +0 -1
- package/dist/cjs/index-CgSgPOBv.js +0 -2546
- package/dist/cjs/index-CgSgPOBv.js.map +0 -1
- package/dist/cjs/index.cjs.js +0 -19
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +0 -2365
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +0 -1
- package/dist/cjs/loader.cjs.js +0 -16
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/cjs/stencil.cjs.js +0 -28
- package/dist/cjs/stencil.cjs.js.map +0 -1
- package/dist/collection/classes/commands/add-object.command.js +0 -14
- package/dist/collection/classes/commands/add-object.command.js.map +0 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +0 -20
- package/dist/collection/classes/commands/add-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/base.command.js +0 -15
- package/dist/collection/classes/commands/base.command.js.map +0 -1
- package/dist/collection/classes/commands/batch.command.js +0 -14
- package/dist/collection/classes/commands/batch.command.js.map +0 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +0 -25
- package/dist/collection/classes/commands/move-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/remove-object.command.js +0 -17
- package/dist/collection/classes/commands/remove-object.command.js.map +0 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +0 -18
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +0 -18
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +0 -24
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/update-object.command.js +0 -29
- package/dist/collection/classes/commands/update-object.command.js.map +0 -1
- package/dist/collection/classes/commands/update-viewport.command.js +0 -23
- package/dist/collection/classes/commands/update-viewport.command.js.map +0 -1
- package/dist/collection/classes/handlers/base.handler.js +0 -7
- package/dist/collection/classes/handlers/base.handler.js.map +0 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +0 -47
- package/dist/collection/classes/handlers/context-menu.handler.js.map +0 -1
- package/dist/collection/classes/handlers/hover.handler.js +0 -19
- package/dist/collection/classes/handlers/hover.handler.js.map +0 -1
- package/dist/collection/classes/handlers/key.handler.js +0 -81
- package/dist/collection/classes/handlers/key.handler.js.map +0 -1
- package/dist/collection/classes/handlers/move.handler.js +0 -84
- package/dist/collection/classes/handlers/move.handler.js.map +0 -1
- package/dist/collection/classes/handlers/resize.handler.js +0 -150
- package/dist/collection/classes/handlers/resize.handler.js.map +0 -1
- package/dist/collection/classes/handlers/rotation.handler.js +0 -102
- package/dist/collection/classes/handlers/rotation.handler.js.map +0 -1
- package/dist/collection/classes/handlers/selection.handler.js +0 -200
- package/dist/collection/classes/handlers/selection.handler.js.map +0 -1
- package/dist/collection/classes/history.class.js +0 -71
- package/dist/collection/classes/history.class.js.map +0 -1
- package/dist/collection/classes/objects/base-object.class.js +0 -199
- package/dist/collection/classes/objects/base-object.class.js.map +0 -1
- package/dist/collection/classes/objects/custom-element.class.js +0 -52
- package/dist/collection/classes/objects/custom-element.class.js.map +0 -1
- package/dist/collection/classes/objects/image.class.js +0 -53
- package/dist/collection/classes/objects/image.class.js.map +0 -1
- package/dist/collection/classes/objects/path.class.js +0 -262
- package/dist/collection/classes/objects/path.class.js.map +0 -1
- package/dist/collection/classes/objects/selection-box.class.js +0 -22
- package/dist/collection/classes/objects/selection-box.class.js.map +0 -1
- package/dist/collection/classes/objects/selection-group.class.js +0 -159
- package/dist/collection/classes/objects/selection-group.class.js.map +0 -1
- package/dist/collection/classes/objects/text.class.js +0 -141
- package/dist/collection/classes/objects/text.class.js.map +0 -1
- package/dist/collection/classes/registries/icon-registry.class.js.map +0 -1
- package/dist/collection/classes/registries/tool.registry.js +0 -18
- package/dist/collection/classes/registries/tool.registry.js.map +0 -1
- package/dist/collection/classes/reviver.class.js +0 -66
- package/dist/collection/classes/reviver.class.js.map +0 -1
- package/dist/collection/classes/store.class.js +0 -287
- package/dist/collection/classes/store.class.js.map +0 -1
- package/dist/collection/classes/structures/circular-buffer.structure.js +0 -46
- package/dist/collection/classes/structures/circular-buffer.structure.js.map +0 -1
- package/dist/collection/classes/structures/octree.structure.js +0 -111
- package/dist/collection/classes/structures/octree.structure.js.map +0 -1
- package/dist/collection/classes/tools/base-tool.class.js +0 -31
- package/dist/collection/classes/tools/base-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/brush-tool.class.js +0 -116
- package/dist/collection/classes/tools/brush-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +0 -86
- package/dist/collection/classes/tools/eraser-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/image-tool.class.js +0 -88
- package/dist/collection/classes/tools/image-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/selection-tool.class.js +0 -156
- package/dist/collection/classes/tools/selection-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/text-tool.class.js +0 -116
- package/dist/collection/classes/tools/text-tool.class.js.map +0 -1
- package/dist/collection/classes/viewport.class.js +0 -148
- package/dist/collection/classes/viewport.class.js.map +0 -1
- package/dist/collection/collection-manifest.json +0 -29
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.css +0 -10
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +0 -154
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +0 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +0 -24
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +0 -672
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +0 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +0 -60
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +0 -1287
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +0 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.css +0 -44
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +0 -100
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +0 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.css +0 -21
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +0 -108
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +0 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +0 -46
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +0 -147
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +0 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +0 -53
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +0 -215
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.css +0 -10
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +0 -92
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +0 -48
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +0 -115
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +0 -30
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +0 -112
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +0 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +0 -17
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +0 -94
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +0 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +0 -28
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +0 -91
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +0 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +0 -17
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +0 -181
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +0 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +0 -55
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +0 -178
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +0 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +0 -19
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +0 -136
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +0 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.css +0 -19
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +0 -116
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +0 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +0 -124
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +0 -268
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +0 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +0 -33
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +0 -79
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +0 -1
- package/dist/collection/configs/default-brush-tool.config.js.map +0 -1
- package/dist/collection/configs/default-engine-state.js +0 -58
- package/dist/collection/configs/default-engine-state.js.map +0 -1
- package/dist/collection/configs/default-text-tool.config.js +0 -32
- package/dist/collection/configs/default-text-tool.config.js.map +0 -1
- package/dist/collection/constants/engine.constants.js +0 -3
- package/dist/collection/constants/engine.constants.js.map +0 -1
- package/dist/collection/enums/event-button.enum.js +0 -7
- package/dist/collection/enums/event-button.enum.js.map +0 -1
- package/dist/collection/enums/handle-type.enum.js +0 -8
- package/dist/collection/enums/handle-type.enum.js.map +0 -1
- package/dist/collection/helpers/class.helper.js +0 -6
- package/dist/collection/helpers/class.helper.js.map +0 -1
- package/dist/collection/helpers/devices.helper.js +0 -6
- package/dist/collection/helpers/devices.helper.js.map +0 -1
- package/dist/collection/helpers/event.helper.js +0 -58
- package/dist/collection/helpers/event.helper.js.map +0 -1
- package/dist/collection/helpers/geometry.helper.js +0 -53
- package/dist/collection/helpers/geometry.helper.js.map +0 -1
- package/dist/collection/helpers/html.helper.js +0 -7
- package/dist/collection/helpers/html.helper.js.map +0 -1
- package/dist/collection/helpers/keyboard.helper.js +0 -31
- package/dist/collection/helpers/keyboard.helper.js.map +0 -1
- package/dist/collection/helpers/math.helper.js +0 -6
- package/dist/collection/helpers/math.helper.js.map +0 -1
- package/dist/collection/helpers/object.helper.js +0 -38
- package/dist/collection/helpers/object.helper.js.map +0 -1
- package/dist/collection/index.js +0 -21
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/interfaces/bounding-box.interface.js +0 -2
- package/dist/collection/interfaces/bounding-box.interface.js.map +0 -1
- package/dist/collection/interfaces/command.interface.js +0 -2
- package/dist/collection/interfaces/command.interface.js.map +0 -1
- package/dist/collection/interfaces/context-menu-item.interface.js +0 -2
- package/dist/collection/interfaces/context-menu-item.interface.js.map +0 -1
- package/dist/collection/interfaces/debug-info.interface.js +0 -2
- package/dist/collection/interfaces/debug-info.interface.js.map +0 -1
- package/dist/collection/interfaces/engine-state.interface.js +0 -2
- package/dist/collection/interfaces/engine-state.interface.js.map +0 -1
- package/dist/collection/interfaces/object.interface.js +0 -2
- package/dist/collection/interfaces/object.interface.js.map +0 -1
- package/dist/collection/interfaces/path-options.interface.js +0 -2
- package/dist/collection/interfaces/path-options.interface.js.map +0 -1
- package/dist/collection/interfaces/point.interface.js +0 -2
- package/dist/collection/interfaces/point.interface.js.map +0 -1
- package/dist/collection/interfaces/polygon.interface.js +0 -2
- package/dist/collection/interfaces/polygon.interface.js.map +0 -1
- package/dist/collection/interfaces/selection-state.interface.js +0 -2
- package/dist/collection/interfaces/selection-state.interface.js.map +0 -1
- package/dist/collection/interfaces/serializable.interface.js +0 -2
- package/dist/collection/interfaces/serializable.interface.js.map +0 -1
- package/dist/collection/interfaces/tool.interface.js +0 -2
- package/dist/collection/interfaces/tool.interface.js.map +0 -1
- package/dist/collection/interfaces/toolbar-control.interface.js +0 -2
- package/dist/collection/interfaces/toolbar-control.interface.js.map +0 -1
- package/dist/collection/types/state.types.js +0 -2
- package/dist/collection/types/state.types.js.map +0 -1
- package/dist/components/index.js +0 -24
- package/dist/components/index.js.map +0 -1
- package/dist/components/kritzel-brush-style.js +0 -9
- package/dist/components/kritzel-brush-style.js.map +0 -1
- package/dist/components/kritzel-color-palette.js +0 -9
- package/dist/components/kritzel-color-palette.js.map +0 -1
- package/dist/components/kritzel-color.js +0 -9
- package/dist/components/kritzel-color.js.map +0 -1
- package/dist/components/kritzel-context-menu.js +0 -9
- package/dist/components/kritzel-context-menu.js.map +0 -1
- package/dist/components/kritzel-control-brush-config.js +0 -9
- package/dist/components/kritzel-control-brush-config.js.map +0 -1
- package/dist/components/kritzel-control-text-config.js +0 -9
- package/dist/components/kritzel-control-text-config.js.map +0 -1
- package/dist/components/kritzel-controls.js +0 -9
- package/dist/components/kritzel-controls.js.map +0 -1
- package/dist/components/kritzel-cursor-trail.js +0 -9
- package/dist/components/kritzel-cursor-trail.js.map +0 -1
- package/dist/components/kritzel-dropdown.js +0 -9
- package/dist/components/kritzel-dropdown.js.map +0 -1
- package/dist/components/kritzel-editor.js +0 -409
- package/dist/components/kritzel-editor.js.map +0 -1
- package/dist/components/kritzel-engine.js +0 -9
- package/dist/components/kritzel-engine.js.map +0 -1
- package/dist/components/kritzel-font-family.js +0 -9
- package/dist/components/kritzel-font-family.js.map +0 -1
- package/dist/components/kritzel-font-size.js +0 -9
- package/dist/components/kritzel-font-size.js.map +0 -1
- package/dist/components/kritzel-font.js +0 -9
- package/dist/components/kritzel-font.js.map +0 -1
- package/dist/components/kritzel-icon.js +0 -9
- package/dist/components/kritzel-icon.js.map +0 -1
- package/dist/components/kritzel-stroke-size.js +0 -9
- package/dist/components/kritzel-stroke-size.js.map +0 -1
- package/dist/components/kritzel-tooltip.js +0 -9
- package/dist/components/kritzel-tooltip.js.map +0 -1
- package/dist/components/kritzel-utility-panel.js +0 -9
- package/dist/components/kritzel-utility-panel.js.map +0 -1
- package/dist/components/p-BJOf0PsO.js.map +0 -1
- package/dist/components/p-BOj_wqdw.js +0 -54
- package/dist/components/p-BOj_wqdw.js.map +0 -1
- package/dist/components/p-BY8BWGge.js.map +0 -1
- package/dist/components/p-BjG1zRRI.js +0 -2718
- package/dist/components/p-BjG1zRRI.js.map +0 -1
- package/dist/components/p-Bn5P7YQn.js.map +0 -1
- package/dist/components/p-C9usqwb5.js +0 -61
- package/dist/components/p-C9usqwb5.js.map +0 -1
- package/dist/components/p-CBCFr_x3.js.map +0 -1
- package/dist/components/p-CF8ziFc4.js.map +0 -1
- package/dist/components/p-CiT5gBDh.js +0 -44
- package/dist/components/p-CiT5gBDh.js.map +0 -1
- package/dist/components/p-Cn_kantt.js +0 -54
- package/dist/components/p-Cn_kantt.js.map +0 -1
- package/dist/components/p-CtiROna-.js +0 -90
- package/dist/components/p-CtiROna-.js.map +0 -1
- package/dist/components/p-Cw2ATHMj.js.map +0 -1
- package/dist/components/p-D0sLslUq.js.map +0 -1
- package/dist/components/p-D8W6LE-c.js.map +0 -1
- package/dist/components/p-DJN0U8pI.js +0 -1327
- package/dist/components/p-DJN0U8pI.js.map +0 -1
- package/dist/components/p-DMAzUKo6.js +0 -102
- package/dist/components/p-DMAzUKo6.js.map +0 -1
- package/dist/components/p-DSLY0tr5.js +0 -52
- package/dist/components/p-DSLY0tr5.js.map +0 -1
- package/dist/components/p-DpiklJU9.js.map +0 -1
- package/dist/components/p-NZJPrwJV.js.map +0 -1
- package/dist/components/p-ubNAWsY_.js +0 -111
- package/dist/components/p-ubNAWsY_.js.map +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js +0 -6
- package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
- package/dist/esm/index-BGl8znzE.js +0 -1564
- package/dist/esm/index-BGl8znzE.js.map +0 -1
- package/dist/esm/index-B_0CRlFw.js +0 -2522
- package/dist/esm/index-B_0CRlFw.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +0 -2346
- package/dist/esm/kritzel-brush-style_18.entry.js.map +0 -1
- package/dist/esm/loader.js +0 -14
- package/dist/esm/loader.js.map +0 -1
- package/dist/esm/stencil.js +0 -24
- package/dist/esm/stencil.js.map +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/stencil/p-3a2f1d19.entry.js +0 -2
- package/dist/stencil/p-3a2f1d19.entry.js.map +0 -1
- package/dist/stencil/p-BGl8znzE.js +0 -3
- package/dist/stencil/p-BGl8znzE.js.map +0 -1
- package/dist/stencil/p-B_0CRlFw.js +0 -2
- package/dist/stencil/p-B_0CRlFw.js.map +0 -1
- package/dist/stencil/p-DQuL1Twl.js +0 -2
- package/dist/stencil/p-DQuL1Twl.js.map +0 -1
|
@@ -1,2365 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-C05uAr89.js');
|
|
4
|
-
var index$1 = require('./index-CgSgPOBv.js');
|
|
5
|
-
|
|
6
|
-
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)}";
|
|
7
|
-
|
|
8
|
-
const KritzelBrushStyle = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
index.registerInstance(this, hostRef);
|
|
11
|
-
this.typeChange = index.createEvent(this, "typeChange");
|
|
12
|
-
this.type = 'pen';
|
|
13
|
-
this.brushOptions = [
|
|
14
|
-
{ value: 'pen', label: 'Pen' },
|
|
15
|
-
{ value: 'highlighter', label: 'Highlighter' },
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
handleDropdownValueChange(event) {
|
|
19
|
-
this.typeChange.emit(event.detail);
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
const dropdownOptions = this.brushOptions.map(option => ({
|
|
23
|
-
value: option.value,
|
|
24
|
-
label: option.label,
|
|
25
|
-
}));
|
|
26
|
-
return (index.h(index.Host, { key: 'd7af382fe6f613aa16a5146785990ad2faa17f60' }, index.h("kritzel-dropdown", { key: '6d6d330d415c210058834b2968774b3db2ab7fc4', options: dropdownOptions, value: this.type, onValueChanged: event => this.handleDropdownValueChange(event) }, index.h("button", { key: 'c9fb33795b8e25f68c1d2ae248dc82a6de29e199', class: "brush-style-button", slot: "prefix" }, index.h("kritzel-icon", { key: '975c95b545a1c27ae2984405ac298592eec9743d', name: this.type, size: 16 })))));
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
KritzelBrushStyle.style = kritzelBrushStyleCss;
|
|
30
|
-
|
|
31
|
-
const kritzelColorCss = ":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";
|
|
32
|
-
|
|
33
|
-
const KritzelColor = class {
|
|
34
|
-
constructor(hostRef) {
|
|
35
|
-
index.registerInstance(this, hostRef);
|
|
36
|
-
this.size = 24;
|
|
37
|
-
}
|
|
38
|
-
isLightColor(hexColor) {
|
|
39
|
-
if (!hexColor)
|
|
40
|
-
return false;
|
|
41
|
-
let r = 0, g = 0, b = 0;
|
|
42
|
-
let sanitizedHex = hexColor.startsWith('#') ? hexColor.slice(1) : hexColor;
|
|
43
|
-
if (sanitizedHex.length === 3) {
|
|
44
|
-
r = parseInt(sanitizedHex[0] + sanitizedHex[0], 16);
|
|
45
|
-
g = parseInt(sanitizedHex[1] + sanitizedHex[1], 16);
|
|
46
|
-
b = parseInt(sanitizedHex[2] + sanitizedHex[2], 16);
|
|
47
|
-
}
|
|
48
|
-
else if (sanitizedHex.length === 6) {
|
|
49
|
-
r = parseInt(sanitizedHex.substring(0, 2), 16);
|
|
50
|
-
g = parseInt(sanitizedHex.substring(2, 4), 16);
|
|
51
|
-
b = parseInt(sanitizedHex.substring(4, 6), 16);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
60
|
-
return luminance > 220;
|
|
61
|
-
}
|
|
62
|
-
render() {
|
|
63
|
-
const isColorVeryLight = this.isLightColor(this.value);
|
|
64
|
-
return (index.h(index.Host, { key: '19ad3872a132c885c612dc3b96698a0c8dc7214d' }, index.h("div", { key: 'f67108e82396cbaa3d070c8dfc83da2b080ddf47', class: "checkerboard-bg", style: {
|
|
65
|
-
width: `${this.size}px`,
|
|
66
|
-
height: `${this.size}px`,
|
|
67
|
-
borderRadius: '50%',
|
|
68
|
-
display: 'inline-block',
|
|
69
|
-
position: 'relative',
|
|
70
|
-
} }, index.h("div", { key: '1af0cc3e9f6eebc04cae2367510ef3b98420a818', class: {
|
|
71
|
-
'color-circle': true,
|
|
72
|
-
'white': isColorVeryLight,
|
|
73
|
-
}, style: {
|
|
74
|
-
backgroundColor: this.value,
|
|
75
|
-
width: `${this.size}px`,
|
|
76
|
-
height: `${this.size}px`,
|
|
77
|
-
borderRadius: '50%',
|
|
78
|
-
position: 'absolute',
|
|
79
|
-
top: '0',
|
|
80
|
-
left: '0',
|
|
81
|
-
display: 'inline-block',
|
|
82
|
-
} }))));
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
KritzelColor.style = kritzelColorCss;
|
|
86
|
-
|
|
87
|
-
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, #f0f0f0)}.color-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-color-palette-selected-background-color)}";
|
|
88
|
-
|
|
89
|
-
const KritzelColorPalette = class {
|
|
90
|
-
constructor(hostRef) {
|
|
91
|
-
index.registerInstance(this, hostRef);
|
|
92
|
-
this.colorChange = index.createEvent(this, "colorChange");
|
|
93
|
-
this.colors = [];
|
|
94
|
-
this.selectedColor = null;
|
|
95
|
-
this.isExpanded = false;
|
|
96
|
-
this.isOpaque = false;
|
|
97
|
-
}
|
|
98
|
-
handleColorClick(color) {
|
|
99
|
-
this.selectedColor = color;
|
|
100
|
-
this.colorChange.emit(color);
|
|
101
|
-
}
|
|
102
|
-
calculateHeight() {
|
|
103
|
-
const colorsPerRow = 6;
|
|
104
|
-
const rowHeight = 32;
|
|
105
|
-
const gap = 8;
|
|
106
|
-
const rowCount = Math.ceil(this.colors.length / colorsPerRow);
|
|
107
|
-
return `${rowCount * rowHeight + (rowCount - 1) * gap}px`;
|
|
108
|
-
}
|
|
109
|
-
render() {
|
|
110
|
-
const displayedColors = this.isExpanded ? this.colors : this.colors.slice(0, 6);
|
|
111
|
-
const expandedHeight = this.isExpanded ? this.calculateHeight() : '32px';
|
|
112
|
-
return (index.h(index.Host, { key: '0f0d176e1c8b199a973dbdb23b84e4a8d4d57f59' }, index.h("div", { key: '1d4707cdb30752d21a5058dbbef5fb32934bd3bd', class: {
|
|
113
|
-
'color-grid': true,
|
|
114
|
-
'expanded': this.isExpanded,
|
|
115
|
-
}, style: {
|
|
116
|
-
height: expandedHeight
|
|
117
|
-
} }, displayedColors.map(color => (index.h("div", { class: {
|
|
118
|
-
'color-container': true,
|
|
119
|
-
'selected': this.selectedColor === color,
|
|
120
|
-
}, onClick: () => this.handleColorClick(color) }, index.h("kritzel-color", { value: color })))))));
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
KritzelColorPalette.style = kritzelColorPaletteCss;
|
|
124
|
-
|
|
125
|
-
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 #f0f0f0);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}";
|
|
126
|
-
|
|
127
|
-
const KritzelContextMenu = class {
|
|
128
|
-
constructor(hostRef) {
|
|
129
|
-
index.registerInstance(this, hostRef);
|
|
130
|
-
this.actionSelected = index.createEvent(this, "actionSelected");
|
|
131
|
-
this.disabledStates = new Map();
|
|
132
|
-
this.visibleItems = [];
|
|
133
|
-
}
|
|
134
|
-
componentWillLoad() {
|
|
135
|
-
this.resolveVisibleItems();
|
|
136
|
-
this.resolveDisabledStates();
|
|
137
|
-
}
|
|
138
|
-
onItemsChanged() {
|
|
139
|
-
this.resolveVisibleItems();
|
|
140
|
-
this.resolveDisabledStates();
|
|
141
|
-
}
|
|
142
|
-
handleItemClick(item, index) {
|
|
143
|
-
if (!this.disabledStates.get(index)) {
|
|
144
|
-
this.actionSelected.emit(item);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
async resolveVisibleItems() {
|
|
148
|
-
const visibleItems = [];
|
|
149
|
-
const visibilityPromises = this.items.map(async (item, index) => {
|
|
150
|
-
let isVisible = true;
|
|
151
|
-
if (item.visible !== undefined) {
|
|
152
|
-
if (typeof item.visible === 'boolean') {
|
|
153
|
-
isVisible = item.visible;
|
|
154
|
-
}
|
|
155
|
-
else if (typeof item.visible === 'function') {
|
|
156
|
-
const result = item.visible(null, this.objects);
|
|
157
|
-
if (result instanceof Promise) {
|
|
158
|
-
isVisible = await result;
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
isVisible = result;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { item, index, isVisible };
|
|
166
|
-
});
|
|
167
|
-
const visibilityResults = await Promise.all(visibilityPromises);
|
|
168
|
-
visibilityResults.forEach(({ item, isVisible }) => {
|
|
169
|
-
if (isVisible) {
|
|
170
|
-
visibleItems.push(item);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
this.visibleItems = visibleItems;
|
|
174
|
-
}
|
|
175
|
-
async resolveDisabledStates() {
|
|
176
|
-
const newStates = new Map();
|
|
177
|
-
const disabledPromises = this.visibleItems.map(async (item, index) => {
|
|
178
|
-
let isDisabled = false;
|
|
179
|
-
if (typeof item.disabled === 'boolean') {
|
|
180
|
-
isDisabled = item.disabled;
|
|
181
|
-
}
|
|
182
|
-
else if (typeof item.disabled === 'function') {
|
|
183
|
-
const result = item.disabled(null, this.objects);
|
|
184
|
-
if (result instanceof Promise) {
|
|
185
|
-
isDisabled = await result;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
isDisabled = result;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
newStates.set(index, isDisabled);
|
|
192
|
-
});
|
|
193
|
-
await Promise.all(disabledPromises);
|
|
194
|
-
this.disabledStates = new Map(newStates);
|
|
195
|
-
}
|
|
196
|
-
render() {
|
|
197
|
-
return (index.h(index.Host, { key: '3265d2e63ff1e1f91faf1c6c5da3490687f3adb1' }, index.h("div", { key: '80b2100e2ffcaba25ca08cfec650b1f7558c5d25', class: "menu-container" }, this.visibleItems.map((item, index$1) => {
|
|
198
|
-
var _a;
|
|
199
|
-
const isDisabled = (_a = this.disabledStates.get(index$1)) !== null && _a !== void 0 ? _a : false;
|
|
200
|
-
return (index.h("button", { key: `${item.label}-${index$1}`, class: { 'menu-item': true, 'disabled': isDisabled }, onClick: () => this.handleItemClick(item, index$1), onTouchStart: () => this.handleItemClick(item, index$1), disabled: isDisabled }, item.icon && index.h("kritzel-icon", { name: item.icon, size: 16 }), index.h("span", { class: "label" }, item.label)));
|
|
201
|
-
}))));
|
|
202
|
-
}
|
|
203
|
-
get hostElement() { return index.getElement(this); }
|
|
204
|
-
static get watchers() { return {
|
|
205
|
-
"items": ["onItemsChanged"]
|
|
206
|
-
}; }
|
|
207
|
-
};
|
|
208
|
-
KritzelContextMenu.style = kritzelContextMenuCss;
|
|
209
|
-
|
|
210
|
-
const kritzelControlBrushConfigCss = ":host{display:flex;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
|
|
211
|
-
|
|
212
|
-
const KritzelControlBrushConfig = class {
|
|
213
|
-
constructor(hostRef) {
|
|
214
|
-
index.registerInstance(this, hostRef);
|
|
215
|
-
this.toolChange = index.createEvent(this, "toolChange");
|
|
216
|
-
this.isExpanded = false;
|
|
217
|
-
this.palette = [];
|
|
218
|
-
}
|
|
219
|
-
handleToolChange(newTool) {
|
|
220
|
-
this.palette = newTool.palettes[newTool.type];
|
|
221
|
-
}
|
|
222
|
-
componentWillLoad() {
|
|
223
|
-
this.palette = this.tool.palettes[this.tool.type];
|
|
224
|
-
}
|
|
225
|
-
handleToggleExpand() {
|
|
226
|
-
this.isExpanded = !this.isExpanded;
|
|
227
|
-
}
|
|
228
|
-
handleTypeChange(event) {
|
|
229
|
-
this.palette = this.tool.palettes[event.detail];
|
|
230
|
-
this.tool.type = event.detail;
|
|
231
|
-
this.tool.color = this.palette[0];
|
|
232
|
-
this.toolChange.emit(this.tool);
|
|
233
|
-
}
|
|
234
|
-
handleColorChange(event) {
|
|
235
|
-
this.tool.color = event.detail;
|
|
236
|
-
this.toolChange.emit(this.tool);
|
|
237
|
-
}
|
|
238
|
-
handleSizeChange(event) {
|
|
239
|
-
this.tool.size = event.detail;
|
|
240
|
-
this.toolChange.emit(this.tool);
|
|
241
|
-
}
|
|
242
|
-
render() {
|
|
243
|
-
return (index.h(index.Host, { key: '8e7930fcc093f7277ed088d8ec5e54e4cd051b86' }, index.h("div", { key: '08bd37b90decc9054c05d646aabbba0a4985d04c', style: {
|
|
244
|
-
display: 'flex',
|
|
245
|
-
flexDirection: 'row',
|
|
246
|
-
alignItems: 'center',
|
|
247
|
-
justifyContent: 'flex-start',
|
|
248
|
-
width: '100%',
|
|
249
|
-
gap: '8px',
|
|
250
|
-
} }, index.h("kritzel-brush-style", { key: 'f79744fb6523d0b4fa67c324cbf8ff3eb8a0308d', type: this.tool.type, onTypeChange: event => this.handleTypeChange(event) }), index.h("button", { key: 'dc3bdd90cebb29f2357e13dbc8d2dcaf02ae056e', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand', style: this.palette.length > 6 ? { visibillity: 'visible' } : { visibility: 'hidden' } }, index.h("kritzel-icon", { key: '6e9e6de7fc7c708aad700498e030d2ad7364a9f3', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), index.h("kritzel-color-palette", { key: 'c1ffd48a475754bb1447e9d866b494fd3476f050', colors: this.palette, selectedColor: this.tool.color, isExpanded: this.isExpanded, isOpaque: true, onColorChange: color => this.handleColorChange(color) }), index.h("kritzel-stroke-size", { key: '38e265b42fe09d0105e0385d7ec8e7d8d318abb0', selectedSize: this.tool.size, onSizeChange: event => this.handleSizeChange(event) })));
|
|
251
|
-
}
|
|
252
|
-
static get watchers() { return {
|
|
253
|
-
"tool": ["handleToolChange"]
|
|
254
|
-
}; }
|
|
255
|
-
};
|
|
256
|
-
KritzelControlBrushConfig.style = kritzelControlBrushConfigCss;
|
|
257
|
-
|
|
258
|
-
const kritzelControlTextConfigCss = ":host{display:block;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
|
|
259
|
-
|
|
260
|
-
const KritzelControlTextConfig = class {
|
|
261
|
-
constructor(hostRef) {
|
|
262
|
-
index.registerInstance(this, hostRef);
|
|
263
|
-
this.toolChange = index.createEvent(this, "toolChange");
|
|
264
|
-
this.isExpanded = false;
|
|
265
|
-
}
|
|
266
|
-
handleToggleExpand() {
|
|
267
|
-
this.isExpanded = !this.isExpanded;
|
|
268
|
-
}
|
|
269
|
-
handleFamilyChange(event) {
|
|
270
|
-
this.tool.fontFamily = event.detail;
|
|
271
|
-
this.toolChange.emit(this.tool);
|
|
272
|
-
}
|
|
273
|
-
handleColorChange(event) {
|
|
274
|
-
this.tool.fontColor = event.detail;
|
|
275
|
-
this.toolChange.emit(this.tool);
|
|
276
|
-
}
|
|
277
|
-
handleSizeChange(event) {
|
|
278
|
-
this.tool.fontSize = event.detail;
|
|
279
|
-
this.toolChange.emit(this.tool);
|
|
280
|
-
}
|
|
281
|
-
render() {
|
|
282
|
-
return (index.h(index.Host, { key: '27d47c47987fb7644313a4face4a7023dfbe454d' }, index.h("div", { key: '835b8072267da18b39a5c02a6c989e1f7b81e9a5', style: {
|
|
283
|
-
display: 'flex',
|
|
284
|
-
flexDirection: 'row',
|
|
285
|
-
alignItems: 'center',
|
|
286
|
-
justifyContent: 'flex-start',
|
|
287
|
-
width: '100%',
|
|
288
|
-
gap: '8px',
|
|
289
|
-
} }, index.h("kritzel-font-family", { key: 'b7a0bde2e9cf53c9ae7c3a32b424825ca9f757c4', selectedFontFamily: this.tool.fontFamily, onFontFamilyChange: event => this.handleFamilyChange(event) }), index.h("button", { key: '41aba583656195c4825a15ddc12c5e1efed0d8d2', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand' }, index.h("kritzel-icon", { key: '5ff979420066703b5d5e886d12f89687392006e3', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), index.h("kritzel-color-palette", { key: '30fbcc05f80b15fba7f1f5ac6413732d0149ee9b', colors: this.tool.palette, selectedColor: this.tool.fontColor, isExpanded: this.isExpanded, onColorChange: event => this.handleColorChange(event) }), index.h("kritzel-font-size", { key: '2a0d3c4578316b37bc1a25b6e065ecf565eca2b3', selectedSize: this.tool.fontSize, fontFamily: this.tool.fontFamily, onSizeChange: event => this.handleSizeChange(event) })));
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
293
|
-
|
|
294
|
-
class KritzelDevicesHelper {
|
|
295
|
-
static isTouchDevice() {
|
|
296
|
-
return window.matchMedia('(any-pointer: coarse)').matches;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
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 #f0f0f0);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%))}:host(.mobile) .kritzel-control:hover{background-color:unset}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}:host(.mobile) .kritzel-control:active{background-color:unset}.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, #f0f0f0)}.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, #f0f0f0)}.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}";
|
|
301
|
-
|
|
302
|
-
const KritzelControls = class {
|
|
303
|
-
constructor(hostRef) {
|
|
304
|
-
index.registerInstance(this, hostRef);
|
|
305
|
-
this.isControlsReady = index.createEvent(this, "isControlsReady");
|
|
306
|
-
this.controls = [];
|
|
307
|
-
this.activeControl = null;
|
|
308
|
-
this.isUtilityPanelVisible = true;
|
|
309
|
-
this.firstConfig = null;
|
|
310
|
-
this.isTooltipVisible = false;
|
|
311
|
-
this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
312
|
-
this.kritzelEngine = null;
|
|
313
|
-
}
|
|
314
|
-
async handleActiveToolChange(event) {
|
|
315
|
-
var _a;
|
|
316
|
-
this.activeControl = this.controls.find(control => control.tool === event.detail) || null;
|
|
317
|
-
await ((_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.setFocus());
|
|
318
|
-
}
|
|
319
|
-
handleClick(event) {
|
|
320
|
-
const element = event.target;
|
|
321
|
-
if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
this.isTooltipVisible = false;
|
|
325
|
-
this.kritzelEngine.enable();
|
|
326
|
-
}
|
|
327
|
-
async closeTooltip() {
|
|
328
|
-
var _a;
|
|
329
|
-
this.isTooltipVisible = false;
|
|
330
|
-
(_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
331
|
-
}
|
|
332
|
-
get activeToolAsTextTool() {
|
|
333
|
-
var _a;
|
|
334
|
-
return (_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.tool;
|
|
335
|
-
}
|
|
336
|
-
get activeToolAsBrushTool() {
|
|
337
|
-
var _a;
|
|
338
|
-
return (_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.tool;
|
|
339
|
-
}
|
|
340
|
-
async componentWillLoad() {
|
|
341
|
-
await this.initializeEngine();
|
|
342
|
-
await this.initializeTools();
|
|
343
|
-
this.isControlsReady.emit();
|
|
344
|
-
}
|
|
345
|
-
async initializeEngine() {
|
|
346
|
-
await customElements.whenDefined('kritzel-engine');
|
|
347
|
-
this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');
|
|
348
|
-
if (!this.kritzelEngine) {
|
|
349
|
-
throw new Error('kritzel-engine not found in parent element.');
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
async initializeTools() {
|
|
353
|
-
for (const c of this.controls) {
|
|
354
|
-
if (c.type === 'tool' && c.tool) {
|
|
355
|
-
c.tool = await this.kritzelEngine.registerTool(c.name, c.tool, c.config);
|
|
356
|
-
}
|
|
357
|
-
if (c.type === 'tool' && c.isDefault && c.tool) {
|
|
358
|
-
await this.kritzelEngine.changeActiveTool(c.tool);
|
|
359
|
-
this.activeControl = c;
|
|
360
|
-
}
|
|
361
|
-
if (c.type === 'config') {
|
|
362
|
-
if (this.firstConfig === null) {
|
|
363
|
-
this.firstConfig = c;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
console.warn('Only one config control is allowed. The first one will be used.');
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
async handleControlClick(control) {
|
|
372
|
-
this.activeControl = control;
|
|
373
|
-
if (this.activeControl.type === 'tool') {
|
|
374
|
-
await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
handleConfigClick(event) {
|
|
378
|
-
event.stopPropagation();
|
|
379
|
-
this.isTooltipVisible = !this.isTooltipVisible;
|
|
380
|
-
this.kritzelEngine.disable();
|
|
381
|
-
}
|
|
382
|
-
async handleToolChange(event) {
|
|
383
|
-
this.activeControl = Object.assign(Object.assign({}, this.activeControl), { tool: event.detail });
|
|
384
|
-
await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
|
|
385
|
-
}
|
|
386
|
-
render() {
|
|
387
|
-
var _a, _b;
|
|
388
|
-
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;
|
|
389
|
-
return (index.h(index.Host, { key: '5531510d4b95c082148ce3e8f5d3048f808162b2', class: {
|
|
390
|
-
mobile: this.isTouchDevice,
|
|
391
|
-
} }, this.isUtilityPanelVisible && (index.h("kritzel-utility-panel", { key: 'e7e58ee4ae6a8a77918d5c8a954c2dcae287b265', style: {
|
|
392
|
-
position: 'absolute',
|
|
393
|
-
bottom: '56px',
|
|
394
|
-
left: '12px',
|
|
395
|
-
}, 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(); } })), index.h("div", { key: '65ad87089a38f3e89f8332fc6f261555c2e7eb40', class: "kritzel-controls" }, this.controls.map(control => {
|
|
396
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
397
|
-
if (control.type === 'tool') {
|
|
398
|
-
return (index.h("button", { class: {
|
|
399
|
-
'kritzel-control': true,
|
|
400
|
-
'selected': ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
|
|
401
|
-
}, key: control.name, onClick: _event => { var _a; return (_a = this.handleControlClick) === null || _a === void 0 ? void 0 : _a.call(this, control); } }, index.h("kritzel-icon", { name: control.icon })));
|
|
402
|
-
}
|
|
403
|
-
if (control.type === 'divider') {
|
|
404
|
-
return index.h("div", { class: "kritzel-divider", key: control.name });
|
|
405
|
-
}
|
|
406
|
-
if (control.type === 'config' && control.name === ((_b = this.firstConfig) === null || _b === void 0 ? void 0 : _b.name) && this.activeControl) {
|
|
407
|
-
return (index.h("div", { class: "kritzel-config-container", key: control.name }, index.h("kritzel-tooltip", { isVisible: this.isTooltipVisible, anchorElement: (_c = this.host.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.kritzel-config-container') }, index.h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (index.h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })), this.activeControl.name === 'text' && (index.h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })))), index.h("div", { class: "kritzel-config", onClick: event => { var _a; return (_a = this.handleConfigClick) === null || _a === void 0 ? void 0 : _a.call(this, event); }, style: {
|
|
408
|
-
cursor: this.activeControl.config ? 'pointer' : 'default',
|
|
409
|
-
pointerEvents: hasNoConfig ? 'none' : 'auto',
|
|
410
|
-
} }, this.activeControl.tool instanceof index$1.KritzelBrushTool && (index.h("div", { class: "color-container" }, index.h("kritzel-color", { value: (_d = this.activeToolAsBrushTool) === null || _d === void 0 ? void 0 : _d.color, size: (_e = this.activeToolAsBrushTool) === null || _e === void 0 ? void 0 : _e.size, style: {
|
|
411
|
-
borderRadius: '50%',
|
|
412
|
-
border: 'none',
|
|
413
|
-
} }))), this.activeControl.tool instanceof index$1.KritzelTextTool && (index.h("div", { class: "font-container" }, index.h("kritzel-font", { fontFamily: (_f = this.activeToolAsTextTool) === null || _f === void 0 ? void 0 : _f.fontFamily, size: (_g = this.activeToolAsTextTool) === null || _g === void 0 ? void 0 : _g.fontSize, color: (_h = this.activeToolAsTextTool) === null || _h === void 0 ? void 0 : _h.fontColor }))), hasNoConfig && index.h("div", { class: "no-config" }))));
|
|
414
|
-
}
|
|
415
|
-
}))));
|
|
416
|
-
}
|
|
417
|
-
static get assetsDirs() { return ["../assets"]; }
|
|
418
|
-
get host() { return index.getElement(this); }
|
|
419
|
-
};
|
|
420
|
-
KritzelControls.style = kritzelControlsCss;
|
|
421
|
-
|
|
422
|
-
const kritzelCursorTrailCss = ":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:9000}";
|
|
423
|
-
|
|
424
|
-
const KritzelCursorTrail = class {
|
|
425
|
-
constructor(hostRef) {
|
|
426
|
-
index.registerInstance(this, hostRef);
|
|
427
|
-
this.cursorTrailPoints = [];
|
|
428
|
-
this.isLeftButtonDown = false;
|
|
429
|
-
this.TRAIL_DURATION_MS = 100;
|
|
430
|
-
this.MAX_TRAIL_POINTS = 50;
|
|
431
|
-
}
|
|
432
|
-
componentDidLoad() {
|
|
433
|
-
this.trailCleanupIntervalId = window.setInterval(() => {
|
|
434
|
-
const now = Date.now();
|
|
435
|
-
const newTrailPoints = this.cursorTrailPoints.filter(p => now - p.timestamp < this.TRAIL_DURATION_MS);
|
|
436
|
-
if (newTrailPoints.length !== this.cursorTrailPoints.length) {
|
|
437
|
-
this.cursorTrailPoints = newTrailPoints;
|
|
438
|
-
}
|
|
439
|
-
}, 50);
|
|
440
|
-
}
|
|
441
|
-
disconnectedCallback() {
|
|
442
|
-
if (this.trailCleanupIntervalId) {
|
|
443
|
-
window.clearInterval(this.trailCleanupIntervalId);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
handleMouseDown(ev) {
|
|
447
|
-
if (ev.pointerType === 'mouse') {
|
|
448
|
-
if (ev.button === index$1.KritzelMouseButton.Left) {
|
|
449
|
-
this.isLeftButtonDown = true;
|
|
450
|
-
this.cursorTrailPoints = [];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
if (ev.pointerType === 'touch') {
|
|
454
|
-
if (this.store.state.pointers.size === 1) {
|
|
455
|
-
this.isLeftButtonDown = true;
|
|
456
|
-
this.cursorTrailPoints = [];
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
handlePointerMove(ev) {
|
|
461
|
-
if (!this.isLeftButtonDown) {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
const newPoint = { x: ev.clientX, y: ev.clientY, timestamp: Date.now() };
|
|
465
|
-
const updatedTrail = [newPoint, ...this.cursorTrailPoints];
|
|
466
|
-
if (updatedTrail.length > this.MAX_TRAIL_POINTS) {
|
|
467
|
-
this.cursorTrailPoints = updatedTrail.slice(0, this.MAX_TRAIL_POINTS);
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
this.cursorTrailPoints = updatedTrail;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
handlePointerUp(ev) {
|
|
474
|
-
if (ev.pointerType === 'mouse') {
|
|
475
|
-
if (ev.button === index$1.KritzelMouseButton.Left) {
|
|
476
|
-
this.isLeftButtonDown = false;
|
|
477
|
-
this.cursorTrailPoints = [];
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
if (ev.pointerType === 'touch') {
|
|
481
|
-
if (this.store.state.pointers.size === 0) {
|
|
482
|
-
this.isLeftButtonDown = false;
|
|
483
|
-
this.cursorTrailPoints = [];
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
render() {
|
|
488
|
-
return (index.h(index.Host, { key: '2e6ee739a4c25cee00470ee95ca22e55712c8d7b' }, this.cursorTrailPoints.length > 1 && (index.h("svg", { key: '483aa687ccd290980ca9c588a84547df2bfdb659', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
489
|
-
position: 'absolute',
|
|
490
|
-
left: '0',
|
|
491
|
-
top: '0',
|
|
492
|
-
width: '100%',
|
|
493
|
-
height: '100%',
|
|
494
|
-
pointerEvents: 'none',
|
|
495
|
-
opacity: 'var(--kritzel-cursor-trail-opacity, 0.6)',
|
|
496
|
-
zIndex: '9000',
|
|
497
|
-
} }, this.cursorTrailPoints.slice(1).map((point, index$1) => {
|
|
498
|
-
const prevPoint = this.cursorTrailPoints[index$1];
|
|
499
|
-
const now = Date.now();
|
|
500
|
-
const age = now - point.timestamp;
|
|
501
|
-
const progress = Math.max(0, Math.min(1, age / this.TRAIL_DURATION_MS));
|
|
502
|
-
if (progress >= 1)
|
|
503
|
-
return null;
|
|
504
|
-
const baseStrokeWidth = Math.max(2, 15 * (1 - progress));
|
|
505
|
-
return (index.h("line", { key: `trail-segment-${point.timestamp}`, x1: prevPoint.x.toString(), y1: prevPoint.y.toString(), x2: point.x.toString(), y2: point.y.toString(), stroke: "var(--kritzel-cursor-trail-color, rgb(228, 228, 228))", "stroke-width": baseStrokeWidth.toString(), "stroke-linecap": "round" }));
|
|
506
|
-
})))));
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
KritzelCursorTrail.style = kritzelCursorTrailCss;
|
|
510
|
-
|
|
511
|
-
const kritzelDropdownCss = ":host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23333333\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"/></svg>');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}";
|
|
512
|
-
|
|
513
|
-
const KritzelDropdown = class {
|
|
514
|
-
constructor(hostRef) {
|
|
515
|
-
index.registerInstance(this, hostRef);
|
|
516
|
-
this.valueChanged = index.createEvent(this, "valueChanged");
|
|
517
|
-
this.options = [];
|
|
518
|
-
this.selectStyles = {};
|
|
519
|
-
this.hasSuffixContent = false;
|
|
520
|
-
this.hasPrefixContent = false;
|
|
521
|
-
this.handleSelectChange = (event) => {
|
|
522
|
-
const newValue = event.target.value;
|
|
523
|
-
if (this.internalValue !== newValue) {
|
|
524
|
-
this.internalValue = newValue;
|
|
525
|
-
this.valueChanged.emit(this.internalValue);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
this.evaluateSuffixContent = () => {
|
|
529
|
-
if (this.suffixSlotElement) {
|
|
530
|
-
const newHasContent = this.suffixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
531
|
-
if (this.hasSuffixContent !== newHasContent) {
|
|
532
|
-
this.hasSuffixContent = newHasContent;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
if (this.hasSuffixContent !== false) {
|
|
537
|
-
this.hasSuffixContent = false;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
this.evaluatePrefixContent = () => {
|
|
542
|
-
if (this.prefixSlotElement) {
|
|
543
|
-
const newHasContent = this.prefixSlotElement.assignedNodes({ flatten: true }).length > 0;
|
|
544
|
-
if (this.hasPrefixContent !== newHasContent) {
|
|
545
|
-
this.hasPrefixContent = newHasContent;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
if (this.hasPrefixContent !== false) {
|
|
550
|
-
this.hasPrefixContent = false;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
componentWillLoad() {
|
|
556
|
-
this.updateInternalValue(this.value, false);
|
|
557
|
-
this.evaluateSuffixContent();
|
|
558
|
-
this.evaluatePrefixContent();
|
|
559
|
-
}
|
|
560
|
-
externalValueChanged(newValue) {
|
|
561
|
-
if (newValue !== this.internalValue) {
|
|
562
|
-
this.updateInternalValue(newValue, false);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
optionsChanged() {
|
|
566
|
-
this.updateInternalValue(this.internalValue, true);
|
|
567
|
-
}
|
|
568
|
-
updateInternalValue(proposedValue, emitChange) {
|
|
569
|
-
let finalValue = proposedValue;
|
|
570
|
-
if (this.options && this.options.length > 0) {
|
|
571
|
-
const isValidValue = this.options.some(opt => opt.value === finalValue);
|
|
572
|
-
if (!finalValue || !isValidValue) {
|
|
573
|
-
finalValue = this.options[0].value;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
finalValue = undefined;
|
|
578
|
-
}
|
|
579
|
-
if (this.internalValue !== finalValue) {
|
|
580
|
-
this.internalValue = finalValue;
|
|
581
|
-
if (emitChange || (proposedValue !== finalValue && proposedValue !== undefined)) {
|
|
582
|
-
this.valueChanged.emit(this.internalValue);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
render() {
|
|
587
|
-
const selectClasses = {
|
|
588
|
-
'custom-select': true,
|
|
589
|
-
'has-suffix-border': this.hasSuffixContent,
|
|
590
|
-
'has-prefix-border': this.hasPrefixContent,
|
|
591
|
-
};
|
|
592
|
-
return (index.h(index.Host, { key: '32c5f5a4f807c1e316c91b795c005b8d30ce6189' }, index.h("div", { key: 'b1cbeff18e688da4a2f7472be290b9527a619f07', class: "dropdown-wrapper" }, index.h("slot", { key: 'b3bbb7e21c6f5620cab41aa4b1c7206b6c75fd86', name: "prefix", ref: el => this.prefixSlotElement = el, onSlotchange: this.evaluatePrefixContent }), index.h("select", { key: '8b2dcdc125bee59cf29fce7c980b755e78d5816e', class: selectClasses, style: Object.assign(Object.assign({}, this.selectStyles), { width: this.width }), onInput: this.handleSelectChange }, this.options.map(option => (index.h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), index.h("slot", { key: '8d83f0dea41ac959bf2392948efef33bb70d0154', name: "suffix", ref: el => this.suffixSlotElement = el, onSlotchange: this.evaluateSuffixContent }))));
|
|
593
|
-
}
|
|
594
|
-
static get watchers() { return {
|
|
595
|
-
"value": ["externalValueChanged"],
|
|
596
|
-
"options": ["optionsChanged"]
|
|
597
|
-
}; }
|
|
598
|
-
};
|
|
599
|
-
KritzelDropdown.style = kritzelDropdownCss;
|
|
600
|
-
|
|
601
|
-
class KritzelIconRegistry {
|
|
602
|
-
static register(name, svgContent) {
|
|
603
|
-
if (this.registry.has(name)) {
|
|
604
|
-
console.warn(`[IconRegistry] Icon "${name}" is already registered. It will be overwritten.`);
|
|
605
|
-
}
|
|
606
|
-
this.registry.set(name, svgContent);
|
|
607
|
-
}
|
|
608
|
-
static get(name) {
|
|
609
|
-
return this.registry.get(name);
|
|
610
|
-
}
|
|
611
|
-
static registerIcons(icons) {
|
|
612
|
-
for (const name in icons) {
|
|
613
|
-
if (Object.prototype.hasOwnProperty.call(icons, name)) {
|
|
614
|
-
this.register(name, icons[name]);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
static has(name) {
|
|
619
|
-
return this.registry.has(name);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
KritzelIconRegistry.registry = new Map();
|
|
623
|
-
KritzelIconRegistry.registerIcons({
|
|
624
|
-
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
|
|
625
|
-
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
|
|
626
|
-
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
|
|
627
|
-
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
|
|
628
|
-
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
|
|
629
|
-
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
|
|
630
|
-
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
|
|
631
|
-
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
|
|
632
|
-
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
633
|
-
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
|
|
634
|
-
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
|
|
635
|
-
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
|
|
636
|
-
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
|
|
637
|
-
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
|
|
638
|
-
'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>',
|
|
639
|
-
'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>',
|
|
640
|
-
'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>',
|
|
641
|
-
'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>'
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
const ABSOLUTE_SCALE_MAX = 1000;
|
|
645
|
-
const ABSOLUTE_SCALE_MIN = 0.0001;
|
|
646
|
-
|
|
647
|
-
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}";
|
|
648
|
-
|
|
649
|
-
const KritzelEditor = class {
|
|
650
|
-
constructor(hostRef) {
|
|
651
|
-
index.registerInstance(this, hostRef);
|
|
652
|
-
this.isReady = index.createEvent(this, "isReady");
|
|
653
|
-
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
654
|
-
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
655
|
-
this.controls = [
|
|
656
|
-
{
|
|
657
|
-
name: 'selection',
|
|
658
|
-
type: 'tool',
|
|
659
|
-
tool: index$1.KritzelSelectionTool,
|
|
660
|
-
icon: 'cursor',
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
name: 'brush',
|
|
664
|
-
type: 'tool',
|
|
665
|
-
tool: index$1.KritzelBrushTool,
|
|
666
|
-
icon: 'pen',
|
|
667
|
-
isDefault: true,
|
|
668
|
-
config: index$1.DEFAULT_BRUSH_CONFIG,
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
name: 'eraser',
|
|
672
|
-
type: 'tool',
|
|
673
|
-
tool: index$1.KritzelEraserTool,
|
|
674
|
-
icon: 'eraser',
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
name: 'text',
|
|
678
|
-
type: 'tool',
|
|
679
|
-
tool: index$1.KritzelTextTool,
|
|
680
|
-
icon: 'type',
|
|
681
|
-
config: index$1.DEFAULT_TEXT_CONFIG,
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
name: 'image',
|
|
685
|
-
type: 'tool',
|
|
686
|
-
tool: index$1.KritzelImageTool,
|
|
687
|
-
icon: 'image',
|
|
688
|
-
},
|
|
689
|
-
{
|
|
690
|
-
name: 'divider',
|
|
691
|
-
type: 'divider',
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
name: 'config',
|
|
695
|
-
type: 'config',
|
|
696
|
-
},
|
|
697
|
-
];
|
|
698
|
-
this.globalContextMenuItems = [
|
|
699
|
-
{
|
|
700
|
-
label: 'Paste',
|
|
701
|
-
icon: 'paste',
|
|
702
|
-
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
703
|
-
action: menu => this.engineRef.paste(menu.x, menu.y),
|
|
704
|
-
},
|
|
705
|
-
{ label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
|
|
706
|
-
];
|
|
707
|
-
this.objectContextMenuItems = [
|
|
708
|
-
{
|
|
709
|
-
label: 'Edit',
|
|
710
|
-
icon: 'pen',
|
|
711
|
-
visible: (_, objects) => objects.length === 1 && objects[0].isEditable,
|
|
712
|
-
action: (_, objects) => {
|
|
713
|
-
if (objects.length === 1) {
|
|
714
|
-
const object = objects[0];
|
|
715
|
-
if (object.isEditable) {
|
|
716
|
-
object.edit();
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
},
|
|
721
|
-
{ label: 'Copy', icon: 'copy', action: () => this.engineRef.copy() },
|
|
722
|
-
{
|
|
723
|
-
label: 'Paste',
|
|
724
|
-
icon: 'paste',
|
|
725
|
-
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
726
|
-
action: (menu, _) => this.engineRef.paste(menu.x, menu.y),
|
|
727
|
-
},
|
|
728
|
-
{ label: 'Delete', icon: 'delete', action: () => this.engineRef.delete() },
|
|
729
|
-
{ label: 'Bring to Front', icon: 'bring-to-front', action: () => this.engineRef.moveToTop() },
|
|
730
|
-
{ label: 'Send to Back', icon: 'send-to-back', action: () => this.engineRef.moveToBottom() },
|
|
731
|
-
];
|
|
732
|
-
this.customSvgIcons = {};
|
|
733
|
-
this.isControlsVisible = true;
|
|
734
|
-
this.isUtilityPanelVisible = true;
|
|
735
|
-
this.isEngineReady = false;
|
|
736
|
-
this.isControlsReady = false;
|
|
737
|
-
}
|
|
738
|
-
onIsEngineReady(newValue) {
|
|
739
|
-
if (newValue && this.isControlsReady) {
|
|
740
|
-
this.checkIsReady();
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
onIsControlsReady(newValue) {
|
|
744
|
-
if (newValue && this.isEngineReady) {
|
|
745
|
-
this.checkIsReady();
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
async getObjectById(id) {
|
|
749
|
-
return this.engineRef.getObjectById(id);
|
|
750
|
-
}
|
|
751
|
-
async addObject(object) {
|
|
752
|
-
return this.engineRef.addObject(object);
|
|
753
|
-
}
|
|
754
|
-
async updateObject(object, updatedProperties) {
|
|
755
|
-
return this.engineRef.updateObject(object, updatedProperties);
|
|
756
|
-
}
|
|
757
|
-
async removeObject(object) {
|
|
758
|
-
return this.engineRef.removeObject(object);
|
|
759
|
-
}
|
|
760
|
-
async getSelectedObjects() {
|
|
761
|
-
return this.engineRef.getSelectedObjects();
|
|
762
|
-
}
|
|
763
|
-
async selectObjects(objects) {
|
|
764
|
-
return this.engineRef.selectObjects(objects);
|
|
765
|
-
}
|
|
766
|
-
async selectAllObjectsInViewport() {
|
|
767
|
-
return this.engineRef.selectAllObjectsInViewport();
|
|
768
|
-
}
|
|
769
|
-
async clearSelection() {
|
|
770
|
-
this.engineRef.clearSelection();
|
|
771
|
-
}
|
|
772
|
-
async centerObjectInViewport(object) {
|
|
773
|
-
return this.engineRef.centerObjectInViewport(object);
|
|
774
|
-
}
|
|
775
|
-
handleTouchStart(event) {
|
|
776
|
-
if (event.cancelable) {
|
|
777
|
-
event.preventDefault();
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
handleKeyDown(event) {
|
|
781
|
-
var _a;
|
|
782
|
-
if (event.key === 'Escape') {
|
|
783
|
-
event.preventDefault();
|
|
784
|
-
(_a = this.controlsRef) === null || _a === void 0 ? void 0 : _a.closeTooltip();
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
componentDidLoad() {
|
|
788
|
-
this.registerCustomSvgIcons();
|
|
789
|
-
}
|
|
790
|
-
async checkIsReady() {
|
|
791
|
-
await customElements.whenDefined('kritzel-editor');
|
|
792
|
-
await customElements.whenDefined('kritzel-controls');
|
|
793
|
-
await customElements.whenDefined('kritzel-engine');
|
|
794
|
-
if (!this.isEngineReady || !this.isControlsReady) {
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
this.isReady.emit(this.host);
|
|
798
|
-
}
|
|
799
|
-
registerCustomSvgIcons() {
|
|
800
|
-
for (const [name, svg] of Object.entries(this.customSvgIcons)) {
|
|
801
|
-
KritzelIconRegistry.register(name, svg);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
render() {
|
|
805
|
-
return (index.h(index.Host, { key: 'f2fa7efff5baf4df8a9b2100b96e1546731b006b' }, index.h("kritzel-engine", { key: 'd4fc5d1b0827656119b14c9e2971818904f41c3f', ref: el => (this.engineRef = el), onIsEngineReady: () => (this.isEngineReady = true), scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems }), index.h("kritzel-controls", { key: 'd5f3a9b3d23090bbc8f36b8f974226697868988d', ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, style: this.isControlsVisible ? { display: 'flex' } : { display: 'none' }, onIsControlsReady: () => (this.isControlsReady = true) })));
|
|
806
|
-
}
|
|
807
|
-
get host() { return index.getElement(this); }
|
|
808
|
-
static get watchers() { return {
|
|
809
|
-
"isEngineReady": ["onIsEngineReady"],
|
|
810
|
-
"isControlsReady": ["onIsControlsReady"]
|
|
811
|
-
}; }
|
|
812
|
-
};
|
|
813
|
-
KritzelEditor.style = kritzelEditorCss;
|
|
814
|
-
|
|
815
|
-
class KritzelViewport {
|
|
816
|
-
constructor(store, host) {
|
|
817
|
-
this.initialTouchDistance = 0;
|
|
818
|
-
this.startX = 0;
|
|
819
|
-
this.startY = 0;
|
|
820
|
-
this._store = store;
|
|
821
|
-
this._store.state.host = host;
|
|
822
|
-
this._store.state.viewportWidth = host.clientWidth;
|
|
823
|
-
this._store.state.viewportHeight = host.clientHeight;
|
|
824
|
-
this._store.state.startX = 0;
|
|
825
|
-
this._store.state.startY = 0;
|
|
826
|
-
this._store.state.translateX = 0;
|
|
827
|
-
this._store.state.translateY = 0;
|
|
828
|
-
}
|
|
829
|
-
handleResize() {
|
|
830
|
-
this._store.state.viewportWidth = this._store.state.host.clientWidth;
|
|
831
|
-
this._store.state.viewportHeight = this._store.state.host.clientHeight;
|
|
832
|
-
this._store.state.hasViewportChanged = true;
|
|
833
|
-
this._store.rerender();
|
|
834
|
-
}
|
|
835
|
-
handlePointerDown(event) {
|
|
836
|
-
if (event.pointerType === 'mouse') {
|
|
837
|
-
const adjustedClientX = event.clientX - this._store.offsetX;
|
|
838
|
-
const adjustedClientY = event.clientY - this._store.offsetY;
|
|
839
|
-
if (event.button === index$1.KritzelMouseButton.Right) {
|
|
840
|
-
this._store.state.isPanning = true;
|
|
841
|
-
this._store.state.startX = adjustedClientX;
|
|
842
|
-
this._store.state.startY = adjustedClientY;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
if (event.pointerType === 'touch') {
|
|
846
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
847
|
-
if (activePointers.length === 2) {
|
|
848
|
-
this._store.state.currentPath = null;
|
|
849
|
-
this._store.state.isScaling = true;
|
|
850
|
-
const firstTouchX = activePointers[0].clientX - this._store.offsetX;
|
|
851
|
-
const firstTouchY = activePointers[0].clientY - this._store.offsetY;
|
|
852
|
-
const secondTouchX = activePointers[1].clientX - this._store.offsetX;
|
|
853
|
-
const secondTouchY = activePointers[1].clientY - this._store.offsetY;
|
|
854
|
-
this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
|
|
855
|
-
this.startX = (firstTouchX + secondTouchX) / 2;
|
|
856
|
-
this.startY = (firstTouchY + secondTouchY) / 2;
|
|
857
|
-
this._store.rerender();
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
handlePointerMove(event) {
|
|
862
|
-
if (event.pointerType === 'mouse') {
|
|
863
|
-
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
864
|
-
const xRelativeToHost = event.clientX - hostRect.left;
|
|
865
|
-
const yRelativeToHost = event.clientY - hostRect.top;
|
|
866
|
-
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
867
|
-
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
868
|
-
if (this._store.state.isPanning) {
|
|
869
|
-
this._store.state.translateX -= this._store.state.startX - xRelativeToHost;
|
|
870
|
-
this._store.state.translateY -= this._store.state.startY - yRelativeToHost;
|
|
871
|
-
this._store.state.startX = xRelativeToHost;
|
|
872
|
-
this._store.state.startY = yRelativeToHost;
|
|
873
|
-
this._store.state.hasViewportChanged = true;
|
|
874
|
-
this._store.state.skipContextMenu = true;
|
|
875
|
-
this._store.rerender();
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
if (event.pointerType === 'touch') {
|
|
879
|
-
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
880
|
-
const xRelativeToHost = event.clientX - hostRect.left;
|
|
881
|
-
const yRelativeToHost = event.clientY - hostRect.top;
|
|
882
|
-
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
883
|
-
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
884
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
885
|
-
if (activePointers.length === 2) {
|
|
886
|
-
const firstTouchX = activePointers[0].clientX - this._store.offsetX;
|
|
887
|
-
const firstTouchY = activePointers[0].clientY - this._store.offsetY;
|
|
888
|
-
const secondTouchX = activePointers[1].clientX - this._store.offsetX;
|
|
889
|
-
const secondTouchY = activePointers[1].clientY - this._store.offsetY;
|
|
890
|
-
const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
|
|
891
|
-
const midpointX = (firstTouchX + secondTouchX) / 2;
|
|
892
|
-
const midpointY = (firstTouchY + secondTouchY) / 2;
|
|
893
|
-
const scaleRatio = currentTouchDistance / this.initialTouchDistance;
|
|
894
|
-
const newScale = this._store.state.scale * scaleRatio;
|
|
895
|
-
if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
|
|
896
|
-
this._store.state.translateX += midpointX - this.startX;
|
|
897
|
-
this._store.state.translateY += midpointY - this.startY;
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
|
|
901
|
-
const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
|
|
902
|
-
this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
|
|
903
|
-
this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
|
|
904
|
-
this._store.state.scale = newScale;
|
|
905
|
-
this.initialTouchDistance = currentTouchDistance;
|
|
906
|
-
}
|
|
907
|
-
this.startX = midpointX;
|
|
908
|
-
this.startY = midpointY;
|
|
909
|
-
this._store.state.hasViewportChanged = true;
|
|
910
|
-
this._store.rerender();
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
handlePointerUp(event) {
|
|
915
|
-
if (event.pointerType === 'mouse') {
|
|
916
|
-
if (this._store.state.isPanning) {
|
|
917
|
-
this._store.state.isPanning = false;
|
|
918
|
-
this._store.rerender();
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
if (event.pointerType === 'touch') {
|
|
922
|
-
this._store.state.isScaling = false;
|
|
923
|
-
this._store.rerender();
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
handleWheel(event) {
|
|
927
|
-
event.preventDefault();
|
|
928
|
-
if (event.ctrlKey === true && index$1.KritzelEventHelper.isMainMouseWheel(event)) {
|
|
929
|
-
this.handleZoom(event);
|
|
930
|
-
}
|
|
931
|
-
if (!event.ctrlKey) {
|
|
932
|
-
this.handlePan(event);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
handleZoom(event) {
|
|
936
|
-
const rect = this._store.state.host.getBoundingClientRect();
|
|
937
|
-
const xRelativeToHost = event.clientX - rect.left;
|
|
938
|
-
const yRelativeToHost = event.clientY - rect.top;
|
|
939
|
-
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
940
|
-
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
941
|
-
const delta = event.deltaY > 0 ? -this._store.state.scaleStep * this._store.state.scale : this._store.state.scaleStep * this._store.state.scale;
|
|
942
|
-
const newScale = Math.min(this._store.state.scaleMax, Math.max(this._store.state.scaleMin, this._store.state.scale + delta));
|
|
943
|
-
const scaleRatio = newScale / this._store.state.scale;
|
|
944
|
-
const translateXAdjustment = (xRelativeToHost - this._store.state.translateX) * (scaleRatio - 1);
|
|
945
|
-
const translateYAdjustment = (yRelativeToHost - this._store.state.translateY) * (scaleRatio - 1);
|
|
946
|
-
this._store.state.scale = newScale;
|
|
947
|
-
this._store.state.translateX -= translateXAdjustment;
|
|
948
|
-
this._store.state.translateY -= translateYAdjustment;
|
|
949
|
-
this._store.state.hasViewportChanged = true;
|
|
950
|
-
this._store.rerender();
|
|
951
|
-
}
|
|
952
|
-
handlePan(event) {
|
|
953
|
-
const panSpeed = 0.8;
|
|
954
|
-
this._store.state.translateX -= event.deltaX * panSpeed;
|
|
955
|
-
this._store.state.translateY -= event.deltaY * panSpeed;
|
|
956
|
-
this._store.state.hasViewportChanged = true;
|
|
957
|
-
this._store.rerender();
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
class UpdateViewportCommand extends index$1.KritzelBaseCommand {
|
|
962
|
-
constructor(store, initiator, previousViewport) {
|
|
963
|
-
super(store, initiator);
|
|
964
|
-
this.previousViewport = previousViewport;
|
|
965
|
-
this.currentViewport = {
|
|
966
|
-
scale: this._store.state.scale,
|
|
967
|
-
translateX: this._store.state.translateX,
|
|
968
|
-
translateY: this._store.state.translateY,
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
execute() {
|
|
972
|
-
this._store.state.scale = this.currentViewport.scale;
|
|
973
|
-
this._store.state.translateX = this.currentViewport.translateX;
|
|
974
|
-
this._store.state.translateY = this.currentViewport.translateY;
|
|
975
|
-
}
|
|
976
|
-
undo() {
|
|
977
|
-
this._store.state.scale = this.previousViewport.scale;
|
|
978
|
-
this._store.state.translateX = this.previousViewport.translateX;
|
|
979
|
-
this._store.state.translateY = this.previousViewport.translateY;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
class KritzelCircularBuffer {
|
|
984
|
-
constructor(capacity) {
|
|
985
|
-
this.head = 0;
|
|
986
|
-
this.tail = 0;
|
|
987
|
-
this.size = 0;
|
|
988
|
-
this.capacity = capacity;
|
|
989
|
-
this.buffer = new Array(capacity).fill(null);
|
|
990
|
-
}
|
|
991
|
-
add(item) {
|
|
992
|
-
this.buffer[this.head] = item;
|
|
993
|
-
this.head = (this.head + 1) % this.capacity;
|
|
994
|
-
if (this.size < this.capacity) {
|
|
995
|
-
this.size++;
|
|
996
|
-
}
|
|
997
|
-
else {
|
|
998
|
-
this.tail = (this.tail + 1) % this.capacity;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
pop() {
|
|
1002
|
-
if (this.size === 0) {
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
this.head = (this.head - 1 + this.capacity) % this.capacity;
|
|
1006
|
-
const item = this.buffer[this.head];
|
|
1007
|
-
this.buffer[this.head] = null;
|
|
1008
|
-
this.size--;
|
|
1009
|
-
return item;
|
|
1010
|
-
}
|
|
1011
|
-
peek() {
|
|
1012
|
-
if (this.size === 0) {
|
|
1013
|
-
return null;
|
|
1014
|
-
}
|
|
1015
|
-
const lastIndex = (this.head - 1 + this.capacity) % this.capacity;
|
|
1016
|
-
return this.buffer[lastIndex];
|
|
1017
|
-
}
|
|
1018
|
-
isEmpty() {
|
|
1019
|
-
return this.size === 0;
|
|
1020
|
-
}
|
|
1021
|
-
clear() {
|
|
1022
|
-
this.buffer.fill(null);
|
|
1023
|
-
this.head = 0;
|
|
1024
|
-
this.tail = 0;
|
|
1025
|
-
this.size = 0;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
class KritzelHistory {
|
|
1030
|
-
constructor(store) {
|
|
1031
|
-
this._store = store;
|
|
1032
|
-
this.undoStack = new KritzelCircularBuffer(this._store.state.historyBufferSize);
|
|
1033
|
-
this.redoStack = new KritzelCircularBuffer(this._store.state.historyBufferSize);
|
|
1034
|
-
this.previousViewport = {
|
|
1035
|
-
scale: this._store.state.scale,
|
|
1036
|
-
scaleStep: this._store.state.scaleStep,
|
|
1037
|
-
translateX: this._store.state.translateX,
|
|
1038
|
-
translateY: this._store.state.translateY,
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
executeCommand(command) {
|
|
1042
|
-
if (this._store.state.hasViewportChanged) {
|
|
1043
|
-
this.addUpdateViewportCommand();
|
|
1044
|
-
}
|
|
1045
|
-
command.execute();
|
|
1046
|
-
if (this._store.state.debugInfo.logCommands)
|
|
1047
|
-
console.info('add', command);
|
|
1048
|
-
this.undoStack.add(command);
|
|
1049
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1050
|
-
this.redoStack.clear();
|
|
1051
|
-
}
|
|
1052
|
-
this._store.rerender();
|
|
1053
|
-
}
|
|
1054
|
-
undo() {
|
|
1055
|
-
if (this._store.state.hasViewportChanged) {
|
|
1056
|
-
const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
|
|
1057
|
-
command.undo();
|
|
1058
|
-
this._store.state.hasViewportChanged = false;
|
|
1059
|
-
this._store.rerender();
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
const command = this.undoStack.pop();
|
|
1063
|
-
if (command) {
|
|
1064
|
-
command.undo();
|
|
1065
|
-
if (this._store.state.debugInfo.logCommands)
|
|
1066
|
-
console.info('undo', command);
|
|
1067
|
-
this.redoStack.add(command);
|
|
1068
|
-
}
|
|
1069
|
-
this._store.rerender();
|
|
1070
|
-
}
|
|
1071
|
-
redo() {
|
|
1072
|
-
const command = this.redoStack.pop();
|
|
1073
|
-
if (command) {
|
|
1074
|
-
command.execute();
|
|
1075
|
-
if (this._store.state.debugInfo.logCommands)
|
|
1076
|
-
console.info('redo', command);
|
|
1077
|
-
this.undoStack.add(command);
|
|
1078
|
-
}
|
|
1079
|
-
this._store.rerender();
|
|
1080
|
-
}
|
|
1081
|
-
addUpdateViewportCommand() {
|
|
1082
|
-
const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
|
|
1083
|
-
command.execute();
|
|
1084
|
-
this.undoStack.add(command);
|
|
1085
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1086
|
-
this.redoStack.clear();
|
|
1087
|
-
}
|
|
1088
|
-
this._store.state.hasViewportChanged = false;
|
|
1089
|
-
this.previousViewport = {
|
|
1090
|
-
scale: this._store.state.scale,
|
|
1091
|
-
scaleStep: this._store.state.scaleStep,
|
|
1092
|
-
translateX: this._store.state.translateX,
|
|
1093
|
-
translateY: this._store.state.translateY,
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
class KritzelOctree {
|
|
1099
|
-
constructor(bounds, capacity = 8) {
|
|
1100
|
-
this.objects = [];
|
|
1101
|
-
this.children = null;
|
|
1102
|
-
this.bounds = bounds;
|
|
1103
|
-
this.capacity = capacity;
|
|
1104
|
-
}
|
|
1105
|
-
insert(object) {
|
|
1106
|
-
if (!this.intersects(object.rotatedBoundingBox, this.bounds)) {
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
if (this.objects.length < this.capacity && this.children === null) {
|
|
1110
|
-
this.objects.push(object);
|
|
1111
|
-
return true;
|
|
1112
|
-
}
|
|
1113
|
-
if (this.children === null) {
|
|
1114
|
-
this.subdivide();
|
|
1115
|
-
}
|
|
1116
|
-
for (const child of this.children) {
|
|
1117
|
-
if (child.insert(object)) {
|
|
1118
|
-
return true;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
return false;
|
|
1122
|
-
}
|
|
1123
|
-
update(object) {
|
|
1124
|
-
const index = this.objects.findIndex(o => o.id === object.id);
|
|
1125
|
-
if (index !== -1) {
|
|
1126
|
-
this.objects[index] = object;
|
|
1127
|
-
return true;
|
|
1128
|
-
}
|
|
1129
|
-
if (this.children !== null) {
|
|
1130
|
-
for (const child of this.children) {
|
|
1131
|
-
if (child.update(object)) {
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
return false;
|
|
1137
|
-
}
|
|
1138
|
-
remove(predicate) {
|
|
1139
|
-
const index = this.objects.findIndex(o => predicate(o));
|
|
1140
|
-
if (index !== -1) {
|
|
1141
|
-
this.objects.splice(index, 1);
|
|
1142
|
-
}
|
|
1143
|
-
if (this.children !== null) {
|
|
1144
|
-
for (const child of this.children) {
|
|
1145
|
-
child.remove(predicate);
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
query(range) {
|
|
1150
|
-
const results = [];
|
|
1151
|
-
if (!this.intersects(range, this.bounds)) {
|
|
1152
|
-
return results;
|
|
1153
|
-
}
|
|
1154
|
-
for (const object of this.objects) {
|
|
1155
|
-
if (this.intersects(object.rotatedBoundingBox, range)) {
|
|
1156
|
-
results.push(object);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
if (this.children !== null) {
|
|
1160
|
-
for (const child of this.children) {
|
|
1161
|
-
results.push(...child.query(range));
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
return results;
|
|
1165
|
-
}
|
|
1166
|
-
filter(predicate) {
|
|
1167
|
-
const results = this.objects.filter(o => predicate(o));
|
|
1168
|
-
if (this.children !== null) {
|
|
1169
|
-
for (const child of this.children) {
|
|
1170
|
-
results.push(...child.filter(predicate));
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
return results;
|
|
1174
|
-
}
|
|
1175
|
-
allObjects() {
|
|
1176
|
-
const results = [...this.objects];
|
|
1177
|
-
if (this.children !== null) {
|
|
1178
|
-
for (const child of this.children) {
|
|
1179
|
-
results.push(...child.allObjects());
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
return results;
|
|
1183
|
-
}
|
|
1184
|
-
subdivide() {
|
|
1185
|
-
const { x, y, z, width, height, depth } = this.bounds;
|
|
1186
|
-
const halfWidth = width / 2;
|
|
1187
|
-
const halfHeight = height / 2;
|
|
1188
|
-
const halfDepth = depth / 2;
|
|
1189
|
-
this.children = [
|
|
1190
|
-
new KritzelOctree({ x, y, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1191
|
-
new KritzelOctree({ x: x + halfWidth, y, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1192
|
-
new KritzelOctree({ x, y: y + halfHeight, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1193
|
-
new KritzelOctree({ x: x + halfWidth, y: y + halfHeight, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1194
|
-
new KritzelOctree({ x, y, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1195
|
-
new KritzelOctree({ x: x + halfWidth, y, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1196
|
-
new KritzelOctree({ x, y: y + halfHeight, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1197
|
-
new KritzelOctree({ x: x + halfWidth, y: y + halfHeight, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
|
|
1198
|
-
];
|
|
1199
|
-
}
|
|
1200
|
-
intersects(a, b) {
|
|
1201
|
-
return !(a.x >= b.x + b.width || // a is completely to the right of b
|
|
1202
|
-
a.x + a.width <= b.x || // a is completely to the left of b
|
|
1203
|
-
a.y >= b.y + b.height || // a is completely below b
|
|
1204
|
-
a.y + a.height <= b.y // a is completely above b
|
|
1205
|
-
);
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
class UpdateObjectCommand extends index$1.KritzelBaseCommand {
|
|
1210
|
-
constructor(store, initiator, object, updatedProperties) {
|
|
1211
|
-
super(store, initiator);
|
|
1212
|
-
this.object = object;
|
|
1213
|
-
this.updatedProperties = updatedProperties;
|
|
1214
|
-
this.previousProperties = {};
|
|
1215
|
-
for (const key in updatedProperties) {
|
|
1216
|
-
if (updatedProperties.hasOwnProperty(key)) {
|
|
1217
|
-
this.previousProperties[key] = this.object[key];
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
execute() {
|
|
1222
|
-
for (const key in this.updatedProperties) {
|
|
1223
|
-
if (this.updatedProperties.hasOwnProperty(key)) {
|
|
1224
|
-
this.object[key] = this.updatedProperties[key];
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
undo() {
|
|
1229
|
-
for (const key in this.previousProperties) {
|
|
1230
|
-
if (this.previousProperties.hasOwnProperty(key)) {
|
|
1231
|
-
this.object[key] = this.previousProperties[key];
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
const DEFAULT_ENGINE_STATE = {
|
|
1238
|
-
activeTool: null,
|
|
1239
|
-
activeText: null,
|
|
1240
|
-
currentPath: null,
|
|
1241
|
-
copiedObjects: null,
|
|
1242
|
-
objectsOctree: null,
|
|
1243
|
-
selectionBox: null,
|
|
1244
|
-
selectionGroup: null,
|
|
1245
|
-
resizeHandleType: null,
|
|
1246
|
-
hasViewportChanged: false,
|
|
1247
|
-
isReady: false,
|
|
1248
|
-
isEnabled: true,
|
|
1249
|
-
isScaling: false,
|
|
1250
|
-
isPanning: false,
|
|
1251
|
-
isFocused: false,
|
|
1252
|
-
isSelecting: false,
|
|
1253
|
-
isResizing: false,
|
|
1254
|
-
isResizeHandleSelected: false,
|
|
1255
|
-
isRotating: false,
|
|
1256
|
-
isRotationHandleSelected: false,
|
|
1257
|
-
isDragging: false,
|
|
1258
|
-
isDrawing: false,
|
|
1259
|
-
isErasing: false,
|
|
1260
|
-
isWriting: false,
|
|
1261
|
-
isCtrlKeyPressed: false,
|
|
1262
|
-
isContextMenuVisible: false,
|
|
1263
|
-
contextMenuItems: [],
|
|
1264
|
-
contextMenuX: 0,
|
|
1265
|
-
contextMenuY: 0,
|
|
1266
|
-
skipContextMenu: false,
|
|
1267
|
-
debugInfo: {
|
|
1268
|
-
showObjectInfo: false,
|
|
1269
|
-
showViewportInfo: false,
|
|
1270
|
-
logCommands: false,
|
|
1271
|
-
},
|
|
1272
|
-
host: null,
|
|
1273
|
-
pointerX: 0,
|
|
1274
|
-
pointerY: 0,
|
|
1275
|
-
scale: 1,
|
|
1276
|
-
scaleMax: 1,
|
|
1277
|
-
scaleMin: 1,
|
|
1278
|
-
scaleStep: 0.05,
|
|
1279
|
-
startX: 0,
|
|
1280
|
-
startY: 0,
|
|
1281
|
-
translateX: 0,
|
|
1282
|
-
translateXMax: 400,
|
|
1283
|
-
translateXMin: 0,
|
|
1284
|
-
translateY: 0,
|
|
1285
|
-
translateYMax: 400,
|
|
1286
|
-
translateYMin: 0,
|
|
1287
|
-
viewportWidth: 0,
|
|
1288
|
-
viewportHeight: 0,
|
|
1289
|
-
historyBufferSize: 1000,
|
|
1290
|
-
longTouchTimeout: null,
|
|
1291
|
-
longTouchDelay: 300,
|
|
1292
|
-
pointers: new Map()
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
class KritzelStore {
|
|
1296
|
-
get history() {
|
|
1297
|
-
return this._history;
|
|
1298
|
-
}
|
|
1299
|
-
get state() {
|
|
1300
|
-
return this._state;
|
|
1301
|
-
}
|
|
1302
|
-
get currentZIndex() {
|
|
1303
|
-
return this._state.objectsOctree.filter(o => !(o instanceof index$1.KritzelSelectionGroup) && !(o instanceof index$1.KrtizelSelectionBox)).length;
|
|
1304
|
-
}
|
|
1305
|
-
get allObjects() {
|
|
1306
|
-
return this._state.objectsOctree.allObjects();
|
|
1307
|
-
}
|
|
1308
|
-
get selectedObjects() {
|
|
1309
|
-
return this.allObjects.filter(o => !(o instanceof index$1.KritzelSelectionGroup)).filter(o => o.isSelected);
|
|
1310
|
-
}
|
|
1311
|
-
get offsetX() {
|
|
1312
|
-
return this._state.host.getBoundingClientRect().left;
|
|
1313
|
-
}
|
|
1314
|
-
get offsetY() {
|
|
1315
|
-
return this._state.host.getBoundingClientRect().top;
|
|
1316
|
-
}
|
|
1317
|
-
constructor(kritzelEngine) {
|
|
1318
|
-
this._listeners = new Map();
|
|
1319
|
-
this.objects = [];
|
|
1320
|
-
this._state = DEFAULT_ENGINE_STATE;
|
|
1321
|
-
this._kritzelEngine = kritzelEngine;
|
|
1322
|
-
this._history = new KritzelHistory(this);
|
|
1323
|
-
this._state.objectsOctree = new KritzelOctree({
|
|
1324
|
-
x: -Infinity,
|
|
1325
|
-
y: -Infinity,
|
|
1326
|
-
z: -Infinity,
|
|
1327
|
-
width: Infinity,
|
|
1328
|
-
height: Infinity,
|
|
1329
|
-
depth: Infinity,
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
rerender() {
|
|
1333
|
-
const viewportBounds = {
|
|
1334
|
-
x: -this._state.translateX / this._state.scale,
|
|
1335
|
-
y: -this._state.translateY / this._state.scale,
|
|
1336
|
-
z: this._state.scale,
|
|
1337
|
-
width: this._state.viewportWidth / this._state.scale,
|
|
1338
|
-
height: this._state.viewportHeight / this._state.scale,
|
|
1339
|
-
depth: 100,
|
|
1340
|
-
};
|
|
1341
|
-
this.objects = this._state.objectsOctree.query(viewportBounds);
|
|
1342
|
-
if (this._kritzelEngine) {
|
|
1343
|
-
this._kritzelEngine.forceUpdate++;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
findObjectById(id) {
|
|
1347
|
-
for (const object of this.allObjects) {
|
|
1348
|
-
if (object.id === id) {
|
|
1349
|
-
return object;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
return null;
|
|
1353
|
-
}
|
|
1354
|
-
deselectAllObjects() {
|
|
1355
|
-
if (this._state.selectionGroup) {
|
|
1356
|
-
this._history.executeCommand(new index$1.RemoveSelectionGroupCommand(this, this));
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
onStateChange(property, listener) {
|
|
1360
|
-
if (!this._listeners.has(property)) {
|
|
1361
|
-
this._listeners.set(property, new Set());
|
|
1362
|
-
}
|
|
1363
|
-
this._listeners.get(property).add(listener);
|
|
1364
|
-
}
|
|
1365
|
-
setState(property, value) {
|
|
1366
|
-
const oldValue = this._state[property];
|
|
1367
|
-
if (oldValue !== value) {
|
|
1368
|
-
this._state[property] = value;
|
|
1369
|
-
if (this._listeners.has(property)) {
|
|
1370
|
-
this._listeners.get(property).forEach(listener => listener(value, oldValue, String(property)));
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
delete() {
|
|
1375
|
-
if (!this.state.selectionGroup) {
|
|
1376
|
-
return;
|
|
1377
|
-
}
|
|
1378
|
-
const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new index$1.RemoveObjectCommand(this, this.state.selectionGroup, obj));
|
|
1379
|
-
const removeSelectionGroupCommand = new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
1380
|
-
const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];
|
|
1381
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this.state.selectionGroup, commands));
|
|
1382
|
-
}
|
|
1383
|
-
deleteObject(id, isHistoryUpdated = true) {
|
|
1384
|
-
const object = this.findObjectById(id);
|
|
1385
|
-
if (object) {
|
|
1386
|
-
if (isHistoryUpdated) {
|
|
1387
|
-
const removeObjectCommand = new index$1.RemoveObjectCommand(this, this, object);
|
|
1388
|
-
this.history.executeCommand(removeObjectCommand);
|
|
1389
|
-
}
|
|
1390
|
-
else {
|
|
1391
|
-
this._state.objectsOctree.remove(obj => obj.id === id);
|
|
1392
|
-
this.rerender();
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
copy() {
|
|
1397
|
-
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
1398
|
-
}
|
|
1399
|
-
paste(x, y) {
|
|
1400
|
-
this.state.copiedObjects.isSelected = true;
|
|
1401
|
-
const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;
|
|
1402
|
-
const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;
|
|
1403
|
-
this.state.copiedObjects.updatePosition(adjustedX, adjustedY);
|
|
1404
|
-
const commands = [];
|
|
1405
|
-
if (this.state.selectionGroup !== null) {
|
|
1406
|
-
commands.push(new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup));
|
|
1407
|
-
}
|
|
1408
|
-
const addCopiedObjectsCommands = this.state.copiedObjects.objects.map(obj => new index$1.AddObjectCommand(this, this, obj));
|
|
1409
|
-
const addCopiedObjectsAsSelectionGroupCommand = new index$1.AddSelectionGroupCommand(this, this, this.state.copiedObjects);
|
|
1410
|
-
commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);
|
|
1411
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this, commands));
|
|
1412
|
-
this.state.isSelecting = false;
|
|
1413
|
-
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
1414
|
-
this.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1415
|
-
}
|
|
1416
|
-
bringForward(object) {
|
|
1417
|
-
const max = this.allObjects.length + 1;
|
|
1418
|
-
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
1419
|
-
const increaseZIndexCommands = objects.map(obj => {
|
|
1420
|
-
if (obj.zIndex === max) {
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });
|
|
1424
|
-
});
|
|
1425
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
1426
|
-
}
|
|
1427
|
-
sendBackward(object) {
|
|
1428
|
-
const min = 0;
|
|
1429
|
-
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
1430
|
-
const decreaseZIndexCommands = objects.map(obj => {
|
|
1431
|
-
if (obj.zIndex === min) {
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });
|
|
1435
|
-
});
|
|
1436
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
1437
|
-
}
|
|
1438
|
-
bringToFront(object) {
|
|
1439
|
-
const max = this.allObjects.length + 1;
|
|
1440
|
-
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
1441
|
-
const increaseZIndexCommands = objects.map(obj => {
|
|
1442
|
-
return new UpdateObjectCommand(this, this, obj, { zIndex: max });
|
|
1443
|
-
});
|
|
1444
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
1445
|
-
}
|
|
1446
|
-
sendToBack(object) {
|
|
1447
|
-
const min = -1;
|
|
1448
|
-
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
1449
|
-
const decreaseZIndexCommands = objects.map(obj => {
|
|
1450
|
-
return new UpdateObjectCommand(this, this, obj, { zIndex: min });
|
|
1451
|
-
});
|
|
1452
|
-
this.history.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
1453
|
-
}
|
|
1454
|
-
selectObjects(objects) {
|
|
1455
|
-
if (objects.length === 0) {
|
|
1456
|
-
return;
|
|
1457
|
-
}
|
|
1458
|
-
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
1459
|
-
objects.forEach(obj => {
|
|
1460
|
-
obj.isSelected = false;
|
|
1461
|
-
selectionGroup.addOrRemove(obj);
|
|
1462
|
-
});
|
|
1463
|
-
selectionGroup.isSelected = true;
|
|
1464
|
-
this.state.selectionGroup = selectionGroup;
|
|
1465
|
-
if (objects.length === 1) {
|
|
1466
|
-
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
1467
|
-
}
|
|
1468
|
-
this.history.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
1469
|
-
}
|
|
1470
|
-
selectAllObjectsInViewport() {
|
|
1471
|
-
const objectsInViewport = this._state.objectsOctree
|
|
1472
|
-
.query({
|
|
1473
|
-
x: -this._state.translateX / this._state.scale,
|
|
1474
|
-
y: -this._state.translateY / this._state.scale,
|
|
1475
|
-
z: this._state.scale,
|
|
1476
|
-
width: this._state.viewportWidth / this._state.scale,
|
|
1477
|
-
height: this._state.viewportHeight / this._state.scale,
|
|
1478
|
-
depth: 100,
|
|
1479
|
-
})
|
|
1480
|
-
.filter(o => !(o instanceof index$1.KritzelSelectionGroup) && !(o instanceof index$1.KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));
|
|
1481
|
-
if (objectsInViewport.length > 0) {
|
|
1482
|
-
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
1483
|
-
objectsInViewport.forEach(obj => {
|
|
1484
|
-
obj.isSelected = false;
|
|
1485
|
-
selectionGroup.addOrRemove(obj);
|
|
1486
|
-
});
|
|
1487
|
-
selectionGroup.isSelected = true;
|
|
1488
|
-
this.state.isSelecting = false;
|
|
1489
|
-
if (objectsInViewport.length === 1) {
|
|
1490
|
-
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
1491
|
-
}
|
|
1492
|
-
this.history.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
1493
|
-
this.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
clearSelection() {
|
|
1497
|
-
const command = new index$1.RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
1498
|
-
this.history.executeCommand(command);
|
|
1499
|
-
this.state.selectionGroup = null;
|
|
1500
|
-
this.state.selectionBox = null;
|
|
1501
|
-
this.state.isSelecting = false;
|
|
1502
|
-
this.state.isResizeHandleSelected = false;
|
|
1503
|
-
this.state.isRotationHandleSelected = false;
|
|
1504
|
-
}
|
|
1505
|
-
resetActiveText() {
|
|
1506
|
-
if (this.state.activeText && this.state.activeText.value === ' ') {
|
|
1507
|
-
this.deleteObject(this.state.activeText.id, false);
|
|
1508
|
-
this.history.undoStack.pop();
|
|
1509
|
-
}
|
|
1510
|
-
this.state.activeText = null;
|
|
1511
|
-
}
|
|
1512
|
-
getObjectFromPointerEvent(event, selector = '.object') {
|
|
1513
|
-
var _a;
|
|
1514
|
-
const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
1515
|
-
if (!shadowRoot)
|
|
1516
|
-
return null;
|
|
1517
|
-
const clientX = event.clientX;
|
|
1518
|
-
const clientY = event.clientY;
|
|
1519
|
-
const elementAtPoint = shadowRoot.elementFromPoint(clientX, clientY);
|
|
1520
|
-
if (!elementAtPoint)
|
|
1521
|
-
return null;
|
|
1522
|
-
const selectedObject = elementAtPoint.closest(selector);
|
|
1523
|
-
if (selectedObject) {
|
|
1524
|
-
return this.allObjects.find(object => selectedObject.id === object.id);
|
|
1525
|
-
}
|
|
1526
|
-
return null;
|
|
1527
|
-
}
|
|
1528
|
-
getObjectsFromPointerEvent(event, selector = '.object') {
|
|
1529
|
-
var _a;
|
|
1530
|
-
const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
1531
|
-
if (!shadowRoot)
|
|
1532
|
-
return [];
|
|
1533
|
-
const clientX = event.clientX;
|
|
1534
|
-
const clientY = event.clientY;
|
|
1535
|
-
const elementsAtPoint = shadowRoot.elementsFromPoint(clientX, clientY);
|
|
1536
|
-
if (!elementsAtPoint || elementsAtPoint.length === 0)
|
|
1537
|
-
return [];
|
|
1538
|
-
const objectIds = new Set();
|
|
1539
|
-
elementsAtPoint.forEach(element => {
|
|
1540
|
-
const selectedObject = element.closest(selector);
|
|
1541
|
-
if (selectedObject && selectedObject.id) {
|
|
1542
|
-
objectIds.add(selectedObject.id);
|
|
1543
|
-
}
|
|
1544
|
-
});
|
|
1545
|
-
if (objectIds.size > 0) {
|
|
1546
|
-
return this.allObjects.filter(object => objectIds.has(object.id)).sort((a, b) => b.zIndex - a.zIndex);
|
|
1547
|
-
}
|
|
1548
|
-
return [];
|
|
1549
|
-
}
|
|
1550
|
-
getCanvasPoint(event) {
|
|
1551
|
-
if (!this.state.host) {
|
|
1552
|
-
return { x: 0, y: 0 };
|
|
1553
|
-
}
|
|
1554
|
-
// Get the position of the kritzel-engine host element relative to the viewport
|
|
1555
|
-
const hostRect = this.state.host.getBoundingClientRect();
|
|
1556
|
-
// 1. Make the pointer coordinates relative to the host element
|
|
1557
|
-
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1558
|
-
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1559
|
-
// 2. Reverse the translation applied to the #origin div
|
|
1560
|
-
const xWithoutTranslate = xRelativeToHost - this.state.translateX;
|
|
1561
|
-
const yWithoutTranslate = yRelativeToHost - this.state.translateY;
|
|
1562
|
-
// 3. Reverse the scaling to get the final world coordinates
|
|
1563
|
-
const worldX = xWithoutTranslate / this.state.scale;
|
|
1564
|
-
const worldY = yWithoutTranslate / this.state.scale;
|
|
1565
|
-
return { x: worldX, y: worldY };
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
class KritzelKeyHandler extends index$1.KritzelBaseHandler {
|
|
1570
|
-
constructor(store) {
|
|
1571
|
-
super(store);
|
|
1572
|
-
}
|
|
1573
|
-
handleKeyDown(event) {
|
|
1574
|
-
if (this._store.state.isFocused === false) {
|
|
1575
|
-
event.preventDefault();
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
this._store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
1579
|
-
if (this._store.state.isCtrlKeyPressed) {
|
|
1580
|
-
event.preventDefault();
|
|
1581
|
-
}
|
|
1582
|
-
if (event.key === 'Escape' && this._store.state.selectionGroup) {
|
|
1583
|
-
this._store.clearSelection();
|
|
1584
|
-
}
|
|
1585
|
-
if (event.key === 'Delete' && this._store.state.selectionGroup) {
|
|
1586
|
-
this._store.delete();
|
|
1587
|
-
}
|
|
1588
|
-
if (event.key === 'z' && event.ctrlKey) {
|
|
1589
|
-
this._store.history.undo();
|
|
1590
|
-
}
|
|
1591
|
-
if (event.key === 'y' && event.ctrlKey) {
|
|
1592
|
-
this._store.history.redo();
|
|
1593
|
-
}
|
|
1594
|
-
if (event.key === 's' && event.ctrlKey) {
|
|
1595
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1596
|
-
this._store.deselectAllObjects();
|
|
1597
|
-
}
|
|
1598
|
-
if (event.key === 'b' && event.ctrlKey) {
|
|
1599
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('brush'));
|
|
1600
|
-
this._store.deselectAllObjects();
|
|
1601
|
-
}
|
|
1602
|
-
if (event.key === 'e' && event.ctrlKey) {
|
|
1603
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('eraser'));
|
|
1604
|
-
this._store.deselectAllObjects();
|
|
1605
|
-
}
|
|
1606
|
-
if (event.key === 'i' && event.ctrlKey) {
|
|
1607
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('image'));
|
|
1608
|
-
this._store.deselectAllObjects();
|
|
1609
|
-
}
|
|
1610
|
-
if (event.key === 'x' && event.ctrlKey) {
|
|
1611
|
-
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('text'));
|
|
1612
|
-
this._store.deselectAllObjects();
|
|
1613
|
-
}
|
|
1614
|
-
if (event.key === 'c' && event.ctrlKey && this._store.state.selectionGroup) {
|
|
1615
|
-
this._store.copy();
|
|
1616
|
-
this._store.rerender();
|
|
1617
|
-
}
|
|
1618
|
-
if (event.key === 'v' && event.ctrlKey && this._store.state.copiedObjects) {
|
|
1619
|
-
this._store.paste();
|
|
1620
|
-
}
|
|
1621
|
-
if (event.key === '+' && event.ctrlKey && this._store.state.selectionGroup) {
|
|
1622
|
-
this._store.bringForward();
|
|
1623
|
-
}
|
|
1624
|
-
if (event.key === '-' && event.ctrlKey && this._store.state.selectionGroup) {
|
|
1625
|
-
this._store.sendBackward();
|
|
1626
|
-
}
|
|
1627
|
-
if (event.key === '*' && event.shiftKey && this._store.state.selectionGroup) {
|
|
1628
|
-
this._store.bringToFront();
|
|
1629
|
-
}
|
|
1630
|
-
if (event.key === '_' && event.shiftKey && this._store.state.selectionGroup) {
|
|
1631
|
-
this._store.sendToBack();
|
|
1632
|
-
}
|
|
1633
|
-
if (event.key === 'a' && event.ctrlKey && this._store.state.activeText) {
|
|
1634
|
-
this._store.state.activeText.selectAll();
|
|
1635
|
-
}
|
|
1636
|
-
if (event.key === 'v' && event.ctrlKey && this._store.state.activeText) {
|
|
1637
|
-
this._store.state.activeText.insertFromClipboard();
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
handleKeyUp(event) {
|
|
1641
|
-
if (this._store.state.isFocused === false) {
|
|
1642
|
-
return;
|
|
1643
|
-
}
|
|
1644
|
-
this._store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
class KritzelContextMenuHandler extends index$1.KritzelBaseHandler {
|
|
1649
|
-
constructor(store, globalContextMenuItems, objectContextMenuItems) {
|
|
1650
|
-
super(store);
|
|
1651
|
-
this.globalContextMenuItems = [];
|
|
1652
|
-
this.objectContextMenuItems = [];
|
|
1653
|
-
this.globalContextMenuItems = globalContextMenuItems;
|
|
1654
|
-
this.objectContextMenuItems = objectContextMenuItems;
|
|
1655
|
-
}
|
|
1656
|
-
handleContextMenu(event) {
|
|
1657
|
-
if (this._store.state.skipContextMenu) {
|
|
1658
|
-
this._store.state.skipContextMenu = false;
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
1662
|
-
if (selectedObject && !(selectedObject instanceof index$1.KritzelSelectionGroup)) {
|
|
1663
|
-
this._store.state.selectionGroup = index$1.KritzelSelectionGroup.create(this._store);
|
|
1664
|
-
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
1665
|
-
this._store.state.selectionGroup.isSelected = true;
|
|
1666
|
-
this._store.state.selectionGroup.rotation = selectedObject.rotation;
|
|
1667
|
-
this._store.state.isSelecting = false;
|
|
1668
|
-
this._store.history.executeCommand(new index$1.AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
1669
|
-
}
|
|
1670
|
-
this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
1671
|
-
let x = event.clientX - this._store.offsetX;
|
|
1672
|
-
let y = event.clientY - this._store.offsetY;
|
|
1673
|
-
const menuWidthEstimate = 150;
|
|
1674
|
-
const menuHeightEstimate = 200;
|
|
1675
|
-
const margin = 10;
|
|
1676
|
-
if (x + menuWidthEstimate > window.innerWidth - margin) {
|
|
1677
|
-
x = window.innerWidth - menuWidthEstimate - margin;
|
|
1678
|
-
}
|
|
1679
|
-
if (y + menuHeightEstimate > window.innerHeight - margin) {
|
|
1680
|
-
y = window.innerHeight - menuHeightEstimate - margin;
|
|
1681
|
-
}
|
|
1682
|
-
x = Math.max(margin, x);
|
|
1683
|
-
y = Math.max(margin, y);
|
|
1684
|
-
this._store.state.contextMenuX = x;
|
|
1685
|
-
this._store.state.contextMenuY = y;
|
|
1686
|
-
this._store.state.isContextMenuVisible = true;
|
|
1687
|
-
this._store.state.isEnabled = false;
|
|
1688
|
-
this._store.rerender();
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
class KritzelClassHelper {
|
|
1693
|
-
static isInstanceOf(object, className) {
|
|
1694
|
-
return object.__class__ === className;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
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}";
|
|
1699
|
-
|
|
1700
|
-
const KritzelEngine = class {
|
|
1701
|
-
validateScaleMax(newValue) {
|
|
1702
|
-
if (newValue > ABSOLUTE_SCALE_MAX) {
|
|
1703
|
-
console.warn(`scaleMax cannot be greater than ${ABSOLUTE_SCALE_MAX}.`);
|
|
1704
|
-
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
1705
|
-
this.store.state.scaleMax = this.scaleMax;
|
|
1706
|
-
}
|
|
1707
|
-
else {
|
|
1708
|
-
this.store.state.scaleMax = newValue;
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
validateScaleMin(newValue) {
|
|
1712
|
-
if (newValue < ABSOLUTE_SCALE_MIN) {
|
|
1713
|
-
console.warn(`scaleMin cannot be less than ${ABSOLUTE_SCALE_MIN}.`);
|
|
1714
|
-
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
1715
|
-
this.store.state.scaleMin = this.scaleMin;
|
|
1716
|
-
}
|
|
1717
|
-
else {
|
|
1718
|
-
this.store.state.scaleMin = newValue;
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
get isSelecting() {
|
|
1722
|
-
return this.store.state.activeTool instanceof index$1.KritzelSelectionTool && this.store.state.isSelecting;
|
|
1723
|
-
}
|
|
1724
|
-
get isSelectionActive() {
|
|
1725
|
-
return this.store.state.activeTool instanceof index$1.KritzelSelectionTool && this.store.state.selectionGroup !== null;
|
|
1726
|
-
}
|
|
1727
|
-
constructor(hostRef) {
|
|
1728
|
-
index.registerInstance(this, hostRef);
|
|
1729
|
-
this.isEngineReady = index.createEvent(this, "isEngineReady");
|
|
1730
|
-
this.activeToolChange = index.createEvent(this, "activeToolChange");
|
|
1731
|
-
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
1732
|
-
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
1733
|
-
this.forceUpdate = 0;
|
|
1734
|
-
this.contextMenuElement = null;
|
|
1735
|
-
this.store = new KritzelStore(this);
|
|
1736
|
-
}
|
|
1737
|
-
componentWillLoad() {
|
|
1738
|
-
this.validateScaleMax(this.scaleMax);
|
|
1739
|
-
this.validateScaleMin(this.scaleMin);
|
|
1740
|
-
}
|
|
1741
|
-
componentDidLoad() {
|
|
1742
|
-
this.contextMenuHandler = new KritzelContextMenuHandler(this.store, this.globalContextMenuItems, this.objectContextMenuItems);
|
|
1743
|
-
this.keyHandler = new KritzelKeyHandler(this.store);
|
|
1744
|
-
this.viewport = new KritzelViewport(this.store, this.host);
|
|
1745
|
-
this._registerStateChangeListeners();
|
|
1746
|
-
if (this.store.state.isReady === false) {
|
|
1747
|
-
this.store.state.isReady = true;
|
|
1748
|
-
this.isEngineReady.emit();
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
handleWheel(ev) {
|
|
1752
|
-
var _a, _b;
|
|
1753
|
-
if (this.store.state.isContextMenuVisible) {
|
|
1754
|
-
this.hideContextMenu();
|
|
1755
|
-
}
|
|
1756
|
-
this.viewport.handleWheel(ev);
|
|
1757
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
|
|
1758
|
-
}
|
|
1759
|
-
handlePointerDown(ev) {
|
|
1760
|
-
var _a, _b;
|
|
1761
|
-
if (index$1.KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
|
|
1762
|
-
this.hideContextMenu();
|
|
1763
|
-
return;
|
|
1764
|
-
}
|
|
1765
|
-
if (this.store.state.isEnabled === false) {
|
|
1766
|
-
return;
|
|
1767
|
-
}
|
|
1768
|
-
index$1.KritzelEventHelper.onLongTouchPress(ev, (event) => {
|
|
1769
|
-
if (!(this.store.state.activeTool instanceof index$1.KritzelSelectionTool)) {
|
|
1770
|
-
return;
|
|
1771
|
-
}
|
|
1772
|
-
this.contextMenuHandler.handleContextMenu(event);
|
|
1773
|
-
});
|
|
1774
|
-
this.host.setPointerCapture(ev.pointerId);
|
|
1775
|
-
this.store.state.pointers.set(ev.pointerId, ev);
|
|
1776
|
-
this.viewport.handlePointerDown(ev);
|
|
1777
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerDown(ev);
|
|
1778
|
-
}
|
|
1779
|
-
handlePointerMove(ev) {
|
|
1780
|
-
var _a, _b;
|
|
1781
|
-
if (this.store.state.isEnabled === false) {
|
|
1782
|
-
return;
|
|
1783
|
-
}
|
|
1784
|
-
this.store.state.pointers.set(ev.pointerId, ev);
|
|
1785
|
-
this.viewport.handlePointerMove(ev);
|
|
1786
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerMove(ev);
|
|
1787
|
-
}
|
|
1788
|
-
handlePointerUp(ev) {
|
|
1789
|
-
var _a, _b;
|
|
1790
|
-
if (this.store.state.isEnabled === false) {
|
|
1791
|
-
return;
|
|
1792
|
-
}
|
|
1793
|
-
this.store.state.pointers.delete(ev.pointerId);
|
|
1794
|
-
this.host.releasePointerCapture(ev.pointerId);
|
|
1795
|
-
this.viewport.handlePointerUp(ev);
|
|
1796
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
|
|
1797
|
-
}
|
|
1798
|
-
handlePointerCancel(ev) {
|
|
1799
|
-
var _a, _b;
|
|
1800
|
-
if (this.store.state.isEnabled === false) {
|
|
1801
|
-
return;
|
|
1802
|
-
}
|
|
1803
|
-
this.host.releasePointerCapture(ev.pointerId);
|
|
1804
|
-
this.store.state.pointers.delete(ev.pointerId);
|
|
1805
|
-
this.viewport.handlePointerUp(ev);
|
|
1806
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
|
|
1807
|
-
}
|
|
1808
|
-
handleContextMenu(ev) {
|
|
1809
|
-
ev.preventDefault();
|
|
1810
|
-
if (this.store.state.isEnabled === false) {
|
|
1811
|
-
return;
|
|
1812
|
-
}
|
|
1813
|
-
if (ev.pointerType === 'touch') {
|
|
1814
|
-
return;
|
|
1815
|
-
}
|
|
1816
|
-
this.contextMenuHandler.handleContextMenu(ev);
|
|
1817
|
-
}
|
|
1818
|
-
handleResize() {
|
|
1819
|
-
this.viewport.handleResize();
|
|
1820
|
-
}
|
|
1821
|
-
handleKeyDown(ev) {
|
|
1822
|
-
this.keyHandler.handleKeyDown(ev);
|
|
1823
|
-
}
|
|
1824
|
-
handleKeyUp(ev) {
|
|
1825
|
-
this.keyHandler.handleKeyUp(ev);
|
|
1826
|
-
}
|
|
1827
|
-
updateFocus(ev) {
|
|
1828
|
-
const rect = this.store.state.host.getBoundingClientRect();
|
|
1829
|
-
const isInside = ev.clientX >= rect.left && ev.clientX <= rect.right && ev.clientY >= rect.top && ev.clientY <= rect.bottom;
|
|
1830
|
-
const path = ev.composedPath();
|
|
1831
|
-
const kritzelEngineElement = this.host.closest('kritzel-engine');
|
|
1832
|
-
const isInKritzelEngine = path.includes(kritzelEngineElement || this.host);
|
|
1833
|
-
this.store.setState('isFocused', isInside && isInKritzelEngine);
|
|
1834
|
-
}
|
|
1835
|
-
async registerTool(toolName, toolClass, toolConfig) {
|
|
1836
|
-
if (typeof toolClass !== 'function' || !(toolClass.prototype instanceof index$1.KritzelBaseTool)) {
|
|
1837
|
-
console.error(`Failed to register tool "${toolName}": Tool class must be a constructor function`);
|
|
1838
|
-
return null;
|
|
1839
|
-
}
|
|
1840
|
-
const registeredTool = index$1.KritzelToolRegistry.registerTool(toolName, toolClass, this.store);
|
|
1841
|
-
if (toolConfig) {
|
|
1842
|
-
Object.entries(toolConfig).forEach(([key, value]) => {
|
|
1843
|
-
registeredTool[key] = value;
|
|
1844
|
-
});
|
|
1845
|
-
}
|
|
1846
|
-
return Promise.resolve(registeredTool);
|
|
1847
|
-
}
|
|
1848
|
-
async changeActiveTool(tool) {
|
|
1849
|
-
var _a;
|
|
1850
|
-
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
1851
|
-
this.store.setState('activeTool', tool);
|
|
1852
|
-
this.store.deselectAllObjects();
|
|
1853
|
-
tool === null || tool === void 0 ? void 0 : tool.onActivate();
|
|
1854
|
-
}
|
|
1855
|
-
async setFocus() {
|
|
1856
|
-
this.host.focus();
|
|
1857
|
-
this.store.state.isFocused = true;
|
|
1858
|
-
}
|
|
1859
|
-
async disable() {
|
|
1860
|
-
this.store.state.isEnabled = false;
|
|
1861
|
-
this.forceUpdate++;
|
|
1862
|
-
}
|
|
1863
|
-
async enable() {
|
|
1864
|
-
this.store.state.isEnabled = true;
|
|
1865
|
-
this.forceUpdate++;
|
|
1866
|
-
}
|
|
1867
|
-
async delete() {
|
|
1868
|
-
this.store.delete();
|
|
1869
|
-
}
|
|
1870
|
-
async copy() {
|
|
1871
|
-
this.store.copy();
|
|
1872
|
-
}
|
|
1873
|
-
async paste(x, y) {
|
|
1874
|
-
this.store.paste(x, y);
|
|
1875
|
-
}
|
|
1876
|
-
async bringForward(object) {
|
|
1877
|
-
this.store.bringForward(object);
|
|
1878
|
-
}
|
|
1879
|
-
async sendBackward(object) {
|
|
1880
|
-
this.store.sendBackward(object);
|
|
1881
|
-
}
|
|
1882
|
-
async moveToTop(object) {
|
|
1883
|
-
this.store.bringToFront(object);
|
|
1884
|
-
}
|
|
1885
|
-
async moveToBottom(object) {
|
|
1886
|
-
this.store.sendToBack(object);
|
|
1887
|
-
}
|
|
1888
|
-
async undo() {
|
|
1889
|
-
this.store.history.undo();
|
|
1890
|
-
}
|
|
1891
|
-
async redo() {
|
|
1892
|
-
this.store.history.redo();
|
|
1893
|
-
}
|
|
1894
|
-
async hideContextMenu() {
|
|
1895
|
-
this.store.state.pointers.clear();
|
|
1896
|
-
this.store.state.isContextMenuVisible = false;
|
|
1897
|
-
this.store.state.selectionBox = null;
|
|
1898
|
-
this.store.state.isSelecting = false;
|
|
1899
|
-
}
|
|
1900
|
-
async getObjectById(id) {
|
|
1901
|
-
const object = this.store.objects.find(obj => obj.id === id);
|
|
1902
|
-
return object || null;
|
|
1903
|
-
}
|
|
1904
|
-
async addObject(object) {
|
|
1905
|
-
this.store.deselectAllObjects();
|
|
1906
|
-
object.id = object.generateId();
|
|
1907
|
-
object._store = this.store;
|
|
1908
|
-
object.scale = object.scale ? object.scale : this.store.state.scale;
|
|
1909
|
-
object.zIndex = this.store.currentZIndex;
|
|
1910
|
-
const command = new index$1.AddObjectCommand(this.store, this, object);
|
|
1911
|
-
this.store.history.executeCommand(command);
|
|
1912
|
-
return object;
|
|
1913
|
-
}
|
|
1914
|
-
async updateObject(object, updatedProperties) {
|
|
1915
|
-
this.store.deselectAllObjects();
|
|
1916
|
-
const command = new UpdateObjectCommand(this.store, this, object, updatedProperties);
|
|
1917
|
-
this.store.history.executeCommand(command);
|
|
1918
|
-
return object;
|
|
1919
|
-
}
|
|
1920
|
-
async removeObject(object) {
|
|
1921
|
-
this.store.deselectAllObjects();
|
|
1922
|
-
const command = new index$1.RemoveObjectCommand(this.store, this, object);
|
|
1923
|
-
this.store.history.executeCommand(command);
|
|
1924
|
-
return object;
|
|
1925
|
-
}
|
|
1926
|
-
async getSelectedObjects() {
|
|
1927
|
-
return this.store.state.selectionGroup ? this.store.state.selectionGroup.objects : [];
|
|
1928
|
-
}
|
|
1929
|
-
async selectObjects(objects) {
|
|
1930
|
-
var _a;
|
|
1931
|
-
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
1932
|
-
this.store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1933
|
-
this.store.deselectAllObjects();
|
|
1934
|
-
this.store.selectObjects(objects);
|
|
1935
|
-
}
|
|
1936
|
-
async selectAllObjectsInViewport() {
|
|
1937
|
-
var _a;
|
|
1938
|
-
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
1939
|
-
this.store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
1940
|
-
this.store.deselectAllObjects();
|
|
1941
|
-
this.store.selectAllObjectsInViewport();
|
|
1942
|
-
}
|
|
1943
|
-
async clearSelection() {
|
|
1944
|
-
this.store.clearSelection();
|
|
1945
|
-
}
|
|
1946
|
-
async centerObjectInViewport(object) {
|
|
1947
|
-
object.centerInViewport();
|
|
1948
|
-
const command = new UpdateObjectCommand(this.store, this, object, object);
|
|
1949
|
-
this.store.history.executeCommand(command);
|
|
1950
|
-
return object;
|
|
1951
|
-
}
|
|
1952
|
-
async getCopiedObjects() {
|
|
1953
|
-
var _a;
|
|
1954
|
-
return ((_a = this.store.state.copiedObjects) === null || _a === void 0 ? void 0 : _a.objects) || [];
|
|
1955
|
-
}
|
|
1956
|
-
_registerStateChangeListeners() {
|
|
1957
|
-
this.store.onStateChange('activeTool', this._handleActiveToolChange.bind(this));
|
|
1958
|
-
this.store.onStateChange('isFocused', this._handleIsFocusedChange.bind(this));
|
|
1959
|
-
}
|
|
1960
|
-
_handleActiveToolChange(activeTool) {
|
|
1961
|
-
if (!(activeTool instanceof index$1.KritzelSelectionTool)) {
|
|
1962
|
-
this.store.clearSelection();
|
|
1963
|
-
}
|
|
1964
|
-
this.store.state.skipContextMenu = false;
|
|
1965
|
-
this.activeToolChange.emit(activeTool);
|
|
1966
|
-
index$1.KritzelKeyboardHelper.forceHideKeyboard();
|
|
1967
|
-
}
|
|
1968
|
-
_handleIsFocusedChange(isFocused) {
|
|
1969
|
-
if (!isFocused) {
|
|
1970
|
-
this.store.resetActiveText();
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
render() {
|
|
1974
|
-
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;
|
|
1975
|
-
const computedStyle = window.getComputedStyle(this.host);
|
|
1976
|
-
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
1977
|
-
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
1978
|
-
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
1979
|
-
return (index.h(index.Host, { key: '61bfbd2fbd2a0fa54671b55372c0c78479bcbd42' }, index.h("div", { key: '51741a7ffe2143fd78ef0d47961c98007c9cb996', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: 'aa580caa079e7ccb619369136a05860d21e7cc53' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
1980
|
-
_a.translateX), index.h("div", { key: '0a3ff31676954408050097cc1bbb34e71c10e157' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
1981
|
-
_b.translateY), index.h("div", { key: '86a4db3532f05ea238b4fa8f84e0cf1d1cfce05e' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
1982
|
-
_c.viewportWidth), index.h("div", { key: '775ef8217d65947e86e19b4b0d3f14b6ca0c0cc4' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
1983
|
-
_d.viewportHeight), index.h("div", { key: '47bb465ff9bf4179dd0d0d3973af534663f72a79' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '4bc3129aa10b9d63ff5ff2eebafb5b98bc4349a5' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
1984
|
-
_e.scale), index.h("div", { key: '2bda37d1f92525c73230cc5247b4ce8d4918b341' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
1985
|
-
_g.name), index.h("div", { key: 'b94f3078b060223150dd26b2194ab0debd2b531b' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: '2d17379ea2ab8c8494d5c51b51a5f1a5f253e5c3' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '2dc852b4a8935da997c0ff46d34bebf0bddc33d8' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '2af7e9330c379c9a9d962d91b07749e2442df0cf' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: '99466f5d289fdc00b9c0b8c21f0a74a491495c96' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '98d95674cdc72f5b375b50d4ee8ac458d4af052d' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '9aa3cea7f3abd42fb627191678f733f7ae3be52d' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: 'ce0f5842e763e68cb9a7912622dedef14c403867' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '459ec8743e55a68dd933d1e005c742fb108b6c94' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'd12267e3924fbd066fa3ea851c3a88317bd5e78e' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '9f6a79f1c5feb36fe636ea5db8f76405efcff620' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '95a2c0ca71db420aedc87914dd1407a7d51e4ad9' }, "PointerX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
1986
|
-
_m.pointerX), index.h("div", { key: '97eeaaa4152979c94086ccb4819622f08c126ba3' }, "PointerY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
1987
|
-
_o.pointerY)), index.h("div", { key: '9c5ac0629d021a44a66fc6d42dec39ea0b8814a8', id: "origin", class: "origin", style: {
|
|
1988
|
-
transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
|
|
1989
|
-
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
1990
|
-
_t.map(object => {
|
|
1991
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1992
|
-
return (index.h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
|
|
1993
|
-
height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
|
|
1994
|
-
width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
|
|
1995
|
-
left: '0',
|
|
1996
|
-
top: '0',
|
|
1997
|
-
position: 'absolute',
|
|
1998
|
-
transform: `rotate(${object.rotationDegrees}deg)`,
|
|
1999
|
-
transformOrigin: 'center',
|
|
2000
|
-
opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
|
|
2001
|
-
pointerEvents: object.markedForRemoval ? 'none' : 'auto',
|
|
2002
|
-
} }, index.h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
|
|
2003
|
-
minHeight: '0',
|
|
2004
|
-
minWidth: '0',
|
|
2005
|
-
backgroundColor: object.backgroundColor,
|
|
2006
|
-
borderColor: object.borderColor,
|
|
2007
|
-
borderWidth: object.borderWidth + 'px',
|
|
2008
|
-
borderStyle: 'solid',
|
|
2009
|
-
padding: object.padding + 'px',
|
|
2010
|
-
overflow: 'visible',
|
|
2011
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el => el ? object.mount(el) : object.unmount(), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2012
|
-
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
2013
|
-
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
2014
|
-
position: 'absolute',
|
|
2015
|
-
overflow: 'visible',
|
|
2016
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, index.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') && (index.h("img", { ref: el => el ? object.mount(el) : object.unmount(), src: object.src, style: {
|
|
2017
|
-
width: '100%',
|
|
2018
|
-
height: '100%',
|
|
2019
|
-
userSelect: 'none',
|
|
2020
|
-
pointerEvents: 'none',
|
|
2021
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.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: {
|
|
2022
|
-
width: '100%',
|
|
2023
|
-
height: '100%',
|
|
2024
|
-
color: object.fontColor,
|
|
2025
|
-
fontSize: ((_a = object.fontSize) === null || _a === void 0 ? void 0 : _a.toString()) + 'px',
|
|
2026
|
-
fontFamily: object.fontFamily,
|
|
2027
|
-
border: 'none',
|
|
2028
|
-
outline: 'none',
|
|
2029
|
-
resize: 'none',
|
|
2030
|
-
overflow: 'hidden',
|
|
2031
|
-
display: 'block',
|
|
2032
|
-
padding: '1px',
|
|
2033
|
-
whiteSpace: 'nowrap',
|
|
2034
|
-
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
2035
|
-
cursor: object.isReadonly ? 'default' : 'text',
|
|
2036
|
-
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
2037
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2038
|
-
width: '100%',
|
|
2039
|
-
height: '100%',
|
|
2040
|
-
pointerEvents: 'auto',
|
|
2041
|
-
overflow: 'hidden',
|
|
2042
|
-
display: 'block',
|
|
2043
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2044
|
-
width: '100%',
|
|
2045
|
-
height: '100%',
|
|
2046
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2047
|
-
width: '100%',
|
|
2048
|
-
height: '100%',
|
|
2049
|
-
} }))), index.h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
2050
|
-
stroke: 'var(--kritzel-selection-border-color, #007AFF)',
|
|
2051
|
-
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_b = this.store.state) === null || _b === void 0 ? void 0 : _b.scale})`,
|
|
2052
|
-
strokeLinecap: 'square',
|
|
2053
|
-
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: "0", y1: "0", x2: "0", y2: object.totalHeight, style: {
|
|
2054
|
-
stroke: 'var(--kritzel-selection-border-color, #007AFF)',
|
|
2055
|
-
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_c = this.store.state) === null || _c === void 0 ? void 0 : _c.scale})`,
|
|
2056
|
-
strokeLinecap: 'square',
|
|
2057
|
-
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: "0", y1: object.totalHeight, x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2058
|
-
stroke: 'var(--kritzel-selection-border-color, #007AFF)',
|
|
2059
|
-
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_d = this.store.state) === null || _d === void 0 ? void 0 : _d.scale})`,
|
|
2060
|
-
strokeLinecap: 'square',
|
|
2061
|
-
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: object.totalWidth, y1: "0", x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2062
|
-
stroke: 'var(--kritzel-selection-border-color, #007AFF)',
|
|
2063
|
-
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_e = this.store.state) === null || _e === void 0 ? void 0 : _e.scale})`,
|
|
2064
|
-
strokeLinecap: 'square',
|
|
2065
|
-
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle top-left", cx: "0", cy: "0", r: `${(baseHandleSize * object.scale) / ((_f = this.store.state) === null || _f === void 0 ? void 0 : _f.scale)}`, style: {
|
|
2066
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2067
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle-overlay top-left", cx: "0", cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_g = this.store.state) === null || _g === void 0 ? void 0 : _g.scale)}`, style: {
|
|
2068
|
-
fill: 'transparent',
|
|
2069
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleSize * object.scale) / ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.scale)}`, style: {
|
|
2070
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2071
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle-overlay top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.scale)}`, style: {
|
|
2072
|
-
fill: 'transparent',
|
|
2073
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.scale)}`, style: {
|
|
2074
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2075
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle-overlay bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.scale)}`, style: {
|
|
2076
|
-
fill: 'transparent',
|
|
2077
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_m = this.store.state) === null || _m === void 0 ? void 0 : _m.scale)}`, style: {
|
|
2078
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2079
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "resize-handle-overlay bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_o = this.store.state) === null || _o === void 0 ? void 0 : _o.scale)}`, style: {
|
|
2080
|
-
fill: 'transparent',
|
|
2081
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("line", { x1: object.totalWidth / 2, y1: "0", x2: object.totalWidth / 2, y2: -((15 * object.scale) / ((_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale)), style: {
|
|
2082
|
-
stroke: 'var(--kritzel-selection-border-color, #007AFF)',
|
|
2083
|
-
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale})`,
|
|
2084
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "rotation-handle", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_r = this.store.state) === null || _r === void 0 ? void 0 : _r.scale)), r: `${(baseHandleSize * object.scale) / ((_s = this.store.state) === null || _s === void 0 ? void 0 : _s.scale)}`, style: {
|
|
2085
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2086
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "rotation-handle-overlay", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_t = this.store.state) === null || _t === void 0 ? void 0 : _t.scale)), r: `${(baseHandleTouchSize * object.scale) / ((_u = this.store.state) === null || _u === void 0 ? void 0 : _u.scale)}`, style: {
|
|
2087
|
-
fill: 'transparent',
|
|
2088
|
-
cursor: 'grab',
|
|
2089
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), index.h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), index.h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), index.h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), index.h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation), index.h("div", { style: { whiteSpace: 'nowrap' } }, "x: ", object.x), index.h("div", { style: { whiteSpace: 'nowrap' } }, "y: ", object.y)))))));
|
|
2090
|
-
}), index.h("svg", { key: '95ad9e12faccc0fbb3af7871b2a4acb383ff8d1c', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2091
|
-
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
2092
|
-
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
2093
|
-
left: '0',
|
|
2094
|
-
top: '0',
|
|
2095
|
-
zIndex: (_w = this.store.state.currentPath) === null || _w === void 0 ? void 0 : _w.zIndex.toString(),
|
|
2096
|
-
position: 'absolute',
|
|
2097
|
-
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
2098
|
-
transformOrigin: 'top left',
|
|
2099
|
-
overflow: 'visible',
|
|
2100
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '94a8e02708fdb85a298d96dbce880dcd2f933c0c', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (index.h("kritzel-context-menu", { key: '127e0f7b1d69243cdb5f41473755e16e3d93a2f3', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, objects: ((_2 = this.store.state.selectionGroup) === null || _2 === void 0 ? void 0 : _2.objects) || [], style: {
|
|
2101
|
-
position: 'fixed',
|
|
2102
|
-
left: `${this.store.state.contextMenuX}px`,
|
|
2103
|
-
top: `${this.store.state.contextMenuY}px`,
|
|
2104
|
-
zIndex: '10000',
|
|
2105
|
-
}, onActionSelected: event => {
|
|
2106
|
-
var _a;
|
|
2107
|
-
event.detail.action({
|
|
2108
|
-
x: (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale,
|
|
2109
|
-
y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
|
|
2110
|
-
}, (_a = this.store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects);
|
|
2111
|
-
this.hideContextMenu();
|
|
2112
|
-
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof index$1.KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: 'c999cf8982b522f0a00b853141171c6726666390', store: this.store })));
|
|
2113
|
-
}
|
|
2114
|
-
get host() { return index.getElement(this); }
|
|
2115
|
-
static get watchers() { return {
|
|
2116
|
-
"scaleMax": ["validateScaleMax"],
|
|
2117
|
-
"scaleMin": ["validateScaleMin"]
|
|
2118
|
-
}; }
|
|
2119
|
-
};
|
|
2120
|
-
KritzelEngine.style = kritzelEngineCss;
|
|
2121
|
-
|
|
2122
|
-
const kritzelFontCss = ":host{display:block}.font-preview{color:var(--kritzel-font-size-text-color, #333333);line-height:1;text-align:center;font-weight:bold}";
|
|
2123
|
-
|
|
2124
|
-
const KritzelFont = class {
|
|
2125
|
-
constructor(hostRef) {
|
|
2126
|
-
index.registerInstance(this, hostRef);
|
|
2127
|
-
this.fontFamily = 'Arial, sans-serif';
|
|
2128
|
-
this.size = 24;
|
|
2129
|
-
this.color = '#000000';
|
|
2130
|
-
}
|
|
2131
|
-
render() {
|
|
2132
|
-
return (index.h(index.Host, { key: 'd0378237899c5641ae4354f3bffb14e3f8bafb59' }, index.h("div", { key: '1475a6ae39ffc97eb780b30c85015c22cecafa6e', class: "font-preview", style: {
|
|
2133
|
-
fontFamily: this.fontFamily,
|
|
2134
|
-
fontSize: `${this.size}px`,
|
|
2135
|
-
color: this.color
|
|
2136
|
-
} }, "A")));
|
|
2137
|
-
}
|
|
2138
|
-
};
|
|
2139
|
-
KritzelFont.style = kritzelFontCss;
|
|
2140
|
-
|
|
2141
|
-
const kritzelFontFamilyCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.font-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:pointer;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}.font-style-button.italic-text{font-style:italic}";
|
|
2142
|
-
|
|
2143
|
-
const KritzelFontFamily = class {
|
|
2144
|
-
constructor(hostRef) {
|
|
2145
|
-
index.registerInstance(this, hostRef);
|
|
2146
|
-
this.fontFamilyChange = index.createEvent(this, "fontFamilyChange");
|
|
2147
|
-
this.fontOptions = [
|
|
2148
|
-
{ value: 'arial', label: 'Arial' },
|
|
2149
|
-
{ value: 'verdana', label: 'Verdana' },
|
|
2150
|
-
{ value: 'helvetica', label: 'Helvetica' },
|
|
2151
|
-
{ value: 'tahoma', label: 'Tahoma' },
|
|
2152
|
-
{ value: 'trebuchet ms', label: 'Trebuchet MS' },
|
|
2153
|
-
{ value: 'times new roman', label: 'Times New Roman' },
|
|
2154
|
-
{ value: 'georgia', label: 'Georgia' },
|
|
2155
|
-
{ value: 'garamond', label: 'Garamond' },
|
|
2156
|
-
{ value: 'courier new', label: 'Courier New' },
|
|
2157
|
-
{ value: 'brush script mt', label: 'Brush Script MT' },
|
|
2158
|
-
];
|
|
2159
|
-
this.handleDropdownValueChange = (event) => {
|
|
2160
|
-
this.fontFamilyChange.emit(event.detail);
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
componentWillLoad() {
|
|
2164
|
-
if (this.fontOptions && this.fontOptions.length > 0) {
|
|
2165
|
-
const isValidCurrentFont = this.fontOptions.some(opt => opt.value === this.selectedFontFamily);
|
|
2166
|
-
if (!this.selectedFontFamily || !isValidCurrentFont) {
|
|
2167
|
-
this.selectedFontFamily = this.fontOptions[0].value;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
render() {
|
|
2172
|
-
const dropdownOptions = this.fontOptions.map(option => ({
|
|
2173
|
-
value: option.value,
|
|
2174
|
-
label: option.label,
|
|
2175
|
-
style: { fontFamily: option.value },
|
|
2176
|
-
}));
|
|
2177
|
-
return (index.h(index.Host, { key: 'f420ff18156d54bfc475148a7d9aae0f1441408c' }, index.h("kritzel-dropdown", { key: '6b54fb8265a0eb59a6a681c6a2b7a95fb222671c', options: dropdownOptions, value: this.selectedFontFamily, onValueChanged: this.handleDropdownValueChange, selectStyles: { fontFamily: this.selectedFontFamily } }, index.h("button", { key: 'b853c75a425c7baafa7a8e749c90c0b08884375c', class: "font-style-button", slot: "suffix" }, "B"), index.h("button", { key: '68dea850dd1d1f38db727d8be0eec3481890c571', class: "font-style-button italic-text", slot: "suffix" }, "I"))));
|
|
2178
|
-
}
|
|
2179
|
-
};
|
|
2180
|
-
KritzelFontFamily.style = kritzelFontFamilyCss;
|
|
2181
|
-
|
|
2182
|
-
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, #f0f0f0)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-font-size-selected-background-color, #e0e0e0)}";
|
|
2183
|
-
|
|
2184
|
-
const KritzelFontSize = class {
|
|
2185
|
-
constructor(hostRef) {
|
|
2186
|
-
index.registerInstance(this, hostRef);
|
|
2187
|
-
this.sizeChange = index.createEvent(this, "sizeChange");
|
|
2188
|
-
this.sizes = [8, 10, 12, 16, 20, 24];
|
|
2189
|
-
this.selectedSize = null;
|
|
2190
|
-
this.fontFamily = 'Arial';
|
|
2191
|
-
}
|
|
2192
|
-
handleSizeClick(size) {
|
|
2193
|
-
this.selectedSize = size;
|
|
2194
|
-
this.sizeChange.emit(size);
|
|
2195
|
-
}
|
|
2196
|
-
render() {
|
|
2197
|
-
return (index.h(index.Host, { key: '1c09a403f1e8278d30b2675c3a6e17e12ec79afa' }, this.sizes.map(size => (index.h("div", { class: {
|
|
2198
|
-
'size-container': true,
|
|
2199
|
-
'selected': this.selectedSize === size,
|
|
2200
|
-
}, onClick: () => this.handleSizeClick(size) }, index.h("kritzel-font", { fontFamily: this.fontFamily, size: size }))))));
|
|
2201
|
-
}
|
|
2202
|
-
};
|
|
2203
|
-
KritzelFontSize.style = kritzelFontSizeCss;
|
|
2204
|
-
|
|
2205
|
-
const kritzelIconCss = ":host{display:inline-flex;justify-content:center;align-items:center;}span{display:flex;align-items:center;width:100%;height:100%;}span>svg{width:100%;height:100%}";
|
|
2206
|
-
|
|
2207
|
-
const KritzelIcon = class {
|
|
2208
|
-
constructor(hostRef) {
|
|
2209
|
-
index.registerInstance(this, hostRef);
|
|
2210
|
-
this.size = 24;
|
|
2211
|
-
}
|
|
2212
|
-
render() {
|
|
2213
|
-
const svgContent = KritzelIconRegistry.get(this.name);
|
|
2214
|
-
if (!svgContent) {
|
|
2215
|
-
console.error(`[kritzel-icon] Icon "${this.name}" not found in registry.`);
|
|
2216
|
-
return index.h("span", { class: "error-icon", "aria-label": `Error: Icon ${this.name} not found` }, "?");
|
|
2217
|
-
}
|
|
2218
|
-
const styles = {
|
|
2219
|
-
width: `${this.size}px`,
|
|
2220
|
-
height: `${this.size}px`,
|
|
2221
|
-
};
|
|
2222
|
-
return (index.h(index.Host, { style: styles }, index.h("span", { "aria-hidden": !this.label, role: this.label ? 'img' : undefined, "aria-label": this.label, innerHTML: svgContent })));
|
|
2223
|
-
}
|
|
2224
|
-
};
|
|
2225
|
-
KritzelIcon.style = kritzelIconCss;
|
|
2226
|
-
|
|
2227
|
-
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, #f0f0f0)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-stroke-size-selected-background-color, #f0f0f0)}";
|
|
2228
|
-
|
|
2229
|
-
const KritzelStrokeSize = class {
|
|
2230
|
-
constructor(hostRef) {
|
|
2231
|
-
index.registerInstance(this, hostRef);
|
|
2232
|
-
this.sizeChange = index.createEvent(this, "sizeChange");
|
|
2233
|
-
this.sizes = [4, 6, 8, 12, 16, 24];
|
|
2234
|
-
this.selectedSize = null;
|
|
2235
|
-
}
|
|
2236
|
-
handleSizeClick(size) {
|
|
2237
|
-
this.selectedSize = size;
|
|
2238
|
-
this.sizeChange.emit(size);
|
|
2239
|
-
}
|
|
2240
|
-
render() {
|
|
2241
|
-
return (index.h(index.Host, { key: '2e2a4d38920e25e1e60788deabe4912b510d0b10' }, this.sizes.map(size => (index.h("div", { class: {
|
|
2242
|
-
'size-container': true,
|
|
2243
|
-
'selected': this.selectedSize === size,
|
|
2244
|
-
}, onClick: () => this.handleSizeClick(size) }, index.h("kritzel-color", { value: '#000000', size: size }))))));
|
|
2245
|
-
}
|
|
2246
|
-
};
|
|
2247
|
-
KritzelStrokeSize.style = kritzelStrokeSizeCss;
|
|
2248
|
-
|
|
2249
|
-
const kritzelTooltipCss = ":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";
|
|
2250
|
-
|
|
2251
|
-
const MOBILE_BREAKPOINT = 768;
|
|
2252
|
-
const KritzelTooltip = class {
|
|
2253
|
-
constructor(hostRef) {
|
|
2254
|
-
index.registerInstance(this, hostRef);
|
|
2255
|
-
this.isVisible = false;
|
|
2256
|
-
this.arrowSize = 8;
|
|
2257
|
-
this.offsetY = 24;
|
|
2258
|
-
this.positionX = 0;
|
|
2259
|
-
this.arrowOffset = '0px';
|
|
2260
|
-
this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
2261
|
-
}
|
|
2262
|
-
handleWindowResize() {
|
|
2263
|
-
this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
2264
|
-
this.calculateAdjustedPosition();
|
|
2265
|
-
}
|
|
2266
|
-
componentWillLoad() {
|
|
2267
|
-
this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
|
|
2268
|
-
this.calculateAdjustedPosition();
|
|
2269
|
-
}
|
|
2270
|
-
componentWillUpdate() {
|
|
2271
|
-
this.calculateAdjustedPosition();
|
|
2272
|
-
}
|
|
2273
|
-
calculateAdjustedPosition() {
|
|
2274
|
-
var _a;
|
|
2275
|
-
if (this.isVisible && this.anchorElement) {
|
|
2276
|
-
const anchorRect = this.anchorElement.getBoundingClientRect();
|
|
2277
|
-
const tooltipContent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.tooltip-content');
|
|
2278
|
-
if (!this.isMobileView) {
|
|
2279
|
-
this.positionX = anchorRect.left + anchorRect.width / 2;
|
|
2280
|
-
this.arrowOffset = `calc(${50}% - ${this.arrowSize}px)`;
|
|
2281
|
-
}
|
|
2282
|
-
else {
|
|
2283
|
-
const tooltipRect = tooltipContent.getBoundingClientRect();
|
|
2284
|
-
this.positionX = anchorRect.left + anchorRect.width / 2 - tooltipRect.width / 2;
|
|
2285
|
-
this.arrowOffset = `${anchorRect.left + anchorRect.width / 2 - tooltipRect.left - this.arrowSize}px`;
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
render() {
|
|
2290
|
-
return (index.h(index.Host, { key: '3161826337f6957d2e568f52cfe3f57d705af0ed', style: {
|
|
2291
|
-
position: 'fixed',
|
|
2292
|
-
zIndex: '9999',
|
|
2293
|
-
transition: 'opacity 0.3s ease-in-out, transform 0.3s ease-in-out',
|
|
2294
|
-
visibility: this.isVisible ? 'visible' : 'hidden',
|
|
2295
|
-
left: !this.isMobileView ? `${this.positionX}px` : '50%',
|
|
2296
|
-
marginBottom: `${this.offsetY + this.arrowSize}px`,
|
|
2297
|
-
} }, index.h("div", { key: '12fc4bc05b7be756102ce3779c9be1d51f3fe13b', class: "tooltip-content", onClick: event => event.stopPropagation() }, index.h("slot", { key: '90f645f8f7cec371aaeda7207a9fb420b02b2ae4' }), index.h("div", { key: '73380e2c6df22bc4a97479a52315e7b34d069fa1', class: "tooltip-arrow-wrapper", style: {
|
|
2298
|
-
position: 'fixed',
|
|
2299
|
-
left: this.arrowOffset,
|
|
2300
|
-
bottom: `-${this.arrowSize * 2}px`,
|
|
2301
|
-
} }, index.h("div", { key: '2e13cb01a3282e161d3212f4970a93b20ca1a0fe', class: "tooltip-arrow", style: {
|
|
2302
|
-
borderLeft: `${this.arrowSize}px solid transparent`,
|
|
2303
|
-
borderRight: `${this.arrowSize}px solid transparent`,
|
|
2304
|
-
borderTop: `${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,
|
|
2305
|
-
filter: 'drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))',
|
|
2306
|
-
} }), index.h("div", { key: '30ddbd00b928c0c734656d6309eaefbae5baf264', class: "tooltip-arrow-rect", style: {
|
|
2307
|
-
position: 'relative',
|
|
2308
|
-
width: `${this.arrowSize * 2}px`,
|
|
2309
|
-
height: `${this.arrowSize}px`,
|
|
2310
|
-
backgroundColor: 'var(--kritzel-controls-tooltip-background-color, #ffffff)',
|
|
2311
|
-
bottom: `${this.arrowSize * 2}px`,
|
|
2312
|
-
} })))));
|
|
2313
|
-
}
|
|
2314
|
-
get el() { return index.getElement(this); }
|
|
2315
|
-
};
|
|
2316
|
-
KritzelTooltip.style = kritzelTooltipCss;
|
|
2317
|
-
|
|
2318
|
-
const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;outline:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";
|
|
2319
|
-
|
|
2320
|
-
const KritzelUtilityPanel = class {
|
|
2321
|
-
constructor(hostRef) {
|
|
2322
|
-
index.registerInstance(this, hostRef);
|
|
2323
|
-
this.undo = index.createEvent(this, "undo");
|
|
2324
|
-
this.redo = index.createEvent(this, "redo");
|
|
2325
|
-
this.delete = index.createEvent(this, "delete");
|
|
2326
|
-
}
|
|
2327
|
-
handleUndo(event) {
|
|
2328
|
-
if (event.cancelable) {
|
|
2329
|
-
event.preventDefault();
|
|
2330
|
-
event.stopPropagation();
|
|
2331
|
-
this.undo.emit();
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
handleRedo(event) {
|
|
2335
|
-
event.preventDefault();
|
|
2336
|
-
event.stopPropagation();
|
|
2337
|
-
this.redo.emit();
|
|
2338
|
-
}
|
|
2339
|
-
render() {
|
|
2340
|
-
return (index.h(index.Host, { key: '496ed78323c9899ad363e7f7732a1464d99e1b3b' }, index.h("button", { key: '7b6b9cd238a8d254f032d5752f184d567e9a3096', class: "utility-button", onClick: event => this.handleUndo(event) }, index.h("kritzel-icon", { key: '8ac19f36c6b82f7cc4a0249e60cf429f75c09218', name: "undo" })), index.h("button", { key: '1164727510a968356042507c1e302b85a135baf8', class: "utility-button", onClick: event => this.handleRedo(event) }, index.h("kritzel-icon", { key: '1c6cc414d5841a06853f99316eee7a0a609d5c92', name: "redo" })), index.h("div", { key: 'e6f3342569b1c6b5a6b267cc215bc8e5d259e302', class: "utility-separator" }), index.h("button", { key: '0aa486a543df924c224f3637857cdcdb06f995ea', class: "utility-button" }, index.h("kritzel-icon", { key: '9ee324e03f5df5297916549743539f7f19950768', name: "delete", onClick: () => this.delete.emit() }))));
|
|
2341
|
-
}
|
|
2342
|
-
};
|
|
2343
|
-
KritzelUtilityPanel.style = kritzelUtilityPanelCss;
|
|
2344
|
-
|
|
2345
|
-
exports.kritzel_brush_style = KritzelBrushStyle;
|
|
2346
|
-
exports.kritzel_color = KritzelColor;
|
|
2347
|
-
exports.kritzel_color_palette = KritzelColorPalette;
|
|
2348
|
-
exports.kritzel_context_menu = KritzelContextMenu;
|
|
2349
|
-
exports.kritzel_control_brush_config = KritzelControlBrushConfig;
|
|
2350
|
-
exports.kritzel_control_text_config = KritzelControlTextConfig;
|
|
2351
|
-
exports.kritzel_controls = KritzelControls;
|
|
2352
|
-
exports.kritzel_cursor_trail = KritzelCursorTrail;
|
|
2353
|
-
exports.kritzel_dropdown = KritzelDropdown;
|
|
2354
|
-
exports.kritzel_editor = KritzelEditor;
|
|
2355
|
-
exports.kritzel_engine = KritzelEngine;
|
|
2356
|
-
exports.kritzel_font = KritzelFont;
|
|
2357
|
-
exports.kritzel_font_family = KritzelFontFamily;
|
|
2358
|
-
exports.kritzel_font_size = KritzelFontSize;
|
|
2359
|
-
exports.kritzel_icon = KritzelIcon;
|
|
2360
|
-
exports.kritzel_stroke_size = KritzelStrokeSize;
|
|
2361
|
-
exports.kritzel_tooltip = KritzelTooltip;
|
|
2362
|
-
exports.kritzel_utility_panel = KritzelUtilityPanel;
|
|
2363
|
-
//# 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-stroke-size.kritzel-tooltip.kritzel-utility-panel.entry.cjs.js.map
|
|
2364
|
-
|
|
2365
|
-
//# sourceMappingURL=kritzel-brush-style_18.cjs.entry.js.map
|