roosterjs 9.11.0 → 9.11.2

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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 9.11.0)
1
+ // Type definitions for roosterjs (Version 9.11.2)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -9276,7 +9276,10 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
9276
9276
  private mouseDownHandler;
9277
9277
  private onDropHandler;
9278
9278
  private keyDownHandler;
9279
- private applyFormatWithContentModel;
9279
+ /**
9280
+ * EXPOSED FOR TESTING PURPOSE ONLY
9281
+ */
9282
+ protected applyFormatWithContentModel(editor: IEditor, isCropMode: boolean, shouldSelectImage: boolean, isApiOperation?: boolean): void;
9280
9283
  private startEditing;
9281
9284
  startRotateAndResize(editor: IEditor, image: HTMLImageElement): void;
9282
9285
  private updateRotateHandleState;
@@ -9285,7 +9288,10 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
9285
9288
  private startCropMode;
9286
9289
  cropImage(): void;
9287
9290
  private editImage;
9288
- private cleanInfo;
9291
+ /**
9292
+ * Exported for testing purpose only
9293
+ */
9294
+ cleanInfo(): void;
9289
9295
  private removeImageWrapper;
9290
9296
  flipImage(direction: 'horizontal' | 'vertical'): void;
9291
9297
  rotateImage(angleRad: number): void;
