ketcher-react 2.9.0-rc.4 → 2.9.0-rc.5-dev.1

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.
@@ -3010,7 +3010,7 @@ var zoom = {
3010
3010
 
3011
3011
  var openHelpLink = function openHelpLink() {
3012
3012
  var _window$open;
3013
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.9.0-rc.4\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3013
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.9.0-rc.5-dev.1\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3014
3014
  };
3015
3015
  var help = {
3016
3016
  help: {
@@ -10352,6 +10352,7 @@ function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateColle
10352
10352
  var _bondProps = new WeakMap();
10353
10353
  var AtomTool = function () {
10354
10354
  function AtomTool(editor, atomProps) {
10355
+ var _ElementColor$atomPro;
10355
10356
  _classCallCheck(this, AtomTool);
10356
10357
  _classPrivateFieldInitSpec$2(this, _bondProps, {
10357
10358
  writable: true,
@@ -10363,8 +10364,10 @@ var AtomTool = function () {
10363
10364
  type: 1,
10364
10365
  stereo: Bond$2.PATTERN.STEREO.NONE
10365
10366
  });
10366
- this.editor.hoverIcon.show().attr('text', "".concat(atomProps.label)).attr('fill', "".concat(ElementColor[atomProps.label]));
10367
- this.editor.updateHoverIconPosition();
10367
+ this.editor.hoverIcon.show();
10368
+ this.editor.hoverIcon.label = atomProps.label;
10369
+ this.editor.hoverIcon.fill = (_ElementColor$atomPro = ElementColor[atomProps.label]) !== null && _ElementColor$atomPro !== void 0 ? _ElementColor$atomPro : '#000000';
10370
+ this.editor.hoverIcon.updatePosition();
10368
10371
  if (editor.selection()) {
10369
10372
  var _editor$selection;
10370
10373
  if ((_editor$selection = editor.selection()) !== null && _editor$selection !== void 0 && _editor$selection.atoms) {
@@ -10448,32 +10451,13 @@ var AtomTool = function () {
10448
10451
  };
10449
10452
  }
10450
10453
  }
10451
- }, {
10452
- key: "mouseLeaveClientArea",
10453
- value: function mouseLeaveClientArea() {
10454
- this.editor.hoverIcon.hide();
10455
- }
10456
- }, {
10457
- key: "mouseover",
10458
- value: function mouseover() {
10459
- this.editor.hoverIcon.show();
10460
- this.editor.updateHoverIconPosition();
10461
- }
10462
10454
  }, {
10463
10455
  key: "mousemove",
10464
10456
  value: function mousemove(event) {
10465
10457
  this.editor.hoverIcon.show();
10466
10458
  var rnd = this.editor.render;
10467
- var layerX = event.layerX,
10468
- layerY = event.layerY;
10469
10459
  if (!this.dragCtx || !this.dragCtx.item) {
10470
- var _this$editor$hoverIco = this.editor.hoverIcon.getBBox(),
10471
- height = _this$editor$hoverIco.height,
10472
- width = _this$editor$hoverIco.width;
10473
- this.editor.hoverIcon.attr({
10474
- x: layerX - width / 2,
10475
- y: layerY - height / 2
10476
- });
10460
+ this.editor.hoverIcon.updatePosition();
10477
10461
  this.editor.hover(this.editor.findItem(event, ['atoms', 'functionalGroups']), null, event);
10478
10462
  return;
10479
10463
  }
@@ -14119,14 +14103,14 @@ var TemplateTool = function () {
14119
14103
  if (sgroup) {
14120
14104
  this.findItems.push('functionalGroups');
14121
14105
  }
14106
+ editor.hoverIcon.label = tmpl.struct.name;
14107
+ editor.hoverIcon.fill = '#000000';
14108
+ editor.hoverIcon.show();
14109
+ editor.hoverIcon.updatePosition();
14122
14110
  }
14123
14111
  _createClass(TemplateTool, [{
14124
14112
  key: "mousedown",
14125
14113
  value: function mousedown(event) {
14126
- if (this.followAction) {
14127
- this.followAction.perform(this.editor.render.ctab);
14128
- delete this.followAction;
14129
- }
14130
14114
  var closestItem = this.editor.findItem(event, ['atoms', 'bonds', 'sgroups', 'functionalGroups']);
14131
14115
  var ctab = this.editor.render.ctab;
14132
14116
  var struct = ctab.molecule;
@@ -14141,10 +14125,9 @@ var TemplateTool = function () {
14141
14125
  }
14142
14126
  }
14143
14127
  this.editor.hover(null);
14144
- var dragCtxItem = getDragCtxItem(this.editor, event, this.mode, this.mergeItems, this.findItems);
14145
14128
  this.dragCtx = {
14146
14129
  xy0: this.editor.render.page2obj(event),
14147
- item: dragCtxItem
14130
+ item: this.editor.findItem(event, this.findItems)
14148
14131
  };
14149
14132
  var dragCtx = this.dragCtx;
14150
14133
  var ci = dragCtx.item;
@@ -14197,26 +14180,10 @@ var TemplateTool = function () {
14197
14180
  key: "mousemove",
14198
14181
  value: function mousemove(event) {
14199
14182
  if (!this.dragCtx) {
14200
- if (this.followAction) {
14201
- this.followAction.perform(this.editor.render.ctab);
14202
- }
14203
- var _fromPaste = fromPaste(this.editor.render.ctab, this.template.molecule, this.editor.render.page2obj(event)),
14204
- _fromPaste2 = _slicedToArray(_fromPaste, 2),
14205
- followAction = _fromPaste2[0],
14206
- _pasteItems = _fromPaste2[1];
14207
- this.followAction = followAction;
14208
- this.editor.update(followAction, true, {
14209
- extendCanvas: false
14210
- });
14211
- if (this.mode === 'fg') {
14212
- var skip = getIgnoredGroupItem(this.editor.struct(), _pasteItems);
14213
- var _ci = this.editor.findItem(event, this.findItems, skip);
14214
- this.editor.hover(_ci !== null && _ci !== void 0 ? _ci : null, null, event);
14215
- } else {
14216
- this.mergeItems = getMergeItems(this.editor, _pasteItems);
14217
- this.editor.hover(getHoverToFuse(this.mergeItems));
14218
- }
14219
- return;
14183
+ this.editor.hoverIcon.show();
14184
+ this.editor.hoverIcon.updatePosition();
14185
+ this.editor.hover(this.editor.findItem(event, this.findItems), null, event);
14186
+ return true;
14220
14187
  }
14221
14188
  var dragCtx = this.dragCtx;
14222
14189
  var ci = dragCtx.item;
@@ -14237,10 +14204,10 @@ var TemplateTool = function () {
14237
14204
  var _fromTemplateOnBondAc = fromTemplateOnBondAction(this.editor.render.ctab, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, false),
14238
14205
  _fromTemplateOnBondAc2 = _slicedToArray(_fromTemplateOnBondAc, 2),
14239
14206
  _action = _fromTemplateOnBondAc2[0],
14240
- _pasteItems2 = _fromTemplateOnBondAc2[1];
14207
+ _pasteItems = _fromTemplateOnBondAc2[1];
14241
14208
  dragCtx.action = _action;
14242
14209
  this.editor.update(dragCtx.action, true);
14243
- dragCtx.mergeItems = getItemsToFuse(this.editor, _pasteItems2);
14210
+ dragCtx.mergeItems = getItemsToFuse(this.editor, _pasteItems);
14244
14211
  this.editor.hover(getHoverToFuse(dragCtx.mergeItems));
14245
14212
  }
14246
14213
  return true;
@@ -14311,7 +14278,7 @@ var TemplateTool = function () {
14311
14278
  key: "mouseup",
14312
14279
  value: function mouseup(event) {
14313
14280
  var _this = this,
14314
- _ci2;
14281
+ _ci;
14315
14282
  var dragCtx = this.dragCtx;
14316
14283
  if (this.targetGroupsIds.length && this.mode !== 'fg') {
14317
14284
  this.editor.event.removeFG.dispatch({
@@ -14345,7 +14312,7 @@ var TemplateTool = function () {
14345
14312
  if (this.isSaltOrSolvent) {
14346
14313
  addSaltsAndSolventsOnCanvasWithoutMerge(restruct, this.template, dragCtx, this.editor);
14347
14314
  return true;
14348
- } else if (((_ci2 = ci) === null || _ci2 === void 0 ? void 0 : _ci2.map) === 'functionalGroups' && FunctionalGroup.isContractedFunctionalGroup(ci.id, functionalGroups) && this.mode === 'fg' && this.targetGroupsIds.length) {
14315
+ } else if (((_ci = ci) === null || _ci === void 0 ? void 0 : _ci.map) === 'functionalGroups' && FunctionalGroup.isContractedFunctionalGroup(ci.id, functionalGroups) && this.mode === 'fg' && this.targetGroupsIds.length) {
14349
14316
  functionalGroupRemoveAction = new Action();
14350
14317
  var _struct = this.editor.struct();
14351
14318
  var _restruct = this.editor.render.ctab;
@@ -14427,10 +14394,6 @@ var TemplateTool = function () {
14427
14394
  }, {
14428
14395
  key: "cancel",
14429
14396
  value: function cancel(e) {
14430
- if (this.followAction) {
14431
- this.followAction.perform(this.editor.render.ctab);
14432
- delete this.followAction;
14433
- }
14434
14397
  this.mouseup(e);
14435
14398
  }
14436
14399
  }, {
@@ -14479,23 +14442,6 @@ function getTargetAtomId(struct, ci) {
14479
14442
  return group === null || group === void 0 ? void 0 : group.getAttAtomId(struct);
14480
14443
  }
14481
14444
  }
14482
- function getIgnoredGroupItem(struct, pasteItems) {
14483
- var groupId = struct.getGroupIdFromAtomId(pasteItems.atoms[0]);
14484
- return {
14485
- map: 'functionalGroups',
14486
- id: groupId
14487
- };
14488
- }
14489
- function getDragCtxItem(editor, event, mode, mergeItems, findItems) {
14490
- if (mode === 'fg') return editor.findItem(event, findItems);
14491
- if ((mergeItems === null || mergeItems === void 0 ? void 0 : mergeItems.atoms.size) === 1 && mergeItems.bonds.size === 0) {
14492
- return {
14493
- map: 'atoms',
14494
- id: mergeItems.atoms.values().next().value
14495
- };
14496
- }
14497
- return null;
14498
- }
14499
14445
 
14500
14446
  var TextTool = function () {
14501
14447
  function TextTool(editor) {
@@ -15937,13 +15883,126 @@ function getValidInputOnly(struct, atoms, bonds) {
15937
15883
  };
15938
15884
  }
15939
15885
 
15886
+ var HOVER_ICON_OPACITY = 0.7;
15887
+ var HoverIcon = function () {
15888
+ function HoverIcon(editor) {
15889
+ _classCallCheck(this, HoverIcon);
15890
+ this.editor = editor;
15891
+ var icon = this.initialize();
15892
+ this.element = icon.element;
15893
+ this._fill = icon.fill;
15894
+ this._label = icon.label;
15895
+ this.isShown = true;
15896
+ this.shouldBeShownWhenMouseBack = false;
15897
+ this.updatePosition();
15898
+ var clientArea = this.editor.render.clientArea;
15899
+ this.onMouseMove = this.onMouseMove.bind(this);
15900
+ this.onMouseLeave = this.onMouseLeave.bind(this);
15901
+ document.addEventListener('mousemove', this.onMouseMove);
15902
+ clientArea.addEventListener('mouseover', this.onMouseMove);
15903
+ clientArea.addEventListener('mouseleave', this.onMouseLeave);
15904
+ }
15905
+ _createClass(HoverIcon, [{
15906
+ key: "fill",
15907
+ get: function get() {
15908
+ return this._fill;
15909
+ },
15910
+ set: function set(fillColor) {
15911
+ this._fill = fillColor;
15912
+ this.element.attr('fill', fillColor);
15913
+ }
15914
+ }, {
15915
+ key: "label",
15916
+ get: function get() {
15917
+ return this._label;
15918
+ },
15919
+ set: function set(label) {
15920
+ this._label = label;
15921
+ this.element.attr('text', label);
15922
+ }
15923
+ }, {
15924
+ key: "isOverLoader",
15925
+ value: function isOverLoader(event) {
15926
+ var target = (event === null || event === void 0 ? void 0 : event.relatedTarget) || event.target;
15927
+ return target === null || target === void 0 ? void 0 : target.classList.contains('loading-spinner');
15928
+ }
15929
+ }, {
15930
+ key: "onMouseMove",
15931
+ value: function onMouseMove(event) {
15932
+ if (this.isShown || this.isOverLoader(event) && this.shouldBeShownWhenMouseBack) {
15933
+ this.show();
15934
+ this.updatePosition();
15935
+ }
15936
+ }
15937
+ }, {
15938
+ key: "onMouseLeave",
15939
+ value: function onMouseLeave(event) {
15940
+ if (!this.isOverLoader(event)) {
15941
+ this.shouldBeShownWhenMouseBack = true;
15942
+ this.hide();
15943
+ }
15944
+ }
15945
+ }, {
15946
+ key: "updatePosition",
15947
+ value: function updatePosition() {
15948
+ var _this$editor$lastCurs = this.editor.lastCursorPosition,
15949
+ x = _this$editor$lastCurs.x,
15950
+ y = _this$editor$lastCurs.y;
15951
+ this.element.attr({
15952
+ x: x,
15953
+ y: y
15954
+ });
15955
+ }
15956
+ }, {
15957
+ key: "show",
15958
+ value: function show() {
15959
+ this.element.show();
15960
+ this.isShown = true;
15961
+ this.shouldBeShownWhenMouseBack = false;
15962
+ }
15963
+ }, {
15964
+ key: "hide",
15965
+ value: function hide() {
15966
+ this.element.hide();
15967
+ this.isShown = false;
15968
+ }
15969
+ }, {
15970
+ key: "initialize",
15971
+ value: function initialize() {
15972
+ var _this$fill;
15973
+ var render = this.editor.render;
15974
+ var fillColor = (_this$fill = this.fill) !== null && _this$fill !== void 0 ? _this$fill : '#000000';
15975
+ var element = render.paper.text(0, 0, this.label || '');
15976
+ element.attr('fill', fillColor);
15977
+ element.attr('font-size', this.editor.options().fontsz);
15978
+ element.attr('opacity', HOVER_ICON_OPACITY);
15979
+ return {
15980
+ element: element,
15981
+ fill: fillColor,
15982
+ label: (this === null || this === void 0 ? void 0 : this.label) || ''
15983
+ };
15984
+ }
15985
+ }, {
15986
+ key: "create",
15987
+ value: function create() {
15988
+ var icon = this.initialize();
15989
+ this.element = icon.element;
15990
+ this._fill = icon.fill;
15991
+ this._label = icon.label;
15992
+ this.isShown = true;
15993
+ this.shouldBeShownWhenMouseBack = false;
15994
+ this.updatePosition();
15995
+ }
15996
+ }]);
15997
+ return HoverIcon;
15998
+ }();
15999
+
15940
16000
  function ownKeys$J(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15941
16001
  function _objectSpread$J(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$J(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$J(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15942
16002
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
15943
16003
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
15944
16004
  var SCALE = 40;
15945
16005
  var HISTORY_SIZE = 32;
15946
- var HOVER_ICON_OPACITY = 0.7;
15947
16006
  var structObjects = ['atoms', 'bonds', 'frags', 'sgroups', 'sgroupData', 'rgroups', 'rxnArrows', 'rxnPluses', 'enhancedFlags', 'simpleObjects', 'texts'];
15948
16007
  var highlightTargets = ['atoms', 'bonds', 'rxnArrows', 'rxnPluses', 'functionalGroups', 'frags', 'merge', 'rgroups', 'sgroups', 'sgroupData', 'enhancedFlags', 'simpleObjects', 'texts'];
15949
16008
  function selectStereoFlagsIfNecessary(atoms, expAtoms) {
@@ -15984,7 +16043,8 @@ var Editor$3 = function () {
15984
16043
  x: 0,
15985
16044
  y: 0
15986
16045
  };
15987
- this.createHoverIcon();
16046
+ this.hoverIcon = new HoverIcon(this);
16047
+ this.hoverIcon.updatePosition();
15988
16048
  this.contextMenu = {};
15989
16049
  this.event = {
15990
16050
  message: new Subscription(),
@@ -16044,26 +16104,6 @@ var Editor$3 = function () {
16044
16104
  this._tool = tool;
16045
16105
  return this._tool;
16046
16106
  }
16047
- }, {
16048
- key: "updateHoverIconPosition",
16049
- value: function updateHoverIconPosition() {
16050
- var _this$lastCursorPosit = this.lastCursorPosition,
16051
- x = _this$lastCursorPosit.x,
16052
- y = _this$lastCursorPosit.y;
16053
- var _this$hoverIcon$getBB = this.hoverIcon.getBBox(),
16054
- height = _this$hoverIcon$getBB.height,
16055
- width = _this$hoverIcon$getBB.width;
16056
- this.hoverIcon.attr({
16057
- x: x - width / 2,
16058
- y: y - height / 2
16059
- });
16060
- }
16061
- }, {
16062
- key: "createHoverIcon",
16063
- value: function createHoverIcon() {
16064
- this.hoverIcon = this.render.paper.text(0, 0, '').attr('font-size', this.options().fontsz).attr('opacity', HOVER_ICON_OPACITY);
16065
- this.updateHoverIconPosition();
16066
- }
16067
16107
  }, {
16068
16108
  key: "clear",
16069
16109
  value: function clear() {
@@ -16087,7 +16127,7 @@ var Editor$3 = function () {
16087
16127
  this.selection(null);
16088
16128
  var struct = value || new Struct();
16089
16129
  var molecule = this.renderAndRecoordinateStruct(struct);
16090
- this.createHoverIcon();
16130
+ this.hoverIcon.create();
16091
16131
  return molecule;
16092
16132
  }
16093
16133
  }, {
@@ -17735,7 +17775,7 @@ var StructEditor = function (_Component) {
17735
17775
  className: classes$D.measureLog,
17736
17776
  ref: this.logRef
17737
17777
  }), indigoVerification && jsx("div", {
17738
- className: classes$D.spinnerOverlay,
17778
+ className: "".concat(classes$D.spinnerOverlay, " loading-spinner"),
17739
17779
  children: jsx(LoadingCircles, {})
17740
17780
  }), jsx(InfoPanel$1, {
17741
17781
  clientX: clientX,
@@ -24015,8 +24055,8 @@ var KetcherBuilder = function () {
24015
24055
  initApp(element, staticResourcesUrl, {
24016
24056
  buttons: buttons || {},
24017
24057
  errorHandler: errorHandler || null,
24018
- version: "2.9.0-rc.4" ,
24019
- buildDate: "2023-03-20T17:32:42" ,
24058
+ version: "2.9.0-rc.5-dev.1" ,
24059
+ buildDate: "2023-03-30T12:13:55" ,
24020
24060
  buildNumber: ''
24021
24061
  }, structService, resolve);
24022
24062
  });