ketcher-react 3.1.0-rc.5 → 3.2.0-rc.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.
package/dist/cjs/index.js CHANGED
@@ -3808,7 +3808,7 @@ var zoom = {
3808
3808
 
3809
3809
  var openHelpLink = function openHelpLink() {
3810
3810
  var _window$open;
3811
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v3.1.0-rc.5\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3811
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v3.2.0-rc.1\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3812
3812
  };
3813
3813
  var help = {
3814
3814
  help: {
@@ -23036,13 +23036,32 @@ var RotateTool = function () {
23036
23036
  key: "mouseup",
23037
23037
  value:
23038
23038
  function mouseup() {
23039
+ var _dragCtx$mergeItems,
23040
+ _this3 = this;
23039
23041
  if (!this.dragCtx) {
23040
23042
  return true;
23041
23043
  }
23042
23044
  this.reStruct.clearSnappingBonds();
23043
23045
  this.editor.update(true);
23044
23046
  var dragCtx = this.dragCtx;
23045
- var action = dragCtx.action ? ketcherCore.fromItemsFuse(this.reStruct, dragCtx.mergeItems).mergeWith(dragCtx.action) : ketcherCore.fromItemsFuse(this.reStruct, dragCtx.mergeItems);
23047
+ var isMergingSGroup = false;
23048
+ var _ref = (_dragCtx$mergeItems = dragCtx.mergeItems) !== null && _dragCtx$mergeItems !== void 0 ? _dragCtx$mergeItems : {},
23049
+ atoms = _ref.atoms,
23050
+ bonds = _ref.bonds;
23051
+ atoms === null || atoms === void 0 || atoms.forEach(function (dst, src) {
23052
+ if (_this3.struct.isAtomFromMacromolecule(src) || _this3.struct.isAtomFromMacromolecule(dst)) {
23053
+ isMergingSGroup = true;
23054
+ }
23055
+ });
23056
+ bonds === null || bonds === void 0 || bonds.forEach(function (dst, src) {
23057
+ if (_this3.struct.isBondFromMacromolecule(src) || _this3.struct.isBondFromMacromolecule(dst)) {
23058
+ isMergingSGroup = true;
23059
+ }
23060
+ });
23061
+ var action = dragCtx.action;
23062
+ if (!isMergingSGroup) {
23063
+ action = action ? ketcherCore.fromItemsFuse(this.reStruct, dragCtx.mergeItems).mergeWith(action) : ketcherCore.fromItemsFuse(this.reStruct, dragCtx.mergeItems);
23064
+ }
23046
23065
  delete this.dragCtx;
23047
23066
  this.editor.update(action);
23048
23067
  if (dragCtx.mergeItems) {
@@ -23157,18 +23176,18 @@ var RotateTool = function () {
23157
23176
  }, {
23158
23177
  key: "partitionNeighborsBySelection",
23159
23178
  value: function partitionNeighborsBySelection(selection, atom) {
23160
- var _this3 = this;
23179
+ var _this4 = this;
23161
23180
  var rotatableHalfBondIds = [];
23162
23181
  var rotatableHalfBondAngles = [];
23163
23182
  var fixedHalfBondIds = [];
23164
23183
  var fixedHalfBondAngles = [];
23165
23184
  atom.neighbors.forEach(function (halfBondId) {
23166
23185
  var _selection$atoms;
23167
- var halfBond = _this3.struct.halfBonds.get(halfBondId);
23186
+ var halfBond = _this4.struct.halfBonds.get(halfBondId);
23168
23187
  assert_1(halfBond != null);
23169
23188
  var neighborAtomId = halfBond.end;
23170
23189
  if (selection !== null && selection !== void 0 && (_selection$atoms = selection.atoms) !== null && _selection$atoms !== void 0 && _selection$atoms.includes(neighborAtomId)) {
23171
- if (!ketcherCore.FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this3.struct)) {
23190
+ if (!ketcherCore.FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this4.struct)) {
23172
23191
  rotatableHalfBondIds.push(halfBondId);
23173
23192
  rotatableHalfBondAngles.push(halfBond.ang);
23174
23193
  }
@@ -23187,7 +23206,7 @@ var RotateTool = function () {
23187
23206
  }, {
23188
23207
  key: "snap",
23189
23208
  value: function snap(mouseMoveAngle) {
23190
- var _this4 = this;
23209
+ var _this5 = this;
23191
23210
  var isSnapping = false;
23192
23211
  var rotateAngle = 0;
23193
23212
  if (!this.snapInfo) {
@@ -23197,18 +23216,18 @@ var RotateTool = function () {
23197
23216
  this.snapInfo.absoluteSnapAngles.some(function (snapAngle, index) {
23198
23217
  if (Math.abs(newRotatedHalfBondAngle - snapAngle) <= MAX_SNAP_DELTA) {
23199
23218
  isSnapping = true;
23200
- assert_1(_this4.snapInfo != null);
23201
- rotateAngle = snapAngle - _this4.snapInfo.rotatableHalfBondAngle;
23202
- _this4.saveSnappingBonds(snapAngle);
23203
- _this4.snapInfo.snapAngleDrawingProps = {
23219
+ assert_1(_this5.snapInfo != null);
23220
+ rotateAngle = snapAngle - _this5.snapInfo.rotatableHalfBondAngle;
23221
+ _this5.saveSnappingBonds(snapAngle);
23222
+ _this5.snapInfo.snapAngleDrawingProps = {
23204
23223
  isSnapping: isSnapping,
23205
23224
  absoluteAngle: snapAngle,
23206
23225
  relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
23207
23226
  };
23208
23227
  return true;
23209
23228
  } else if (Math.abs(newRotatedHalfBondAngle - snapAngle) < ANGLE_INDICATOR_VISIBLE_DELTA) {
23210
- assert_1(_this4.snapInfo != null);
23211
- _this4.snapInfo.snapAngleDrawingProps = {
23229
+ assert_1(_this5.snapInfo != null);
23230
+ _this5.snapInfo.snapAngleDrawingProps = {
23212
23231
  isSnapping: isSnapping,
23213
23232
  absoluteAngle: snapAngle,
23214
23233
  relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
@@ -23223,15 +23242,15 @@ var RotateTool = function () {
23223
23242
  key: "saveSnappingBonds",
23224
23243
  value: function saveSnappingBonds(snapAngle) {
23225
23244
  var _this$snapInfo2,
23226
- _this5 = this;
23245
+ _this6 = this;
23227
23246
  var halfBondsToBeHighlighted = (_this$snapInfo2 = this.snapInfo) === null || _this$snapInfo2 === void 0 ? void 0 : _this$snapInfo2.snapAngleToHalfBonds.get(snapAngle);
23228
23247
  var bondIds = halfBondsToBeHighlighted === null || halfBondsToBeHighlighted === void 0 ? void 0 : halfBondsToBeHighlighted.map(function (halfBond) {
23229
- var bondId = _this5.struct.getBondIdByHalfBond(halfBond);
23248
+ var bondId = _this6.struct.getBondIdByHalfBond(halfBond);
23230
23249
  assert_1(bondId != null);
23231
23250
  return bondId;
23232
23251
  });
23233
23252
  bondIds === null || bondIds === void 0 || bondIds.forEach(function (bondId) {
23234
- _this5.reStruct.addSnappingBonds(bondId);
23253
+ _this6.reStruct.addSnappingBonds(bondId);
23235
23254
  });
23236
23255
  }
23237
23256
  }]);
@@ -24599,10 +24618,14 @@ var Editor$3 = function () {
24599
24618
  key: "renderAndRecoordinateStruct",
24600
24619
  value: function renderAndRecoordinateStruct(struct) {
24601
24620
  var needToCenterStruct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
24621
+ var x = arguments.length > 2 ? arguments[2] : undefined;
24622
+ var y = arguments.length > 3 ? arguments[3] : undefined;
24602
24623
  var action = ketcherCore.fromNewCanvas(this.render.ctab, struct);
24603
24624
  this.update(action);
24604
24625
  if (needToCenterStruct) {
24605
24626
  this.centerStruct();
24627
+ } else if (x != null && y != null) {
24628
+ this.positionStruct(x, y);
24606
24629
  }
24607
24630
  return this.render.ctab.molecule;
24608
24631
  }
@@ -24610,22 +24633,33 @@ var Editor$3 = function () {
24610
24633
  key: "struct",
24611
24634
  value: function struct(value) {
24612
24635
  var needToCenterStruct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
24636
+ var x = arguments.length > 2 ? arguments[2] : undefined;
24637
+ var y = arguments.length > 3 ? arguments[3] : undefined;
24613
24638
  if (arguments.length === 0) {
24614
24639
  return this.render.ctab.molecule;
24615
24640
  }
24616
24641
  ketcherCore.KetcherLogger.log('Editor.struct(), start', value, needToCenterStruct);
24617
24642
  this.selection(null);
24618
24643
  var struct = value || new ketcherCore.Struct();
24619
- var molecule = this.renderAndRecoordinateStruct(struct, needToCenterStruct);
24644
+ var molecule = this.renderAndRecoordinateStruct(struct, needToCenterStruct, x, y);
24620
24645
  this.hoverIcon.create();
24621
24646
  ketcherCore.KetcherLogger.log('Editor.struct(), end');
24622
24647
  return molecule;
24623
24648
  }
24624
24649
  }, {
24625
24650
  key: "structToAddFragment",
24626
- value: function structToAddFragment(value) {
24627
- var superStruct = value.mergeInto(this.render.ctab.molecule.clone());
24628
- return this.renderAndRecoordinateStruct(superStruct);
24651
+ value: function structToAddFragment(value, x, y) {
24652
+ if (x != null && y != null) {
24653
+ var position = new ketcherCore.Vec2(x, y);
24654
+ var _fromPaste = ketcherCore.fromPaste(this.render.ctab, value, position, 0),
24655
+ _fromPaste2 = _slicedToArray__default["default"](_fromPaste, 1),
24656
+ action = _fromPaste2[0];
24657
+ this.update(action, true);
24658
+ return this.render.ctab.molecule;
24659
+ } else {
24660
+ var superStruct = value.mergeInto(this.render.ctab.molecule.clone());
24661
+ return this.renderAndRecoordinateStruct(superStruct);
24662
+ }
24629
24663
  }
24630
24664
  }, {
24631
24665
  key: "setOptions",
@@ -24695,6 +24729,17 @@ var Editor$3 = function () {
24695
24729
  var action = ketcherCore.fromMultipleMove(structure, structureToMove, shiftVector);
24696
24730
  this.update(action, true);
24697
24731
  }
24732
+ }, {
24733
+ key: "positionStruct",
24734
+ value: function positionStruct(x, y) {
24735
+ var structure = this.render.ctab;
24736
+ var structCenter = getStructCenter(structure);
24737
+ var viewBoxCenter = new ketcherCore.Vec2(this.render.viewBox.minX + x, this.render.viewBox.minY + y);
24738
+ var shiftVector = viewBoxCenter.sub(structCenter);
24739
+ var structureToMove = getSelectionMap(structure);
24740
+ var action = ketcherCore.fromMultipleMove(structure, structureToMove, shiftVector);
24741
+ this.update(action, true);
24742
+ }
24698
24743
  }, {
24699
24744
  key: "zoomAccordingContent",
24700
24745
  value: function zoomAccordingContent(struct) {
@@ -35065,8 +35110,8 @@ var KetcherBuilder = function () {
35065
35110
  cleanup = initApp(element, appRoot, staticResourcesUrl, {
35066
35111
  buttons: buttons || {},
35067
35112
  errorHandler: errorHandler || null,
35068
- version: "3.1.0-rc.5" ,
35069
- buildDate: "2025-02-20T17:53:33" ,
35113
+ version: "3.2.0-rc.1" ,
35114
+ buildDate: "2025-03-04T14:36:10" ,
35070
35115
  buildNumber: '',
35071
35116
  customButtons: customButtons || []
35072
35117
  }, structService, resolve, togglerComponent);
@@ -35358,7 +35403,7 @@ var ModeControl = function ModeControl(_ref3) {
35358
35403
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35359
35404
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
35360
35405
  var MacromoleculesEditor = React.lazy(function () {
35361
- return Promise.resolve().then(function () { return require('./index.modern-8730b9f1.js'); });
35406
+ return Promise.resolve().then(function () { return require('./index.modern-dc72bcd6.js'); });
35362
35407
  });
35363
35408
  var Editor = function Editor(props) {
35364
35409
  var _useState = React.useState(false),