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

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.2\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: {
@@ -7531,7 +7530,6 @@ var RenderStruct = function () {
7531
7530
  autoScale: true
7532
7531
  }, options));
7533
7532
  rnd.setMolecule(preparedStruct);
7534
- rnd.update(true, options.viewSz);
7535
7533
  if (needCache) {
7536
7534
  renderCache.set(cacheKey, rnd.clientArea.innerHTML);
7537
7535
  }
@@ -13544,7 +13542,7 @@ var RotateTool = function () {
13544
13542
  _createClass(RotateTool, [{
13545
13543
  key: "mousedown",
13546
13544
  value: function mousedown(event, handleCenter, center) {
13547
- var xy0 = center || this.getCenter(this.editor, event)[0];
13545
+ var xy0 = center || this.getCenter(this.editor)[0] || this.editor.render.page2obj(event);
13548
13546
  this.dragCtx = {
13549
13547
  xy0: xy0,
13550
13548
  angle1: utils.calcAngle(xy0, handleCenter || this.editor.render.page2obj(event))
@@ -13553,56 +13551,51 @@ var RotateTool = function () {
13553
13551
  }
13554
13552
  }, {
13555
13553
  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;
13554
+ value: function getCenter(editor) {
13555
+ var _selection$atoms;
13556
+ var selection = editor.selection();
13557
+ var struct = editor.render.ctab.molecule;
13558
+ var _ref = selection || {},
13559
+ texts = _ref.texts,
13560
+ rxnArrows = _ref.rxnArrows,
13561
+ rxnPluses = _ref.rxnPluses;
13562
+ 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
13563
  var atom = struct.atoms.get(atomId);
13564
13564
  return !FunctionalGroup.isAtomInContractedFunctionalGroup(atom, struct.sgroups, struct.functionalGroups, false) || FunctionalGroup.isAttachmentPointAtom(atomId, struct);
13565
13565
  })) || [];
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
- }
13566
+ var xy0;
13567
+ var attachAtomId = null;
13568
+ var isMoreThanOneAttachAtom = false;
13569
+ visibleAtoms.forEach(function (aid) {
13570
+ var atom = struct.atoms.get(aid);
13571
+ if (isMoreThanOneAttachAtom) return;
13572
+ atom === null || atom === void 0 ? void 0 : atom.neighbors.find(function (nei) {
13573
+ var hb = struct.halfBonds.get(nei);
13574
+ if (hb) {
13575
+ var _editor$selection2, _editor$selection2$at;
13576
+ 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) {
13577
+ if (attachAtomId === null) {
13578
+ attachAtomId = aid;
13579
+ } else if (attachAtomId !== aid) {
13580
+ isMoreThanOneAttachAtom = true;
13581
+ return true;
13585
13582
  }
13586
13583
  }
13587
- return false;
13588
- });
13584
+ }
13585
+ return false;
13589
13586
  });
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);
13587
+ });
13588
+ if (!isMoreThanOneAttachAtom && attachAtomId !== null) {
13589
+ var _struct$atoms$get;
13590
+ xy0 = (_struct$atoms$get = struct.atoms.get(attachAtomId)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.pp;
13591
+ } 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) {
13592
+ var selectionBoundingBox = editor.render.ctab.getVBoxObj({
13593
+ atoms: visibleAtoms,
13594
+ texts: texts,
13595
+ rxnArrows: rxnArrows,
13596
+ rxnPluses: rxnPluses
13602
13597
  });
13603
- xy0 = xy0.scaled(1 / struct.atoms.size);
13604
- } else if (event) {
13605
- xy0 = editor.render.page2obj(event);
13598
+ xy0 = selectionBoundingBox === null || selectionBoundingBox === void 0 ? void 0 : selectionBoundingBox.centre();
13606
13599
  }
13607
13600
  return [xy0, visibleAtoms];
13608
13601
  }
