Skip to content

Commit

Permalink
Merge branch 'master' into #540-calculate-values-inputs-do-not-handle…
Browse files Browse the repository at this point in the history
…-errors
  • Loading branch information
Kirill Kapytov authored and Kirill Kapytov committed Oct 7, 2021
2 parents d2a1b49 + 42eb8f7 commit 3bd7a21
Show file tree
Hide file tree
Showing 5 changed files with 1,239 additions and 59 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ jobs:
- name: Install Dependencies
run: yarn install

- name: Run audit
run: npx audit-ci --critical

- name: Run build
run: npx cross-env CI=false yarn build

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "yarn workspaces run test",
"serve:remote": "cd example && yarn serve:remote",
"serve:standalone": "cd example && yarn serve:standalone",
"serve": "run-p serve:*"
"serve": "run-p serve:*",
"audit:fix": "yarn-audit-fix"
},
"devDependencies": {
"@babel/core": "^7.12.3",
Expand Down Expand Up @@ -40,7 +41,8 @@
"stylelint-config-recommended-scss": "^4.3.0",
"stylelint-config-standard": "^22.0.0",
"stylelint-prettier": "^1.1.2",
"stylelint-scss": "^3.20.1"
"stylelint-scss": "^3.20.1",
"yarn-audit-fix": "^7.0.8"
},
"husky": {
"hooks": {
Expand Down
22 changes: 18 additions & 4 deletions packages/ketcher-core/src/domain/entities/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ export class Struct {
})

fidMap.forEach((newfid, oldfid) => {
const frags = JSON.parse(JSON.stringify(this.frags.get(oldfid)))
const fragment = this.frags.get(oldfid)

if (frags && Object.keys(frags).length !== 0) {
// TODO: delete type check
if (fragment && fragment instanceof Fragment) {
cp.frags.set(newfid, this.frags.get(oldfid)!.clone(aidMap!)) // clone Fragments
}
})
Expand Down Expand Up @@ -534,8 +535,15 @@ export class Struct {
max: pp
}
} else {
bb.min = Vec2.min(bb.min, pp)
bb.max = Vec2.max(bb.max, pp)
if (pp instanceof Array) {
pp.forEach(vec => {
bb.min = Vec2.min(bb.min, vec)
bb.max = Vec2.max(bb.max, vec)
})
} else {
bb.min = Vec2.min(bb.min, pp)
bb.max = Vec2.max(bb.max, pp)
}
}
}

Expand All @@ -551,6 +559,12 @@ export class Struct {
this.rxnArrows.forEach(item => {
extend(item.pos)
})
this.simpleObjects.forEach(item => {
extend(item.pos)
})
this.texts.forEach(item => {
extend(item.position)
})
}
if (!bb && global) {
bb = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ function structNormalization(struct) {
rxnPlus.pp = rxnPlus.pp.sub(cbb.min)
})

normStruct.simpleObjects.forEach(simpleObject => {
simpleObject.pos = simpleObject.pos.map(p => p.sub(cbb.min))
})

normStruct.texts.forEach(text => {
text.position = text.position.sub(cbb.min)
})

return normStruct
}

Expand Down
Loading

0 comments on commit 3bd7a21

Please sign in to comment.