ketcher-react 2.15.0-rc.5 → 2.15.0
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 +393 -154
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +394 -155
- package/dist/index.modern.js.map +1 -1
- package/dist/script/ui/component/cliparea/cliparea.d.ts +1 -1
- package/dist/script/ui/component/cliparea/clipboardUtils.d.ts +7 -0
- package/dist/script/ui/state/hotkeys.d.ts +6 -3
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -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$2 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, 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';
|
|
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, 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, 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';
|
|
@@ -267,6 +267,15 @@ var debugObj = {
|
|
|
267
267
|
|
|
268
268
|
var classes$R = {"cliparea":"cliparea-module_cliparea__GdPrN"};
|
|
269
269
|
|
|
270
|
+
function isClipboardAPIAvailable() {
|
|
271
|
+
var _navigator;
|
|
272
|
+
return typeof ((_navigator = navigator) === null || _navigator === void 0 || (_navigator = _navigator.clipboard) === null || _navigator === void 0 ? void 0 : _navigator.writeText) === 'function';
|
|
273
|
+
}
|
|
274
|
+
function notifyCopyCut() {
|
|
275
|
+
var event = new Event('copyOrCutComplete');
|
|
276
|
+
window.dispatchEvent(event);
|
|
277
|
+
}
|
|
278
|
+
|
|
270
279
|
function _createSuper$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); return function _createSuperInternal() { var Super = _getPrototypeOf$2(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$2(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$2(this, result); }; }
|
|
271
280
|
function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
272
281
|
var ieCb = window.clipboardData;
|
|
@@ -296,76 +305,87 @@ var ClipArea = function (_Component) {
|
|
|
296
305
|
mousedown: function mousedown(event) {
|
|
297
306
|
if (event.shiftKey && !isActiveElement(event.target)) event.preventDefault();
|
|
298
307
|
},
|
|
299
|
-
copy: function () {
|
|
300
|
-
|
|
308
|
+
copy: function copy(event) {
|
|
309
|
+
if (!_this2.props.focused()) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (isClipboardAPIAvailable()) {
|
|
313
|
+
_this2.props.onCopy().then(function (data) {
|
|
314
|
+
if (!data) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
_copy(data).then(function () {
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
notifyCopyCut();
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
var data = _this2.props.onLegacyCopy();
|
|
324
|
+
if (data) {
|
|
325
|
+
legacyCopy(event.clipboardData, data);
|
|
326
|
+
}
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
cut: function () {
|
|
331
|
+
var _cut = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(event) {
|
|
301
332
|
var data;
|
|
302
333
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
303
334
|
while (1) switch (_context.prev = _context.next) {
|
|
304
335
|
case 0:
|
|
305
|
-
if (
|
|
306
|
-
_context.next =
|
|
336
|
+
if (_this2.props.focused()) {
|
|
337
|
+
_context.next = 2;
|
|
307
338
|
break;
|
|
308
339
|
}
|
|
309
|
-
_context.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
340
|
+
return _context.abrupt("return");
|
|
341
|
+
case 2:
|
|
342
|
+
if (isClipboardAPIAvailable()) {
|
|
343
|
+
_this2.props.onCut().then(function (data) {
|
|
344
|
+
if (!data) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
_copy(data).then(function () {
|
|
348
|
+
event.preventDefault();
|
|
349
|
+
notifyCopyCut();
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
} else {
|
|
353
|
+
data = _this2.props.onLegacyCut();
|
|
354
|
+
if (data) {
|
|
355
|
+
legacyCopy(event.clipboardData, data);
|
|
356
|
+
}
|
|
357
|
+
event.preventDefault();
|
|
316
358
|
}
|
|
317
|
-
|
|
318
|
-
return _copy(data);
|
|
319
|
-
case 7:
|
|
320
|
-
event.preventDefault();
|
|
321
|
-
case 8:
|
|
359
|
+
case 3:
|
|
322
360
|
case "end":
|
|
323
361
|
return _context.stop();
|
|
324
362
|
}
|
|
325
363
|
}, _callee);
|
|
326
364
|
}));
|
|
327
|
-
function
|
|
328
|
-
return _copy2.apply(this, arguments);
|
|
329
|
-
}
|
|
330
|
-
return copy;
|
|
331
|
-
}(),
|
|
332
|
-
cut: function () {
|
|
333
|
-
var _cut = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(event) {
|
|
334
|
-
var data;
|
|
335
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
336
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
337
|
-
case 0:
|
|
338
|
-
if (!(_this2.props.focused() && _this2.props.onCut)) {
|
|
339
|
-
_context2.next = 8;
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
_context2.next = 3;
|
|
343
|
-
return _this2.props.onCut();
|
|
344
|
-
case 3:
|
|
345
|
-
data = _context2.sent;
|
|
346
|
-
if (!data) {
|
|
347
|
-
_context2.next = 7;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
_context2.next = 7;
|
|
351
|
-
return _copy(data);
|
|
352
|
-
case 7:
|
|
353
|
-
event.preventDefault();
|
|
354
|
-
case 8:
|
|
355
|
-
case "end":
|
|
356
|
-
return _context2.stop();
|
|
357
|
-
}
|
|
358
|
-
}, _callee2);
|
|
359
|
-
}));
|
|
360
|
-
function cut(_x2) {
|
|
365
|
+
function cut(_x) {
|
|
361
366
|
return _cut.apply(this, arguments);
|
|
362
367
|
}
|
|
363
368
|
return cut;
|
|
364
369
|
}(),
|
|
365
370
|
paste: function paste(event) {
|
|
366
|
-
if (_this2.props.focused()
|
|
367
|
-
|
|
368
|
-
|
|
371
|
+
if (!_this2.props.focused()) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (isClipboardAPIAvailable()) {
|
|
375
|
+
navigator.clipboard.read().then(function (data) {
|
|
376
|
+
if (!data) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
_this2.props.onPaste(data).then(function () {
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
notifyCopyCut();
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
} else {
|
|
385
|
+
var data = legacyPaste(event.clipboardData, _this2.props.formats);
|
|
386
|
+
if (data) {
|
|
387
|
+
_this2.props.onLegacyPaste(data);
|
|
388
|
+
}
|
|
369
389
|
event.preventDefault();
|
|
370
390
|
}
|
|
371
391
|
}
|
|
@@ -410,32 +430,55 @@ function autoselect(cliparea) {
|
|
|
410
430
|
cliparea.value = ' ';
|
|
411
431
|
cliparea.select();
|
|
412
432
|
}
|
|
413
|
-
function _copy(
|
|
414
|
-
return
|
|
433
|
+
function _copy(_x2) {
|
|
434
|
+
return _copy2.apply(this, arguments);
|
|
415
435
|
}
|
|
416
|
-
function
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
436
|
+
function _copy2() {
|
|
437
|
+
_copy2 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(data) {
|
|
438
|
+
var clipboardItemData;
|
|
439
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
440
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
420
441
|
case 0:
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
442
|
+
_context2.prev = 0;
|
|
443
|
+
clipboardItemData = {};
|
|
444
|
+
Object.keys(data).forEach(function (mimeType) {
|
|
445
|
+
var mimeTypeToSet = mimeType === 'text/plain' ? mimeType : "web ".concat(mimeType);
|
|
446
|
+
clipboardItemData[mimeTypeToSet] = Promise.resolve(new Blob([data[mimeType]], {
|
|
447
|
+
type: mimeTypeToSet
|
|
448
|
+
}));
|
|
449
|
+
});
|
|
450
|
+
_context2.next = 5;
|
|
451
|
+
return navigator.clipboard.write([new ClipboardItem(clipboardItemData)]);
|
|
427
452
|
case 5:
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
case
|
|
453
|
+
_context2.next = 10;
|
|
454
|
+
break;
|
|
455
|
+
case 7:
|
|
456
|
+
_context2.prev = 7;
|
|
457
|
+
_context2.t0 = _context2["catch"](0);
|
|
458
|
+
case 10:
|
|
431
459
|
case "end":
|
|
432
|
-
return
|
|
460
|
+
return _context2.stop();
|
|
433
461
|
}
|
|
434
|
-
},
|
|
462
|
+
}, _callee2, null, [[0, 7]]);
|
|
435
463
|
}));
|
|
436
|
-
return
|
|
464
|
+
return _copy2.apply(this, arguments);
|
|
437
465
|
}
|
|
438
|
-
function
|
|
466
|
+
function legacyCopy(clipboardData, data) {
|
|
467
|
+
if (!clipboardData && ieCb) {
|
|
468
|
+
ieCb.setData('text', data['text/plain']);
|
|
469
|
+
} else {
|
|
470
|
+
var curFmt = null;
|
|
471
|
+
clipboardData.setData('text/plain', data['text/plain']);
|
|
472
|
+
try {
|
|
473
|
+
Object.keys(data).forEach(function (fmt) {
|
|
474
|
+
curFmt = fmt;
|
|
475
|
+
clipboardData.setData(fmt, data[fmt]);
|
|
476
|
+
});
|
|
477
|
+
} catch (e) {
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function legacyPaste(cb, formats) {
|
|
439
482
|
var data = {};
|
|
440
483
|
if (!cb && ieCb) {
|
|
441
484
|
data['text/plain'] = ieCb.getData('text');
|
|
@@ -3258,7 +3301,7 @@ var zoom = {
|
|
|
3258
3301
|
|
|
3259
3302
|
var openHelpLink = function openHelpLink() {
|
|
3260
3303
|
var _window$open;
|
|
3261
|
-
return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.15.0
|
|
3304
|
+
return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.15.0\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
|
|
3262
3305
|
};
|
|
3263
3306
|
var help = {
|
|
3264
3307
|
help: {
|
|
@@ -8552,12 +8595,12 @@ var implementation$4 = function bind(that) {
|
|
|
8552
8595
|
|
|
8553
8596
|
var functionBind = Function.prototype.bind || implementation$4;
|
|
8554
8597
|
|
|
8555
|
-
var hasOwnProperty$2 = {}.hasOwnProperty;
|
|
8556
8598
|
var call = Function.prototype.call;
|
|
8599
|
+
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
8557
8600
|
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8601
|
+
|
|
8602
|
+
/** @type {(o: {}, p: PropertyKey) => p is keyof o} */
|
|
8603
|
+
var hasown = functionBind.call(call, $hasOwn);
|
|
8561
8604
|
|
|
8562
8605
|
var undefined$1;
|
|
8563
8606
|
|
|
@@ -8802,12 +8845,12 @@ var stringToPath = function stringToPath(string) {
|
|
|
8802
8845
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
8803
8846
|
var intrinsicName = name;
|
|
8804
8847
|
var alias;
|
|
8805
|
-
if (
|
|
8848
|
+
if (hasown(LEGACY_ALIASES, intrinsicName)) {
|
|
8806
8849
|
alias = LEGACY_ALIASES[intrinsicName];
|
|
8807
8850
|
intrinsicName = '%' + alias[0] + '%';
|
|
8808
8851
|
}
|
|
8809
8852
|
|
|
8810
|
-
if (
|
|
8853
|
+
if (hasown(INTRINSICS, intrinsicName)) {
|
|
8811
8854
|
var value = INTRINSICS[intrinsicName];
|
|
8812
8855
|
if (value === needsEval) {
|
|
8813
8856
|
value = doEval(intrinsicName);
|
|
@@ -8871,7 +8914,7 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
8871
8914
|
intrinsicBaseName += '.' + part;
|
|
8872
8915
|
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
8873
8916
|
|
|
8874
|
-
if (
|
|
8917
|
+
if (hasown(INTRINSICS, intrinsicRealName)) {
|
|
8875
8918
|
value = INTRINSICS[intrinsicRealName];
|
|
8876
8919
|
} else if (value != null) {
|
|
8877
8920
|
if (!(part in value)) {
|
|
@@ -8897,7 +8940,7 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
8897
8940
|
value = value[part];
|
|
8898
8941
|
}
|
|
8899
8942
|
} else {
|
|
8900
|
-
isOwn =
|
|
8943
|
+
isOwn = hasown(value, part);
|
|
8901
8944
|
value = value[part];
|
|
8902
8945
|
}
|
|
8903
8946
|
|
|
@@ -17173,114 +17216,310 @@ function initClipboard(dispatch) {
|
|
|
17173
17216
|
var state = global.currentState;
|
|
17174
17217
|
return !state.modal;
|
|
17175
17218
|
},
|
|
17219
|
+
onLegacyCut: function onLegacyCut() {
|
|
17220
|
+
var state = global.currentState;
|
|
17221
|
+
var editor = state.editor;
|
|
17222
|
+
var data = legacyClipData(editor);
|
|
17223
|
+
if (data) debAction({
|
|
17224
|
+
tool: 'eraser',
|
|
17225
|
+
opts: 1
|
|
17226
|
+
});else editor.selection(null);
|
|
17227
|
+
return data;
|
|
17228
|
+
},
|
|
17176
17229
|
onCut: function onCut() {
|
|
17177
|
-
return _asyncToGenerator( _regeneratorRuntime.mark(function
|
|
17178
|
-
var
|
|
17179
|
-
return _regeneratorRuntime.wrap(function
|
|
17180
|
-
while (1) switch (
|
|
17230
|
+
return _asyncToGenerator( _regeneratorRuntime.mark(function _callee2() {
|
|
17231
|
+
var ketcherInstance, result;
|
|
17232
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
17233
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
17181
17234
|
case 0:
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17235
|
+
ketcherInstance = ketcherProvider.getKetcher();
|
|
17236
|
+
_context2.next = 3;
|
|
17237
|
+
return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
|
|
17238
|
+
var state, editor, data;
|
|
17239
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17240
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17241
|
+
case 0:
|
|
17242
|
+
state = global.currentState;
|
|
17243
|
+
editor = state.editor;
|
|
17244
|
+
_context.next = 4;
|
|
17245
|
+
return clipData(editor);
|
|
17246
|
+
case 4:
|
|
17247
|
+
data = _context.sent;
|
|
17248
|
+
if (data) debAction({
|
|
17249
|
+
tool: 'eraser',
|
|
17250
|
+
opts: 1
|
|
17251
|
+
});else editor.selection(null);
|
|
17252
|
+
return _context.abrupt("return", data);
|
|
17253
|
+
case 7:
|
|
17254
|
+
case "end":
|
|
17255
|
+
return _context.stop();
|
|
17256
|
+
}
|
|
17257
|
+
}, _callee);
|
|
17258
|
+
})), ketcherInstance.eventBus);
|
|
17259
|
+
case 3:
|
|
17260
|
+
result = _context2.sent;
|
|
17261
|
+
return _context2.abrupt("return", result);
|
|
17262
|
+
case 5:
|
|
17194
17263
|
case "end":
|
|
17195
|
-
return
|
|
17264
|
+
return _context2.stop();
|
|
17196
17265
|
}
|
|
17197
|
-
},
|
|
17266
|
+
}, _callee2);
|
|
17198
17267
|
}))();
|
|
17199
17268
|
},
|
|
17269
|
+
onLegacyCopy: function onLegacyCopy() {
|
|
17270
|
+
var state = global.currentState;
|
|
17271
|
+
var editor = state.editor;
|
|
17272
|
+
var data = legacyClipData(editor);
|
|
17273
|
+
editor.selection(null);
|
|
17274
|
+
return data;
|
|
17275
|
+
},
|
|
17200
17276
|
onCopy: function onCopy() {
|
|
17201
|
-
return _asyncToGenerator( _regeneratorRuntime.mark(function
|
|
17202
|
-
var
|
|
17203
|
-
return _regeneratorRuntime.wrap(function
|
|
17204
|
-
while (1) switch (
|
|
17277
|
+
return _asyncToGenerator( _regeneratorRuntime.mark(function _callee4() {
|
|
17278
|
+
var ketcherInstance, result;
|
|
17279
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
17280
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
17205
17281
|
case 0:
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17282
|
+
ketcherInstance = ketcherProvider.getKetcher();
|
|
17283
|
+
_context4.next = 3;
|
|
17284
|
+
return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee3() {
|
|
17285
|
+
var state, editor, data;
|
|
17286
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
17287
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
17288
|
+
case 0:
|
|
17289
|
+
state = global.currentState;
|
|
17290
|
+
editor = state.editor;
|
|
17291
|
+
_context3.next = 4;
|
|
17292
|
+
return clipData(editor);
|
|
17293
|
+
case 4:
|
|
17294
|
+
data = _context3.sent;
|
|
17295
|
+
editor.selection(null);
|
|
17296
|
+
return _context3.abrupt("return", data);
|
|
17297
|
+
case 7:
|
|
17298
|
+
case "end":
|
|
17299
|
+
return _context3.stop();
|
|
17300
|
+
}
|
|
17301
|
+
}, _callee3);
|
|
17302
|
+
})), ketcherInstance.eventBus);
|
|
17303
|
+
case 3:
|
|
17304
|
+
result = _context4.sent;
|
|
17305
|
+
return _context4.abrupt("return", result);
|
|
17306
|
+
case 5:
|
|
17215
17307
|
case "end":
|
|
17216
|
-
return
|
|
17308
|
+
return _context4.stop();
|
|
17217
17309
|
}
|
|
17218
|
-
},
|
|
17310
|
+
}, _callee4);
|
|
17219
17311
|
}))();
|
|
17220
17312
|
},
|
|
17221
17313
|
onPaste: function onPaste(data) {
|
|
17314
|
+
return _asyncToGenerator( _regeneratorRuntime.mark(function _callee6() {
|
|
17315
|
+
var ketcherInstance, result;
|
|
17316
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
17317
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
17318
|
+
case 0:
|
|
17319
|
+
ketcherInstance = ketcherProvider.getKetcher();
|
|
17320
|
+
_context6.next = 3;
|
|
17321
|
+
return runAsyncAction( _asyncToGenerator( _regeneratorRuntime.mark(function _callee5() {
|
|
17322
|
+
var structStr;
|
|
17323
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
17324
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
17325
|
+
case 0:
|
|
17326
|
+
_context5.next = 2;
|
|
17327
|
+
return getStructStringFromClipboardData(data);
|
|
17328
|
+
case 2:
|
|
17329
|
+
structStr = _context5.sent;
|
|
17330
|
+
if (structStr || !rxnTextPlain.test(data['text/plain'])) {
|
|
17331
|
+
loadStruct(structStr, {
|
|
17332
|
+
fragment: true,
|
|
17333
|
+
isPaste: true
|
|
17334
|
+
});
|
|
17335
|
+
}
|
|
17336
|
+
case 4:
|
|
17337
|
+
case "end":
|
|
17338
|
+
return _context5.stop();
|
|
17339
|
+
}
|
|
17340
|
+
}, _callee5);
|
|
17341
|
+
})), ketcherInstance.eventBus);
|
|
17342
|
+
case 3:
|
|
17343
|
+
result = _context6.sent;
|
|
17344
|
+
return _context6.abrupt("return", result);
|
|
17345
|
+
case 5:
|
|
17346
|
+
case "end":
|
|
17347
|
+
return _context6.stop();
|
|
17348
|
+
}
|
|
17349
|
+
}, _callee6);
|
|
17350
|
+
}))();
|
|
17351
|
+
},
|
|
17352
|
+
onLegacyPaste: function onLegacyPaste(data) {
|
|
17222
17353
|
var structStr = data[ChemicalMimeType.KET] || data[ChemicalMimeType.Mol] || data[ChemicalMimeType.Rxn] || data['text/plain'];
|
|
17223
|
-
if (structStr || !rxnTextPlain.test(data['text/plain']))
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17354
|
+
if (structStr || !rxnTextPlain.test(data['text/plain'])) {
|
|
17355
|
+
loadStruct(structStr, {
|
|
17356
|
+
fragment: true,
|
|
17357
|
+
isPaste: true
|
|
17358
|
+
});
|
|
17359
|
+
}
|
|
17227
17360
|
}
|
|
17228
17361
|
};
|
|
17229
17362
|
}
|
|
17230
|
-
function
|
|
17363
|
+
function safelyGetMimeType(_x, _x2) {
|
|
17364
|
+
return _safelyGetMimeType.apply(this, arguments);
|
|
17365
|
+
}
|
|
17366
|
+
function _safelyGetMimeType() {
|
|
17367
|
+
_safelyGetMimeType = _asyncToGenerator( _regeneratorRuntime.mark(function _callee7(clipboardItem, mimeType) {
|
|
17368
|
+
var result;
|
|
17369
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
17370
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
17371
|
+
case 0:
|
|
17372
|
+
_context7.prev = 0;
|
|
17373
|
+
_context7.next = 3;
|
|
17374
|
+
return clipboardItem.getType(mimeType);
|
|
17375
|
+
case 3:
|
|
17376
|
+
result = _context7.sent;
|
|
17377
|
+
return _context7.abrupt("return", result);
|
|
17378
|
+
case 7:
|
|
17379
|
+
_context7.prev = 7;
|
|
17380
|
+
_context7.t0 = _context7["catch"](0);
|
|
17381
|
+
return _context7.abrupt("return", '');
|
|
17382
|
+
case 10:
|
|
17383
|
+
case "end":
|
|
17384
|
+
return _context7.stop();
|
|
17385
|
+
}
|
|
17386
|
+
}, _callee7, null, [[0, 7]]);
|
|
17387
|
+
}));
|
|
17388
|
+
return _safelyGetMimeType.apply(this, arguments);
|
|
17389
|
+
}
|
|
17390
|
+
function getStructStringFromClipboardData(_x3) {
|
|
17391
|
+
return _getStructStringFromClipboardData.apply(this, arguments);
|
|
17392
|
+
}
|
|
17393
|
+
function _getStructStringFromClipboardData() {
|
|
17394
|
+
_getStructStringFromClipboardData = _asyncToGenerator( _regeneratorRuntime.mark(function _callee8(data) {
|
|
17395
|
+
var clipboardItem, structStr;
|
|
17396
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
17397
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
17398
|
+
case 0:
|
|
17399
|
+
clipboardItem = data[0];
|
|
17400
|
+
_context8.next = 3;
|
|
17401
|
+
return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.KET));
|
|
17402
|
+
case 3:
|
|
17403
|
+
_context8.t2 = _context8.sent;
|
|
17404
|
+
if (_context8.t2) {
|
|
17405
|
+
_context8.next = 8;
|
|
17406
|
+
break;
|
|
17407
|
+
}
|
|
17408
|
+
_context8.next = 7;
|
|
17409
|
+
return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.Mol));
|
|
17410
|
+
case 7:
|
|
17411
|
+
_context8.t2 = _context8.sent;
|
|
17412
|
+
case 8:
|
|
17413
|
+
_context8.t1 = _context8.t2;
|
|
17414
|
+
if (_context8.t1) {
|
|
17415
|
+
_context8.next = 13;
|
|
17416
|
+
break;
|
|
17417
|
+
}
|
|
17418
|
+
_context8.next = 12;
|
|
17419
|
+
return safelyGetMimeType(clipboardItem, "web ".concat(ChemicalMimeType.Rxn));
|
|
17420
|
+
case 12:
|
|
17421
|
+
_context8.t1 = _context8.sent;
|
|
17422
|
+
case 13:
|
|
17423
|
+
_context8.t0 = _context8.t1;
|
|
17424
|
+
if (_context8.t0) {
|
|
17425
|
+
_context8.next = 18;
|
|
17426
|
+
break;
|
|
17427
|
+
}
|
|
17428
|
+
_context8.next = 17;
|
|
17429
|
+
return safelyGetMimeType(clipboardItem, 'text/plain');
|
|
17430
|
+
case 17:
|
|
17431
|
+
_context8.t0 = _context8.sent;
|
|
17432
|
+
case 18:
|
|
17433
|
+
structStr = _context8.t0;
|
|
17434
|
+
return _context8.abrupt("return", structStr === '' ? '' : structStr.text());
|
|
17435
|
+
case 20:
|
|
17436
|
+
case "end":
|
|
17437
|
+
return _context8.stop();
|
|
17438
|
+
}
|
|
17439
|
+
}, _callee8);
|
|
17440
|
+
}));
|
|
17441
|
+
return _getStructStringFromClipboardData.apply(this, arguments);
|
|
17442
|
+
}
|
|
17443
|
+
function isAbleToCopy(editor) {
|
|
17444
|
+
var struct = editor.structSelected();
|
|
17445
|
+
var errorHandler = editor.errorHandler;
|
|
17446
|
+
if (struct.isBlank()) {
|
|
17447
|
+
return false;
|
|
17448
|
+
}
|
|
17449
|
+
var simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
|
|
17450
|
+
if (simpleObjectOrText && isIE && errorHandler) {
|
|
17451
|
+
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');
|
|
17452
|
+
return false;
|
|
17453
|
+
}
|
|
17454
|
+
return true;
|
|
17455
|
+
}
|
|
17456
|
+
function clipData(_x4) {
|
|
17231
17457
|
return _clipData.apply(this, arguments);
|
|
17232
17458
|
}
|
|
17233
17459
|
function _clipData() {
|
|
17234
|
-
_clipData = _asyncToGenerator( _regeneratorRuntime.mark(function
|
|
17235
|
-
var res, struct, errorHandler,
|
|
17236
|
-
return _regeneratorRuntime.wrap(function
|
|
17237
|
-
while (1) switch (
|
|
17460
|
+
_clipData = _asyncToGenerator( _regeneratorRuntime.mark(function _callee9(editor) {
|
|
17461
|
+
var res, struct, errorHandler, serializer, ket, ketcherInstance, data, type;
|
|
17462
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
17463
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
17238
17464
|
case 0:
|
|
17465
|
+
if (isAbleToCopy(editor)) {
|
|
17466
|
+
_context9.next = 2;
|
|
17467
|
+
break;
|
|
17468
|
+
}
|
|
17469
|
+
return _context9.abrupt("return", null);
|
|
17470
|
+
case 2:
|
|
17239
17471
|
res = {};
|
|
17240
17472
|
struct = editor.structSelected();
|
|
17241
17473
|
errorHandler = editor.errorHandler;
|
|
17242
|
-
|
|
17243
|
-
_context3.next = 5;
|
|
17244
|
-
break;
|
|
17245
|
-
}
|
|
17246
|
-
return _context3.abrupt("return", null);
|
|
17247
|
-
case 5:
|
|
17248
|
-
simpleObjectOrText = Boolean(struct.simpleObjects.size || struct.texts.size);
|
|
17249
|
-
if (!(simpleObjectOrText && isIE && errorHandler)) {
|
|
17250
|
-
_context3.next = 9;
|
|
17251
|
-
break;
|
|
17252
|
-
}
|
|
17253
|
-
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');
|
|
17254
|
-
return _context3.abrupt("return", null);
|
|
17255
|
-
case 9:
|
|
17256
|
-
_context3.prev = 9;
|
|
17474
|
+
_context9.prev = 5;
|
|
17257
17475
|
serializer = new KetSerializer();
|
|
17258
17476
|
ket = serializer.serialize(struct);
|
|
17259
17477
|
ketcherInstance = ketcherProvider.getKetcher();
|
|
17260
|
-
|
|
17261
|
-
return getStructure(SupportedFormat.molAuto,
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
data = _context3.sent;
|
|
17478
|
+
_context9.next = 11;
|
|
17479
|
+
return getStructure(SupportedFormat.molAuto, ketcherInstance.formatterFactory, struct);
|
|
17480
|
+
case 11:
|
|
17481
|
+
data = _context9.sent;
|
|
17265
17482
|
res[ChemicalMimeType.KET] = ket;
|
|
17266
17483
|
type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn;
|
|
17267
17484
|
res['text/plain'] = data;
|
|
17268
17485
|
res[type] = data;
|
|
17269
|
-
return
|
|
17486
|
+
return _context9.abrupt("return", res);
|
|
17487
|
+
case 19:
|
|
17488
|
+
_context9.prev = 19;
|
|
17489
|
+
_context9.t0 = _context9["catch"](5);
|
|
17490
|
+
errorHandler && errorHandler(_context9.t0.message);
|
|
17491
|
+
case 22:
|
|
17492
|
+
return _context9.abrupt("return", null);
|
|
17270
17493
|
case 23:
|
|
17271
|
-
_context3.prev = 23;
|
|
17272
|
-
_context3.t0 = _context3["catch"](9);
|
|
17273
|
-
errorHandler && errorHandler(_context3.t0.message);
|
|
17274
|
-
case 26:
|
|
17275
|
-
return _context3.abrupt("return", null);
|
|
17276
|
-
case 27:
|
|
17277
17494
|
case "end":
|
|
17278
|
-
return
|
|
17495
|
+
return _context9.stop();
|
|
17279
17496
|
}
|
|
17280
|
-
},
|
|
17497
|
+
}, _callee9, null, [[5, 19]]);
|
|
17281
17498
|
}));
|
|
17282
17499
|
return _clipData.apply(this, arguments);
|
|
17283
17500
|
}
|
|
17501
|
+
function legacyClipData(editor) {
|
|
17502
|
+
if (!isAbleToCopy(editor)) {
|
|
17503
|
+
return null;
|
|
17504
|
+
}
|
|
17505
|
+
var res = {};
|
|
17506
|
+
var struct = editor.structSelected();
|
|
17507
|
+
var errorHandler = editor.errorHandler;
|
|
17508
|
+
var molSerializer = new MolSerializer();
|
|
17509
|
+
try {
|
|
17510
|
+
var serializer = new KetSerializer();
|
|
17511
|
+
var ket = serializer.serialize(struct);
|
|
17512
|
+
res[ChemicalMimeType.KET] = ket;
|
|
17513
|
+
var type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn;
|
|
17514
|
+
var data = molSerializer.serialize(struct);
|
|
17515
|
+
res['text/plain'] = data;
|
|
17516
|
+
res[type] = data;
|
|
17517
|
+
return res;
|
|
17518
|
+
} catch (e) {
|
|
17519
|
+
errorHandler && errorHandler(e.message);
|
|
17520
|
+
}
|
|
17521
|
+
return null;
|
|
17522
|
+
}
|
|
17284
17523
|
|
|
17285
17524
|
var AppClipArea = connect(null, function (dispatch) {
|
|
17286
17525
|
return dispatch(initClipboard);
|
|
@@ -30876,8 +31115,8 @@ var KetcherBuilder = function () {
|
|
|
30876
31115
|
initApp(element, appRoot, staticResourcesUrl, {
|
|
30877
31116
|
buttons: buttons || {},
|
|
30878
31117
|
errorHandler: errorHandler || null,
|
|
30879
|
-
version: "2.15.0
|
|
30880
|
-
buildDate: "2023-
|
|
31118
|
+
version: "2.15.0" ,
|
|
31119
|
+
buildDate: "2023-11-06T13:55:38" ,
|
|
30881
31120
|
buildNumber: ''
|
|
30882
31121
|
}, structService, resolve);
|
|
30883
31122
|
});
|