diff --git a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--512ac--Tailed-Arrows-after-adding-removing-of-tails-3-chromium-linux.png b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--512ac--Tailed-Arrows-after-adding-removing-of-tails-3-chromium-linux.png index d9a066fba2..b0b9db074d 100644 Binary files a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--512ac--Tailed-Arrows-after-adding-removing-of-tails-3-chromium-linux.png and b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--512ac--Tailed-Arrows-after-adding-removing-of-tails-3-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--92c26-e-length-1-4-after-adding-removing-of-tails-4-chromium-linux.png b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--92c26-e-length-1-4-after-adding-removing-of-tails-4-chromium-linux.png index db919ff90d..685c218aac 100644 Binary files a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--92c26-e-length-1-4-after-adding-removing-of-tails-4-chromium-linux.png and b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--92c26-e-length-1-4-after-adding-removing-of-tails-4-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--a46e0-with-two-tails-after-adding-removing-of-tails-3-chromium-linux.png b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--a46e0-with-two-tails-after-adding-removing-of-tails-3-chromium-linux.png index 36700ac615..191e740847 100644 Binary files a/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--a46e0-with-two-tails-after-adding-removing-of-tails-3-chromium-linux.png and b/ketcher-autotests/tests/Reactions/Reaction-tools/Multi-Tailed-Arrow-Tool/multi-tailed-arrow-tool.spec.ts-snapshots/Multi-Tailed-Arrow-Tool-Verify-that-Undo-Redo--a46e0-with-two-tails-after-adding-removing-of-tails-3-chromium-linux.png differ diff --git a/packages/ketcher-core/src/application/editor/operations/multitailArrow/multitailArrowAddRemoveTail.ts b/packages/ketcher-core/src/application/editor/operations/multitailArrow/multitailArrowAddRemoveTail.ts index f3667da22c..eea90946c5 100644 --- a/packages/ketcher-core/src/application/editor/operations/multitailArrow/multitailArrowAddRemoveTail.ts +++ b/packages/ketcher-core/src/application/editor/operations/multitailArrow/multitailArrowAddRemoveTail.ts @@ -2,9 +2,14 @@ import { BaseOperation } from 'application/editor/operations/base'; import { OperationType } from 'application/editor'; import { ReStruct } from 'application/render'; +import { FixedPrecisionCoordinates } from 'domain/entities'; export class MultitailArrowAddTail extends BaseOperation { - constructor(private itemId: number, private tailId?: number) { + constructor( + private itemId: number, + private tailId?: number, + private coordinate?: FixedPrecisionCoordinates, + ) { super(OperationType.MULTITAIL_ARROW_ADD_TAIL); } @@ -15,8 +20,7 @@ export class MultitailArrowAddTail extends BaseOperation { if (!reMultitailArrow || !multitailArrow) { return; } - - this.tailId = multitailArrow.addTail(this.tailId); + this.tailId = multitailArrow.addTail(this.tailId, this.coordinate); BaseOperation.invalidateItem(reStruct, 'multitailArrows', this.itemId, 1); } @@ -26,6 +30,7 @@ export class MultitailArrowAddTail extends BaseOperation { } export class MultitailArrowRemoveTail extends BaseOperation { + private coordinate?: FixedPrecisionCoordinates; constructor(private itemId: number, private tailId: number) { super(OperationType.MULTITAIL_ARROW_REMOVE_TAIL); } @@ -33,8 +38,9 @@ export class MultitailArrowRemoveTail extends BaseOperation { execute(reStruct: ReStruct) { const reMultitailArrow = reStruct.multitailArrows.get(this.itemId); const multitailArrow = reStruct.molecule.multitailArrows.get(this.itemId); + this.coordinate = multitailArrow?.getTailCoordinate(this.tailId); - if (!reMultitailArrow || !multitailArrow) { + if (!reMultitailArrow || !multitailArrow || !this.coordinate) { return; } @@ -43,6 +49,6 @@ export class MultitailArrowRemoveTail extends BaseOperation { } invert(): BaseOperation { - return new MultitailArrowAddTail(this.itemId, this.tailId); + return new MultitailArrowAddTail(this.itemId, this.tailId, this.coordinate); } } diff --git a/packages/ketcher-core/src/domain/entities/index.ts b/packages/ketcher-core/src/domain/entities/index.ts index 5d7f191fa8..e97692bb57 100644 --- a/packages/ketcher-core/src/domain/entities/index.ts +++ b/packages/ketcher-core/src/domain/entities/index.ts @@ -17,6 +17,7 @@ export * from './atom'; export * from './atomList'; export * from './bond'; +export * from './fixedPrecision'; export * from './fragment'; export * from './functionalGroup'; export * from './halfBond'; diff --git a/packages/ketcher-core/src/domain/entities/multitailArrow.ts b/packages/ketcher-core/src/domain/entities/multitailArrow.ts index cae98c39ce..76aaa38d9f 100644 --- a/packages/ketcher-core/src/domain/entities/multitailArrow.ts +++ b/packages/ketcher-core/src/domain/entities/multitailArrow.ts @@ -3,7 +3,7 @@ import { Vec2 } from 'domain/entities/vec2'; import { Pool } from 'domain/entities/pool'; import { getNodeWithInvertedYCoord, KetFileNode } from 'domain/serializers'; import { MULTITAIL_ARROW_SERIALIZE_KEY } from 'domain/constants'; -import { FixedPrecisionCoordinates } from 'domain/entities/fixedPrecision'; +import { FixedPrecisionCoordinates } from 'domain/entities'; export type Line = [Vec2, Vec2]; @@ -365,7 +365,16 @@ export class MultitailArrow extends BaseMicromoleculeEntity { ); } - addTail(id?: number): number { + getTailCoordinate(id: number): FixedPrecisionCoordinates | undefined { + return this.tailsYOffset.get(id); + } + + addTail(id?: number, coordinate?: FixedPrecisionCoordinates): number { + // Coordinate can only be present for undo\redo + if (typeof id === 'number' && coordinate) { + this.tailsYOffset.set(id, coordinate); + return id; + } const { center, distance } = this.getTailsMaxDistance(); if (!MultitailArrow.canAddTail(distance)) { throw new Error('Cannot add tail because no minimal distance found'); diff --git a/packages/ketcher-react/src/script/ui/state/editor/index.js b/packages/ketcher-react/src/script/ui/state/editor/index.js index ca47b2090b..7149d2f9d4 100644 --- a/packages/ketcher-react/src/script/ui/state/editor/index.js +++ b/packages/ketcher-react/src/script/ui/state/editor/index.js @@ -49,7 +49,7 @@ export default function initEditor(dispatch, getState) { // eslint-disable-line no-shadow const state = global.currentState; const activeTool = state.actionState.activeTool.tool; - if (activeTool === 'select') return; + if (activeTool === 'select' && !force) return; const selectMode = state.toolbar.visibleTools.select; const resetOption = state.options.settings.resetToSelect; if (resetOption === true || resetOption === activeTool || force === true)