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.
@@ -24,7 +24,7 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
24
24
  import _regeneratorRuntime from '@babel/runtime/regenerator';
25
25
  import _classCallCheck$2 from '@babel/runtime/helpers/classCallCheck';
26
26
  import _createClass$1 from '@babel/runtime/helpers/createClass';
27
- import { KetSerializer, MolSerializer, KetcherLogger, Ketcher, defaultBondThickness, FormatterFactory, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SdfSerializer, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, SimpleObjectMode, emitEventRequestIsFinished, SGroup as SGroup$1, Pile, getStereoAtomsMap, identifyStructFormat, SupportedFormat, ChemicalMimeType, RenderStruct, Struct, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, Vec2, fromMultipleMove, scrollCanvasByVector, FunctionalGroup, Scale, fromSgroupDeletion, fromFragmentDeletion, mergeMapOfItemsToSet, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, fromSimpleObjectResizing, fromArrowResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, isCloseToEdgeOfScreen, isCloseToEdgeOfCanvas, extendCanvasByVector, formatProperties, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromPaste, fromTemplateOnAtom, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromPlusAddition, fromRotate, fromFlip, fromSimpleObjectAddition, fromTemplateOnCanvas, fromTemplateOnBondAction, BondAttr, AtomAttr, fromTextCreation, fromHighlightCreate, fromHighlightClear, fromNewCanvas, Render, fromDescriptorsAlign, atomGetAttr, genericsList, getAtomCustomQuery, getFormatMimeTypeByFileName, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, b64toBlob, Generics, TextCommand, DefaultStructServiceOptions } from 'ketcher-core';
27
+ import { KetSerializer, MolSerializer, KetcherLogger, Ketcher, defaultBondThickness, FormatterFactory, notifyRequestCompleted, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SdfSerializer, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, SimpleObjectMode, SGroup as SGroup$1, Pile, getStereoAtomsMap, identifyStructFormat, SupportedFormat, ChemicalMimeType, RenderStruct, Struct, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, Vec2, fromMultipleMove, scrollCanvasByVector, FunctionalGroup, Scale, fromSgroupDeletion, fromFragmentDeletion, mergeMapOfItemsToSet, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, fromSimpleObjectResizing, fromArrowResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, isCloseToEdgeOfScreen, isCloseToEdgeOfCanvas, extendCanvasByVector, formatProperties, ketcherProvider, runAsyncAction, getStructure, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromPaste, fromTemplateOnAtom, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromPlusAddition, fromRotate, fromFlip, fromSimpleObjectAddition, fromTemplateOnCanvas, fromTemplateOnBondAction, BondAttr, AtomAttr, fromTextCreation, fromHighlightCreate, fromHighlightClear, fromNewCanvas, Render, fromDescriptorsAlign, atomGetAttr, genericsList, getAtomCustomQuery, getFormatMimeTypeByFileName, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, b64toBlob, Generics, TextCommand, DefaultStructServiceOptions } from 'ketcher-core';
28
28
  import * as React from 'react';
29
29
  import React__default, { createRef, Component, useRef, useEffect, useState, useMemo, createElement, forwardRef, useCallback, useLayoutEffect, Fragment as Fragment$2, PureComponent, lazy, Suspense } from 'react';
30
30
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
@@ -334,6 +334,15 @@ function lookup(map, event) {
334
334
  }
335
335
  keyNorm.lookup = lookup;
336
336
 
337
+ function isClipboardAPIAvailable() {
338
+ var _navigator, _navigator$clipboard;
339
+ 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';
340
+ }
341
+ function notifyCopyCut() {
342
+ var event = new Event('copyOrCutComplete');
343
+ window.dispatchEvent(event);
344
+ }
345
+
337
346
  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; } } }; }
338
347
  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); }
339
348
  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; }
@@ -367,70 +376,135 @@ var ClipArea = function (_Component) {
367
376
  if (event.shiftKey && !isActiveElement(event.target)) event.preventDefault();
368
377
  },
