ketcher-react 2.11.0-rc.1 → 2.11.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
26
26
  import _createClass from '@babel/runtime/helpers/createClass';
27
27
  import { KetSerializer, MolSerializer, Ketcher, FormatterFactory, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, Bond as Bond$2, Elements, AtomList, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, SimpleObjectMode, emitEventRequestIsFinished, SGroup as SGroup$1, Pile, getStereoAtomsMap, identifyStructFormat, SupportedFormat, ChemicalMimeType, SdfSerializer, Render, Struct, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, FunctionalGroup, fromAtomsAttrs, fracAngle, Vec2, fromBondAddition, Action, fromAtomAddition, fromSgroupDeletion, fromFragmentDeletion, fromOneBondDeletion, bondChangingAction, fromBondsAttrs, fromChain, getItemsToFuse, getHoverToFuse, fromItemsFuse, fromStereoFlagUpdate, Scale, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, fromSgroupAction, mergeMapOfItemsToSet, ReBond, setExpandSGroup, fromSimpleObjectResizing, fromArrowResizing, fromMultipleMove, fromTextDeletion, fromTextUpdating, isCloseToEdgeOfCanvas, isCloseToEdgeOfScreen, getDirections, shiftAndExtendCanvasByVector, scrollByVector, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromPaste, fromTemplateOnAtom, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromPlusAddition, fromRotate, fromFlip, fromBondAlign, fromSimpleObjectAddition, fromTemplateOnBondAction, fromTemplateOnCanvas, fromTextCreation, formatProperties, Fragment as Fragment$1, OperationType, fromHighlightCreate, fromHighlightClear, fromNewCanvas, fromDescriptorsAlign, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, b64toBlob, Generics, TextCommand, DefaultStructServiceOptions } from 'ketcher-core';
28
28
  import * as React from 'react';
29
- import React__default, { createRef, Component, useState, useEffect, useRef, useMemo, createElement, forwardRef, useCallback, useLayoutEffect, Fragment as Fragment$2, PureComponent } from 'react';
29
+ import React__default, { createRef, Component, useState, useEffect, useRef, useMemo, createElement, forwardRef, useCallback, useLayoutEffect, Fragment as Fragment$2, PureComponent, lazy, Suspense } from 'react';
30
30
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
31
31
  import _inherits from '@babel/runtime/helpers/inherits';
32
32
  import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
@@ -61,7 +61,6 @@ import MenuItem from '@mui/material/MenuItem';
61
61
  import { HexColorPicker, HexColorInput } from 'react-colorful';
62
62
  import { saveAs } from 'file-saver';
63
63
  import FontFaceObserver from 'font-face-observer';
64
- import Viewer from 'miew-react';
65
64
  import { useDropzone } from 'react-dropzone';
66
65
  import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
67
66
  import { css } from '@emotion/react';
@@ -1577,8 +1576,8 @@ var sgroup = {
1577
1576
  title: 'Polymer label',
1578
1577
  type: 'string',
1579
1578
  "default": 'n',
1580
- pattern: '^[a-zA-Z]$',
1581
- invalidMessage: 'SRU subscript should consist of a single letter'
1579
+ pattern: '^(?!\\s*$)[^"]+$',
1580
+ invalidMessage: 'SRU subscript should not be empty and contain double quotes'
1582
1581
  },
