-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2423 Hotkeys for atoms don't work on Functional Groups and Salts abb…
…reviations (#2580) * #2423 fix hotkey for functional groups * #2423 moved logic with sgroup to handleHotkeysOverItem * #2423 fix imports * #2513 fix bug with SRU polymer * #2513 move logic to Atom Tool * #2513 replace functionalGroup by hovering * #2513 fix issue when atom doesn't exist
- Loading branch information
1 parent
c93a6f5
commit 8de0ba6
Showing
5 changed files
with
85 additions
and
8 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
36 changes: 36 additions & 0 deletions
36
packages/ketcher-react/src/script/editor/tool/helper/deleteFunctionalGroups.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,36 @@ | ||
import { | ||
FunctionalGroup, | ||
SGroup, | ||
fromSgroupDeletion, | ||
fromFragmentDeletion, | ||
ReStruct, | ||
Action | ||
} from 'ketcher-core' | ||
|
||
export function deleteFunctionalGroups( | ||
sGroupsId: number[], | ||
struct: ReStruct, | ||
action: Action | ||
): number[] { | ||
const deletedAtoms: number[] = [] | ||
const functionalGroups = struct.molecule.functionalGroups | ||
const sgroups = struct.sgroups | ||
sGroupsId.forEach((sGroupId) => { | ||
const sGroupItem = sgroups.get(sGroupId)?.item | ||
if ( | ||
FunctionalGroup.isContractedFunctionalGroup(sGroupId, functionalGroups) | ||
) { | ||
const atomsWithoutAttachmentPoint = | ||
SGroup.getAtomsSGroupWithoutAttachmentPoint(sGroupItem, struct.molecule) | ||
deletedAtoms.push(...atomsWithoutAttachmentPoint) | ||
action.mergeWith(fromSgroupDeletion(struct, sGroupId)) | ||
action.mergeWith( | ||
fromFragmentDeletion(struct, { | ||
atoms: atomsWithoutAttachmentPoint, | ||
bonds: SGroup.getBonds(struct, sGroupItem) | ||
}) | ||
) | ||
} | ||
}) | ||
return deletedAtoms | ||
} |
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