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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3073,7 +3073,7 @@ var zoom = {
3073
3073
 
3074
3074
  var openHelpLink = function openHelpLink() {
3075
3075
  var _window$open;
3076
- 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();
3076
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.9.0-rc.5\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3077
3077
  };
3078
3078
  var help = {
3079
3079
  help: {
@@ -10415,6 +10415,7 @@ function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateColle
10415
10415
  var _bondProps = new WeakMap();
10416
10416
  var AtomTool = function () {
10417
10417
  function AtomTool(editor, atomProps) {
10418
+ var _ElementColor$atomPro;
10418
10419
  _classCallCheck__default["default"](this, AtomTool);
10419
10420
  _classPrivateFieldInitSpec$2(this, _bondProps, {
10420
10421
  writable: true,
@@ -10426,8 +10427,10 @@ var AtomTool = function () {
10426
10427
  type: 1,
10427
10428
  stereo: ketcherCore.Bond.PATTERN.STEREO.NONE
10428
10429
  });
10429
- this.editor.hoverIcon.show().attr('text', "".concat(atomProps.label)).attr('fill', "".concat(ketcherCore.ElementColor[atomProps.label]));
10430
- this.editor.updateHoverIconPosition();
10430
+ this.editor.hoverIcon.show();
10431
+ this.editor.hoverIcon.label = atomProps.label;
10432
+ this.editor.hoverIcon.fill = (_ElementColor$atomPro = ketcherCore.ElementColor[atomProps.label]) !== null && _ElementColor$atomPro !== void 0 ? _ElementColor$atomPro : '#000000';
10433
+ this.editor.hoverIcon.updatePosition();
10431
10434
  if (editor.selection()) {
10432
10435
  var _editor$selection;
10433
10436
  if ((_editor$selection = editor.selection()) !== null && _editor$selection !== void 0 && _editor$selection.atoms) {
@@ -10511,32 +10514,13 @@ var AtomTool = function () {
10511
10514
  };
10512
10515
  }
10513
10516
  }
10514
- }, {
10515
- key: "mouseLeaveClientArea",
10516
- value: function mouseLeaveClientArea() {
10517
- this.editor.hoverIcon.hide();
10518
- }
10519
- }, {
10520
- key: "mouseover",
10521
- value: function mouseover() {
10522
- this.editor.hoverIcon.show();
10523
- this.editor.updateHoverIconPosition();
10524
- }
10525
10517
  }, {
10526
10518
  key: "mousemove",
10527
10519
  value: function mousemove(event) {
10528
10520
  this.editor.hoverIcon.show();
10529
10521
  var rnd = this.editor.render;
10530
- var layerX = event.layerX,
10531
- layerY = event.layerY;
10532
10522
  if (!this.dragCtx || !this.dragCtx.item) {
10533
- var _this$editor$hoverIco = this.editor.hoverIcon.getBBox(),
10534
- height = _this$editor$hoverIco.height,
10535
- width = _this$editor$hoverIco.width;
10536
- this.editor.hoverIcon.attr({
10537
- x: layerX - width / 2,
10538
- y: layerY - height / 2
10539
- });
10523
+ this.editor.hoverIcon.updatePosition();
10540
10524
  this.editor.hover(this.editor.findItem(event, ['atoms', 'functionalGroups']), null, event);
10541
10525
  return;
10542
10526
  }
@@ -14182,14 +14166,14 @@ var TemplateTool = function () {
14182
14166
  if (sgroup) {
14183
14167
  this.findItems.push('functionalGroups');
14184
14168
  }
14169
+ editor.hoverIcon.label = tmpl.struct.name;
14170
+ editor.hoverIcon.fill = '#000000';
14171
+ editor.hoverIcon.show();
14172
+ editor.hoverIcon.updatePosition();
14185
14173
  }
14186
14174
  _createClass__default["default"](TemplateTool, [{
14187
14175
  key: "mousedown",
14188
14176
  value: function mousedown(event) {
14189
- if (this.followAction) {
14190
- this.followAction.perform(this.editor.render.ctab);
14191
- delete this.followAction;
14192
- }
14193
14177
  var closestItem = this.editor.findItem(event, ['atoms', 'bonds', 'sgroups', 'functionalGroups']);
14194
14178
  var ctab = this.editor.render.ctab;
14195
14179
  var struct = ctab.molecule;
@@ -14204,10 +14188,9 @@ var TemplateTool = function () {
14204
14188
  }
14205
14189
  }
14206
14190
  this.editor.hover(null);
14207
- var dragCtxItem = getDragCtxItem(this.editor, event, this.mode, this.mergeItems, this.findItems);
14208
14191
  this.dragCtx = {
14209
14192
  xy0: this.editor.render.page2obj(event),
14210
- item: dragCtxItem
14193
+ item: this.editor.findItem(event, this.findItems)
14211
14194
  };
14212
14195
  var dragCtx = this.dragCtx;
14213
14196
  var ci = dragCtx.item;
@@ -14260,26 +14243,10 @@ var TemplateTool = function () {
14260
14243
  key: "mousemove",
14261
14244
  value: function mousemove(event) {
14262
14245
  if (!this.dragCtx) {
14263
- if (this.followAction) {
14264
- this.followAction.perform(this.editor.render.ctab);
14265
- }
14266
- var _fromPaste = ketcherCore.fromPaste(this.editor.render.ctab, this.template.molecule, this.editor.render.page2obj(event)),
14267
- _fromPaste2 = _slicedToArray__default["default"](_fromPaste, 2),
14268
- followAction = _fromPaste2[0],
14269
- _pasteItems = _fromPaste2[1];
14270
- this.followAction = followAction;
14271
- this.editor.update(followAction, true, {
14272
- extendCanvas: false
14273
- });
14274
- if (this.mode === 'fg') {
14275
- var skip = getIgnoredGroupItem(this.editor.struct(), _pasteItems);
14276
- var _ci = this.editor.findItem(event, this.findItems, skip);
14277
- this.editor.hover(_ci !== null && _ci !== void 0 ? _ci : null, null, event);
14278
- } else {
14279
- this.mergeItems = getMergeItems(this.editor, _pasteItems);
14280
- this.editor.hover(ketcherCore.getHoverToFuse(this.mergeItems));
14281
- }
14282
- return;
14246
+ this.editor.hoverIcon.show();
14247
+ this.editor.hoverIcon.updatePosition();
14248
+ this.editor.hover(this.editor.findItem(event, this.findItems), null, event);
14249
+ return true;
14283
14250
  }
14284
14251
  var dragCtx = this.dragCtx;
14285
14252
  var ci = dragCtx.item;
@@ -14300,10 +14267,10 @@ var TemplateTool = function () {
14300
14267
  var _fromTemplateOnBondAc = ketcherCore.fromTemplateOnBondAction(this.editor.render.ctab, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, false),
14301
14268
  _fromTemplateOnBondAc2 = _slicedToArray__default["default"](_fromTemplateOnBondAc, 2),
14302
14269
  _action = _fromTemplateOnBondAc2[0],
14303
- _pasteItems2 = _fromTemplateOnBondAc2[1];
14270
+ _pasteItems = _fromTemplateOnBondAc2[1];
14304
14271
  dragCtx.action = _action;
14305
14272
  this.editor.update(dragCtx.action, true);
14306
- dragCtx.mergeItems = ketcherCore.getItemsToFuse(this.editor, _pasteItems2);
14273
+ dragCtx.mergeItems = ketcherCore.getItemsToFuse(this.editor, _pasteItems);
14307
14274
  this.editor.hover(ketcherCore.getHoverToFuse(dragCtx.mergeItems));
14308
14275
  }
14309
14276
  return true;
@@ -14374,7 +14341,7 @@ var TemplateTool = function () {
14374
14341
  key: "mouseup",
14375
14342
  value: function mouseup(event) {
14376
14343
  var _this = this,
14377
- _ci2;
14344
+ _ci;
14378
14345
  var dragCtx = this.dragCtx;
14379
14346
  if (this.targetGroupsIds.length && this.mode !== 'fg') {
14380
14347
  this.editor.event.removeFG.dispatch({
@@ -14408,7 +14375,7 @@ var TemplateTool = function () {
14408
14375
  if (this.isSaltOrSolvent) {
14409
14376
  addSaltsAndSolventsOnCanvasWithoutMerge(restruct, this.template, dragCtx, this.editor);
14410
14377
  return true;
14411
- } else if (((_ci2 = ci) === null || _ci2 === void 0 ? void 0 : _ci2.map) === 'functionalGroups' && ketcherCore.FunctionalGroup.isContractedFunctionalGroup(ci.id, functionalGroups) && this.mode === 'fg' && this.targetGroupsIds.length) {
14378
+ } else if (((_ci = ci) === null || _ci === void 0 ? void 0 : _ci.map) === 'functionalGroups' && ketcherCore.FunctionalGroup.isContractedFunctionalGroup(ci.id, functionalGroups) && this.mode === 'fg' && this.targetGroupsIds.length) {
14412
14379
  functionalGroupRemoveAction = new ketcherCore.Action();
14413
14380
  var _struct = this.editor.struct();
14414
14381
  var _restruct = this.editor.render.ctab;
@@ -14490,10 +14457,6 @@ var TemplateTool = function () {
14490
14457
  }, {
14491
14458
  key: "cancel",
14492
14459
  value: function cancel(e) {
14493
- if (this.followAction) {
14494
- this.followAction.perform(this.editor.render.ctab);
14495
- delete this.followAction;
14496
- }
14497
14460
  this.mouseup(e);
14498
14461
  }
14499
14462
  }, {
@@ -14542,23 +14505,6 @@ function getTargetAtomId(struct, ci) {
14542
14505
  return group === null || group === void 0 ? void 0 : group.getAttAtomId(struct);
14543
14506
  }
14544
14507
  }
14545
- function getIgnoredGroupItem(struct, pasteItems) {
14546
- var groupId = struct.getGroupIdFromAtomId(pasteItems.atoms[0]);
14547
- return {
14548
- map: 'functionalGroups',
14549
- id: groupId
14550
- };
14551
- }
14552
- function getDragCtxItem(editor, event, mode, mergeItems, findItems) {
14553
- if (mode === 'fg') return editor.findItem(event, findItems);
14554
- if ((mergeItems === null || mergeItems === void 0 ? void 0 : mergeItems.atoms.size) === 1 && mergeItems.bonds.size === 0) {
14555
- return {
14556
- map: 'atoms',
14557
- id: mergeItems.atoms.values().next().value
14558
- };
14559
- }
14560
- return null;
14561
- }
14562
14508
 
14563
14509
  var TextTool = function () {
14564
14510
  function TextTool(editor) {
@@ -16000,13 +15946,126 @@ function getValidInputOnly(struct, atoms, bonds) {
16000
15946
  };
16001
15947
  }
16002
15948
 
15949
+ var HOVER_ICON_OPACITY = 0.7;
15950
+ var HoverIcon = function () {
15951
+ function HoverIcon(editor) {
15952
+ _classCallCheck__default["default"](this, HoverIcon);
15953
+ this.editor = editor;
15954
+ var icon = this.initialize();
15955
+ this.element = icon.element;
15956
+ this._fill = icon.fill;
15957
+ this._label = icon.label;
15958
+ this.isShown = true;
15959
+ this.shouldBeShownWhenMouseBack = false;
15960
+ this.updatePosition();
15961
+ var clientArea = this.editor.render.clientArea;
15962
+ this.onMouseMove = this.onMouseMove.bind(this);
15963
+ this.onMouseLeave = this.onMouseLeave.bind(this);
15964
+ document.addEventListener('mousemove', this.onMouseMove);
15965
+ clientArea.addEventListener('mouseover', this.onMouseMove);
15966
+ clientArea.addEventListener('mouseleave', this.onMouseLeave);
15967
+ }
15968
+ _createClass__default["default"](HoverIcon, [{
15969
+ key: "fill",
15970
+ get: function get() {
15971
+ return this._fill;
15972
+ },
15973
+ set: function set(fillColor) {
15974
+ this._fill = fillColor;
15975
+ this.element.attr('fill', fillColor);
15976
+ }
15977
+ }, {
15978
+ key: "label",
15979
+ get: function get() {
15980
+ return this._label;
15981
+ },
15982
+ set: function set(label) {
15983
+ this._label = label;
15984
+ this.element.attr('text', label);
15985
+ }
15986
+ }, {
15987
+ key: "isOverLoader",
15988
+ value: function isOverLoader(event) {
15989
+ var target = (event === null || event === void 0 ? void 0 : event.relatedTarget) || event.target;
15990
+ return target === null || target === void 0 ? void 0 : target.classList.contains('loading-spinner');
15991
+ }
15992
+ }, {
15993
+ key: "onMouseMove",
15994
+ value: function onMouseMove(event) {
15995
+ if (this.isShown || this.isOverLoader(event) && this.shouldBeShownWhenMouseBack) {
15996
+ this.show();
15997
+ this.updatePosition();
15998
+ }
15999
+ }
16000
+ }, {
16001
+ key: "onMouseLeave",
16002
+ value: function onMouseLeave(event) {
16003
+ if (!this.isOverLoader(event)) {
16004
+ this.shouldBeShownWhenMouseBack = true;
16005
+ this.hide();
16006
+ }
16007
+ }
16008
+ }, {
16009
+ key: "updatePosition",
16010
+ value: function updatePosition() {
16011
+ var _this$editor$lastCurs = this.editor.lastCursorPosition,
16012
+ x = _this$editor$lastCurs.x,
16013
+ y = _this$editor$lastCurs.y;
16014
+ this.element.attr({
16015
+ x: x,
16016
+ y: y
16017
+ });
16018
+ }
16019
+ }, {
16020
+ key: "show",
16021
+ value: function show() {
16022
+ this.element.show();
16023
+ this.isShown = true;
16024
+ this.shouldBeShownWhenMouseBack = false;
16025
+ }
16026
+ }, {
16027
+ key: "hide",
16028
+ value: function hide() {
16029
+ this.element.hide();
16030
+ this.isShown = false;
16031
+ }
16032
+ }, {
16033
+ key: "initialize",
16034
+ value: function initialize() {
16035
+ var _this$fill;
16036
+ var render = this.editor.render;
16037
+ var fillColor = (_this$fill = this.fill) !== null && _this$fill !== void 0 ? _this$fill : '#000000';
16038
+ var element = render.paper.text(0, 0, this.label || '');
16039
+ element.attr('fill', fillColor);
16040
+ element.attr('font-size', this.editor.options().fontsz);
16041
+ element.attr('opacity', HOVER_ICON_OPACITY);
16042
+ return {
16043
+ element: element,
16044
+ fill: fillColor,
16045
+ label: (this === null || this === void 0 ? void 0 : this.label) || ''
16046
+ };
16047
+ }
16048
+ }, {
16049
+ key: "create",
16050
+ value: function create() {
16051
+ var icon = this.initialize();
16052
+ this.element = icon.element;
16053
+ this._fill = icon.fill;
16054
+ this._label = icon.label;
16055
+ this.isShown = true;
16056
+ this.shouldBeShownWhenMouseBack = false;
16057
+ this.updatePosition();
16058
+ }
16059
+ }]);
16060
+ return HoverIcon;
16061
+ }();
16062
+
16003
16063
  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; }
16004
16064
  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__default["default"](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; }
16005
16065
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
16006
16066
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
16007
16067
  var SCALE = 40;
16008
16068
  var HISTORY_SIZE = 32;
16009
- var HOVER_ICON_OPACITY = 0.7;
16010
16069
  var structObjects = ['atoms', 'bonds', 'frags', 'sgroups', 'sgroupData', 'rgroups', 'rxnArrows', 'rxnPluses', 'enhancedFlags', 'simpleObjects', 'texts'];
16011
16070
  var highlightTargets = ['atoms', 'bonds', 'rxnArrows', 'rxnPluses', 'functionalGroups', 'frags', 'merge', 'rgroups', 'sgroups', 'sgroupData', 'enhancedFlags', 'simpleObjects', 'texts'];
16012
16071
  function selectStereoFlagsIfNecessary(atoms, expAtoms) {
@@ -16047,7 +16106,8 @@ var Editor$3 = function () {
16047
16106
  x: 0,
16048
16107
  y: 0
16049
16108
  };
16050
- this.createHoverIcon();
16109
+ this.hoverIcon = new HoverIcon(this);
16110
+ this.hoverIcon.updatePosition();
16051
16111
  this.contextMenu = {};
16052
16112
  this.event = {
16053
16113
  message: new subscription.Subscription(),
@@ -16107,26 +16167,6 @@ var Editor$3 = function () {
16107
16167
  this._tool = tool;
16108
16168
  return this._tool;
16109
16169
  }
16110
- }, {
16111
- key: "updateHoverIconPosition",
16112
- value: function updateHoverIconPosition() {
16113
- var _this$lastCursorPosit = this.lastCursorPosition,
16114
- x = _this$lastCursorPosit.x,
16115
- y = _this$lastCursorPosit.y;
16116
- var _this$hoverIcon$getBB = this.hoverIcon.getBBox(),
16117
- height = _this$hoverIcon$getBB.height,
16118
- width = _this$hoverIcon$getBB.width;
16119
- this.hoverIcon.attr({
16120
- x: x - width / 2,
16121
- y: y - height / 2
16122
- });
16123
- }
16124
- }, {
16125
- key: "createHoverIcon",
16126
- value: function createHoverIcon() {
16127
- this.hoverIcon = this.render.paper.text(0, 0, '').attr('font-size', this.options().fontsz).attr('opacity', HOVER_ICON_OPACITY);
16128
- this.updateHoverIconPosition();
16129
- }
16130
16170
  }, {
16131
16171
  key: "clear",
16132
16172
  value: function clear() {
@@ -16150,7 +16190,7 @@ var Editor$3 = function () {
16150
16190
  this.selection(null);
16151
16191
  var struct = value || new ketcherCore.Struct();
16152
16192
  var molecule = this.renderAndRecoordinateStruct(struct);
16153
- this.createHoverIcon();
16193
+ this.hoverIcon.create();
16154
16194
  return molecule;
16155
16195
  }
16156
16196
  }, {
@@ -17798,7 +17838,7 @@ var StructEditor = function (_Component) {
17798
17838
  className: classes$D.measureLog,
17799
17839
  ref: this.logRef
17800
17840
  }), indigoVerification && jsxRuntime.jsx("div", {
17801
- className: classes$D.spinnerOverlay,
17841
+ className: "".concat(classes$D.spinnerOverlay, " loading-spinner"),
17802
17842
  children: jsxRuntime.jsx(LoadingCircles, {})
17803
17843
  }), jsxRuntime.jsx(InfoPanel$1, {
17804
17844
  clientX: clientX,
@@ -24078,8 +24118,8 @@ var KetcherBuilder = function () {
24078
24118
  initApp(element, staticResourcesUrl, {
24079
24119
  buttons: buttons || {},
24080
24120
  errorHandler: errorHandler || null,
24081
- version: "2.9.0-rc.4" ,
24082
- buildDate: "2023-03-20T17:32:42" ,
24121
+ version: "2.9.0-rc.5" ,
24122
+ buildDate: "2023-03-27T12:30:17" ,
24083
24123
  buildNumber: ''
24084
24124
  }, structService, resolve);
24085
24125
  });