-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5104 - save\load to ket and tails add\remove
- Loading branch information
1 parent
3edb26c
commit 4c5e894
Showing
44 changed files
with
740 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/ketcher-core/src/application/editor/operations/multitailArrow/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './multitailArrowAddRemoveTail'; | ||
export * from './multitailArrowMove'; | ||
export * from './multitailArrowUpsertDelete'; |
48 changes: 48 additions & 0 deletions
48
...cher-core/src/application/editor/operations/multitailArrow/multitailArrowAddRemoveTail.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable @typescript-eslint/no-use-before-define,@typescript-eslint/no-non-null-assertion */ | ||
import { BaseOperation } from 'application/editor/operations/base'; | ||
import { OperationType } from 'application/editor'; | ||
import { ReStruct } from 'application/render'; | ||
|
||
export class MultitailArrowAddTail extends BaseOperation { | ||
constructor(private itemId: number, private tailId?: number) { | ||
super(OperationType.MULTITAIL_ARROW_ADD_TAIL); | ||
} | ||
|
||
execute(reStruct: ReStruct) { | ||
const reMultitailArrow = reStruct.multitailArrows.get(this.itemId); | ||
const multitailArrow = reStruct.molecule.multitailArrows.get(this.itemId); | ||
|
||
if (!reMultitailArrow || !multitailArrow) { | ||
return; | ||
} | ||
|
||
this.tailId = multitailArrow.addTail(this.tailId); | ||
BaseOperation.invalidateItem(reStruct, 'multitailArrows', this.itemId, 1); | ||
} | ||
|
||
invert() { | ||
return new MultitailArrowRemoveTail(this.itemId, this.tailId!); | ||
} | ||
} | ||
|
||
export class MultitailArrowRemoveTail extends BaseOperation { | ||
constructor(private itemId: number, private tailId: number) { | ||
super(OperationType.MULTITAIL_ARROW_REMOVE_TAIL); | ||
} | ||
|
||
execute(reStruct: ReStruct) { | ||
const reMultitailArrow = reStruct.multitailArrows.get(this.itemId); | ||
const multitailArrow = reStruct.molecule.multitailArrows.get(this.itemId); | ||
|
||
if (!reMultitailArrow || !multitailArrow) { | ||
return; | ||
} | ||
|
||
multitailArrow.removeTail(this.tailId); | ||
BaseOperation.invalidateItem(reStruct, 'multitailArrows', this.itemId, 1); | ||
} | ||
|
||
invert(): BaseOperation { | ||
return new MultitailArrowAddTail(this.itemId, this.tailId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const MULTITAIL_ARROW_KEY = 'multitailArrows'; | ||
|
||
export const MULTITAIL_ARROW_TOOL_NAME = 'reaction-arrow-multitail'; | ||
|
||
export const MULTITAIL_ARROW_SERIALIZE_KEY = 'multi-tailed-arrow'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.