Skip to content

Commit

Permalink
#113 Ketcher Release Regression (#114)
Browse files Browse the repository at this point in the history
- add support of table for *.md
- add .env file
- ignore error if server is not set
- fix getState() error while copy/paste structure
- extract combobox styles into separate object
- fix adding new templates
  • Loading branch information
AndreiMazol authored Nov 24, 2020
1 parent fcfc296 commit eff12d9
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 26 deletions.
1 change: 1 addition & 0 deletions example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_API_PATH=
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '@ketcher/react/dist/index.css'
const App = () => {
return (
<div>
<Editor staticResourcesUrl={process.env.PUBLIC_URL} apiPath={''} />
<Editor staticResourcesUrl={process.env.PUBLIC_URL} apiPath={process.env.REACT_APP_API_PATH} />
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"regenerator-runtime": "^0.13.7",
"remark-gfm": "^1.0.0",
"remark-parse": "^9.0.0",
"replace": "^1.2.0",
"reselect": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/script/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function api(base, defaultOptions) {
imagoVersions: res['imago_versions']
}))
.catch(() => {
throw Error('Server is not compatible')
//TODO: add error handler
})

function request(method, url, data, headers) {
Expand Down
9 changes: 4 additions & 5 deletions src/script/ui/component/form/combobox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ class ComboBox extends Component {

render() {
const { value, type = 'text', schema } = this.props

const suggestList = schema.enumNames
.filter(item => item !== value)
.map(item => <li onMouseDown={this.updateInput}>{item}</li>)

const suggestListStyles = {
display: this.state.suggestsHidden ? 'none' : 'block'
}
return (
<div>
<input
Expand All @@ -60,9 +61,7 @@ class ComboBox extends Component {
autoComplete="off"
/>
{suggestList.length !== 0 ? (
<ui
className="suggestList"
style={`display: ${this.state.suggestsHidden ? 'none' : 'block'}`}>
<ui className="suggestList" style={suggestListStyles}>
{suggestList}
</ui>
) : (
Expand Down
4 changes: 2 additions & 2 deletions src/script/ui/component/structrender.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import Render from '../../render'

function renderStruct(el, struct, options = {}) {
if (el) {
if (struct.prerender) {
if (struct?.prerender) {
// Should it sit here?
el.innerHTML = struct.prerender
} else {
} else if (struct) {
console.info('render!', el.clientWidth, el.clientWidth)
const rnd = new Render(el, {
autoScale: true,
Expand Down
3 changes: 2 additions & 1 deletion src/script/ui/dialog/mainmenu/about.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function About(props) {
<dt>
<a
href="http://lifescience.opensource.epam.com/ketcher/help.html"
target="_blank">
target="_blank"
rel="noopener noreferrer">
Ketcher
</a>
</dt>
Expand Down
5 changes: 4 additions & 1 deletion src/script/ui/dialog/mainmenu/help.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React, { useEffect, useState, useCallback } from 'react'
import Markdown from 'react-markdown'
import gfm from 'remark-gfm'
import { useSettingsContext } from './../../../../hooks'
import Dialog from '../../component/dialog'
function Help(props) {
Expand All @@ -39,7 +40,9 @@ function Help(props) {
content && (
<Dialog title="Help" params={props} buttons={['Close']}>
{content && (
<Markdown transformImageUri={transfromImageUri}>{content}</Markdown>
<Markdown plugins={[gfm]} transformImageUri={transfromImageUri}>
{content}
</Markdown>
)}
</Dialog>
)
Expand Down
18 changes: 9 additions & 9 deletions src/script/ui/state/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ import { openDialog } from './modal'
import { onAction, load } from './shared'

export function initKeydownListener(element) {
return function (dispatch, getState) {
return function (dispatch) {
const hotKeys = initHotKeys()
element.addEventListener('keydown', event =>
keyHandle(dispatch, getState, hotKeys, event)
keyHandle(dispatch, global.currentState, hotKeys, event)
)
}
}

/* HotKeys */
function keyHandle(dispatch, getState, hotKeys, event) {
const state = getState()
function keyHandle(dispatch, state, hotKeys, event) {
//const state = global.currentState
if (state.modal) return

const editor = state.editor
Expand Down Expand Up @@ -115,7 +115,7 @@ function checkGroupOnTool(group, actionTool) {
const rxnTextPlain = /\$RXN\n+\s+0\s+0\s+0\n*/

/* ClipArea */
export function initClipboard(dispatch, getState) {
export function initClipboard(dispatch) {
const formats = Object.keys(structFormat.map).map(
fmt => structFormat.map[fmt].mime
)
Expand All @@ -128,17 +128,17 @@ export function initClipboard(dispatch, getState) {
return {
formats,
focused() {
return !getState().modal
return !global.currentState.modal
},
onCut() {
const editor = getState().editor
const editor = global.currentState.editor
const data = clipData(editor)
if (data) debAction({ tool: 'eraser', opts: 1 })
else editor.selection(null)
return data
},
onCopy() {
const editor = getState().editor
const editor = global.currentState.editor
const data = clipData(editor)
editor.selection(null)
return data
Expand All @@ -150,7 +150,7 @@ export function initClipboard(dispatch, getState) {
data['chemical/x-mdl-rxnfile'] ||
data['text/plain']

const struct = getState().editor.render.ctab.molecule
const struct = global.currentState.editor.render.ctab.molecule

if (
structStr &&
Expand Down
9 changes: 4 additions & 5 deletions src/script/ui/state/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function checkServer() {
res =>
dispatch(
appUpdate({
indigoVersion: res.indigoVersion,
imagoVersions: res.imagoVersions,
server: true
indigoVersion: res?.indigoVersion,
imagoVersions: res?.imagoVersions,
server: res?.indigoVersion && res?.imagoVersions
})
),
err => console.info(err)
Expand Down Expand Up @@ -98,8 +98,7 @@ export function check(optsTypes) {
.catch(e => {
//TODO: add error handler call
//legacy message: Failed check
throw e
}) // eslint-disable-line no-undef
})
// TODO: notification
}
}
Expand Down
109 changes: 108 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8073,7 +8073,7 @@ loglevel@^1.6.8:
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.0.tgz#728166855a740d59d38db01cf46f042caa041bb0"
integrity sha512-i2sY04nal5jDcagM3FMfG++T69GEEM8CYuOfeOIvmXzOIcwE9a/CJPR0MFM97pYMj/u10lzz7/zd7+qwhrBTqQ==

longest-streak@^2.0.1:
longest-streak@^2.0.0, longest-streak@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4"
integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==
Expand Down Expand Up @@ -8218,6 +8218,55 @@ mdast-util-from-markdown@^0.8.0:
micromark "~2.10.0"
parse-entities "^2.0.0"

mdast-util-gfm-autolink-literal@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.1.tgz#94675074d725ed7254b3172fa7e7c3252960de39"
integrity sha512-gJ2xSpqKCetSr22GEWpZH3f5ffb4pPn/72m4piY0v7T/S+O7n7rw+sfoPLhb2b4O7WdnERoYdALRcmD68FMtlw==

mdast-util-gfm-strikethrough@^0.2.0:
version "0.2.2"
resolved "https://registry.yarnpkg.com/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-0.2.2.tgz#6e9ddd33ce41b06a60463e817f6ef4cf7bfa0655"
integrity sha512-T37ZbaokJcRbHROXmoVAieWnesPD5N21tv2ifYzaGRLbkh1gknItUGhZzHefUn5Zc/eaO/iTDSAFOBrn/E8kWw==
dependencies:
mdast-util-to-markdown "^0.5.0"

mdast-util-gfm-table@^0.1.0:
version "0.1.4"
resolved "https://registry.yarnpkg.com/mdast-util-gfm-table/-/mdast-util-gfm-table-0.1.4.tgz#5b3d71d16294c6fae1c2c424d3a081ffc7407b83"
integrity sha512-T4xFSON9kUb/IpYA5N+KGWcsdGczAvILvKiXQwUGind6V9fvjPCR9yhZnIeaLdBWXaz3m/Gq77ZtuLMjtFR4IQ==
dependencies:
markdown-table "^2.0.0"
mdast-util-to-markdown "^0.5.0"

mdast-util-gfm-task-list-item@^0.1.0:
version "0.1.5"
resolved "https://registry.yarnpkg.com/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-0.1.5.tgz#3179e77f1c881370818302e7b93537d7c281401d"
integrity sha512-6O0bt34r+e7kYjeSwedhjDPYraspKIYKbhvhQEEioL7gSmXDxhN7WQW2KoxhVMpNzjNc03yC7K5KH6NHlz2jOA==
dependencies:
mdast-util-to-markdown "^0.5.0"

mdast-util-gfm@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/mdast-util-gfm/-/mdast-util-gfm-0.1.0.tgz#bac0efe703670d1b40474e6be13dbdd887273a04"
integrity sha512-HLfygQL6HdhJhFbLta4Ki9hClrzyAxRjyRvpm5caN65QZL+NyHPmqFlnF9vm1Rn58JT2+AbLwNcEDY4MEvkk8Q==
dependencies:
mdast-util-gfm-autolink-literal "^0.1.0"
mdast-util-gfm-strikethrough "^0.2.0"
mdast-util-gfm-table "^0.1.0"
mdast-util-gfm-task-list-item "^0.1.0"

mdast-util-to-markdown@^0.5.0:
version "0.5.3"
resolved "https://registry.yarnpkg.com/mdast-util-to-markdown/-/mdast-util-to-markdown-0.5.3.tgz#e05c54a3ccd239bab63c48a1e5b5747f0dcd5aca"
integrity sha512-sr8q7fQJ1xoCqZSXW6dO/MYu2Md+a4Hfk9uO+XHCfiBhVM0EgWtfAV7BuN+ff6otUeu2xDyt1o7vhZGwOG3+BA==
dependencies:
"@types/unist" "^2.0.0"
longest-streak "^2.0.0"
mdast-util-to-string "^1.0.0"
parse-entities "^2.0.0"
repeat-string "^1.0.0"
zwitch "^1.0.0"

mdast-util-to-string@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz#27055500103f51637bd07d01da01eb1967a43527"
Expand Down Expand Up @@ -8326,6 +8375,51 @@ microevent.ts@~0.1.1:
resolved "https://registry.yarnpkg.com/microevent.ts/-/microevent.ts-0.1.1.tgz#70b09b83f43df5172d0205a63025bce0f7357fa0"
integrity sha512-jo1OfR4TaEwd5HOrt5+tAZ9mqT4jmpNAusXtyfNzqVm9uiSYFZlKM1wYL4oU7azZW/PxQW53wM0S6OR1JHNa2g==

micromark-extension-gfm-autolink-literal@~0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.1.tgz#5326fc86f3ae0fbba57bb0bfc2f158c9456528ce"
integrity sha512-j30923tDp0faCNDjwqe4cMi+slegbGfc3VEAExEU8d54Q/F6pR6YxCVH+6xV0ItRoj3lCn1XkUWcy6FC3S9BOw==
dependencies:
micromark "~2.10.0"

micromark-extension-gfm-strikethrough@~0.6.0:
version "0.6.2"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.2.tgz#754788bdd13046e7f69edaa0d3f3d555d23128d6"
integrity sha512-aehEEqtTn3JekJNwZZxa7ZJVfzmuaWp4ew6x6sl3VAKIwdDZdqYeYSQIrNKwNgH7hX0g56fAwnSDLusJggjlCQ==
dependencies:
micromark "~2.10.0"

micromark-extension-gfm-table@~0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.1.tgz#79cc37da82d6ae0cc3901c1c6264b97a72372fbd"
integrity sha512-xVpqOnfFaa2OtC/Y7rlt4tdVFlUHdoLH3RXAZgb/KP3DDyKsAOx6BRS3UxiiyvmD/p2l6VUpD4bMIniuP4o4JA==
dependencies:
micromark "~2.10.0"

micromark-extension-gfm-tagfilter@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-0.3.0.tgz#d9f26a65adee984c9ccdd7e182220493562841ad"
integrity sha512-9GU0xBatryXifL//FJH+tAZ6i240xQuFrSL7mYi8f4oZSbc+NvXjkrHemeYP0+L4ZUT+Ptz3b95zhUZnMtoi/Q==

micromark-extension-gfm-task-list-item@~0.3.0:
version "0.3.2"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-0.3.2.tgz#74dbcf473276e762d2062baa0764b53c19205797"
integrity sha512-cm8lYS10YAqeXE9B27TK3u1Ihumo3H9p/3XumT+jp8vSuSbSpFIJe0bDi2kq4YAAIxtcTzUOxhEH4ko2/NYDkQ==
dependencies:
micromark "~2.10.0"

micromark-extension-gfm@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/micromark-extension-gfm/-/micromark-extension-gfm-0.3.1.tgz#30b8706bd2a3f7fd31aa37873d743946a9e856c3"
integrity sha512-lJlhcOqzoJdjQg+LMumVHdUQ61LjtqGdmZtrAdfvatRUnJTqZlRwXXHdLQgNDYlFw4mycZ4NSTKlya5QcQXl1A==
dependencies:
micromark "~2.10.0"
micromark-extension-gfm-autolink-literal "~0.5.0"
micromark-extension-gfm-strikethrough "~0.6.0"
micromark-extension-gfm-table "~0.4.0"
micromark-extension-gfm-tagfilter "~0.3.0"
micromark-extension-gfm-task-list-item "~0.3.0"

micromark@~2.10.0:
version "2.10.1"
resolved "https://registry.yarnpkg.com/micromark/-/micromark-2.10.1.tgz#cd73f54e0656f10e633073db26b663a221a442a7"
Expand Down Expand Up @@ -10948,6 +11042,14 @@ relateurl@^0.2.7:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=

remark-gfm@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/remark-gfm/-/remark-gfm-1.0.0.tgz#9213643001be3f277da6256464d56fd28c3b3c0d"
integrity sha512-KfexHJCiqvrdBZVbQ6RopMZGwaXz6wFJEfByIuEwGf0arvITHjiKKZ1dpXujjH9KZdm1//XJQwgfnJ3lmXaDPA==
dependencies:
mdast-util-gfm "^0.1.0"
micromark-extension-gfm "^0.3.0"

remark-parse@^8.0.0:
version "8.0.3"
resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-8.0.3.tgz#9c62aa3b35b79a486454c690472906075f40c7e1"
Expand Down Expand Up @@ -13717,3 +13819,8 @@ yargs@^16.0.3:
string-width "^4.2.0"
y18n "^5.0.5"
yargs-parser "^20.2.2"

zwitch@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920"
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==

0 comments on commit eff12d9

Please sign in to comment.