roosterjs 9.35.1 → 9.36.0

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/rooster.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 9.35.1)
1
+ // Type definitions for roosterjs (Version 9.36.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -4637,6 +4637,10 @@ interface EditorEnvironment {
4637
4637
  * Whether editor is running on Android
4638
4638
  */
4639
4639
  readonly isAndroid?: boolean;
4640
+ /**
4641
+ * Whether editor is running on iOS
4642
+ */
4643
+ readonly isIOS?: boolean;
4640
4644
  /**
4641
4645
  * Whether editor is running on Safari browser
4642
4646
  */
@@ -9935,7 +9939,7 @@ class ImageEditPlugin implements ImageEditor, EditorPlugin {
9935
9939
  private startEditing;
9936
9940
  private updateImageDimensionsIfZero;
9937
9941
  private startEditingInternal;
9938
- startRotateAndResize(editor: IEditor, image: HTMLImageElement): void;
9942
+ startRotateAndResize(editor: IEditor, image: HTMLImageElement, isRTL: boolean): void;
9939
9943
  private updateResizeHandleDirection;
9940
9944
  private updateRotateHandleState;
9941
9945
  isOperationAllowed(operation: ImageEditOperation): boolean;
package/dist/rooster.js CHANGED
@@ -15458,6 +15458,7 @@ function createEditorEnvironment(contentDiv, options) {
15458
15458
  modelToDomSettings: (0, createEditorDefaultSettings_1.createModelToDomSettings)(options),
15459
15459
  isMac: appVersion.indexOf('Mac') != -1,
15460
15460
  isAndroid: /android/i.test(userAgent),
15461
+ isIOS: /iPad|iPhone/.test(userAgent),
15461
15462
  isSafari: userAgent.indexOf('Safari') >= 0 &&
15462
15463
  userAgent.indexOf('Chrome') < 0 &&
15463
15464
  userAgent.indexOf('Android') < 0,
@@ -32173,10 +32174,11 @@ var deleteCollapsedSelection_1 = __webpack_require__(/*! ./deleteSteps/deleteCol
32173
32174
  * @returns True if the event is handled by content model, otherwise false
32174
32175
  */
32175
32176
  function keyboardDelete(editor, rawEvent, handleExpandedSelection) {
32177
+ var _a;
32176
32178
  if (handleExpandedSelection === void 0) { handleExpandedSelection = true; }
32177
32179
  var handled = false;
32178
32180
  var selection = editor.getDOMSelection();
32179
- if (shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection)) {
32181
+ if (shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection, (_a = editor.getEnvironment().isIOS) !== null && _a !== void 0 ? _a : false)) {
32180
32182
  editor.formatContentModel(function (model, context) {
32181
32183
  var result = (0, roosterjs_content_model_dom_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
32182
32184
  handled = (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
@@ -32213,7 +32215,7 @@ function getDeleteSteps(rawEvent, isMac) {
32213
32215
  deleteParagraphStyle_1.deleteParagraphStyle,
32214
32216
  ];
32215
32217
  }
32216
- function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection) {
32218
+ function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection, isIOS) {
32217
32219
  var _a, _b;
32218
32220
  if (!selection) {
32219
32221
  return false; // Nothing to delete
@@ -32239,15 +32241,19 @@ function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelecti
32239
32241
  // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
32240
32242
  return !((0, roosterjs_content_model_dom_1.isNodeOfType)(startContainer, 'TEXT_NODE') &&
32241
32243
  !(0, roosterjs_content_model_dom_1.isModifierKey)(rawEvent) &&
32242
- (canDeleteBefore(rawEvent, startContainer, startOffset) ||
32244
+ (canDeleteBefore(rawEvent, startContainer, startOffset, isIOS) ||
32243
32245
  canDeleteAfter(rawEvent, startContainer, startOffset)));
32244
32246
  }
32245
32247
  }
32246
- function canDeleteBefore(rawEvent, text, offset) {
32248
+ function canDeleteBefore(rawEvent, text, offset, isIOS) {
32247
32249
  var _a, _b;
32248
- if (rawEvent.key != 'Backspace' || offset <= 1) {
32250
+ if (rawEvent.key != 'Backspace') {
32249
32251
  return false;
32250
32252
  }
32253
+ if (offset <= 1) {
32254
+ // For iOS, allow browser to handle deletion of first character on iOS to preserve auto-capitalization
32255
+ return offset === 1 && isIOS;
32256
+ }
32251
32257
  var length = (_b = (_a = text.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
32252
32258
  if (offset == length) {
32253
32259
  // At the end of text, need to check if next segment is deletable
@@ -33574,6 +33580,7 @@ var ImageEditPlugin = /** @class */ (function () {
33574
33580
  var _this = this;
33575
33581
  var editingImageModel;
33576
33582
  var selection = editor.getDOMSelection();
33583
+ var isRTL = false;
33577
33584
  editor.formatContentModel(function (model, context) {
33578
33585
  var editingImage = (0, getSelectedImage_1.getSelectedImage)(model);
33579
33586
  var previousSelectedImage = isApiOperation
@@ -33627,6 +33634,7 @@ var ImageEditPlugin = /** @class */ (function () {
33627
33634
  _this.isCropMode = isCropMode;
33628
33635
  (0, roosterjs_content_model_dom_1.mutateSegment)(editingImage.paragraph, editingImage.image, function (image) {
33629
33636
  editingImageModel = image;
33637
+ isRTL = editingImage.paragraph.format.direction == 'rtl';
33630
33638
  _this.imageEditInfo = (0, updateImageEditInfo_1.updateImageEditInfo)(image, selection.image);
33631
33639
  image.format.imageState = 'isEditing';
33632
33640
  });
@@ -33643,10 +33651,10 @@ var ImageEditPlugin = /** @class */ (function () {
33643
33651
  (0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') &&
33644
33652
  (0, roosterjs_content_model_dom_1.isElementOfType)(node, 'img')) {
33645
33653
  if (isCropMode) {
33646
- _this.startCropMode(editor, node);
33654
+ _this.startCropMode(editor, node, isRTL);
33647
33655
  }
33648
33656
  else {
33649
- _this.startRotateAndResize(editor, node);
33657
+ _this.startRotateAndResize(editor, node, isRTL);
33650
33658
  }
33651
33659
  }
33652
33660
  },
@@ -33707,7 +33715,7 @@ var ImageEditPlugin = /** @class */ (function () {
33707
33715
  ]);
33708
33716
  editor.setEditorStyle(IMAGE_EDIT_CLASS_CARET, "caret-color: transparent;");
33709
33717
  };
33710
- ImageEditPlugin.prototype.startRotateAndResize = function (editor, image) {
33718
+ ImageEditPlugin.prototype.startRotateAndResize = function (editor, image, isRTL) {
33711
33719
  var _this = this;
33712
33720
  var _a, _b;
33713
33721
  if (this.imageEditInfo) {
@@ -33719,7 +33727,7 @@ var ImageEditPlugin = /** @class */ (function () {
33719
33727
  _this.selectedImage &&
33720
33728
  _this.wrapper &&
33721
33729
  _this.clonedImage) {
33722
- (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, _this.resizers);
33730
+ (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, _this.resizers, undefined /* croppers */, isRTL);
33723
33731
  _this.wasImageResized = true;
33724
33732
  }
33725
33733
  }, 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 () {
@@ -33728,12 +33736,12 @@ var ImageEditPlugin = /** @class */ (function () {
33728
33736
  _this.selectedImage &&
33729
33737
  _this.wrapper &&
33730
33738
  _this.clonedImage) {
33731
- (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper);
33739
+ (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, undefined /* croppers */, isRTL);
33732
33740
  _this.updateRotateHandleState(editor, _this.selectedImage, _this.wrapper, _this.rotators, (_a = _this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = _this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
33733
33741
  _this.updateResizeHandleDirection(_this.resizers, _this.imageEditInfo.angleRad);
33734
33742
  }
33735
33743
  }, this.zoomScale, isMobileOrTable)), false);
33736
- (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, this.resizers);
33744
+ (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, this.resizers, undefined /* croppers */, isRTL);
33737
33745
  this.updateRotateHandleState(editor, this.selectedImage, this.wrapper, this.rotators, (_a = this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
33738
33746
  }
33739
33747
  }
@@ -33765,7 +33773,7 @@ var ImageEditPlugin = /** @class */ (function () {
33765
33773
  ImageEditPlugin.prototype.canRegenerateImage = function (image) {
33766
33774
  return (0, canRegenerateImage_1.canRegenerateImage)(image);
33767
33775
  };
33768
- ImageEditPlugin.prototype.startCropMode = function (editor, image) {
33776
+ ImageEditPlugin.prototype.startCropMode = function (editor, image, isRTL) {
33769
33777
  var _this = this;
33770
33778
  if (this.imageEditInfo) {
33771
33779
  this.startEditing(editor, image, ['crop']);
@@ -33775,11 +33783,11 @@ var ImageEditPlugin = /** @class */ (function () {
33775
33783
  _this.selectedImage &&
33776
33784
  _this.wrapper &&
33777
33785
  _this.clonedImage) {
33778
- (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined, _this.croppers);
33786
+ (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, _this.croppers, isRTL);
33779
33787
  _this.isCropMode = true;
33780
33788
  }
33781
33789
  }, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet)), false);
33782
- (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined, this.croppers);
33790
+ (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined /* resizers */, this.croppers, isRTL);
33783
33791
  }
33784
33792
  }
33785
33793
  };
@@ -35065,7 +35073,7 @@ exports.getSelectedImage = getSelectedImage;
35065
35073
  "use strict";
35066
35074
 
35067
35075
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35068
- exports.isRTL = exports.checkIfImageWasResized = exports.setSize = exports.setWrapperSizeDimensions = exports.setFlipped = exports.rotateCoordinate = exports.isASmallImage = exports.getPx = void 0;
35076
+ exports.checkIfImageWasResized = exports.setSize = exports.setWrapperSizeDimensions = exports.setFlipped = exports.rotateCoordinate = exports.isASmallImage = exports.getPx = void 0;
35069
35077
  var constants_1 = __webpack_require__(/*! ../constants/constants */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/constants/constants.ts");
35070
35078
  /**
35071
35079
  * @internal
@@ -35153,13 +35161,6 @@ function checkIfImageWasResized(image) {
35153
35161
  }
35154
35162
  }
35155
35163
  exports.checkIfImageWasResized = checkIfImageWasResized;
35156
- /**
35157
- * @internal
35158
- */
35159
- function isRTL(image) {
35160
- return window.getComputedStyle(image).direction === 'rtl';
35161
- }
35162
- exports.isRTL = isRTL;
35163
35164
  function isFixedNumberValue(value) {
35164
35165
  var numberValue = typeof value === 'string' ? parseInt(value) : value;
35165
35166
  return !isNaN(numberValue);
@@ -35338,7 +35339,7 @@ var imageEditUtils_1 = __webpack_require__(/*! ./imageEditUtils */ "./packages/r
35338
35339
  /**
35339
35340
  * @internal
35340
35341
  */
35341
- function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers, croppers) {
35342
+ function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers, croppers, isRTL) {
35342
35343
  var angleRad = editInfo.angleRad, bottomPercent = editInfo.bottomPercent, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, flippedHorizontal = editInfo.flippedHorizontal, flippedVertical = editInfo.flippedVertical;
35343
35344
  var generateImageSize = (0, generateImageSize_1.getGeneratedImageSize)(editInfo, croppers && (croppers === null || croppers === void 0 ? void 0 : croppers.length) > 0);
35344
35345
  if (!generateImageSize) {
@@ -35361,7 +35362,7 @@ function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers,
35361
35362
  wrapper.style.verticalAlign = 'text-bottom';
35362
35363
  // Update the text-alignment to avoid the image to overflow if the parent element have align center or right
35363
35364
  // or if the direction is Right To Left
35364
- if ((0, imageEditUtils_1.isRTL)(clonedImage)) {
35365
+ if (isRTL) {
35365
35366
  wrapper.style.textAlign = 'right';
35366
35367
  if (!croppers) {
35367
35368
  clonedImage.style.left = (0, imageEditUtils_1.getPx)(cropLeftPx);