ketcher-react 2.13.0-rc.2 → 2.13.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.
@@ -2513,7 +2513,8 @@ var SettingsManager = function () {
2513
2513
  return SettingsManager;
2514
2514
  }();
2515
2515
 
2516
- var _excluded$y = ["rescale", "fragment"];
2516
+ var _excluded$y = ["rescale", "fragment"],
2517
+ _excluded2$6 = ["isPaste"];
2517
2518
  function ownKeys$1b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2518
2519
  function _objectSpread$1c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1b(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2519
2520
  function onAction(action) {
@@ -2559,7 +2560,7 @@ function removeStructAction() {
2559
2560
  function load(struct, options) {
2560
2561
  return function () {
2561
2562
  var _ref = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(dispatch, getState) {
2562
- var state, editor, server, errorHandler, parsedStruct, _options2, fragment, hasUnsupportedGroups, oldStruct, stereAtomsMap;
2563
+ var state, editor, server, errorHandler, _options2, isPaste, otherOptions, parsedStruct, _otherOptions, fragment, hasUnsupportedGroups, oldStruct, stereAtomsMap;
2563
2564
  return _regeneratorRuntime.wrap(function _callee$(_context) {
2564
2565
  while (1) {
2565
2566
  switch (_context.prev = _context.next) {
@@ -2569,31 +2570,32 @@ function load(struct, options) {
2569
2570
  server = state.server;
2570
2571
  errorHandler = editor.errorHandler;
2571
2572
  options = options || {};
2572
- options = _objectSpread$1c(_objectSpread$1c({}, options), {}, {
2573
+ _options2 = options, isPaste = _options2.isPaste, otherOptions = _objectWithoutProperties(_options2, _excluded2$6);
2574
+ otherOptions = _objectSpread$1c(_objectSpread$1c({}, otherOptions), {}, {
2573
2575
  'dearomatize-on-load': editor.options()['dearomatize-on-load'],
2574
2576
  ignoreChiralFlag: editor.options().ignoreChiralFlag
2575
2577
  });
2576
2578
  dispatch(setAnalyzingFile(true));
2577
- _context.prev = 7;
2578
- _context.next = 10;
2579
- return parseStruct(struct, server, options);
2580
- case 10:
2579
+ _context.prev = 8;
2580
+ _context.next = 11;
2581
+ return parseStruct(struct, server, otherOptions);
2582
+ case 11:
2581
2583
  parsedStruct = _context.sent;
2582
- _options2 = options, fragment = _options2.fragment;
2584
+ _otherOptions = otherOptions, fragment = _otherOptions.fragment;
2583
2585
  hasUnsupportedGroups = parsedStruct.sgroups.some(function (sGroup) {
2584
2586
  return !supportedSGroupTypes[sGroup.type];
2585
2587
  });
2586
2588
  if (!hasUnsupportedGroups) {
2587
- _context.next = 17;
2589
+ _context.next = 18;
2588
2590
  break;
2589
2591
  }
2590
- _context.next = 16;
2592
+ _context.next = 17;
2591
2593
  return editor.event.confirm.dispatch();
2592
- case 16:
2594
+ case 17:
2593
2595
  parsedStruct.sgroups = parsedStruct.sgroups.filter(function (_key, sGroup) {
2594
2596
  return supportedSGroupTypes[sGroup.type];
2595
2597
  });
2596
- case 17:
2598
+ case 18:
2597
2599
  parsedStruct.rescale();
2598
2600
  if (editor.struct().atoms.size) {
2599
2601
  oldStruct = editor.struct().clone();
@@ -2638,29 +2640,31 @@ function load(struct, options) {
2638
2640
  } else {
2639
2641
  editor.struct(parsedStruct);
2640
2642
  }
2641
- editor.zoomAccordingContent();
2642
- editor.centerStruct();
2643
+ editor.zoomAccordingContent(parsedStruct);
2644
+ if (!isPaste) {
2645
+ editor.centerStruct();
2646
+ }
2643
2647
  dispatch(setAnalyzingFile(false));
2644
2648
  dispatch({
2645
2649
  type: 'MODAL_CLOSE'
2646
2650
  });
2647
- _context.next = 35;
2651
+ _context.next = 36;
2648
2652
  break;
2649
- case 31:
2650
- _context.prev = 31;
2651
- _context.t0 = _context["catch"](7);
2653
+ case 32:
2654
+ _context.prev = 32;
2655
+ _context.t0 = _context["catch"](8);
2652
2656
  dispatch(setAnalyzingFile(false));
2653
2657
  _context.t0 && errorHandler && errorHandler(_context.t0.message);
2654
- case 35:
2655
- _context.prev = 35;
2658
+ case 36:
2659
+ _context.prev = 36;
2656
2660
  emitEventRequestIsFinished();
2657
- return _context.finish(35);
2658
- case 38:
2661
+ return _context.finish(36);
2662
+ case 39:
2659
2663
  case "end":
2660
2664
  return _context.stop();
2661
2665
  }
2662
2666
  }
2663
- }, _callee, null, [[7, 31, 35, 38]]);
2667
+ }, _callee, null, [[8, 32, 36, 39]]);
2664
2668
  }));
2665
2669
  return function (_x, _x2) {
2666
2670
  return _ref.apply(this, arguments);
@@ -2790,6 +2794,11 @@ function serverTransform(method, data, struct) {
2790
2794
  });
2791
2795
  };
2792
2796
  }
2797
+ function resetStereoFlagsPosition(struct) {
2798
+ struct.frags.forEach(function (fragment) {
2799
+ return fragment.stereoFlagPosition = undefined;
2800
+ });
2801
+ }
2793
2802
  function serverCall(editor, server, method, options, struct) {
2794
2803
  var selection = editor.selection();
2795
2804
  var selectedAtoms = [];
@@ -2800,6 +2809,9 @@ function serverCall(editor, server, method, options, struct) {
2800
2809
  return aidMap.get(aid);
2801
2810
  });
2802
2811
  }
2812
+ if (method === 'layout') {
2813
+ resetStereoFlagsPosition(currentStruct);
2814
+ }
2803
2815
  var ketSerializer = new KetSerializer();
2804
2816
  return server.then(function () {
2805
2817
  return server[method](Object.assign({
@@ -3027,7 +3039,7 @@ var zoom = {
3027
3039
 
3028
3040
  var openHelpLink = function openHelpLink() {
3029
3041
  var _window$open;
3030
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.13.0-rc.2\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3042
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.13.0-rc.3\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3031
3043
  };
3032
3044
  var help = {
3033
3045
  help: {
@@ -12532,7 +12544,8 @@ function initClipboard(dispatch) {
12532
12544
  onPaste: function onPaste(data) {
12533
12545
  var structStr = data[ChemicalMimeType.KET] || data[ChemicalMimeType.Mol] || data[ChemicalMimeType.Rxn] || data['text/plain'];
12534
12546
  if (structStr || !rxnTextPlain.test(data['text/plain'])) loadStruct(structStr, {
12535
- fragment: true
12547
+ fragment: true,
12548
+ isPaste: true
12536
12549
  });
12537
12550
  }
12538
12551
  };
@@ -21534,18 +21547,27 @@ var Editor$3 = function () {
21534
21547
  }
21535
21548
  }, {
21536
21549
  key: "zoomAccordingContent",
21537
- value: function zoomAccordingContent() {
21538
- this.zoom(1);
21539
- var clientAreaBoundingBox = this.render.clientArea.getBoundingClientRect();
21540
- var paper = this.render.paper;
21550
+ value: function zoomAccordingContent(struct) {
21541
21551
  var MIN_ZOOM_VALUE = 0.1;
21542
21552
  var MAX_ZOOM_VALUE = 1;
21543
- var MARGIN = 0.02;
21544
- var newZoomValue = paper.height - clientAreaBoundingBox.height > paper.width - clientAreaBoundingBox.width ? clientAreaBoundingBox.height / paper.height : clientAreaBoundingBox.width / paper.width;
21545
- newZoomValue -= MARGIN;
21546
- if (newZoomValue < MAX_ZOOM_VALUE) {
21547
- this.zoom(newZoomValue < MIN_ZOOM_VALUE ? MIN_ZOOM_VALUE : Number(newZoomValue.toFixed(2)));
21553
+ var MARGIN_IN_PIXELS = 40;
21554
+ var parsedStructCoordBoundingBox = struct.getCoordBoundingBox();
21555
+ var parsedStructSize = new Vec2(parsedStructCoordBoundingBox.max.x - parsedStructCoordBoundingBox.min.x, parsedStructCoordBoundingBox.max.y - parsedStructCoordBoundingBox.min.y);
21556
+ var parsedStructSizeInPixels = {
21557
+ width: parsedStructSize.x * this.render.options.scale * this.render.options.zoom,
21558
+ height: parsedStructSize.y * this.render.options.scale * this.render.options.zoom
21559
+ };
21560
+ var clientAreaBoundingBox = this.render.clientArea.getBoundingClientRect();
21561
+ if (parsedStructSizeInPixels.width + MARGIN_IN_PIXELS < clientAreaBoundingBox.width && parsedStructSizeInPixels.height + MARGIN_IN_PIXELS < clientAreaBoundingBox.height) {
21562
+ return;
21548
21563
  }
21564
+ var newZoomValue = this.render.options.zoom / (parsedStructSizeInPixels.height - clientAreaBoundingBox.height > parsedStructSizeInPixels.width - clientAreaBoundingBox.width ? parsedStructSizeInPixels.height / clientAreaBoundingBox.height : parsedStructSizeInPixels.width / clientAreaBoundingBox.width);
21565
+ if (newZoomValue >= MAX_ZOOM_VALUE) {
21566
+ this.zoom(MAX_ZOOM_VALUE);
21567
+ return;
21568
+ }
21569
+ newZoomValue -= MARGIN_IN_PIXELS / clientAreaBoundingBox.width;
21570
+ this.zoom(newZoomValue < MIN_ZOOM_VALUE ? MIN_ZOOM_VALUE : Number(newZoomValue.toFixed(2)));
21549
21571
  }
21550
21572
  }, {
21551
21573
  key: "selection",
@@ -29546,10 +29568,10 @@ var mapDispatchToProps$1 = function mapDispatchToProps(dispatch) {
29546
29568
  var onZoomOut = function onZoomOut() {
29547
29569
  return dispatchAction(dispatch, 'zoom-out');
29548
29570
  };
29549
- return _objectSpread$2({
29550
- onZoomIn: onZoomIn,
29551
- onZoomOut: onZoomOut
29552
- }, dispatch(initEditor));
29571
+ return _objectSpread$2(_objectSpread$2({}, dispatch(initEditor)), {}, {
29572
+ onZoomOut: onZoomOut,
29573
+ onZoomIn: onZoomIn
29574
+ });
29553
29575
  };
29554
29576
  var Editor$1 = connect(function (state) {
29555
29577
  return {
@@ -29991,8 +30013,8 @@ var KetcherBuilder = function () {
29991
30013
  initApp(element, staticResourcesUrl, {
29992
30014
  buttons: buttons || {},
29993
30015
  errorHandler: errorHandler || null,
29994
- version: "2.13.0-rc.2" ,
29995
- buildDate: "2023-07-27T11:07:44" ,
30016
+ version: "2.13.0-rc.3" ,
30017
+ buildDate: "2023-08-04T11:43:37" ,
29996
30018
  buildNumber: ''
29997
30019
  }, structService, resolve);
29998
30020
  });