ketcher-react 2.16.0-rc.3 → 2.16.0-rc.4

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.
package/dist/index.js CHANGED
@@ -397,6 +397,15 @@ function lookup(map, event) {
397
397
  }
398
398
  keyNorm.lookup = lookup;
399
399
 
400
+ function isClipboardAPIAvailable() {
401
+ var _navigator, _navigator$clipboard;
402
+ return typeof ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$clipboard = _navigator.clipboard) === null || _navigator$clipboard === void 0 ? void 0 : _navigator$clipboard.writeText) === 'function';
403
+ }
404
+ function notifyCopyCut() {
405
+ var event = new Event('copyOrCutComplete');
406
+ window.dispatchEvent(event);
407
+ }
408
+
400
409
  function _createForOfIteratorHelper$f(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$f(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
401
410
  function _unsupportedIterableToArray$f(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$f(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$f(o, minLen); }
402
411
  function _arrayLikeToArray$f(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
@@ -430,70 +439,135 @@ var ClipArea = function (_Component) {
430
439
  if (event.shiftKey && !isActiveElement(event.target)) event.preventDefault();
431
440
  },
432
441
  copy: function copy(event) {
433
- if (_this2.props.focused() && _this2.props.onCopy) {
434
- var data = _this2.props.onCopy();
435
- if (data) _copy(event.clipboardData, data);
436
- event.preventDefault();
442
+ if (!_this2.props.focused()) {
443
+ return;
437
444
  }
438
- },
439
- cut: function cut(event) {
440
- if (_this2.props.focused() && _this2.props.onCut) {
441
- var data = _this2.props.onCut();
442
- if (data) _copy(event.clipboardData, data);
445
+ if (isClipboardAPIAvailable()) {
446
+ _this2.props.onCopy().then(function (data) {
447
+ if (!data) {
448
+ return;
449
+ }
450
+ _copy(data).then(function () {
451
+ event.preventDefault();
452
+ notifyCopyCut();
453
+ });
454
+ });
455
+ } else {
456
+ var data = _this2.props.onLegacyCopy();
457
+ if (data) {
458
+ legacyCopy(event.clipboardData, data);
459
+ }
443
460
  event.preventDefault();
444
461
  }
445
462
  },
463
+ cut: function () {
464
+ var _cut = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee(event) {
465
+ var data;
466
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
467
+ while (1) {
468
+ switch (_context.prev = _context.next) {
469
+ case 0:
470
+ if (_this2.props.focused()) {
471
+ _context.next = 2;
472
+ break;
473
+ }
474
+ return _context.abrupt("return");
475
+ case 2:
476
+ if (isClipboardAPIAvailable()) {
477
+ _this2.props.onCut().then(function (data) {
478
+ if (!data) {
479
+ return;
480
+ }
481
+ _copy(data).then(function () {
482
+ event.preventDefault();
483
+ notifyCopyCut();
484
+ });
485
+ });
486
+ } else {
487
+ data = _this2.props.onLegacyCut();
488
+ if (data) {
489
+ legacyCopy(event.clipboardData, data);
490
+ }
491
+ event.preventDefault();
492
+ }
493
+ case 3:
494
+ case "end":
495
+ return _context.stop();
496
+ }
497
+ }
498
+ }, _callee);
499
+ }));
500
+ function cut(_x) {
501
+ return _cut.apply(this, arguments);
502
+ }
503
+ return cut;
504
+ }(),
446
505
  paste: function paste(event) {
447
- if (_this2.props.focused() && _this2.props.onPaste) {
448
- var data = _paste(event.clipboardData, _this2.props.formats);
449
- if (data) _this2.props.onPaste(data);
506
+ if (!_this2.props.focused()) {
507
+ return;
508
+ }
509
+ if (isClipboardAPIAvailable()) {
510
+ navigator.clipboard.read().then(function (data) {
511
+ if (!data) {
512
+ return;
513
+ }
514
+ _this2.props.onPaste(data).then(function () {
515
+ event.preventDefault();
516
+ ketcherCore.notifyRequestCompleted();
517
+ });
518
+ });
519
+ } else {
520
+ var data = legacyPaste(event.clipboardData, _this2.props.formats);
521
+ if (data) {
522
+ _this2.props.onLegacyPaste(data);
523
+ }
450
524
  event.preventDefault();
451
525
  }
452
526
  },
453
527
  keydown: function () {
454
- var _keydown = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee(event) {
528
+ var _keydown = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee2(event) {
455
529
  var _navigator$clipboard, clipboardData, data, _window$ketcher$edito, _window$ketcher$edito2;
456
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
530
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
457
531
  while (1) {
458
- switch (_context.prev = _context.next) {
532
+ switch (_context2.prev = _context2.next) {
459
533
  case 0:
460
534
  if (!(!_this2.props.focused() || !_this2.props.onPaste)) {
461
- _context.next = 2;
535
+ _context2.next = 2;
462
536
  break;
463
537
  }
464
- return _context.abrupt("return");
538
+ return _context2.abrupt("return");
465
539
  case 2:
466
540
  if (!(isControlKey(event) && event.altKey && event.code === 'KeyV')) {
467
- _context.next = 14;
541
+ _context2.next = 14;
468
542
  break;
469
543
  }
470
544
  if (!((_navigator$clipboard = navigator.clipboard) !== null && _navigator$clipboard !== void 0 && _navigator$clipboard.read)) {
471
- _context.next = 13;
545
+ _context2.next = 13;
472
546
  break;
473
547
  }
474
- _context.next = 6;
548
+ _context2.next = 6;
475
549
  return navigator.clipboard.read();
476
550
  case 6:
477
- clipboardData = _context.sent;
478
- _context.next = 9;
551
+ clipboardData = _context2.sent;
552
+ _context2.next = 9;
479
553
  return pasteByKeydown(clipboardData);
480
554
  case 9:
481
- data = _context.sent;
555
+ data = _context2.sent;
482
556
  if (data) {
483
557
  _this2.props.onPaste(data, true);
484
558
  }
485
- _context.next = 14;
559
+ _context2.next = 14;
486
560
  break;
487
561
  case 13:
488
562
  (_window$ketcher$edito = (_window$ketcher$edito2 = window.ketcher.editor).errorHandler) === null || _window$ketcher$edito === void 0 ? void 0 : _window$ketcher$edito.call(_window$ketcher$edito2, "Your browser doesn't support pasting clipboard content via Ctrl-Alt-V. Please use Google Chrome browser or load SMARTS structure from .smarts file instead.");
489
563
  case 14:
490
564
  case "end":
491
- return _context.stop();
565
+ return _context2.stop();
492
566
  }
493
567
  }
494
- }, _callee);
568
+ }, _callee2);
495
569
  }));
