roosterjs 9.35.0 → 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.0)
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
@@ -9956,7 +9956,7 @@ var setContentModel = function (core, model, option, onNodeCreated, isInitializi
9956
9956
  : (0, roosterjs_content_model_dom_1.createModelToDomContextWithConfig)(core.environment.modelToDomSettings.calculated, editorContext);
9957
9957
  modelToDomContext.onNodeCreated = onNodeCreated;
9958
9958
  (_a = core.onFixUpModel) === null || _a === void 0 ? void 0 : _a.call(core, model);
9959
- var selection = (0, roosterjs_content_model_dom_1.contentModelToDom)(core.logicalRoot.ownerDocument.implementation.createHTMLDocument(), core.logicalRoot, model, modelToDomContext);
9959
+ var selection = (0, roosterjs_content_model_dom_1.contentModelToDom)(core.logicalRoot.ownerDocument, core.logicalRoot, model, modelToDomContext);
9960
9960
  if (!core.lifecycle.shadowEditFragment) {
9961
9961
  // Clear pending mutations since we will use our latest model object to replace existing cache
9962
9962
  (_b = core.cache.textMutationObserver) === null || _b === void 0 ? void 0 : _b.flushMutations(true /*ignoreMutations*/);
@@ -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,
@@ -27888,8 +27889,8 @@ var handleParagraph = function (doc, parent, paragraph, context, refNode) {
27888
27889
  paragraph.segments.some(function (segment) { return segment.segmentType != 'SelectionMarker'; }));
27889
27890
  var formatOnWrapper = needParagraphWrapper
27890
27891
  ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (((_a = paragraph.decorator) === null || _a === void 0 ? void 0 : _a.format) || {})), paragraph.segmentFormat) : {};
27891
- var prevRefNode = refNode === null || refNode === void 0 ? void 0 : refNode.previousSibling;
27892
27892
  container = doc.createElement(((_b = paragraph.decorator) === null || _b === void 0 ? void 0 : _b.tagName) || DefaultParagraphTag);