@@ -10396,8 +10396,8 @@ var DomIndexerImpl = /** @class */ (function () {
10396
10396
  };
10397
10397
  DomIndexerImpl.prototype.reconcileTextSelection = function (textNode, startOffset, endOffset) {
10398
10398
  var _a;
10399
- var _b;
10400
- var _c = textNode.__roosterjsContentModel, paragraph = _c.paragraph, segments = _c.segments;
10399
+ var _b, _c;
10400
+ var _d = textNode.__roosterjsContentModel, paragraph = _d.paragraph, segments = _d.segments;
10401
10401
  var first = segments[0];
10402
10402
  var last = segments[segments.length - 1];
10403
10403
  var selectable;
@@ -10419,6 +10419,14 @@ var DomIndexerImpl = /** @class */ (function () {
10419
10419
  if (endOffset === undefined) {
10420
10420
  var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(first.format);
10421
10421
  newSegments.push(marker);
10422
+ if (startOffset < ((_b = textNode.nodeValue) !== null && _b !== void 0 ? _b : '').length) {
10423
+ if (first.link) {
10424
+ (0, roosterjs_content_model_dom_1.addLink)(marker, first.link);
10425
+ }
10426
+ if (first.code) {
10427
+ (0, roosterjs_content_model_dom_1.addCode)(marker, first.code);
10428
+ }
10429
+ }
10422
10430
  selectable = marker;
10423
10431
  endOffset = startOffset;
10424
10432
  }
@@ -10460,7 +10468,7 @@ var DomIndexerImpl = /** @class */ (function () {
10460
10468
  var isBefore = wrapper.previousSibling == delimiter;
10461
10469
  var isAfter = wrapper.nextSibling == delimiter;
10462
10470
  if (index >= 0 && delimiter && (0, roosterjs_content_model_dom_1.isEntityDelimiter)(delimiter) && (isBefore || isAfter)) {
10463
- var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(((_b = paragraph.segments[isAfter ? index + 1 : index - 1]) !== null && _b !== void 0 ? _b : first).format);
10471
+ var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(((_c = paragraph.segments[isAfter ? index + 1 : index - 1]) !== null && _c !== void 0 ? _c : first).format);
10464
10472
  paragraph.segments.splice(isAfter ? index + 1 : index, 0, marker);
10465
10473
  selectable = marker;
10466
10474
  }
@@ -10878,6 +10886,7 @@ var deleteEmptyList_1 = __webpack_require__(/*! ./utils/deleteEmptyList */ "./pa
10878
10886
  var pasteCopyBlockEntityParser_1 = __webpack_require__(/*! ../../override/pasteCopyBlockEntityParser */ "./packages/roosterjs-content-model-core/lib/override/pasteCopyBlockEntityParser.ts");
10879
10887
  var paste_1 = __webpack_require__(/*! ../../command/paste/paste */ "./packages/roosterjs-content-model-core/lib/command/paste/paste.ts");
10880
10888
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
10889
+ var TEMP_DIV_ID = 'roosterJS_copyCutTempDiv';
10881
10890
  /**
10882
10891
  * Copy and paste plugin for handling onCopy and onPaste event
10883
10892
  */
@@ -11041,6 +11050,7 @@ var CopyPastePlugin = /** @class */ (function () {
11041
11050
  div.style.color = 'black';
11042
11051
  div.childNodes.forEach(function (node) { return div.removeChild(node); });
11043
11052
  div.style.display = '';
11053
+ div.id = TEMP_DIV_ID;
11044
11054
  div.focus();
11045
11055
  return div;
11046
11056
  };
@@ -20977,8 +20987,6 @@ function isSegmentEmpty(segment) {
20977
20987
  switch (segment.segmentType) {
20978
20988
  case 'Text':
20979
20989
  return !segment.text;
20980
- case 'Image':
20981
- return !segment.src;
20982
20990
  default:
20983
20991
  return false;
20984
20992
  }
@@ -21192,6 +21200,7 @@ function normalizeParagraph(paragraph) {
21192
21200
  (0, mutate_1.mutateBlock)(paragraph).segments.pop();
21193
21201
  }
21194
21202
  }
21203
+ normalizeParagraphStyle(paragraph);
21195
21204
  }
21196
21205
  if (!(0, isWhiteSpacePreserved_1.isWhiteSpacePreserved)(paragraph.format.whiteSpace)) {
21197
21206
  (0, normalizeSegment_1.normalizeAllSegments)(paragraph);
@@ -21201,6 +21210,13 @@ function normalizeParagraph(paragraph) {
21201
21210
  moveUpSegmentFormat(paragraph);
21202
21211
  }
21203
21212
  exports.normalizeParagraph = normalizeParagraph;
21213
+ function normalizeParagraphStyle(paragraph) {
21214
+ // New paragraph should not have white-space style
21215
+ if (paragraph.format.whiteSpace &&
21216
+ paragraph.segments.every(function (seg) { return seg.segmentType == 'Br' || seg.segmentType == 'SelectionMarker'; })) {
21217
+ delete (0, mutate_1.mutateBlock)(paragraph).format.whiteSpace;
21218
+ }
21219
+ }
21204
21220
  function removeEmptySegments(block) {
21205
21221
  for (var j = block.segments.length - 1; j >= 0; j--) {
21206
21222
  if ((0, isEmpty_1.isSegmentEmpty)(block.segments[j])) {
@@ -29621,14 +29637,22 @@ var ImageEditPlugin = /** @class */ (function () {
29621
29637
  };
29622
29638
  ImageEditPlugin.prototype.keyDownHandler = function (editor, event) {
29623
29639
  if (this.isEditing) {
29624
- if (event.rawEvent.key === 'Escape') {
29625
- this.removeImageWrapper();
29640
+ if (event.rawEvent.key === 'Escape' ||
29641
+ event.rawEvent.key === 'Delete' ||
29642
+ event.rawEvent.key === 'Backspace') {
29643
+ if (event.rawEvent.key === 'Escape') {
29644
+ this.removeImageWrapper();
29645
+ }
29646
+ this.cleanInfo();
29626
29647
  }
29627
29648
  else {
29628
29649
  this.applyFormatWithContentModel(editor, this.isCropMode, true /** should selectImage */, false /* isApiOperation */);
29629
29650
  }
29630
29651
  }
29631
29652
  };
29653
+ /**
29654
+ * EXPOSED FOR TESTING PURPOSE ONLY
29655
+ */
29632
29656
  ImageEditPlugin.prototype.applyFormatWithContentModel = function (editor, isCropMode, shouldSelectImage, isApiOperation) {
29633
29657
  var _this = this;
29634
29658
  var editingImageModel;
@@ -29655,6 +29679,15 @@ var ImageEditPlugin = /** @class */ (function () {
29655
29679
  image.isSelected = shouldSelectImage;
29656
29680
  image.isSelectedAsImageSelection = shouldSelectImage;
29657
29681
  delete image.dataset.isEditing;
29682
+ if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range' && !selection.range.collapsed) {
29683
+ var selectedParagraphs = (0, roosterjs_content_model_dom_1.getSelectedParagraphs)(model, true);
29684
+ var isImageInRange = selectedParagraphs.some(function (paragraph) {
29685
+ return paragraph.segments.includes(image);
29686
+ });
29687
+ if (isImageInRange) {
29688
+ image.isSelected = true;
29689
+ }
29690
+ }
29658
29691
  });
29659
29692
  if (shouldSelectImage) {
29660
29693
  (0, normalizeImageSelection_1.normalizeImageSelection)(previousSelectedImage);
@@ -29726,6 +29759,7 @@ var ImageEditPlugin = /** @class */ (function () {
29726
29759
  if (this.imageEditInfo) {
29727
29760
  this.startEditing(editor, image, ['resize', 'rotate']);
29728
29761
  if (this.selectedImage && this.imageEditInfo && this.wrapper && this.clonedImage) {
29762
+ var isMobileOrTable = !!editor.getEnvironment().isMobileOrTablet;
29729
29763
  this.dndHelpers = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.ResizeHandle, resizerContext_1.Resizer, function () {
29730
29764
  if (_this.imageEditInfo &&
29731
29765
  _this.selectedImage &&
@@ -29734,7 +29768,7 @@ var ImageEditPlugin = /** @class */ (function () {
29734
29768
  (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, _this.resizers);
29735
29769
  _this.wasImageResized = true;
29736
29770
  }
29737
- }, this.zoomScale)), false), (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.RotateHandle, rotatorContext_1.Rotator, function () {
29771
+ }, this.zoomScale, isMobileOrTable)), false), (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.RotateHandle, rotatorContext_1.Rotator, function () {
29738
29772
  var _a;
29739
29773
  if (_this.imageEditInfo &&
29740
29774
  _this.selectedImage &&
@@ -29743,7 +29777,7 @@ var ImageEditPlugin = /** @class */ (function () {
29743
29777
  (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper);
29744
29778
  _this.updateRotateHandleState(editor, _this.selectedImage, _this.wrapper, _this.rotators, (_a = _this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad);
29745
29779
  }
29746
- }, this.zoomScale)), false);
29780
+ }, this.zoomScale, isMobileOrTable)), false);
29747
29781
  (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, this.resizers);
29748
29782
  this.updateRotateHandleState(editor, this.selectedImage, this.wrapper, this.rotators, (_a = this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad);
29749
29783
  }
@@ -29783,7 +29817,7 @@ var ImageEditPlugin = /** @class */ (function () {
29783
29817
  (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined, _this.croppers);
29784
29818
  _this.isCropMode = true;
29785
29819
  }
29786
- }, this.zoomScale)), false);
29820
+ }, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet)), false);
29787
29821
  (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined, this.croppers);
29788
29822
  }
29789
29823
  }
@@ -29809,6 +29843,9 @@ var ImageEditPlugin = /** @class */ (function () {
29809
29843
  (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper);
29810
29844
  this.applyFormatWithContentModel(editor, false /* isCrop */, true /* shouldSelect*/, true /* isApiOperation */);
29811
29845
  };
29846
+ /**
29847
+ * Exported for testing purpose only
29848
+ */
29812
29849
  ImageEditPlugin.prototype.cleanInfo = function () {
29813
29850
  var _a, _b;
29814
29851
  (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorStyle(IMAGE_EDIT_CLASS, null);
@@ -30983,7 +31020,7 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
30983
31020
  /**
30984
31021
  * @internal
30985
31022
  */
30986
- function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale) {
31023
+ function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale, useTouch) {
30987
31024
  return getEditElements(wrapper, elementClass).map(function (element) {
30988
31025
  return new DragAndDropHelper_1.DragAndDropHelper(element, {
30989
31026
  editInfo: editInfo,
@@ -30991,7 +31028,7 @@ function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper,
30991
31028
  elementClass: elementClass,
30992
31029
  x: element.dataset.x,
30993
31030
  y: element.dataset.y,
30994
- }, updateWrapper, helper, zoomScale);
31031
+ }, updateWrapper, helper, zoomScale, useTouch);
30995
31032
  });
30996
31033
  }
30997
31034
  exports.getDropAndDragHelpers = getDropAndDragHelpers;