496
- function keydown(_x) {
570
+ function keydown(_x2) {
497
571
  return _keydown.apply(this, arguments);
498
572
  }
499
573
  return keydown;
@@ -539,23 +613,58 @@ function autoselect(cliparea) {
539
613
  cliparea.value = ' ';
540
614
  cliparea.select();
541
615
  }
542
- function _copy(cb, data) {
543
- if (!cb && ieCb) {
616
+ function _copy(_x3) {
617
+ return _copy2.apply(this, arguments);
618
+ }
619
+ function _copy2() {
620
+ _copy2 = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee3(data) {
621
+ var clipboardItemData;
622
+ return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
623
+ while (1) {
624
+ switch (_context3.prev = _context3.next) {
625
+ case 0:
626
+ _context3.prev = 0;
627
+ clipboardItemData = {};
628
+ Object.keys(data).forEach(function (mimeType) {
629
+ var mimeTypeToSet = mimeType === 'text/plain' ? mimeType : "web ".concat(mimeType);
630
+ clipboardItemData[mimeTypeToSet] = Promise.resolve(new Blob([data[mimeType]], {
631
+ type: mimeTypeToSet
632
+ }));
633
+ });
634
+ _context3.next = 5;
635
+ return navigator.clipboard.write([new ClipboardItem(clipboardItemData)]);
636
+ case 5:
637
+ _context3.next = 11;
638
+ break;
639
+ case 7:
640
+ _context3.prev = 7;
641
+ _context3.t0 = _context3["catch"](0);
642
+ ketcherCore.KetcherLogger.error('cliparea.jsx::copy', _context3.t0);
643
+ case 11:
644
+ case "end":
645
+ return _context3.stop();
646
+ }
647
+ }
648
+ }, _callee3, null, [[0, 7]]);
649
+ }));
650
+ return _copy2.apply(this, arguments);
651
+ }
652
+ function legacyCopy(clipboardData, data) {
653
+ if (!clipboardData && ieCb) {
544
654
  ieCb.setData('text', data['text/plain']);
545
655
  } else {
546
656
  var curFmt = null;
547
- cb.setData('text/plain', data['text/plain']);
657
+ clipboardData.setData('text/plain', data['text/plain']);
548
658
  try {
549
659
  Object.keys(data).forEach(function (fmt) {
550
660
  curFmt = fmt;
551
- cb.setData(fmt, data[fmt]);
661
+ clipboardData.setData(fmt, data[fmt]);
552
662
  });
553
663
  } catch (e) {
554
- ketcherCore.KetcherLogger.error('cliparea.jsx::copy', e);
555
664
  }
556
665
  }
557
666
  }
