ketcher-react 2.26.0-rc.5 → 2.26.0-rc.7

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.
@@ -3733,7 +3733,7 @@ var zoom = {
3733
3733
 
3734
3734
  var openHelpLink = function openHelpLink() {
3735
3735
  var _window$open;
3736
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.26.0-rc.5\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3736
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.26.0-rc.7\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3737
3737
  };
3738
3738
  var help = {
3739
3739
  help: {
@@ -16150,22 +16150,34 @@ function getElementsInRectangle(restruct, p0, p1) {
16150
16150
  var bottomLeftPosition = new Vec2(x0, y1);
16151
16151
  var polygon = [topLeftPosition, topRightPosition, bottomRightPosition, bottomLeftPosition];
16152
16152
  restruct.bonds.forEach(function (bond, bid) {
16153
- if (struct.isBondFromMacromolecule(bid)) {
16153
+ if (FunctionalGroup.isBondInContractedFunctionalGroup(bond.b, sGroups, functionalGroups)) {
16154
16154
  return;
16155
16155
  }
16156
- var centre = Vec2.lc2(
16157
- restruct.atoms.get(bond.b.begin).a.pp, 0.5,
16158
- restruct.atoms.get(bond.b.end).a.pp, 0.5);
16159
- if (centre.x > x0 && centre.x < x1 && centre.y > y0 && centre.y < y1 && !FunctionalGroup.isBondInContractedFunctionalGroup(bond.b, sGroups, functionalGroups)) {
16156
+ var center;
16157
+ if (bond.b.isExternalBondBetweenMonomers(struct)) {
16158
+ var firstMonomer = struct.getGroupFromAtomId(bond.b.begin);
16159
+ var secondMonomer = struct.getGroupFromAtomId(bond.b.end);
16160
+ assert_1(firstMonomer);
16161
+ assert_1(secondMonomer);
16162
+ center = firstMonomer.pp && secondMonomer.pp ? Vec2.centre(firstMonomer.pp, secondMonomer.pp) : bond.b.center;
16163
+ } else {
16164
+ center = bond.b.center;
16165
+ }
16166
+ if (center.x > x0 && center.x < x1 && center.y > y0 && center.y < y1) {
16160
16167
  bondList.push(bid);
16161
16168
  }
16162
16169
  });
16163
16170
  restruct.atoms.forEach(function (atom, aid) {
16164
16171
  var relatedFGId = FunctionalGroup.findFunctionalGroupByAtom(functionalGroups, aid);
16165
- var reSGroup = restruct.sgroups.get(relatedFGId);
16166
- if (atom.a.pp.x > x0 && atom.a.pp.x < x1 && atom.a.pp.y > y0 && atom.a.pp.y < y1 && (!FunctionalGroup.isAtomInContractedFunctionalGroup(atom.a, sGroups, functionalGroups, true) ||
16167
- aid === reSGroup.item.atoms[0])) {
16168
- atomList.push(aid);
16172
+ var sGroup = struct.sgroups.get(relatedFGId);
16173
+ if (struct.isAtomFromMacromolecule(aid)) {
16174
+ if (sGroup && sGroup.pp && sGroup.pp.x > x0 && sGroup.pp.x < x1 && sGroup.pp.y > y0 && sGroup.pp.y < y1) {
16175
+ atomList.push(aid);
16176
+ }
16177
+ } else {
16178
+ if (atom.a.pp.x > x0 && atom.a.pp.x < x1 && atom.a.pp.y > y0 && atom.a.pp.y < y1 && (!FunctionalGroup.isAtomInContractedFunctionalGroup(atom.a, sGroups, functionalGroups, true) || aid === (sGroup === null || sGroup === void 0 ? void 0 : sGroup.atoms[0]))) {
16179
+ atomList.push(aid);
16180
+ }
16169
16181
  }
16170
16182
  });
16171
16183
  var rxnArrowsList = [];
@@ -16260,22 +16272,34 @@ function getElementsInPolygon(restruct, rr) {
16260
16272
  r[i] = new Vec2(rr[i].x, rr[i].y);
16261
16273
  }
16262
16274
  restruct.bonds.forEach(function (bond, bid) {
16263
- if (struct.isAtomFromMacromolecule(bond.b.begin) || struct.isAtomFromMacromolecule(bond.b.end)) {
16275
+ if (FunctionalGroup.isBondInContractedFunctionalGroup(bond.b, sGroups, functionalGroups)) {
16264
16276
  return;
16265
16277
  }
16266
- var centre = Vec2.lc2(
16267
- restruct.atoms.get(bond.b.begin).a.pp, 0.5,
16268
- restruct.atoms.get(bond.b.end).a.pp, 0.5);
16269
- if (isPointInPolygon(r, centre) && !FunctionalGroup.isBondInContractedFunctionalGroup(bond.b, sGroups, functionalGroups)) {
16278
+ var center;
16279
+ if (bond.b.isExternalBondBetweenMonomers(struct)) {
16280
+ var firstMonomer = struct.getGroupFromAtomId(bond.b.begin);
16281
+ var secondMonomer = struct.getGroupFromAtomId(bond.b.end);
16282
+ assert_1(firstMonomer);
16283
+ assert_1(secondMonomer);
16284
+ center = firstMonomer !== null && firstMonomer !== void 0 && firstMonomer.pp && secondMonomer !== null && secondMonomer !== void 0 && secondMonomer.pp ? Vec2.centre(firstMonomer.pp, secondMonomer.pp) : bond.b.center;
16285
+ } else {
16286
+ center = bond.b.center;
16287
+ }
16288
+ if (isPointInPolygon(r, center)) {
16270
16289
  bondList.push(bid);
16271
16290
  }
16272
16291
  });
16273
16292
  restruct.atoms.forEach(function (atom, aid) {
16274
16293
  var relatedFGId = FunctionalGroup.findFunctionalGroupByAtom(functionalGroups, aid);
16275
- var reSGroup = restruct.sgroups.get(relatedFGId);
16276
- if (isPointInPolygon(r, atom.a.pp) && (!FunctionalGroup.isAtomInContractedFunctionalGroup(atom.a, sGroups, functionalGroups, true) ||
16277
- aid === reSGroup.item.atoms[0])) {
16278
- atomList.push(aid);
16294
+ var sGroup = struct.sgroups.get(relatedFGId);
16295
+ if (struct.isAtomFromMacromolecule(aid)) {
16296
+ if (sGroup && sGroup.pp && isPointInPolygon(r, sGroup.pp)) {
16297
+ atomList.push(aid);
16298
+ }
16299
+ } else {
16300
+ if (isPointInPolygon(r, atom.a.pp) && (!FunctionalGroup.isAtomInContractedFunctionalGroup(atom.a, sGroups, functionalGroups, true) || aid === (sGroup === null || sGroup === void 0 ? void 0 : sGroup.atoms[0]))) {
16301
+ atomList.push(aid);
16302
+ }
16279
16303
  }
16280
16304
  });
16281
16305
  var rxnArrowsList = [];
@@ -23299,6 +23323,7 @@ var supportedMimesForRegex = supportedMimes.map(function (item) {
23299
23323
  }).join('|');
23300
23324
  var allowList = new RegExp("^image/(".concat(supportedMimesForRegex, ")$"));
23301
23325
  var MIN_DIMENSION_SIZE = 16;
23326
+ var MIN_SIZELESS_IMAGE_SRC_LENGTH = 320;
23302
23327
  var ImageTool = function () {
23303
23328
  function ImageTool(editor) {
23304
23329
  _classCallCheck$2(this, ImageTool);
@@ -23383,7 +23408,9 @@ var ImageTool = function () {
23383
23408
  });
23384
23409
  image.onload = function () {
23385
23410
  _this.resetElementValue();
23386
- if (image.width < MIN_DIMENSION_SIZE || image.height < MIN_DIMENSION_SIZE) {
23411
+ var isValidSize = image.width >= MIN_DIMENSION_SIZE && image.height >= MIN_DIMENSION_SIZE;
23412
+ var isValidSizeless = image.width === 0 && image.height === 0 && image.src.length >= MIN_SIZELESS_IMAGE_SRC_LENGTH;
23413
+ if (!isValidSize && !isValidSizeless) {
23387
23414
  var _errorMessage = 'Image should be at least 16x16 pixels';
23388
23415
  KetcherLogger.error("".concat(TAG, ":onLoad"), _errorMessage);
23389
23416
  if (errorHandler) {
@@ -23391,8 +23418,9 @@ var ImageTool = function () {
23391
23418
  }
23392
23419
  return;
23393
23420
  }
23394
- var halfSize = Scale.canvasToModel(new Vec2(image.width / 2, image.height / 2), _this.editor.render.options);
23395
- _this.editor.update(fromImageCreation(_this.editor.render.ctab, image.src, clickPosition, halfSize));
23421
+ var halfSize = isValidSizeless ? new Vec2(MIN_DIMENSION_SIZE, MIN_DIMENSION_SIZE) : new Vec2(image.width / 2, image.height / 2);
23422
+ var halfSizeScaled = Scale.canvasToModel(halfSize, _this.editor.render.options);
23423
+ _this.editor.update(fromImageCreation(_this.editor.render.ctab, image.src, clickPosition, halfSizeScaled));
23396
23424
  };
23397
23425
  image.onerror = function (e) {
23398
23426
  _this.resetElementValue();
@@ -24577,21 +24605,13 @@ var Editor$3 = function () {
24577
24605
  if (arguments.length === 0) {
24578
24606
  return this._selection;
24579
24607
  }
24580
- var struct = this.struct();
24581
24608
  var ReStruct = this.render.ctab;
24582
24609
  var selectAll = false;
24583
24610
  this._selection = null;
24584
24611
  if (ci === 'all') {
24585
24612
  selectAll = true;
24586
24613
  ci = structObjects.reduce(function (res, key) {
24587
- var restructItemsIds = Array.from(ReStruct[key].keys());
24588
- restructItemsIds = restructItemsIds.filter(function (restructItemId) {
24589
- return !struct.isTargetFromMacromolecule({
24590
- map: key,
24591
- id: restructItemId
24592
- });
24593
- });
24594
- res[key] = restructItemsIds;
24614
+ res[key] = Array.from(ReStruct[key].keys());
24595
24615
  return res;
24596
24616
  }, {});
24597
24617
  }
@@ -26405,24 +26425,46 @@ function getMenuPropsForClosestItem(editor, closestItem) {
26405
26425
  case 'bonds':
26406
26426
  {
26407
26427
  var functionalGroup = FunctionalGroup.findFunctionalGroupByBond(struct, struct.functionalGroups, closestItem.id, true);
26408
- return functionalGroup === null || functionalGroup !== null && functionalGroup !== void 0 && functionalGroup.relatedSGroup.isSuperatomWithoutLabel ? {
26409
- id: CONTEXT_MENU_ID.FOR_BONDS,
26410
- bondIds: [closestItem.id]
26411
- } : {
26412
- id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
26413
- functionalGroups: [functionalGroup]
26414
- };
26428
+ var noFunctionalGroup = functionalGroup === null || (functionalGroup === null || functionalGroup === void 0 ? void 0 : functionalGroup.relatedSGroup.isSuperatomWithoutLabel);
26429
+ var isMonomer = (functionalGroup === null || functionalGroup === void 0 ? void 0 : functionalGroup.relatedSGroup) instanceof MonomerMicromolecule;
26430
+ if (noFunctionalGroup) {
26431
+ return {
26432
+ id: CONTEXT_MENU_ID.FOR_BONDS,
26433
+ bondIds: [closestItem.id]
26434
+ };
26435
+ } else if (isMonomer) {
26436
+ return {
26437
+ id: CONTEXT_MENU_ID.FOR_MACROMOLECULE,
26438
+ functionalGroups: [functionalGroup]
26439
+ };
26440
+ } else {
26441
+ return {
26442
+ id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
26443
+ functionalGroups: [functionalGroup]
26444
+ };
26445
+ }
26415
26446
  }
26416
26447
  case 'atoms':
26417
26448
  {
26418
26449
  var _functionalGroup = FunctionalGroup.findFunctionalGroupByAtom(struct.functionalGroups, closestItem.id, true);
26419
- return _functionalGroup === null || _functionalGroup !== null && _functionalGroup !== void 0 && _functionalGroup.relatedSGroup.isSuperatomWithoutLabel ? {
26420
- id: CONTEXT_MENU_ID.FOR_ATOMS,
26421
- atomIds: [closestItem.id]
26422
- } : {
26423
- id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
26424
- functionalGroups: [_functionalGroup]
26425
- };
26450
+ var _noFunctionalGroup = _functionalGroup === null || (_functionalGroup === null || _functionalGroup === void 0 ? void 0 : _functionalGroup.relatedSGroup.isSuperatomWithoutLabel);
26451
+ var _isMonomer = (_functionalGroup === null || _functionalGroup === void 0 ? void 0 : _functionalGroup.relatedSGroup) instanceof MonomerMicromolecule;
26452
+ if (_noFunctionalGroup) {
26453
+ return {
26454
+ id: CONTEXT_MENU_ID.FOR_ATOMS,
26455
+ atomIds: [closestItem.id]
26456
+ };
26457
+ } else if (_isMonomer) {
26458
+ return {
26459
+ id: CONTEXT_MENU_ID.FOR_MACROMOLECULE,
26460
+ functionalGroups: [_functionalGroup]
26461
+ };
26462
+ } else {
26463
+ return {
26464
+ id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
26465
+ functionalGroups: [_functionalGroup]
26466
+ };
26467
+ }
26426
26468
  }
26427
26469
  case 'sgroups':
26428
26470
  case 'functionalGroups':
@@ -34780,8 +34822,8 @@ var KetcherBuilder = function () {
34780
34822
  cleanup = initApp(element, appRoot, staticResourcesUrl, {
34781
34823
  buttons: buttons || {},
34782
34824
  errorHandler: errorHandler || null,
34783
- version: "2.26.0-rc.5" ,
34784
- buildDate: "2024-10-21T15:20:30" ,
34825
+ version: "2.26.0-rc.7" ,
34826
+ buildDate: "2024-11-04T09:39:10" ,
34785
34827
  buildNumber: '',
34786
34828
  customButtons: customButtons || []
34787
34829
  }, structService, resolve, togglerComponent);