369
378
  copy: function copy(event) {
370
- if (_this2.props.focused() && _this2.props.onCopy) {
371
- var data = _this2.props.onCopy();
372
- if (data) _copy(event.clipboardData, data);
373
- event.preventDefault();
379
+ if (!_this2.props.focused()) {
380
+ return;
374
381
  }
375
- },
376
- cut: function cut(event) {
377
- if (_this2.props.focused() && _this2.props.onCut) {
378
- var data = _this2.props.onCut();
379
- if (data) _copy(event.clipboardData, data);
382
+ if (isClipboardAPIAvailable()) {
383
+ _this2.props.onCopy().then(function (data) {
384
+ if (!data) {
385
+ return;
386
+ }
387
+ _copy(data).then(function () {
388
+ event.preventDefault();
389
+ notifyCopyCut();
390
+ });
391
+ });
392
+ } else {
393
+ var data = _this2.props.onLegacyCopy();
394
+ if (data) {
395
+ legacyCopy(event.clipboardData, data);
396
+ }
380
397
  event.preventDefault();
381
398
  }
382
399
  },
400
+ cut: function () {
401
+ var _cut = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(event) {
402
+ var data;
403
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
404
+ while (1) {
405
+ switch (_context.prev = _context.next) {
406
+ case 0:
407
+ if (_this2.props.focused()) {
408
+ _context.next = 2;
409
+ break;
410
+ }
411
+ return _context.abrupt("return");
412
+ case 2:
413
+ if (isClipboardAPIAvailable()) {
414
+ _this2.props.onCut().then(function (data) {
415
+ if (!data) {
416
+ return;
417
+ }
418
+ _copy(data).then(function () {
419
+ event.preventDefault();
420
+ notifyCopyCut();
421
+ });
422
+ });
423
+ } else {
424
+ data = _this2.props.onLegacyCut();
425
+ if (data) {
426
+ legacyCopy(event.clipboardData, data);
427
+ }
428
+ event.preventDefault();
429
+ }
430
+ case 3:
431
+ case "end":
432
+ return _context.stop();
433
+ }
434
+ }
435
+ }, _callee);
436
+ }));
437
+ function cut(_x) {
438
+ return _cut.apply(this, arguments);
439
+ }
440
+ return cut;
441
+ }(),
383
442
  paste: function paste(event) {
384
- if (_this2.props.focused() && _this2.props.onPaste) {
385
- var data = _paste(event.clipboardData, _this2.props.formats);
386
- if (data) _this2.props.onPaste(data);
443
+ if (!_this2.props.focused()) {
444
+ return;
445
+ }
446
+ if (isClipboardAPIAvailable()) {
447
+ navigator.clipboard.read().then(function (data) {
448
+ if (!data) {
449
+ return;
450
+ }
451
+ _this2.props.onPaste(data).then(function () {
452
+ event.preventDefault();
453
+ notifyRequestCompleted();
454
+ });
455
+ });
456
+ } else {
457
+ var data = legacyPaste(event.clipboardData, _this2.props.formats);
458
+ if (data) {
459
+ _this2.props.onLegacyPaste(data);
460
+ }
387
461
  event.preventDefault();
388
462
  }
389
463
  },
390
464
  keydown: function () {
391
- var _keydown = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(event) {
465
+ var _keydown = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(event) {
392
466
  var _navigator$clipboard, clipboardData, data, _window$ketcher$edito, _window$ketcher$edito2;
393
- return _regeneratorRuntime.wrap(function _callee$(_context) {
467
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
394
468
  while (1) {
395
- switch (_context.prev = _context.next) {
469
+ switch (_context2.prev = _context2.next) {
396
470
  case 0:
397
471
  if (!(!_this2.props.focused() || !_this2.props.onPaste)) {
398
- _context.next = 2;
472
+ _context2.next = 2;
399
473
  break;
400
474
  }
401
- return _context.abrupt("return");
475
+ return _context2.abrupt("return");
402
476
  case 2:
403
477
  if (!(isControlKey(event) && event.altKey && event.code === 'KeyV')) {
404
- _context.next = 14;
478
+ _context2.next = 14;
405
479
  break;
406
480
  }
407
481
  if (!((_navigator$clipboard = navigator.clipboard) !== null && _navigator$clipboard !== void 0 && _navigator$clipboard.read)) {
408
- _context.next = 13;
482
+ _context2.next = 13;
409
483
  break;
410
484
  }
411
- _context.next = 6;
485
+ _context2.next = 6;
412
486
  return navigator.clipboard.read();
413
487
  case 6:
414
- clipboardData = _context.sent;
415
- _context.next = 9;
488
+ clipboardData = _context2.sent;
489
+ _context2.next = 9;
416
490
  return pasteByKeydown(clipboardData);
417
491
  case 9:
418
- data = _context.sent;
492
+ data = _context2.sent;
419
493
  if (data) {
420
494
  _this2.props.onPaste(data, true);
421
495
  }
422
- _context.next = 14;
496
+ _context2.next = 14;
423
497
  break;
424
498
  case 13:
425
499
  (_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.");
426
500
  case 14:
427
501
  case "end":
428
- return _context.stop();
502
+ return _context2.stop();
429
503
  }
430
504
  }
431
- }, _callee);
505
+ }, _callee2);
432
506
  }));
433
- function keydown(_x) {
507
+ function keydown(_x2) {
434
508
  return _keydown.apply(this, arguments);
435
509
  }
436
510
  return keydown;
@@ -476,23 +550,58 @@ function autoselect(cliparea) {
476
550
  cliparea.value = ' ';
477
551
  cliparea.select();
478
552
  }
479
- function _copy(cb, data) {
480
- if (!cb && ieCb) {
553
+ function _copy(_x3) {
554
+ return _copy2.apply(this, arguments);
555
+ }
556
+ function _copy2() {
557
+ _copy2 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee3(data) {
558
+ var clipboardItemData;
559
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
560
+ while (1) {
561
+ switch (_context3.prev = _context3.next) {
562
+ case 0:
563
+ _context3.prev = 0;
564
+ clipboardItemData = {};
565
+ Object.keys(data).forEach(function (mimeType) {
566
+ var mimeTypeToSet = mimeType === 'text/plain' ? mimeType : "web ".concat(mimeType);
567
+ clipboardItemData[mimeTypeToSet] = Promise.resolve(new Blob([data[mimeType]], {
568
+ type: mimeTypeToSet
569
+ }));
570
+ });
571
+ _context3.next = 5;
572
+ return navigator.clipboard.write([new ClipboardItem(clipboardItemData)]);
573
+ case 5:
574
+ _context3.next = 11;
575
+ break;
576
+ case 7:
577
+ _context3.prev = 7;
578
+ _context3.t0 = _context3["catch"](0);
579
+ KetcherLogger.error('cliparea.jsx::copy', _context3.t0);
580
+ case 11:
581
+ case "end":
582
+ return _context3.stop();
583
+ }
584
+ }
585
+ }, _callee3, null, [[0, 7]]);
586
+ }));
587
+ return _copy2.apply(this, arguments);
588
+ }
589
+ function legacyCopy(clipboardData, data) {
590
+ if (!clipboardData && ieCb) {
481
591
  ieCb.setData('text', data['text/plain']);
482
592
  } else {
483
593
  var curFmt = null;
484
- cb.setData('text/plain', data['text/plain']);
594
+ clipboardData.setData('text/plain', data['text/plain']);
485
595
  try {
486
596
  Object.keys(data).forEach(function (fmt) {
487
597
  curFmt = fmt;
488
- cb.setData(fmt, data[fmt]);
598
+ clipboardData.setData(fmt, data[fmt]);
489
599
  });
490
600
  } catch (e) {
491
- KetcherLogger.error('cliparea.jsx::copy', e);
492
601
  }
493
602
  }
494
603
  }