558
- function _paste(cb, formats) {
667
+ function legacyPaste(cb, formats) {
559
668
  var data = {};
560
669
  if (!cb && ieCb) {
561
670
  data['text/plain'] = ieCb.getData('text');
@@ -569,64 +678,64 @@ function _paste(cb, formats) {
569
678
  }
570
679
  return data;
571
680
  }
572
- function pasteByKeydown(_x2) {
681
+ function pasteByKeydown(_x4) {
573
682
  return _pasteByKeydown.apply(this, arguments);
574
683
  }
575
684
  function _pasteByKeydown() {
576
- _pasteByKeydown = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee2(clipboardData) {
685
+ _pasteByKeydown = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee4(clipboardData) {
577
686
  var data, _iterator, _step, item, textPlain;
578
- return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
687
+ return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
579
688
  while (1) {
580
- switch (_context2.prev = _context2.next) {
689
+ switch (_context4.prev = _context4.next) {
581
690
  case 0:
582
691
  data = {};
583
692
  if (!(!clipboardData && ieCb)) {
584
- _context2.next = 5;
693
+ _context4.next = 5;
585
694
  break;
586
695
  }
587
696
  data['text/plain'] = ieCb.getData('text');
588
- _context2.next = 26;
697
+ _context4.next = 26;
589
698
  break;
590
699
  case 5:
591
700
  _iterator = _createForOfIteratorHelper$f(clipboardData);
592
- _context2.prev = 6;
701
+ _context4.prev = 6;
593
702
  _iterator.s();
594
703
  case 8:
595
704
  if ((_step = _iterator.n()).done) {
596
- _context2.next = 18;
705
+ _context4.next = 18;
597
706
  break;
598
707
  }
599
708
  item = _step.value;
600
- _context2.next = 12;
709
+ _context4.next = 12;
601
710
  return item.getType('text/plain');
602
711
  case 12:
603
- textPlain = _context2.sent;
604
- _context2.next = 15;
712
+ textPlain = _context4.sent;
713
+ _context4.next = 15;
605
714
  return textPlain.text();
606
715
  case 15:
607
- data['text/plain'] = _context2.sent;
716
+ data['text/plain'] = _context4.sent;
608
717
  case 16:
609
- _context2.next = 8;
718
+ _context4.next = 8;
610
719
  break;
611
720
  case 18:
612
- _context2.next = 23;
721
+ _context4.next = 23;
613
722
  break;
614
723
  case 20:
615
- _context2.prev = 20;
616
- _context2.t0 = _context2["catch"](6);
617
- _iterator.e(_context2.t0);
724
+ _context4.prev = 20;
725
+ _context4.t0 = _context4["catch"](6);
726
+ _iterator.e(_context4.t0);
618
727
  case 23:
619
- _context2.prev = 23;
728
+ _context4.prev = 23;
620
729
  _iterator.f();
621
- return _context2.finish(23);
730
+ return _context4.finish(23);
622
731
  case 26:
623
- return _context2.abrupt("return", data);
732
+ return _context4.abrupt("return", data);
624
733
  case 27:
625
734
  case "end":
626
- return _context2.stop();
735
+ return _context4.stop();
627
736
  }
628
737
  }
629
- }, _callee2, null, [[6, 20, 23, 26]]);
738
+ }, _callee4, null, [[6, 20, 23, 26]]);
630
739
  }));
631
740
  return _pasteByKeydown.apply(this, arguments);
632
741
  }
