ketcher-react 2.18.0-rc.4 → 2.18.0-rc.6

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.
@@ -40,7 +40,7 @@ import styled from '@emotion/styled';
40
40
  import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
41
41
  import * as KN from 'w3c-keyname';
42
42
  import _slicedToArray$1 from '@babel/runtime/helpers/slicedToArray';
43
- import ReactDOM from 'react-dom';
43
+ import ReactDOM, { createPortal } from 'react-dom';
44
44
  import { connect, useDispatch, useSelector, Provider } from 'react-redux';
45
45
  import { combineReducers, createStore as createStore$1, applyMiddleware } from 'redux';
46
46
  import _, { throttle as throttle$1, intersection, difference, debounce as debounce$1, cloneDeep, isEqual as isEqual$1, capitalize as capitalize$1, range as range$2, isEmpty as isEmpty$1, uniqBy } from 'lodash';
@@ -3595,7 +3595,7 @@ var zoom = {
3595
3595
 
3596
3596
  var openHelpLink = function openHelpLink() {
3597
3597
  var _window$open;
3598
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.18.0-rc.4\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3598
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.18.0-rc.6\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3599
3599
  };
3600
3600
  var help = {
3601
3601
  help: {
@@ -9014,9 +9014,11 @@ function throughFileReader(file) {
9014
9014
  cfb.FullPaths.forEach(function (path) {
9015
9015
  if (path.endsWith('.bin')) {
9016
9016
  var ole = CFB.find(cfb, path);
9017
- var sdf = CFB.find(CFB.parse(ole.content), 'CONTENTS');
9018
- var base64String = arrayBufferToBase64(sdf.content);
9019
- structures.push(base64String);
9017
+ var sdf = CFB.find(CFB.parse(ole === null || ole === void 0 ? void 0 : ole.content), 'CONTENTS');
9018
+ var base64String = arrayBufferToBase64(sdf === null || sdf === void 0 ? void 0 : sdf.content);
9019
+ if (base64String.startsWith('VmpDRDAxMDAEAw')) {
9020
+ structures.push(base64String);
9021
+ }
9020
9022
  }
9021
9023
  });
9022
9024
  content = {
@@ -24524,14 +24526,32 @@ var props = {
24524
24526
  var ContextMenu = function ContextMenu() {
24525
24527
  var _useAppContext = useAppContext(),
24526
24528
  getKetcherInstance = _useAppContext.getKetcherInstance;
24529
+ var resetMenuPosition = function resetMenuPosition() {
24530
+ var contextMenuElement = document.querySelector('.contexify:last-of-type');
24531
+ var ketcherRootElement = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
24532
+ if (!contextMenuElement || !ketcherRootElement) {
24533
+ return;
24534
+ }
24535
+ var contextMenuElementBoundingBox = contextMenuElement.getBoundingClientRect();
24536
+ var ketcherRootElementBoundingBox = ketcherRootElement.getBoundingClientRect();
24537
+ if (!contextMenuElementBoundingBox || !ketcherRootElementBoundingBox) {
24538
+ return;
24539
+ }
24540
+ var left = contextMenuElementBoundingBox.right > ketcherRootElementBoundingBox.right ? contextMenuElementBoundingBox.x - (contextMenuElementBoundingBox.right - ketcherRootElementBoundingBox.right) : contextMenuElementBoundingBox.x;
24541
+ var top = contextMenuElementBoundingBox.bottom > ketcherRootElementBoundingBox.bottom ? contextMenuElementBoundingBox.y - (contextMenuElementBoundingBox.bottom - ketcherRootElementBoundingBox.bottom) : contextMenuElementBoundingBox.y;
24542
+ contextMenuElement.style.left = "".concat(left, "px");
24543
+ contextMenuElement.style.top = "".concat(top, "px");
24544
+ };
24527
24545
  var trackVisibility = useCallback(function (id, visible) {
24528
24546
  var editor = getKetcherInstance().editor;
24529
24547
  if (visible) {
24530
24548
  editor.hoverIcon.hide();
24549
+ resetMenuPosition();
24531
24550
  }
24532
24551
  editor.contextMenu[id] = visible;
24533
24552
  }, [getKetcherInstance]);
24534
- return jsxs(Fragment, {
24553
+ var ketcherEditorRootElement = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
24554
+ return ketcherEditorRootElement ? createPortal(jsxs(Fragment, {
24535
24555
  children: [jsx(Menu, _objectSpread$H(_objectSpread$H({}, props), {}, {
24536
24556
  id: CONTEXT_MENU_ID.FOR_BONDS,
24537
24557
  onVisibilityChange: function onVisibilityChange(visible) {
@@ -24563,7 +24583,7 @@ var ContextMenu = function ContextMenu() {
24563
24583
  },
24564
24584
  children: jsx(RGroupAttachmentPointMenuItems, {})
24565
24585
  }))]
24566
- });
24586
+ }), ketcherEditorRootElement) : null;
24567
24587
  };
24568
24588
 
24569
24589
  var getIsItemInSelection = function getIsItemInSelection(_ref) {
@@ -28590,7 +28610,7 @@ var mapStateToProps$6 = function mapStateToProps(state) {
28590
28610
  };
28591
28611
  var RgroupLogicContainer = connect(mapStateToProps$6)(RgroupLogic);
28592
28612
 
28593
- var classes$n = {"button-common-styles":"Open-module_button-common-styles__NBSQP","scrollbar":"Open-module_scrollbar__sRvYM","open":"Open-module_open__m8V9g","textareaEditor":"Open-module_textareaEditor__ZbEVj","footerContent":"Open-module_footerContent__Q0hTw","buttonsContainer":"Open-module_buttonsContainer__L1HqU","openButton":"Open-module_openButton__cj3oU","cancelButton":"Open-module_cancelButton__0TQzA","copyButton":"Open-module_copyButton__KlXKd"};
28613
+ var classes$n = {"button-common-styles":"Open-module_button-common-styles__NBSQP","scrollbar":"Open-module_scrollbar__sRvYM","open":"Open-module_open__m8V9g","textareaEditor":"Open-module_textareaEditor__ZbEVj","footerContent":"Open-module_footerContent__Q0hTw","buttonsContainer":"Open-module_buttonsContainer__L1HqU","openButton":"Open-module_openButton__cj3oU","cancelButton":"Open-module_cancelButton__0TQzA","copyButton":"Open-module_copyButton__KlXKd","loadingContainer":"Open-module_loadingContainer__Y354t"};
28594
28614
 
28595
28615
  var styles$b = {"analyzingFileWrapper":"AnalyzingFile-module_analyzingFileWrapper__j0Ltf","fileBox":"AnalyzingFile-module_fileBox__ywFIh"};
28596
28616
 
@@ -28776,37 +28796,40 @@ var CDXStructuresViewer = function CDXStructuresViewer(_ref) {
28776
28796
  inputHandler(itemsMap[selectedIndex].base64struct);
28777
28797
  }
28778
28798
  }, [inputHandler, itemsMap, selectedIndex]);
28779
- var getImages = useCallback(function () {
28780
- var itemsList = {};
28799
+ var getImage = function getImage(str, index) {
28781
28800
  setLoading(true);
28782
- var promises = structList.map(function (str) {
28783
- return parseStruct(str, server).then(function (struct) {
28784
- return {
28785
- base64struct: str,
28786
- struct: struct
28787
- };
28788
- })["catch"](function (error) {
28789
- return {
28790
- base64struct: str,
28791
- error: error.message || error
28792
- };
28801
+ parseStruct(str, server).then(function (struct) {
28802
+ var object = {
28803
+ base64struct: str,
28804
+ struct: struct
28805
+ };
28806
+ setItemsMap(function (state) {
28807
+ return _objectSpread$p(_objectSpread$p({}, state), {}, _defineProperty$1({}, index, object));
28793
28808
  });
28794
- });
28795
- Promise.allSettled(promises).then(function (values) {
28796
- values.forEach(function (el, index) {
28797
- if (el.status === 'fulfilled') {
28798
- itemsList[index] = el.value;
28799
- }
28809
+ })["catch"](function (error) {
28810
+ var object = {
28811
+ base64struct: str,
28812
+ error: error.message || error
28813
+ };
28814
+ setItemsMap(function (state) {
28815
+ return _objectSpread$p(_objectSpread$p({}, state), {}, _defineProperty$1({}, index, object));
28800
28816
  });
28801
- setItemsMap(itemsList);
28817
+ })["finally"](function () {
28802
28818
  setLoading(false);
28803
- setSelectedIndex(0);
28804
28819
  });
28805
- }, [server, structList]);
28820
+ };
28806
28821
  useEffect(function () {
28807
- getImages();
28808
- }, [getImages]);
28822
+ if (structList[selectedIndex] && !itemsMap[selectedIndex]) {
28823
+ getImage(structList[selectedIndex], selectedIndex);
28824
+ }
28825
+ }, [itemsMap, selectedIndex]);
28809
28826
  var renderStructure = function renderStructure(structure) {
28827
+ if (loading) {
28828
+ return jsx("div", {
28829
+ className: styles$8.centerWrapper,
28830
+ children: jsx(LoadingCircles, {})
28831
+ });
28832
+ }
28810
28833
  if (structure !== null && structure !== void 0 && structure.error) {
28811
28834
  var _itemsMap$selectedInd;
28812
28835
  return jsxs("div", {
@@ -28834,7 +28857,6 @@ var CDXStructuresViewer = function CDXStructuresViewer(_ref) {
28834
28857
  })
28835
28858
  });
28836
28859
  }
28837
- var menuList = Object.values(itemsMap) || [];
28838
28860
  return jsxs("div", {
28839
28861
  className: styles$8.structuresWrapper,
28840
28862
  children: [jsxs("div", {
@@ -28843,16 +28865,17 @@ var CDXStructuresViewer = function CDXStructuresViewer(_ref) {
28843
28865
  className: styles$8.header,
28844
28866
  children: "Select structure"
28845
28867
  }), jsx(MenuList, {
28846
- children: menuList.map(function (value, index) {
28868
+ children: structList.map(function (value, index) {
28869
+ var _itemsMap$index;
28847
28870
  return jsxs(MenuItem, {
28848
28871
  selected: index === selectedIndex,
28849
28872
  onClick: function onClick() {
28850
28873
  return setSelectedIndex(index);
28851
28874
  },
28852
- children: ["Structure ".concat(index + 1), value.error && jsx(Icon, {
28875
+ children: ["Structure ".concat(index + 1), ((_itemsMap$index = itemsMap[index]) === null || _itemsMap$index === void 0 ? void 0 : _itemsMap$index.error) && jsx(Icon, {
28853
28876
  name: "error"
28854
28877
  })]
28855
- }, value.base64struct + index);
28878
+ }, value + index);
28856
28879
  })
28857
28880
  })]
28858
28881
  }), jsx("div", {
@@ -28868,10 +28891,7 @@ var CDXStructuresViewer = function CDXStructuresViewer(_ref) {
28868
28891
  className: styles$8.fileName,
28869
28892
  children: fileName
28870
28893
  })]
28871
- }), loading ? jsx("div", {
28872
- className: styles$8.centerWrapper,
28873
- children: jsx(LoadingCircles, {})
28874
- }) : renderStructures()]
28894
+ }), renderStructures()]
28875
28895
  });
28876
28896
  };
28877
28897
 
@@ -28961,6 +28981,10 @@ var Open = function Open(props) {
28961
28981
  _useState10 = _slicedToArray$1(_useState9, 2),
28962
28982
  currentState = _useState10[0],
28963
28983
  setCurrentState = _useState10[1];
28984
+ var _useState11 = useState(false),
28985
+ _useState12 = _slicedToArray$1(_useState11, 2),
28986
+ isLoading = _useState12[0],
28987
+ setIsLoading = _useState12[1];
28964
28988
  useEffect(function () {
28965
28989
  if (server) {
28966
28990
  fileOpener(server).then(function (chosenOpener) {
@@ -28971,6 +28995,7 @@ var Open = function Open(props) {
28971
28995
  }
28972
28996
  }, [server]);
28973
28997
  var onFileLoad = function onFileLoad(files) {
28998
+ setIsLoading(true);
28974
28999
  var onLoad = function onLoad(fileContent) {
28975
29000
  if (fileContent.isPPTX) {
28976
29001
  setStructStr('');
@@ -28980,9 +29005,11 @@ var Open = function Open(props) {
28980
29005
  setStructStr(fileContent);
28981
29006
  setCurrentState(MODAL_STATES.textEditor);
28982
29007
  }
29008
+ setIsLoading(false);
28983
29009
  };
28984
29010
  var onError = function onError() {
28985
- return errorHandler('Error processing file');
29011
+ setIsLoading(false);
29012
+ errorHandler('Error processing file');
28986
29013
  };
28987
29014
  setFileName(files[0].name);
28988
29015
  opener.chosenOpener(files[0]).then(onLoad, onError);
@@ -29010,7 +29037,7 @@ var Open = function Open(props) {
29010
29037
  if (currentState === MODAL_STATES.imageRec) {
29011
29038
  return jsx(Recognize, _objectSpread$n({}, rest));
29012
29039
  }
29013
- return jsx(Dialog, {
29040
+ return jsxs(Dialog, {
29014
29041
  title: "Open structure",
29015
29042
  className: classes$n.open,
29016
29043
  params: rest,
@@ -29026,7 +29053,7 @@ var Open = function Open(props) {
29026
29053
  }) : undefined,
29027
29054
  buttons: [],
29028
29055
  withDivider: true,
29029
- children: jsx(ViewSwitcher, {
29056
+ children: [jsx(ViewSwitcher, {
29030
29057
  isAnalyzingFile: isAnalyzingFile,
29031
29058
  fileName: fileName,
29032
29059
  currentState: currentState,
@@ -29042,7 +29069,10 @@ var Open = function Open(props) {
29042
29069
  inputHandler: setStructStr,
29043
29070
  autoFocus: true,
29044
29071
  structList: structList
29045
- })
29072
+ }), isLoading && jsx("div", {
29073
+ className: classes$n.loadingContainer,
29074
+ children: jsx(LoadingCircles, {})
29075
+ })]
29046
29076
  });
29047
29077
  };
29048
29078
 
@@ -32417,8 +32447,7 @@ var AbbreviationLookup = function AbbreviationLookup(_ref) {
32417
32447
  loweredLookupValue = _useState6[0],
32418
32448
  setLoweredLookupValue = _useState6[1];
32419
32449
  useLayoutEffect(function () {
32420
- var _inputRef$current, _autocompleteRef$curr, _autocompleteRef$curr2, _autocompleteRef$curr3, _autocompleteRef$curr4;
32421
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
32450
+ var _autocompleteRef$curr, _autocompleteRef$curr2, _autocompleteRef$curr3, _autocompleteRef$curr4, _inputRef$current;
32422
32451
  var containerHeight = (_autocompleteRef$curr = (_autocompleteRef$curr2 = autocompleteRef.current) === null || _autocompleteRef$curr2 === void 0 ? void 0 : _autocompleteRef$curr2.offsetHeight) !== null && _autocompleteRef$curr !== void 0 ? _autocompleteRef$curr : 0;
32423
32452
  var containerWidth = (_autocompleteRef$curr3 = (_autocompleteRef$curr4 = autocompleteRef.current) === null || _autocompleteRef$curr4 === void 0 ? void 0 : _autocompleteRef$curr4.offsetWidth) !== null && _autocompleteRef$curr3 !== void 0 ? _autocompleteRef$curr3 : 0;
32424
32453
  var parentNode = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
@@ -32434,6 +32463,7 @@ var AbbreviationLookup = function AbbreviationLookup(_ref) {
32434
32463
  left: "".concat(left, "px"),
32435
32464
  top: "".concat(top, "px")
32436
32465
  });
32466
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
32437
32467
  return function () {
32438
32468
  var _inputRef$current2;
32439
32469
  (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || (_inputRef$current2 = _inputRef$current2.closest(KETCHER_ROOT_NODE_CSS_SELECTOR)) === null || _inputRef$current2 === void 0 || _inputRef$current2.getElementsByClassName(CLIP_AREA_BASE_CLASS)[0].focus();
@@ -32748,8 +32778,8 @@ var KetcherBuilder = function () {
32748
32778
  initApp(element, appRoot, staticResourcesUrl, {
32749
32779
  buttons: buttons || {},
32750
32780
  errorHandler: errorHandler || null,
32751
- version: "2.18.0-rc.4" ,
32752
- buildDate: "2024-02-06T12:50:19" ,
32781
+ version: "2.18.0-rc.6" ,
32782
+ buildDate: "2024-02-13T18:53:18" ,
32753
32783
  buildNumber: ''
32754
32784
  }, structService, resolve, togglerComponent);
32755
32785
  });