495
- function _paste(cb, formats) {
604
+ function legacyPaste(cb, formats) {
496
605
  var data = {};
497
606
  if (!cb && ieCb) {
498
607
  data['text/plain'] = ieCb.getData('text');
@@ -506,64 +615,64 @@ function _paste(cb, formats) {
506
615
  }
507
616
  return data;
508
617
  }
509
- function pasteByKeydown(_x2) {
618
+ function pasteByKeydown(_x4) {
510
619
  return _pasteByKeydown.apply(this, arguments);
511
620
  }
512
621
  function _pasteByKeydown() {
513
- _pasteByKeydown = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(clipboardData) {
622
+ _pasteByKeydown = _asyncToGenerator( _regeneratorRuntime.mark(function _callee4(clipboardData) {
514
623
  var data, _iterator, _step, item, textPlain;
515
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
624
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
516
625
  while (1) {
517
- switch (_context2.prev = _context2.next) {
626
+ switch (_context4.prev = _context4.next) {
518
627
  case 0:
519
628
  data = {};
520
629
  if (!(!clipboardData && ieCb)) {
521
- _context2.next = 5;
630
+ _context4.next = 5;
522
631
  break;
523
632
  }
524
633
  data['text/plain'] = ieCb.getData('text');
525
- _context2.next = 26;
634
+ _context4.next = 26;
526
635
  break;
527
636
  case 5:
528
637
  _iterator = _createForOfIteratorHelper$f(clipboardData);
529
- _context2.prev = 6;
638
+ _context4.prev = 6;
530
639
  _iterator.s();
531
640
  case 8:
532
641
  if ((_step = _iterator.n()).done) {
533
- _context2.next = 18;
642
+ _context4.next = 18;
534
643
  break;
535
644
  }
536
645
  item = _step.value;
537
- _context2.next = 12;
646
+ _context4.next = 12;
538
647
  return item.getType('text/plain');
539
648
  case 12:
540
- textPlain = _context2.sent;
541
- _context2.next = 15;
649
+ textPlain = _context4.sent;
650
+ _context4.next = 15;
542
651
  return textPlain.text();
543
652
  case 15:
544
- data['text/plain'] = _context2.sent;
653
+ data['text/plain'] = _context4.sent;
545
654
  case 16:
546
- _context2.next = 8;
655
+ _context4.next = 8;
547
656
  break;
548
657
  case 18:
549
- _context2.next = 23;
658
+ _context4.next = 23;
550
659
  break;
551
660
  case 20:
552
- _context2.prev = 20;
553
- _context2.t0 = _context2["catch"](6);
554
- _iterator.e(_context2.t0);
661
+ _context4.prev = 20;
662
+ _context4.t0 = _context4["catch"](6);
663
+ _iterator.e(_context4.t0);
555
664
  case 23:
556
- _context2.prev = 23;
665
+ _context4.prev = 23;
557
666
  _iterator.f();
558
- return _context2.finish(23);
667
+ return _context4.finish(23);
559
668
  case 26:
560
- return _context2.abrupt("return", data);
669
+ return _context4.abrupt("return", data);
561
670
  case 27:
562
671
  case "end":
563
- return _context2.stop();
672
+ return _context4.stop();
564
673
  }
565
674
  }
566
- }, _callee2, null, [[6, 20, 23, 26]]);
675
+ }, _callee4, null, [[6, 20, 23, 26]]);
567
676
  }));
568
677
  return _pasteByKeydown.apply(this, arguments);
569
678
  }
@@ -3188,7 +3297,7 @@ function load(struct, options) {
3188
3297
  _context.t0 && errorHandler && errorHandler(_context.t0.message);
3189
3298
  case 37:
3190
3299
  _context.prev = 37;
3191
- emitEventRequestIsFinished();
3300
+ notifyRequestCompleted();
3192
3301
  return _context.finish(37);
3193
3302
  case 40:
3194
3303
  case "end":
@@ -3573,7 +3682,7 @@ var zoom = {
3573
3682
 
3574
3683
  var openHelpLink = function openHelpLink() {
3575
3684
  var _window$open;
3576
- 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();
3685
+ 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();
3577
3686
  };
3578
3687
  var help = {
3579
3688
  help: {
@@ -14226,7 +14335,7 @@ var mapDispatchToProps$j = function mapDispatchToProps(dispatch) {
14226
14335
  var RightToolbarContainer = connect(mapStateToProps$j, mapDispatchToProps$j)(RightToolbar);
14227
14336
 
14228
14337
  var _templateObject$7;
14229
- var TopToolbarIconButton = styled(IconButton)(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral(["\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"])));
14338
+ var TopToolbarIconButton = styled(IconButton)(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral(["\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"])));
14230
14339
 
14231
14340
  var FileControls = function FileControls(_ref) {
14232
14341
  var onFileOpen = _ref.onFileOpen,
@@ -14708,7 +14817,7 @@ var ExternalFuncControls = function ExternalFuncControls(_ref) {
14708
14817
 
14709
14818
  var _templateObject$2;
14710
14819
  var collapseLimit = 650;
14711
- var ControlsPanel = styled('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\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"])));
14820
+ var ControlsPanel = styled('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\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"])));
14712
14821
  var TopToolbar = function TopToolbar(_ref) {
14713
14822
  var className = _ref.className,
14714
14823
  disabledButtons = _ref.disabledButtons,
@@ -17611,46 +17720,330 @@ function initClipboard(dispatch) {
17611
17720
  var state = global.currentState;
17612
17721
  return !state.modal;
17613
17722
  },
17614
- onCut: function onCut() {
17723
+ onLegacyCut: function onLegacyCut() {
17615
17724
  var state = global.currentState;
17616
17725
  var editor = state.editor;
17617
- var data = clipData(editor);
17726
+ var data = legacyClipData(editor);
17618
17727
  if (data) debAction({
17619
17728
  tool: 'eraser',
17620
17729
  opts: 1
17621
17730
  });else editor.selection(null);
17622
17731
  return data;
17623
17732
  },
17624
- onCopy: function onCopy() {
17733
+ onCut: function onCut() {
17734
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee2() {
17735
+ var ketcherInstance, result;
17736
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
17737
+ while (1) {
17738
+ switch (_context2.prev = _context2.next) {
17739
+ case 0:
17740
+ ketcherInstance = ketcherProvider.getKetcher();
17741
+ _context2.next = 3;
17742
+ return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
17743
+ var state, editor, data;
17744
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17745
+ while (1) {
17746
+ switch (_context.prev = _context.next) {
17747
+ case 0:
17748
+ state = global.currentState;
17749
+ editor = state.editor;
17750
+ _context.next = 4;
17751
+ return clipData(editor);
17752
+ case 4:
17753
+ data = _context.sent;
17754
+ if (data) debAction({
17755
+ tool: 'eraser',
17756
+ opts: 1
17757
+ });else editor.selection(null);
17758
+ return _context.abrupt("return", data);
17759
+ case 7:
17760
+ case "end":
17761
+ return _context.stop();
17762
+ }
17763
+ }
17764
+ }, _callee);
17765
+ })), ketcherInstance.eventBus);
17766
+ case 3:
17767
+ result = _context2.sent;
17768
+ return _context2.abrupt("return", result);
17769
+ case 5:
17770
+ case "end":
17771
+ return _context2.stop();
17772
+ }
17773
+ }
17774
+ }, _callee2);
17775
+ }))();
17776
+ },
17777
+ onLegacyCopy: function onLegacyCopy() {
17625
17778
  var state = global.currentState;
17626
17779
  var editor = state.editor;
17627
- var data = clipData(editor);
17780
+ var data = legacyClipData(editor);
17628
17781
  editor.selection(null);
17629
17782
  return data;
17630
17783
  },
17784
+ onCopy: function onCopy() {
17785
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee4() {
17786
+ var ketcherInstance, result;
17787
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
17788
+ while (1) {
17789
+ switch (_context4.prev = _context4.next) {
17790
+ case 0:
17791
+ ketcherInstance = ketcherProvider.getKetcher();
17792
+ _context4.next = 3;
17793
+ return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee3() {
17794
+ var state, editor, data;
17795
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
17796
+ while (1) {
17797
+ switch (_context3.prev = _context3.next) {
17798
+ case 0:
17799
+ state = global.currentState;
17800
+ editor = state.editor;
17801
+ _context3.next = 4;
17802
+ return clipData(editor);
17803
+ case 4:
17804
+ data = _context3.sent;
17805
+ editor.selection(null);
17806
+ return _context3.abrupt("return", data);
17807
+ case 7:
17808
+ case "end":
17809
+ return _context3.stop();
17810
+ }
17811
+ }
17812
+ }, _callee3);
17813
+ })), ketcherInstance.eventBus);
17814
+ case 3:
17815
+ result = _context4.sent;
17816
+ return _context4.abrupt("return", result);
17817
+ case 5:
17818
+ case "end":
17819
+ return _context4.stop();
17820
+ }
17821
+ }
17822
+ }, _callee4);
17823
+ }))();
17824
+ },
17631
17825
  onPaste: function onPaste(data, isSmarts) {
17826
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee6() {
17827
+ var ketcherInstance, result;
17828
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
17829
+ while (1) {
17830
+ switch (_context6.prev = _context6.next) {
17831
+ case 0:
17832
+ ketcherInstance = ketcherProvider.getKetcher();
17833
+ _context6.next = 3;
17834
+ return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee5() {
17835
+ var structStr;
17836
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
17837
+ while (1) {
17838
+ switch (_context5.prev = _context5.next) {
17839
+ case 0:
17840
+ _context5.next = 2;
17841
+ return getStructStringFromClipboardData(data);
17842
+ case 2:
17843
+ structStr = _context5.sent;
17844
+ if (structStr || !rxnTextPlain.test(data['text/plain'])) {
17845
+ if (isSmarts) {
17846
+ loadStruct(structStr, {
17847
+ fragment: true,
17848
+ isPaste: true,
17849
+ 'input-format': ChemicalMimeType.DaylightSmarts
17850
+ });
17851
+ } else {
17852
+ loadStruct(structStr, {
17853
+ fragment: true,
17854
+ isPaste: true
17855
+ });
17856
+ }
17857
+ }
17858
+ case 4:
17859
+ case "end":
17860
+ return _context5.stop();
17861
+ }
17862
+ }
17863
+ }, _callee5);
17864
+ })), ketcherInstance.eventBus);
17865
+ case 3:
17866
+ result = _context6.sent;
17867
+ return _context6.abrupt("return", result);
17868
+ case 5:
17869
+ case "end":
17870
+ return _context6.stop();
17871
+ }
17872
+ }
17873
+ }, _callee6);
17874
+ }))();
17875
+ },
17876
+ onLegacyPaste: function onLegacyPaste(data, isSmarts) {
17632
17877
  var structStr = data[ChemicalMimeType.KET] || data[ChemicalMimeType.Mol] || data[ChemicalMimeType.Rxn] || data['text/plain'];
17633
- if (structStr || !rxnTextPlain.test(data['text/plain'])) isSmarts ? loadStruct(structStr, {
17634
- fragment: true,
17635
- isPaste: true,
17636
- 'input-format': ChemicalMimeType.DaylightSmarts
17637
- }) : loadStruct(structStr, {
17638
- fragment: true,
17639
- isPaste: true
17640
- });
17878
+ if (structStr || !rxnTextPlain.test(data['text/plain'])) {
17879
+ if (isSmarts) {
17880
+ loadStruct(structStr, {
17881
+ fragment: true,
17882
+ isPaste: true,
17883
+ 'input-format': ChemicalMimeType.DaylightSmarts
17884
+ });
17885
+ } else {
17886
+ loadStruct(structStr, {
17887
+ fragment: true,
17888
+ isPaste: true
17889
+ });
17890
+ }
17891
+ }
17641
17892
  }