@@ -3251,7 +3360,7 @@ function load(struct, options) {
3251
3360
  _context.t0 && errorHandler && errorHandler(_context.t0.message);
3252
3361
  case 37:
3253
3362
  _context.prev = 37;
3254
- ketcherCore.emitEventRequestIsFinished();
3363
+ ketcherCore.notifyRequestCompleted();
3255
3364
  return _context.finish(37);
3256
3365
  case 40:
3257
3366
  case "end":
@@ -3636,7 +3745,7 @@ var zoom = {
3636
3745
 
3637
3746
  var openHelpLink = function openHelpLink() {
3638
3747
  var _window$open;
3639
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.16.0-rc.3\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3748
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.16.0-rc.4\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3640
3749
  };
3641
3750
  var help = {
3642
3751
  help: {
@@ -14289,7 +14398,7 @@ var mapDispatchToProps$j = function mapDispatchToProps(dispatch) {
14289
14398
  var RightToolbarContainer = reactRedux.connect(mapStateToProps$j, mapDispatchToProps$j)(RightToolbar);
14290
14399
 
14291
14400
  var _templateObject$7;
14292
- var TopToolbarIconButton = styled__default["default"](IconButton)(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral__default["default"](["\n border-radius: 4px;\n padding: 2px;\n\n @media only screen and (min-width: 1024px) {\n height: 32px;\n width: 32px;\n padding: 4px;\n }\n @media only screen and (min-width: 1920px) {\n height: 40px;\n width: 40px;\n padding: 5px;\n }\n"])));
14401
+ var TopToolbarIconButton = styled__default["default"](IconButton)(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral__default["default"](["\n border-radius: 4px;\n padding: 2px;\n\n @media only screen {\n @container (min-width: 1024px) {\n height: 32px;\n width: 32px;\n padding: 4px;\n }\n }\n @media only screen {\n @container (min-width: 1920px) {\n height: 40px;\n width: 40px;\n padding: 5px;\n }\n }\n"])));
14293
14402
 
14294
14403
  var FileControls = function FileControls(_ref) {
14295
14404
  var onFileOpen = _ref.onFileOpen,
@@ -14771,7 +14880,7 @@ var ExternalFuncControls = function ExternalFuncControls(_ref) {
14771
14880
 
14772
14881
  var _templateObject$2;
14773
14882
  var collapseLimit = 650;
14774
- var ControlsPanel = styled__default["default"]('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral__default["default"](["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 0px;\n height: 36px;\n padding: 0px 22px;\n background-color: #ffffff;\n box-shadow: 0px 2px 5px rgba(103, 104, 132, 0.15);\n\n .group {\n display: flex;\n flex-direction: row;\n gap: 0px;\n }\n\n & * {\n box-sizing: border-box;\n }\n\n @media only screen and (min-width: 1024px) {\n height: 40px;\n gap: 0px;\n padding-bottom: 0;\n .group {\n gap: 4px;\n }\n }\n\n @media only screen and (min-width: 1920px) {\n height: 64px;\n gap: 12px;\n }\n"])));
14883
+ var ControlsPanel = styled__default["default"]('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral__default["default"](["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 0px;\n height: 36px;\n padding: 0px 22px;\n background-color: #ffffff;\n box-shadow: 0px 2px 5px rgba(103, 104, 132, 0.15);\n\n .group {\n display: flex;\n flex-direction: row;\n gap: 0px;\n }\n\n & * {\n box-sizing: border-box;\n }\n\n @media only screen {\n @container (min-width: 1024px) {\n height: 40px;\n gap: 0px;\n padding-bottom: 0;\n .group {\n gap: 4px;\n }\n }\n }\n\n @media only screen {\n @container (min-width: 1920px) {\n height: 64px;\n gap: 12px;\n }\n }\n"])));
14775
14884
  var TopToolbar = function TopToolbar(_ref) {
14776
14885
  var className = _ref.className,
14777
14886
  disabledButtons = _ref.disabledButtons,
@@ -17674,46 +17783,330 @@ function initClipboard(dispatch) {
17674
17783
  var state = global.currentState;
17675
17784
  return !state.modal;
17676
17785
  },
17677
- onCut: function onCut() {
17786
+ onLegacyCut: function onLegacyCut() {
17678
17787
  var state = global.currentState;
17679
17788
  var editor = state.editor;
17680
- var data = clipData(editor);
17789
+ var data = legacyClipData(editor);
17681
17790
  if (data) debAction({
17682
17791
  tool: 'eraser',
17683
17792
  opts: 1
17684
17793
  });else editor.selection(null);
17685
17794
  return data;
17686
17795
  },
17687
- onCopy: function onCopy() {
17796
+ onCut: function onCut() {
17797
+ return _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee2() {
17798
+ var ketcherInstance, result;
17799
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
17800
+ while (1) {
17801
+ switch (_context2.prev = _context2.next) {
17802
+ case 0:
17803
+ ketcherInstance = ketcherCore.ketcherProvider.getKetcher();
17804
+ _context2.next = 3;
17805
+ return ketcherCore.runAsyncAction( _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee() {
17806
+ var state, editor, data;
17807
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
17808
+ while (1) {
17809
+ switch (_context.prev = _context.next) {
17810
+ case 0:
17811
+ state = global.currentState;
17812
+ editor = state.editor;
17813
+ _context.next = 4;
17814
+ return clipData(editor);
17815
+ case 4:
17816
+ data = _context.sent;
17817
+ if (data) debAction({
17818
+ tool: 'eraser',
17819
+ opts: 1
17820
+ });else editor.selection(null);
17821
+ return _context.abrupt("return", data);
17822
+ case 7:
17823
+ case "end":
17824
+ return _context.stop();
17825
+ }
17826
+ }
17827
+ }, _callee);
17828
+ })), ketcherInstance.eventBus);
17829
+ case 3:
17830
+ result = _context2.sent;
17831
+ return _context2.abrupt("return", result);
17832
+ case 5:
17833
+ case "end":
17834
+ return _context2.stop();
17835
+ }
17836
+ }
17837
+ }, _callee2);
17838
+ }))();
17839
+ },
17840
+ onLegacyCopy: function onLegacyCopy() {
17688
17841
  var state = global.currentState;
17689
17842
  var editor = state.editor;
17690
- var data = clipData(editor);
17843
+ var data = legacyClipData(editor);
17691
17844
  editor.selection(null);
17692
17845
  return data;
17693
17846
  },
17847
+ onCopy: function onCopy() {
17848
+ return _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee4() {
17849
+ var ketcherInstance, result;
17850
+ return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
17851
+ while (1) {
17852
+ switch (_context4.prev = _context4.next) {
17853
+ case 0:
17854
+ ketcherInstance = ketcherCore.ketcherProvider.getKetcher();
17855
+ _context4.next = 3;
17856
+ return ketcherCore.runAsyncAction( _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee3() {
17857
+ var state, editor, data;
17858
+ return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
17859
+ while (1) {
17860
+ switch (_context3.prev = _context3.next) {
17861
+ case 0:
17862
+ state = global.currentState;
17863
+ editor = state.editor;
17864
+ _context3.next = 4;
17865
+ return clipData(editor);
17866
+ case 4:
17867
+ data = _context3.sent;
17868
+ editor.selection(null);
17869
+ return _context3.abrupt("return", data);
17870
+ case 7:
17871
+ case "end":
17872
+ return _context3.stop();
17873
+ }
17874
+ }
17875
+ }, _callee3);
17876
+ })), ketcherInstance.eventBus);
17877
+ case 3:
17878
+ result = _context4.sent;
17879
+ return _context4.abrupt("return", result);
17880
+ case 5:
17881
+ case "end":
17882
+ return _context4.stop();
17883
+ }
17884
+ }
17885
+ }, _callee4);
17886
+ }))();
17887
+ },
17694
17888
  onPaste: function onPaste(data, isSmarts) {
17889
+ return _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee6() {
17890
+ var ketcherInstance, result;
17891
+ return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
17892
+ while (1) {
17893
+ switch (_context6.prev = _context6.next) {
17894
+ case 0:
17895
+ ketcherInstance = ketcherCore.ketcherProvider.getKetcher();
17896
+ _context6.next = 3;
17897
+ return ketcherCore.runAsyncAction( _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee5() {
17898
+ var structStr;
17899
+ return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
17900
+ while (1) {
17901
+ switch (_context5.prev = _context5.next) {
17902
+ case 0:
17903
+ _context5.next = 2;
17904
+ return getStructStringFromClipboardData(data);
17905
+ case 2:
17906
+ structStr = _context5.sent;
17907
+ if (structStr || !rxnTextPlain.test(data['text/plain'])) {
17908
+ if (isSmarts) {
17909
+ loadStruct(structStr, {
17910
+ fragment: true,
17911
+ isPaste: true,
17912
+ 'input-format': ketcherCore.ChemicalMimeType.DaylightSmarts
17913
+ });
17914
+ } else {
17915
+ loadStruct(structStr, {
17916
+ fragment: true,
17917
+ isPaste: true
17918
+ });
17919
+ }
17920
+ }
17921
+ case 4:
17922
+ case "end":
17923
+ return _context5.stop();
17924
+ }
17925
+ }
17926
+ }, _callee5);
17927
+ })), ketcherInstance.eventBus);
17928
+ case 3:
17929
+ result = _context6.sent;
17930
+ return _context6.abrupt("return", result);
17931
+ case 5:
17932
+ case "end":
17933
+ return _context6.stop();
17934
+ }
17935
+ }
17936
+ }, _callee6);
17937
+ }))();
17938
+ },
17939
+ onLegacyPaste: function onLegacyPaste(data, isSmarts) {
17695
17940
  var structStr = data[ketcherCore.ChemicalMimeType.KET] || data[ketcherCore.ChemicalMimeType.Mol] || data[ketcherCore.ChemicalMimeType.Rxn] || data['text/plain'];
17696
- if (structStr || !rxnTextPlain.test(data['text/plain'])) isSmarts ? loadStruct(structStr, {
17697
- fragment: true,
17698
- isPaste: true,
17699
- 'input-format': ketcherCore.ChemicalMimeType.DaylightSmarts
17700
- }) : loadStruct(structStr, {
17701
- fragment: true,
17702
- isPaste: true
17703
- });
17941
+ if (structStr || !rxnTextPlain.test(data['text/plain'])) {
17942
+ if (isSmarts) {
17943
+ loadStruct(structStr, {
17944
+ fragment: true,
17945
+ isPaste: true,
17946
+ 'input-format': ketcherCore.ChemicalMimeType.DaylightSmarts
17947
+ });
17948
+ } else {
17949
+ loadStruct(structStr, {
17950
+ fragment: true,
17951
+ isPaste: true
17952
+ });
17953
+ }
17954
+ }
17704
17955
  }
