ketcher-react 2.15.0-rc.2 → 2.15.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, Ketcher, defaultBondThickness, FormatterFactory, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SdfSerializer, Bond as Bond$2, Elements, AtomList, 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, scrollByVector, 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, isCloseToEdgeOfCanvas, isCloseToEdgeOfScreen, getDirections, shiftAndExtendCanvasByVector, 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, fromTemplateOnBondAction, fromTemplateOnCanvas, fromTextCreation, fromHighlightCreate, fromHighlightClear, fromNewCanvas, Render, fromDescriptorsAlign, atomGetAttr, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, b64toBlob, Generics, TextCommand, DefaultStructServiceOptions } from 'ketcher-core';
27
+ import { KetSerializer, MolSerializer, Ketcher, defaultBondThickness, FormatterFactory, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SdfSerializer, Bond as Bond$2, Elements, AtomList, 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, scrollByVector, 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, isCloseToEdgeOfCanvas, isCloseToEdgeOfScreen, getDirections, shiftAndExtendCanvasByVector, formatProperties, ketcherProvider, 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, fromTemplateOnBondAction, fromTemplateOnCanvas, fromTextCreation, fromHighlightCreate, fromHighlightClear, fromNewCanvas, Render, fromDescriptorsAlign, atomGetAttr, 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';
@@ -297,20 +297,76 @@ var ClipArea = function (_Component) {
297
297
  mousedown: function mousedown(event) {
298
298
  if (event.shiftKey && !isActiveElement(event.target)) event.preventDefault();
299
299
  },
300
- copy: function copy(event) {
301
- if (_this2.props.focused() && _this2.props.onCopy) {
302
- var data = _this2.props.onCopy();
303
- if (data) _copy(event.clipboardData, data);
304
- event.preventDefault();
300
+ copy: function () {
301
+ var _copy2 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(event) {
302
+ var data;
303
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
304
+ while (1) {
305
+ switch (_context.prev = _context.next) {
306
+ case 0:
307
+ if (!(_this2.props.focused() && _this2.props.onCopy)) {
308
+ _context.next = 8;
309
+ break;
310
+ }
311
+ _context.next = 3;
312
+ return _this2.props.onCopy();
313
+ case 3:
314
+ data = _context.sent;
315
+ if (!data) {
316
+ _context.next = 7;
317
+ break;
318
+ }
319
+ _context.next = 7;
320
+ return _copy(data);
321
+ case 7:
322
+ event.preventDefault();
323
+ case 8:
324
+ case "end":
325
+ return _context.stop();
326
+ }
327
+ }
328
+ }, _callee);
329
+ }));
330
+ function copy(_x) {
331
+ return _copy2.apply(this, arguments);
305
332
  }
306
- },
307
- cut: function cut(event) {
308
- if (_this2.props.focused() && _this2.props.onCut) {
309
- var data = _this2.props.onCut();
310
- if (data) _copy(event.clipboardData, data);
311
- event.preventDefault();
333
+ return copy;
334
+ }(),
335
+ cut: function () {
336
+ var _cut = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(event) {
337
+ var data;
338
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
339
+ while (1) {
340
+ switch (_context2.prev = _context2.next) {
341
+ case 0:
342
+ if (!(_this2.props.focused() && _this2.props.onCut)) {
343
+ _context2.next = 8;
344
+ break;
345
+ }
346
+ _context2.next = 3;
347
+ return _this2.props.onCut();
348
+ case 3:
349
+ data = _context2.sent;
350
+ if (!data) {
351
+ _context2.next = 7;
352
+ break;
353
+ }
354
+ _context2.next = 7;
355
+ return _copy(data);
356
+ case 7:
357
+ event.preventDefault();
358
+ case 8:
359
+ case "end":
360
+ return _context2.stop();
361
+ }
362
+ }
363
+ }, _callee2);
364
+ }));
365
+ function cut(_x2) {
366
+ return _cut.apply(this, arguments);
312
367
  }