1583
1582
  connectivity: {
1584
1583
  title: 'Repeat Pattern',
@@ -3011,7 +3010,7 @@ var zoom = {
3011
3010
 
3012
3011
  var openHelpLink = function openHelpLink() {
3013
3012
  var _window$open;
3014
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.11.0-rc.1\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3013
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.11.0-rc.3\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3015
3014
  };
3016
3015
  var help = {
3017
3016
  help: {
@@ -7530,8 +7529,8 @@ var RenderStruct = function () {
7530
7529
  var rnd = new Render(el, _objectSpread$11({
7531
7530
  autoScale: true
7532
7531
  }, options));
7532
+ preparedStruct.rescale();
7533
7533
  rnd.setMolecule(preparedStruct);
7534
- rnd.update(true, options.viewSz);
7535
7534
  if (needCache) {
7536
7535
  renderCache.set(cacheKey, rnd.clientArea.innerHTML);
7537
7536
  }
@@ -13544,7 +13543,7 @@ var RotateTool = function () {
13544
13543
  _createClass(RotateTool, [{
13545
13544
  key: "mousedown",
13546
13545
  value: function mousedown(event, handleCenter, center) {
13547
- var xy0 = center || this.getCenter(this.editor, event)[0];
13546
+ var xy0 = center || this.getCenter(this.editor)[0] || this.editor.render.page2obj(event);
13548
13547
  this.dragCtx = {
13549
13548
  xy0: xy0,
13550
13549
  angle1: utils.calcAngle(xy0, handleCenter || this.editor.render.page2obj(event))
@@ -13553,56 +13552,51 @@ var RotateTool = function () {
13553
13552
  }
13554
13553
  }, {
13555
13554
  key: "getCenter",
13556
- value: function getCenter(editor, event) {
13557
- var _this$editor$selectio,
13558
- _this$editor$selectio2,
13559
- _this = this,
13560
- _struct$atoms;
13561
- var visibleAtoms = ((_this$editor$selectio = this.editor.selection()) === null || _this$editor$selectio === void 0 ? void 0 : (_this$editor$selectio2 = _this$editor$selectio.atoms) === null || _this$editor$selectio2 === void 0 ? void 0 : _this$editor$selectio2.filter(function (atomId) {
13562
- var struct = _this.editor.render.ctab.molecule;
13555
+ value: function getCenter(editor) {
13556
+ var _selection$atoms;
13557
+ var selection = editor.selection();
13558
+ var struct = editor.render.ctab.molecule;
13559
+ var _ref = selection || {},
13560
+ texts = _ref.texts,
13561
+ rxnArrows = _ref.rxnArrows,
13562
+ rxnPluses = _ref.rxnPluses;
13563
+ var visibleAtoms = (selection === null || selection === void 0 ? void 0 : (_selection$atoms = selection.atoms) === null || _selection$atoms === void 0 ? void 0 : _selection$atoms.filter(function (atomId) {
13563
13564
  var atom = struct.atoms.get(atomId);
13564
13565
  return !FunctionalGroup.isAtomInContractedFunctionalGroup(atom, struct.sgroups, struct.functionalGroups, false) || FunctionalGroup.isAttachmentPointAtom(atomId, struct);
13565
13566
  })) || [];
13566
- var xy0 = new Vec2();
13567
- var struct = editor.render.ctab.molecule;
13568
- if (visibleAtoms.length > 0) {
13569
- var rotId = null;
13570
- var rotAll = false;
13571
- visibleAtoms.forEach(function (aid) {
13572
- var atom = struct.atoms.get(aid);
13573
- if (rotAll) return;
13574
- atom === null || atom === void 0 ? void 0 : atom.neighbors.find(function (nei) {
13575
- var hb = struct.halfBonds.get(nei);
13576
- if (hb) {
13577
- var _editor$selection2, _editor$selection2$at;
13578
- if (((_editor$selection2 = editor.selection()) === null || _editor$selection2 === void 0 ? void 0 : (_editor$selection2$at = _editor$selection2.atoms) === null || _editor$selection2$at === void 0 ? void 0 : _editor$selection2$at.indexOf(hb.end)) === -1) {
13579
- if (rotId == null) {
13580
- rotId = aid;
13581
- } else if (rotId !== aid) {
13582
- rotAll = true;
13583
- return true;
13584
- }
13567
+ var xy0;
13568
+ var attachAtomId = null;
13569
+ var isMoreThanOneAttachAtom = false;
13570
+ visibleAtoms.forEach(function (aid) {
13571
+ var atom = struct.atoms.get(aid);
13572
+ if (isMoreThanOneAttachAtom) return;
13573
+ atom === null || atom === void 0 ? void 0 : atom.neighbors.find(function (nei) {
13574
+ var hb = struct.halfBonds.get(nei);
13575
+ if (hb) {
13576
+ var _editor$selection2, _editor$selection2$at;
13577
+ if (((_editor$selection2 = editor.selection()) === null || _editor$selection2 === void 0 ? void 0 : (_editor$selection2$at = _editor$selection2.atoms) === null || _editor$selection2$at === void 0 ? void 0 : _editor$selection2$at.indexOf(hb.end)) === -1) {
13578
+ if (attachAtomId === null) {
13579
+ attachAtomId = aid;
13580
+ } else if (attachAtomId !== aid) {
13581
+ isMoreThanOneAttachAtom = true;
13582
+ return true;
13585
13583
  }
13586
13584
  }
13587
- return false;
13588
- });
13585
+ }
13586
+ return false;
13589
13587
  });
13590
- if (!rotAll && rotId !== null) {
13591
- var _struct$atoms$get;
13592
- xy0 = (_struct$atoms$get = struct.atoms.get(rotId)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.pp;
13593
- } else {
13594
- var selectionBoundingBox = editor.render.ctab.getVBoxObj({
13595
- atoms: visibleAtoms
13596
- });
13597
- xy0 = selectionBoundingBox.centre();
13598
- }
13599
- } else if ((_struct$atoms = struct.atoms) !== null && _struct$atoms !== void 0 && _struct$atoms.size) {
13600
- struct.atoms.forEach(function (atom) {
13601
- xy0.add_(atom.pp);
13588
+ });
13589
+ if (!isMoreThanOneAttachAtom && attachAtomId !== null) {
13590
+ var _struct$atoms$get;
13591
+ xy0 = (_struct$atoms$get = struct.atoms.get(attachAtomId)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.pp;
13592
+ } else if (visibleAtoms.length || texts !== null && texts !== void 0 && texts.length || rxnArrows !== null && rxnArrows !== void 0 && rxnArrows.length || rxnPluses !== null && rxnPluses !== void 0 && rxnPluses.length) {
13593
+ var selectionBoundingBox = editor.render.ctab.getVBoxObj({
13594
+ atoms: visibleAtoms,
13595
+ texts: texts,
13596
+ rxnArrows: rxnArrows,
13597
+ rxnPluses: rxnPluses
13602
13598
  });
13603
- xy0 = xy0.scaled(1 / struct.atoms.size);
13604
- } else if (event) {
13605
- xy0 = editor.render.page2obj(event);
13599
+ xy0 = selectionBoundingBox === null || selectionBoundingBox === void 0 ? void 0 : selectionBoundingBox.centre();
13606
13600
  }
13607
13601
  return [xy0, visibleAtoms];
13608
13602
  }
@@ -13883,7 +13877,7 @@ var TemplateTool = function () {
13883
13877
  case 6:
13884
13878
  this.editor.hover(null);
13885
13879
  this.dragCtx = {
13886
- xy0: this.editor.render.page2obj(this.event),
13880
+ xy0: this.editor.render.page2obj(event),
13887
13881
  item: this.editor.findItem(this.event, this.findItems)
13888
13882
  };
13889
13883
  dragCtx = this.dragCtx;
@@ -15965,12 +15959,7 @@ var RotateController = function () {
15965
15959
  value: function rerender() {
15966
15960
  this.clean();
15967
15961
  this.init();
15968
- var _this$rotateTool$getC = this.rotateTool.getCenter(this.editor),
15969
- _this$rotateTool$getC2 = _slicedToArray(_this$rotateTool$getC, 2),
15970
- originalCenter = _this$rotateTool$getC2[0],
15971
- visibleAtoms = _this$rotateTool$getC2[1];
15972
- this.originalCenter = originalCenter;
15973
- this.show(visibleAtoms);
15962
+ this.show();
15974
15963
  }
15975
15964
  }, {
15976
15965
  key: "clean",
@@ -16019,13 +16008,23 @@ var RotateController = function () {
16019
16008
  }
16020
16009
  }, {
16021
16010
  key: "show",
16022
- value: function show(visibleAtoms) {
16011
+ value: function show() {
16023
16012
  var _this$handle6, _this$handle7, _this$handle8, _this$handle9, _this$cross3;
16024
- var enable = visibleAtoms.length > 1 && this.editor.tool() instanceof SelectTool;
16013
+ var _this$rotateTool$getC = this.rotateTool.getCenter(this.editor),
16014
+ _this$rotateTool$getC2 = _slicedToArray(_this$rotateTool$getC, 2),
16015
+ originalCenter = _this$rotateTool$getC2[0],
16016
+ visibleAtoms = _this$rotateTool$getC2[1];
16017
+ var _ref = this.editor.selection() || {},
16018
+ texts = _ref.texts,
16019
+ rxnArrows = _ref.rxnArrows,
16020
+ rxnPluses = _ref.rxnPluses;
16021
+ var isMoreThanOneItemBeingSelected = visibleAtoms.concat(texts || [], rxnArrows || [], rxnPluses || []).length > 1;
16022
+ var enable = (isMoreThanOneItemBeingSelected || (rxnArrows === null || rxnArrows === void 0 ? void 0 : rxnArrows.length)) && this.editor.tool() instanceof SelectTool && originalCenter;
16025
16023
  if (!enable) {
16026
16024
  return;
16027
16025
  }
16028
- var rectStartY = this.drawBoundingRect(visibleAtoms);
16026
+ this.originalCenter = originalCenter;
16027
+ var rectStartY = this.drawBoundingRect(visibleAtoms, texts, rxnArrows, rxnPluses);
16029
16028
  this.handleCenter = new Vec2(this.center.x, rectStartY - STYLE.HANDLE_MARGIN - STYLE.HANDLE_RADIUS);
16030
16029
  this.drawLink();
16031
16030
  this.drawCross();
@@ -16092,11 +16091,14 @@ var RotateController = function () {
16092
16091
  }
16093
16092
  }, {
16094
16093
  key: "drawBoundingRect",
16095
- value: function drawBoundingRect(visibleAtoms) {
16094
+ value: function drawBoundingRect(visibleAtoms, texts, rxnArrows, rxnPluses) {
16096
16095
  var RECT_RADIUS = 20;
16097
16096
  var RECT_PADDING = 10;
16098
16097
  var rectBox = this.render.ctab.getVBoxObj({
16099
16098
  atoms: visibleAtoms,
16099
+ texts: texts,
16100
+ rxnArrows: rxnArrows,
16101
+ rxnPluses: rxnPluses,
16100
16102
  sgroups: getGroupIdsFromItemArrays(this.render.ctab.molecule, {
16101
16103
  atoms: visibleAtoms
16102
16104
  })
@@ -17373,6 +17375,7 @@ var useFunctionalGroupEoc = function useFunctionalGroupEoc() {
17373
17375
  }));
17374
17376
  });
17375
17377
  editor.update(action);
17378
+ editor.rotateController.rerender();
17376
17379
  highlightFG(dispatch, {
17377
17380
  group: null,
17378
17381
  id: null
@@ -17930,11 +17933,10 @@ function _objectSpread$C(target) { for (var i = 1; i < arguments.length; i++) {
17930
17933
  var HOVER_PANEL_PADDING = 20;
17931
17934
  function getSGroupFirstAtom(sGroup, render) {
17932
17935
  var _render$ctab$atoms, _render$ctab$atoms$ge;
17933
- var firstSgroupAtom = sGroup.firstSgroupAtom;
17936
+ var firstSgroupAtom = sGroup.firstSgroupAtom,
17937
+ firstSgroupAtomId = sGroup.firstSgroupAtomId;
17934
17938
  if (firstSgroupAtom) return firstSgroupAtom.pp;
17935
- var _sGroup$atoms = _slicedToArray(sGroup.atoms, 1),
17936
- firstAtomId = _sGroup$atoms[0];
17937
- return ((_render$ctab$atoms = render.ctab.atoms) === null || _render$ctab$atoms === void 0 ? void 0 : (_render$ctab$atoms$ge = _render$ctab$atoms.get(firstAtomId)) === null || _render$ctab$atoms$ge === void 0 ? void 0 : _render$ctab$atoms$ge.a.pp) || new Vec2(0, 0);
17939
+ return ((_render$ctab$atoms = render.ctab.atoms) === null || _render$ctab$atoms === void 0 ? void 0 : (_render$ctab$atoms$ge = _render$ctab$atoms.get(firstSgroupAtomId)) === null || _render$ctab$atoms$ge === void 0 ? void 0 : _render$ctab$atoms$ge.a.pp) || new Vec2(0, 0);
17938
17940
  }
17939
17941
  function getPanelPosition(clientX, clientY, render, sGroup) {
17940
17942
  var width = 0;
@@ -17989,7 +17991,7 @@ var InfoPanel = function InfoPanel(props) {
17989
17991
  var childRef = useRef(null);
17990
17992
  var groupName = sGroup === null || sGroup === void 0 ? void 0 : (_sGroup$data = sGroup.data) === null || _sGroup$data === void 0 ? void 0 : _sGroup$data.name;
17991
17993
  useEffect(function () {
17992
- if (!groupStruct && (sGroup === null || sGroup === void 0 ? void 0 : sGroup.type) === 'DAT') {
17994
+ if (sGroup && SGroup$1.isDataSGroup(sGroup)) {
17993
17995
  var _sGroup$data2, _sGroup$data3;
17994
17996
  setSGroupData("".concat((_sGroup$data2 = sGroup.data) === null || _sGroup$data2 === void 0 ? void 0 : _sGroup$data2.fieldName, "=").concat((_sGroup$data3 = sGroup.data) === null || _sGroup$data3 === void 0 ? void 0 : _sGroup$data3.fieldValue));
17995
17997
  } else {
@@ -18010,7 +18012,8 @@ var InfoPanel = function InfoPanel(props) {
18010
18012
  y = position.y;
18011
18013
  var width = size.x;
18012
18014
  var height = size.y;
18013
- return molecule ? jsx("div", {
18015
+ var showMolecule = molecule && sGroup && !SGroup$1.isDataSGroup(sGroup);
18016
+ return showMolecule ? jsx("div", {
18014
18017
  style: {
18015
18018
  left: x + 'px',
18016
18019
  top: y + 'px'
@@ -20486,9 +20489,12 @@ var mapDispatchToProps$8 = function mapDispatchToProps(dispatch) {
20486
20489
  };
20487
20490
  var Recognize = connect(mapStateToProps$b, mapDispatchToProps$8)(RecognizeDialog);
20488
20491
 
20489
- var classes$t = {"button-common-styles":"Miew-module_button-common-styles__8FE-p","scrollbar":"Miew-module_scrollbar__ZMWH-","warning":"Miew-module_warning__IDl5F","applyButton":"Miew-module_applyButton__ZDE-i","miewDialog":"Miew-module_miewDialog__gHvYc","miewContainer":"Miew-module_miewContainer__2SNw3","miewDarkTheme":"Miew-module_miewDarkTheme__kMFzc"};
20492
+ var classes$t = {"button-common-styles":"Miew-module_button-common-styles__8FE-p","scrollbar":"Miew-module_scrollbar__ZMWH-","warning":"Miew-module_warning__IDl5F","applyButton":"Miew-module_applyButton__ZDE-i","miewDialog":"Miew-module_miewDialog__gHvYc","miewContainer":"Miew-module_miewContainer__2SNw3","loadingContainer":"Miew-module_loadingContainer__cVF-M","miewDarkTheme":"Miew-module_miewDarkTheme__kMFzc"};
20490
20493
 
20491
20494
  var _excluded$g = ["miewOpts", "server", "struct", "onExportCML", "miewTheme"];
20495
+ var Viewer = lazy(function () {
20496
+ return import('miew-react');
20497
+ });
20492
20498
  var BACKGROUND_COLOR = {
20493
20499
  dark: '0x202020',
20494
20500
  light: '0xcccccc'
@@ -20557,6 +20563,10 @@ var MiewDialog = function MiewDialog(_ref) {
20557
20563
  miewTheme = _ref$miewTheme === void 0 ? 'light' : _ref$miewTheme,
20558
20564
  prop = _objectWithoutProperties(_ref, _excluded$g);
20559
20565
  var miewRef = useRef();
20566
+ var _useState = useState(false),
20567
+ _useState2 = _slicedToArray(_useState, 2),
20568
+ isInitialized = _useState2[0],
20569
+ setIsIsInitialized = _useState2[1];
20560
20570
  var onMiewInit = useCallback(function (miew) {
20561
20571
  miewRef.current = miew;
20562
20572
  var factory = new FormatterFactory(server);
@@ -20567,7 +20577,8 @@ var MiewDialog = function MiewDialog(_ref) {
20567
20577
  fileType: 'cml'
20568
20578
  });
20569
20579
  }).then(function () {
20570
- return miew.setOptions(miewOpts);
20580
+ miew.setOptions(miewOpts);
20581
+ setIsIsInitialized(true);
20571
20582
  })["catch"](function (ex) {
20572
20583
  return (void 0);
20573
20584
  });
@@ -20587,6 +20598,7 @@ var MiewDialog = function MiewDialog(_ref) {
20587
20598
  buttons: ['Cancel', jsx("button", {
20588
20599
  onClick: exportCML,
20589
20600
  className: classes$t.applyButton,
20601
+ disabled: !isInitialized,
20590
20602
  children: "Apply"
20591
20603
  }, "apply")],
20592
20604
  footerContent: jsx(FooterContent$2, {}),
@@ -20594,8 +20606,14 @@ var MiewDialog = function MiewDialog(_ref) {
20594
20606
  children: jsx("div", {
20595
20607
  children: jsx("div", {
20596
20608
  className: "".concat(classes$t.miewContainer, " ").concat(miewTheme === 'dark' ? classes$t.miewDarkTheme : ''),
20597
- children: jsx(Viewer, {
20598
- onInit: onMiewInit
20609
+ children: jsx(Suspense, {
20610
+ fallback: jsx("div", {
20611
+ className: classes$t.loadingContainer,
20612
+ children: jsx(LoadingCircles, {})
20613
+ }),
20614
+ children: jsx(Viewer, {
20615
+ onInit: onMiewInit
20616
+ })
20599
20617
  })
20600
20618
  })
20601
20619
  })
@@ -24590,8 +24608,8 @@ var KetcherBuilder = function () {
24590
24608
  initApp(element, staticResourcesUrl, {
24591
24609
  buttons: buttons || {},
24592
24610
  errorHandler: errorHandler || null,
24593
- version: "2.11.0-rc.1" ,
24594
- buildDate: "2023-05-23T14:46:26" ,
24611
+ version: "2.11.0-rc.3" ,
24612
+ buildDate: "2023-06-01T07:21:00" ,
24595
24613
  buildNumber: ''
24596
24614
  }, structService, resolve);
24597
24615
  });