27893
+ parent.insertBefore(container, refNode);
27893
27894
  context.regularSelection.current = {
27894
27895
  block: needParagraphWrapper ? container : container.parentNode,
27895
27896
  segment: null,
@@ -27931,13 +27932,7 @@ var handleParagraph = function (doc, parent, paragraph, context, refNode) {
27931
27932
  // since this paragraph it is implicit. In that case container.nextSibling will become original
27932
27933
  // inline entity's next sibling. So reset refNode to its real next sibling (after change) here
27933
27934
  // to make sure the value is correct.
27934
- refNode =
27935
- prevRefNode === undefined // When refNode is not passed in
27936
- ? null
27937
- : prevRefNode === null // When refNode is the first child of parent
27938
- ? parent.firstChild
27939
- : prevRefNode.nextSibling; // Normal case
27940
- parent.insertBefore(container, refNode);
27935
+ refNode = container.nextSibling;
27941
27936
  if (container) {
27942
27937
  (_d = context.onNodeCreated) === null || _d === void 0 ? void 0 : _d.call(context, paragraph, container);
27943
27938
  (_e = context.domIndexer) === null || _e === void 0 ? void 0 : _e.onParagraph(container);
@@ -32179,10 +32174,11 @@ var deleteCollapsedSelection_1 = __webpack_require__(/*! ./deleteSteps/deleteCol
32179
32174
  * @returns True if the event is handled by content model, otherwise false
32180
32175
  */
32181
32176
  function keyboardDelete(editor, rawEvent, handleExpandedSelection) {
32177
+ var _a;
32182
32178
  if (handleExpandedSelection === void 0) { handleExpandedSelection = true; }
32183
32179
  var handled = false;
32184
32180
  var selection = editor.getDOMSelection();
32185
- if (shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection)) {
32181
+ if (shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection, (_a = editor.getEnvironment().isIOS) !== null && _a !== void 0 ? _a : false)) {
32186
32182
  editor.formatContentModel(function (model, context) {
32187
32183
  var result = (0, roosterjs_content_model_dom_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
32188
32184
  handled = (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
@@ -32219,7 +32215,7 @@ function getDeleteSteps(rawEvent, isMac) {
32219
32215
  deleteParagraphStyle_1.deleteParagraphStyle,
32220
32216
  ];
32221
32217
  }
32222
- function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection) {
32218
+ function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelection, isIOS) {
32223
32219
  var _a, _b;
32224
32220
  if (!selection) {
32225
32221
  return false; // Nothing to delete
@@ -32245,15 +32241,19 @@ function shouldDeleteWithContentModel(selection, rawEvent, handleExpandedSelecti
32245
32241
  // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
32246
32242
  return !((0, roosterjs_content_model_dom_1.isNodeOfType)(startContainer, 'TEXT_NODE') &&
32247
32243
  !(0, roosterjs_content_model_dom_1.isModifierKey)(rawEvent) &&
32248
- (canDeleteBefore(rawEvent, startContainer, startOffset) ||
32244
+ (canDeleteBefore(rawEvent, startContainer, startOffset, isIOS) ||
32249
32245
  canDeleteAfter(rawEvent, startContainer, startOffset)));
32250
32246
  }
32251
32247
  }
32252
- function canDeleteBefore(rawEvent, text, offset) {
32248
+ function canDeleteBefore(rawEvent, text, offset, isIOS) {
32253
32249
  var _a, _b;
32254
- if (rawEvent.key != 'Backspace' || offset <= 1) {
32250
+ if (rawEvent.key != 'Backspace') {
32255
32251
  return false;
32256
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
+ }
32257
32257
  var length = (_b = (_a = text.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
32258
32258
  if (offset == length) {
32259
32259
  // At the end of text, need to check if next segment is deletable
@@ -33580,6 +33580,7 @@ var ImageEditPlugin = /** @class */ (function () {
33580
33580
  var _this = this;
33581
33581
  var editingImageModel;
33582
33582
  var selection = editor.getDOMSelection();
33583
+ var isRTL = false;
33583
33584
  editor.formatContentModel(function (model, context) {
33584
33585
  var editingImage = (0, getSelectedImage_1.getSelectedImage)(model);
33585
33586
  var previousSelectedImage = isApiOperation
@@ -33633,6 +33634,7 @@ var ImageEditPlugin = /** @class */ (function () {
33633
33634
  _this.isCropMode = isCropMode;
33634
33635
  (0, roosterjs_content_model_dom_1.mutateSegment)(editingImage.paragraph, editingImage.image, function (image) {
33635
33636
  editingImageModel = image;
33637
+ isRTL = editingImage.paragraph.format.direction == 'rtl';
33636
33638
  _this.imageEditInfo = (0, updateImageEditInfo_1.updateImageEditInfo)(image, selection.image);
33637
33639
  image.format.imageState = 'isEditing';
33638
33640
  });
@@ -33649,10 +33651,10 @@ var ImageEditPlugin = /** @class */ (function () {
33649
33651
  (0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') &&
33650
33652
  (0, roosterjs_content_model_dom_1.isElementOfType)(node, 'img')) {
33651
33653
  if (isCropMode) {
33652
- _this.startCropMode(editor, node);
33654
+ _this.startCropMode(editor, node, isRTL);
33653
33655
  }
33654
33656
  else {
33655
- _this.startRotateAndResize(editor, node);
33657
+ _this.startRotateAndResize(editor, node, isRTL);
33656
33658
  }
33657
33659
  }
33658
33660
  },
@@ -33713,7 +33715,7 @@ var ImageEditPlugin = /** @class */ (function () {
33713
33715
  ]);
33714
33716
  editor.setEditorStyle(IMAGE_EDIT_CLASS_CARET, "caret-color: transparent;");
33715
33717
  };
33716
- ImageEditPlugin.prototype.startRotateAndResize = function (editor, image) {
33718
+ ImageEditPlugin.prototype.startRotateAndResize = function (editor, image, isRTL) {
33717
33719
  var _this = this;
33718
33720
  var _a, _b;
33719
33721
  if (this.imageEditInfo) {
@@ -33725,7 +33727,7 @@ var ImageEditPlugin = /** @class */ (function () {
33725
33727
  _this.selectedImage &&
33726
33728
  _this.wrapper &&
33727
33729
  _this.clonedImage) {
33728
- (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);
33729
33731
  _this.wasImageResized = true;
33730
33732
  }
33731
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 () {
@@ -33734,12 +33736,12 @@ var ImageEditPlugin = /** @class */ (function () {
33734
33736
  _this.selectedImage &&
33735
33737
  _this.wrapper &&
33736
33738
  _this.clonedImage) {
33737
- (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);
33738
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));
33739
33741
  _this.updateResizeHandleDirection(_this.resizers, _this.imageEditInfo.angleRad);
33740
33742
  }
33741
33743
  }, this.zoomScale, isMobileOrTable)), false);
33742
- (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);
33743
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));
33744
33746
  }
33745
33747
  }
@@ -33771,7 +33773,7 @@ var ImageEditPlugin = /** @class */ (function () {
33771
33773
  ImageEditPlugin.prototype.canRegenerateImage = function (image) {
33772
33774
  return (0, canRegenerateImage_1.canRegenerateImage)(image);
33773
33775
  };
33774
- ImageEditPlugin.prototype.startCropMode = function (editor, image) {
33776
+ ImageEditPlugin.prototype.startCropMode = function (editor, image, isRTL) {
33775
33777
  var _this = this;
33776
33778
  if (this.imageEditInfo) {
33777
33779
  this.startEditing(editor, image, ['crop']);
@@ -33781,11 +33783,11 @@ var ImageEditPlugin = /** @class */ (function () {
33781
33783
  _this.selectedImage &&
33782
33784
  _this.wrapper &&
33783
33785
  _this.clonedImage) {
33784
- (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);
33785
33787
  _this.isCropMode = true;
33786
33788
  }
33787
33789
  }, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet)), false);
33788
- (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);
33789
33791
  }
33790
33792
  }
33791
33793
  };
@@ -35071,7 +35073,7 @@ exports.getSelectedImage = getSelectedImage;
35071
35073
  "use strict";
35072
35074
 
35073
35075
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35074
- 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;
35075
35077
  var constants_1 = __webpack_require__(/*! ../constants/constants */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/constants/constants.ts");
35076
35078
  /**
35077
35079
  * @internal
@@ -35159,13 +35161,6 @@ function checkIfImageWasResized(image) {
35159
35161
  }
35160
35162
  }
35161
35163
  exports.checkIfImageWasResized = checkIfImageWasResized;
35162
- /**
35163
- * @internal
35164
- */
35165
- function isRTL(image) {
35166
- return window.getComputedStyle(image).direction === 'rtl';
35167
- }
35168
- exports.isRTL = isRTL;
35169
35164
  function isFixedNumberValue(value) {
35170
35165
  var numberValue = typeof value === 'string' ? parseInt(value) : value;
35171
35166
  return !isNaN(numberValue);
@@ -35344,7 +35339,7 @@ var imageEditUtils_1 = __webpack_require__(/*! ./imageEditUtils */ "./packages/r
35344
35339
  /**
35345
35340
  * @internal
35346
35341
  */
35347
- function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers, croppers) {
35342
+ function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers, croppers, isRTL) {
35348
35343
  var angleRad = editInfo.angleRad, bottomPercent = editInfo.bottomPercent, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, flippedHorizontal = editInfo.flippedHorizontal, flippedVertical = editInfo.flippedVertical;
35349
35344
  var generateImageSize = (0, generateImageSize_1.getGeneratedImageSize)(editInfo, croppers && (croppers === null || croppers === void 0 ? void 0 : croppers.length) > 0);
35350
35345
  if (!generateImageSize) {
@@ -35367,7 +35362,7 @@ function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers,
35367
35362
  wrapper.style.verticalAlign = 'text-bottom';
35368
35363
  // Update the text-alignment to avoid the image to overflow if the parent element have align center or right
35369
35364
  // or if the direction is Right To Left
35370
- if ((0, imageEditUtils_1.isRTL)(clonedImage)) {
35365
+ if (isRTL) {
35371
35366
  wrapper.style.textAlign = 'right';
35372
35367
  if (!croppers) {
35373
35368
  clonedImage.style.left = (0, imageEditUtils_1.getPx)(cropLeftPx);