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