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.
@@ -77,10 +77,10 @@ declare class Editor implements KetcherEditor {
77
77
  setOrigin(): void;
78
78
  tool(name?: any, opts?: any): Tool | null;
79
79
  clear(): void;
80
- renderAndRecoordinateStruct(struct: Struct, needToCenterStruct?: boolean): Struct;
80
+ renderAndRecoordinateStruct(struct: Struct, needToCenterStruct?: boolean, x?: number, y?: number): Struct;
81
81
  /** Apply {@link value}: {@link Struct} if provided to {@link render} and */
82
- struct(value?: Struct, needToCenterStruct?: boolean): Struct;
83
- structToAddFragment(value: Struct): Struct;
82
+ struct(value?: Struct, needToCenterStruct?: boolean, x?: number, y?: number): Struct;
83
+ structToAddFragment(value: Struct, x?: number, y?: number): Struct;
84
84
  setOptions(opts: string): false | import("ketcher-core").RenderOptions;
85
85
  /** Apply options from {@link value} */
86
86
  options(value?: any): import("ketcher-core").RenderOptions;
@@ -88,6 +88,7 @@ declare class Editor implements KetcherEditor {
88
88
  private updateToolAfterOptionsChange;
89
89
  zoom(value?: any, event?: WheelEvent): number;
90
90
  centerStruct(): void;
91
+ positionStruct(x: number, y: number): void;
91
92
  zoomAccordingContent(struct: Struct): void;
92
93
  selection(ci?: any): Selection | null;
93
94
  hover(ci: {
package/dist/index.js CHANGED
@@ -3743,7 +3743,7 @@ var zoom = {
3743
3743
 
3744
3744
  var openHelpLink = function openHelpLink() {
3745
3745
  var _window$open;
3746
- 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();
3746
+ 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();
3747
3747
  };
3748
3748
  var help = {
3749
3749
  help: {
@@ -22971,13 +22971,32 @@ var RotateTool = function () {
22971
22971
  key: "mouseup",
22972
22972
  value:
22973
22973
  function mouseup() {
22974
+ var _dragCtx$mergeItems,
22975
+ _this3 = this;
22974
22976
  if (!this.dragCtx) {
22975
22977
  return true;
22976
22978
  }
22977
22979
  this.reStruct.clearSnappingBonds();
22978
22980
  this.editor.update(true);
22979
22981
  var dragCtx = this.dragCtx;
22980
- var action = dragCtx.action ? fromItemsFuse(this.reStruct, dragCtx.mergeItems).mergeWith(dragCtx.action) : fromItemsFuse(this.reStruct, dragCtx.mergeItems);
22982
+ var isMergingSGroup = false;
22983
+ var _ref = (_dragCtx$mergeItems = dragCtx.mergeItems) !== null && _dragCtx$mergeItems !== void 0 ? _dragCtx$mergeItems : {},
22984
+ atoms = _ref.atoms,
22985
+ bonds = _ref.bonds;
22986
+ atoms === null || atoms === void 0 || atoms.forEach(function (dst, src) {
22987
+ if (_this3.struct.isAtomFromMacromolecule(src) || _this3.struct.isAtomFromMacromolecule(dst)) {
22988
+ isMergingSGroup = true;
22989
+ }
22990
+ });
22991
+ bonds === null || bonds === void 0 || bonds.forEach(function (dst, src) {
22992
+ if (_this3.struct.isBondFromMacromolecule(src) || _this3.struct.isBondFromMacromolecule(dst)) {
22993
+ isMergingSGroup = true;
22994
+ }
22995
+ });
22996
+ var action = dragCtx.action;
22997
+ if (!isMergingSGroup) {
22998
+ action = action ? fromItemsFuse(this.reStruct, dragCtx.mergeItems).mergeWith(action) : fromItemsFuse(this.reStruct, dragCtx.mergeItems);
22999
+ }
22981
23000
  delete this.dragCtx;
22982
23001
  this.editor.update(action);
22983
23002
  if (dragCtx.mergeItems) {
@@ -23092,18 +23111,18 @@ var RotateTool = function () {
23092
23111
  }, {
23093
23112
  key: "partitionNeighborsBySelection",
23094
23113
  value: function partitionNeighborsBySelection(selection, atom) {
23095
- var _this3 = this;
23114
+ var _this4 = this;
23096
23115
  var rotatableHalfBondIds = [];
23097
23116
  var rotatableHalfBondAngles = [];
23098
23117
  var fixedHalfBondIds = [];
23099
23118
  var fixedHalfBondAngles = [];
23100
23119
  atom.neighbors.forEach(function (halfBondId) {
23101
23120
  var _selection$atoms;
23102
- var halfBond = _this3.struct.halfBonds.get(halfBondId);
23121
+ var halfBond = _this4.struct.halfBonds.get(halfBondId);
23103
23122
  assert_1(halfBond != null);
23104
23123
  var neighborAtomId = halfBond.end;
23105
23124
  if (selection !== null && selection !== void 0 && (_selection$atoms = selection.atoms) !== null && _selection$atoms !== void 0 && _selection$atoms.includes(neighborAtomId)) {
23106
- if (!FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this3.struct)) {
23125
+ if (!FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this4.struct)) {
23107
23126
  rotatableHalfBondIds.push(halfBondId);
23108
23127
  rotatableHalfBondAngles.push(halfBond.ang);
23109
23128
  }
@@ -23122,7 +23141,7 @@ var RotateTool = function () {
23122
23141
  }, {
23123
23142
  key: "snap",
23124
23143
  value: function snap(mouseMoveAngle) {
23125
- var _this4 = this;
23144
+ var _this5 = this;
23126
23145
  var isSnapping = false;
23127
23146
  var rotateAngle = 0;
23128
23147
  if (!this.snapInfo) {
@@ -23132,18 +23151,18 @@ var RotateTool = function () {
23132
23151
  this.snapInfo.absoluteSnapAngles.some(function (snapAngle, index) {
23133
23152
  if (Math.abs(newRotatedHalfBondAngle - snapAngle) <= MAX_SNAP_DELTA) {
23134
23153
  isSnapping = true;
23135
- assert_1(_this4.snapInfo != null);
23136
- rotateAngle = snapAngle - _this4.snapInfo.rotatableHalfBondAngle;
23137
- _this4.saveSnappingBonds(snapAngle);
23138
- _this4.snapInfo.snapAngleDrawingProps = {
23154
+ assert_1(_this5.snapInfo != null);
23155
+ rotateAngle = snapAngle - _this5.snapInfo.rotatableHalfBondAngle;
23156
+ _this5.saveSnappingBonds(snapAngle);
23157
+ _this5.snapInfo.snapAngleDrawingProps = {
23139
23158
  isSnapping: isSnapping,
23140
23159
  absoluteAngle: snapAngle,
23141
23160
  relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
23142
23161
  };
23143
23162
  return true;
23144
23163
  } else if (Math.abs(newRotatedHalfBondAngle - snapAngle) < ANGLE_INDICATOR_VISIBLE_DELTA) {
23145
- assert_1(_this4.snapInfo != null);
23146
- _this4.snapInfo.snapAngleDrawingProps = {
23164
+ assert_1(_this5.snapInfo != null);
23165
+ _this5.snapInfo.snapAngleDrawingProps = {
23147
23166
  isSnapping: isSnapping,
23148
23167
  absoluteAngle: snapAngle,
23149
23168
  relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
@@ -23158,15 +23177,15 @@ var RotateTool = function () {
23158
23177
  key: "saveSnappingBonds",
23159
23178
  value: function saveSnappingBonds(snapAngle) {
23160
23179
  var _this$snapInfo2,
23161
- _this5 = this;
23180
+ _this6 = this;
23162
23181
  var halfBondsToBeHighlighted = (_this$snapInfo2 = this.snapInfo) === null || _this$snapInfo2 === void 0 ? void 0 : _this$snapInfo2.snapAngleToHalfBonds.get(snapAngle);
23163
23182
  var bondIds = halfBondsToBeHighlighted === null || halfBondsToBeHighlighted === void 0 ? void 0 : halfBondsToBeHighlighted.map(function (halfBond) {
23164
- var bondId = _this5.struct.getBondIdByHalfBond(halfBond);
23183
+ var bondId = _this6.struct.getBondIdByHalfBond(halfBond);
23165
23184
  assert_1(bondId != null);
23166
23185
  return bondId;
23167
23186
  });
23168
23187
  bondIds === null || bondIds === void 0 || bondIds.forEach(function (bondId) {
23169
- _this5.reStruct.addSnappingBonds(bondId);
23188
+ _this6.reStruct.addSnappingBonds(bondId);
23170
23189
  });
23171
23190
  }
23172
23191
  }]);
@@ -24534,10 +24553,14 @@ var Editor$3 = function () {
24534
24553
  key: "renderAndRecoordinateStruct",
24535
24554
  value: function renderAndRecoordinateStruct(struct) {
24536
24555
  var needToCenterStruct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
24556
+ var x = arguments.length > 2 ? arguments[2] : undefined;
24557
+ var y = arguments.length > 3 ? arguments[3] : undefined;
24537
24558
  var action = fromNewCanvas(this.render.ctab, struct);
24538
24559
  this.update(action);
24539
24560
  if (needToCenterStruct) {
24540
24561
  this.centerStruct();
24562
+ } else if (x != null && y != null) {
24563
+ this.positionStruct(x, y);
24541
24564
  }
24542
24565
  return this.render.ctab.molecule;
24543
24566
  }
@@ -24545,22 +24568,33 @@ var Editor$3 = function () {
24545
24568
  key: "struct",
24546
24569
  value: function struct(value) {
24547
24570
  var needToCenterStruct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
24571
+ var x = arguments.length > 2 ? arguments[2] : undefined;
24572
+ var y = arguments.length > 3 ? arguments[3] : undefined;
24548
24573
  if (arguments.length === 0) {
24549
24574
  return this.render.ctab.molecule;
24550
24575
  }
24551
24576
  KetcherLogger.log('Editor.struct(), start', value, needToCenterStruct);
24552
24577
  this.selection(null);
24553
24578
  var struct = value || new Struct();
24554
- var molecule = this.renderAndRecoordinateStruct(struct, needToCenterStruct);
24579
+ var molecule = this.renderAndRecoordinateStruct(struct, needToCenterStruct, x, y);
24555
24580
  this.hoverIcon.create();
24556
24581
  KetcherLogger.log('Editor.struct(), end');
24557
24582
  return molecule;
24558
24583
  }
24559
24584
  }, {
24560
24585
  key: "structToAddFragment",
24561
- value: function structToAddFragment(value) {
24562
- var superStruct = value.mergeInto(this.render.ctab.molecule.clone());
24563
- return this.renderAndRecoordinateStruct(superStruct);
24586
+ value: function structToAddFragment(value, x, y) {
24587
+ if (x != null && y != null) {
24588
+ var position = new Vec2(x, y);
24589
+ var _fromPaste = fromPaste(this.render.ctab, value, position, 0),
24590
+ _fromPaste2 = _slicedToArray$1(_fromPaste, 1),
24591
+ action = _fromPaste2[0];
24592
+ this.update(action, true);
24593
+ return this.render.ctab.molecule;
24594
+ } else {
24595
+ var superStruct = value.mergeInto(this.render.ctab.molecule.clone());
24596
+ return this.renderAndRecoordinateStruct(superStruct);
24597
+ }
24564
24598
  }
24565
24599
  }, {
24566
24600
  key: "setOptions",
@@ -24630,6 +24664,17 @@ var Editor$3 = function () {
24630
24664
  var action = fromMultipleMove(structure, structureToMove, shiftVector);
24631
24665
  this.update(action, true);
24632
24666
  }
24667
+ }, {
24668
+ key: "positionStruct",
24669
+ value: function positionStruct(x, y) {
24670
+ var structure = this.render.ctab;
24671
+ var structCenter = getStructCenter(structure);
24672
+ var viewBoxCenter = new Vec2(this.render.viewBox.minX + x, this.render.viewBox.minY + y);
24673
+ var shiftVector = viewBoxCenter.sub(structCenter);
24674
+ var structureToMove = getSelectionMap(structure);
24675
+ var action = fromMultipleMove(structure, structureToMove, shiftVector);
24676
+ this.update(action, true);
24677
+ }
24633
24678
  }, {
24634
24679
  key: "zoomAccordingContent",
24635
24680
  value: function zoomAccordingContent(struct) {
@@ -35000,8 +35045,8 @@ var KetcherBuilder = function () {
35000
35045
  cleanup = initApp(element, appRoot, staticResourcesUrl, {
35001
35046
  buttons: buttons || {},
35002
35047
  errorHandler: errorHandler || null,
35003
- version: "3.1.0-rc.5" ,
35004
- buildDate: "2025-02-20T17:53:33" ,
35048
+ version: "3.2.0-rc.1" ,
35049
+ buildDate: "2025-03-04T14:36:10" ,
35005
35050
  buildNumber: '',
35006
35051
  customButtons: customButtons || []
35007
35052
  }, structService, resolve, togglerComponent);
@@ -35293,7 +35338,7 @@ var ModeControl = function ModeControl(_ref3) {
35293
35338
  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; }
35294
35339
  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$1(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; }
35295
35340
  var MacromoleculesEditor = lazy(function () {
35296
- return import('./index.modern-f8e2203d.js');
35341
+ return import('./index.modern-17b0bd64.js');
35297
35342
  });
35298
35343
  var Editor = function Editor(props) {
35299
35344
  var _useState = useState(false),