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