kritzel-stencil 0.0.131 → 0.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-BwINBV6L.js → index-DCHCVnOl.js} +755 -701
- package/dist/cjs/index-DCHCVnOl.js.map +1 -0
- package/dist/cjs/index-nzUNdMPh.js +6 -2
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +32 -0
- package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +1 -0
- package/dist/cjs/{kritzel-brush-style_23.cjs.entry.js → kritzel-color_22.cjs.entry.js} +1046 -874
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/commands/add-object.command.js +6 -7
- package/dist/collection/classes/commands/add-object.command.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +9 -9
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/base.command.js +3 -3
- package/dist/collection/classes/commands/base.command.js.map +1 -1
- package/dist/collection/classes/commands/batch.command.js +2 -2
- package/dist/collection/classes/commands/batch.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +15 -7
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +8 -9
- package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +7 -7
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +15 -7
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +14 -12
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +6 -5
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/commands/update-viewport.command.js +11 -11
- package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
- package/dist/collection/classes/{store.class.js → core/core.class.js} +116 -145
- package/dist/collection/classes/core/core.class.js.map +1 -0
- package/dist/collection/classes/{database.class.js → core/database.class.js} +28 -20
- package/dist/collection/classes/core/database.class.js.map +1 -0
- package/dist/collection/classes/core/history.class.js +88 -0
- package/dist/collection/classes/core/history.class.js.map +1 -0
- package/dist/collection/classes/{reviver.class.js → core/reviver.class.js} +27 -23
- package/dist/collection/classes/core/reviver.class.js.map +1 -0
- package/dist/collection/classes/core/store.class.js +51 -0
- package/dist/collection/classes/core/store.class.js.map +1 -0
- package/dist/collection/classes/core/viewport.class.js +165 -0
- package/dist/collection/classes/core/viewport.class.js.map +1 -0
- package/dist/collection/classes/core/workspace.class.js +42 -0
- package/dist/collection/classes/core/workspace.class.js.map +1 -0
- package/dist/collection/classes/handlers/base.handler.js +4 -4
- package/dist/collection/classes/handlers/base.handler.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +29 -19
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/hover.handler.js +5 -5
- package/dist/collection/classes/handlers/hover.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +38 -44
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +49 -44
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +55 -60
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +59 -69
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +73 -72
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +30 -17
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +3 -3
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +5 -5
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +7 -7
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +4 -4
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +19 -20
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +13 -13
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/registries/tool.registry.js +2 -2
- package/dist/collection/classes/registries/tool.registry.js.map +1 -1
- package/dist/collection/classes/tools/base-tool.class.js +11 -5
- package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +57 -53
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +26 -26
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +11 -11
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +39 -37
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +37 -37
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +28 -28
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +7 -9
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +177 -7
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +237 -232
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +5 -0
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +3 -3
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +12 -12
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +1 -0
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +5 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +2 -2
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +18 -7
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +24 -9
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +4 -42
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +0 -4
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +52 -10
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +4 -0
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +79 -7
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +47 -15
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +4 -0
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +6 -6
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +12 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +23 -7
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +5 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +25 -15
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +0 -1
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/devices.helper.js +20 -0
- package/dist/collection/helpers/devices.helper.js.map +1 -1
- package/dist/collection/helpers/event.helper.js +1 -5
- package/dist/collection/helpers/event.helper.js.map +1 -1
- package/dist/collection/helpers/html.helper.js +29 -0
- package/dist/collection/helpers/html.helper.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +0 -14
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/clonable.interface.js +2 -0
- package/dist/collection/interfaces/clonable.interface.js.map +1 -0
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/serializable.interface.js.map +1 -1
- package/dist/collection/types/deep-readonly.type.js +2 -0
- package/dist/collection/types/deep-readonly.type.js.map +1 -0
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-brush-style.js +59 -1
- package/dist/components/kritzel-brush-style.js.map +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +80 -37
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-CMJ3P0Vw.js → p-0iJh9Z6m.js} +5 -5
- package/dist/components/p-0iJh9Z6m.js.map +1 -0
- package/dist/components/p-B0kd2rUI.js +16 -0
- package/dist/components/p-B0kd2rUI.js.map +1 -0
- package/dist/components/{p-BB5R2k1o.js → p-B3LGnqFz.js} +41 -31
- package/dist/components/p-B3LGnqFz.js.map +1 -0
- package/dist/components/{p-BB0_-X42.js → p-B7kZ1_RH.js} +4 -4
- package/dist/components/{p-BB0_-X42.js.map → p-B7kZ1_RH.js.map} +1 -1
- package/dist/components/{p-t4NIsuX9.js → p-B7w19kIk.js} +15 -27
- package/dist/components/p-B7w19kIk.js.map +1 -0
- package/dist/components/{p-B1BLgWL1.js → p-BGdsAz54.js} +27 -18
- package/dist/components/p-BGdsAz54.js.map +1 -0
- package/dist/components/{p-CGmS8wnN.js → p-BKvOO7NT.js} +26 -16
- package/dist/components/p-BKvOO7NT.js.map +1 -0
- package/dist/components/{p-BhiYvSBc.js → p-BM9IjvnD.js} +3 -3
- package/dist/components/p-BM9IjvnD.js.map +1 -0
- package/dist/components/{p-BrBQUN0Q.js → p-BPsQrpzN.js} +40 -11
- package/dist/components/p-BPsQrpzN.js.map +1 -0
- package/dist/components/p-C6qB08BS.js +68 -0
- package/dist/components/p-C6qB08BS.js.map +1 -0
- package/dist/components/{p-BPz_H-EG.js → p-CM8KdFZI.js} +28 -16
- package/dist/components/p-CM8KdFZI.js.map +1 -0
- package/dist/components/{p-DHSEK3rF.js → p-CNTK3JOp.js} +174 -153
- package/dist/components/p-CNTK3JOp.js.map +1 -0
- package/dist/components/{p-DMrtdhBD.js → p-CsyM5q2M.js} +7 -7
- package/dist/components/p-CsyM5q2M.js.map +1 -0
- package/dist/components/{p-BuewJQNl.js → p-CwH-bwjb.js} +1187 -1141
- package/dist/components/p-CwH-bwjb.js.map +1 -0
- package/dist/components/{p-BgmKrd5Z.js → p-DCx3703u.js} +5 -5
- package/dist/components/p-DCx3703u.js.map +1 -0
- package/dist/components/{p-trncBp_6.js → p-DFO-6kuA.js} +15 -15
- package/dist/components/p-DFO-6kuA.js.map +1 -0
- package/dist/components/{p-BubxwvMA.js → p-Db3kxVe2.js} +24 -24
- package/dist/components/p-Db3kxVe2.js.map +1 -0
- package/dist/components/{p-BexTdWaX.js → p-Ddlbt3Bj.js} +4 -4
- package/dist/components/p-Ddlbt3Bj.js.map +1 -0
- package/dist/components/{p-CHxPWeZd.js → p-DjU7p3od.js} +11 -11
- package/dist/components/{p-CHxPWeZd.js.map → p-DjU7p3od.js.map} +1 -1
- package/dist/components/{p-BeljsQ-8.js → p-Dw4n-4zp.js} +32 -17
- package/dist/components/p-Dw4n-4zp.js.map +1 -0
- package/dist/components/{p-DxTu1aoJ.js → p-NP1Htol7.js} +7 -45
- package/dist/components/p-NP1Htol7.js.map +1 -0
- package/dist/components/p-YqK8ch2R.js +46 -0
- package/dist/components/p-YqK8ch2R.js.map +1 -0
- package/dist/components/p-l10It7Nm.js +30 -0
- package/dist/components/p-l10It7Nm.js.map +1 -0
- package/dist/components/{p-p1Jkec_q.js → p-sq9jgfX0.js} +3 -3
- package/dist/components/p-sq9jgfX0.js.map +1 -0
- package/dist/components/{p-yZ48g7-u.js → p-sreNwi0N.js} +4 -4
- package/dist/components/{p-yZ48g7-u.js.map → p-sreNwi0N.js.map} +1 -1
- package/dist/esm/{index-B-oSk-v8.js → index-DY3KqYWc.js} +756 -702
- package/dist/esm/index-DY3KqYWc.js.map +1 -0
- package/dist/esm/index-oCOlsFCN.js +6 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style.entry.js +30 -0
- package/dist/esm/kritzel-brush-style.entry.js.map +1 -0
- package/dist/esm/{kritzel-brush-style_23.entry.js → kritzel-color_22.entry.js} +1048 -875
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/kritzel-brush-style.entry.esm.js.map +1 -0
- package/dist/stencil/p-25d1e040.entry.js +2 -0
- package/dist/stencil/p-25d1e040.entry.js.map +1 -0
- package/dist/stencil/p-DY3KqYWc.js +2 -0
- package/dist/stencil/p-DY3KqYWc.js.map +1 -0
- package/dist/stencil/p-dc534b01.entry.js +2 -0
- package/dist/stencil/p-dc534b01.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/add-object.command.d.ts +2 -2
- package/dist/types/classes/commands/add-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/base.command.d.ts +3 -3
- package/dist/types/classes/commands/batch.command.d.ts +2 -1
- package/dist/types/classes/commands/move-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/remove-object.command.d.ts +2 -2
- package/dist/types/classes/commands/remove-selection-group.command.d.ts +2 -2
- package/dist/types/classes/commands/resize-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/update-object.command.d.ts +2 -2
- package/dist/types/classes/commands/update-viewport.command.d.ts +2 -1
- package/dist/types/classes/{store.class.d.ts → core/core.class.d.ts} +9 -19
- package/dist/types/classes/{database.class.d.ts → core/database.class.d.ts} +3 -2
- package/dist/types/classes/{history.class.d.ts → core/history.class.d.ts} +5 -5
- package/dist/types/classes/core/reviver.class.d.ts +6 -0
- package/dist/types/classes/core/store.class.d.ts +17 -0
- package/dist/types/classes/{viewport.class.d.ts → core/viewport.class.d.ts} +3 -3
- package/dist/types/classes/core/workspace.class.d.ts +24 -0
- package/dist/types/classes/handlers/base.handler.d.ts +3 -3
- package/dist/types/classes/handlers/context-menu.handler.d.ts +2 -2
- package/dist/types/classes/handlers/hover.handler.d.ts +2 -2
- package/dist/types/classes/handlers/key.handler.d.ts +2 -2
- package/dist/types/classes/handlers/move.handler.d.ts +4 -2
- package/dist/types/classes/handlers/resize.handler.d.ts +3 -2
- package/dist/types/classes/handlers/rotation.handler.d.ts +6 -2
- package/dist/types/classes/handlers/selection.handler.d.ts +2 -2
- package/dist/types/classes/objects/base-object.class.d.ts +8 -5
- package/dist/types/classes/objects/custom-element.class.d.ts +2 -2
- package/dist/types/classes/objects/image.class.d.ts +2 -2
- package/dist/types/classes/objects/path.class.d.ts +2 -2
- package/dist/types/classes/objects/selection-box.class.d.ts +2 -2
- package/dist/types/classes/objects/selection-group.class.d.ts +2 -2
- package/dist/types/classes/objects/text.class.d.ts +2 -2
- package/dist/types/classes/registries/tool.registry.d.ts +2 -2
- package/dist/types/classes/tools/base-tool.class.d.ts +8 -4
- package/dist/types/classes/tools/brush-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/eraser-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/image-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/selection-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/text-tool.class.d.ts +2 -2
- package/dist/types/components/core/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +5 -5
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +13 -3
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +21 -22
- package/dist/types/components/shared/kritzel-dropdown/kritzel-dropdown.d.ts +2 -2
- package/dist/types/components/shared/kritzel-menu-item/kritzel-menu-item.d.ts +2 -0
- package/dist/types/components/shared/kritzel-portal/kritzel-portal.d.ts +0 -1
- package/dist/types/components/shared/kritzel-split-button/kritzel-split-button.d.ts +4 -2
- package/dist/types/components/shared/kritzel-tooltip/kritzel-tooltip.d.ts +8 -2
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +5 -3
- package/dist/types/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.d.ts +1 -1
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +3 -1
- package/dist/types/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +3 -2
- package/dist/types/components.d.ts +41 -12
- package/dist/types/helpers/devices.helper.d.ts +4 -0
- package/dist/types/helpers/event.helper.d.ts +1 -1
- package/dist/types/helpers/html.helper.d.ts +1 -0
- package/dist/types/helpers/object.helper.d.ts +0 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -2
- package/dist/types/interfaces/serializable.interface.d.ts +2 -1
- package/dist/types/types/deep-readonly.type.d.ts +7 -0
- package/package.json +3 -2
- package/dist/cjs/index-BwINBV6L.js.map +0 -1
- package/dist/collection/classes/database.class.js.map +0 -1
- package/dist/collection/classes/history.class.js +0 -88
- package/dist/collection/classes/history.class.js.map +0 -1
- package/dist/collection/classes/reviver.class.js.map +0 -1
- package/dist/collection/classes/store.class.js.map +0 -1
- package/dist/collection/classes/viewport.class.js +0 -153
- package/dist/collection/classes/viewport.class.js.map +0 -1
- package/dist/collection/classes/workspace.class.js +0 -15
- package/dist/collection/classes/workspace.class.js.map +0 -1
- package/dist/components/p-B1BLgWL1.js.map +0 -1
- package/dist/components/p-BB5R2k1o.js.map +0 -1
- package/dist/components/p-BPz_H-EG.js.map +0 -1
- package/dist/components/p-B_lb1FGi.js +0 -19
- package/dist/components/p-B_lb1FGi.js.map +0 -1
- package/dist/components/p-BeljsQ-8.js.map +0 -1
- package/dist/components/p-BexTdWaX.js.map +0 -1
- package/dist/components/p-BgmKrd5Z.js.map +0 -1
- package/dist/components/p-BhiYvSBc.js.map +0 -1
- package/dist/components/p-BrBQUN0Q.js.map +0 -1
- package/dist/components/p-BubxwvMA.js.map +0 -1
- package/dist/components/p-BuewJQNl.js.map +0 -1
- package/dist/components/p-CGmS8wnN.js.map +0 -1
- package/dist/components/p-CJKA5zIE.js +0 -10
- package/dist/components/p-CJKA5zIE.js.map +0 -1
- package/dist/components/p-CMJ3P0Vw.js.map +0 -1
- package/dist/components/p-DHSEK3rF.js.map +0 -1
- package/dist/components/p-DMrtdhBD.js.map +0 -1
- package/dist/components/p-DnUKql15.js +0 -30
- package/dist/components/p-DnUKql15.js.map +0 -1
- package/dist/components/p-DxTu1aoJ.js.map +0 -1
- package/dist/components/p-p1Jkec_q.js.map +0 -1
- package/dist/components/p-rIRXQdie.js +0 -64
- package/dist/components/p-rIRXQdie.js.map +0 -1
- package/dist/components/p-t4NIsuX9.js.map +0 -1
- package/dist/components/p-trncBp_6.js.map +0 -1
- package/dist/esm/index-B-oSk-v8.js.map +0 -1
- package/dist/stencil/p-3bb80782.entry.js +0 -2
- package/dist/stencil/p-3bb80782.entry.js.map +0 -1
- package/dist/stencil/p-B-oSk-v8.js +0 -2
- package/dist/stencil/p-B-oSk-v8.js.map +0 -1
- package/dist/types/classes/reviver.class.d.ts +0 -6
- package/dist/types/classes/workspace.class.d.ts +0 -16
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
class KritzelBaseCommand {
|
|
2
|
-
|
|
2
|
+
_core;
|
|
3
3
|
initiator;
|
|
4
4
|
skipHistory;
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
5
|
+
constructor(core, initiator, skipHistory = false) {
|
|
6
|
+
this._core = core;
|
|
7
7
|
this.initiator = initiator?.constructor?.name ?? 'Unknown';
|
|
8
8
|
this.skipHistory = skipHistory;
|
|
9
9
|
}
|
|
@@ -15,38 +15,12 @@ class KritzelBaseCommand {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
class ObjectHelper {
|
|
19
|
-
static generateUUID() {
|
|
20
|
-
return Math.random().toString(36).substr(2, 9);
|
|
21
|
-
}
|
|
22
|
-
static clone(objOrObjs) {
|
|
23
|
-
const cloneObject = (obj) => {
|
|
24
|
-
const { _store, _elementRef, totalWidth, totalHeight, element, ...remainingProps } = obj;
|
|
25
|
-
const clonedProps = structuredClone(remainingProps);
|
|
26
|
-
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
27
|
-
clonedProps.element = element.cloneNode(true);
|
|
28
|
-
}
|
|
29
|
-
return clonedProps;
|
|
30
|
-
};
|
|
31
|
-
if (Array.isArray(objOrObjs)) {
|
|
32
|
-
return objOrObjs.map(cloneObject);
|
|
33
|
-
}
|
|
34
|
-
return cloneObject(objOrObjs);
|
|
35
|
-
}
|
|
36
|
-
static isEmpty(obj) {
|
|
37
|
-
if (obj === null || obj === undefined) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return Object?.keys(obj).length === 0 && obj?.constructor === Object;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
18
|
class UpdateObjectCommand extends KritzelBaseCommand {
|
|
45
19
|
object;
|
|
46
20
|
updatedProperties;
|
|
47
21
|
previousProperties;
|
|
48
|
-
constructor(
|
|
49
|
-
super(
|
|
22
|
+
constructor(core, initiator, object, updatedProperties, skipHistory = false) {
|
|
23
|
+
super(core, initiator, skipHistory);
|
|
50
24
|
this.object = object;
|
|
51
25
|
this.updatedProperties = updatedProperties;
|
|
52
26
|
this.previousProperties = {};
|
|
@@ -62,7 +36,8 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
62
36
|
this.object[key] = this.updatedProperties[key];
|
|
63
37
|
}
|
|
64
38
|
}
|
|
65
|
-
this.
|
|
39
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
40
|
+
this._core.updateObjectInDatabase(this.object);
|
|
66
41
|
}
|
|
67
42
|
undo() {
|
|
68
43
|
for (const key in this.previousProperties) {
|
|
@@ -70,14 +45,15 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
70
45
|
this.object[key] = this.previousProperties[key];
|
|
71
46
|
}
|
|
72
47
|
}
|
|
73
|
-
this.
|
|
48
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
49
|
+
this._core.updateObjectInDatabase(this.object);
|
|
74
50
|
}
|
|
75
51
|
}
|
|
76
52
|
|
|
77
53
|
class KritzelToolRegistry {
|
|
78
54
|
static registry = {};
|
|
79
|
-
static registerTool(toolName, constructor,
|
|
80
|
-
const toolInstance = new constructor(
|
|
55
|
+
static registerTool(toolName, constructor, core) {
|
|
56
|
+
const toolInstance = new constructor(core);
|
|
81
57
|
toolInstance.name = toolName;
|
|
82
58
|
this.registry[toolName] = toolInstance;
|
|
83
59
|
return toolInstance;
|
|
@@ -95,9 +71,9 @@ class KritzelToolRegistry {
|
|
|
95
71
|
class KritzelBaseTool {
|
|
96
72
|
__class__ = this.constructor.name;
|
|
97
73
|
name = 'base-tool';
|
|
98
|
-
|
|
99
|
-
constructor(
|
|
100
|
-
this.
|
|
74
|
+
_core;
|
|
75
|
+
constructor(core) {
|
|
76
|
+
this._core = core;
|
|
101
77
|
}
|
|
102
78
|
onActivate() {
|
|
103
79
|
// default implementation
|
|
@@ -117,7 +93,13 @@ class KritzelBaseTool {
|
|
|
117
93
|
handleWheel(_event) {
|
|
118
94
|
// default implementation
|
|
119
95
|
}
|
|
120
|
-
|
|
96
|
+
serialize() {
|
|
97
|
+
return {
|
|
98
|
+
__class__: this.__class__,
|
|
99
|
+
name: this.name,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
deserialize(object) {
|
|
121
103
|
Object.assign(this, object);
|
|
122
104
|
return this;
|
|
123
105
|
}
|
|
@@ -125,17 +107,17 @@ class KritzelBaseTool {
|
|
|
125
107
|
|
|
126
108
|
class AddObjectCommand extends KritzelBaseCommand {
|
|
127
109
|
object;
|
|
128
|
-
constructor(
|
|
129
|
-
super(
|
|
110
|
+
constructor(core, initiator, object, skipHistory = false) {
|
|
111
|
+
super(core, initiator, skipHistory);
|
|
130
112
|
this.object = object;
|
|
131
113
|
}
|
|
132
114
|
execute() {
|
|
133
|
-
this.
|
|
134
|
-
this.
|
|
115
|
+
this._core.store.state.objectsMap.insert(this.object);
|
|
116
|
+
this._core.addObjectToDatabase(this.object);
|
|
135
117
|
}
|
|
136
118
|
undo() {
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
119
|
+
this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
|
|
120
|
+
this._core.deleteObjectFromDatabase(this.object.id);
|
|
139
121
|
}
|
|
140
122
|
}
|
|
141
123
|
|
|
@@ -161,11 +143,7 @@ class KritzelEventHelper {
|
|
|
161
143
|
const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
|
|
162
144
|
return !!contextMenu;
|
|
163
145
|
}
|
|
164
|
-
static
|
|
165
|
-
if (event.pointerType !== 'touch') {
|
|
166
|
-
onCancel?.();
|
|
167
|
-
return () => { };
|
|
168
|
-
}
|
|
146
|
+
static onLongPress(event, onSuccess, onCancel) {
|
|
169
147
|
const longPressTimeout = 400;
|
|
170
148
|
const moveThreshold = 10;
|
|
171
149
|
const startX = event.clientX;
|
|
@@ -273,8 +251,8 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
273
251
|
'#808000',
|
|
274
252
|
'#800080',
|
|
275
253
|
];
|
|
276
|
-
constructor(
|
|
277
|
-
super(
|
|
254
|
+
constructor(core) {
|
|
255
|
+
super(core);
|
|
278
256
|
}
|
|
279
257
|
handlePointerDown(event) {
|
|
280
258
|
if (event.cancelable) {
|
|
@@ -283,66 +261,66 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
283
261
|
if (event.pointerType === 'mouse') {
|
|
284
262
|
const path = event.composedPath().slice(1);
|
|
285
263
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
286
|
-
const object = this.
|
|
287
|
-
if (this.
|
|
288
|
-
this.
|
|
264
|
+
const object = this._core.findObjectById(objectElement?.id);
|
|
265
|
+
if (this._core.store.state.activeText === null && object && object instanceof KritzelText) {
|
|
266
|
+
this._core.store.setState('activeText', object);
|
|
289
267
|
object.focus();
|
|
290
268
|
return;
|
|
291
269
|
}
|
|
292
|
-
if (this.
|
|
270
|
+
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
293
271
|
object.focus();
|
|
294
272
|
return;
|
|
295
273
|
}
|
|
296
|
-
if (this.
|
|
297
|
-
this.
|
|
298
|
-
this.
|
|
274
|
+
if (this._core.store.state.activeText !== null) {
|
|
275
|
+
this._core.resetActiveText();
|
|
276
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
299
277
|
return;
|
|
300
278
|
}
|
|
301
279
|
if (KritzelEventHelper.isLeftClick(event) === false) {
|
|
302
280
|
return;
|
|
303
281
|
}
|
|
304
|
-
const clientX = event.clientX - this.
|
|
305
|
-
const clientY = event.clientY - this.
|
|
306
|
-
const text = KritzelText.create(this.
|
|
282
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
283
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
284
|
+
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
307
285
|
text.fontColor = this.fontColor;
|
|
308
|
-
text.translateX = (clientX - this.
|
|
309
|
-
text.translateY = (clientY - this.
|
|
310
|
-
text.zIndex = this.
|
|
311
|
-
this.
|
|
312
|
-
this.
|
|
286
|
+
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
287
|
+
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
288
|
+
text.zIndex = this._core.store.currentZIndex;
|
|
289
|
+
this._core.store.setState('activeText', text);
|
|
290
|
+
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
313
291
|
}
|
|
314
292
|
if (event.pointerType === 'touch') {
|
|
315
|
-
const activePointers = Array.from(this.
|
|
293
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
316
294
|
const path = event.composedPath().slice(1);
|
|
317
295
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
318
|
-
const object = this.
|
|
319
|
-
if (this.
|
|
320
|
-
this.
|
|
296
|
+
const object = this._core.findObjectById(objectElement?.id);
|
|
297
|
+
if (this._core.store.state.activeText === null && object && object instanceof KritzelText) {
|
|
298
|
+
this._core.store.setState('activeText', object);
|
|
321
299
|
object.focus();
|
|
322
300
|
return;
|
|
323
301
|
}
|
|
324
|
-
if (this.
|
|
302
|
+
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
325
303
|
object.focus();
|
|
326
304
|
return;
|
|
327
305
|
}
|
|
328
|
-
if (this.
|
|
329
|
-
this.
|
|
330
|
-
this.
|
|
306
|
+
if (this._core.store.state.activeText !== null) {
|
|
307
|
+
this._core.resetActiveText();
|
|
308
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
331
309
|
return;
|
|
332
310
|
}
|
|
333
311
|
if (activePointers.length > 1) {
|
|
334
312
|
return;
|
|
335
313
|
}
|
|
336
314
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
337
|
-
const clientX = Math.round(activePointers[0].clientX - this.
|
|
338
|
-
const clientY = Math.round(activePointers[0].clientY - this.
|
|
339
|
-
const text = KritzelText.create(this.
|
|
315
|
+
const clientX = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
316
|
+
const clientY = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
317
|
+
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
340
318
|
text.fontColor = this.fontColor;
|
|
341
|
-
text.translateX = (clientX - this.
|
|
342
|
-
text.translateY = (clientY - this.
|
|
343
|
-
text.zIndex = this.
|
|
344
|
-
this.
|
|
345
|
-
this.
|
|
319
|
+
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
320
|
+
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
321
|
+
text.zIndex = this._core.store.currentZIndex;
|
|
322
|
+
this._core.store.setState('activeText', text);
|
|
323
|
+
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
346
324
|
}
|
|
347
325
|
}
|
|
348
326
|
handlePointerUp(event) {
|
|
@@ -350,17 +328,29 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
350
328
|
event.preventDefault();
|
|
351
329
|
}
|
|
352
330
|
if (event.pointerType === 'mouse') {
|
|
353
|
-
this.
|
|
354
|
-
this.
|
|
331
|
+
this._core.store.state.activeText?.updateTextareaDimensions();
|
|
332
|
+
this._core.store.state.activeText?.focus();
|
|
355
333
|
}
|
|
356
334
|
if (event.pointerType === 'touch') {
|
|
357
|
-
this.
|
|
358
|
-
this.
|
|
335
|
+
this._core.store.state.activeText?.updateTextareaDimensions();
|
|
336
|
+
this._core.store.state.activeText?.focus();
|
|
359
337
|
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
360
338
|
}
|
|
361
339
|
}
|
|
362
340
|
}
|
|
363
341
|
|
|
342
|
+
class ObjectHelper {
|
|
343
|
+
static generateUUID() {
|
|
344
|
+
return Math.random().toString(36).substr(2, 9);
|
|
345
|
+
}
|
|
346
|
+
static isEmpty(obj) {
|
|
347
|
+
if (obj === null || obj === undefined) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
return Object?.keys(obj).length === 0 && obj?.constructor === Object;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
364
354
|
class KritzelGeometryHelper {
|
|
365
355
|
static doPolygonsIntersect(polygon1, polygon2) {
|
|
366
356
|
// 1. Convert polygons to array of points for easier processing
|
|
@@ -416,7 +406,7 @@ class KritzelGeometryHelper {
|
|
|
416
406
|
|
|
417
407
|
class KritzelBaseObject {
|
|
418
408
|
__class__ = 'KritzelBaseObject';
|
|
419
|
-
|
|
409
|
+
_core;
|
|
420
410
|
_elementRef;
|
|
421
411
|
id;
|
|
422
412
|
workspaceId;
|
|
@@ -530,11 +520,11 @@ class KritzelBaseObject {
|
|
|
530
520
|
constructor() {
|
|
531
521
|
this.id = this.generateId();
|
|
532
522
|
}
|
|
533
|
-
static create(
|
|
523
|
+
static create(core) {
|
|
534
524
|
const object = new KritzelBaseObject();
|
|
535
|
-
object.
|
|
536
|
-
object.zIndex = store.currentZIndex;
|
|
537
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
525
|
+
object._core = core;
|
|
526
|
+
object.zIndex = core.store.currentZIndex;
|
|
527
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
538
528
|
return object;
|
|
539
529
|
}
|
|
540
530
|
mount(element) {
|
|
@@ -561,23 +551,23 @@ class KritzelBaseObject {
|
|
|
561
551
|
}
|
|
562
552
|
isInViewport() {
|
|
563
553
|
const viewportBounds = {
|
|
564
|
-
x: -this.
|
|
565
|
-
y: -this.
|
|
566
|
-
width: this.
|
|
567
|
-
height: this.
|
|
554
|
+
x: -this._core.store.state.translateX / this._core.store.state.scale,
|
|
555
|
+
y: -this._core.store.state.translateY / this._core.store.state.scale,
|
|
556
|
+
width: this._core.store.state.viewportWidth / this._core.store.state.scale,
|
|
557
|
+
height: this._core.store.state.viewportHeight / this._core.store.state.scale};
|
|
568
558
|
return (this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
|
|
569
559
|
this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&
|
|
570
560
|
this.boundingBox.y < viewportBounds.y + viewportBounds.height &&
|
|
571
561
|
this.boundingBox.y + this.boundingBox.height > viewportBounds.y);
|
|
572
562
|
}
|
|
573
563
|
centerInViewport() {
|
|
574
|
-
const scale = this.
|
|
575
|
-
this.translateX = (this.
|
|
576
|
-
this.translateY = (this.
|
|
564
|
+
const scale = this._core.store.state.scale;
|
|
565
|
+
this.translateX = (this._core.store.state.viewportWidth / 2 - this.totalWidth / 2 - this._core.store.state.translateX) / scale;
|
|
566
|
+
this.translateY = (this._core.store.state.viewportHeight / 2 - this.totalHeight / 2 - this._core.store.state.translateY) / scale;
|
|
577
567
|
}
|
|
578
568
|
move(startX, startY, endX, endY) {
|
|
579
|
-
const deltaX = (startX - endX) / this.
|
|
580
|
-
const deltaY = (startY - endY) / this.
|
|
569
|
+
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
570
|
+
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
581
571
|
this.translateX += deltaX;
|
|
582
572
|
this.translateY += deltaY;
|
|
583
573
|
}
|
|
@@ -593,6 +583,11 @@ class KritzelBaseObject {
|
|
|
593
583
|
rotate(value) {
|
|
594
584
|
this.rotation = value;
|
|
595
585
|
}
|
|
586
|
+
clone() {
|
|
587
|
+
const clone = new KritzelBaseObject();
|
|
588
|
+
Object.assign(clone, this);
|
|
589
|
+
return clone;
|
|
590
|
+
}
|
|
596
591
|
copy() {
|
|
597
592
|
const copiedObject = Object.create(Object.getPrototypeOf(this));
|
|
598
593
|
Object.assign(copiedObject, this);
|
|
@@ -603,7 +598,15 @@ class KritzelBaseObject {
|
|
|
603
598
|
onSelectedClick() {
|
|
604
599
|
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
605
600
|
}
|
|
606
|
-
|
|
601
|
+
serialize() {
|
|
602
|
+
const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this;
|
|
603
|
+
const clonedProps = structuredClone(remainingProps);
|
|
604
|
+
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
605
|
+
clonedProps.element = element.cloneNode(true);
|
|
606
|
+
}
|
|
607
|
+
return clonedProps;
|
|
608
|
+
}
|
|
609
|
+
deserialize(object) {
|
|
607
610
|
Object.assign(this, object);
|
|
608
611
|
return this;
|
|
609
612
|
}
|
|
@@ -623,7 +626,7 @@ class KritzelBaseObject {
|
|
|
623
626
|
updatePosition(x, y) {
|
|
624
627
|
this.translateX = x;
|
|
625
628
|
this.translateY = y;
|
|
626
|
-
this.
|
|
629
|
+
this._core.store.state.objectsMap.update(this);
|
|
627
630
|
}
|
|
628
631
|
}
|
|
629
632
|
|
|
@@ -639,7 +642,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
639
642
|
isEditable = true;
|
|
640
643
|
rows = 1;
|
|
641
644
|
get isReadonly() {
|
|
642
|
-
return !(this.
|
|
645
|
+
return !(this._core.store.state.activeTool instanceof KritzelTextTool);
|
|
643
646
|
}
|
|
644
647
|
constructor(config) {
|
|
645
648
|
super();
|
|
@@ -655,22 +658,22 @@ class KritzelText extends KritzelBaseObject {
|
|
|
655
658
|
this.scale = config.scale || 1;
|
|
656
659
|
}
|
|
657
660
|
}
|
|
658
|
-
static create(
|
|
661
|
+
static create(core, fontSize, fontFamily) {
|
|
659
662
|
const object = new KritzelText();
|
|
660
|
-
object.
|
|
663
|
+
object._core = core;
|
|
661
664
|
object.id = object.generateId();
|
|
662
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
665
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
663
666
|
object.fontSize = fontSize;
|
|
664
667
|
object.fontFamily = fontFamily;
|
|
665
668
|
object.translateX = 0;
|
|
666
669
|
object.translateY = 0;
|
|
667
|
-
object.width = object.initialWidth / (object.
|
|
668
|
-
object.height = (object.fontSize * 1.2) / (object.
|
|
670
|
+
object.width = object.initialWidth / (object._core.store.state.scale < 0 ? object._core.store.state.scale : 1);
|
|
671
|
+
object.height = (object.fontSize * 1.2) / (object._core.store.state.scale < 0 ? object._core.store.state.scale : 1);
|
|
669
672
|
object.padding = 5;
|
|
670
673
|
object.backgroundColor = 'transparent';
|
|
671
|
-
object.scale = object.
|
|
674
|
+
object.scale = object._core.store.state.scale;
|
|
672
675
|
object.value = ' ';
|
|
673
|
-
object.zIndex = store.currentZIndex;
|
|
676
|
+
object.zIndex = core.store.currentZIndex;
|
|
674
677
|
return object;
|
|
675
678
|
}
|
|
676
679
|
mount(element) {
|
|
@@ -724,7 +727,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
724
727
|
document.body.removeChild(span);
|
|
725
728
|
this.width = textWidth;
|
|
726
729
|
this.height = textHeight;
|
|
727
|
-
this.
|
|
730
|
+
this._core.history.executeCommand(new UpdateObjectCommand(this._core, this, this, { ...this }));
|
|
728
731
|
}
|
|
729
732
|
}
|
|
730
733
|
focus() {
|
|
@@ -757,10 +760,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
757
760
|
}
|
|
758
761
|
}
|
|
759
762
|
edit() {
|
|
760
|
-
this.
|
|
761
|
-
this.
|
|
762
|
-
this.
|
|
763
|
-
this.
|
|
763
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
764
|
+
this._core.store.setState('selectionGroup', null);
|
|
765
|
+
this._core.store.setState('selectionBox', null);
|
|
766
|
+
this._core.store.setState('activeText', this);
|
|
764
767
|
setTimeout(() => {
|
|
765
768
|
this.focus();
|
|
766
769
|
}, 300);
|
|
@@ -820,11 +823,11 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
820
823
|
this.d = this.generateSvgPath();
|
|
821
824
|
this.updateDimensions();
|
|
822
825
|
}
|
|
823
|
-
static create(
|
|
826
|
+
static create(core, options) {
|
|
824
827
|
const object = new KritzelPath();
|
|
825
|
-
object.
|
|
828
|
+
object._core = core;
|
|
826
829
|
object.id = object.generateId();
|
|
827
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
830
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
828
831
|
object.options = options;
|
|
829
832
|
object.points = options?.points ?? [];
|
|
830
833
|
object.translateX = options?.translateX ?? 0;
|
|
@@ -832,7 +835,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
832
835
|
object.scale = options?.scale ?? 1;
|
|
833
836
|
object.strokeWidth = options?.strokeWidth ?? 8;
|
|
834
837
|
object.fill = options?.fill ?? '#000000';
|
|
835
|
-
object.zIndex = store.currentZIndex;
|
|
838
|
+
object.zIndex = core.store.currentZIndex;
|
|
836
839
|
object.d = object.generateSvgPath();
|
|
837
840
|
object.updateDimensions();
|
|
838
841
|
return object;
|
|
@@ -860,8 +863,8 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
860
863
|
this._adjustedPoints = null;
|
|
861
864
|
}
|
|
862
865
|
move(startX, startY, endX, endY) {
|
|
863
|
-
const deltaX = (startX - endX) / this.
|
|
864
|
-
const deltaY = (startY - endY) / this.
|
|
866
|
+
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
867
|
+
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
865
868
|
this.translateX += deltaX;
|
|
866
869
|
this.translateY += deltaY;
|
|
867
870
|
this._adjustedPoints = null;
|
|
@@ -940,7 +943,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
940
943
|
this.translateX = x;
|
|
941
944
|
this.translateY = y;
|
|
942
945
|
this._adjustedPoints = null;
|
|
943
|
-
this.
|
|
946
|
+
this._core.store.state.objectsMap.update(this);
|
|
944
947
|
}
|
|
945
948
|
computeAdjustedPoints() {
|
|
946
949
|
if (!this.points?.length) {
|
|
@@ -1071,17 +1074,17 @@ class KritzelImage extends KritzelBaseObject {
|
|
|
1071
1074
|
this.translateY = config?.translateY || 0;
|
|
1072
1075
|
this.scale = config?.scale || 1;
|
|
1073
1076
|
}
|
|
1074
|
-
static create(
|
|
1077
|
+
static create(core) {
|
|
1075
1078
|
const object = new KritzelImage();
|
|
1076
|
-
object.
|
|
1079
|
+
object._core = core;
|
|
1077
1080
|
object.id = object.generateId();
|
|
1078
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
1081
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
1079
1082
|
object.x = 0;
|
|
1080
1083
|
object.y = 0;
|
|
1081
1084
|
object.translateX = 0;
|
|
1082
1085
|
object.translateY = 0;
|
|
1083
|
-
object.scale = object.
|
|
1084
|
-
object.zIndex = store.currentZIndex;
|
|
1086
|
+
object.scale = object._core.store.state.scale;
|
|
1087
|
+
object.zIndex = core.store.currentZIndex;
|
|
1085
1088
|
return object;
|
|
1086
1089
|
}
|
|
1087
1090
|
resize(x, y, width, height) {
|
|
@@ -1116,8 +1119,8 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1116
1119
|
pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],
|
|
1117
1120
|
highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
|
|
1118
1121
|
};
|
|
1119
|
-
constructor(
|
|
1120
|
-
super(
|
|
1122
|
+
constructor(core) {
|
|
1123
|
+
super(core);
|
|
1121
1124
|
}
|
|
1122
1125
|
handlePointerDown(event) {
|
|
1123
1126
|
if (event.cancelable) {
|
|
@@ -1125,34 +1128,34 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1125
1128
|
}
|
|
1126
1129
|
if (event.pointerType === 'mouse') {
|
|
1127
1130
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1128
|
-
this.
|
|
1129
|
-
const x = event.clientX - this.
|
|
1130
|
-
const y = event.clientY - this.
|
|
1131
|
-
this.
|
|
1131
|
+
this._core.store.setState('isDrawing', true);
|
|
1132
|
+
const x = event.clientX - this._core.store.offsetX;
|
|
1133
|
+
const y = event.clientY - this._core.store.offsetY;
|
|
1134
|
+
this._core.store.setState('currentPath', KritzelPath.create(this._core, {
|
|
1132
1135
|
points: [[x, y]],
|
|
1133
|
-
translateX: -this.
|
|
1134
|
-
translateY: -this.
|
|
1135
|
-
scale: this.
|
|
1136
|
+
translateX: -this._core.store.state.translateX,
|
|
1137
|
+
translateY: -this._core.store.state.translateY,
|
|
1138
|
+
scale: this._core.store.state.scale,
|
|
1136
1139
|
fill: this.color,
|
|
1137
1140
|
strokeWidth: this.size,
|
|
1138
|
-
});
|
|
1141
|
+
}));
|
|
1139
1142
|
}
|
|
1140
1143
|
}
|
|
1141
1144
|
if (event.pointerType === 'touch') {
|
|
1142
|
-
const activePointers = Array.from(this.
|
|
1145
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1143
1146
|
if (activePointers.length === 1) {
|
|
1144
|
-
const x = Math.round(activePointers[0].clientX - this.
|
|
1145
|
-
const y = Math.round(activePointers[0].clientY - this.
|
|
1146
|
-
this.
|
|
1147
|
-
this.
|
|
1147
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1148
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1149
|
+
this._core.store.setState('isDrawing', true);
|
|
1150
|
+
this._core.store.setState('currentPath', KritzelPath.create(this._core, {
|
|
1148
1151
|
points: [[x, y]],
|
|
1149
|
-
translateX: -this.
|
|
1150
|
-
translateY: -this.
|
|
1151
|
-
scale: this.
|
|
1152
|
+
translateX: -this._core.store.state.translateX,
|
|
1153
|
+
translateY: -this._core.store.state.translateY,
|
|
1154
|
+
scale: this._core.store.state.scale,
|
|
1152
1155
|
fill: this.color,
|
|
1153
1156
|
strokeWidth: this.size,
|
|
1154
|
-
});
|
|
1155
|
-
this.
|
|
1157
|
+
}));
|
|
1158
|
+
this._core.rerender();
|
|
1156
1159
|
}
|
|
1157
1160
|
}
|
|
1158
1161
|
}
|
|
@@ -1161,34 +1164,34 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1161
1164
|
event.preventDefault();
|
|
1162
1165
|
}
|
|
1163
1166
|
if (event.pointerType === 'mouse') {
|
|
1164
|
-
if (this.
|
|
1165
|
-
const x = event.clientX - this.
|
|
1166
|
-
const y = event.clientY - this.
|
|
1167
|
-
this.
|
|
1168
|
-
points: [...this.
|
|
1169
|
-
translateX: -this.
|
|
1170
|
-
translateY: -this.
|
|
1171
|
-
scale: this.
|
|
1167
|
+
if (this._core.store.state.isDrawing) {
|
|
1168
|
+
const x = event.clientX - this._core.store.offsetX;
|
|
1169
|
+
const y = event.clientY - this._core.store.offsetY;
|
|
1170
|
+
this._core.store.setState('currentPath', KritzelPath.create(this._core, {
|
|
1171
|
+
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1172
|
+
translateX: -this._core.store.state.translateX,
|
|
1173
|
+
translateY: -this._core.store.state.translateY,
|
|
1174
|
+
scale: this._core.store.state.scale,
|
|
1172
1175
|
fill: this.color,
|
|
1173
1176
|
strokeWidth: this.size,
|
|
1174
|
-
});
|
|
1175
|
-
this.
|
|
1177
|
+
}));
|
|
1178
|
+
this._core.rerender();
|
|
1176
1179
|
}
|
|
1177
1180
|
}
|
|
1178
1181
|
if (event.pointerType === 'touch') {
|
|
1179
|
-
const activePointers = Array.from(this.
|
|
1182
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1180
1183
|
if (activePointers.length === 1) {
|
|
1181
|
-
const x = Math.round(activePointers[0].clientX - this.
|
|
1182
|
-
const y = Math.round(activePointers[0].clientY - this.
|
|
1183
|
-
this.
|
|
1184
|
-
points: [...this.
|
|
1185
|
-
translateX: -this.
|
|
1186
|
-
translateY: -this.
|
|
1187
|
-
scale: this.
|
|
1184
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1185
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1186
|
+
this._core.store.setState('currentPath', KritzelPath.create(this._core, {
|
|
1187
|
+
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1188
|
+
translateX: -this._core.store.state.translateX,
|
|
1189
|
+
translateY: -this._core.store.state.translateY,
|
|
1190
|
+
scale: this._core.store.state.scale,
|
|
1188
1191
|
fill: this.color,
|
|
1189
1192
|
strokeWidth: this.size,
|
|
1190
|
-
});
|
|
1191
|
-
this.
|
|
1193
|
+
}));
|
|
1194
|
+
this._core.rerender();
|
|
1192
1195
|
}
|
|
1193
1196
|
}
|
|
1194
1197
|
}
|
|
@@ -1197,24 +1200,28 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1197
1200
|
event.preventDefault();
|
|
1198
1201
|
}
|
|
1199
1202
|
if (event.pointerType === 'mouse') {
|
|
1200
|
-
if (this.
|
|
1201
|
-
this.
|
|
1202
|
-
if (this.
|
|
1203
|
-
|
|
1204
|
-
|
|
1203
|
+
if (this._core.store.state.isDrawing) {
|
|
1204
|
+
this._core.store.setState('isDrawing', false);
|
|
1205
|
+
if (this._core.store.state.currentPath) {
|
|
1206
|
+
const currentPath = this._core.store.state.currentPath;
|
|
1207
|
+
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1208
|
+
this._core.store.setState('currentPath', currentPath);
|
|
1209
|
+
this._core.history.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
|
|
1205
1210
|
}
|
|
1206
|
-
this.
|
|
1211
|
+
this._core.store.setState('currentPath', undefined);
|
|
1207
1212
|
}
|
|
1208
1213
|
}
|
|
1209
1214
|
if (event.pointerType === 'touch') {
|
|
1210
|
-
if (this.
|
|
1211
|
-
this.
|
|
1212
|
-
if (this.
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
+
if (this._core.store.state.isDrawing) {
|
|
1216
|
+
this._core.store.setState('isDrawing', false);
|
|
1217
|
+
if (this._core.store.state.currentPath) {
|
|
1218
|
+
const currentPath = this._core.store.state.currentPath;
|
|
1219
|
+
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1220
|
+
this._core.store.setState('currentPath', currentPath);
|
|
1221
|
+
this._core.history.executeCommand(new AddObjectCommand(this._core, this, currentPath));
|
|
1215
1222
|
}
|
|
1216
|
-
this.
|
|
1217
|
-
this.
|
|
1223
|
+
this._core.store.setState('currentPath', undefined);
|
|
1224
|
+
this._core.rerender();
|
|
1218
1225
|
}
|
|
1219
1226
|
}
|
|
1220
1227
|
}
|
|
@@ -1222,8 +1229,8 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1222
1229
|
|
|
1223
1230
|
class BatchCommand extends KritzelBaseCommand {
|
|
1224
1231
|
commands;
|
|
1225
|
-
constructor(
|
|
1226
|
-
super(
|
|
1232
|
+
constructor(core, initiator, commands, skipHistory = false) {
|
|
1233
|
+
super(core, initiator, skipHistory);
|
|
1227
1234
|
this.commands = commands;
|
|
1228
1235
|
}
|
|
1229
1236
|
execute() {
|
|
@@ -1249,11 +1256,11 @@ class KritzelCustomElement extends KritzelBaseObject {
|
|
|
1249
1256
|
this.width = config.width || 0;
|
|
1250
1257
|
}
|
|
1251
1258
|
}
|
|
1252
|
-
static create(
|
|
1259
|
+
static create(core, config) {
|
|
1253
1260
|
const object = new KritzelCustomElement(config);
|
|
1254
|
-
object.
|
|
1261
|
+
object._core = core;
|
|
1255
1262
|
object.id = object.generateId();
|
|
1256
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
1263
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
1257
1264
|
return object;
|
|
1258
1265
|
}
|
|
1259
1266
|
mount(element) {
|
|
@@ -1289,98 +1296,98 @@ class KritzelCustomElement extends KritzelBaseObject {
|
|
|
1289
1296
|
|
|
1290
1297
|
class RemoveObjectCommand extends KritzelBaseCommand {
|
|
1291
1298
|
object;
|
|
1292
|
-
constructor(
|
|
1293
|
-
super(
|
|
1299
|
+
constructor(core, initiator, object, skipHistory = false) {
|
|
1300
|
+
super(core, initiator, skipHistory);
|
|
1294
1301
|
this.object = object;
|
|
1295
1302
|
}
|
|
1296
1303
|
execute() {
|
|
1297
|
-
this.
|
|
1298
|
-
this.
|
|
1299
|
-
this.
|
|
1304
|
+
this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
|
|
1305
|
+
this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
1306
|
+
this._core.deleteObjectFromDatabase(this.object.id);
|
|
1300
1307
|
}
|
|
1301
1308
|
undo() {
|
|
1302
|
-
this.
|
|
1303
|
-
this.
|
|
1304
|
-
this.
|
|
1309
|
+
this._core.store.state.objectsMap.insert(this.object);
|
|
1310
|
+
this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
1311
|
+
this._core.addObjectToDatabase(this.object);
|
|
1305
1312
|
}
|
|
1306
1313
|
}
|
|
1307
1314
|
|
|
1308
1315
|
class KritzelEraserTool extends KritzelBaseTool {
|
|
1309
1316
|
touchStartTimeout = null;
|
|
1310
|
-
constructor(
|
|
1311
|
-
super(
|
|
1317
|
+
constructor(core) {
|
|
1318
|
+
super(core);
|
|
1312
1319
|
}
|
|
1313
1320
|
handlePointerDown(event) {
|
|
1314
1321
|
if (event.pointerType === 'mouse') {
|
|
1315
1322
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1316
|
-
this.
|
|
1323
|
+
this._core.store.setState('isErasing', true);
|
|
1317
1324
|
}
|
|
1318
1325
|
}
|
|
1319
1326
|
if (event.pointerType === 'touch') {
|
|
1320
1327
|
this.touchStartTimeout = setTimeout(() => {
|
|
1321
|
-
if (this.
|
|
1322
|
-
this.
|
|
1328
|
+
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
1329
|
+
this._core.store.setState('isErasing', true);
|
|
1323
1330
|
}
|
|
1324
1331
|
}, 80);
|
|
1325
1332
|
}
|
|
1326
1333
|
}
|
|
1327
1334
|
handlePointerMove(event) {
|
|
1328
1335
|
if (event.pointerType === 'mouse') {
|
|
1329
|
-
if (this.
|
|
1330
|
-
const selectedObjects = this.
|
|
1336
|
+
if (this._core.store.state.isErasing) {
|
|
1337
|
+
const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
1331
1338
|
if (selectedObjects.length === 0)
|
|
1332
1339
|
return;
|
|
1333
|
-
const x = this.
|
|
1334
|
-
const y = this.
|
|
1340
|
+
const x = this._core.store.state.pointerX;
|
|
1341
|
+
const y = this._core.store.state.pointerY;
|
|
1335
1342
|
selectedObjects.forEach(selectedObject => {
|
|
1336
1343
|
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
1337
1344
|
});
|
|
1338
|
-
this.
|
|
1345
|
+
this._core.rerender();
|
|
1339
1346
|
}
|
|
1340
1347
|
}
|
|
1341
1348
|
if (event.pointerType === 'touch') {
|
|
1342
|
-
if (this.
|
|
1343
|
-
const shadowRoot = this.
|
|
1349
|
+
if (this._core.store.state.pointers.size === 1 && this._core.store.state.isErasing) {
|
|
1350
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
1344
1351
|
if (!shadowRoot)
|
|
1345
1352
|
return;
|
|
1346
|
-
const selectedObjects = this.
|
|
1353
|
+
const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
1347
1354
|
if (selectedObjects.length === 0)
|
|
1348
1355
|
return;
|
|
1349
|
-
const x = this.
|
|
1350
|
-
const y = this.
|
|
1356
|
+
const x = this._core.store.state.pointerX;
|
|
1357
|
+
const y = this._core.store.state.pointerY;
|
|
1351
1358
|
selectedObjects.forEach(selectedObject => {
|
|
1352
1359
|
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
1353
1360
|
});
|
|
1354
|
-
this.
|
|
1361
|
+
this._core.rerender();
|
|
1355
1362
|
}
|
|
1356
1363
|
}
|
|
1357
1364
|
}
|
|
1358
1365
|
handlePointerUp(event) {
|
|
1359
1366
|
if (event.pointerType === 'mouse') {
|
|
1360
|
-
if (this.
|
|
1361
|
-
const removeCommands = this.
|
|
1367
|
+
if (this._core.store.state.isErasing) {
|
|
1368
|
+
const removeCommands = this._core.store.allObjects.filter(object => object.markedForRemoval).map(object => {
|
|
1362
1369
|
object.markedForRemoval = false;
|
|
1363
|
-
return new RemoveObjectCommand(this.
|
|
1370
|
+
return new RemoveObjectCommand(this._core, this, object);
|
|
1364
1371
|
});
|
|
1365
1372
|
if (removeCommands.length > 0) {
|
|
1366
|
-
this.
|
|
1373
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1367
1374
|
}
|
|
1368
|
-
this.
|
|
1375
|
+
this._core.store.setState('isErasing', false);
|
|
1369
1376
|
}
|
|
1370
1377
|
}
|
|
1371
1378
|
if (event.pointerType === 'touch') {
|
|
1372
1379
|
clearTimeout(this.touchStartTimeout);
|
|
1373
|
-
if (this.
|
|
1374
|
-
const removeCommands = this.
|
|
1380
|
+
if (this._core.store.state.isErasing) {
|
|
1381
|
+
const removeCommands = this._core.store.allObjects
|
|
1375
1382
|
.filter(object => object.markedForRemoval)
|
|
1376
1383
|
.map(object => {
|
|
1377
1384
|
object.markedForRemoval = false;
|
|
1378
|
-
return new RemoveObjectCommand(this.
|
|
1385
|
+
return new RemoveObjectCommand(this._core, this, object);
|
|
1379
1386
|
});
|
|
1380
1387
|
if (removeCommands.length > 0) {
|
|
1381
|
-
this.
|
|
1388
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1382
1389
|
}
|
|
1383
|
-
this.
|
|
1390
|
+
this._core.store.setState('isErasing', false);
|
|
1384
1391
|
}
|
|
1385
1392
|
}
|
|
1386
1393
|
}
|
|
@@ -1388,18 +1395,18 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1388
1395
|
|
|
1389
1396
|
class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
1390
1397
|
previousSelectionGroup;
|
|
1391
|
-
constructor(
|
|
1392
|
-
super(
|
|
1393
|
-
this.previousSelectionGroup = this.
|
|
1398
|
+
constructor(core, initiator, skipHistory = false) {
|
|
1399
|
+
super(core, initiator, skipHistory);
|
|
1400
|
+
this.previousSelectionGroup = this._core.store.state.selectionGroup;
|
|
1394
1401
|
}
|
|
1395
1402
|
execute() {
|
|
1396
|
-
this.
|
|
1397
|
-
this.
|
|
1403
|
+
this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
|
|
1404
|
+
this._core.store.setState('selectionGroup', null);
|
|
1398
1405
|
}
|
|
1399
1406
|
undo() {
|
|
1400
1407
|
if (this.previousSelectionGroup) {
|
|
1401
|
-
this.
|
|
1402
|
-
this.
|
|
1408
|
+
this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
|
|
1409
|
+
this._core.store.setState('selectionGroup', this.previousSelectionGroup);
|
|
1403
1410
|
}
|
|
1404
1411
|
}
|
|
1405
1412
|
}
|
|
@@ -1411,33 +1418,41 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1411
1418
|
endX;
|
|
1412
1419
|
endY;
|
|
1413
1420
|
skipExecution;
|
|
1414
|
-
constructor(
|
|
1415
|
-
super(
|
|
1421
|
+
constructor(core, initiator, startX, startY, endX, endY, skipFirstExecution = false, skipHistory = false) {
|
|
1422
|
+
super(core, initiator, skipHistory);
|
|
1416
1423
|
this.startX = startX;
|
|
1417
1424
|
this.startY = startY;
|
|
1418
1425
|
this.endX = endX;
|
|
1419
1426
|
this.endY = endY;
|
|
1420
1427
|
this.skipExecution = skipFirstExecution;
|
|
1421
|
-
this.selectionGroup = this.
|
|
1428
|
+
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1422
1429
|
}
|
|
1423
1430
|
execute() {
|
|
1424
1431
|
if (this.skipExecution) {
|
|
1425
1432
|
this.skipExecution = false;
|
|
1426
1433
|
return;
|
|
1427
1434
|
}
|
|
1428
|
-
this.
|
|
1429
|
-
this.
|
|
1435
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1436
|
+
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1437
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1438
|
+
this._core.store.state.objectsMap.update(object);
|
|
1439
|
+
this._core.updateObjectInDatabase(object);
|
|
1440
|
+
});
|
|
1430
1441
|
}
|
|
1431
1442
|
undo() {
|
|
1432
|
-
this.
|
|
1433
|
-
this.
|
|
1443
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1444
|
+
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1445
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1446
|
+
this._core.store.state.objectsMap.update(object);
|
|
1447
|
+
this._core.updateObjectInDatabase(object);
|
|
1448
|
+
});
|
|
1434
1449
|
}
|
|
1435
1450
|
}
|
|
1436
1451
|
|
|
1437
1452
|
class KritzelBaseHandler {
|
|
1438
|
-
|
|
1439
|
-
constructor(
|
|
1440
|
-
this.
|
|
1453
|
+
_core;
|
|
1454
|
+
constructor(core) {
|
|
1455
|
+
this._core = core;
|
|
1441
1456
|
}
|
|
1442
1457
|
}
|
|
1443
1458
|
|
|
@@ -1448,16 +1463,26 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1448
1463
|
startY;
|
|
1449
1464
|
endX;
|
|
1450
1465
|
endY;
|
|
1451
|
-
|
|
1452
|
-
|
|
1466
|
+
hasMoved = false;
|
|
1467
|
+
constructor(core) {
|
|
1468
|
+
super(core);
|
|
1469
|
+
}
|
|
1470
|
+
reset() {
|
|
1471
|
+
this.dragStartX = 0;
|
|
1472
|
+
this.dragStartY = 0;
|
|
1473
|
+
this.startX = 0;
|
|
1474
|
+
this.startY = 0;
|
|
1475
|
+
this.endX = 0;
|
|
1476
|
+
this.endY = 0;
|
|
1477
|
+
this.hasMoved = false;
|
|
1453
1478
|
}
|
|
1454
1479
|
handlePointerDown(event) {
|
|
1455
1480
|
if (event.pointerType === 'mouse') {
|
|
1456
1481
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1457
|
-
if (this.
|
|
1458
|
-
const clientX = event.clientX - this.
|
|
1459
|
-
const clientY = event.clientY - this.
|
|
1460
|
-
this.
|
|
1482
|
+
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
1483
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1484
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1485
|
+
this._core.store.setState('isDragging', true);
|
|
1461
1486
|
this.dragStartX = clientX;
|
|
1462
1487
|
this.dragStartY = clientY;
|
|
1463
1488
|
this.startX = this.dragStartX;
|
|
@@ -1466,11 +1491,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1466
1491
|
}
|
|
1467
1492
|
}
|
|
1468
1493
|
if (event.pointerType === 'touch') {
|
|
1469
|
-
const activePointers = Array.from(this.
|
|
1470
|
-
if (this.
|
|
1471
|
-
if (this.
|
|
1472
|
-
const x = Math.round(activePointers[0].clientX - this.
|
|
1473
|
-
const y = Math.round(activePointers[0].clientY - this.
|
|
1494
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1495
|
+
if (this._core.store.state.pointers.size === 1) {
|
|
1496
|
+
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
1497
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1498
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1474
1499
|
this.dragStartX = x;
|
|
1475
1500
|
this.dragStartY = y;
|
|
1476
1501
|
this.startX = x;
|
|
@@ -1481,30 +1506,35 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1481
1506
|
}
|
|
1482
1507
|
handlePointerMove(event) {
|
|
1483
1508
|
if (event.pointerType === 'mouse') {
|
|
1484
|
-
if (this.
|
|
1485
|
-
const clientX = event.clientX - this.
|
|
1486
|
-
const clientY = event.clientY - this.
|
|
1509
|
+
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
1510
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1511
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1487
1512
|
this.endX = clientX;
|
|
1488
1513
|
this.endY = clientY;
|
|
1489
|
-
this.
|
|
1514
|
+
this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
|
|
1490
1515
|
this.dragStartX = clientX;
|
|
1491
1516
|
this.dragStartY = clientY;
|
|
1517
|
+
this.hasMoved = true;
|
|
1492
1518
|
}
|
|
1493
1519
|
}
|
|
1494
1520
|
if (event.pointerType === 'touch') {
|
|
1495
|
-
const activePointers = Array.from(this.
|
|
1496
|
-
if (this.
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
this.
|
|
1521
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1522
|
+
if (this._core.store.state.pointers.size === 1 &&
|
|
1523
|
+
this._core.store.state.selectionGroup &&
|
|
1524
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
1525
|
+
!this._core.store.state.isRotationHandleSelected) {
|
|
1526
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1527
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1528
|
+
this._core.store.setState('isDragging', true);
|
|
1500
1529
|
this.endX = x;
|
|
1501
1530
|
this.endY = y;
|
|
1531
|
+
this.hasMoved = true;
|
|
1502
1532
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
1503
1533
|
const moveDeltaY = Math.abs(y - this.startY);
|
|
1504
1534
|
const moveThreshold = 5;
|
|
1505
1535
|
if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
|
|
1506
|
-
clearTimeout(this.
|
|
1507
|
-
this.
|
|
1536
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1537
|
+
this._core.store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
|
|
1508
1538
|
this.dragStartX = x;
|
|
1509
1539
|
this.dragStartY = y;
|
|
1510
1540
|
}
|
|
@@ -1513,29 +1543,21 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1513
1543
|
}
|
|
1514
1544
|
handlePointerUp(event) {
|
|
1515
1545
|
if (event.pointerType === 'mouse') {
|
|
1516
|
-
if (this.
|
|
1517
|
-
this.
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
translateY: object.translateY
|
|
1523
|
-
});
|
|
1524
|
-
});
|
|
1525
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1546
|
+
if (this._core.store.state.isDragging) {
|
|
1547
|
+
this._core.store.setState('isDragging', false);
|
|
1548
|
+
if (this.hasMoved) {
|
|
1549
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1550
|
+
}
|
|
1551
|
+
this.reset();
|
|
1526
1552
|
}
|
|
1527
1553
|
}
|
|
1528
1554
|
if (event.pointerType === 'touch') {
|
|
1529
|
-
if (this.
|
|
1530
|
-
this.
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
translateY: object.translateY
|
|
1536
|
-
});
|
|
1537
|
-
});
|
|
1538
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1555
|
+
if (this._core.store.state.isDragging) {
|
|
1556
|
+
this._core.store.setState('isDragging', false);
|
|
1557
|
+
if (this.hasMoved) {
|
|
1558
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1559
|
+
}
|
|
1560
|
+
this.reset();
|
|
1539
1561
|
}
|
|
1540
1562
|
}
|
|
1541
1563
|
}
|
|
@@ -1553,19 +1575,27 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1553
1575
|
newSize;
|
|
1554
1576
|
previousSize;
|
|
1555
1577
|
selectionGroup;
|
|
1556
|
-
constructor(
|
|
1557
|
-
super(
|
|
1578
|
+
constructor(core, initiator, previousSize, newSize, skipHistory = false) {
|
|
1579
|
+
super(core, initiator, skipHistory);
|
|
1558
1580
|
this.previousSize = previousSize;
|
|
1559
1581
|
this.newSize = newSize;
|
|
1560
|
-
this.selectionGroup = this.
|
|
1582
|
+
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1561
1583
|
}
|
|
1562
1584
|
execute() {
|
|
1563
|
-
this.
|
|
1564
|
-
this.
|
|
1585
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1586
|
+
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1587
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1588
|
+
this._core.store.state.objectsMap.update(object);
|
|
1589
|
+
this._core.updateObjectInDatabase(object);
|
|
1590
|
+
});
|
|
1565
1591
|
}
|
|
1566
1592
|
undo() {
|
|
1567
|
-
this.
|
|
1568
|
-
this.
|
|
1593
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1594
|
+
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1595
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1596
|
+
this._core.store.state.objectsMap.update(object);
|
|
1597
|
+
this._core.updateObjectInDatabase(object);
|
|
1598
|
+
});
|
|
1569
1599
|
}
|
|
1570
1600
|
}
|
|
1571
1601
|
|
|
@@ -1574,71 +1604,77 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1574
1604
|
initialMouseY = 0;
|
|
1575
1605
|
initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1576
1606
|
newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1577
|
-
constructor(
|
|
1578
|
-
super(
|
|
1607
|
+
constructor(core) {
|
|
1608
|
+
super(core);
|
|
1609
|
+
}
|
|
1610
|
+
reset() {
|
|
1611
|
+
this.initialMouseX = 0;
|
|
1612
|
+
this.initialMouseY = 0;
|
|
1613
|
+
this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1614
|
+
this.newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1579
1615
|
}
|
|
1580
1616
|
handlePointerDown(event) {
|
|
1581
1617
|
if (event.pointerType === 'mouse') {
|
|
1582
1618
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1583
|
-
if (this.
|
|
1584
|
-
const clientX = event.clientX - this.
|
|
1585
|
-
const clientY = event.clientY - this.
|
|
1586
|
-
this.
|
|
1619
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1620
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1621
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1622
|
+
this._core.store.setState('isResizing', true);
|
|
1587
1623
|
this.initialMouseX = clientX;
|
|
1588
1624
|
this.initialMouseY = clientY;
|
|
1589
|
-
this.initialSize.width = this.
|
|
1590
|
-
this.initialSize.height = this.
|
|
1591
|
-
this.initialSize.x = this.
|
|
1592
|
-
this.initialSize.y = this.
|
|
1625
|
+
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
1626
|
+
this.initialSize.height = this._core.store.state.selectionGroup.height;
|
|
1627
|
+
this.initialSize.x = this._core.store.state.selectionGroup.translateX;
|
|
1628
|
+
this.initialSize.y = this._core.store.state.selectionGroup.translateY;
|
|
1593
1629
|
}
|
|
1594
1630
|
}
|
|
1595
1631
|
}
|
|
1596
1632
|
if (event.pointerType === 'touch') {
|
|
1597
|
-
const activePointers = Array.from(this.
|
|
1633
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1598
1634
|
const firstTouch = activePointers[0];
|
|
1599
1635
|
if (!firstTouch) {
|
|
1600
1636
|
return;
|
|
1601
1637
|
}
|
|
1602
1638
|
if (activePointers.length === 1) {
|
|
1603
|
-
if (this.
|
|
1604
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
1605
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
1606
|
-
this.
|
|
1639
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1640
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1641
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1642
|
+
this._core.store.setState('isResizing', true);
|
|
1607
1643
|
this.initialMouseX = clientX;
|
|
1608
1644
|
this.initialMouseY = clientY;
|
|
1609
|
-
this.initialSize.width = this.
|
|
1610
|
-
this.initialSize.height = this.
|
|
1611
|
-
this.initialSize.x = this.
|
|
1612
|
-
this.initialSize.y = this.
|
|
1613
|
-
clearTimeout(this.
|
|
1645
|
+
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
1646
|
+
this.initialSize.height = this._core.store.state.selectionGroup.height;
|
|
1647
|
+
this.initialSize.x = this._core.store.state.selectionGroup.translateX;
|
|
1648
|
+
this.initialSize.y = this._core.store.state.selectionGroup.translateY;
|
|
1649
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1614
1650
|
}
|
|
1615
1651
|
}
|
|
1616
1652
|
}
|
|
1617
1653
|
}
|
|
1618
1654
|
handlePointerMove(event) {
|
|
1619
1655
|
if (event.pointerType === 'mouse') {
|
|
1620
|
-
if (this.
|
|
1621
|
-
const clientX = event.clientX - this.
|
|
1622
|
-
const clientY = event.clientY - this.
|
|
1656
|
+
if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
|
|
1657
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1658
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1623
1659
|
const dx = clientX - this.initialMouseX;
|
|
1624
1660
|
const dy = clientY - this.initialMouseY;
|
|
1625
|
-
switch (this.
|
|
1661
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
1626
1662
|
case KritzelHandleType.TopLeft:
|
|
1627
1663
|
this.newSize.width = this.initialSize.width - dx;
|
|
1628
1664
|
this.newSize.height = this.initialSize.height - dy;
|
|
1629
|
-
this.newSize.x = dx / this.
|
|
1630
|
-
this.newSize.y = dy / this.
|
|
1665
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
1666
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
1631
1667
|
break;
|
|
1632
1668
|
case KritzelHandleType.TopRight:
|
|
1633
1669
|
this.newSize.width = this.initialSize.width + dx;
|
|
1634
1670
|
this.newSize.height = this.initialSize.height - dy;
|
|
1635
1671
|
this.newSize.x = this.initialSize.x;
|
|
1636
|
-
this.newSize.y = dy / this.
|
|
1672
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
1637
1673
|
break;
|
|
1638
1674
|
case KritzelHandleType.BottomLeft:
|
|
1639
1675
|
this.newSize.width = this.initialSize.width - dx;
|
|
1640
1676
|
this.newSize.height = this.initialSize.height + dy;
|
|
1641
|
-
this.newSize.x = dx / this.
|
|
1677
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
1642
1678
|
this.newSize.y = this.initialSize.y;
|
|
1643
1679
|
break;
|
|
1644
1680
|
case KritzelHandleType.BottomRight:
|
|
@@ -1648,38 +1684,37 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1648
1684
|
this.newSize.y = this.initialSize.y;
|
|
1649
1685
|
break;
|
|
1650
1686
|
}
|
|
1651
|
-
this.
|
|
1652
|
-
this._store.rerender();
|
|
1687
|
+
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1653
1688
|
}
|
|
1654
1689
|
}
|
|
1655
1690
|
if (event.pointerType === 'touch') {
|
|
1656
|
-
const activePointers = Array.from(this.
|
|
1691
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1657
1692
|
const oneFingerTouch = activePointers[0];
|
|
1658
1693
|
if (!oneFingerTouch) {
|
|
1659
1694
|
return;
|
|
1660
1695
|
}
|
|
1661
|
-
if (this.
|
|
1662
|
-
const clientX = Math.round(oneFingerTouch.clientX - this.
|
|
1663
|
-
const clientY = Math.round(oneFingerTouch.clientY - this.
|
|
1696
|
+
if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
|
|
1697
|
+
const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);
|
|
1698
|
+
const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);
|
|
1664
1699
|
const dx = clientX - this.initialMouseX;
|
|
1665
1700
|
const dy = clientY - this.initialMouseY;
|
|
1666
|
-
switch (this.
|
|
1701
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
1667
1702
|
case KritzelHandleType.TopLeft:
|
|
1668
1703
|
this.newSize.width = this.initialSize.width - dx;
|
|
1669
1704
|
this.newSize.height = this.initialSize.height - dy;
|
|
1670
|
-
this.newSize.x = dx / this.
|
|
1671
|
-
this.newSize.y = dy / this.
|
|
1705
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
1706
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
1672
1707
|
break;
|
|
1673
1708
|
case KritzelHandleType.TopRight:
|
|
1674
1709
|
this.newSize.width = this.initialSize.width + dx;
|
|
1675
1710
|
this.newSize.height = this.initialSize.height - dy;
|
|
1676
1711
|
this.newSize.x = this.initialSize.x;
|
|
1677
|
-
this.newSize.y = dy / this.
|
|
1712
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
1678
1713
|
break;
|
|
1679
1714
|
case KritzelHandleType.BottomLeft:
|
|
1680
1715
|
this.newSize.width = this.initialSize.width - dx;
|
|
1681
1716
|
this.newSize.height = this.initialSize.height + dy;
|
|
1682
|
-
this.newSize.x = dx / this.
|
|
1717
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
1683
1718
|
this.newSize.y = this.initialSize.y;
|
|
1684
1719
|
break;
|
|
1685
1720
|
case KritzelHandleType.BottomRight:
|
|
@@ -1689,33 +1724,25 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1689
1724
|
this.newSize.y = this.initialSize.y;
|
|
1690
1725
|
break;
|
|
1691
1726
|
}
|
|
1692
|
-
this.
|
|
1693
|
-
clearTimeout(this.
|
|
1727
|
+
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1728
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1694
1729
|
}
|
|
1695
1730
|
}
|
|
1696
1731
|
}
|
|
1697
1732
|
handlePointerUp(event) {
|
|
1698
1733
|
if (event.pointerType === 'mouse') {
|
|
1699
|
-
if (this.
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
});
|
|
1704
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1705
|
-
this._store.state.isResizing = false;
|
|
1706
|
-
this._store.rerender();
|
|
1734
|
+
if (this._core.store.state.isResizing) {
|
|
1735
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1736
|
+
this._core.store.setState('isResizing', false);
|
|
1737
|
+
this.reset();
|
|
1707
1738
|
}
|
|
1708
1739
|
}
|
|
1709
1740
|
if (event.pointerType === 'touch') {
|
|
1710
|
-
if (this.
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1716
|
-
this._store.state.isResizing = false;
|
|
1717
|
-
this._store.rerender();
|
|
1718
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1741
|
+
if (this._core.store.state.isResizing) {
|
|
1742
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1743
|
+
this._core.store.setState('isResizing', false);
|
|
1744
|
+
this.reset();
|
|
1745
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1719
1746
|
}
|
|
1720
1747
|
}
|
|
1721
1748
|
}
|
|
@@ -1725,24 +1752,26 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1725
1752
|
rotation;
|
|
1726
1753
|
initialRotation;
|
|
1727
1754
|
selectionGroup;
|
|
1728
|
-
constructor(
|
|
1729
|
-
super(
|
|
1755
|
+
constructor(core, initiator, rotation, initialRotation, skipHistory = false) {
|
|
1756
|
+
super(core, initiator, skipHistory);
|
|
1730
1757
|
this.rotation = rotation;
|
|
1731
|
-
this.initialRotation =
|
|
1732
|
-
this.selectionGroup = this.
|
|
1758
|
+
this.initialRotation = initialRotation;
|
|
1759
|
+
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1733
1760
|
}
|
|
1734
1761
|
execute() {
|
|
1735
|
-
this.
|
|
1736
|
-
this.
|
|
1737
|
-
this.
|
|
1738
|
-
this.
|
|
1762
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1763
|
+
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1764
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1765
|
+
this._core.store.state.objectsMap.update(object);
|
|
1766
|
+
this._core.updateObjectInDatabase(object);
|
|
1739
1767
|
});
|
|
1740
1768
|
}
|
|
1741
1769
|
undo() {
|
|
1742
|
-
this.
|
|
1743
|
-
this.
|
|
1744
|
-
this.
|
|
1745
|
-
this.
|
|
1770
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1771
|
+
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1772
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1773
|
+
this._core.store.state.objectsMap.update(object);
|
|
1774
|
+
this._core.updateObjectInDatabase(object);
|
|
1746
1775
|
});
|
|
1747
1776
|
}
|
|
1748
1777
|
}
|
|
@@ -1750,111 +1779,103 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1750
1779
|
class KritzelRotationHandler extends KritzelBaseHandler {
|
|
1751
1780
|
initialRotation = 0;
|
|
1752
1781
|
rotation = 0;
|
|
1753
|
-
|
|
1754
|
-
|
|
1782
|
+
unchangedObjects = [];
|
|
1783
|
+
initialSelectionGroupRotation = 0;
|
|
1784
|
+
constructor(core) {
|
|
1785
|
+
super(core);
|
|
1786
|
+
}
|
|
1787
|
+
reset() {
|
|
1788
|
+
this.initialRotation = 0;
|
|
1789
|
+
this.rotation = 0;
|
|
1790
|
+
this.unchangedObjects = [];
|
|
1755
1791
|
}
|
|
1756
1792
|
handlePointerDown(event) {
|
|
1757
1793
|
if (event.pointerType === 'mouse') {
|
|
1758
1794
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1759
|
-
if (this.
|
|
1760
|
-
const clientX = event.clientX - this.
|
|
1761
|
-
const clientY = event.clientY - this.
|
|
1762
|
-
this.
|
|
1763
|
-
const centerX = this.
|
|
1764
|
-
const centerY = this.
|
|
1765
|
-
const cursorX = (clientX - this.
|
|
1766
|
-
const cursorY = (clientY - this.
|
|
1767
|
-
this.
|
|
1795
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1796
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1797
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1798
|
+
this._core.store.setState('isRotating', true);
|
|
1799
|
+
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1800
|
+
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1801
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1802
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1803
|
+
this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;
|
|
1804
|
+
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1805
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1768
1806
|
}
|
|
1769
1807
|
}
|
|
1770
1808
|
}
|
|
1771
1809
|
if (event.pointerType === 'touch') {
|
|
1772
|
-
const activePointers = Array.from(this.
|
|
1810
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1773
1811
|
const firstTouch = activePointers[0];
|
|
1774
1812
|
if (!firstTouch) {
|
|
1775
1813
|
return;
|
|
1776
1814
|
}
|
|
1777
1815
|
if (activePointers.length === 1) {
|
|
1778
|
-
if (this.
|
|
1779
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
1780
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
1781
|
-
this.
|
|
1782
|
-
const centerX = this.
|
|
1783
|
-
const centerY = this.
|
|
1784
|
-
const cursorX = (clientX - this.
|
|
1785
|
-
const cursorY = (clientY - this.
|
|
1786
|
-
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this.
|
|
1787
|
-
|
|
1816
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1817
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1818
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1819
|
+
this._core.store.setState('isRotating', true);
|
|
1820
|
+
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1821
|
+
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1822
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1823
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1824
|
+
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1825
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1826
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1788
1827
|
}
|
|
1789
1828
|
}
|
|
1790
1829
|
}
|
|
1791
1830
|
}
|
|
1792
1831
|
handlePointerMove(event) {
|
|
1793
1832
|
if (event.pointerType === 'mouse') {
|
|
1794
|
-
if (this.
|
|
1795
|
-
const clientX = event.clientX - this.
|
|
1796
|
-
const clientY = event.clientY - this.
|
|
1797
|
-
const groupCenterX = this.
|
|
1798
|
-
const groupCenterY = this.
|
|
1799
|
-
const cursorX = (clientX - this.
|
|
1800
|
-
const cursorY = (clientY - this.
|
|
1833
|
+
if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
|
|
1834
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
1835
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
1836
|
+
const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1837
|
+
const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1838
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1839
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1801
1840
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
1802
1841
|
this.rotation = currentRotation - this.initialRotation;
|
|
1803
|
-
this.
|
|
1804
|
-
this._store.rerender();
|
|
1842
|
+
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1805
1843
|
}
|
|
1806
1844
|
}
|
|
1807
1845
|
if (event.pointerType === 'touch') {
|
|
1808
|
-
const activePointers = Array.from(this.
|
|
1846
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1809
1847
|
const firstTouch = activePointers[0];
|
|
1810
1848
|
if (!firstTouch) {
|
|
1811
1849
|
return;
|
|
1812
1850
|
}
|
|
1813
|
-
if (this.
|
|
1814
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
1815
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
1816
|
-
const groupCenterX = this.
|
|
1817
|
-
const groupCenterY = this.
|
|
1818
|
-
const cursorX = (clientX - this.
|
|
1819
|
-
const cursorY = (clientY - this.
|
|
1851
|
+
if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
|
|
1852
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1853
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1854
|
+
const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1855
|
+
const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1856
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1857
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1820
1858
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
1821
1859
|
this.rotation = currentRotation - this.initialRotation;
|
|
1822
|
-
this.
|
|
1823
|
-
this.
|
|
1824
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1860
|
+
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1861
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1825
1862
|
}
|
|
1826
1863
|
}
|
|
1827
1864
|
}
|
|
1828
1865
|
handlePointerUp(event) {
|
|
1829
1866
|
if (event.pointerType === 'mouse') {
|
|
1830
|
-
if (this.
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
rotation: object.rotation,
|
|
1835
|
-
translateX: object.translateX,
|
|
1836
|
-
translateY: object.translateY,
|
|
1837
|
-
});
|
|
1838
|
-
});
|
|
1839
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1840
|
-
this._store.state.isRotating = false;
|
|
1841
|
-
this.initialRotation = 0;
|
|
1842
|
-
this.rotation = 0;
|
|
1867
|
+
if (this._core.store.state.isRotating) {
|
|
1868
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1869
|
+
this._core.store.setState('isRotating', false);
|
|
1870
|
+
this.reset();
|
|
1843
1871
|
}
|
|
1844
1872
|
}
|
|
1845
1873
|
if (event.pointerType === 'touch') {
|
|
1846
|
-
if (this.
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
});
|
|
1852
|
-
});
|
|
1853
|
-
this._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1854
|
-
this._store.state.isRotating = false;
|
|
1855
|
-
this.initialRotation = 0;
|
|
1856
|
-
this.rotation = 0;
|
|
1857
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
1874
|
+
if (this._core.store.state.isRotating) {
|
|
1875
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1876
|
+
this._core.store.setState('isRotating', false);
|
|
1877
|
+
this.reset();
|
|
1878
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1858
1879
|
}
|
|
1859
1880
|
}
|
|
1860
1881
|
}
|
|
@@ -1863,12 +1884,12 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1863
1884
|
class KrtizelSelectionBox extends KritzelBaseObject {
|
|
1864
1885
|
__class__ = 'KrtizelSelectionBox';
|
|
1865
1886
|
objects = [];
|
|
1866
|
-
static create(
|
|
1887
|
+
static create(core) {
|
|
1867
1888
|
const object = new KrtizelSelectionBox();
|
|
1868
|
-
object.
|
|
1889
|
+
object._core = core;
|
|
1869
1890
|
object.id = object.generateId();
|
|
1870
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
1871
|
-
object.scale = store.state.scale;
|
|
1891
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
1892
|
+
object.scale = core.store.state.scale;
|
|
1872
1893
|
object.zIndex = 99999;
|
|
1873
1894
|
object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(0, 122, 255, 0.2))';
|
|
1874
1895
|
object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(0, 122, 255, 0.5))';
|
|
@@ -1881,20 +1902,20 @@ class KrtizelSelectionBox extends KritzelBaseObject {
|
|
|
1881
1902
|
|
|
1882
1903
|
class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
1883
1904
|
selectionGroup;
|
|
1884
|
-
constructor(
|
|
1885
|
-
super(
|
|
1905
|
+
constructor(core, initiator, selectionGroup, skipHistory = false) {
|
|
1906
|
+
super(core, initiator, skipHistory);
|
|
1886
1907
|
this.selectionGroup = selectionGroup;
|
|
1887
1908
|
}
|
|
1888
1909
|
execute() {
|
|
1889
|
-
this.
|
|
1890
|
-
this.
|
|
1891
|
-
this.
|
|
1892
|
-
this.
|
|
1910
|
+
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
|
|
1911
|
+
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
1912
|
+
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1913
|
+
this._core.store.setState('selectionBox', null);
|
|
1893
1914
|
}
|
|
1894
1915
|
undo() {
|
|
1895
|
-
this.
|
|
1896
|
-
this.
|
|
1897
|
-
this.
|
|
1916
|
+
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
1917
|
+
this._core.store.setState('selectionGroup', null);
|
|
1918
|
+
this._core.store.setState('selectionBox', null);
|
|
1898
1919
|
}
|
|
1899
1920
|
}
|
|
1900
1921
|
|
|
@@ -1905,23 +1926,23 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1905
1926
|
touchStartY = 0;
|
|
1906
1927
|
touchStartTimeout = null;
|
|
1907
1928
|
get isSelectionClick() {
|
|
1908
|
-
return this.
|
|
1929
|
+
return this._core.store.state.selectionBox && this._core.store.state.selectionBox.width === 0 && this._core.store.state.selectionBox.height === 0;
|
|
1909
1930
|
}
|
|
1910
1931
|
get isSelectionDrag() {
|
|
1911
|
-
return this.
|
|
1932
|
+
return this._core.store.state.selectionBox && (this._core.store.state.selectionBox.width > 0 || this._core.store.state.selectionBox.height > 0);
|
|
1912
1933
|
}
|
|
1913
|
-
constructor(
|
|
1914
|
-
super(
|
|
1934
|
+
constructor(core) {
|
|
1935
|
+
super(core);
|
|
1915
1936
|
}
|
|
1916
1937
|
handlePointerDown(event) {
|
|
1917
1938
|
if (event.pointerType === 'mouse') {
|
|
1918
|
-
if (KritzelEventHelper.isLeftClick(event) && !this.
|
|
1939
|
+
if (KritzelEventHelper.isLeftClick(event) && !this._core.store.state.selectionGroup) {
|
|
1919
1940
|
this.startMouseSelection(event);
|
|
1920
1941
|
}
|
|
1921
1942
|
}
|
|
1922
1943
|
if (event.pointerType === 'touch') {
|
|
1923
1944
|
this.touchStartTimeout = setTimeout(() => {
|
|
1924
|
-
if (this.
|
|
1945
|
+
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling && !this._core.store.state.selectionGroup) {
|
|
1925
1946
|
this.startTouchSelection();
|
|
1926
1947
|
this.updateTouchSelection();
|
|
1927
1948
|
}
|
|
@@ -1930,30 +1951,30 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1930
1951
|
}
|
|
1931
1952
|
handlePointerMove(event) {
|
|
1932
1953
|
if (event.pointerType === 'mouse') {
|
|
1933
|
-
if (this.
|
|
1954
|
+
if (this._core.store.state.isSelecting) {
|
|
1934
1955
|
this.updateMouseSelection(event);
|
|
1935
1956
|
}
|
|
1936
1957
|
}
|
|
1937
1958
|
if (event.pointerType === 'touch') {
|
|
1938
|
-
const activePointers = Array.from(this.
|
|
1939
|
-
const x = Math.round(activePointers[0].clientX - this.
|
|
1940
|
-
const y = Math.round(activePointers[0].clientY - this.
|
|
1959
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1960
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1961
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1941
1962
|
const moveDeltaX = Math.abs(x - this.touchStartX);
|
|
1942
1963
|
const moveDeltaY = Math.abs(y - this.touchStartY);
|
|
1943
1964
|
const moveThreshold = 5;
|
|
1944
|
-
if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this.
|
|
1965
|
+
if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._core.store.state.isSelecting) {
|
|
1945
1966
|
this.updateTouchSelection();
|
|
1946
|
-
clearTimeout(this.
|
|
1967
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1947
1968
|
}
|
|
1948
1969
|
}
|
|
1949
1970
|
}
|
|
1950
1971
|
handlePointerUp(event) {
|
|
1951
1972
|
if (event.pointerType === 'mouse') {
|
|
1952
|
-
if (KritzelEventHelper.isLeftClick(event) && this.
|
|
1973
|
+
if (KritzelEventHelper.isLeftClick(event) && this._core.store.state.isSelecting) {
|
|
1953
1974
|
if (this.isSelectionClick) {
|
|
1954
|
-
const x = this.
|
|
1955
|
-
const y = this.
|
|
1956
|
-
const selectedObject = this.
|
|
1975
|
+
const x = this._core.store.state.pointerX;
|
|
1976
|
+
const y = this._core.store.state.pointerY;
|
|
1977
|
+
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
1957
1978
|
this.addObjectToSelectionGroup(selectedObject);
|
|
1958
1979
|
this.removeSelectionBox();
|
|
1959
1980
|
}
|
|
@@ -1966,11 +1987,11 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1966
1987
|
}
|
|
1967
1988
|
if (event.pointerType === 'touch') {
|
|
1968
1989
|
clearTimeout(this.touchStartTimeout);
|
|
1969
|
-
if (this.
|
|
1990
|
+
if (this._core.store.state.isSelecting) {
|
|
1970
1991
|
if (this.isSelectionClick) {
|
|
1971
|
-
const x = this.
|
|
1972
|
-
const y = this.
|
|
1973
|
-
const selectedObject = this.
|
|
1992
|
+
const x = this._core.store.state.pointerX;
|
|
1993
|
+
const y = this._core.store.state.pointerY;
|
|
1994
|
+
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
1974
1995
|
this.addObjectToSelectionGroup(selectedObject);
|
|
1975
1996
|
this.removeSelectionBox();
|
|
1976
1997
|
}
|
|
@@ -1979,82 +2000,80 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1979
2000
|
this.addSelectedObjectsToSelectionGroup();
|
|
1980
2001
|
this.removeSelectionBox();
|
|
1981
2002
|
}
|
|
1982
|
-
this.
|
|
2003
|
+
this._core.store.setState('skipContextMenu', false);
|
|
1983
2004
|
}
|
|
1984
2005
|
}
|
|
1985
2006
|
}
|
|
1986
2007
|
removeSelectionBox() {
|
|
1987
|
-
this.
|
|
1988
|
-
this.
|
|
1989
|
-
this.
|
|
1990
|
-
this._store.rerender();
|
|
2008
|
+
this._core.store.setState('selectionBox', null);
|
|
2009
|
+
this._core.store.setState('isSelecting', false);
|
|
2010
|
+
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
|
|
1991
2011
|
}
|
|
1992
2012
|
startMouseSelection(event) {
|
|
1993
2013
|
let clientX, clientY;
|
|
1994
|
-
clientX = event.clientX - this.
|
|
1995
|
-
clientY = event.clientY - this.
|
|
1996
|
-
const selectionBox = KrtizelSelectionBox.create(this.
|
|
1997
|
-
this.startX = (clientX - this.
|
|
1998
|
-
this.startY = (clientY - this.
|
|
2014
|
+
clientX = event.clientX - this._core.store.offsetX;
|
|
2015
|
+
clientY = event.clientY - this._core.store.offsetY;
|
|
2016
|
+
const selectionBox = KrtizelSelectionBox.create(this._core);
|
|
2017
|
+
this.startX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
2018
|
+
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1999
2019
|
selectionBox.translateX = this.startX;
|
|
2000
2020
|
selectionBox.translateY = this.startY;
|
|
2001
|
-
this.
|
|
2002
|
-
this.
|
|
2003
|
-
this.
|
|
2004
|
-
this.
|
|
2005
|
-
this.
|
|
2021
|
+
this._core.store.setState('selectionGroup', null);
|
|
2022
|
+
this._core.store.setState('selectionBox', selectionBox);
|
|
2023
|
+
this._core.store.setState('isSelecting', true);
|
|
2024
|
+
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2025
|
+
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2006
2026
|
}
|
|
2007
2027
|
startTouchSelection() {
|
|
2008
|
-
const activePointers = Array.from(this.
|
|
2028
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
2009
2029
|
const firstTouch = activePointers[0];
|
|
2010
2030
|
if (!firstTouch) {
|
|
2011
2031
|
return;
|
|
2012
2032
|
}
|
|
2013
2033
|
let clientX, clientY;
|
|
2014
|
-
clientX = Math.round(firstTouch.clientX - this.
|
|
2015
|
-
clientY = Math.round(firstTouch.clientY - this.
|
|
2034
|
+
clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
2035
|
+
clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
2016
2036
|
this.touchStartX = clientX;
|
|
2017
2037
|
this.touchStartY = clientY;
|
|
2018
|
-
const selectionBox = KrtizelSelectionBox.create(this.
|
|
2019
|
-
this.startX = (clientX - this.
|
|
2020
|
-
this.startY = (clientY - this.
|
|
2038
|
+
const selectionBox = KrtizelSelectionBox.create(this._core);
|
|
2039
|
+
this.startX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
2040
|
+
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2021
2041
|
selectionBox.translateX = this.startX;
|
|
2022
2042
|
selectionBox.translateY = this.startY;
|
|
2023
|
-
this.
|
|
2024
|
-
this.
|
|
2025
|
-
this.
|
|
2026
|
-
this.
|
|
2027
|
-
this.
|
|
2043
|
+
this._core.store.setState('selectionGroup', null);
|
|
2044
|
+
this._core.store.setState('selectionBox', selectionBox);
|
|
2045
|
+
this._core.store.setState('isSelecting', true);
|
|
2046
|
+
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2047
|
+
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2028
2048
|
}
|
|
2029
2049
|
updateMouseSelection(event) {
|
|
2030
2050
|
let clientX, clientY;
|
|
2031
|
-
clientX = event.clientX - this.
|
|
2032
|
-
clientY = event.clientY - this.
|
|
2033
|
-
const selectionBox = this.
|
|
2051
|
+
clientX = event.clientX - this._core.store.offsetX;
|
|
2052
|
+
clientY = event.clientY - this._core.store.offsetY;
|
|
2053
|
+
const selectionBox = this._core.store.state.selectionBox;
|
|
2034
2054
|
if (selectionBox) {
|
|
2035
|
-
const currentX = (clientX - this.
|
|
2036
|
-
const currentY = (clientY - this.
|
|
2055
|
+
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2056
|
+
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2037
2057
|
selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2038
2058
|
selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2039
2059
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2040
2060
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2041
2061
|
this.updateSelectedObjects();
|
|
2042
|
-
this._store.rerender();
|
|
2043
2062
|
}
|
|
2044
2063
|
}
|
|
2045
2064
|
updateTouchSelection() {
|
|
2046
|
-
const activePointers = Array.from(this.
|
|
2065
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
2047
2066
|
const firstTouch = activePointers[0];
|
|
2048
2067
|
if (!firstTouch) {
|
|
2049
2068
|
return;
|
|
2050
2069
|
}
|
|
2051
2070
|
let clientX, clientY;
|
|
2052
|
-
clientX = Math.round(firstTouch.clientX - this.
|
|
2053
|
-
clientY = Math.round(firstTouch.clientY - this.
|
|
2054
|
-
const selectionBox = this.
|
|
2071
|
+
clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
2072
|
+
clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
2073
|
+
const selectionBox = this._core.store.state.selectionBox;
|
|
2055
2074
|
if (selectionBox) {
|
|
2056
|
-
const currentX = (clientX - this.
|
|
2057
|
-
const currentY = (clientY - this.
|
|
2075
|
+
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2076
|
+
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2058
2077
|
selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2059
2078
|
selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2060
2079
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
@@ -2063,49 +2082,52 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2063
2082
|
}
|
|
2064
2083
|
}
|
|
2065
2084
|
updateSelectedObjects() {
|
|
2066
|
-
this.
|
|
2085
|
+
this._core.store.allObjects
|
|
2067
2086
|
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
2068
|
-
.forEach(object => (object.isSelected = object.hitTestPolygon(this.
|
|
2087
|
+
.forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
|
|
2069
2088
|
}
|
|
2070
2089
|
addObjectToSelectionGroup(object) {
|
|
2071
2090
|
if (!object) {
|
|
2072
2091
|
return;
|
|
2073
2092
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
this.
|
|
2093
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2094
|
+
selectionGroup.addOrRemove(object);
|
|
2095
|
+
selectionGroup.isSelected = true;
|
|
2096
|
+
selectionGroup.rotation = object.rotation;
|
|
2097
|
+
this._core.store.setState('selectionGroup', selectionGroup);
|
|
2098
|
+
this._core.history.executeCommand(new AddSelectionGroupCommand(this._core, this, this._core.store.state.selectionGroup));
|
|
2079
2099
|
}
|
|
2080
2100
|
addSelectedObjectsToSelectionGroup() {
|
|
2081
|
-
const selectedObjects = this.
|
|
2101
|
+
const selectedObjects = this._core.store.selectedObjects;
|
|
2082
2102
|
if (selectedObjects.length === 0) {
|
|
2083
2103
|
return;
|
|
2084
2104
|
}
|
|
2085
|
-
this.
|
|
2105
|
+
this._core.store.setState('selectionGroup', KritzelSelectionGroup.create(this._core));
|
|
2086
2106
|
selectedObjects.forEach(o => {
|
|
2087
2107
|
o.isSelected = false;
|
|
2088
|
-
this.
|
|
2108
|
+
this._core.store.state.selectionGroup.addOrRemove(o);
|
|
2089
2109
|
});
|
|
2090
|
-
this.
|
|
2091
|
-
|
|
2092
|
-
|
|
2110
|
+
const selectionGroup = this._core.store.state.selectionGroup;
|
|
2111
|
+
selectionGroup.isSelected = true;
|
|
2112
|
+
if (selectionGroup.length === 1) {
|
|
2113
|
+
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2093
2114
|
}
|
|
2094
|
-
this.
|
|
2115
|
+
this._core.store.setState('selectionGroup', selectionGroup);
|
|
2116
|
+
this._core.history.executeCommand(new AddSelectionGroupCommand(this._core, this, this._core.store.state.selectionGroup));
|
|
2095
2117
|
}
|
|
2096
2118
|
}
|
|
2097
2119
|
|
|
2098
2120
|
class KritzelHoverHandler extends KritzelBaseHandler {
|
|
2099
|
-
constructor(
|
|
2100
|
-
super(
|
|
2121
|
+
constructor(core) {
|
|
2122
|
+
super(core);
|
|
2101
2123
|
}
|
|
2102
2124
|
handlePointerMove(event) {
|
|
2103
2125
|
if (event.pointerType === 'mouse') {
|
|
2104
|
-
const hoveredObject = this.
|
|
2126
|
+
const hoveredObject = this._core.getObjectFromPointerEvent(event, '.object');
|
|
2105
2127
|
if (!hoveredObject)
|
|
2106
2128
|
return;
|
|
2107
|
-
const x = this.
|
|
2108
|
-
const y = this.
|
|
2129
|
+
const x = this._core.store.state.pointerX;
|
|
2130
|
+
const y = this._core.store.state.pointerY;
|
|
2109
2131
|
hoveredObject.isHovered = hoveredObject.hitTest(x, y);
|
|
2110
2132
|
}
|
|
2111
2133
|
}
|
|
@@ -2117,13 +2139,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2117
2139
|
hoverHandler;
|
|
2118
2140
|
resizeHandler;
|
|
2119
2141
|
rotationHandler;
|
|
2120
|
-
constructor(
|
|
2121
|
-
super(
|
|
2122
|
-
this.selectionHandler = new KritzelSelectionHandler(this.
|
|
2123
|
-
this.moveHandler = new KritzelMoveHandler(this.
|
|
2124
|
-
this.hoverHandler = new KritzelHoverHandler(this.
|
|
2125
|
-
this.resizeHandler = new KritzelResizeHandler(this.
|
|
2126
|
-
this.rotationHandler = new KritzelRotationHandler(this.
|
|
2142
|
+
constructor(core) {
|
|
2143
|
+
super(core);
|
|
2144
|
+
this.selectionHandler = new KritzelSelectionHandler(this._core);
|
|
2145
|
+
this.moveHandler = new KritzelMoveHandler(this._core);
|
|
2146
|
+
this.hoverHandler = new KritzelHoverHandler(this._core);
|
|
2147
|
+
this.resizeHandler = new KritzelResizeHandler(this._core);
|
|
2148
|
+
this.rotationHandler = new KritzelRotationHandler(this._core);
|
|
2127
2149
|
}
|
|
2128
2150
|
handlePointerDown(event) {
|
|
2129
2151
|
if (event.cancelable) {
|
|
@@ -2131,16 +2153,16 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2131
2153
|
}
|
|
2132
2154
|
if (event.pointerType === 'mouse') {
|
|
2133
2155
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
2134
|
-
this.
|
|
2135
|
-
this.
|
|
2136
|
-
this.
|
|
2156
|
+
this._core.store.setState('isResizeHandleSelected', this.isHandleSelected(event));
|
|
2157
|
+
this._core.store.setState('isRotationHandleSelected', this.isRotationHandleSelected(event));
|
|
2158
|
+
this._core.store.setState('resizeHandleType', this.getHandleType(event));
|
|
2137
2159
|
const selectedObject = this.getSelectedObject(event);
|
|
2138
|
-
const isDifferentObject = selectedObject && this.
|
|
2160
|
+
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2139
2161
|
if ((selectedObject === null || isDifferentObject) &&
|
|
2140
|
-
this.
|
|
2141
|
-
!this.
|
|
2142
|
-
!this.
|
|
2143
|
-
this.
|
|
2162
|
+
this._core.store.state.selectionGroup &&
|
|
2163
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
2164
|
+
!this._core.store.state.isRotationHandleSelected) {
|
|
2165
|
+
this._core.history.executeCommand(new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup));
|
|
2144
2166
|
}
|
|
2145
2167
|
if (selectedObject && selectedObject.isSelected === false && selectedObject?.objects.length === 1 && selectedObject.objects[0].isInteractive) {
|
|
2146
2168
|
return;
|
|
@@ -2150,32 +2172,33 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2150
2172
|
this.selectionHandler.handlePointerDown(event);
|
|
2151
2173
|
this.resizeHandler.handlePointerDown(event);
|
|
2152
2174
|
this.rotationHandler.handlePointerDown(event);
|
|
2153
|
-
this.
|
|
2175
|
+
this._core.rerender();
|
|
2154
2176
|
}
|
|
2155
2177
|
if (event.pointerType === 'touch') {
|
|
2156
|
-
if (this.
|
|
2178
|
+
if (this._core.store.state.isScaling === true) {
|
|
2157
2179
|
return;
|
|
2158
2180
|
}
|
|
2159
|
-
if (this.
|
|
2160
|
-
this.
|
|
2161
|
-
this.
|
|
2162
|
-
this.
|
|
2181
|
+
if (this._core.store.state.pointers.size === 1) {
|
|
2182
|
+
this._core.store.setState('isResizeHandleSelected', this.isHandleSelected(event));
|
|
2183
|
+
this._core.store.setState('isRotationHandleSelected', this.isRotationHandleSelected(event));
|
|
2184
|
+
this._core.store.setState('resizeHandleType', this.getHandleType(event));
|
|
2163
2185
|
const selectedObject = this.getSelectedObject(event);
|
|
2164
|
-
const isDifferentObject = selectedObject && this.
|
|
2165
|
-
if (!this.
|
|
2166
|
-
this.
|
|
2186
|
+
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2187
|
+
if (!this._core.store.state.selectionGroup && selectedObject) {
|
|
2188
|
+
this._core.store.setState('skipContextMenu', true);
|
|
2167
2189
|
}
|
|
2168
2190
|
if ((selectedObject === null || isDifferentObject) &&
|
|
2169
|
-
this.
|
|
2170
|
-
!this.
|
|
2171
|
-
!this.
|
|
2172
|
-
this.
|
|
2191
|
+
this._core.store.state.selectionGroup &&
|
|
2192
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
2193
|
+
!this._core.store.state.isRotationHandleSelected) {
|
|
2194
|
+
this._core.history.executeCommand(new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup));
|
|
2173
2195
|
}
|
|
2174
2196
|
}
|
|
2175
2197
|
this.rotationHandler.handlePointerDown(event);
|
|
2176
2198
|
this.resizeHandler.handlePointerDown(event);
|
|
2177
2199
|
this.moveHandler.handlePointerDown(event);
|
|
2178
2200
|
this.selectionHandler.handlePointerDown(event);
|
|
2201
|
+
this._core.rerender();
|
|
2179
2202
|
}
|
|
2180
2203
|
}
|
|
2181
2204
|
handlePointerMove(event) {
|
|
@@ -2188,17 +2211,17 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2188
2211
|
this.selectionHandler.handlePointerMove(event);
|
|
2189
2212
|
this.resizeHandler.handlePointerMove(event);
|
|
2190
2213
|
this.rotationHandler.handlePointerMove(event);
|
|
2191
|
-
this.
|
|
2214
|
+
this._core.rerender();
|
|
2192
2215
|
}
|
|
2193
2216
|
if (event.pointerType === 'touch') {
|
|
2194
|
-
if (this.
|
|
2217
|
+
if (this._core.store.state.isScaling === true) {
|
|
2195
2218
|
return;
|
|
2196
2219
|
}
|
|
2197
2220
|
this.rotationHandler.handlePointerMove(event);
|
|
2198
2221
|
this.resizeHandler.handlePointerMove(event);
|
|
2199
2222
|
this.moveHandler.handlePointerMove(event);
|
|
2200
2223
|
this.selectionHandler.handlePointerMove(event);
|
|
2201
|
-
this.
|
|
2224
|
+
this._core.rerender();
|
|
2202
2225
|
}
|
|
2203
2226
|
}
|
|
2204
2227
|
handlePointerUp(event) {
|
|
@@ -2210,22 +2233,23 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2210
2233
|
this.selectionHandler.handlePointerUp(event);
|
|
2211
2234
|
this.resizeHandler.handlePointerUp(event);
|
|
2212
2235
|
this.rotationHandler.handlePointerUp(event);
|
|
2213
|
-
this.
|
|
2236
|
+
this._core.rerender();
|
|
2214
2237
|
}
|
|
2215
2238
|
if (event.pointerType === 'touch') {
|
|
2216
|
-
if (this.
|
|
2239
|
+
if (this._core.store.state.isScaling === true) {
|
|
2217
2240
|
return;
|
|
2218
2241
|
}
|
|
2219
2242
|
this.rotationHandler.handlePointerUp(event);
|
|
2220
2243
|
this.resizeHandler.handlePointerUp(event);
|
|
2221
2244
|
this.moveHandler.handlePointerUp(event);
|
|
2222
2245
|
this.selectionHandler.handlePointerUp(event);
|
|
2246
|
+
this._core.rerender();
|
|
2223
2247
|
}
|
|
2224
2248
|
}
|
|
2225
2249
|
getSelectedObject(event) {
|
|
2226
2250
|
const path = event.composedPath().slice(1);
|
|
2227
2251
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
2228
|
-
const object = this.
|
|
2252
|
+
const object = this._core.findObjectById(objectElement?.id);
|
|
2229
2253
|
if (!object) {
|
|
2230
2254
|
return null;
|
|
2231
2255
|
}
|
|
@@ -2233,7 +2257,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2233
2257
|
return object;
|
|
2234
2258
|
}
|
|
2235
2259
|
else {
|
|
2236
|
-
const group = KritzelSelectionGroup.create(this.
|
|
2260
|
+
const group = KritzelSelectionGroup.create(this._core);
|
|
2237
2261
|
group.translateX = 0;
|
|
2238
2262
|
group.translateY = 0;
|
|
2239
2263
|
group.addOrRemove(object);
|
|
@@ -2241,7 +2265,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2241
2265
|
}
|
|
2242
2266
|
}
|
|
2243
2267
|
getHandleType(event) {
|
|
2244
|
-
const shadowRoot = this.
|
|
2268
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
2245
2269
|
if (!shadowRoot)
|
|
2246
2270
|
return;
|
|
2247
2271
|
const elementAtPoint = shadowRoot.elementFromPoint(event.clientX, event.clientY);
|
|
@@ -2249,7 +2273,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2249
2273
|
return handle?.classList[1];
|
|
2250
2274
|
}
|
|
2251
2275
|
isHandleSelected(event) {
|
|
2252
|
-
const shadowRoot = this.
|
|
2276
|
+
const shadowRoot = this._core.store.state.host?.shadowRoot;
|
|
2253
2277
|
if (!shadowRoot)
|
|
2254
2278
|
return false;
|
|
2255
2279
|
const elementAtPoint = shadowRoot.elementFromPoint(event.clientX, event.clientY);
|
|
@@ -2261,10 +2285,144 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2261
2285
|
}
|
|
2262
2286
|
}
|
|
2263
2287
|
|
|
2288
|
+
const DEFAULT_BRUSH_CONFIG = {
|
|
2289
|
+
type: 'pen',
|
|
2290
|
+
color: '#000000',
|
|
2291
|
+
size: 16,
|
|
2292
|
+
palettes: {
|
|
2293
|
+
pen: [
|
|
2294
|
+
'#000000',
|
|
2295
|
+
'#ff5252',
|
|
2296
|
+
'#ffbc00',
|
|
2297
|
+
'#00c853',
|
|
2298
|
+
'#0000FF',
|
|
2299
|
+
'#d500f9',
|
|
2300
|
+
'#fafafa',
|
|
2301
|
+
'#a52714',
|
|
2302
|
+
'#ee8100',
|
|
2303
|
+
'#558b2f',
|
|
2304
|
+
'#01579b',
|
|
2305
|
+
'#8e24aa',
|
|
2306
|
+
'#90a4ae',
|
|
2307
|
+
'#ff4081',
|
|
2308
|
+
'#ff6e40',
|
|
2309
|
+
'#aeea00',
|
|
2310
|
+
'#304ffe',
|
|
2311
|
+
'#7c4dff',
|
|
2312
|
+
'#cfd8dc',
|
|
2313
|
+
'#f8bbd0',
|
|
2314
|
+
'#ffccbc',
|
|
2315
|
+
'#f0f4c3',
|
|
2316
|
+
'#9fa8da',
|
|
2317
|
+
'#d1c4e9',
|
|
2318
|
+
],
|
|
2319
|
+
highlighter: [
|
|
2320
|
+
'#0000006e',
|
|
2321
|
+
'#ff52526e',
|
|
2322
|
+
'#ffbb006e',
|
|
2323
|
+
'#00c8536e',
|
|
2324
|
+
'#0000FF6e',
|
|
2325
|
+
'#d500f96e',
|
|
2326
|
+
'#fafafa6e',
|
|
2327
|
+
'#a527146e',
|
|
2328
|
+
'#ee81006e',
|
|
2329
|
+
'#558b2f6e',
|
|
2330
|
+
'#01579b6e',
|
|
2331
|
+
'#8e24aa6e',
|
|
2332
|
+
'#90a4ae6e',
|
|
2333
|
+
'#ff40816e',
|
|
2334
|
+
'#ff6e406e',
|
|
2335
|
+
'#aeea006e',
|
|
2336
|
+
'#304ffe6e',
|
|
2337
|
+
'#7c4dff6e',
|
|
2338
|
+
'#cfd8dc6e',
|
|
2339
|
+
'#f8bbd06e',
|
|
2340
|
+
'#ffccbc6e',
|
|
2341
|
+
'#f0f4c36e',
|
|
2342
|
+
'#9fa8da6e',
|
|
2343
|
+
'#d1c4e96e',
|
|
2344
|
+
],
|
|
2345
|
+
},
|
|
2346
|
+
};
|
|
2347
|
+
|
|
2348
|
+
const DEFAULT_TEXT_CONFIG = {
|
|
2349
|
+
color: '#000000',
|
|
2350
|
+
size: 8,
|
|
2351
|
+
fontFamily: 'Arial',
|
|
2352
|
+
palette: [
|
|
2353
|
+
'#000000',
|
|
2354
|
+
'#ff5252',
|
|
2355
|
+
'#ffbc00',
|
|
2356
|
+
'#00c853',
|
|
2357
|
+
'#0000FF',
|
|
2358
|
+
'#d500f9',
|
|
2359
|
+
'#fafafa',
|
|
2360
|
+
'#a52714',
|
|
2361
|
+
'#ee8100',
|
|
2362
|
+
'#558b2f',
|
|
2363
|
+
'#01579b',
|
|
2364
|
+
'#8e24aa',
|
|
2365
|
+
'#90a4ae',
|
|
2366
|
+
'#ff4081',
|
|
2367
|
+
'#ff6e40',
|
|
2368
|
+
'#aeea00',
|
|
2369
|
+
'#304ffe',
|
|
2370
|
+
'#7c4dff',
|
|
2371
|
+
'#cfd8dc',
|
|
2372
|
+
'#f8bbd0',
|
|
2373
|
+
'#ffccbc',
|
|
2374
|
+
'#f0f4c3',
|
|
2375
|
+
'#9fa8da',
|
|
2376
|
+
'#d1c4e9',
|
|
2377
|
+
],
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
class KritzelWorkspace {
|
|
2381
|
+
__class__ = 'KritzelWorkspace';
|
|
2382
|
+
id;
|
|
2383
|
+
name;
|
|
2384
|
+
createdAt;
|
|
2385
|
+
updatedAt;
|
|
2386
|
+
viewport;
|
|
2387
|
+
_core;
|
|
2388
|
+
constructor(id, name, viewport = { translateX: 0, translateY: 0, scale: 1 }) {
|
|
2389
|
+
this.id = id;
|
|
2390
|
+
this.name = name;
|
|
2391
|
+
this.createdAt = new Date();
|
|
2392
|
+
this.updatedAt = new Date();
|
|
2393
|
+
this.viewport = viewport;
|
|
2394
|
+
}
|
|
2395
|
+
static create(core, obj) {
|
|
2396
|
+
const workspace = new KritzelWorkspace(obj.id, obj.name, obj.viewport);
|
|
2397
|
+
workspace._core = core;
|
|
2398
|
+
Object.assign(workspace, obj);
|
|
2399
|
+
return workspace;
|
|
2400
|
+
}
|
|
2401
|
+
addObject(obj) {
|
|
2402
|
+
this._core.engine.addObject(obj);
|
|
2403
|
+
}
|
|
2404
|
+
serialize() {
|
|
2405
|
+
return {
|
|
2406
|
+
__class__: this.__class__,
|
|
2407
|
+
id: this.id,
|
|
2408
|
+
name: this.name,
|
|
2409
|
+
createdAt: this.createdAt,
|
|
2410
|
+
updatedAt: this.updatedAt,
|
|
2411
|
+
viewport: this.viewport,
|
|
2412
|
+
};
|
|
2413
|
+
}
|
|
2414
|
+
deserialize(object) {
|
|
2415
|
+
Object.assign(this, object);
|
|
2416
|
+
this.createdAt = new Date(object.createdAt);
|
|
2417
|
+
this.updatedAt = new Date(object.updatedAt);
|
|
2418
|
+
return this;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2264
2422
|
class KritzelReviver {
|
|
2265
|
-
|
|
2266
|
-
constructor(
|
|
2267
|
-
this.
|
|
2423
|
+
_core;
|
|
2424
|
+
constructor(core) {
|
|
2425
|
+
this._core = core;
|
|
2268
2426
|
}
|
|
2269
2427
|
revive(obj) {
|
|
2270
2428
|
if (obj && typeof obj === 'object') {
|
|
@@ -2272,34 +2430,37 @@ class KritzelReviver {
|
|
|
2272
2430
|
let revivedObj;
|
|
2273
2431
|
switch (obj.__class__) {
|
|
2274
2432
|
case 'KritzelPath':
|
|
2275
|
-
revivedObj = KritzelPath.create(this.
|
|
2433
|
+
revivedObj = KritzelPath.create(this._core).deserialize(obj);
|
|
2276
2434
|
break;
|
|
2277
2435
|
case 'KritzelText':
|
|
2278
|
-
revivedObj = KritzelText.create(this.
|
|
2436
|
+
revivedObj = KritzelText.create(this._core, obj.fontSize, obj.fontFamily).deserialize(obj);
|
|
2279
2437
|
break;
|
|
2280
2438
|
case 'KritzelImage':
|
|
2281
|
-
revivedObj = KritzelImage.create(this.
|
|
2439
|
+
revivedObj = KritzelImage.create(this._core).deserialize(obj);
|
|
2282
2440
|
break;
|
|
2283
2441
|
case 'KritzelCustomElement':
|
|
2284
|
-
revivedObj = KritzelCustomElement.create(this.
|
|
2442
|
+
revivedObj = KritzelCustomElement.create(this._core).deserialize(obj);
|
|
2285
2443
|
break;
|
|
2286
2444
|
case 'KritzelSelectionGroup':
|
|
2287
|
-
revivedObj = KritzelSelectionGroup.create(this.
|
|
2445
|
+
revivedObj = KritzelSelectionGroup.create(this._core).deserialize(obj);
|
|
2446
|
+
break;
|
|
2447
|
+
case 'KritzelWorkspace':
|
|
2448
|
+
revivedObj = KritzelWorkspace.create(this._core, obj).deserialize(obj);
|
|
2288
2449
|
break;
|
|
2289
2450
|
case 'KritzelBrushTool':
|
|
2290
|
-
revivedObj = new KritzelBrushTool(this.
|
|
2451
|
+
revivedObj = new KritzelBrushTool(this._core);
|
|
2291
2452
|
break;
|
|
2292
2453
|
case 'KritzelEraserTool':
|
|
2293
|
-
revivedObj = new KritzelEraserTool(this.
|
|
2454
|
+
revivedObj = new KritzelEraserTool(this._core);
|
|
2294
2455
|
break;
|
|
2295
2456
|
case 'KritzelImageTool':
|
|
2296
|
-
revivedObj = new KritzelImageTool(this.
|
|
2457
|
+
revivedObj = new KritzelImageTool(this._core);
|
|
2297
2458
|
break;
|
|
2298
2459
|
case 'KritzelSelectionTool':
|
|
2299
|
-
revivedObj = new KritzelSelectionTool(this.
|
|
2460
|
+
revivedObj = new KritzelSelectionTool(this._core);
|
|
2300
2461
|
break;
|
|
2301
2462
|
case 'KritzelTextTool':
|
|
2302
|
-
revivedObj = new KritzelTextTool(this.
|
|
2463
|
+
revivedObj = new KritzelTextTool(this._core);
|
|
2303
2464
|
break;
|
|
2304
2465
|
default:
|
|
2305
2466
|
revivedObj = obj;
|
|
@@ -2329,12 +2490,12 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2329
2490
|
get length() {
|
|
2330
2491
|
return this.objects.length;
|
|
2331
2492
|
}
|
|
2332
|
-
static create(
|
|
2493
|
+
static create(core) {
|
|
2333
2494
|
const object = new KritzelSelectionGroup();
|
|
2334
|
-
object.
|
|
2495
|
+
object._core = core;
|
|
2335
2496
|
object.id = object.generateId();
|
|
2336
|
-
object.workspaceId = store.state.activeWorkspace.id;
|
|
2337
|
-
object.scale = store.state.scale;
|
|
2497
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
2498
|
+
object.scale = core.store.state.scale;
|
|
2338
2499
|
object.zIndex = 99999;
|
|
2339
2500
|
return object;
|
|
2340
2501
|
}
|
|
@@ -2346,7 +2507,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2346
2507
|
else {
|
|
2347
2508
|
this.objects.splice(index, 1);
|
|
2348
2509
|
}
|
|
2349
|
-
this.unchangedObjects =
|
|
2510
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2350
2511
|
this.refreshObjectDimensions();
|
|
2351
2512
|
}
|
|
2352
2513
|
deselectAllChildren() {
|
|
@@ -2366,17 +2527,17 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2366
2527
|
});
|
|
2367
2528
|
this.translateX = x;
|
|
2368
2529
|
this.translateY = y;
|
|
2369
|
-
this.
|
|
2530
|
+
this._core.store.state.objectsMap.update(this);
|
|
2370
2531
|
}
|
|
2371
2532
|
move(startX, startY, endX, endY) {
|
|
2372
|
-
const deltaX = (startX - endX) / this.
|
|
2373
|
-
const deltaY = (startY - endY) / this.
|
|
2533
|
+
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
2534
|
+
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
2374
2535
|
this.translateX += deltaX;
|
|
2375
2536
|
this.translateY += deltaY;
|
|
2376
|
-
this.
|
|
2537
|
+
this._core.store.state.objectsMap.update(this);
|
|
2377
2538
|
this.objects.forEach(obj => {
|
|
2378
2539
|
obj.move(startX, startY, endX, endY);
|
|
2379
|
-
this.
|
|
2540
|
+
this._core.store.state.objectsMap.update(obj);
|
|
2380
2541
|
});
|
|
2381
2542
|
this.unchangedObjects.forEach(obj => {
|
|
2382
2543
|
obj.translateX += deltaX;
|
|
@@ -2394,10 +2555,10 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2394
2555
|
const updatedX = child.translateX + deltaX + (child.translateX - this.translateX) * (widthScaleFactor - 1);
|
|
2395
2556
|
const updatedY = child.translateY + deltaY + (child.translateY - this.translateY) * (heightScaleFactor - 1);
|
|
2396
2557
|
child.resize(updatedX, updatedY, updatedWidth, updatedHeight);
|
|
2397
|
-
this.
|
|
2558
|
+
this._core.store.state.objectsMap.update(child);
|
|
2398
2559
|
});
|
|
2399
2560
|
this.refreshObjectDimensions();
|
|
2400
|
-
this.unchangedObjects =
|
|
2561
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2401
2562
|
}
|
|
2402
2563
|
rotate(value) {
|
|
2403
2564
|
this.rotation = value;
|
|
@@ -2415,19 +2576,19 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2415
2576
|
child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
|
|
2416
2577
|
child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
|
|
2417
2578
|
child.rotate(this.objects.length === 1 ? value : value + unchangedChild.rotation);
|
|
2418
|
-
this.
|
|
2579
|
+
this._core.store.state.objectsMap.update(child);
|
|
2419
2580
|
});
|
|
2420
2581
|
}
|
|
2421
2582
|
copy() {
|
|
2422
|
-
const selectionGroup = KritzelSelectionGroup.create(this.
|
|
2423
|
-
let currentZIndex = this.
|
|
2583
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2584
|
+
let currentZIndex = this._core.store.currentZIndex;
|
|
2424
2585
|
this.objects.sort((a, b) => a.zIndex - b.zIndex).forEach(obj => {
|
|
2425
2586
|
const copiedObject = obj.copy();
|
|
2426
2587
|
copiedObject.zIndex = currentZIndex;
|
|
2427
2588
|
selectionGroup.addOrRemove(copiedObject);
|
|
2428
2589
|
currentZIndex++;
|
|
2429
2590
|
});
|
|
2430
|
-
selectionGroup.unchangedObjects =
|
|
2591
|
+
selectionGroup.unchangedObjects = selectionGroup.objects.map(obj => obj.clone());
|
|
2431
2592
|
if (this.objects.length === 1) {
|
|
2432
2593
|
selectionGroup.rotation = this.objects[0].rotation;
|
|
2433
2594
|
}
|
|
@@ -2455,7 +2616,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2455
2616
|
this.width = (this.maxX - this.minX - this.padding) * this.scale;
|
|
2456
2617
|
this.height = (this.maxY - this.minY - this.padding) * this.scale;
|
|
2457
2618
|
}
|
|
2458
|
-
this.
|
|
2619
|
+
this._core.store.state.objectsMap.update(this);
|
|
2459
2620
|
}
|
|
2460
2621
|
getOffsetXToCenter(obj) {
|
|
2461
2622
|
const objCenterX = obj.translateX + obj.totalWidth / obj.scale / 2;
|
|
@@ -2469,7 +2630,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2469
2630
|
}
|
|
2470
2631
|
getUnchangedObject(objectId) {
|
|
2471
2632
|
const obj = this.unchangedObjects.find(obj => obj.id === objectId);
|
|
2472
|
-
const reviver = new KritzelReviver(this.
|
|
2633
|
+
const reviver = new KritzelReviver(this._core);
|
|
2473
2634
|
return reviver.revive(obj);
|
|
2474
2635
|
}
|
|
2475
2636
|
}
|
|
@@ -2486,15 +2647,15 @@ function _mergeNamespaces(e,t){return t.forEach((function(t){t&&"string"!=typeof
|
|
|
2486
2647
|
class KritzelImageTool extends KritzelBaseTool {
|
|
2487
2648
|
fileInput = null;
|
|
2488
2649
|
maxCompressionSize = 300;
|
|
2489
|
-
constructor(
|
|
2490
|
-
super(
|
|
2650
|
+
constructor(core) {
|
|
2651
|
+
super(core);
|
|
2491
2652
|
this.setupFileInput();
|
|
2492
2653
|
}
|
|
2493
2654
|
onActivate() {
|
|
2494
2655
|
this.openFilePicker();
|
|
2495
2656
|
}
|
|
2496
2657
|
openFilePicker() {
|
|
2497
|
-
if (this.
|
|
2658
|
+
if (this._core.store.isDisabled) {
|
|
2498
2659
|
return;
|
|
2499
2660
|
}
|
|
2500
2661
|
this.fileInput.click();
|
|
@@ -2541,138 +2702,31 @@ class KritzelImageTool extends KritzelBaseTool {
|
|
|
2541
2702
|
reader.readAsDataURL(file);
|
|
2542
2703
|
}
|
|
2543
2704
|
createKritzelImage(img) {
|
|
2544
|
-
const image = KritzelImage.create(this.
|
|
2705
|
+
const image = KritzelImage.create(this._core);
|
|
2545
2706
|
const { scaledWidth, scaledHeight } = image.calculateScaledDimensions(img);
|
|
2546
2707
|
image.src = img.src;
|
|
2547
2708
|
image.width = scaledWidth;
|
|
2548
2709
|
image.height = scaledHeight;
|
|
2549
|
-
image.zIndex = this.
|
|
2710
|
+
image.zIndex = this._core.store.currentZIndex;
|
|
2550
2711
|
image.centerInViewport();
|
|
2551
2712
|
this.addImageToStore(image);
|
|
2552
2713
|
return image;
|
|
2553
2714
|
}
|
|
2554
2715
|
addImageToStore(image) {
|
|
2555
|
-
const selectionGroup = KritzelSelectionGroup.create(this.
|
|
2716
|
+
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2556
2717
|
selectionGroup.addOrRemove(image);
|
|
2557
2718
|
selectionGroup.isSelected = true;
|
|
2558
|
-
const addImageCommand = new AddObjectCommand(this.
|
|
2559
|
-
const addSelectionGroupCommand = new AddSelectionGroupCommand(this.
|
|
2560
|
-
this.
|
|
2561
|
-
this.
|
|
2719
|
+
const addImageCommand = new AddObjectCommand(this._core, this, image);
|
|
2720
|
+
const addSelectionGroupCommand = new AddSelectionGroupCommand(this._core, this, selectionGroup);
|
|
2721
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, [addImageCommand, addSelectionGroupCommand]));
|
|
2722
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
2562
2723
|
}
|
|
2563
2724
|
handleCancel() {
|
|
2564
|
-
this.
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
const DEFAULT_BRUSH_CONFIG = {
|
|
2569
|
-
type: 'pen',
|
|
2570
|
-
color: '#000000',
|
|
2571
|
-
size: 16,
|
|
2572
|
-
palettes: {
|
|
2573
|
-
pen: [
|
|
2574
|
-
'#000000',
|
|
2575
|
-
'#ff5252',
|
|
2576
|
-
'#ffbc00',
|
|
2577
|
-
'#00c853',
|
|
2578
|
-
'#0000FF',
|
|
2579
|
-
'#d500f9',
|
|
2580
|
-
'#fafafa',
|
|
2581
|
-
'#a52714',
|
|
2582
|
-
'#ee8100',
|
|
2583
|
-
'#558b2f',
|
|
2584
|
-
'#01579b',
|
|
2585
|
-
'#8e24aa',
|
|
2586
|
-
'#90a4ae',
|
|
2587
|
-
'#ff4081',
|
|
2588
|
-
'#ff6e40',
|
|
2589
|
-
'#aeea00',
|
|
2590
|
-
'#304ffe',
|
|
2591
|
-
'#7c4dff',
|
|
2592
|
-
'#cfd8dc',
|
|
2593
|
-
'#f8bbd0',
|
|
2594
|
-
'#ffccbc',
|
|
2595
|
-
'#f0f4c3',
|
|
2596
|
-
'#9fa8da',
|
|
2597
|
-
'#d1c4e9',
|
|
2598
|
-
],
|
|
2599
|
-
highlighter: [
|
|
2600
|
-
'#0000006e',
|
|
2601
|
-
'#ff52526e',
|
|
2602
|
-
'#ffbb006e',
|
|
2603
|
-
'#00c8536e',
|
|
2604
|
-
'#0000FF6e',
|
|
2605
|
-
'#d500f96e',
|
|
2606
|
-
'#fafafa6e',
|
|
2607
|
-
'#a527146e',
|
|
2608
|
-
'#ee81006e',
|
|
2609
|
-
'#558b2f6e',
|
|
2610
|
-
'#01579b6e',
|
|
2611
|
-
'#8e24aa6e',
|
|
2612
|
-
'#90a4ae6e',
|
|
2613
|
-
'#ff40816e',
|
|
2614
|
-
'#ff6e406e',
|
|
2615
|
-
'#aeea006e',
|
|
2616
|
-
'#304ffe6e',
|
|
2617
|
-
'#7c4dff6e',
|
|
2618
|
-
'#cfd8dc6e',
|
|
2619
|
-
'#f8bbd06e',
|
|
2620
|
-
'#ffccbc6e',
|
|
2621
|
-
'#f0f4c36e',
|
|
2622
|
-
'#9fa8da6e',
|
|
2623
|
-
'#d1c4e96e',
|
|
2624
|
-
],
|
|
2625
|
-
},
|
|
2626
|
-
};
|
|
2627
|
-
|
|
2628
|
-
const DEFAULT_TEXT_CONFIG = {
|
|
2629
|
-
color: '#000000',
|
|
2630
|
-
size: 8,
|
|
2631
|
-
fontFamily: 'Arial',
|
|
2632
|
-
palette: [
|
|
2633
|
-
'#000000',
|
|
2634
|
-
'#ff5252',
|
|
2635
|
-
'#ffbc00',
|
|
2636
|
-
'#00c853',
|
|
2637
|
-
'#0000FF',
|
|
2638
|
-
'#d500f9',
|
|
2639
|
-
'#fafafa',
|
|
2640
|
-
'#a52714',
|
|
2641
|
-
'#ee8100',
|
|
2642
|
-
'#558b2f',
|
|
2643
|
-
'#01579b',
|
|
2644
|
-
'#8e24aa',
|
|
2645
|
-
'#90a4ae',
|
|
2646
|
-
'#ff4081',
|
|
2647
|
-
'#ff6e40',
|
|
2648
|
-
'#aeea00',
|
|
2649
|
-
'#304ffe',
|
|
2650
|
-
'#7c4dff',
|
|
2651
|
-
'#cfd8dc',
|
|
2652
|
-
'#f8bbd0',
|
|
2653
|
-
'#ffccbc',
|
|
2654
|
-
'#f0f4c3',
|
|
2655
|
-
'#9fa8da',
|
|
2656
|
-
'#d1c4e9',
|
|
2657
|
-
],
|
|
2658
|
-
};
|
|
2659
|
-
|
|
2660
|
-
class KritzelWorkspace {
|
|
2661
|
-
id;
|
|
2662
|
-
name;
|
|
2663
|
-
createdAt;
|
|
2664
|
-
updatedAt;
|
|
2665
|
-
viewport;
|
|
2666
|
-
constructor(id, name, viewport = { translateX: 0, translateY: 0, scale: 1 }) {
|
|
2667
|
-
this.id = id;
|
|
2668
|
-
this.name = name;
|
|
2669
|
-
this.createdAt = new Date();
|
|
2670
|
-
this.updatedAt = new Date();
|
|
2671
|
-
this.viewport = viewport;
|
|
2725
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
2672
2726
|
}
|
|
2673
2727
|
}
|
|
2674
2728
|
|
|
2675
|
-
export {
|
|
2676
|
-
//# sourceMappingURL=index-
|
|
2729
|
+
export { AddSelectionGroupCommand as A, BatchCommand as B, DEFAULT_BRUSH_CONFIG as D, KritzelBrushTool as K, ObjectHelper as O, RemoveSelectionGroupCommand as R, UpdateObjectCommand as U, KritzelTextTool as a, KritzelMouseButton as b, KritzelSelectionTool as c, KritzelEraserTool as d, DEFAULT_TEXT_CONFIG as e, KritzelImageTool as f, KritzelWorkspace as g, KritzelKeyboardHelper as h, KritzelEventHelper as i, KritzelBaseHandler as j, KritzelToolRegistry as k, KritzelSelectionGroup as l, KritzelBaseCommand as m, KrtizelSelectionBox as n, KritzelReviver as o, RemoveObjectCommand as p, AddObjectCommand as q, KritzelBaseTool as r, KritzelText as s, KritzelPath as t, KritzelImage as u };
|
|
2730
|
+
//# sourceMappingURL=index-DY3KqYWc.js.map
|
|
2677
2731
|
|
|
2678
|
-
//# sourceMappingURL=index-
|
|
2732
|
+
//# sourceMappingURL=index-DY3KqYWc.js.map
|