17642
17893
  };
17643
17894
  }
17644
- function clipData(editor) {
17645
- var res = {};
17895
+ function safelyGetMimeType(_x, _x2) {
17896
+ return _safelyGetMimeType.apply(this, arguments);
17897
+ }
17898
+ function _safelyGetMimeType() {
17899
+ _safelyGetMimeType = _asyncToGenerator( _regeneratorRuntime.mark(function _callee7(clipboardItem, mimeType) {
17900
+ var result;
17901
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
17902
+ while (1) {
17903
+ switch (_context7.prev = _context7.next) {
17904
+ case 0:
17905
+ _context7.prev = 0;
17906
+ _context7.next = 3;
17907
+ return clipboardItem.getType(mimeType);
17908
+ case 3:
17909
+ result = _context7.sent;
17910
+ return _context7.abrupt("return", result);
17911
+ case 7:
17912
+ _context7.prev = 7;
17913
+ _context7.t0 = _context7["catch"](0);
17914
+ return _context7.abrupt("return", '');
17915
+ case 10:
17916
+ case "end":
17917
+ return _context7.stop();
17918
+ }
17919
+ }
17920
+ }, _callee7, null, [[0, 7]]);
17921
+ }));
17922
+ return _safelyGetMimeType.apply(this, arguments);
17923
+ }
17924
+ function getStructStringFromClipboardData(_x3) {
17925
+ return _getStructStringFromClipboardData.apply(this, arguments);
17926
+ }
17927
+ function _getStructStringFromClipboardData() {
17928
+ _getStructStringFromClipboardData = _asyncToGenerator( _regeneratorRuntime.mark(function _callee8(data) {
17929
+ var clipboardItem, structStr;
17930
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
17931
+ while (1) {
17932
+ switch (_context8.prev = _context8.next) {
17933
+ case 0:
17934
+ clipboardItem = data[0];
17935
+ _context8.next = 3;
17936
+ return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.KET));
17937
+ case 3:
17938
+ _context8.t2 = _context8.sent;
17939
+ if (_context8.t2) {
17940
+ _context8.next = 8;
17941
+ break;
17942
+ }
17943
+ _context8.next = 7;
17944
+ return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.Mol));
17945
+ case 7:
17946
+ _context8.t2 = _context8.sent;
17947
+ case 8:
17948
+ _context8.t1 = _context8.t2;
17949
+ if (_context8.t1) {
17950
+ _context8.next = 13;
17951
+ break;
17952
+ }
17953
+ _context8.next = 12;
17954
+ return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.Rxn));
17955
+ case 12:
17956
+ _context8.t1 = _context8.sent;
17957
+ case 13:
17958
+ _context8.t0 = _context8.t1;
17959
+ if (_context8.t0) {
17960
+ _context8.next = 18;
17961
+ break;
17962
+ }
17963
+ _context8.next = 17;
17964
+ return safelyGetMimeType(clipboardItem, 'text/plain');
17965
+ case 17:
17966
+ _context8.t0 = _context8.sent;
17967
+ case 18:
17968
+ structStr = _context8.t0;
17969
+ return _context8.abrupt("return", structStr === '' ? '' : structStr.text());
17970
+ case 20:
17971
+ case "end":
17972
+ return _context8.stop();
17973
+ }
17974
+ }
17975
+ }, _callee8);
17976
+ }));
17977
+ return _getStructStringFromClipboardData.apply(this, arguments);
17978
+ }
17979
+ function isAbleToCopy(editor) {
17646
17980
  var struct = editor.structSelected();
17647
17981
  var errorHandler = editor.errorHandler;
17648
- if (struct.isBlank()) return null;
17982
+ if (struct.isBlank()) {
17983
+ return false;
17984
+ }
17649
17985
  var simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
17650
- if (simpleObjectOrText && isIE) {
17986
+ if (simpleObjectOrText && isIE && errorHandler) {
17651
17987
  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');
17988
+ return false;
17989
+ }
17990
+ return true;
17991
+ }
17992
+ function clipData(_x4) {
17993
+ return _clipData.apply(this, arguments);
17994
+ }
17995
+ function _clipData() {
17996
+ _clipData = _asyncToGenerator( _regeneratorRuntime.mark(function _callee9(editor) {
17997
+ var res, struct, errorHandler, serializer, ket, ketcherInstance, data, type;
17998
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
17999
+ while (1) {
18000
+ switch (_context9.prev = _context9.next) {
18001
+ case 0:
18002
+ if (isAbleToCopy(editor)) {
18003
+ _context9.next = 2;
18004
+ break;
18005
+ }
18006
+ return _context9.abrupt("return", null);
18007
+ case 2:
18008
+ res = {};
18009
+ struct = editor.structSelected();
18010
+ errorHandler = editor.errorHandler;
18011
+ _context9.prev = 5;
18012
+ serializer = new KetSerializer();
18013
+ ket = serializer.serialize(struct);
18014
+ ketcherInstance = ketcherProvider.getKetcher();
18015
+ _context9.next = 11;
18016
+ return getStructure(SupportedFormat.molAuto, ketcherInstance.formatterFactory, struct);
18017
+ case 11:
18018
+ data = _context9.sent;
18019
+ res[ChemicalMimeType.KET] = ket;
18020
+ type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn;
18021
+ res['text/plain'] = data;
18022
+ res[type] = data;
18023
+ return _context9.abrupt("return", res);
18024
+ case 19:
18025
+ _context9.prev = 19;
18026
+ _context9.t0 = _context9["catch"](5);
18027
+ KetcherLogger.error('hotkeys.ts::clipData', _context9.t0);
18028
+ errorHandler && errorHandler(_context9.t0.message);
18029
+ case 23:
18030
+ return _context9.abrupt("return", null);
18031
+ case 24:
18032
+ case "end":
18033
+ return _context9.stop();
18034
+ }
18035
+ }
18036
+ }, _callee9, null, [[5, 19]]);
18037
+ }));
18038
+ return _clipData.apply(this, arguments);
18039
+ }
18040
+ function legacyClipData(editor) {
18041
+ if (!isAbleToCopy(editor)) {
17652
18042
  return null;
17653
18043
  }
18044
+ var res = {};
18045
+ var struct = editor.structSelected();
18046
+ var errorHandler = editor.errorHandler;
17654
18047
  var molSerializer = new MolSerializer();
17655
18048
  try {
17656
18049
  var serializer = new KetSerializer();
@@ -17662,8 +18055,7 @@ function clipData(editor) {
17662
18055
  res[type] = data;
17663
18056
  return res;
17664
18057
  } catch (e) {
17665
- KetcherLogger.error('hotkeys.ts::clipData', e);
17666
- errorHandler(e.message);
18058
+ errorHandler && errorHandler(e.message);
17667
18059
  }
17668
18060
  return null;
17669
18061
  }
@@ -25499,7 +25891,7 @@ function Field(props) {
25499
25891
  name: name,
25500
25892
  schema: desc
25501
25893
  }, fieldOpts), rest), {}, {
25502
- "data-testid": "file-name-input"
25894
+ "data-testid": "".concat(name, "-input")
25503
25895
  }));
