ketcher-react 2.7.0-rc.8 → 2.7.0-rc.9

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.
@@ -40,7 +40,7 @@ import ReactDOM from 'react-dom';
40
40
  import { connect, useDispatch, useSelector, Provider } from 'react-redux';
41
41
  import { combineReducers, createStore as createStore$1, applyMiddleware } from 'redux';
42
42
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
43
- import { logger } from 'redux-logger';
43
+ import 'redux-logger';
44
44
  import thunk from 'redux-thunk';
45
45
  import { throttle as throttle$1, inRange, isEqual as isEqual$1, range as range$1 } from 'lodash';
46
46
  import useResizeObserver from 'use-resize-observer/polyfilled';
@@ -366,7 +366,6 @@ function _copy(cb, data) {
366
366
  cb.setData(fmt, data[fmt]);
367
367
  });
368
368
  } catch (ex) {
369
- console.info("Could not write exact type ".concat(curFmt));
370
369
  }
371
370
  }
372
371
  }
@@ -692,7 +691,6 @@ var storage = {
692
691
  try {
693
692
  item = JSON.parse(localStorage.getItem(key));
694
693
  } catch (ex) {
695
- console.info('LocalStorage:', ex.name);
696
694
  }
697
695
  return item;
698
696
  },
@@ -702,7 +700,6 @@ var storage = {
702
700
  localStorage.setItem(key, JSON.stringify(data));
703
701
  isSet = true;
704
702
  } catch (ex) {
705
- console.info('LocalStorage:', ex.name);
706
703
  isSet = false;
707
704
  }
708
705
  return isSet;
@@ -837,7 +834,6 @@ function constant(schema, prop) {
837
834
  return desc.constant || desc["enum"][0];
838
835
  }