313
- },
368
+ return cut;
369
+ }(),
314
370
  paste: function paste(event) {
315
371
  if (_this2.props.focused() && _this2.props.onPaste) {
316
372
  var data = _paste(event.clipboardData, _this2.props.formats);
@@ -359,20 +415,32 @@ function autoselect(cliparea) {
359
415
  cliparea.value = ' ';
360
416
  cliparea.select();
361
417
  }
362
- function _copy(cb, data) {
363
- if (!cb && ieCb) {
364
- ieCb.setData('text', data['text/plain']);
365
- } else {
366
- var curFmt = null;
367
- cb.setData('text/plain', data['text/plain']);
368
- try {
369
- Object.keys(data).forEach(function (fmt) {
370
- curFmt = fmt;
371
- cb.setData(fmt, data[fmt]);
372
- });
373
- } catch (ex) {
374
- }
375
- }
418
+ function _copy(_x3) {
419
+ return _copy3.apply(this, arguments);
420
+ }
421
+ function _copy3() {
422
+ _copy3 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee3(data) {
423
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
424
+ while (1) {
425
+ switch (_context3.prev = _context3.next) {
426
+ case 0:
427
+ _context3.prev = 0;
428
+ _context3.next = 3;
429
+ return navigator.clipboard.writeText(data['text/plain']);
430
+ case 3:
431
+ _context3.next = 8;
432
+ break;
433
+ case 5:
434
+ _context3.prev = 5;
435
+ _context3.t0 = _context3["catch"](0);
436
+ case 8:
437
+ case "end":
438
+ return _context3.stop();
439
+ }
440
+ }
441
+ }, _callee3, null, [[0, 5]]);
442
+ }));
443
+ return _copy3.apply(this, arguments);
376
444
  }
377
445
  function _paste(cb, formats) {
378
446
  var data = {};
@@ -3201,7 +3269,7 @@ var zoom = {
3201
3269
 
3202
3270
  var openHelpLink = function openHelpLink() {
3203
3271
  var _window$open;
3204
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.15.0-rc.2\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3272
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.15.0-rc.4\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3205
3273
  };
3206
3274
  var help = {
3207
3275
  help: {
@@ -16992,21 +17060,53 @@ function initClipboard(dispatch) {
16992
17060
  return !state.modal;
16993
17061
  },
16994
17062
  onCut: function onCut() {
16995
- var state = global.currentState;
16996
- var editor = state.editor;
16997
- var data = clipData(editor);
16998
- if (data) debAction({
16999
- tool: 'eraser',
17000
- opts: 1
17001
- });else editor.selection(null);
17002
- return data;
17063
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
17064
+ var state, editor, data;
17065
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17066
+ while (1) {
17067
+ switch (_context.prev = _context.next) {
17068
+ case 0:
17069
+ state = global.currentState;
17070
+ editor = state.editor;
17071
+ _context.next = 4;
17072
+ return clipData(editor);
17073
+ case 4:
17074
+ data = _context.sent;
17075
+ if (data) debAction({
17076
+ tool: 'eraser',
17077
+ opts: 1
17078
+ });else editor.selection(null);
17079
+ return _context.abrupt("return", data);
17080
+ case 7:
17081
+ case "end":
17082
+ return _context.stop();
17083
+ }
17084
+ }
17085
+ }, _callee);
17086
+ }))();
17003
17087
  },
17004
17088
  onCopy: function onCopy() {
17005
- var state = global.currentState;
17006
- var editor = state.editor;
17007
- var data = clipData(editor);
17008
- editor.selection(null);
17009
- return data;
17089
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee2() {
17090
+ var state, editor, data;
17091
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
17092
+ while (1) {
17093
+ switch (_context2.prev = _context2.next) {
17094
+ case 0:
17095
+ state = global.currentState;
17096
+ editor = state.editor;
17097
+ _context2.next = 4;
17098
+ return clipData(editor);
17099
+ case 4:
17100
+ data = _context2.sent;
17101
+ editor.selection(null);
17102
+ return _context2.abrupt("return", data);
17103
+ case 7:
17104
+ case "end":
17105
+ return _context2.stop();
17106
+ }
17107
+ }
17108
+ }, _callee2);
17109
+ }))();
17010
17110
  },
17011
17111
  onPaste: function onPaste(data) {
17012
17112
  var structStr = data[ChemicalMimeType.KET] || data[ChemicalMimeType.Mol] || data[ChemicalMimeType.Rxn] || data['text/plain'];
@@ -17017,30 +17117,61 @@ function initClipboard(dispatch) {
17017
17117
  }
17018
17118
  };
