Skip to content

Commit

Permalink
Merge branch 'master' into #736-block-some-tools-if-they-are-applied-…
Browse files Browse the repository at this point in the history
…to-FG
  • Loading branch information
Kirill Kapytov authored and Kirill Kapytov committed Oct 20, 2021
2 parents f235308 + 7408aa1 commit b0f856e
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 100 deletions.
5 changes: 5 additions & 0 deletions packages/ketcher-core/src/application/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

import utils from './shared/utils'

// TODO: delete it
export const fracAngle = utils.fracAngle
export * from './operations'
export * from './actions'
export * from './shared/constants'
Expand Down
4 changes: 2 additions & 2 deletions packages/ketcher-core/src/application/render/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
***************************************************************************/

import { Vec2 } from 'domain/entities'
import utils from '../editor/shared/utils'

function defaultOptions(opt) {
const scaleFactor = opt.scale || 100

// TODO: test if rotation step is working now
// if (opt.rotationStep) utils.setFracAngle(opt.rotationStep)
if (opt.rotationStep) utils.setFracAngle(opt.rotationStep)

const labelFontSize = Math.ceil(1.9 * (scaleFactor / 6))
const subFontSize = Math.ceil(0.7 * labelFontSize)
Expand Down
1 change: 0 additions & 1 deletion packages/ketcher-react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const config = {
],
external: [
'url',
/@babel\/runtime/,
'remark-parse',
'unified',
'asap',
Expand Down
15 changes: 2 additions & 13 deletions packages/ketcher-react/src/script/editor/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,15 @@
* limitations under the License.
***************************************************************************/

import { Vec2 } from 'ketcher-core'
import { inRange } from 'lodash'

let FRAC = Math.PI / 12 // '15º'
import { Vec2, fracAngle } from 'ketcher-core'

function setFracAngle(angle) {
FRAC = (Math.PI / 180) * angle
}
import { inRange } from 'lodash'

function calcAngle(pos0, pos1) {
const v = Vec2.diff(pos1, pos0)
return Math.atan2(v.y, v.x)
}

function fracAngle(angle, angle2) {
if (angle2) angle = calcAngle(angle, angle2)
return Math.round(angle / FRAC) * FRAC
}

function calcNewAtomPos(pos0, pos1, ctrlKey) {
const v = new Vec2(1, 0).rotate(
ctrlKey ? calcAngle(pos0, pos1) : fracAngle(pos0, pos1)
Expand Down Expand Up @@ -74,6 +64,5 @@ export default {
fracAngle,
calcNewAtomPos,
degrees,
setFracAngle,
mergeBondsParams
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
outline: none;
}

height: 312px;
display: flex;
flex-wrap: wrap;
overflow: scroll;

.scrollbar();
}
.struct {
Expand All @@ -45,9 +50,7 @@
background: @form-hover-background;
}
}
.tr {
display: flex;
}

.td {
position: relative;
&::before {
Expand Down
110 changes: 43 additions & 67 deletions packages/ketcher-react/src/script/ui/dialog/template/TemplateTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
***************************************************************************/

import { AutoSizer, List } from 'react-virtualized'

import { FC } from 'react'
import { Struct } from 'ketcher-core'
import StructRender from '../../component/structrender'
Expand Down Expand Up @@ -73,73 +71,51 @@ const TemplateTable: FC<TemplateTableProps> = props => {
height: `${ITEM_SIZE.height}px`
}

return (
return !ITEMS_COUNT ? (
<EmptySearchResult textInfo="No items found" />
) : (
<div className={classes.table} style={{ minWidth: ITEM_SIZE.width }}>
<AutoSizer>
{({ height, width }) => {
const itemsPerRow = Math.floor(width / ITEM_SIZE.width)
const rowCount = Math.ceil(ITEMS_COUNT / itemsPerRow)

return !ITEMS_COUNT ? (
<EmptySearchResult textInfo="No items found" />
) : (
<List
className={classes.tableContent}
width={width}
height={height}
rowCount={rowCount}
rowHeight={ITEM_SIZE.height}
rowRenderer={({ index, key, style }) => {
const fromIndex = index * itemsPerRow
const toIndex = Math.min(fromIndex + itemsPerRow, ITEMS_COUNT)
const items = templates.slice(fromIndex, toIndex)

return (
<div className={classes.tr} key={key} style={style}>
{items.map((tmpl, i) => (
<div
className={
tmpl === selected
? `${classes.td} ${classes.selected}`
: classes.td
}
title={greekify(tmplName(tmpl, i))}
key={
tmpl.struct.name !== selected?.struct.name
? tmpl.struct.name
: `${tmpl.struct.name}_selected`
}
style={tmplStyles}>
<RenderTmpl
tmpl={tmpl}
className={classes.struct}
onClick={() => onSelect(tmpl)}
/>
<div className={classes.btnContainer}>
{tmpl.props.group === 'User Templates' && (
<button
className={classes.deleteButton}
onClick={() => onDelete!(tmpl)}>
Delete
</button>
)}
{tmpl.props.group !== 'Functional Groups' && (
<button
className={classes.attachButton}
onClick={() => onAttach!(tmpl)}>
Edit
</button>
)}
</div>
</div>
))}
</div>
)
}}
/>
<div className={classes.tableContent}>
{templates.map((tmpl, i) => {
return (
<div
className={
tmpl === selected
? `${classes.td} ${classes.selected}`
: classes.td
}
title={greekify(tmplName(tmpl, i))}
key={
tmpl.struct.name !== selected?.struct.name
? `${tmpl.struct.name}_${i}`
: `${tmpl.struct.name}_selected`
}
style={tmplStyles}>
<RenderTmpl
tmpl={tmpl}
className={classes.struct}
onClick={() => onSelect(tmpl)}
/>
<div className={classes.btnContainer}>
{tmpl.props.group === 'User Templates' && (
<button
className={classes.deleteButton}
onClick={() => onDelete!(tmpl)}>
Delete
</button>
)}
{tmpl.props.group !== 'Functional Groups' && (
<button
className={classes.attachButton}
onClick={() => onAttach!(tmpl)}>
Edit
</button>
)}
</div>
</div>
)
}}
</AutoSizer>
})}
</div>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

.measureLog {
top: 0;
left: 0;
right: 0;
}
}

Expand All @@ -50,7 +50,8 @@
position: absolute;
background-color: white;
border: @border-color 1px solid;
border-radius: 5px 0;
border-radius: 0 5px;
min-width: 8em;
height: 1.2em;
padding: 0.3em;
text-align: center;
Expand Down
1 change: 0 additions & 1 deletion packages/ketcher-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-visualizer": "^4.2.0",
"rollup-plugin-web-worker-loader": "^1.6.0",
Expand Down
23 changes: 12 additions & 11 deletions packages/ketcher-standalone/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import babel from '@rollup/plugin-babel'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import cleanup from 'rollup-plugin-cleanup'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import del from 'rollup-plugin-delete'
import typescript from 'rollup-plugin-typescript2'
import cleanup from 'rollup-plugin-cleanup'
import strip from '@rollup/plugin-strip'
import webWorkerLoader from 'rollup-plugin-web-worker-loader'
import json from '@rollup/plugin-json'
import nodePolyfills from 'rollup-plugin-node-polyfills'
import pkg from './package.json'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import strip from '@rollup/plugin-strip'
import typescript from 'rollup-plugin-typescript2'
import webWorkerLoader from 'rollup-plugin-web-worker-loader'

const mode = {
PRODUCTION: 'production',
Expand Down Expand Up @@ -41,21 +40,23 @@ const config = {
'object-assign',
'unist-util-visit',
'unist-util-visit-parents',
'xtend'
'xtend',
'ketcher-core',
/@babel\/runtime/
],
plugins: [
del({
targets: 'dist/*',
runOnce: true
}),
peerDepsExternal(),
nodePolyfills(),
resolve({ extensions, preferBuiltins: false }),
commonjs(),
webWorkerLoader({
extensions,
sourcemap: false,
targetPlatform: 'browser'
targetPlatform: 'browser',
external: ['@babel/runtime']
}),
replace(
{
Expand Down

0 comments on commit b0f856e

Please sign in to comment.