17705
17956
  };
17706
17957
  }
17707
- function clipData(editor) {
17708
- var res = {};
17958
+ function safelyGetMimeType(_x, _x2) {
17959
+ return _safelyGetMimeType.apply(this, arguments);
17960
+ }
17961
+ function _safelyGetMimeType() {
17962
+ _safelyGetMimeType = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee7(clipboardItem, mimeType) {
17963
+ var result;
17964
+ return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
17965
+ while (1) {
17966
+ switch (_context7.prev = _context7.next) {
17967
+ case 0:
17968
+ _context7.prev = 0;
17969
+ _context7.next = 3;
17970
+ return clipboardItem.getType(mimeType);
17971
+ case 3:
17972
+ result = _context7.sent;
17973
+ return _context7.abrupt("return", result);
17974
+ case 7:
17975
+ _context7.prev = 7;
17976
+ _context7.t0 = _context7["catch"](0);
17977
+ return _context7.abrupt("return", '');
17978
+ case 10:
17979
+ case "end":
17980
+ return _context7.stop();
17981
+ }
17982
+ }
17983
+ }, _callee7, null, [[0, 7]]);
17984
+ }));
17985
+ return _safelyGetMimeType.apply(this, arguments);
17986
+ }
17987
+ function getStructStringFromClipboardData(_x3) {
17988
+ return _getStructStringFromClipboardData.apply(this, arguments);
17989
+ }
17990
+ function _getStructStringFromClipboardData() {
17991
+ _getStructStringFromClipboardData = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee8(data) {
17992
+ var clipboardItem, structStr;
17993
+ return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
17994
+ while (1) {
17995
+ switch (_context8.prev = _context8.next) {
17996
+ case 0:
17997
+ clipboardItem = data[0];
17998
+ _context8.next = 3;
17999
+ return safelyGetMimeType(clipboardItem, "web ".concat(ketcherCore.ChemicalMimeType.KET));
18000
+ case 3:
18001
+ _context8.t2 = _context8.sent;
18002
+ if (_context8.t2) {
18003
+ _context8.next = 8;
18004
+ break;
18005
+ }
18006
+ _context8.next = 7;
18007
+ return safelyGetMimeType(clipboardItem, "web ".concat(ketcherCore.ChemicalMimeType.Mol));
18008
+ case 7:
18009
+ _context8.t2 = _context8.sent;
18010
+ case 8:
18011
+ _context8.t1 = _context8.t2;
18012
+ if (_context8.t1) {
18013
+ _context8.next = 13;
18014
+ break;
18015
+ }
18016
+ _context8.next = 12;
18017
+ return safelyGetMimeType(clipboardItem, "web ".concat(ketcherCore.ChemicalMimeType.Rxn));
18018
+ case 12:
18019
+ _context8.t1 = _context8.sent;
18020
+ case 13:
18021
+ _context8.t0 = _context8.t1;
18022
+ if (_context8.t0) {
18023
+ _context8.next = 18;
18024
+ break;
18025
+ }
18026
+ _context8.next = 17;
18027
+ return safelyGetMimeType(clipboardItem, 'text/plain');
18028
+ case 17:
18029
+ _context8.t0 = _context8.sent;
18030
+ case 18:
18031
+ structStr = _context8.t0;
18032
+ return _context8.abrupt("return", structStr === '' ? '' : structStr.text());
18033
+ case 20:
18034
+ case "end":
18035
+ return _context8.stop();
18036
+ }
18037
+ }
18038
+ }, _callee8);
18039
+ }));
18040
+ return _getStructStringFromClipboardData.apply(this, arguments);
18041
+ }
18042
+ function isAbleToCopy(editor) {
17709
18043
  var struct = editor.structSelected();
17710
18044
  var errorHandler = editor.errorHandler;
17711
- if (struct.isBlank()) return null;
18045
+ if (struct.isBlank()) {
18046
+ return false;
18047
+ }
17712
18048
  var simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
17713
- if (simpleObjectOrText && reactDeviceDetect.isIE) {
18049
+ if (simpleObjectOrText && reactDeviceDetect.isIE && errorHandler) {
17714
18050
  errorHandler('The structure you are trying to copy contains Simple object or/and Text object.' + 'To copy Simple object or Text object in Internet Explorer try "Copy as KET" button');
18051
+ return false;
18052
+ }
18053
+ return true;
18054
+ }
18055
+ function clipData(_x4) {
18056
+ return _clipData.apply(this, arguments);
18057
+ }
18058
+ function _clipData() {
18059
+ _clipData = _asyncToGenerator__default["default"]( _regeneratorRuntime__default["default"].mark(function _callee9(editor) {
18060
+ var res, struct, errorHandler, serializer, ket, ketcherInstance, data, type;
18061
+ return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
18062
+ while (1) {
18063
+ switch (_context9.prev = _context9.next) {
18064
+ case 0:
18065
+ if (isAbleToCopy(editor)) {
18066
+ _context9.next = 2;
18067
+ break;
18068
+ }
18069
+ return _context9.abrupt("return", null);
18070
+ case 2:
18071
+ res = {};
18072
+ struct = editor.structSelected();
18073
+ errorHandler = editor.errorHandler;
18074
+ _context9.prev = 5;
18075
+ serializer = new ketcherCore.KetSerializer();
18076
+ ket = serializer.serialize(struct);
18077
+ ketcherInstance = ketcherCore.ketcherProvider.getKetcher();
18078
+ _context9.next = 11;
18079
+ return ketcherCore.getStructure(ketcherCore.SupportedFormat.molAuto, ketcherInstance.formatterFactory, struct);
18080
+ case 11:
18081
+ data = _context9.sent;
18082
+ res[ketcherCore.ChemicalMimeType.KET] = ket;
18083
+ type = struct.isReaction ? ketcherCore.ChemicalMimeType.Mol : ketcherCore.ChemicalMimeType.Rxn;
18084
+ res['text/plain'] = data;
18085
+ res[type] = data;
18086
+ return _context9.abrupt("return", res);
18087
+ case 19:
18088
+ _context9.prev = 19;
18089
+ _context9.t0 = _context9["catch"](5);
18090
+ ketcherCore.KetcherLogger.error('hotkeys.ts::clipData', _context9.t0);
18091
+ errorHandler && errorHandler(_context9.t0.message);
18092
+ case 23:
18093
+ return _context9.abrupt("return", null);
18094
+ case 24:
18095
+ case "end":
18096
+ return _context9.stop();
18097
+ }
18098
+ }
18099
+ }, _callee9, null, [[5, 19]]);
18100
+ }));
18101
+ return _clipData.apply(this, arguments);
18102
+ }
18103
+ function legacyClipData(editor) {
18104
+ if (!isAbleToCopy(editor)) {
17715
18105
  return null;
17716
18106
  }
18107
+ var res = {};
18108
+ var struct = editor.structSelected();
18109
+ var errorHandler = editor.errorHandler;
17717
18110
  var molSerializer = new ketcherCore.MolSerializer();
17718
18111
  try {
17719
18112
  var serializer = new ketcherCore.KetSerializer();
@@ -17725,8 +18118,7 @@ function clipData(editor) {
17725
18118
  res[type] = data;
17726
18119
  return res;
17727
18120
  } catch (e) {
17728
- ketcherCore.KetcherLogger.error('hotkeys.ts::clipData', e);
17729
- errorHandler(e.message);
18121
+ errorHandler && errorHandler(e.message);
17730
18122
  }
17731
18123
  return null;
17732
18124
  }
@@ -25562,7 +25954,7 @@ function Field(props) {
25562
25954
  name: name,
25563
25955
  schema: desc
25564
25956
  }, fieldOpts), rest), {}, {
25565
- "data-testid": "file-name-input"
25957
+ "data-testid": "".concat(name, "-input")
25566
25958
  }));