25504
25896
  if (labelPos === false) return formField;
25505
25897
  return jsxs(Label, {
@@ -25508,10 +25900,12 @@ function Field(props) {
25508
25900
  title: rest.title || desc.title,
25509
25901
  labelPos: labelPos,
25510
25902
  tooltip: rest === null || rest === void 0 ? void 0 : rest.tooltip,
25903
+ "data-testid": props['data-testid'],
25511
25904
  children: [jsx("span", {
25512
25905
  className: classes$B.inputWrapper,
25513
25906
  onMouseEnter: handlePopoverOpen,
25514
25907
  onMouseLeave: handlePopoverClose,
25908
+ "data-testid": props['data-testid'] + '-input-span',
25515
25909
  children: formField
25516
25910
  }), dataError && anchorEl && jsx(ErrorPopover, {
25517
25911
  anchorEl: anchorEl,
@@ -25615,7 +26009,8 @@ function CustomQueryField(props) {
25615
26009
  type: 'boolean'
25616
26010
  },
25617
26011
  value: checkboxValue,
25618
- onChange: handleCheckboxChange
26012
+ onChange: handleCheckboxChange,
26013
+ "data-testid": "custom-query-checkbox"
25619
26014
  })
25620
26015
  }), jsx("span", {
25621
26016
  onMouseEnter: handlePopoverOpen,
@@ -27384,6 +27779,7 @@ var AtomElement = function AtomElement(_ref) {
27384
27779
  label: capitalize$1(label)
27385
27780
  }, onChange);
27386
27781
  },
27782
+ "data-testid": "label-input",
27387
27783
  autoFocus: true
27388
27784
  }, "atomLabel"), jsx(ElementNumber, {
27389
27785
  label: label
@@ -27517,21 +27913,26 @@ var Atom = function Atom(props) {
27517
27913
  formState: formState,
27518
27914
  className: ""
27519
27915
  }), jsx(Field, {
27520
- name: "alias"
27916
+ name: "alias",
27917
+ "data-testid": "alias"
27521
27918
  }), jsx(Field, {
27522
27919
  name: "charge",
27523
- maxLength: atomProps.charge.maxLength
27920
+ maxLength: atomProps.charge.maxLength,
27921
+ "data-testid": "charge"
27524
27922
  }), jsx(Field, {
27525
27923
  name: "isotope",
27526
- maxLength: atomProps.isotope.maxLength
27924
+ maxLength: atomProps.isotope.maxLength,
27925
+ "data-testid": "isotope"
27527
27926
  }), jsx(Field, {
27528
27927
  name: "explicitValence",
27529
27928
  component: Select,
27530
- options: getSelectOptionsFromSchema(atomProps.explicitValence)
27929
+ options: getSelectOptionsFromSchema(atomProps.explicitValence),
27930
+ "data-testid": "explicitValence"
27531
27931
  }), jsx(Field, {
27532
27932
  name: "radical",
27533
27933
  component: Select,
27534
- options: getSelectOptionsFromSchema(atomProps.radical)
27934
+ options: getSelectOptionsFromSchema(atomProps.radical),
27935
+ "data-testid": "radical"
27535
27936
  })]
