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

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.5\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: {
@@ -24524,14 +24524,32 @@ var props = {
24524
24524
  var ContextMenu = function ContextMenu() {
24525
24525
  var _useAppContext = useAppContext(),
24526
24526
  getKetcherInstance = _useAppContext.getKetcherInstance;
24527
+ var resetMenuPosition = function resetMenuPosition() {
24528
+ var contextMenuElement = document.querySelector('.contexify:last-of-type');
24529
+ var ketcherRootElement = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
24530
+ if (!contextMenuElement || !ketcherRootElement) {
24531
+ return;
24532
+ }
24533
+ var contextMenuElementBoundingBox = contextMenuElement.getBoundingClientRect();
24534
+ var ketcherRootElementBoundingBox = ketcherRootElement.getBoundingClientRect();
24535
+ if (!contextMenuElementBoundingBox || !ketcherRootElementBoundingBox) {
24536
+ return;
24537
+ }
24538
+ var left = contextMenuElementBoundingBox.right > ketcherRootElementBoundingBox.right ? contextMenuElementBoundingBox.x - (contextMenuElementBoundingBox.right - ketcherRootElementBoundingBox.right) : contextMenuElementBoundingBox.x;
24539
+ var top = contextMenuElementBoundingBox.bottom > ketcherRootElementBoundingBox.bottom ? contextMenuElementBoundingBox.y - (contextMenuElementBoundingBox.bottom - ketcherRootElementBoundingBox.bottom) : contextMenuElementBoundingBox.y;
24540
+ contextMenuElement.style.left = "".concat(left, "px");
24541
+ contextMenuElement.style.top = "".concat(top, "px");
24542
+ };
24527
24543
  var trackVisibility = useCallback(function (id, visible) {
24528
24544
  var editor = getKetcherInstance().editor;
24529
24545
  if (visible) {
24530
24546
  editor.hoverIcon.hide();
24547
+ resetMenuPosition();
24531
24548
  }
24532
24549
  editor.contextMenu[id] = visible;
24533
24550
  }, [getKetcherInstance]);
24534
- return jsxs(Fragment, {
24551
+ var ketcherEditorRootElement = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
24552
+ return ketcherEditorRootElement ? createPortal(jsxs(Fragment, {
24535
24553
  children: [jsx(Menu, _objectSpread$H(_objectSpread$H({}, props), {}, {
24536
24554
  id: CONTEXT_MENU_ID.FOR_BONDS,
24537
24555
  onVisibilityChange: function onVisibilityChange(visible) {
@@ -24563,7 +24581,7 @@ var ContextMenu = function ContextMenu() {
24563
24581
  },
24564
24582
  children: jsx(RGroupAttachmentPointMenuItems, {})
24565
24583
  }))]
24566
- });
24584
+ }), ketcherEditorRootElement) : null;
24567
24585
  };
24568
24586
 
24569
24587
  var getIsItemInSelection = function getIsItemInSelection(_ref) {
@@ -32417,8 +32435,7 @@ var AbbreviationLookup = function AbbreviationLookup(_ref) {
32417
32435
  loweredLookupValue = _useState6[0],
32418
32436
  setLoweredLookupValue = _useState6[1];
32419
32437
  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();
32438
+ var _autocompleteRef$curr, _autocompleteRef$curr2, _autocompleteRef$curr3, _autocompleteRef$curr4, _inputRef$current;
32422
32439
  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
32440
  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
32441
  var parentNode = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
@@ -32434,6 +32451,7 @@ var AbbreviationLookup = function AbbreviationLookup(_ref) {
32434
32451
  left: "".concat(left, "px"),
32435
32452
  top: "".concat(top, "px")
32436
32453
  });
32454
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
32437
32455
  return function () {
32438
32456
  var _inputRef$current2;
32439
32457
  (_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 +32766,8 @@ var KetcherBuilder = function () {
32748
32766
  initApp(element, appRoot, staticResourcesUrl, {
32749
32767
  buttons: buttons || {},
32750
32768
  errorHandler: errorHandler || null,
32751
- version: "2.18.0-rc.4" ,
32752
- buildDate: "2024-02-06T12:50:19" ,
32769
+ version: "2.18.0-rc.5" ,
32770
+ buildDate: "2024-02-09T16:22:25" ,
32753
32771
  buildNumber: ''
32754
32772
  }, structService, resolve, togglerComponent);
32755
32773
  });