Skip to content

Commit

Permalink
Merge branch '#1920-abbreviation-is-expanded-after-adding-to-the-canv…
Browse files Browse the repository at this point in the history
…as' into #1921-incorrect-info-panel-behavior
  • Loading branch information
KonstantinEpam23 committed Dec 15, 2022
2 parents c1fc74d + e310dcf commit d2200e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ export class SGroup {
static isSaltOrSolvent(moleculeName: string): boolean {
const saltsAndSolventsProvider = SaltsAndSolventsProvider.getInstance()
const saltsAndSolvents = saltsAndSolventsProvider.getSaltsAndSolventsList()
return saltsAndSolvents.some(({ name }) => name === moleculeName)
return saltsAndSolvents.some(
({ name, abbreviation }) =>
name === moleculeName || moleculeName === abbreviation
)
}

static isAtomInSaltOrSolvent(
Expand Down
2 changes: 2 additions & 0 deletions packages/ketcher-core/src/domain/entities/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class Struct {
frags: Pool<Fragment | null>
rgroups: Pool<RGroup>
name: string
abbreviation?: string
sGroupForest: SGroupForest
simpleObjects: Pool<SimpleObject>
texts: Pool<Text>
Expand All @@ -78,6 +79,7 @@ export class Struct {
this.frags = new Pool<Fragment>()
this.rgroups = new Pool<RGroup>()
this.name = ''
this.abbreviation = ''
this.sGroupForest = new SGroupForest()
this.simpleObjects = new Pool<SimpleObject>()
this.texts = new Pool<Text>()
Expand Down
6 changes: 4 additions & 2 deletions packages/ketcher-react/src/script/editor/tool/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class BondTool {
}
}
// don't rotate the bond if the distance between the start and end point is too small
if (dist > 0.3)
if (dist > 0.3) {
dragCtx.action = fromBondAddition(
rnd.ctab,
this.bondProps,
Expand All @@ -246,7 +246,9 @@ class BondTool {
beginPos,
endPos
)[0]
else delete dragCtx.action
} else {
delete dragCtx.action
}
this.editor.update(dragCtx.action, true)
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export function initSaltsAndSolventsTemplates(baseUrl: string) {
const text = await prefetchStatic(url)
const templates = sdfSerializer.deserialize(text)
const saltsAndSolvents = templates.reduce(
(acc: Struct[], { struct }) => [...acc, struct],
(acc: Struct[], { struct, props }) => {
acc.push({ ...struct, abbreviation: props.abbreviation } as Struct)
return acc
},
[]
)
saltsAndSolventsProvider.setSaltsAndSolventsList(saltsAndSolvents)
Expand Down

0 comments on commit d2200e9

Please sign in to comment.