25567
25959
  if (labelPos === false) return formField;
25568
25960
  return jsxRuntime.jsxs(Label, {
@@ -25571,10 +25963,12 @@ function Field(props) {
25571
25963
  title: rest.title || desc.title,
25572
25964
  labelPos: labelPos,
25573
25965
  tooltip: rest === null || rest === void 0 ? void 0 : rest.tooltip,
25966
+ "data-testid": props['data-testid'],
25574
25967
  children: [jsxRuntime.jsx("span", {
25575
25968
  className: classes$B.inputWrapper,
25576
25969
  onMouseEnter: handlePopoverOpen,
25577
25970
  onMouseLeave: handlePopoverClose,
25971
+ "data-testid": props['data-testid'] + '-input-span',
25578
25972
  children: formField
25579
25973
  }), dataError && anchorEl && jsxRuntime.jsx(ErrorPopover, {
25580
25974
  anchorEl: anchorEl,
@@ -25678,7 +26072,8 @@ function CustomQueryField(props) {
25678
26072
  type: 'boolean'
25679
26073
  },
25680
26074
  value: checkboxValue,
25681
- onChange: handleCheckboxChange
26075
+ onChange: handleCheckboxChange,
26076
+ "data-testid": "custom-query-checkbox"
25682
26077
  })
25683
26078
  }), jsxRuntime.jsx("span", {
25684
26079
  onMouseEnter: handlePopoverOpen,
@@ -27447,6 +27842,7 @@ var AtomElement = function AtomElement(_ref) {
27447
27842
  label: _.capitalize(label)
27448
27843
  }, onChange);
27449
27844
  },
27845
+ "data-testid": "label-input",
27450
27846
  autoFocus: true
27451
27847
  }, "atomLabel"), jsxRuntime.jsx(ElementNumber, {
27452
27848
  label: label
@@ -27580,21 +27976,26 @@ var Atom = function Atom(props) {
27580
27976
  formState: formState,
27581
27977
  className: ""
27582
27978
  }), jsxRuntime.jsx(Field, {
27583
- name: "alias"
27979
+ name: "alias",
27980
+ "data-testid": "alias"
27584
27981
  }), jsxRuntime.jsx(Field, {
27585
27982
  name: "charge",
27586
- maxLength: atomProps.charge.maxLength
27983
+ maxLength: atomProps.charge.maxLength,
27984
+ "data-testid": "charge"
27587
27985
  }), jsxRuntime.jsx(Field, {
27588
27986
  name: "isotope",
27589
- maxLength: atomProps.isotope.maxLength
27987
+ maxLength: atomProps.isotope.maxLength,
27988
+ "data-testid": "isotope"
27590
27989
  }), jsxRuntime.jsx(Field, {
27591
27990
  name: "explicitValence",
27592
27991
  component: Select,
27593
- options: getSelectOptionsFromSchema(atomProps.explicitValence)
27992
+ options: getSelectOptionsFromSchema(atomProps.explicitValence),
27993
+ "data-testid": "explicitValence"
27594
27994
  }), jsxRuntime.jsx(Field, {
27595
27995
  name: "radical",
27596
27996
  component: Select,
27597
- options: getSelectOptionsFromSchema(atomProps.radical)
27997
+ options: getSelectOptionsFromSchema(atomProps.radical),
27998
+ "data-testid": "radical"
27598
27999
  })]