27536
27937
  })
27537
27938
  }, {
@@ -27543,7 +27944,8 @@ var Atom = function Atom(props) {
27543
27944
  return jsx(Field, {
27544
27945
  name: field.name,
27545
27946
  component: Select,
27546
- options: getSelectOptionsFromSchema(atomProps[field.name])
27947
+ options: getSelectOptionsFromSchema(atomProps[field.name]),
27948
+ "data-testid": field.name
27547
27949
  }, field.name);
27548
27950
  } else {
27549
27951
  return jsx(Field, _objectSpread$v({}, field), field.name);
@@ -27593,6 +27995,7 @@ var Atom = function Atom(props) {
27593
27995
  component = _ref.component;
27594
27996
  var shouldGroupBeRended = expandedAccordions.includes(groupName);
27595
27997
  return jsxs("div", {
27998
+ "data-testid": "".concat(groupName, "-section"),
27596
27999
  children: [jsx("div", {
27597
28000
  onClick: handleAccordionChange(groupName),
27598
28001
  className: classes$t.accordionSummaryWrapper,
@@ -27817,19 +28220,22 @@ var Bond = function Bond(props) {
27817
28220
  component: Select,
27818
28221
  options: getSelectOptionsFromSchema(bondProps.type),
27819
28222
  disabled: isCustomQuery,
27820
- formName: "bond-properties"
28223
+ formName: "bond-properties",
28224
+ "data-testid": "type"
27821
28225
  }), jsx(Field, {
27822
28226
  name: "topology",
27823
28227
  component: Select,
27824
28228
  options: getSelectOptionsFromSchema(bondProps.topology),
27825
28229
  disabled: isCustomQuery,
27826
- formName: "bond-properties"
28230
+ formName: "bond-properties",
28231
+ "data-testid": "topology"
27827
28232
  }), jsx(Field, {
27828
28233
  name: "center",
27829
28234
  component: Select,
27830
28235
  options: getSelectOptionsFromSchema(bondProps.center),
27831
28236
  disabled: isCustomQuery,
27832
- formName: "bond-properties"
28237
+ formName: "bond-properties",
28238
+ "data-testid": "reacting-center"
27833
28239
  }), jsx("div", {
27834
28240
  className: classes$q.customQueryWrapper,
27835
28241
  children: jsx(CustomQueryField, {
@@ -31947,8 +32353,8 @@ var KetcherBuilder = function () {
31947
32353
  initApp(element, appRoot, staticResourcesUrl, {
31948
32354
  buttons: buttons || {},
31949
32355
  errorHandler: errorHandler || null,
31950
- version: "2.16.0-rc.3" ,
31951
- buildDate: "2023-10-25T15:15:54" ,
32356
+ version: "2.16.0-rc.4" ,
32357
+ buildDate: "2023-12-11T17:06:24" ,
31952
32358
  buildNumber: ''
31953
32359
  }, structService, resolve);
31954
32360
  });
@@ -31989,6 +32395,7 @@ var KetcherBuilder = function () {
31989
32395
  if (initialMol) {
31990
32396
  ketcher.setMolecule(initialMol);
31991
32397
  }
32398
+ ketcherProvider.setKetcherInstance(ketcher);
31992
32399
  return ketcher;
31993
32400
  }
31994
32401
  }]);