17019
17119
  }
17020
- function clipData(editor) {
17021
- var res = {};
17022
- var struct = editor.structSelected();
17023
- var errorHandler = editor.errorHandler;
17024
- if (struct.isBlank()) return null;
17025
- var simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
17026
- if (simpleObjectOrText && isIE) {
17027
- 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');
17028
- return null;
17029
- }
17030
- var molSerializer = new MolSerializer();
17031
- try {
17032
- var serializer = new KetSerializer();
17033
- var ket = serializer.serialize(struct);
17034
- res[ChemicalMimeType.KET] = ket;
17035
- var type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn;
17036
- var data = molSerializer.serialize(struct);
17037
- res['text/plain'] = data;
17038
- res[type] = data;
17039
- return res;
17040
- } catch (e) {
17041
- errorHandler(e.message);
17042
- }
17043
- return null;
17120
+ function clipData(_x) {
17121
+ return _clipData.apply(this, arguments);
17122
+ }
17123
+ function _clipData() {
17124
+ _clipData = _asyncToGenerator( _regeneratorRuntime.mark(function _callee3(editor) {
17125
+ var res, struct, errorHandler, simpleObjectOrText, serializer, ket, ketcherInstance, data, type;
17126
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
17127
+ while (1) {
17128
+ switch (_context3.prev = _context3.next) {
17129
+ case 0:
17130
+ res = {};
17131
+ struct = editor.structSelected();
17132
+ errorHandler = editor.errorHandler;
17133
+ if (!struct.isBlank()) {
17134
+ _context3.next = 5;
17135
+ break;
17136
+ }
17137
+ return _context3.abrupt("return", null);
17138
+ case 5:
17139
+ simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
17140
+ if (!(simpleObjectOrText && isIE && errorHandler)) {
17141
+ _context3.next = 9;
17142
+ break;
17143
+ }
17144
+ 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');
17145
+ return _context3.abrupt("return", null);
17146
+ case 9:
17147
+ _context3.prev = 9;
17148
+ serializer = new KetSerializer();
17149
+ ket = serializer.serialize(struct);
17150
+ ketcherInstance = ketcherProvider.getKetcher();
17151
+ _context3.next = 15;
17152
+ return getStructure(SupportedFormat.molAuto,
17153
+ ketcherInstance.formatterFactory, struct);
17154
+ case 15:
17155
+ data = _context3.sent;
17156
+ res[ChemicalMimeType.KET] = ket;
17157
+ type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn;
17158
+ res['text/plain'] = data;
17159
+ res[type] = data;
17160
+ return _context3.abrupt("return", res);
17161
+ case 23:
17162
+ _context3.prev = 23;
17163
+ _context3.t0 = _context3["catch"](9);
17164
+ errorHandler && errorHandler(_context3.t0.message);
17165
+ case 26:
17166
+ return _context3.abrupt("return", null);
17167
+ case 27:
17168
+ case "end":
17169
+ return _context3.stop();
17170
+ }
17171
+ }
17172
+ }, _callee3, null, [[9, 23]]);
17173
+ }));
17174
+ return _clipData.apply(this, arguments);
17044
17175
  }
17045
17176
 
17046
17177
  var AppClipArea = connect(null, function (dispatch) {
@@ -30634,8 +30765,8 @@ var KetcherBuilder = function () {
30634
30765
  initApp(element, appRoot, staticResourcesUrl, {
30635
30766
  buttons: buttons || {},
30636
30767
  errorHandler: errorHandler || null,
30637
- version: "2.15.0-rc.2" ,
30638
- buildDate: "2023-09-13T13:57:29" ,
30768
+ version: "2.15.0-rc.4" ,
30769
+ buildDate: "2023-10-10T15:38:15" ,
30639
30770
  buildNumber: ''
30640
30771
  }, structService, resolve);
30641
30772
  });
@@ -30676,6 +30807,7 @@ var KetcherBuilder = function () {
30676
30807
  if (initialMol) {
30677
30808
  ketcher.setMolecule(initialMol);
30678
30809
  }
30810
+ ketcherProvider.setKetcherInstance(ketcher);
30679
30811
  return ketcher;
30680
30812
  }
30681
30813
  }]);