27599
28000
  })
27600
28001
  }, {
@@ -27606,7 +28007,8 @@ var Atom = function Atom(props) {
27606
28007
  return jsxRuntime.jsx(Field, {
27607
28008
  name: field.name,
27608
28009
  component: Select,
27609
- options: getSelectOptionsFromSchema(atomProps[field.name])
28010
+ options: getSelectOptionsFromSchema(atomProps[field.name]),
28011
+ "data-testid": field.name
27610
28012
  }, field.name);
27611
28013
  } else {
27612
28014
  return jsxRuntime.jsx(Field, _objectSpread$v({}, field), field.name);
@@ -27656,6 +28058,7 @@ var Atom = function Atom(props) {
27656
28058
  component = _ref.component;
27657
28059
  var shouldGroupBeRended = expandedAccordions.includes(groupName);
27658
28060
  return jsxRuntime.jsxs("div", {
28061
+ "data-testid": "".concat(groupName, "-section"),
27659
28062
  children: [jsxRuntime.jsx("div", {
27660
28063
  onClick: handleAccordionChange(groupName),
27661
28064
  className: classes$t.accordionSummaryWrapper,
@@ -27880,19 +28283,22 @@ var Bond = function Bond(props) {
27880
28283
  component: Select,
27881
28284
  options: getSelectOptionsFromSchema(bondProps.type),
27882
28285
  disabled: isCustomQuery,
27883
- formName: "bond-properties"
28286
+ formName: "bond-properties",
28287
+ "data-testid": "type"
27884
28288
  }), jsxRuntime.jsx(Field, {
27885
28289
  name: "topology",
27886
28290
  component: Select,
27887
28291
  options: getSelectOptionsFromSchema(bondProps.topology),
27888
28292
  disabled: isCustomQuery,
27889
- formName: "bond-properties"
28293
+ formName: "bond-properties",
28294
+ "data-testid": "topology"
27890
28295
  }), jsxRuntime.jsx(Field, {
27891
28296
  name: "center",
27892
28297
  component: Select,
27893
28298
  options: getSelectOptionsFromSchema(bondProps.center),
27894
28299
  disabled: isCustomQuery,
27895
- formName: "bond-properties"
28300
+ formName: "bond-properties",
28301
+ "data-testid": "reacting-center"
27896
28302
  }), jsxRuntime.jsx("div", {
27897
28303
  className: classes$q.customQueryWrapper,
27898
28304
  children: jsxRuntime.jsx(CustomQueryField, {
@@ -32010,8 +32416,8 @@ var KetcherBuilder = function () {
32010
32416
  initApp(element, appRoot, staticResourcesUrl, {
32011
32417
  buttons: buttons || {},
32012
32418
  errorHandler: errorHandler || null,
32013
- version: "2.16.0-rc.3" ,
32014
- buildDate: "2023-10-25T15:15:54" ,
32419
+ version: "2.16.0-rc.4" ,
32420
+ buildDate: "2023-12-11T17:06:24" ,
32015
32421
  buildNumber: ''
32016
32422
  }, structService, resolve);
32017
32423
  });
@@ -32052,6 +32458,7 @@ var KetcherBuilder = function () {
32052
32458
  if (initialMol) {
32053
32459
  ketcher.setMolecule(initialMol);
32054
32460
  }
32461
+ ketcherCore.ketcherProvider.setKetcherInstance(ketcher);
32055
32462
  return ketcher;
32056
32463
  }
32057
32464
  }]);