839
836
  function mapOf(schema, prop) {
840
- console.assert(schema.oneOf);
841
837
  return schema.oneOf.reduce(function (res, desc) {
842
838
  res[constant(desc, prop)] = desc;
843
839
  return res;
@@ -2877,7 +2873,7 @@ var zoom = {
2877
2873
 
2878
2874
  var openHelpLink = function openHelpLink() {
2879
2875
  var _window$open;
2880
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.6.0\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
2876
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.7.0-rc.9\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
2881
2877
  };
2882
2878
  var help = {
2883
2879
  help: {
@@ -7646,9 +7642,7 @@ function execute(activeTool, _ref) {
7646
7642
  }
7647
7643
  } else if (typeof action === 'function') {
7648
7644
  action(editor, server, options);
7649
- } else {
7650
- console.info('no action');
7651
- }
7645
+ } else ;
7652
7646
  return activeTool;
7653
7647
  }
7654
7648
  function selected(actObj, activeTool, _ref2) {
@@ -7887,7 +7881,6 @@ function greekify(str) {
7887
7881
  });
7888
7882
  }
7889
7883
  function filterLib(lib, filter$1) {
7890
- console.warn('Filter', filter$1);
7891
7884
  var trimmedFilter = filter$1.trim();
7892
7885
  var re = new RegExp(escapeRegExp(greekify(trimmedFilter)), 'i');
7893
7886
  return flow(filter(function (item) {
@@ -7898,7 +7891,6 @@ function filterLib(lib, filter$1) {
7898
7891
  }, {}))(lib);
7899
7892
  }
7900
7893
  function filterFGLib(lib, filter$1) {
7901
- console.warn('Filter', filter$1);
7902
7894
  var trimmedFilter = filter$1.trim();
7903
7895
  var re = new RegExp(escapeRegExp(greekify(trimmedFilter)), 'i');
7904
7896
  var searchFunction = function searchFunction(item) {
@@ -8183,9 +8175,6 @@ function createStore (options, server, setEditor) {
8183
8175
  templates: initTmplsState
8184
8176
  };
8185
8177
  var middleware = [thunk];
8186
- if (process.env.KETCHER_ENABLE_REDUX_LOGGER === 'true') {
8187
- middleware.push(logger);
8188
- }
8189
8178
  var rootReducer = getRootReducer(setEditor);
8190
8179
  return createStore$1(rootReducer, initState, applyMiddleware.apply(void 0, middleware));
8191
8180
  }
@@ -9772,7 +9761,6 @@ var TopToolbar = function TopToolbar(_ref) {
9772
9761
  isCollapsed: width < collapseLimit
9773
9762
  }), jsx(SystemControls, {
9774
9763
  onHistoryClick: function onHistoryClick() {
9775
- console.log('History button clicked');
9776
9764
  },
9777
9765
  onSettingsOpen: onSettingsOpen,
9778
9766
  onFullscreen: onFullscreen,
@@ -10135,6 +10123,7 @@ var AtomTool = function () {
10135
10123
  stereo: Bond$2.PATTERN.STEREO.NONE
10136
10124
  });
10137
10125
  this.editor.hoverIcon.show().attr('text', "".concat(atomProps.label)).attr('fill', "".concat(ElementColor[atomProps.label]));
10126
+ this.editor.updateHoverIconPosition();
10138
10127
  if (editor.selection()) {
10139
10128
  var _editor$selection;
10140
10129
  if ((_editor$selection = editor.selection()) !== null && _editor$selection !== void 0 && _editor$selection.atoms) {
@@ -10227,6 +10216,7 @@ var AtomTool = function () {
10227
10216
  key: "mouseover",
10228
10217
  value: function mouseover() {
10229
10218
  this.editor.hoverIcon.show();
10219
+ this.editor.updateHoverIconPosition();
10230
10220
  }
10231
10221
  }, {
10232
10222
  key: "mousemove",
@@ -11702,7 +11692,6 @@ var SGroupTool = function () {
11702
11692
  var type = sg ? sg.type : defaultType;
11703
11693
  var eventName = type === 'DAT' ? 'sdataEdit' : 'sgroupEdit';
11704
11694
  if (!selection.atoms && !selection.bonds && !sg) {
11705
- console.info('There is no selection or sgroup');
11706
11695
  return;
11707
11696
  }
11708
11697
  var attrs;
@@ -12584,7 +12573,6 @@ var EraserTool = function () {
12584
12573
  } else if (ci.map === 'texts') {
12585
12574
  this.editor.update(fromTextDeletion(restruct, ci.id));
12586
12575
  } else {
12587
- console.error('EraserTool: unable to delete the object ' + ci.map + '[' + ci.id + ']');
12588
12576
  return;
12589
12577
  }
12590
12578
  this.editor.selection(null);
@@ -15392,7 +15380,11 @@ var Editor$3 = function () {
15392
15380
  this.highlights = new Highlighter(this);
15393
15381
  this.renderAndRecoordinateStruct = this.renderAndRecoordinateStruct.bind(this);
15394
15382
  this.setOptions = this.setOptions.bind(this);
15395
- this.hoverIcon = this.render.paper.text(0, 0, '').attr('font-size', options.fontsz).attr('opacity', HOVER_ICON_OPACITY);
15383
+ this.lastCursorPosition = {
15384
+ x: 0,
15385
+ y: 0
15386
+ };
15387
+ this.createHoverIcon();
15396
15388
  this.event = {
15397
15389
  message: new Subscription(),
15398
15390
  elementEdit: new PipelineSubscription(),
@@ -15450,6 +15442,26 @@ var Editor$3 = function () {
15450
15442
  this._tool = tool;
15451
15443
  return this._tool;
15452
15444
  }
15445
+ }, {
15446
+ key: "updateHoverIconPosition",
15447
+ value: function updateHoverIconPosition() {
15448
+ var _this$lastCursorPosit = this.lastCursorPosition,
15449
+ x = _this$lastCursorPosit.x,
15450
+ y = _this$lastCursorPosit.y;
15451
+ var _this$hoverIcon$getBB = this.hoverIcon.getBBox(),
15452
+ height = _this$hoverIcon$getBB.height,
15453
+ width = _this$hoverIcon$getBB.width;
15454
+ this.hoverIcon.attr({
15455
+ x: x - width / 2,
15456
+ y: y - height / 2
15457
+ });
15458
+ }
15459
+ }, {
15460
+ key: "createHoverIcon",
15461
+ value: function createHoverIcon() {
15462
+ this.hoverIcon = this.render.paper.text(0, 0, '').attr('font-size', this.options().fontsz).attr('opacity', HOVER_ICON_OPACITY);
15463
+ this.updateHoverIconPosition();
15464
+ }
15453
15465
  }, {
15454
15466
  key: "clear",
15455
15467
  value: function clear() {
@@ -15472,7 +15484,9 @@ var Editor$3 = function () {
15472
15484
  }
15473
15485
  this.selection(null);
15474
15486
  var struct = value || new Struct();
15475
- return this.renderAndRecoordinateStruct(struct);
15487
+ var molecule = this.renderAndRecoordinateStruct(struct);
15488
+ this.createHoverIcon();
15489
+ return molecule;
15476
15490
  }
15477
15491
  }, {
15478
15492
  key: "structToAddFragment",
@@ -15748,12 +15762,27 @@ var Editor$3 = function () {
15748
15762
  function isMouseRight(event) {
15749
15763
  return event.which && event.which === 3 || event.button && event.button === 2;
15750
15764
  }
15765
+ function resetSelectionOnCanvasClick(editor, eventName) {
15766
+ if (eventName === 'mouseup') {
15767
+ editor.selection(null);
15768
+ }
15769
+ }
15770
+ function updateLastCursorPosition(editor, event) {
15771
+ var events = ['mousemove', 'click', 'mousedown', 'mouseup', 'mouseover'];
15772
+ if (events.includes(event.type)) {
15773
+ editor.lastCursorPosition = {
15774
+ x: event.layerX,
15775
+ y: event.layerY
15776
+ };
15777
+ }
15778
+ }
15751
15779
  function domEventSetup(editor, clientArea) {
15752
15780
  ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseup', 'mouseleave', 'mouseover'].forEach(function (eventName) {
15753
15781
  editor.event[eventName] = new DOMSubscription();
15754
15782
  var subs = editor.event[eventName];
15755
15783
  clientArea.addEventListener(eventName, subs.dispatch.bind(subs));
15756
15784
  subs.add(function (event) {
15785
+ updateLastCursorPosition(editor, event);
15757
15786
  if (eventName !== 'mouseup' && eventName !== 'mouseleave') {
15758
15787
  if (isMouseRight(event) || !event.target || event.target.nodeName === 'DIV') {
15759
15788
  editor.hover(null);
@@ -15766,16 +15795,13 @@ function domEventSetup(editor, clientArea) {
15766
15795
  EditorTool[eventName](event);
15767
15796
  return true;
15768
15797
  }
15769
- if (eventName === 'mouseup') {
15770
- editor.selection(null);
15771
- }
15798
+ resetSelectionOnCanvasClick(editor, eventName);
15772
15799
  return true;
15773
15800
  }, -1);
15774
15801
  });
15775
15802
  }
15776
15803
  function recoordinate(editor, rp
15777
15804
  ) {
15778
- console.assert(rp, 'Reference point not specified');
15779
15805
  if (rp) {
15780
15806
  editor.render.setScrollOffset(rp.x, rp.y);
15781
15807
  } else {
@@ -17995,7 +18021,6 @@ var mapDispatchToProps$b = function mapDispatchToProps(dispatch, ownProps) {
17995
18021
  result: JSON.parse(newOpts)
17996
18022
  }));
17997
18023
  } catch (ex) {
17998
- console.info('Bad file');
17999
18024
  }
18000
18025
  },
18001
18026
  onReset: function onReset() {
@@ -18699,7 +18724,7 @@ var MiewDialog = function MiewDialog(_ref) {
18699
18724
  }).then(function () {
18700
18725
  return miew.setOptions(miewOpts);
18701
18726
  })["catch"](function (ex) {
18702
- return console.error(ex.message);
18727
+ return (void 0);
18703
18728
  });
18704
18729
  }, [miewOpts, server, struct]);
18705
18730
  var exportCML = useCallback(function () {
@@ -22576,8 +22601,8 @@ var KetcherBuilder = function () {
22576
22601
  initApp(element, staticResourcesUrl, {
22577
22602
  buttons: buttons || {},
22578
22603
  errorHandler: errorHandler || null,
22579
- version: "2.6.4" ,
22580
- buildDate: "2022-12-28T14:55:11" ,
22604
+ version: "2.7.0-rc.9" ,
22605
+ buildDate: "2023-01-13T09:07:01" ,
22581
22606
  buildNumber: ''
22582
22607
  }, structService, resolve);
22583
22608
  });