@@ -13883,7 +13876,7 @@ var TemplateTool = function () {
13883
13876
  case 6:
13884
13877
  this.editor.hover(null);
13885
13878
  this.dragCtx = {
13886
- xy0: this.editor.render.page2obj(this.event),
13879
+ xy0: this.editor.render.page2obj(event),
13887
13880
  item: this.editor.findItem(this.event, this.findItems)
13888
13881
  };
13889
13882
  dragCtx = this.dragCtx;
@@ -15965,12 +15958,7 @@ var RotateController = function () {
15965
15958
  value: function rerender() {
15966
15959
  this.clean();
15967
15960
  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);
15961
+ this.show();
15974
15962
  }
15975
15963
  }, {
15976
15964
  key: "clean",
@@ -16019,13 +16007,23 @@ var RotateController = function () {
16019
16007
  }
16020
16008
  }, {
16021
16009
  key: "show",
16022
- value: function show(visibleAtoms) {
16010
+ value: function show() {
16023
16011
  var _this$handle6, _this$handle7, _this$handle8, _this$handle9, _this$cross3;
16024
- var enable = visibleAtoms.length > 1 && this.editor.tool() instanceof SelectTool;
16012
+ var _this$rotateTool$getC = this.rotateTool.getCenter(this.editor),
16013
+ _this$rotateTool$getC2 = _slicedToArray(_this$rotateTool$getC, 2),
16014
+ originalCenter = _this$rotateTool$getC2[0],
16015
+ visibleAtoms = _this$rotateTool$getC2[1];
16016
+ var _ref = this.editor.selection() || {},
16017
+ texts = _ref.texts,
16018
+ rxnArrows = _ref.rxnArrows,
16019
+ rxnPluses = _ref.rxnPluses;
16020
+ var isMoreThanOneItemBeingSelected = visibleAtoms.concat(texts || [], rxnArrows || [], rxnPluses || []).length > 1;
16021
+ var enable = (isMoreThanOneItemBeingSelected || (rxnArrows === null || rxnArrows === void 0 ? void 0 : rxnArrows.length)) && this.editor.tool() instanceof SelectTool && originalCenter;
16025
16022
  if (!enable) {
16026
16023
  return;
16027
16024
  }
16028
- var rectStartY = this.drawBoundingRect(visibleAtoms);
16025
+ this.originalCenter = originalCenter;
16026
+ var rectStartY = this.drawBoundingRect(visibleAtoms, texts, rxnArrows, rxnPluses);
16029
16027
  this.handleCenter = new Vec2(this.center.x, rectStartY - STYLE.HANDLE_MARGIN - STYLE.HANDLE_RADIUS);
16030
16028
  this.drawLink();
16031
16029
  this.drawCross();
@@ -16092,11 +16090,14 @@ var RotateController = function () {
16092
16090
  }
16093
16091
  }, {
16094
16092
  key: "drawBoundingRect",
16095
- value: function drawBoundingRect(visibleAtoms) {
16093
+ value: function drawBoundingRect(visibleAtoms, texts, rxnArrows, rxnPluses) {
16096
16094
  var RECT_RADIUS = 20;
16097
16095
  var RECT_PADDING = 10;
16098
16096
  var rectBox = this.render.ctab.getVBoxObj({
16099
16097
  atoms: visibleAtoms,
16098
+ texts: texts,
16099
+ rxnArrows: rxnArrows,
16100
+ rxnPluses: rxnPluses,
16100
16101
  sgroups: getGroupIdsFromItemArrays(this.render.ctab.molecule, {
16101
16102
  atoms: visibleAtoms
16102
16103
  })
@@ -17373,6 +17374,7 @@ var useFunctionalGroupEoc = function useFunctionalGroupEoc() {
17373
17374
  }));
17374
17375
  });
17375
17376
  editor.update(action);
17377
+ editor.rotateController.rerender();
17376
17378
  highlightFG(dispatch, {
17377
17379
  group: null,
17378
17380
  id: null
@@ -17930,11 +17932,10 @@ function _objectSpread$C(target) { for (var i = 1; i < arguments.length; i++) {
17930
17932
  var HOVER_PANEL_PADDING = 20;
17931
17933
  function getSGroupFirstAtom(sGroup, render) {
17932
17934
  var _render$ctab$atoms, _render$ctab$atoms$ge;
17933
- var firstSgroupAtom = sGroup.firstSgroupAtom;
17935
+ var firstSgroupAtom = sGroup.firstSgroupAtom,
17936
+ firstSgroupAtomId = sGroup.firstSgroupAtomId;
17934
17937
  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);
17938
+ 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
17939
  }
17939
17940
  function getPanelPosition(clientX, clientY, render, sGroup) {
17940
17941
  var width = 0;
@@ -20486,9 +20487,12 @@ var mapDispatchToProps$8 = function mapDispatchToProps(dispatch) {
20486
20487
  };
20487
20488
  var Recognize = connect(mapStateToProps$b, mapDispatchToProps$8)(RecognizeDialog);
20488
20489
 
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"};
20490
+ 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
20491
 
20491
20492
  var _excluded$g = ["miewOpts", "server", "struct", "onExportCML", "miewTheme"];
20493
+ var Viewer = lazy(function () {
20494
+ return import('miew-react');
20495
+ });
20492
20496
  var BACKGROUND_COLOR = {
20493
20497
  dark: '0x202020',
20494
20498
  light: '0xcccccc'
@@ -20557,6 +20561,10 @@ var MiewDialog = function MiewDialog(_ref) {
20557
20561
  miewTheme = _ref$miewTheme === void 0 ? 'light' : _ref$miewTheme,
20558
20562
  prop = _objectWithoutProperties(_ref, _excluded$g);
20559
20563
  var miewRef = useRef();
20564
+ var _useState = useState(false),
20565
+ _useState2 = _slicedToArray(_useState, 2),
20566
+ isInitialized = _useState2[0],
20567
+ setIsIsInitialized = _useState2[1];
20560
20568
  var onMiewInit = useCallback(function (miew) {
20561
20569
  miewRef.current = miew;
20562
20570
  var factory = new FormatterFactory(server);
@@ -20567,7 +20575,8 @@ var MiewDialog = function MiewDialog(_ref) {
20567
20575
  fileType: 'cml'
20568
20576
  });
20569
20577
  }).then(function () {
20570
- return miew.setOptions(miewOpts);
20578
+ miew.setOptions(miewOpts);
20579
+ setIsIsInitialized(true);
20571
20580
  })["catch"](function (ex) {
20572
20581
  return (void 0);
20573
20582
  });
@@ -20587,6 +20596,7 @@ var MiewDialog = function MiewDialog(_ref) {
20587
20596
  buttons: ['Cancel', jsx("button", {
20588
20597
  onClick: exportCML,
20589
20598
  className: classes$t.applyButton,
20599
+ disabled: !isInitialized,
20590
20600
  children: "Apply"
20591
20601
  }, "apply")],
20592
20602
  footerContent: jsx(FooterContent$2, {}),
@@ -20594,8 +20604,14 @@ var MiewDialog = function MiewDialog(_ref) {
20594
20604
  children: jsx("div", {
20595
20605
  children: jsx("div", {
20596
20606
  className: "".concat(classes$t.miewContainer, " ").concat(miewTheme === 'dark' ? classes$t.miewDarkTheme : ''),
20597
- children: jsx(Viewer, {
20598
- onInit: onMiewInit
20607
+ children: jsx(Suspense, {
20608
+ fallback: jsx("div", {
20609
+ className: classes$t.loadingContainer,
20610
+ children: jsx(LoadingCircles, {})
20611
+ }),
20612
+ children: jsx(Viewer, {
20613
+ onInit: onMiewInit
20614
+ })
20599
20615
  })
20600
20616
  })
20601
20617
  })
@@ -24590,8 +24606,8 @@ var KetcherBuilder = function () {
24590
24606
  initApp(element, staticResourcesUrl, {
24591
24607
  buttons: buttons || {},
24592
24608
  errorHandler: errorHandler || null,
24593
- version: "2.11.0-rc.1" ,
24594
- buildDate: "2023-05-23T14:46:26" ,
24609
+ version: "2.11.0-rc.2" ,
24610
+ buildDate: "2023-05-30T13:30:11" ,
24595
24611
  buildNumber: ''
24596
24612
  }, structService, resolve);
24597
24613
  });