kritzel-stencil 0.0.143 → 0.0.145
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-Cg50mv2K.js → default-text-tool.config-D2dP2xyB.js} +15947 -1100
- package/dist/cjs/default-text-tool.config-D2dP2xyB.js.map +1 -0
- package/dist/cjs/{index-DcTwXs_q.js → index-Cj__YTlG.js} +9 -11
- package/dist/cjs/index-Cj__YTlG.js.map +1 -0
- package/dist/cjs/index.cjs.js +1369 -12
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +771 -720
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/cjs/stencil.cjs.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +263 -211
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/store.class.js +21 -3
- package/dist/collection/classes/core/store.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +8 -3
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/core/workspace.class.js +2 -3
- package/dist/collection/classes/core/workspace.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +11 -14
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +13 -13
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +18 -10
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +20 -17
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +26 -23
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +32 -30
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +6 -15
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +2 -0
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +2 -0
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +4 -0
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +3 -4
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +109 -49
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +36 -42
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js +93 -0
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +232 -0
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +35 -0
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/providers/websocket-sync-provider.class.js +89 -0
- package/dist/collection/classes/providers/websocket-sync-provider.class.js.map +1 -0
- package/dist/collection/classes/structures/app-state-map.structure.js +189 -0
- package/dist/collection/classes/structures/app-state-map.structure.js.map +1 -0
- package/dist/collection/classes/structures/object-map.structure.js +260 -1
- package/dist/collection/classes/structures/object-map.structure.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +48 -37
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +10 -12
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +2 -10
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +11 -8
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +12 -18
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +36 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +61 -35
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -2
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +3 -3
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/configs/{default-engine-state.js → default-engine-config.js} +2 -8
- package/dist/collection/configs/default-engine-config.js.map +1 -0
- package/dist/collection/configs/default-sync.config.js +12 -0
- package/dist/collection/configs/default-sync.config.js.map +1 -0
- package/dist/collection/constants/core.constants.js +2 -0
- package/dist/collection/constants/core.constants.js.map +1 -0
- package/dist/collection/index.js +8 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/debug-info.interface.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/collection/interfaces/selection-state.interface.js.map +1 -1
- package/dist/collection/interfaces/sync-config.interface.js +2 -0
- package/dist/collection/interfaces/sync-config.interface.js.map +1 -0
- package/dist/collection/interfaces/sync-provider.interface.js +2 -0
- package/dist/collection/interfaces/sync-provider.interface.js.map +1 -0
- package/dist/components/index.js +1361 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/kritzel-brush-style.js +4 -4
- 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 +39 -27
- 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-C_hSH2nN.js → p-8iFF5GHL.js} +6 -6
- package/dist/components/{p-C_hSH2nN.js.map → p-8iFF5GHL.js.map} +1 -1
- package/dist/components/{p-BycHaC-9.js → p-BCrMfH5n.js} +6 -6
- package/dist/components/{p-BycHaC-9.js.map → p-BCrMfH5n.js.map} +1 -1
- package/dist/components/{p-D_RcVGj0.js → p-BHDOht0m.js} +6 -6
- package/dist/components/{p-D_RcVGj0.js.map → p-BHDOht0m.js.map} +1 -1
- package/dist/components/{p-DqsgZIHC.js → p-BHT7_POQ.js} +6 -6
- package/dist/components/{p-DqsgZIHC.js.map → p-BHT7_POQ.js.map} +1 -1
- package/dist/components/{p-DzyZA2GT.js → p-BQ5cdSqE.js} +11 -11
- package/dist/components/{p-DzyZA2GT.js.map → p-BQ5cdSqE.js.map} +1 -1
- package/dist/components/{p-Co5lU_7h.js → p-BaHZYvfq.js} +13 -13
- package/dist/components/{p-Co5lU_7h.js.map → p-BaHZYvfq.js.map} +1 -1
- package/dist/components/{p-BJbN3vca.js → p-BctNMdxr.js} +8 -8
- package/dist/components/{p-BJbN3vca.js.map → p-BctNMdxr.js.map} +1 -1
- package/dist/components/{p-BAw249L9.js → p-BgRGxOIE.js} +20 -20
- package/dist/components/{p-BAw249L9.js.map → p-BgRGxOIE.js.map} +1 -1
- package/dist/components/{p-D27d2rKT.js → p-Bhtn9qay.js} +5 -5
- package/dist/components/{p-D27d2rKT.js.map → p-Bhtn9qay.js.map} +1 -1
- package/dist/components/{p-CEn1WeG3.js → p-Bit0z7Yg.js} +9 -9
- package/dist/components/{p-CEn1WeG3.js.map → p-Bit0z7Yg.js.map} +1 -1
- package/dist/components/{p-CGb-8cK4.js → p-BlI4vzRZ.js} +5 -5
- package/dist/components/{p-CGb-8cK4.js.map → p-BlI4vzRZ.js.map} +1 -1
- package/dist/components/p-ByRC-aCs.js +18262 -0
- package/dist/components/p-ByRC-aCs.js.map +1 -0
- package/dist/components/{p-fiFoOjv0.js → p-C3_LIgzd.js} +10 -10
- package/dist/components/{p-fiFoOjv0.js.map → p-C3_LIgzd.js.map} +1 -1
- package/dist/components/{p-DPxzgBs0.js → p-CIXPLjCu.js} +4 -4
- package/dist/components/{p-DPxzgBs0.js.map → p-CIXPLjCu.js.map} +1 -1
- package/dist/components/{p-CoFmi-t6.js → p-COGwCbe1.js} +116 -188
- package/dist/components/p-COGwCbe1.js.map +1 -0
- package/dist/components/{p-dcR2uxM3.js → p-CURq0twf.js} +6 -6
- package/dist/components/{p-dcR2uxM3.js.map → p-CURq0twf.js.map} +1 -1
- package/dist/components/{p-C9hrbrUN.js → p-CwkUrTy1.js} +5 -7
- package/dist/{cjs/index-DcTwXs_q.js.map → components/p-CwkUrTy1.js.map} +1 -1
- package/dist/components/{p-ByAzDzS5.js → p-D13ydJjo.js} +5 -5
- package/dist/components/{p-ByAzDzS5.js.map → p-D13ydJjo.js.map} +1 -1
- package/dist/components/{p-BFNwskCY.js → p-Dbp5YJIa.js} +5 -5
- package/dist/components/{p-BFNwskCY.js.map → p-Dbp5YJIa.js.map} +1 -1
- package/dist/components/{p-BEKicPnH.js → p-Dcf7tVJW.js} +5 -5
- package/dist/components/{p-BEKicPnH.js.map → p-Dcf7tVJW.js.map} +1 -1
- package/dist/components/{p-CieOx1XL.js → p-EBtkRix7.js} +8 -8
- package/dist/components/{p-CieOx1XL.js.map → p-EBtkRix7.js.map} +1 -1
- package/dist/components/{p-gCHmJzc2.js → p-NXPGXBZ2.js} +6 -6
- package/dist/components/{p-gCHmJzc2.js.map → p-NXPGXBZ2.js.map} +1 -1
- package/dist/components/{p-YqK8ch2R.js → p-n789Y3S-.js} +4 -5
- package/dist/components/p-n789Y3S-.js.map +1 -0
- package/dist/esm/{index-Bj5QIJYQ.js → default-text-tool.config-CsZAW1Cu.js} +15908 -1092
- package/dist/esm/default-text-tool.config-CsZAW1Cu.js.map +1 -0
- package/dist/esm/{index-Cw77zP6g.js → index-SGde3HXB.js} +9 -11
- package/dist/esm/index-SGde3HXB.js.map +1 -0
- package/dist/esm/index.js +1358 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +736 -685
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/index.esm.js.map +1 -1
- package/dist/stencil/p-27adbf9d.entry.js +2 -0
- package/dist/stencil/p-27adbf9d.entry.js.map +1 -0
- package/dist/stencil/p-CsZAW1Cu.js +2 -0
- package/dist/stencil/p-CsZAW1Cu.js.map +1 -0
- package/dist/stencil/{p-Cw77zP6g.js → p-SGde3HXB.js} +2 -2
- package/dist/stencil/p-SGde3HXB.js.map +1 -0
- package/dist/stencil/{p-8b831c94.entry.js → p-d702c5af.entry.js} +2 -2
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/core/core.class.d.ts +34 -21
- package/dist/types/classes/core/store.class.d.ts +8 -0
- package/dist/types/classes/objects/base-object.class.d.ts +1 -5
- package/dist/types/classes/objects/path.class.d.ts +1 -0
- package/dist/types/classes/objects/selection-box.class.d.ts +2 -3
- package/dist/types/classes/objects/selection-group.class.d.ts +24 -5
- package/dist/types/classes/objects/text.class.d.ts +0 -3
- package/dist/types/classes/providers/broadcast-sync-provider.class.d.ts +18 -0
- package/dist/types/classes/providers/hocuspocus-sync-provider.class.d.ts +120 -0
- package/dist/types/classes/providers/indexeddb-sync-provider.class.d.ts +22 -0
- package/dist/types/classes/providers/websocket-sync-provider.class.d.ts +52 -0
- package/dist/types/classes/structures/app-state-map.structure.d.ts +30 -0
- package/dist/types/classes/structures/object-map.structure.d.ts +39 -1
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +3 -0
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +2 -0
- package/dist/types/components.d.ts +6 -0
- package/dist/types/configs/{default-engine-state.d.ts → default-engine-config.d.ts} +1 -1
- package/dist/types/configs/default-sync.config.d.ts +5 -0
- package/dist/types/constants/core.constants.d.ts +0 -0
- package/dist/types/index.d.ts +8 -1
- package/dist/types/interfaces/debug-info.interface.d.ts +0 -1
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -10
- package/dist/types/interfaces/object.interface.d.ts +1 -1
- package/dist/types/interfaces/selection-state.interface.d.ts +0 -4
- package/dist/types/interfaces/sync-config.interface.d.ts +22 -0
- package/dist/types/interfaces/sync-provider.interface.d.ts +29 -0
- package/dist/types/stencil-public-runtime.d.ts +1 -1
- package/package.json +6 -2
- package/dist/cjs/index-Cg50mv2K.js.map +0 -1
- package/dist/collection/classes/commands/add-object.command.js +0 -18
- package/dist/collection/classes/commands/add-object.command.js.map +0 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +0 -24
- package/dist/collection/classes/commands/add-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/base.command.js +0 -19
- package/dist/collection/classes/commands/base.command.js.map +0 -1
- package/dist/collection/classes/commands/batch.command.js +0 -15
- package/dist/collection/classes/commands/batch.command.js.map +0 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +0 -44
- package/dist/collection/classes/commands/move-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/remove-object.command.js +0 -18
- package/dist/collection/classes/commands/remove-object.command.js.map +0 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +0 -19
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +0 -29
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +0 -29
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +0 -1
- package/dist/collection/classes/commands/update-object.command.js +0 -38
- package/dist/collection/classes/commands/update-object.command.js.map +0 -1
- package/dist/collection/classes/commands/update-viewport.command.js +0 -25
- package/dist/collection/classes/commands/update-viewport.command.js.map +0 -1
- package/dist/collection/classes/core/command-manager.class.js +0 -51
- package/dist/collection/classes/core/command-manager.class.js.map +0 -1
- package/dist/collection/classes/core/database.class.js +0 -236
- package/dist/collection/classes/core/database.class.js.map +0 -1
- package/dist/collection/classes/core/history.class.js +0 -51
- package/dist/collection/classes/core/history.class.js.map +0 -1
- package/dist/collection/classes/structures/circular-buffer.structure.js +0 -48
- package/dist/collection/classes/structures/circular-buffer.structure.js.map +0 -1
- package/dist/collection/configs/default-engine-state.js.map +0 -1
- package/dist/collection/interfaces/command.interface.js +0 -2
- package/dist/collection/interfaces/command.interface.js.map +0 -1
- package/dist/components/p-C9hrbrUN.js.map +0 -1
- package/dist/components/p-CoFmi-t6.js.map +0 -1
- package/dist/components/p-EO13AYoE.js +0 -3331
- package/dist/components/p-EO13AYoE.js.map +0 -1
- package/dist/components/p-YqK8ch2R.js.map +0 -1
- package/dist/esm/index-Bj5QIJYQ.js.map +0 -1
- package/dist/esm/index-Cw77zP6g.js.map +0 -1
- package/dist/stencil/p-Bj5QIJYQ.js +0 -2
- package/dist/stencil/p-Bj5QIJYQ.js.map +0 -1
- package/dist/stencil/p-Cw77zP6g.js.map +0 -1
- package/dist/stencil/p-b4185842.entry.js +0 -2
- package/dist/stencil/p-b4185842.entry.js.map +0 -1
- package/dist/types/classes/commands/add-object.command.d.ts +0 -9
- package/dist/types/classes/commands/add-selection-group.command.d.ts +0 -10
- package/dist/types/classes/commands/base.command.d.ts +0 -11
- package/dist/types/classes/commands/batch.command.d.ts +0 -8
- package/dist/types/classes/commands/move-selection-group.command.d.ts +0 -13
- package/dist/types/classes/commands/remove-object.command.d.ts +0 -9
- package/dist/types/classes/commands/remove-selection-group.command.d.ts +0 -8
- package/dist/types/classes/commands/resize-selection-group.command.d.ts +0 -20
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +0 -10
- package/dist/types/classes/commands/update-object.command.d.ts +0 -11
- package/dist/types/classes/commands/update-viewport.command.d.ts +0 -21
- package/dist/types/classes/core/command-manager.class.d.ts +0 -16
- package/dist/types/classes/core/database.class.d.ts +0 -29
- package/dist/types/classes/core/history.class.d.ts +0 -12
- package/dist/types/classes/structures/circular-buffer.structure.d.ts +0 -13
- package/dist/types/interfaces/command.interface.d.ts +0 -6
- /package/dist/stencil/{p-8b831c94.entry.js.map → p-d702c5af.entry.js.map} +0 -0
|
@@ -226,11 +226,15 @@ class KritzelBaseObject {
|
|
|
226
226
|
const deltaY = targetCenterY - objectCenterY;
|
|
227
227
|
this.updatePosition(this.translateX + deltaX, this.translateY + deltaY);
|
|
228
228
|
}
|
|
229
|
+
update() {
|
|
230
|
+
this._core.store.state.objectsMap.update(this);
|
|
231
|
+
}
|
|
229
232
|
move(startX, startY, endX, endY) {
|
|
230
233
|
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
231
234
|
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
232
235
|
this.translateX += deltaX;
|
|
233
236
|
this.translateY += deltaY;
|
|
237
|
+
this._core.store.state.objectsMap.update(this);
|
|
234
238
|
}
|
|
235
239
|
resize(x, y, width, height) {
|
|
236
240
|
if (width <= 1 || height <= 1) {
|
|
@@ -240,9 +244,11 @@ class KritzelBaseObject {
|
|
|
240
244
|
this.height = height;
|
|
241
245
|
this.translateX = x;
|
|
242
246
|
this.translateY = y;
|
|
247
|
+
this._core.store.state.objectsMap.update(this);
|
|
243
248
|
}
|
|
244
249
|
rotate(value) {
|
|
245
250
|
this.rotation = value;
|
|
251
|
+
this._core.store.state.objectsMap.update(this);
|
|
246
252
|
}
|
|
247
253
|
clone() {
|
|
248
254
|
const clone = Object.create(Object.getPrototypeOf(this));
|
|
@@ -257,9 +263,6 @@ class KritzelBaseObject {
|
|
|
257
263
|
copiedObject.isMounted = false;
|
|
258
264
|
return copiedObject;
|
|
259
265
|
}
|
|
260
|
-
onSelectedClick() {
|
|
261
|
-
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
262
|
-
}
|
|
263
266
|
serialize() {
|
|
264
267
|
const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this;
|
|
265
268
|
const clonedProps = structuredClone(remainingProps);
|
|
@@ -290,18 +293,6 @@ class KritzelBaseObject {
|
|
|
290
293
|
this.translateY = y;
|
|
291
294
|
this._core.store.state.objectsMap.update(this);
|
|
292
295
|
}
|
|
293
|
-
onExecuteAddCommand(_object) {
|
|
294
|
-
// This method can be overridden by subclasses to handle actions after an add command is executed.
|
|
295
|
-
}
|
|
296
|
-
onUndoAddCommand(_object) {
|
|
297
|
-
// This method can be overridden by subclasses to handle actions after an add command is undone.
|
|
298
|
-
}
|
|
299
|
-
onExecuteUpdateCommand(_updatedProperties) {
|
|
300
|
-
// This method can be overridden by subclasses to handle actions after an update command is executed.
|
|
301
|
-
}
|
|
302
|
-
onUndoUpdateCommand(_previousProperties) {
|
|
303
|
-
// This method can be overridden by subclasses to handle actions after an update command is undone.
|
|
304
|
-
}
|
|
305
296
|
}
|
|
306
297
|
|
|
307
298
|
class KritzelKeyboardHelper {
|
|
@@ -353,62 +344,6 @@ class KritzelKeyboardHelper {
|
|
|
353
344
|
}
|
|
354
345
|
}
|
|
355
346
|
|
|
356
|
-
class KritzelBaseCommand {
|
|
357
|
-
_core;
|
|
358
|
-
initiator;
|
|
359
|
-
skipHistory;
|
|
360
|
-
timestamp;
|
|
361
|
-
constructor(core, initiator, skipHistory = false) {
|
|
362
|
-
this._core = core;
|
|
363
|
-
this.initiator = initiator?.constructor?.name ?? 'Unknown';
|
|
364
|
-
this.skipHistory = skipHistory;
|
|
365
|
-
this.timestamp = new Date();
|
|
366
|
-
}
|
|
367
|
-
execute() {
|
|
368
|
-
throw new Error('Method not implemented.');
|
|
369
|
-
}
|
|
370
|
-
undo() {
|
|
371
|
-
throw new Error('Method not implemented.');
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
class UpdateObjectCommand extends KritzelBaseCommand {
|
|
376
|
-
object;
|
|
377
|
-
updatedProperties;
|
|
378
|
-
previousProperties;
|
|
379
|
-
constructor(core, initiator, object, updatedProperties, skipHistory = false) {
|
|
380
|
-
super(core, initiator, skipHistory);
|
|
381
|
-
this.object = object;
|
|
382
|
-
this.updatedProperties = updatedProperties;
|
|
383
|
-
this.previousProperties = {};
|
|
384
|
-
for (const key in updatedProperties) {
|
|
385
|
-
if (updatedProperties.hasOwnProperty(key)) {
|
|
386
|
-
this.previousProperties[key] = this.object[key];
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
execute() {
|
|
391
|
-
for (const key in this.updatedProperties) {
|
|
392
|
-
if (this.updatedProperties.hasOwnProperty(key)) {
|
|
393
|
-
this.object[key] = this.updatedProperties[key];
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
this.object.onExecuteUpdateCommand(this.updatedProperties);
|
|
397
|
-
this._core.store.state.objectsMap.update(this.object);
|
|
398
|
-
this._core.updateObjectInDatabase(this.object);
|
|
399
|
-
}
|
|
400
|
-
undo() {
|
|
401
|
-
for (const key in this.previousProperties) {
|
|
402
|
-
if (this.previousProperties.hasOwnProperty(key)) {
|
|
403
|
-
this.object[key] = this.previousProperties[key];
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
this.object.onUndoUpdateCommand(this.previousProperties);
|
|
407
|
-
this._core.store.state.objectsMap.update(this.object);
|
|
408
|
-
this._core.updateObjectInDatabase(this.object);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
347
|
// ::- Persistent data structure representing an ordered mapping from
|
|
413
348
|
// strings to values, with some convenient update methods.
|
|
414
349
|
function OrderedMap(content) {
|
|
@@ -4988,13 +4923,17 @@ can be lifted. Will not go across
|
|
|
4988
4923
|
function liftTarget(range) {
|
|
4989
4924
|
let parent = range.parent;
|
|
4990
4925
|
let content = parent.content.cutByIndex(range.startIndex, range.endIndex);
|
|
4991
|
-
for (let depth = range.depth;; --depth) {
|
|
4926
|
+
for (let depth = range.depth, contentBefore = 0, contentAfter = 0;; --depth) {
|
|
4992
4927
|
let node = range.$from.node(depth);
|
|
4993
|
-
let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);
|
|
4928
|
+
let index = range.$from.index(depth) + contentBefore, endIndex = range.$to.indexAfter(depth) - contentAfter;
|
|
4994
4929
|
if (depth < range.depth && node.canReplace(index, endIndex, content))
|
|
4995
4930
|
return depth;
|
|
4996
4931
|
if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
|
|
4997
4932
|
break;
|
|
4933
|
+
if (index)
|
|
4934
|
+
contentBefore = 1;
|
|
4935
|
+
if (endIndex < node.childCount)
|
|
4936
|
+
contentAfter = 1;
|
|
4998
4937
|
}
|
|
4999
4938
|
return null;
|
|
5000
4939
|
}
|
|
@@ -5576,7 +5515,7 @@ function replaceRange(tr, from, to, slice) {
|
|
|
5576
5515
|
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
5577
5516
|
if (fitsTrivially($from, $to, slice))
|
|
5578
5517
|
return tr.step(new ReplaceStep(from, to, slice));
|
|
5579
|
-
let targetDepths = coveredDepths($from,
|
|
5518
|
+
let targetDepths = coveredDepths($from, $to);
|
|
5580
5519
|
// Can't replace the whole document, so remove 0 if it's present
|
|
5581
5520
|
if (targetDepths[targetDepths.length - 1] == 0)
|
|
5582
5521
|
targetDepths.pop();
|
|
@@ -13866,23 +13805,6 @@ Depending on the detected platform, this will hold
|
|
|
13866
13805
|
*/
|
|
13867
13806
|
const baseKeymap = mac ? macBaseKeymap : pcBaseKeymap;
|
|
13868
13807
|
|
|
13869
|
-
class AddObjectCommand extends KritzelBaseCommand {
|
|
13870
|
-
object;
|
|
13871
|
-
constructor(core, initiator, object, skipHistory = false) {
|
|
13872
|
-
super(core, initiator, skipHistory);
|
|
13873
|
-
this.object = object;
|
|
13874
|
-
}
|
|
13875
|
-
execute() {
|
|
13876
|
-
this._core.store.state.objectsMap.insert(this.object);
|
|
13877
|
-
this._core.addObjectToDatabase(this.object);
|
|
13878
|
-
}
|
|
13879
|
-
undo() {
|
|
13880
|
-
this.object.isMounted = false;
|
|
13881
|
-
this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
|
|
13882
|
-
this._core.deleteObjectFromDatabase(this.object.id);
|
|
13883
|
-
}
|
|
13884
|
-
}
|
|
13885
|
-
|
|
13886
13808
|
class KritzelText extends KritzelBaseObject {
|
|
13887
13809
|
__class__ = 'KritzelText';
|
|
13888
13810
|
fontFamily = 'Arial';
|
|
@@ -13892,7 +13814,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
13892
13814
|
initialHeight = 1;
|
|
13893
13815
|
scale = 1;
|
|
13894
13816
|
scaleFactor = 1;
|
|
13895
|
-
isNew = true;
|
|
13896
13817
|
isDebugInfoVisible = true;
|
|
13897
13818
|
isEditable = true;
|
|
13898
13819
|
isEditing = false;
|
|
@@ -13976,19 +13897,30 @@ class KritzelText extends KritzelBaseObject {
|
|
|
13976
13897
|
}),
|
|
13977
13898
|
editable: () => false,
|
|
13978
13899
|
dispatchTransaction: transaction => {
|
|
13900
|
+
// Apply the transaction to get the new state
|
|
13979
13901
|
const newState = this.editor.state.apply(transaction);
|
|
13902
|
+
// Update the editor state first
|
|
13980
13903
|
this.editor.updateState(newState);
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13904
|
+
// Only update content and adjust size if the document actually changed
|
|
13905
|
+
// AND it's not from a remote source (to prevent infinite loops)
|
|
13906
|
+
if (transaction.docChanged) {
|
|
13907
|
+
this.content = newState.doc.toJSON();
|
|
13908
|
+
this.adjustSizeOnInput();
|
|
13909
|
+
if (!transaction.getMeta('fromRemote')) {
|
|
13910
|
+
// Mark updates as temporary while editing - they'll be consolidated on save
|
|
13911
|
+
this._core.store.state.objectsMap.update(this, { temporary: true });
|
|
13912
|
+
}
|
|
13913
|
+
}
|
|
13984
13914
|
},
|
|
13985
13915
|
});
|
|
13986
13916
|
}
|
|
13987
13917
|
setContent(content) {
|
|
13988
13918
|
this.content = content;
|
|
13989
|
-
if (this.editor) {
|
|
13919
|
+
if (this.editor && content) {
|
|
13990
13920
|
const newDoc = this.editor.state.schema.nodeFromJSON(content);
|
|
13991
13921
|
const tr = this.editor.state.tr.replaceWith(0, this.editor.state.doc.content.size, newDoc.content);
|
|
13922
|
+
// Mark this transaction as coming from remote/external source
|
|
13923
|
+
tr.setMeta('fromRemote', true);
|
|
13992
13924
|
this.editor.dispatch(tr);
|
|
13993
13925
|
}
|
|
13994
13926
|
}
|
|
@@ -14004,8 +13936,8 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14004
13936
|
if (this.rotation !== 0) {
|
|
14005
13937
|
const newTotalWidth = this.totalWidth;
|
|
14006
13938
|
const newTotalHeight = this.totalHeight;
|
|
14007
|
-
const deltaWidth = (newTotalWidth - previousTotalWidth) / 2;
|
|
14008
|
-
const deltaHeight = (newTotalHeight - previousTotalHeight) / 2;
|
|
13939
|
+
const deltaWidth = (newTotalWidth - previousTotalWidth) / 2 / this.scale;
|
|
13940
|
+
const deltaHeight = (newTotalHeight - previousTotalHeight) / 2 / this.scale;
|
|
14009
13941
|
if (deltaWidth !== 0 || deltaHeight !== 0) {
|
|
14010
13942
|
const cos = Math.cos(this.rotation);
|
|
14011
13943
|
const sin = Math.sin(this.rotation);
|
|
@@ -14016,10 +13948,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14016
13948
|
}
|
|
14017
13949
|
}
|
|
14018
13950
|
}
|
|
14019
|
-
if (this._core) {
|
|
14020
|
-
this._core.store.state.objectsMap.update(this);
|
|
14021
|
-
this._core.rerender();
|
|
14022
|
-
}
|
|
14023
13951
|
}
|
|
14024
13952
|
resize(x, y, width, height) {
|
|
14025
13953
|
if (width <= 1 || height <= 1) {
|
|
@@ -14034,6 +13962,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14034
13962
|
this.height = originalHeight * this.scaleFactor;
|
|
14035
13963
|
this.translateX = x;
|
|
14036
13964
|
this.translateY = y;
|
|
13965
|
+
this._core.store.state.objectsMap.update(this);
|
|
14037
13966
|
}
|
|
14038
13967
|
focus(coords) {
|
|
14039
13968
|
if (this.editor) {
|
|
@@ -14055,20 +13984,22 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14055
13984
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
14056
13985
|
this.uneditedObject = this.clone();
|
|
14057
13986
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
14058
|
-
this._core.store.state.activeText = this;
|
|
14059
13987
|
if (this.editor) {
|
|
14060
13988
|
this.editor.setProps({ editable: () => true });
|
|
14061
13989
|
}
|
|
14062
13990
|
this.isEditing = true;
|
|
14063
|
-
if (event) {
|
|
14064
|
-
this.focus({ x: event.clientX, y: event.clientY });
|
|
14065
|
-
}
|
|
14066
|
-
else {
|
|
14067
|
-
this.focus();
|
|
14068
|
-
}
|
|
14069
13991
|
this._core.rerender();
|
|
14070
|
-
requestAnimationFrame(() =>
|
|
14071
|
-
|
|
13992
|
+
requestAnimationFrame(() => {
|
|
13993
|
+
this.adjustSizeOnInput();
|
|
13994
|
+
// Focus after the DOM has been updated
|
|
13995
|
+
if (event) {
|
|
13996
|
+
this.focus({ x: event.clientX, y: event.clientY });
|
|
13997
|
+
}
|
|
13998
|
+
else {
|
|
13999
|
+
this.focus();
|
|
14000
|
+
}
|
|
14001
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
14002
|
+
});
|
|
14072
14003
|
}
|
|
14073
14004
|
save() {
|
|
14074
14005
|
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
@@ -14076,15 +14007,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14076
14007
|
this.editor.setProps({ editable: () => false });
|
|
14077
14008
|
this.editor.dom.blur();
|
|
14078
14009
|
this.isEditing = false;
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
}
|
|
14084
|
-
else {
|
|
14085
|
-
saveCommand = new UpdateObjectCommand(this._core, this, this.uneditedObject, { ...this });
|
|
14086
|
-
}
|
|
14087
|
-
this._core.commandManager.executeCommand(saveCommand);
|
|
14010
|
+
// Consolidate all temporary keystrokes into a single undo item
|
|
14011
|
+
this._core.store.state.objectsMap.consolidateTemporaryItems();
|
|
14012
|
+
// Final update with normal origin
|
|
14013
|
+
this._core.store.state.objectsMap.update(this);
|
|
14088
14014
|
}
|
|
14089
14015
|
handlePointerDown(event) {
|
|
14090
14016
|
if (!this.isEditing) {
|
|
@@ -14122,18 +14048,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14122
14048
|
}
|
|
14123
14049
|
deserialize(object) {
|
|
14124
14050
|
super.deserialize(object);
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
}
|
|
14128
|
-
onExecuteUpdateCommand(updatedProperties) {
|
|
14129
|
-
if ('content' in updatedProperties) {
|
|
14130
|
-
this.setContent(updatedProperties.content);
|
|
14131
|
-
}
|
|
14132
|
-
}
|
|
14133
|
-
onUndoUpdateCommand(previousProperties) {
|
|
14134
|
-
if ('content' in previousProperties && this.editor) {
|
|
14135
|
-
this.setContent(previousProperties.content);
|
|
14051
|
+
if (object.content) {
|
|
14052
|
+
this.setContent(object.content);
|
|
14136
14053
|
}
|
|
14054
|
+
return this;
|
|
14137
14055
|
}
|
|
14138
14056
|
}
|
|
14139
14057
|
|
|
@@ -14174,6 +14092,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
14174
14092
|
options;
|
|
14175
14093
|
isVisible = true;
|
|
14176
14094
|
isDebugInfoVisible = true;
|
|
14095
|
+
isCompleted = false;
|
|
14177
14096
|
_adjustedPoints = null;
|
|
14178
14097
|
get viewBox() {
|
|
14179
14098
|
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
@@ -14224,10 +14143,12 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
14224
14143
|
this.translateX = x;
|
|
14225
14144
|
this.translateY = y;
|
|
14226
14145
|
this._adjustedPoints = null;
|
|
14146
|
+
this._core.store.state.objectsMap.update(this);
|
|
14227
14147
|
}
|
|
14228
14148
|
rotate(value) {
|
|
14229
14149
|
this.rotation = value;
|
|
14230
14150
|
this._adjustedPoints = null;
|
|
14151
|
+
this._core.store.state.objectsMap.update(this);
|
|
14231
14152
|
}
|
|
14232
14153
|
move(startX, startY, endX, endY) {
|
|
14233
14154
|
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
@@ -14235,6 +14156,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
14235
14156
|
this.translateX += deltaX;
|
|
14236
14157
|
this.translateY += deltaY;
|
|
14237
14158
|
this._adjustedPoints = null;
|
|
14159
|
+
this._core.store.state.objectsMap.update(this);
|
|
14238
14160
|
}
|
|
14239
14161
|
hitTest(x, y) {
|
|
14240
14162
|
const halfStroke = this.strokeWidth / this.scale / 2;
|
|
@@ -14532,7 +14454,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14532
14454
|
this._core.store.state.isDrawing = true;
|
|
14533
14455
|
const x = event.clientX - this._core.store.offsetX;
|
|
14534
14456
|
const y = event.clientY - this._core.store.offsetY;
|
|
14535
|
-
|
|
14457
|
+
const path = KritzelPath.create(this._core, {
|
|
14536
14458
|
points: [[x, y]],
|
|
14537
14459
|
translateX: -this._core.store.state.translateX,
|
|
14538
14460
|
translateY: -this._core.store.state.translateY,
|
|
@@ -14540,6 +14462,8 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14540
14462
|
fill: this.color,
|
|
14541
14463
|
strokeWidth: this.size,
|
|
14542
14464
|
});
|
|
14465
|
+
path.isCompleted = false;
|
|
14466
|
+
this._core.store.state.objectsMap.insert(path);
|
|
14543
14467
|
}
|
|
14544
14468
|
}
|
|
14545
14469
|
if (event.pointerType === 'touch') {
|
|
@@ -14548,7 +14472,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14548
14472
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
14549
14473
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
14550
14474
|
this._core.store.state.isDrawing = true;
|
|
14551
|
-
|
|
14475
|
+
const path = KritzelPath.create(this._core, {
|
|
14552
14476
|
points: [[x, y]],
|
|
14553
14477
|
translateX: -this._core.store.state.translateX,
|
|
14554
14478
|
translateY: -this._core.store.state.translateY,
|
|
@@ -14556,7 +14480,8 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14556
14480
|
fill: this.color,
|
|
14557
14481
|
strokeWidth: this.size,
|
|
14558
14482
|
});
|
|
14559
|
-
|
|
14483
|
+
path.isCompleted = false;
|
|
14484
|
+
this._core.store.state.objectsMap.insert(path);
|
|
14560
14485
|
}
|
|
14561
14486
|
}
|
|
14562
14487
|
}
|
|
@@ -14566,33 +14491,45 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14566
14491
|
}
|
|
14567
14492
|
if (event.pointerType === 'mouse') {
|
|
14568
14493
|
if (this._core.store.state.isDrawing) {
|
|
14569
|
-
const
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14494
|
+
const currentPath = this._core.store.currentPath;
|
|
14495
|
+
if (currentPath) {
|
|
14496
|
+
const x = event.clientX - this._core.store.offsetX;
|
|
14497
|
+
const y = event.clientY - this._core.store.offsetY;
|
|
14498
|
+
const updatedPath = KritzelPath.create(this._core, {
|
|
14499
|
+
points: [...currentPath.points, [x, y]],
|
|
14500
|
+
translateX: -this._core.store.state.translateX,
|
|
14501
|
+
translateY: -this._core.store.state.translateY,
|
|
14502
|
+
scale: this._core.store.state.scale,
|
|
14503
|
+
fill: this.color,
|
|
14504
|
+
strokeWidth: this.size,
|
|
14505
|
+
});
|
|
14506
|
+
updatedPath.id = currentPath.id;
|
|
14507
|
+
updatedPath.workspaceId = currentPath.workspaceId;
|
|
14508
|
+
updatedPath.isCompleted = false;
|
|
14509
|
+
this._core.store.state.objectsMap.update(updatedPath);
|
|
14510
|
+
}
|
|
14580
14511
|
}
|
|
14581
14512
|
}
|
|
14582
14513
|
if (event.pointerType === 'touch') {
|
|
14583
14514
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
14584
14515
|
if (activePointers.length === 1) {
|
|
14585
|
-
const
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14516
|
+
const currentPath = this._core.store.currentPath;
|
|
14517
|
+
if (currentPath) {
|
|
14518
|
+
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
14519
|
+
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
14520
|
+
const updatedPath = KritzelPath.create(this._core, {
|
|
14521
|
+
points: [...currentPath.points, [x, y]],
|
|
14522
|
+
translateX: -this._core.store.state.translateX,
|
|
14523
|
+
translateY: -this._core.store.state.translateY,
|
|
14524
|
+
scale: this._core.store.state.scale,
|
|
14525
|
+
fill: this.color,
|
|
14526
|
+
strokeWidth: this.size,
|
|
14527
|
+
});
|
|
14528
|
+
updatedPath.id = currentPath.id;
|
|
14529
|
+
updatedPath.workspaceId = currentPath.workspaceId;
|
|
14530
|
+
updatedPath.isCompleted = false;
|
|
14531
|
+
this._core.store.state.objectsMap.update(updatedPath);
|
|
14532
|
+
}
|
|
14596
14533
|
}
|
|
14597
14534
|
}
|
|
14598
14535
|
}
|
|
@@ -14603,26 +14540,23 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
14603
14540
|
if (event.pointerType === 'mouse') {
|
|
14604
14541
|
if (this._core.store.state.isDrawing) {
|
|
14605
14542
|
this._core.store.state.isDrawing = false;
|
|
14606
|
-
|
|
14607
|
-
|
|
14543
|
+
const currentPath = this._core.store.currentPath;
|
|
14544
|
+
if (currentPath) {
|
|
14545
|
+
currentPath.isCompleted = true;
|
|
14608
14546
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
14609
|
-
this._core.store.state.currentPath
|
|
14610
|
-
this._core.commandManager.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
|
|
14547
|
+
this._core.store.state.objectsMap.update(currentPath);
|
|
14611
14548
|
}
|
|
14612
|
-
this._core.store.state.currentPath = undefined;
|
|
14613
14549
|
}
|
|
14614
14550
|
}
|
|
14615
14551
|
if (event.pointerType === 'touch') {
|
|
14616
14552
|
if (this._core.store.state.isDrawing) {
|
|
14617
14553
|
this._core.store.state.isDrawing = false;
|
|
14618
|
-
|
|
14619
|
-
|
|
14554
|
+
const currentPath = this._core.store.currentPath;
|
|
14555
|
+
if (currentPath) {
|
|
14556
|
+
currentPath.isCompleted = true;
|
|
14620
14557
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
14621
|
-
this._core.store.state.currentPath
|
|
14622
|
-
this._core.commandManager.executeCommand(new AddObjectCommand(this._core, this, currentPath));
|
|
14558
|
+
this._core.store.state.objectsMap.update(currentPath);
|
|
14623
14559
|
}
|
|
14624
|
-
this._core.store.state.currentPath = undefined;
|
|
14625
|
-
this._core.rerender();
|
|
14626
14560
|
}
|
|
14627
14561
|
}
|
|
14628
14562
|
}
|
|
@@ -14660,18 +14594,17 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14660
14594
|
const path = event.composedPath().slice(1);
|
|
14661
14595
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
14662
14596
|
const object = this._core.findObjectById(objectElement?.id);
|
|
14663
|
-
|
|
14664
|
-
|
|
14597
|
+
const activeText = this._core.store.activeText;
|
|
14598
|
+
if (activeText === null && object instanceof KritzelText) {
|
|
14665
14599
|
object.edit(event);
|
|
14666
14600
|
return;
|
|
14667
14601
|
}
|
|
14668
|
-
if (
|
|
14669
|
-
|
|
14670
|
-
this._core.store.state.activeText = object;
|
|
14602
|
+
if (activeText !== null && object instanceof KritzelText) {
|
|
14603
|
+
activeText.save();
|
|
14671
14604
|
object.edit(event);
|
|
14672
14605
|
return;
|
|
14673
14606
|
}
|
|
14674
|
-
if (
|
|
14607
|
+
if (activeText !== null && object instanceof KritzelText === false) {
|
|
14675
14608
|
this._core.resetActiveText();
|
|
14676
14609
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
14677
14610
|
return;
|
|
@@ -14682,12 +14615,10 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14682
14615
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
14683
14616
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
14684
14617
|
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
14685
|
-
text.isNew = true;
|
|
14686
14618
|
text.fontColor = this.fontColor;
|
|
14687
14619
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
14688
14620
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
14689
14621
|
text.zIndex = this._core.store.currentZIndex;
|
|
14690
|
-
this._core.store.state.activeText = text;
|
|
14691
14622
|
this._core.store.state.objectsMap.insert(text);
|
|
14692
14623
|
this._core.rerender();
|
|
14693
14624
|
requestAnimationFrame(() => text.edit(event));
|
|
@@ -14697,18 +14628,17 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14697
14628
|
const path = event.composedPath().slice(1);
|
|
14698
14629
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
14699
14630
|
const object = this._core.findObjectById(objectElement?.id);
|
|
14700
|
-
|
|
14701
|
-
|
|
14631
|
+
const activeText = this._core.store.activeText;
|
|
14632
|
+
if (activeText === null && object instanceof KritzelText) {
|
|
14702
14633
|
object.edit(event);
|
|
14703
14634
|
return;
|
|
14704
14635
|
}
|
|
14705
|
-
if (
|
|
14706
|
-
|
|
14707
|
-
this._core.store.state.activeText = object;
|
|
14636
|
+
if (activeText !== null && object instanceof KritzelText) {
|
|
14637
|
+
activeText.save();
|
|
14708
14638
|
object.edit(event);
|
|
14709
14639
|
return;
|
|
14710
14640
|
}
|
|
14711
|
-
if (
|
|
14641
|
+
if (activeText !== null && object instanceof KritzelText === false) {
|
|
14712
14642
|
this._core.resetActiveText();
|
|
14713
14643
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
14714
14644
|
return;
|
|
@@ -14720,12 +14650,10 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14720
14650
|
const clientX = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
14721
14651
|
const clientY = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
14722
14652
|
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
14723
|
-
text.isNew = true;
|
|
14724
14653
|
text.fontColor = this.fontColor;
|
|
14725
14654
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
14726
14655
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
14727
14656
|
text.zIndex = this._core.store.currentZIndex;
|
|
14728
|
-
this._core.store.state.activeText = text;
|
|
14729
14657
|
this._core.store.state.objectsMap.insert(text);
|
|
14730
14658
|
this._core.rerender();
|
|
14731
14659
|
}
|
|
@@ -14735,16 +14663,16 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14735
14663
|
event.preventDefault();
|
|
14736
14664
|
}
|
|
14737
14665
|
if (event.pointerType === 'mouse') {
|
|
14738
|
-
this._core.store.
|
|
14666
|
+
this._core.store.activeText?.edit(event);
|
|
14739
14667
|
}
|
|
14740
14668
|
if (event.pointerType === 'touch') {
|
|
14741
|
-
this._core.store.
|
|
14669
|
+
this._core.store.activeText?.edit(event);
|
|
14742
14670
|
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
14743
14671
|
}
|
|
14744
14672
|
}
|
|
14745
14673
|
}
|
|
14746
14674
|
|
|
14747
|
-
export {
|
|
14748
|
-
//# sourceMappingURL=p-
|
|
14675
|
+
export { KritzelText as K, KritzelPath as a, KritzelBrushTool as b, KritzelTextTool as c, KritzelKeyboardHelper as d, KritzelBaseObject as e, KritzelBaseTool as f, KritzelEventHelper as g, KritzelToolRegistry as h };
|
|
14676
|
+
//# sourceMappingURL=p-COGwCbe1.js.map
|
|
14749
14677
|
|
|
14750
|
-
//# sourceMappingURL=p-
|
|
14678
|
+
//# sourceMappingURL=p-COGwCbe1.js.map
|