roosterjs 8.35.2 → 8.37.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.js CHANGED
@@ -2155,12 +2155,14 @@ Object.defineProperty(exports, "getDarkColor", { enumerable: true, get: function
2155
2155
 
2156
2156
  Object.defineProperty(exports, "__esModule", { value: true });
2157
2157
  var Color = __webpack_require__(/*! color */ "./node_modules/color/index.js");
2158
- var baseLValue = 21.247; // L-value of #333333
2158
+ var DefaultBaseLValue = 21.247; // L-value of #333333
2159
2159
  /**
2160
2160
  * Get dark mode color for a given color
2161
2161
  * @param color The color to calculate from
2162
+ * @param baseLValue The Light value for base dark color in LAB format. @default the Light value for #333333
2162
2163
  */
2163
- function getDarkColor(color) {
2164
+ function getDarkColor(color, baseLValue) {
2165
+ if (baseLValue === void 0) { baseLValue = DefaultBaseLValue; }
2164
2166
  try {
2165
2167
  var computedColor = Color(color || undefined);
2166
2168
  var colorLab = computedColor.lab().array();
@@ -3084,8 +3086,7 @@ function setAlignment(editor, alignment) {
3084
3086
  var selection = editor.getSelectionRangeEx();
3085
3087
  var isATable = selection && selection.type === 1 /* TableSelection */;
3086
3088
  var elementAtCursor = editor.getElementAtCursor();
3087
- if (editor.isFeatureEnabled("TableAlignment" /* TableAlignment */) &&
3088
- isATable &&
3089
+ if (isATable &&
3089
3090
  (0, roosterjs_editor_dom_1.isWholeTableSelected)(new roosterjs_editor_dom_1.VTable(selection.table), selection.coordinates)) {
3090
3091
  alignTable(selection, alignment);
3091
3092
  }
@@ -4196,7 +4197,9 @@ function applyInlineStyle(editor, callback, apiName) {
4196
4197
  else if (editor.isFeatureEnabled("PendingStyleBasedFormat" /* PendingStyleBasedFormat */)) {
4197
4198
  editor.triggerPluginEvent(13 /* PendingFormatStateChanged */, {
4198
4199
  formatState: {},
4199
- formatCallback: safeCallback,
4200
+ // Here we use callback instead of safeCallback because we know it's contentEditable.
4201
+ // In addition, for elements that are not added to the DOM tree, isContentEditable always returns false on Safari.
4202
+ formatCallback: callback,
4200
4203
  });
4201
4204
  editor.triggerContentChangedEvent("Format" /* Format */);
4202
4205
  }
@@ -5097,7 +5100,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
5097
5100
  * When typing goes directly under content div, many things can go wrong
5098
5101
  * We fix it by wrapping it with a div and reposition cursor within the div
5099
5102
  */
5100
- var ensureTypeInContainer = function (core, position, keyboardEvent) {
5103
+ var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
5101
5104
  var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
5102
5105
  var td;
5103
5106
  if (table && (td = table.querySelector('td,th'))) {
@@ -5118,20 +5121,28 @@ var ensureTypeInContainer = function (core, position, keyboardEvent) {
5118
5121
  var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
5119
5122
  (keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
5120
5123
  formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
5124
+ if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
5125
+ var firstChild = formatNode.firstChild;
5126
+ formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
5127
+ ? firstChild
5128
+ : (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
5129
+ position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5130
+ }
5121
5131
  }
5122
5132
  else {
5123
5133
  // Only reason we don't get the selection block is that we have an empty content div
5124
5134
  // which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
5125
5135
  // The fix is to add a DIV wrapping, apply default format and move cursor over
5126
- formatNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5127
- core.api.insertNode(core, formatNode, {
5136
+ var newNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5137
+ core.api.insertNode(core, newNode, {
5128
5138
  position: 1 /* End */,
5129
5139
  updateCursor: false,
5130
5140
  replaceSelection: false,
5131
5141
  insertOnNewLine: false,
5132
5142
  });
5143
+ formatNode = newNode.firstChild;
5133
5144
  // element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
5134
- position = new roosterjs_editor_dom_1.Position(formatNode.firstChild, 0 /* Begin */);
5145
+ position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5135
5146
  }
5136
5147
  if (formatNode && core.lifecycle.defaultFormat) {
5137
5148
  (0, roosterjs_editor_dom_1.applyFormat)(formatNode, core.lifecycle.defaultFormat, core.lifecycle.isDarkMode);
@@ -5850,7 +5861,6 @@ exports.restoreUndoSnapshot = restoreUndoSnapshot;
5850
5861
 
5851
5862
  Object.defineProperty(exports, "__esModule", { value: true });
5852
5863
  exports.selectImage = void 0;
5853
- var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
5854
5864
  var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
5855
5865
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5856
5866
  var IMAGE_ID = 'imageSelected';
@@ -5885,7 +5895,7 @@ exports.selectImage = selectImage;
5885
5895
  var select = function (core, image) {
5886
5896
  (0, roosterjs_editor_dom_1.removeImportantStyleRule)(image, ['border', 'margin']);
5887
5897
  var borderCSS = buildBorderCSS(core, image.id);
5888
- (0, addSelectionStyle_1.default)(core, borderCSS, STYLE_ID);
5898
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, borderCSS, STYLE_ID + core.contentDiv.id);
5889
5899
  };
5890
5900
  var buildBorderCSS = function (core, imageId) {
5891
5901
  var divId = core.contentDiv.id;
@@ -5894,10 +5904,7 @@ var buildBorderCSS = function (core, imageId) {
5894
5904
  };
5895
5905
  var unselect = function (core) {
5896
5906
  var doc = core.contentDiv.ownerDocument;
5897
- var styleTag = doc.getElementById(STYLE_ID + core.contentDiv.id);
5898
- if (styleTag) {
5899
- doc.head.removeChild(styleTag);
5900
- }
5907
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
5901
5908
  };
5902
5909
 
5903
5910
 
@@ -5979,7 +5986,6 @@ function restorePendingFormatState(core) {
5979
5986
 
5980
5987
  Object.defineProperty(exports, "__esModule", { value: true });
5981
5988
  exports.selectTable = void 0;
5982
- var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
5983
5989
  var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
5984
5990
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5985
5991
  var TABLE_ID = 'tableSelected';
@@ -6080,19 +6086,13 @@ function buildCss(table, coordinates, contentDivSelector) {
6080
6086
  function select(core, table, coordinates) {
6081
6087
  var contentDivSelector = '#' + core.contentDiv.id;
6082
6088
  var _a = buildCss(table, coordinates, contentDivSelector), css = _a.css, ranges = _a.ranges;
6083
- (0, addSelectionStyle_1.default)(core, css, STYLE_ID);
6089
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, css, STYLE_ID + core.contentDiv.id);
6084
6090
  return ranges;
6085
6091
  }
6086
- function unselect(core) {
6087
- var _a;
6088
- var div = core.contentDiv;
6089
- var styleElement = div.ownerDocument.getElementById(STYLE_ID + div.id);
6090
- if ((_a = styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
6091
- while (styleElement.sheet.cssRules.length > 0) {
6092
- styleElement.sheet.deleteRule(0);
6093
- }
6094
- }
6095
- }
6092
+ var unselect = function (core) {
6093
+ var doc = core.contentDiv.ownerDocument;
6094
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
6095
+ };
6096
6096
  function generateCssFromCell(contentDivSelector, tableId, middleElSelector, rowIndex, cellTag, index) {
6097
6097
  return (contentDivSelector +
6098
6098
  ' #' +
@@ -6229,7 +6229,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
6229
6229
  */
6230
6230
  var switchShadowEdit = function (core, isOn) {
6231
6231
  var lifecycle = core.lifecycle, contentDiv = core.contentDiv;
6232
- var shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
6232
+ var shadowEditEntities = lifecycle.shadowEditEntities, shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
6233
6233
  var wasInShadowEdit = !!shadowEditFragment;
6234
6234
  var getShadowEditSelectionPath = function (selectionType, shadowEditSelection) {
6235
6235
  return (((shadowEditSelection === null || shadowEditSelection === void 0 ? void 0 : shadowEditSelection.type) == selectionType &&
@@ -6244,10 +6244,9 @@ var switchShadowEdit = function (core, isOn) {
6244
6244
  var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
6245
6245
  shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
6246
6246
  shadowEditTableSelectionPath = getShadowEditSelectionPath(1 /* TableSelection */, selection);
6247
- shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
6248
6247
  shadowEditImageSelectionPath = getShadowEditSelectionPath(2 /* ImageSelection */, selection);
6249
- (0, roosterjs_editor_dom_1.moveChildNodes)(shadowEditFragment, contentDiv);
6250
- shadowEditFragment.normalize();
6248
+ shadowEditEntities = {};
6249
+ shadowEditFragment = (0, roosterjs_editor_dom_1.moveContentWithEntityPlaceholders)(contentDiv, shadowEditEntities);
6251
6250
  core.api.triggerEvent(core, {
6252
6251
  eventType: 17 /* EnteredShadowEdit */,
6253
6252
  fragment: shadowEditFragment,
@@ -6257,22 +6256,22 @@ var switchShadowEdit = function (core, isOn) {
6257
6256
  lifecycle.shadowEditSelectionPath = shadowEditSelectionPath;
6258
6257
  lifecycle.shadowEditTableSelectionPath = shadowEditTableSelectionPath;
6259
6258
  lifecycle.shadowEditImageSelectionPath = shadowEditImageSelectionPath;
6259
+ lifecycle.shadowEditEntities = shadowEditEntities;
6260
6260
  }
6261
- (0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
6262
6261
  if (lifecycle.shadowEditFragment) {
6263
- contentDiv.appendChild(lifecycle.shadowEditFragment.cloneNode(true /*deep*/));
6262
+ (0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(lifecycle.shadowEditFragment, contentDiv, lifecycle.shadowEditEntities, true /*insertClonedNode*/);
6264
6263
  }
6265
6264
  }
6266
6265
  else {
6267
6266
  lifecycle.shadowEditFragment = null;
6268
6267
  lifecycle.shadowEditSelectionPath = null;
6268
+ lifecycle.shadowEditEntities = null;
6269
6269
  if (wasInShadowEdit) {
6270
6270
  core.api.triggerEvent(core, {
6271
6271
  eventType: 18 /* LeavingShadowEdit */,
6272
6272
  }, false /*broadcast*/);
6273
- (0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
6274
6273
  if (shadowEditFragment) {
6275
- contentDiv.appendChild(shadowEditFragment);
6274
+ (0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(shadowEditFragment, contentDiv, shadowEditEntities);
6276
6275
  }
6277
6276
  core.api.focus(core);
6278
6277
  if (shadowEditSelectionPath) {
@@ -6487,39 +6486,6 @@ function handledExclusively(event, plugin) {
6487
6486
  }
6488
6487
 
6489
6488
 
6490
- /***/ }),
6491
-
6492
- /***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts":
6493
- /*!*******************************************************************************!*\
6494
- !*** ./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts ***!
6495
- \*******************************************************************************/
6496
- /*! no static exports found */
6497
- /***/ (function(module, exports, __webpack_require__) {
6498
-
6499
- "use strict";
6500
-
6501
- Object.defineProperty(exports, "__esModule", { value: true });
6502
- /**
6503
- * Add style to selected elements
6504
- * @param core The Editor core object
6505
- * @param cssRule The css rule that must added to the selection
6506
- * @param styleId the ID of the style tag
6507
- */
6508
- function addSelectionStyle(core, cssRule, styleId) {
6509
- var _a;
6510
- var styleTagId = styleId + core.contentDiv.id;
6511
- var doc = core.contentDiv.ownerDocument;
6512
- var styleTag = doc.getElementById(styleTagId);
6513
- if (!styleTag) {
6514
- styleTag = doc.createElement('style');
6515
- styleTag.id = styleTagId;
6516
- doc.head.appendChild(styleTag);
6517
- }
6518
- (_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
6519
- }
6520
- exports.default = addSelectionStyle;
6521
-
6522
-
6523
6489
  /***/ }),
6524
6490
 
6525
6491
  /***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts":
@@ -6672,6 +6638,9 @@ var CopyPastePlugin = /** @class */ (function () {
6672
6638
  var image = tempDiv_1.querySelector('#' + selection_1.image.id);
6673
6639
  if (image) {
6674
6640
  newRange = (0, roosterjs_editor_dom_1.createRange)(image);
6641
+ if (isCut) {
6642
+ this.deleteImage(this.editor, selection_1.image.id);
6643
+ }
6675
6644
  }
6676
6645
  }
6677
6646
  else {
@@ -6781,6 +6750,11 @@ var CopyPastePlugin = /** @class */ (function () {
6781
6750
  table.style.removeProperty('height');
6782
6751
  }
6783
6752
  };
6753
+ CopyPastePlugin.prototype.deleteImage = function (editor, imageId) {
6754
+ editor.queryElements('#' + imageId, function (node) {
6755
+ editor.deleteNode(node);
6756
+ });
6757
+ };
6784
6758
  return CopyPastePlugin;
6785
6759
  }());
6786
6760
  exports.default = CopyPastePlugin;
@@ -7480,6 +7454,95 @@ var workaroundSelectionIssueForIE = roosterjs_editor_dom_1.Browser.isIE
7480
7454
  : function () { };
7481
7455
 
7482
7456
 
7457
+ /***/ }),
7458
+
7459
+ /***/ "./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts":
7460
+ /*!**************************************************************************!*\
7461
+ !*** ./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts ***!
7462
+ \**************************************************************************/
7463
+ /*! no static exports found */
7464
+ /***/ (function(module, exports, __webpack_require__) {
7465
+
7466
+ "use strict";
7467
+
7468
+ Object.defineProperty(exports, "__esModule", { value: true });
7469
+ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
7470
+ var Escape = 'Escape';
7471
+ var mouseRightButton = 2;
7472
+ var mouseLeftButton = 0;
7473
+ /**
7474
+ * Detect image selection and help highlight the image
7475
+ */
7476
+ var ImageSelection = /** @class */ (function () {
7477
+ function ImageSelection() {
7478
+ this.editor = null;
7479
+ }
7480
+ /**
7481
+ * Get a friendly name of this plugin
7482
+ */
7483
+ ImageSelection.prototype.getName = function () {
7484
+ return 'ImageSelection';
7485
+ };
7486
+ /**
7487
+ * Initialize this plugin. This should only be called from Editor
7488
+ * @param editor Editor instance
7489
+ */
7490
+ ImageSelection.prototype.initialize = function (editor) {
7491
+ this.editor = editor;
7492
+ };
7493
+ /**
7494
+ * Dispose this plugin
7495
+ */
7496
+ ImageSelection.prototype.dispose = function () {
7497
+ var _a;
7498
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.select(null);
7499
+ this.editor = null;
7500
+ };
7501
+ ImageSelection.prototype.onPluginEvent = function (event) {
7502
+ var _a;
7503
+ if (this.editor) {
7504
+ switch (event.eventType) {
7505
+ case 17 /* EnteredShadowEdit */:
7506
+ case 18 /* LeavingShadowEdit */:
7507
+ var selection = this.editor.getSelectionRangeEx();
7508
+ if (selection.type == 2 /* ImageSelection */) {
7509
+ this.editor.select(selection.image);
7510
+ }
7511
+ break;
7512
+ case 6 /* MouseUp */:
7513
+ var target = event.rawEvent.target;
7514
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
7515
+ if (event.rawEvent.button === mouseRightButton) {
7516
+ var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
7517
+ this.editor.select(imageRange);
7518
+ }
7519
+ else if (event.rawEvent.button === mouseLeftButton) {
7520
+ this.editor.select(target);
7521
+ }
7522
+ }
7523
+ break;
7524
+ case 2 /* KeyUp */:
7525
+ var key = event.rawEvent.key;
7526
+ var keyDownSelection = this.editor.getSelectionRangeEx();
7527
+ if (keyDownSelection.type === 2 /* ImageSelection */) {
7528
+ if (key === Escape) {
7529
+ this.editor.select(keyDownSelection.image, -2 /* Before */);
7530
+ (_a = this.editor.getSelectionRange()) === null || _a === void 0 ? void 0 : _a.collapse();
7531
+ event.rawEvent.stopPropagation();
7532
+ }
7533
+ else {
7534
+ this.editor.select(keyDownSelection.ranges[0]);
7535
+ }
7536
+ }
7537
+ break;
7538
+ }
7539
+ }
7540
+ };
7541
+ return ImageSelection;
7542
+ }());
7543
+ exports.default = ImageSelection;
7544
+
7545
+
7483
7546
  /***/ }),
7484
7547
 
7485
7548
  /***/ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts":
@@ -7570,6 +7633,7 @@ var LifecyclePlugin = /** @class */ (function () {
7570
7633
  onExternalContentTransform: (_c = options.onExternalContentTransform) !== null && _c !== void 0 ? _c : null,
7571
7634
  experimentalFeatures: options.experimentalFeatures || [],
7572
7635
  shadowEditFragment: null,
7636
+ shadowEditEntities: null,
7573
7637
  shadowEditSelectionPath: null,
7574
7638
  shadowEditTableSelectionPath: null,
7575
7639
  shadowEditImageSelectionPath: null,
@@ -8422,6 +8486,7 @@ var CopyPastePlugin_1 = __webpack_require__(/*! ./CopyPastePlugin */ "./packages
8422
8486
  var DOMEventPlugin_1 = __webpack_require__(/*! ./DOMEventPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/DOMEventPlugin.ts");
8423
8487
  var EditPlugin_1 = __webpack_require__(/*! ./EditPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EditPlugin.ts");
8424
8488
  var EntityPlugin_1 = __webpack_require__(/*! ./EntityPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EntityPlugin.ts");
8489
+ var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts");
8425
8490
  var LifecyclePlugin_1 = __webpack_require__(/*! ./LifecyclePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts");
8426
8491
  var MouseUpPlugin_1 = __webpack_require__(/*! ./MouseUpPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/MouseUpPlugin.ts");
8427
8492
  var NormalizeTablePlugin_1 = __webpack_require__(/*! ./NormalizeTablePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/NormalizeTablePlugin.ts");
@@ -8449,6 +8514,7 @@ function createCorePlugins(contentDiv, options) {
8449
8514
  mouseUp: map.mouseUp || new MouseUpPlugin_1.default(),
8450
8515
  copyPaste: map.copyPaste || new CopyPastePlugin_1.default(options),
8451
8516
  entity: map.entity || new EntityPlugin_1.default(),
8517
+ imageSelection: map.imageSelection || new ImageSelection_1.default(),
8452
8518
  normalizeTable: map.normalizeTable || new NormalizeTablePlugin_1.default(),
8453
8519
  lifecycle: map.lifecycle || new LifecyclePlugin_1.default(options, contentDiv),
8454
8520
  };
@@ -8894,9 +8960,7 @@ var Editor = /** @class */ (function () {
8894
8960
  coordinates: arg2,
8895
8961
  };
8896
8962
  }
8897
- else if (this.isFeatureEnabled("ImageSelection" /* ImageSelection */) &&
8898
- (0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') &&
8899
- typeof arg2 == 'undefined') {
8963
+ else if ((0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') && typeof arg2 == 'undefined') {
8900
8964
  rangeEx = {
8901
8965
  type: 2 /* ImageSelection */,
8902
8966
  ranges: [],
@@ -11211,6 +11275,143 @@ function commitEntity(wrapper, type, isReadonly, id) {
11211
11275
  exports.default = commitEntity;
11212
11276
 
11213
11277
 
11278
+ /***/ }),
11279
+
11280
+ /***/ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts":
11281
+ /*!****************************************************************************!*\
11282
+ !*** ./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts ***!
11283
+ \****************************************************************************/
11284
+ /*! no static exports found */
11285
+ /***/ (function(module, exports, __webpack_require__) {
11286
+
11287
+ "use strict";
11288
+
11289
+ Object.defineProperty(exports, "__esModule", { value: true });
11290
+ exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = void 0;
11291
+ var getEntityFromElement_1 = __webpack_require__(/*! ./getEntityFromElement */ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts");
11292
+ var getEntitySelector_1 = __webpack_require__(/*! ./getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
11293
+ var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
11294
+ var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
11295
+ var EntityPlaceHolderTagName = 'ENTITY-PLACEHOLDER';
11296
+ /**
11297
+ * Create a placeholder comment node for entity
11298
+ * @param entity The entity to create placeholder from
11299
+ * @returns A placeholder comment node as
11300
+ */
11301
+ function createEntityPlaceholder(entity) {
11302
+ var placeholder = entity.wrapper.ownerDocument.createElement(EntityPlaceHolderTagName);
11303
+ placeholder.id = entity.id;
11304
+ return placeholder;
11305
+ }
11306
+ exports.createEntityPlaceholder = createEntityPlaceholder;
11307
+ /**
11308
+ * Move content from a container into a new Document fragment, and try keep entities to be reusable by creating placeholder
11309
+ * for them in the document fragment.
11310
+ * If an entity is directly under root container, the whole entity can be reused and no need to move it at all.
11311
+ * If an entity is not directly under root container, it is still reusable, but it may need some movement.
11312
+ * In any case, entities will be replaced with a placeholder in the target document fragment.
11313
+ * We will use an entity map (the "entities" parameter) to save the map from entity id to its wrapper element.
11314
+ * @param root The root element
11315
+ * @param entities A map from entity id to entity wrapper element
11316
+ * @returns A new document fragment contains all the content and entity placeholders
11317
+ */
11318
+ function moveContentWithEntityPlaceholders(root, entities) {
11319
+ var entitySelector = (0, getEntitySelector_1.default)();
11320
+ var fragment = root.ownerDocument.createDocumentFragment();
11321
+ var next = null;
11322
+ var _loop_1 = function (child) {
11323
+ var entity;
11324
+ var nodeToAppend = child;
11325
+ next = child.nextSibling;
11326
+ if ((0, safeInstanceOf_1.default)(child, 'HTMLElement')) {
11327
+ if ((entity = (0, getEntityFromElement_1.default)(child))) {
11328
+ nodeToAppend = getPlaceholder(entity, entities);
11329
+ }
11330
+ else {
11331
+ child.querySelectorAll(entitySelector).forEach(function (wrapper) {
11332
+ var _a;
11333
+ if ((entity = (0, getEntityFromElement_1.default)(wrapper))) {
11334
+ var placeholder = getPlaceholder(entity, entities);
11335
+ (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(placeholder, wrapper);
11336
+ }
11337
+ });
11338
+ }
11339
+ }
11340
+ fragment.appendChild(nodeToAppend);
11341
+ };
11342
+ for (var child = root.firstChild; child; child = next) {
11343
+ _loop_1(child);
11344
+ }
11345
+ fragment.normalize();
11346
+ return fragment;
11347
+ }
11348
+ exports.moveContentWithEntityPlaceholders = moveContentWithEntityPlaceholders;
11349
+ /**
11350
+ * Restore HTML content from a document fragment that may contain entity placeholders.
11351
+ * @param source Source document fragment that contains HTML content and entity placeholders
11352
+ * @param target Target container, usually to be editor root container
11353
+ * @param entities A map from entity id to entity wrapper, used for reusing existing DOM structure for entity
11354
+ * @param insertClonedNode When pass true, merge with a cloned copy of the nodes from source fragment rather than the nodes themselves @default false
11355
+ */
11356
+ function restoreContentWithEntityPlaceholder(source, target, entities, insertClonedNode) {
11357
+ var anchor = target.firstChild;
11358
+ entities = entities || {};
11359
+ var _loop_2 = function (current) {
11360
+ var wrapper = null;
11361
+ var next = current.nextSibling;
11362
+ var id = tryGetIdFromEntityPlaceholder(current);
11363
+ if (id && (wrapper = entities[current.id])) {
11364
+ anchor = removeUntil(anchor, wrapper);
11365
+ if (anchor) {
11366
+ anchor = anchor.nextSibling;
11367
+ }
11368
+ else {
11369
+ target.appendChild(wrapper);
11370
+ }
11371
+ }
11372
+ else {
11373
+ var nodeToInsert = insertClonedNode ? current.cloneNode(true /*deep*/) : current;
11374
+ target.insertBefore(nodeToInsert, anchor);
11375
+ if ((0, safeInstanceOf_1.default)(nodeToInsert, 'HTMLElement')) {
11376
+ nodeToInsert.querySelectorAll(EntityPlaceHolderTagName).forEach(function (placeholder) {
11377
+ var _a;
11378
+ wrapper = entities[placeholder.id];
11379
+ if (wrapper) {
11380
+ (_a = placeholder.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(wrapper, placeholder);
11381
+ }
11382
+ });
11383
+ }
11384
+ }
11385
+ current = next;
11386
+ out_current_1 = current;
11387
+ };
11388
+ var out_current_1;
11389
+ for (var current = source.firstChild; current;) {
11390
+ _loop_2(current);
11391
+ current = out_current_1;
11392
+ }
11393
+ removeUntil(anchor);
11394
+ }
11395
+ exports.restoreContentWithEntityPlaceholder = restoreContentWithEntityPlaceholder;
11396
+ function removeUntil(anchor, nodeToStop) {
11397
+ var _a;
11398
+ while (anchor && (!nodeToStop || anchor != nodeToStop)) {
11399
+ var nodeToRemove = anchor;
11400
+ anchor = anchor.nextSibling;
11401
+ (_a = nodeToRemove.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(nodeToRemove);
11402
+ }
11403
+ return anchor;
11404
+ }
11405
+ function tryGetIdFromEntityPlaceholder(node) {
11406
+ return (0, getTagOfNode_1.default)(node) == EntityPlaceHolderTagName ? node.id : null;
11407
+ }
11408
+ function getPlaceholder(entity, entities) {
11409
+ var placeholder = createEntityPlaceholder(entity);
11410
+ entities[entity.id] = entity.wrapper;
11411
+ return placeholder;
11412
+ }
11413
+
11414
+
11214
11415
  /***/ }),
11215
11416
 
11216
11417
  /***/ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts":
@@ -12262,8 +12463,8 @@ exports.isCssVariable = isCssVariable;
12262
12463
 
12263
12464
  Object.defineProperty(exports, "__esModule", { value: true });
12264
12465
  exports.getIntersectedRect = exports.moveChildNodes = exports.KnownCreateElementData = exports.createElement = exports.matchesSelector = exports.setColor = exports.getInnerHTML = exports.readFile = exports.safeInstanceOf = exports.normalizeRect = exports.splitTextNode = exports.getLastLeafNode = exports.getFirstLeafNode = exports.getPreviousLeafSibling = exports.getNextLeafSibling = exports.wrap = exports.unwrap = exports.splitBalancedNodeRange = exports.splitParentNode = exports.queryElements = exports.matchLink = exports.isVoidHtmlElement = exports.isNodeEmpty = exports.isBlockElement = exports.getTagOfNode = exports.PendableFormatCommandMap = exports.getPendableFormatState = exports.getComputedStyle = exports.getComputedStyles = exports.fromHtml = exports.findClosestElementAncestor = exports.contains = exports.collapseNodes = exports.changeElementTag = exports.applyFormat = exports.getBrowserInfo = exports.Browser = exports.extractClipboardItemsForIE = exports.extractClipboardItems = exports.extractClipboardEvent = exports.applyTextStyle = exports.PartialInlineElement = exports.NodeInlineElement = exports.LinkInlineElement = exports.ImageInlineElement = exports.getInlineElementAtNode = exports.PositionContentSearcher = exports.ContentTraverser = exports.getFirstLastBlockElement = exports.getBlockElementAtNode = void 0;
12265
- exports.adjustInsertPosition = exports.removeImportantStyleRule = exports.setStyles = exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = exports.cacheGetEventData = exports.getEntitySelector = exports.getEntityFromElement = exports.commitEntity = exports.chainSanitizerCallback = exports.createDefaultHtmlSanitizerOptions = exports.getInheritableStyles = exports.HtmlSanitizer = exports.canUndoAutoComplete = exports.createSnapshots = exports.moveCurrentSnapsnot = exports.moveCurrentSnapshot = exports.clearProceedingSnapshotsV2 = exports.clearProceedingSnapshots = exports.canMoveCurrentSnapshot = exports.addSnapshotV2 = exports.addSnapshot = exports.addRangeToSelection = exports.setHtmlWithMetadata = exports.setHtmlWithSelectionPath = exports.getHtmlWithSelectionPath = exports.getSelectionPath = exports.isPositionAtBeginningOf = exports.getPositionRect = exports.createRange = exports.Position = exports.mergeBlocksInRegion = exports.getSelectionRangeInRegion = exports.isNodeInRegion = exports.collapseNodesInRegion = exports.getSelectedBlockElementsInRegion = exports.getRegionsFromRange = exports.saveTableCellMetadata = exports.getTableFormatInfo = exports.setListItemStyle = exports.VListChain = exports.createVListFromRegion = exports.VListItem = exports.VList = exports.isWholeTableSelected = exports.VTable = exports.isNodeAfter = void 0;
12266
- exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = void 0;
12466
+ exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = exports.cacheGetEventData = exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = exports.getEntitySelector = exports.getEntityFromElement = exports.commitEntity = exports.chainSanitizerCallback = exports.createDefaultHtmlSanitizerOptions = exports.getInheritableStyles = exports.HtmlSanitizer = exports.canUndoAutoComplete = exports.createSnapshots = exports.moveCurrentSnapsnot = exports.moveCurrentSnapshot = exports.clearProceedingSnapshotsV2 = exports.clearProceedingSnapshots = exports.canMoveCurrentSnapshot = exports.addSnapshotV2 = exports.addSnapshot = exports.addRangeToSelection = exports.setHtmlWithMetadata = exports.setHtmlWithSelectionPath = exports.getHtmlWithSelectionPath = exports.getSelectionPath = exports.isPositionAtBeginningOf = exports.getPositionRect = exports.createRange = exports.Position = exports.mergeBlocksInRegion = exports.getSelectionRangeInRegion = exports.isNodeInRegion = exports.collapseNodesInRegion = exports.getSelectedBlockElementsInRegion = exports.getRegionsFromRange = exports.saveTableCellMetadata = exports.getTableFormatInfo = exports.setListItemStyle = exports.VListChain = exports.createVListFromRegion = exports.VListItem = exports.VList = exports.isWholeTableSelected = exports.VTable = exports.isNodeAfter = void 0;
12467
+ exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.removeGlobalCssStyle = exports.setGlobalCssStyles = exports.removeImportantStyleRule = exports.setStyles = void 0;
12267
12468
  var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
12268
12469
  Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
12269
12470
  var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
@@ -12435,6 +12636,10 @@ var getEntityFromElement_1 = __webpack_require__(/*! ./entity/getEntityFromEleme
12435
12636
  Object.defineProperty(exports, "getEntityFromElement", { enumerable: true, get: function () { return getEntityFromElement_1.default; } });
12436
12637
  var getEntitySelector_1 = __webpack_require__(/*! ./entity/getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
12437
12638
  Object.defineProperty(exports, "getEntitySelector", { enumerable: true, get: function () { return getEntitySelector_1.default; } });
12639
+ var entityPlaceholderUtils_1 = __webpack_require__(/*! ./entity/entityPlaceholderUtils */ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts");
12640
+ Object.defineProperty(exports, "createEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.createEntityPlaceholder; } });
12641
+ Object.defineProperty(exports, "moveContentWithEntityPlaceholders", { enumerable: true, get: function () { return entityPlaceholderUtils_1.moveContentWithEntityPlaceholders; } });
12642
+ Object.defineProperty(exports, "restoreContentWithEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.restoreContentWithEntityPlaceholder; } });
12438
12643
  var cacheGetEventData_1 = __webpack_require__(/*! ./event/cacheGetEventData */ "./packages/roosterjs-editor-dom/lib/event/cacheGetEventData.ts");
12439
12644
  Object.defineProperty(exports, "cacheGetEventData", { enumerable: true, get: function () { return cacheGetEventData_1.default; } });
12440
12645
  var clearEventDataCache_1 = __webpack_require__(/*! ./event/clearEventDataCache */ "./packages/roosterjs-editor-dom/lib/event/clearEventDataCache.ts");
@@ -12451,6 +12656,10 @@ var setStyles_1 = __webpack_require__(/*! ./style/setStyles */ "./packages/roost
12451
12656
  Object.defineProperty(exports, "setStyles", { enumerable: true, get: function () { return setStyles_1.default; } });
12452
12657
  var removeImportantStyleRule_1 = __webpack_require__(/*! ./style/removeImportantStyleRule */ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts");
12453
12658
  Object.defineProperty(exports, "removeImportantStyleRule", { enumerable: true, get: function () { return removeImportantStyleRule_1.default; } });
12659
+ var setGlobalCssStyles_1 = __webpack_require__(/*! ./style/setGlobalCssStyles */ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts");
12660
+ Object.defineProperty(exports, "setGlobalCssStyles", { enumerable: true, get: function () { return setGlobalCssStyles_1.default; } });
12661
+ var removeGlobalCssStyle_1 = __webpack_require__(/*! ./style/removeGlobalCssStyle */ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts");
12662
+ Object.defineProperty(exports, "removeGlobalCssStyle", { enumerable: true, get: function () { return removeGlobalCssStyle_1.default; } });
12454
12663
  var adjustInsertPosition_1 = __webpack_require__(/*! ./edit/adjustInsertPosition */ "./packages/roosterjs-editor-dom/lib/edit/adjustInsertPosition.ts");
12455
12664
  Object.defineProperty(exports, "adjustInsertPosition", { enumerable: true, get: function () { return adjustInsertPosition_1.default; } });
12456
12665
  var deleteSelectedContent_1 = __webpack_require__(/*! ./edit/deleteSelectedContent */ "./packages/roosterjs-editor-dom/lib/edit/deleteSelectedContent.ts");
@@ -13811,6 +14020,17 @@ function createListChainName() {
13811
14020
 
13812
14021
  "use strict";
13813
14022
 
14023
+ var __assign = (this && this.__assign) || function () {
14024
+ __assign = Object.assign || function(t) {
14025
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14026
+ s = arguments[i];
14027
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
14028
+ t[p] = s[p];
14029
+ }
14030
+ return t;
14031
+ };
14032
+ return __assign.apply(this, arguments);
14033
+ };
13814
14034
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13815
14035
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
13816
14036
  if (ar || !(i in from)) {
@@ -13824,6 +14044,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13824
14044
  exports.ListStyleDefinitionMetadata = void 0;
13825
14045
  var contains_1 = __webpack_require__(/*! ../utils/contains */ "./packages/roosterjs-editor-dom/lib/utils/contains.ts");
13826
14046
  var getListTypeFromNode_1 = __webpack_require__(/*! ./getListTypeFromNode */ "./packages/roosterjs-editor-dom/lib/list/getListTypeFromNode.ts");
14047
+ var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
13827
14048
  var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
13828
14049
  var isBlockElement_1 = __webpack_require__(/*! ../utils/isBlockElement */ "./packages/roosterjs-editor-dom/lib/utils/isBlockElement.ts");
13829
14050
  var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
@@ -13831,6 +14052,7 @@ var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./pac
13831
14052
  var setBulletListMarkers_1 = __webpack_require__(/*! ./setBulletListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setBulletListMarkers.ts");
13832
14053
  var setListItemStyle_1 = __webpack_require__(/*! ./setListItemStyle */ "./packages/roosterjs-editor-dom/lib/list/setListItemStyle.ts");
13833
14054
  var setNumberingListMarkers_1 = __webpack_require__(/*! ./setNumberingListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setNumberingListMarkers.ts");
14055
+ var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
13834
14056
  var toArray_1 = __webpack_require__(/*! ../jsUtils/toArray */ "./packages/roosterjs-editor-dom/lib/jsUtils/toArray.ts");
13835
14057
  var unwrap_1 = __webpack_require__(/*! ../utils/unwrap */ "./packages/roosterjs-editor-dom/lib/utils/unwrap.ts");
13836
14058
  var wrap_1 = __webpack_require__(/*! ../utils/wrap */ "./packages/roosterjs-editor-dom/lib/utils/wrap.ts");
@@ -13840,6 +14062,8 @@ var orderListStyles = [null, 'lower-alpha', 'lower-roman'];
13840
14062
  var unorderedListStyles = ['disc', 'circle', 'square'];
13841
14063
  var MARGIN_BASE = '0in 0in 0in 0.5in';
13842
14064
  var NEGATIVE_MARGIN = '-.25in';
14065
+ var stylesToInherit = ['font-size', 'font-family', 'color'];
14066
+ var attrsToInherit = ['data-ogsc', 'data-ogsb', 'data-ogac', 'data-ogab'];
13843
14067
  /**
13844
14068
  * @internal
13845
14069
  * The definition for the number of BulletListType or NumberingListType
@@ -14038,6 +14262,7 @@ var VListItem = /** @class */ (function () {
14038
14262
  * sure the direct parent of this list matches the list types when writing back.
14039
14263
  */
14040
14264
  VListItem.prototype.writeBack = function (listStack, originalRoot, shouldReuseAllAncestorListElements) {
14265
+ var _this = this;
14041
14266
  var _a;
14042
14267
  if (shouldReuseAllAncestorListElements === void 0) { shouldReuseAllAncestorListElements = false; }
14043
14268
  var nextLevel = 1;
@@ -14096,12 +14321,43 @@ var VListItem = /** @class */ (function () {
14096
14321
  this.node.style.setProperty('display', this.dummy ? 'block' : null);
14097
14322
  // 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
14098
14323
  if (this.listTypes.length > 1) {
14099
- var stylesToInherit = ['font-size', 'font-family', 'color'];
14100
- (0, setListItemStyle_1.default)(this.node, stylesToInherit);
14324
+ (0, setListItemStyle_1.default)(this.node, stylesToInherit, true /*isCssStyle*/);
14325
+ (0, setListItemStyle_1.default)(this.node, attrsToInherit, false /*isCssStyle*/);
14101
14326
  }
14102
14327
  // 5. If this is not a list item now, need to unwrap the LI node and do proper handling
14103
14328
  if (this.listTypes.length <= 1) {
14104
- wrapIfNotBlockNode((0, getTagOfNode_1.default)(this.node) == 'LI' ? getChildrenAndUnwrap(this.node) : [this.node], true /*checkFirst*/, true /*checkLast*/);
14329
+ // If original <LI> node has styles for font and color, we need to apply it to new parent
14330
+ var isLi = (0, getTagOfNode_1.default)(this.node) == 'LI';
14331
+ var stylesToApply = isLi
14332
+ ? {
14333
+ 'font-family': this.node.style.fontFamily,
14334
+ 'font-size': this.node.style.fontSize,
14335
+ color: this.node.style.color,
14336
+ }
14337
+ : undefined;
14338
+ var childNodes = isLi ? getChildrenAndUnwrap(this.node) : [this.node];
14339
+ if (stylesToApply) {
14340
+ var _loop_1 = function (i) {
14341
+ if ((0, safeInstanceOf_1.default)(childNodes[i], 'Text')) {
14342
+ childNodes[i] = (0, wrap_1.default)(childNodes[i], 'span');
14343
+ }
14344
+ var node = childNodes[i];
14345
+ if ((0, safeInstanceOf_1.default)(node, 'HTMLElement')) {
14346
+ var styles = __assign(__assign({}, stylesToApply), (0, getStyles_1.default)(node));
14347
+ (0, setStyles_1.default)(node, styles);
14348
+ attrsToInherit.forEach(function (attr) {
14349
+ var attrValue = _this.node.getAttribute(attr);
14350
+ if (attrValue) {
14351
+ node.setAttribute(attr, attrValue);
14352
+ }
14353
+ });
14354
+ }
14355
+ };
14356
+ for (var i = 0; i < childNodes.length; i++) {
14357
+ _loop_1(i);
14358
+ }
14359
+ }
14360
+ wrapIfNotBlockNode(childNodes, true /*checkFirst*/, true /*checkLast*/);
14105
14361
  }
14106
14362
  };
14107
14363
  /**
@@ -14548,18 +14804,17 @@ var bulletListStyle = (_a = {},
14548
14804
  Object.defineProperty(exports, "__esModule", { value: true });
14549
14805
  var ContentTraverser_1 = __webpack_require__(/*! ../contentTraverser/ContentTraverser */ "./packages/roosterjs-editor-dom/lib/contentTraverser/ContentTraverser.ts");
14550
14806
  var findClosestElementAncestor_1 = __webpack_require__(/*! ../utils/findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
14551
- var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
14552
14807
  var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
14553
- var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
14554
14808
  /**
14555
14809
  * Set the Style of a List Item provided, with the styles that the inline child elements have
14556
14810
  * If the child inline elements have different styles, it will not modify the styles of the list item
14557
14811
  * @param element the LI Element to set the styles
14558
14812
  * @param styles The styles that should be applied to the element.
14813
+ * @param isCssStyle True means the given styles are CSS style names, false means they are HTML attributes @default true
14559
14814
  */
14560
- function setListItemStyle(element, styles) {
14561
- var elementsStyles = getInlineChildElementsStyle(element, styles);
14562
- var stylesToApply = (0, getStyles_1.default)(element);
14815
+ function setListItemStyle(element, styles, isCssStyle) {
14816
+ if (isCssStyle === void 0) { isCssStyle = true; }
14817
+ var elementsStyles = getInlineChildElementsStyle(element, styles, isCssStyle);
14563
14818
  styles.forEach(function (styleName) {
14564
14819
  var styleValues = elementsStyles.map(function (style) {
14565
14820
  return style[styleName] !== undefined ? style[styleName] : '';
@@ -14567,39 +14822,53 @@ function setListItemStyle(element, styles) {
14567
14822
  if (styleValues &&
14568
14823
  (styleValues.length == 1 || new Set(styleValues).size == 1) &&
14569
14824
  styleValues[0]) {
14570
- stylesToApply[styleName] = styleValues[0];
14825
+ if (isCssStyle) {
14826
+ element.style.setProperty(styleName, styleValues[0]);
14827
+ }
14828
+ else {
14829
+ element.setAttribute(styleName, styleValues[0]);
14830
+ }
14571
14831
  }
14572
14832
  });
14573
- (0, setStyles_1.default)(element, stylesToApply);
14574
14833
  }
14575
14834
  exports.default = setListItemStyle;
14576
- function getInlineChildElementsStyle(element, styles) {
14577
- var _a;
14835
+ function getInlineChildElementsStyle(element, styles, isCssStyle) {
14836
+ var _a, _b;
14578
14837
  var result = [];
14579
14838
  var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
14580
14839
  var currentInlineElement = null;
14581
14840
  var _loop_1 = function () {
14582
14841
  currentInlineElement = contentTraverser.currentInlineElement;
14583
14842
  var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
14584
- var currentStyle = {};
14843
+ var currentStyle = null;
14585
14844
  currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
14586
- // we should consider of when it is the single childnode of element, the parentNode's style should add
14587
- // such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
14588
- while (currentNode &&
14589
- currentNode !== element &&
14590
- (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
14845
+ var _loop_2 = function () {
14846
+ var element_1 = currentNode;
14591
14847
  styles.forEach(function (styleName) {
14592
- var styleValue = currentNode.style.getPropertyValue(styleName);
14848
+ var styleValue = isCssStyle
14849
+ ? element_1.style.getPropertyValue(styleName)
14850
+ : element_1.getAttribute(styleName);
14851
+ if (!currentStyle) {
14852
+ currentStyle = {};
14853
+ }
14593
14854
  if (styleValue && !currentStyle[styleName]) {
14594
14855
  currentStyle[styleName] = styleValue;
14595
14856
  }
14596
14857
  });
14597
- if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _a === void 0 ? void 0 : _a.childNodes.length) === 1) {
14858
+ if (((_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.childNodes.length) === 1) {
14598
14859
  currentNode = currentNode.parentNode;
14599
14860
  }
14600
14861
  else {
14601
14862
  currentNode = null;
14602
14863
  }
14864
+ };
14865
+ // we should consider of when it is the single child node of element, the parentNode's style should add
14866
+ // such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
14867
+ while (currentNode &&
14868
+ currentNode !== element &&
14869
+ (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement') &&
14870
+ (result.length == 0 || (((_a = currentNode.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) || 0) > 0)) {
14871
+ _loop_2();
14603
14872
  }
14604
14873
  if (currentStyle) {
14605
14874
  result.push(currentStyle);
@@ -16304,6 +16573,33 @@ function getStyles(element) {
16304
16573
  exports.default = getStyles;
16305
16574
 
16306
16575
 
16576
+ /***/ }),
16577
+
16578
+ /***/ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts":
16579
+ /*!*************************************************************************!*\
16580
+ !*** ./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts ***!
16581
+ \*************************************************************************/
16582
+ /*! no static exports found */
16583
+ /***/ (function(module, exports, __webpack_require__) {
16584
+
16585
+ "use strict";
16586
+
16587
+ /**
16588
+ * Remove a css rule style from a style sheet
16589
+ * @param doc The document object
16590
+ * @param styleId the ID of the style tag
16591
+ */
16592
+ Object.defineProperty(exports, "__esModule", { value: true });
16593
+ function removeGlobalCssStyle(doc, styleId) {
16594
+ var _a;
16595
+ var styleTag = doc.getElementById(styleId);
16596
+ if (styleTag) {
16597
+ (_a = styleTag.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(styleTag);
16598
+ }
16599
+ }
16600
+ exports.default = removeGlobalCssStyle;
16601
+
16602
+
16307
16603
  /***/ }),
16308
16604
 
16309
16605
  /***/ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts":
@@ -16341,6 +16637,38 @@ function removeImportantStyleRule(element, styleProperties) {
16341
16637
  exports.default = removeImportantStyleRule;
16342
16638
 
16343
16639
 
16640
+ /***/ }),
16641
+
16642
+ /***/ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts":
16643
+ /*!***********************************************************************!*\
16644
+ !*** ./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts ***!
16645
+ \***********************************************************************/
16646
+ /*! no static exports found */
16647
+ /***/ (function(module, exports, __webpack_require__) {
16648
+
16649
+ "use strict";
16650
+
16651
+ /**
16652
+ * Add global css styles
16653
+ * @param doc The document object
16654
+ * @param cssRule The css rule that must added to the selection
16655
+ * @param editorId Te id of the editor
16656
+ * @param styleId the ID of the style tag
16657
+ */
16658
+ Object.defineProperty(exports, "__esModule", { value: true });
16659
+ function setGlobalCssStyles(doc, cssRule, styleId) {
16660
+ var _a;
16661
+ var styleTag = doc.getElementById(styleId);
16662
+ if (!styleTag) {
16663
+ styleTag = doc.createElement('style');
16664
+ styleTag.id = styleId;
16665
+ doc.head.appendChild(styleTag);
16666
+ }
16667
+ (_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
16668
+ }
16669
+ exports.default = setGlobalCssStyles;
16670
+
16671
+
16344
16672
  /***/ }),
16345
16673
 
16346
16674
  /***/ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts":
@@ -17908,7 +18236,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17908
18236
  exports.KnownCreateElementData = void 0;
17909
18237
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
17910
18238
  var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
17911
- var Browser_1 = __webpack_require__(/*! ./Browser */ "./packages/roosterjs-editor-dom/lib/utils/Browser.ts");
17912
18239
  /**
17913
18240
  * All known CreateElementData used by roosterjs to create elements
17914
18241
  */
@@ -17916,9 +18243,10 @@ exports.KnownCreateElementData = (_a = {},
17916
18243
  _a[0 /* None */] = { tag: '' },
17917
18244
  // Edge can sometimes lose current format when Enter to new line.
17918
18245
  // So here we add an extra SPAN for Edge to workaround this bug
17919
- _a[1 /* EmptyLine */] = Browser_1.Browser.isEdge
17920
- ? { tag: 'div', children: [{ tag: 'span', children: [{ tag: 'br' }] }] }
17921
- : { tag: 'div', children: [{ tag: 'br' }] },
18246
+ _a[1 /* EmptyLine */] = {
18247
+ tag: 'div',
18248
+ children: [{ tag: 'span', children: [{ tag: 'br' }] }],
18249
+ },
17922
18250
  _a[2 /* BlockquoteWrapper */] = {
17923
18251
  tag: 'blockquote',
17924
18252
  style: 'margin-top:0;margin-bottom:0',
@@ -17936,8 +18264,14 @@ exports.KnownCreateElementData = (_a = {},
17936
18264
  style: 'position: fixed; width: 0; height: 0',
17937
18265
  },
17938
18266
  _a[6 /* ImageEditWrapper */] = {
17939
- tag: 'div',
17940
- style: 'width:100%;height:100%;position:relative;overflow:hidden',
18267
+ tag: 'span',
18268
+ style: 'max-width:100%;position:fixed',
18269
+ children: [
18270
+ {
18271
+ tag: 'div',
18272
+ style: 'width:100%;height:100%;position:relative;overflow:hidden',
18273
+ },
18274
+ ],
17941
18275
  },
17942
18276
  _a[7 /* TableHorizontalResizer */] = {
17943
18277
  tag: 'div',
@@ -19514,31 +19848,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
19514
19848
  __exportStar(__webpack_require__(/*! ./plugins/ImageResize/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageResize/index.ts"), exports);
19515
19849
 
19516
19850
 
19517
- /***/ }),
19518
-
19519
- /***/ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts":
19520
- /*!*****************************************************************!*\
19521
- !*** ./packages/roosterjs-editor-plugins/lib/ImageSelection.ts ***!
19522
- \*****************************************************************/
19523
- /*! no static exports found */
19524
- /***/ (function(module, exports, __webpack_require__) {
19525
-
19526
- "use strict";
19527
-
19528
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19529
- if (k2 === undefined) k2 = k;
19530
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
19531
- }) : (function(o, m, k, k2) {
19532
- if (k2 === undefined) k2 = k;
19533
- o[k2] = m[k];
19534
- }));
19535
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19536
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19537
- };
19538
- Object.defineProperty(exports, "__esModule", { value: true });
19539
- __exportStar(__webpack_require__(/*! ./plugins/ImageSelection/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts"), exports);
19540
-
19541
-
19542
19851
  /***/ }),
19543
19852
 
19544
19853
  /***/ "./packages/roosterjs-editor-plugins/lib/Paste.ts":
@@ -19699,7 +20008,6 @@ __exportStar(__webpack_require__(/*! ./TableResize */ "./packages/roosterjs-edit
19699
20008
  __exportStar(__webpack_require__(/*! ./Watermark */ "./packages/roosterjs-editor-plugins/lib/Watermark.ts"), exports);
19700
20009
  __exportStar(__webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/TableCellSelection.ts"), exports);
19701
20010
  __exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-editor-plugins/lib/AutoFormat.ts"), exports);
19702
- __exportStar(__webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts"), exports);
19703
20011
 
19704
20012
 
19705
20013
  /***/ }),
@@ -20360,6 +20668,8 @@ var getAutoBulletListStyle_1 = __webpack_require__(/*! ../utils/getAutoBulletLis
20360
20668
  var getAutoNumberingListStyle_1 = __webpack_require__(/*! ../utils/getAutoNumberingListStyle */ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/getAutoNumberingListStyle.ts");
20361
20669
  var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
20362
20670
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
20671
+ var PREVIOUS_BLOCK_CACHE_KEY = 'previousBlock';
20672
+ var NEXT_BLOCK_CACHE_KEY = 'nextBlock';
20363
20673
  var ListStyleDefinitionMetadata = (0, roosterjs_editor_dom_1.createObjectDefinition)({
20364
20674
  orderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 20 /* Max */),
20365
20675
  unorderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 9 /* Max */),
@@ -20589,10 +20899,10 @@ var AutoNumberingList = {
20589
20899
  },
20590
20900
  };
20591
20901
  var getPreviousListItem = function (editor, textRange) {
20592
- var _a;
20593
- var previousNode = (_a = editor
20902
+ var blockElement = editor
20594
20903
  .getBodyTraverser(textRange === null || textRange === void 0 ? void 0 : textRange.startContainer)
20595
- .getPreviousBlockElement()) === null || _a === void 0 ? void 0 : _a.collapseToSingleElement();
20904
+ .getPreviousBlockElement();
20905
+ var previousNode = blockElement === null || blockElement === void 0 ? void 0 : blockElement.getEndNode();
20596
20906
  return (0, roosterjs_editor_dom_1.getTagOfNode)(previousNode) === 'LI' ? previousNode : undefined;
20597
20907
  };
20598
20908
  var getPreviousListType = function (editor, textRange, listType) {
@@ -20694,6 +21004,57 @@ function shouldTriggerList(event, editor, getListStyle, listType) {
20694
21004
  listStyle &&
20695
21005
  shouldTriggerNewListStyle);
20696
21006
  }
21007
+ /**
21008
+ * MergeListOnBackspaceAfterList edit feature, provides the ability to merge list on backspace on block after a list.
21009
+ */
21010
+ var MergeListOnBackspaceAfterList = {
21011
+ keys: [8 /* BACKSPACE */],
21012
+ shouldHandleEvent: function (event, editor) {
21013
+ var _a, _b;
21014
+ var target = editor.getElementAtCursor();
21015
+ if (target) {
21016
+ var cursorBlock = (_a = editor.getBlockElementAtNode(target)) === null || _a === void 0 ? void 0 : _a.getStartNode();
21017
+ var previousBlock_1 = (_b = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.previousElementSibling) !== null && _b !== void 0 ? _b : null;
21018
+ if (isList(previousBlock_1)) {
21019
+ var range = editor.getSelectionRange();
21020
+ var searcher = editor.getContentSearcherOfCursor(event);
21021
+ var textBeforeCursor = searcher === null || searcher === void 0 ? void 0 : searcher.getSubStringBefore(4);
21022
+ var nearestInline = searcher === null || searcher === void 0 ? void 0 : searcher.getNearestNonTextInlineElement();
21023
+ if (range && range.collapsed && textBeforeCursor === '' && !nearestInline) {
21024
+ var tempBlock = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.nextElementSibling;
21025
+ var nextBlock_1 = isList(tempBlock) ? tempBlock : tempBlock === null || tempBlock === void 0 ? void 0 : tempBlock.firstChild;
21026
+ if (isList(nextBlock_1) &&
21027
+ (0, roosterjs_editor_dom_1.getTagOfNode)(previousBlock_1) == (0, roosterjs_editor_dom_1.getTagOfNode)(nextBlock_1)) {
21028
+ var element = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return previousBlock_1; });
21029
+ var nextElement = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return nextBlock_1; });
21030
+ return !!element && !!nextElement;
21031
+ }
21032
+ }
21033
+ }
21034
+ }
21035
+ return false;
21036
+ },
21037
+ handleEvent: function (event, editor) {
21038
+ editor.runAsync(function (editor) {
21039
+ var previousList = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return null; });
21040
+ var targetBlock = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return null; });
21041
+ var rangeBeforeWriteBack = editor.getSelectionRange();
21042
+ if (previousList && targetBlock && rangeBeforeWriteBack) {
21043
+ var fvList = new roosterjs_editor_dom_1.VList(previousList);
21044
+ fvList.mergeVList(new roosterjs_editor_dom_1.VList(targetBlock));
21045
+ var span = editor.getDocument().createElement('span');
21046
+ span.id = 'restoreRange';
21047
+ rangeBeforeWriteBack.insertNode(span);
21048
+ fvList.writeBack();
21049
+ span = editor.queryElements('#restoreRange')[0];
21050
+ if (span.parentElement) {
21051
+ editor.select(new roosterjs_editor_dom_1.Position(span, -3 /* After */));
21052
+ span.parentElement.removeChild(span);
21053
+ }
21054
+ }
21055
+ });
21056
+ },
21057
+ };
20697
21058
  /**
20698
21059
  * @internal
20699
21060
  */
@@ -20708,7 +21069,12 @@ exports.ListFeatures = {
20708
21069
  maintainListChainWhenDelete: MaintainListChainWhenDelete,
20709
21070
  autoNumberingList: AutoNumberingList,
20710
21071
  autoBulletList: AutoBulletList,
21072
+ mergeListOnBackspaceAfterList: MergeListOnBackspaceAfterList,
20711
21073
  };
21074
+ function isList(element) {
21075
+ return (!!element &&
21076
+ ((0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLOListElement') || (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLUListElement')));
21077
+ }
20712
21078
 
20713
21079
 
20714
21080
  /***/ }),
@@ -21656,10 +22022,24 @@ function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previous
21656
22022
  }
21657
22023
  }
21658
22024
  var isDoubleParenthesis = trigger[0] === '(' && trigger[trigger.length - 1] === ')';
21659
- var numberingType = identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle);
22025
+ var numberingType = isValidNumbering(trigger, isDoubleParenthesis)
22026
+ ? identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle)
22027
+ : null;
21660
22028
  return numberingType;
21661
22029
  }
21662
22030
  exports.default = getAutoNumberingListStyle;
22031
+ /**
22032
+ * Check if index has only numbers or only letters to avoid sequence of character such 1:1. trigger a list.
22033
+ * @param textBeforeCursor
22034
+ * @param isDoubleParenthesis
22035
+ * @returns
22036
+ */
22037
+ function isValidNumbering(textBeforeCursor, isDoubleParenthesis) {
22038
+ var index = isDoubleParenthesis
22039
+ ? textBeforeCursor.slice(1, -1)
22040
+ : textBeforeCursor.slice(0, -1);
22041
+ return Number(index) || /^[A-Za-z\s]*$/.test(index);
22042
+ }
21663
22043
 
21664
22044
 
21665
22045
  /***/ }),
@@ -22313,12 +22693,8 @@ var getGeneratedImageSize_1 = __webpack_require__(/*! ./editInfoUtils/getGenerat
22313
22693
  var Cropper_1 = __webpack_require__(/*! ./imageEditors/Cropper */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Cropper.ts");
22314
22694
  var editInfo_1 = __webpack_require__(/*! ./editInfoUtils/editInfo */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/editInfo.ts");
22315
22695
  var Rotator_1 = __webpack_require__(/*! ./imageEditors/Rotator */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Rotator.ts");
22316
- var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
22317
22696
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
22318
22697
  var Resizer_1 = __webpack_require__(/*! ./imageEditors/Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
22319
- var SHIFT_KEYCODE = 16;
22320
- var CTRL_KEYCODE = 17;
22321
- var ALT_KEYCODE = 18;
22322
22698
  var DIRECTIONS = 8;
22323
22699
  var DirectionRad = (Math.PI * 2) / DIRECTIONS;
22324
22700
  var DirectionOrder = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
@@ -22347,10 +22723,6 @@ var ImageEditHTMLMap = (_a = {},
22347
22723
  _a[4 /* Rotate */] = Rotator_1.getRotateHTML,
22348
22724
  _a[8 /* Crop */] = Cropper_1.getCropHTML,
22349
22725
  _a);
22350
- /**
22351
- * Image edit entity name
22352
- */
22353
- var IMAGE_EDIT_WRAPPER_ENTITY_TYPE = 'IMAGE_EDIT_WRAPPER';
22354
22726
  /**
22355
22727
  * Default background colors for rotate handle
22356
22728
  */
@@ -22378,35 +22750,31 @@ var ImageEdit = /** @class */ (function () {
22378
22750
  * quit editing mode when editor lose focus
22379
22751
  */
22380
22752
  this.onBlur = function () {
22381
- _this.setEditingImage(null);
22753
+ _this.setEditingImage(null, true);
22382
22754
  };
22383
22755
  /**
22384
22756
  * Remove the temp wrapper of the image
22385
- * @param wrapper The wrapper object to remove. If not specified, remove all existing wrappers.
22386
22757
  */
22387
- this.removeWrapper = function (wrapper) {
22388
- var parent = wrapper === null || wrapper === void 0 ? void 0 : wrapper.parentNode;
22389
- var img = wrapper === null || wrapper === void 0 ? void 0 : wrapper.querySelector('img');
22390
- if (img && parent) {
22391
- img.style.position = '';
22392
- img.style.margin = null;
22393
- img.style.textAlign = null;
22394
- parent.insertBefore(img, wrapper);
22395
- parent.removeChild(wrapper);
22758
+ this.removeWrapper = function () {
22759
+ var _a, _b;
22760
+ var doc = _this.editor.getDocument();
22761
+ if (_this.zoomWrapper && ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.contains(_this.zoomWrapper))) {
22762
+ (_b = doc.body) === null || _b === void 0 ? void 0 : _b.removeChild(_this.zoomWrapper);
22763
+ _this.toggleImageVisibility(_this.image, true /** showImage */);
22396
22764
  }
22765
+ _this.wrapper = null;
22766
+ _this.zoomWrapper = null;
22397
22767
  };
22398
22768
  /**
22399
22769
  * Update image edit elements to reflect current editing result
22400
22770
  * @param context
22401
22771
  */
22402
22772
  this.updateWrapper = function (context) {
22403
- var wrapper = _this.getImageWrapper(_this.image);
22773
+ var wrapper = _this.wrapper;
22404
22774
  if (wrapper) {
22405
22775
  // Prepare: get related editing elements
22406
22776
  var cropContainers = getEditElements(wrapper, "r_cropC" /* CropContainer */);
22407
22777
  var cropOverlays = getEditElements(wrapper, "r_cropO" /* CropOverlay */);
22408
- var rotateCenter = getEditElements(wrapper, "r_rotateC" /* RotateCenter */)[0];
22409
- var rotateHandle = getEditElements(wrapper, "r_rotateH" /* RotateHandle */)[0];
22410
22778
  var resizeHandles = getEditElements(wrapper, "r_resizeH" /* ResizeHandle */);
22411
22779
  var cropHandles = getEditElements(wrapper, "r_cropH" /* CropHandle */);
22412
22780
  // Cropping and resizing will show different UI, so check if it is cropping here first
@@ -22425,12 +22793,14 @@ var ImageEdit = /** @class */ (function () {
22425
22793
  wrapper.style.height = getPx(visibleHeight);
22426
22794
  wrapper.style.margin = marginVertical + "px " + marginHorizontal + "px";
22427
22795
  wrapper.style.transform = "rotate(" + angleRad + "rad)";
22796
+ _this.zoomWrapper.style.width = getPx(visibleWidth);
22797
+ _this.zoomWrapper.style.height = getPx(visibleHeight);
22428
22798
  // Update the text-alignment to avoid the image to overflow if the parent element have align center or right
22429
22799
  // or if the direction is Right To Left
22430
22800
  wrapper.style.textAlign = isRtl(wrapper.parentNode) ? 'right' : 'left';
22431
22801
  // Update size of the image
22432
- _this.image.style.width = getPx(originalWidth);
22433
- _this.image.style.height = getPx(originalHeight);
22802
+ _this.clonedImage.style.width = getPx(originalWidth);
22803
+ _this.clonedImage.style.height = getPx(originalHeight);
22434
22804
  if (isCropping) {
22435
22805
  // For crop, we also need to set position of the overlays
22436
22806
  setSize(cropContainers[0], cropLeftPx, cropTopPx, cropRightPx, cropBottomPx, undefined, undefined);
@@ -22442,7 +22812,7 @@ var ImageEdit = /** @class */ (function () {
22442
22812
  }
22443
22813
  else {
22444
22814
  // For rotate/resize, set the margin of the image so that cropped part won't be visible
22445
- _this.image.style.margin = -cropTopPx + "px 0 0 " + -cropLeftPx + "px";
22815
+ _this.clonedImage.style.margin = -cropTopPx + "px 0 0 " + -cropLeftPx + "px";
22446
22816
  // Double check resize
22447
22817
  if ((context === null || context === void 0 ? void 0 : context.elementClass) == "r_resizeH" /* ResizeHandle */) {
22448
22818
  var clientWidth = wrapper.clientWidth;
@@ -22451,7 +22821,6 @@ var ImageEdit = /** @class */ (function () {
22451
22821
  (0, Resizer_1.doubleCheckResize)(_this.editInfo, _this.options.preserveRatio, clientWidth, clientHeight);
22452
22822
  _this.updateWrapper();
22453
22823
  }
22454
- (0, Rotator_1.updateRotateHandlePosition)(_this.editInfo, _this.editor.getRelativeDistanceToEditor(wrapper, true /*addScroll*/), marginVertical, rotateCenter, rotateHandle);
22455
22824
  updateHandleCursor(resizeHandles, angleRad);
22456
22825
  }
22457
22826
  }
@@ -22488,56 +22857,26 @@ var ImageEdit = /** @class */ (function () {
22488
22857
  };
22489
22858
  /**
22490
22859
  * Handle events triggered from editor
22491
- * @param event PluginEvent object
22860
+ * @param e PluginEvent object
22492
22861
  */
22493
22862
  ImageEdit.prototype.onPluginEvent = function (e) {
22494
22863
  switch (e.eventType) {
22864
+ case 22 /* SelectionChanged */:
22865
+ if (e.selectionRangeEx &&
22866
+ e.selectionRangeEx.type === 2 /* ImageSelection */) {
22867
+ this.setEditingImage(e.selectionRangeEx.image, 7 /* ResizeAndRotate */);
22868
+ }
22869
+ break;
22495
22870
  case 5 /* MouseDown */:
22496
22871
  this.setEditingImage(null);
22497
22872
  break;
22498
- case 6 /* MouseUp */:
22499
- var target = e.rawEvent.target;
22500
- if (e.isClicking &&
22501
- e.rawEvent.button == 0 &&
22502
- (0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
22503
- target.isContentEditable &&
22504
- (0, roosterjs_editor_dom_1.matchesSelector)(target, this.options.imageSelector)) {
22505
- this.setEditingImage(target, 7 /* ResizeAndRotate */);
22506
- }
22507
- break;
22508
22873
  case 0 /* KeyDown */:
22509
- var key = e.rawEvent.which;
22510
- if (key == 46 /* DELETE */ || key == 8 /* BACKSPACE */) {
22511
- // Set current editing image to null and select the image if any, and do not prevent default of the event
22512
- // so that browser will delete the selected image for us
22513
- this.setEditingImage(null, true /*selectImage*/);
22514
- }
22515
- else if (key == 27 /* ESCAPE */ && this.image) {
22516
- // Press ESC should cancel current editing operation, resume back to original edit info
22517
- this.editInfo = (0, editInfo_1.getEditInfoFromImage)(this.image);
22518
- this.setEditingImage(null);
22519
- e.rawEvent.preventDefault();
22520
- }
22521
- else if (key != SHIFT_KEYCODE && key != CTRL_KEYCODE && key != ALT_KEYCODE) {
22522
- // For other key, just unselect current image and select it. If this is an input key, the image will be replaced
22523
- this.setEditingImage(null, true /*selectImage*/);
22524
- }
22874
+ this.setEditingImage(null);
22525
22875
  break;
22526
22876
  case 7 /* ContentChanged */:
22527
- if (e.source != "InsertEntity" /* InsertEntity */ ||
22528
- e.data.type != IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
22877
+ if (e.source !== "Format" /* Format */) {
22529
22878
  // After contentChanged event, the current image wrapper may not be valid any more, remove all of them if any
22530
- this.editor.queryElements((0, roosterjs_editor_dom_1.getEntitySelector)(IMAGE_EDIT_WRAPPER_ENTITY_TYPE), this.removeWrapper);
22531
- }
22532
- break;
22533
- case 15 /* EntityOperation */:
22534
- if (e.entity.type == IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
22535
- if (e.operation == 8 /* ReplaceTemporaryContent */) {
22536
- this.removeWrapper(e.entity.wrapper);
22537
- }
22538
- else if (e.operation == 1 /* Click */) {
22539
- e.rawEvent.preventDefault();
22540
- }
22879
+ this.removeWrapper();
22541
22880
  }
22542
22881
  break;
22543
22882
  case 8 /* ExtractContentWithDom */:
@@ -22546,10 +22885,13 @@ var ImageEdit = /** @class */ (function () {
22546
22885
  (0, editInfo_1.deleteEditInfo)(img);
22547
22886
  });
22548
22887
  break;
22888
+ case 14 /* Scroll */:
22889
+ this.setEditingImage(null);
22890
+ break;
22549
22891
  }
22550
22892
  };
22551
22893
  /**
22552
- * Check if the given image edit operation is allowed by this pluign
22894
+ * Check if the given image edit operation is allowed by this plugin
22553
22895
  * @param operation The image edit operation to check
22554
22896
  * @returns True means it is allowed, otherwise false
22555
22897
  */
@@ -22560,16 +22902,13 @@ var ImageEdit = /** @class */ (function () {
22560
22902
  var _this = this;
22561
22903
  var operation = typeof operationOrSelect === 'number' ? operationOrSelect : 0 /* None */;
22562
22904
  var selectImage = typeof operationOrSelect === 'number' ? false : !!operationOrSelect;
22563
- if (this.image) {
22905
+ if (!image && this.image) {
22564
22906
  // When there is image in editing, clean up any cached objects and elements
22565
22907
  this.clearDndHelpers();
22566
22908
  // Apply the changes, and add undo snapshot if necessary
22567
- (0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized);
22909
+ (0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized, this.clonedImage);
22568
22910
  // Remove editing wrapper
22569
- var wrapper = this.getImageWrapper(this.image);
22570
- if (wrapper) {
22571
- this.removeWrapper(wrapper);
22572
- }
22911
+ this.removeWrapper();
22573
22912
  this.editor.addUndoSnapshot(function () { return _this.image; }, "ImageResize" /* ImageResize */);
22574
22913
  if (selectImage) {
22575
22914
  this.editor.select(this.image);
@@ -22577,6 +22916,7 @@ var ImageEdit = /** @class */ (function () {
22577
22916
  this.image = null;
22578
22917
  this.editInfo = null;
22579
22918
  this.lastSrc = null;
22919
+ this.clonedImage = null;
22580
22920
  }
22581
22921
  if (!this.image && (image === null || image === void 0 ? void 0 : image.isContentEditable)) {
22582
22922
  // If there is new image to edit, enter editing mode for this image
@@ -22590,12 +22930,12 @@ var ImageEdit = /** @class */ (function () {
22590
22930
  ((0, canRegenerateImage_1.default)(image) ? operation : 3 /* Resize */) &
22591
22931
  this.allowedOperations;
22592
22932
  // Create and update editing wrapper and elements
22593
- var wrapper = this.createWrapper(operation);
22933
+ this.createWrapper(operation);
22594
22934
  this.updateWrapper();
22595
22935
  // Init drag and drop
22596
22936
  this.dndHelpers = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], this.createDndHelpers("r_resizeH" /* ResizeHandle */, Resizer_1.Resizer), true), this.createDndHelpers("r_rotateH" /* RotateHandle */, Rotator_1.Rotator), true), this.createDndHelpers("r_cropH" /* CropHandle */, Cropper_1.Cropper), true), this.createDndHelpers("r_cropC" /* CropContainer */, Cropper_1.Cropper), true);
22597
- // Put cursor next to the image
22598
- this.editor.select(wrapper, -3 /* After */);
22937
+ this.editor.select(this.image);
22938
+ this.toggleImageVisibility(this.image, false /** showImage */);
22599
22939
  }
22600
22940
  };
22601
22941
  /**
@@ -22603,25 +22943,22 @@ var ImageEdit = /** @class */ (function () {
22603
22943
  */
22604
22944
  ImageEdit.prototype.createWrapper = function (operation) {
22605
22945
  var _this = this;
22606
- // Wrap the image with an entity so that we can easily retrieve it later
22607
- var wrapper = (0, roosterjs_editor_api_1.insertEntity)(this.editor, IMAGE_EDIT_WRAPPER_ENTITY_TYPE, (0, roosterjs_editor_dom_1.wrap)(this.image, 6 /* ImageEditWrapper */), false /*isBlock*/, true /*isReadonly*/).wrapper;
22608
- wrapper.style.position = 'relative';
22609
- wrapper.style.maxWidth = '100%';
22946
+ //Clone the image and insert the clone in a entity
22947
+ this.clonedImage = this.image.cloneNode(true);
22948
+ this.wrapper = (0, roosterjs_editor_dom_1.createElement)(6 /* ImageEditWrapper */, this.image.ownerDocument);
22949
+ this.wrapper.firstChild.appendChild(this.clonedImage);
22610
22950
  // keep the same vertical align
22611
- var originalVerticalAlign = this.image.ownerDocument.defaultView
22612
- .getComputedStyle(this.image)
22613
- .getPropertyValue('vertical-align');
22951
+ var originalVerticalAlign = this.getStylePropertyValue(this.image, 'vertical-align');
22614
22952
  if (originalVerticalAlign) {
22615
- wrapper.style.verticalAlign = originalVerticalAlign;
22953
+ this.wrapper.style.verticalAlign = originalVerticalAlign;
22616
22954
  }
22617
- wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
22955
+ this.wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
22618
22956
  // Cache current src so that we can compare it after edit see if src is changed
22619
22957
  this.lastSrc = this.image.getAttribute('src');
22620
22958
  // Set image src to original src to help show editing UI, also it will be used when regenerate image dataURL after editing
22621
- this.image.src = this.editInfo.src;
22622
- this.image.style.position = 'absolute';
22623
- this.image.style.maxWidth = null;
22624
- var isExperimentalHandlesEnabled = this.editor.isFeatureEnabled("AdaptiveHandlesResizer" /* AdaptiveHandlesResizer */);
22959
+ this.clonedImage.src = this.editInfo.src;
22960
+ this.clonedImage.style.position = 'absolute';
22961
+ this.clonedImage.style.maxWidth = null;
22625
22962
  // Get HTML for all edit elements (resize handle, rotate handle, crop handle and overlay, ...) and create HTML element
22626
22963
  var options = {
22627
22964
  borderColor: getColorString(this.options.borderColor, this.editor.isDarkMode()),
@@ -22629,8 +22966,7 @@ var ImageEdit = /** @class */ (function () {
22629
22966
  rotateHandleBackColor: this.editor.isDarkMode()
22630
22967
  ? DARK_MODE_BGCOLOR
22631
22968
  : LIGHT_MODE_BGCOLOR,
22632
- isSmallImage: isASmallImage(this.editInfo, isExperimentalHandlesEnabled),
22633
- handlesExperimentalFeatures: isExperimentalHandlesEnabled,
22969
+ isSmallImage: isASmallImage(this.editInfo),
22634
22970
  };
22635
22971
  var htmlData = [(0, Resizer_1.getResizeBordersHTML)(options)];
22636
22972
  (0, roosterjs_editor_dom_1.getObjectKeys)(ImageEditHTMLMap).forEach(function (thisOperation) {
@@ -22641,20 +22977,47 @@ var ImageEdit = /** @class */ (function () {
22641
22977
  htmlData.forEach(function (data) {
22642
22978
  var element = (0, roosterjs_editor_dom_1.createElement)(data, _this.image.ownerDocument);
22643
22979
  if (element) {
22644
- wrapper.appendChild(element);
22980
+ _this.wrapper.appendChild(element);
22645
22981
  }
22646
22982
  });
22647
- return wrapper;
22983
+ this.insertImageWrapper(this.image, this.wrapper, this.editor.getZoomScale());
22648
22984
  };
22649
- /**
22650
- * Get image wrapper from image
22651
- * @param image The image to get wrapper from
22652
- */
22653
- ImageEdit.prototype.getImageWrapper = function (image) {
22654
- var _a;
22655
- // Get the image wrapper from image using Entity API
22656
- var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)((_a = image === null || image === void 0 ? void 0 : image.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode);
22657
- return (entity === null || entity === void 0 ? void 0 : entity.type) == IMAGE_EDIT_WRAPPER_ENTITY_TYPE ? entity.wrapper : null;
22985
+ ImageEdit.prototype.toggleImageVisibility = function (image, showImage) {
22986
+ var editorId = this.editor.getEditorDomAttribute('id');
22987
+ var doc = this.editor.getDocument();
22988
+ var editingId = 'editingId' + editorId;
22989
+ if (showImage) {
22990
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, editingId);
22991
+ }
22992
+ else {
22993
+ var cssRule = "#" + editorId + " #" + image.id + " {visibility: hidden}";
22994
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(doc, cssRule, editingId);
22995
+ }
22996
+ };
22997
+ ImageEdit.prototype.createZoomWrapper = function (wrapper, scale) {
22998
+ var zoomWrapper = this.editor.getDocument().createElement('div');
22999
+ zoomWrapper.style.transform = "scale(" + (scale || 1) + ")";
23000
+ zoomWrapper.style.transformOrigin = 'top left';
23001
+ zoomWrapper.style.position = 'fixed';
23002
+ zoomWrapper.appendChild(wrapper);
23003
+ return zoomWrapper;
23004
+ };
23005
+ ImageEdit.prototype.copyImageSize = function (image, element) {
23006
+ var _a = image.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
23007
+ element.style.top = top + "px";
23008
+ element.style.bottom = bottom + "px";
23009
+ element.style.right = right + "px";
23010
+ element.style.left = left + "px";
23011
+ return element;
23012
+ };
23013
+ ImageEdit.prototype.insertImageWrapper = function (image, wrapper, scale) {
23014
+ this.zoomWrapper = this.copyImageSize(image, this.createZoomWrapper(wrapper, scale));
23015
+ this.editor.getDocument().body.appendChild(this.zoomWrapper);
23016
+ };
23017
+ ImageEdit.prototype.getStylePropertyValue = function (element, property) {
23018
+ return element.ownerDocument.defaultView
23019
+ .getComputedStyle(this.image)
23020
+ .getPropertyValue(property);
22658
23021
  };
22659
23022
  /**
22660
23023
  * Create drag and drop helpers
@@ -22669,7 +23032,7 @@ var ImageEdit = /** @class */ (function () {
22669
23032
  options: this.options,
22670
23033
  elementClass: elementClass,
22671
23034
  };
22672
- var wrapper = this.getImageWrapper(this.image);
23035
+ var wrapper = this.wrapper;
22673
23036
  return wrapper
22674
23037
  ? getEditElements(wrapper, elementClass).map(function (element) {
22675
23038
  return new DragAndDropHelper_1.default(element, __assign(__assign({}, commonContext), { x: element.dataset.x, y: element.dataset.y }), _this.updateWrapper, dragAndDrop, _this.editor.getZoomScale());
@@ -22750,9 +23113,9 @@ function isFixedNumberValue(value) {
22750
23113
  var numberValue = typeof value === 'string' ? parseInt(value) : value;
22751
23114
  return !isNaN(numberValue);
22752
23115
  }
22753
- function isASmallImage(editInfo, isFeatureEnabled) {
23116
+ function isASmallImage(editInfo) {
22754
23117
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx;
22755
- return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE && isFeatureEnabled;
23118
+ return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE;
22756
23119
  }
22757
23120
  function getColorString(color, isDarkMode) {
22758
23121
  if (typeof color === 'string') {
@@ -22939,10 +23302,11 @@ var editInfo_1 = __webpack_require__(/*! ./editInfo */ "./packages/roosterjs-edi
22939
23302
  * @param image The image to apply the change
22940
23303
  * @param editInfo Edit info that contains the changed information of the image
22941
23304
  * @param previousSrc Last src value of the image before the change was made
23305
+ * @param editingImage (optional) Image in editing state
22942
23306
  */
22943
- function applyChange(editor, image, editInfo, previousSrc, wasResized) {
23307
+ function applyChange(editor, image, editInfo, previousSrc, wasResized, editingImage) {
22944
23308
  var newSrc = '';
22945
- var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(image);
23309
+ var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(editingImage !== null && editingImage !== void 0 ? editingImage : image);
22946
23310
  var state = (0, checkEditInfoState_1.default)(editInfo, initEditInfo);
22947
23311
  switch (state) {
22948
23312
  case 1 /* ResizeOnly */:
@@ -22956,7 +23320,7 @@ function applyChange(editor, image, editInfo, previousSrc, wasResized) {
22956
23320
  break;
22957
23321
  case 3 /* FullyChanged */:
22958
23322
  // For other cases (cropped, rotated, ...) we need to create a new image to reflect the change
22959
- newSrc = (0, generateDataURL_1.default)(image, editInfo);
23323
+ newSrc = (0, generateDataURL_1.default)(editingImage !== null && editingImage !== void 0 ? editingImage : image, editInfo);
22960
23324
  break;
22961
23325
  }
22962
23326
  var srcChanged = newSrc != previousSrc;
@@ -23508,14 +23872,12 @@ exports.doubleCheckResize = doubleCheckResize;
23508
23872
  * Get HTML for resize handles at the corners
23509
23873
  */
23510
23874
  function getCornerResizeHTML(_a, onShowResizeHandle) {
23511
- var resizeBorderColor = _a.borderColor, handlesExperimentalFeatures = _a.handlesExperimentalFeatures;
23875
+ var resizeBorderColor = _a.borderColor;
23512
23876
  var result = [];
23513
23877
  Xs.forEach(function (x) {
23514
23878
  return Ys.forEach(function (y) {
23515
23879
  var elementData = (x == '') == (y == '')
23516
- ? getResizeHandleHTML(x, y, resizeBorderColor, handlesExperimentalFeatures
23517
- ? 1 /* CircularHandlesCorner */
23518
- : 0 /* SquareHandles */)
23880
+ ? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
23519
23881
  : null;
23520
23882
  if (onShowResizeHandle) {
23521
23883
  onShowResizeHandle(elementData, x, y);
@@ -23531,7 +23893,7 @@ exports.getCornerResizeHTML = getCornerResizeHTML;
23531
23893
  * Get HTML for resize handles on the sides
23532
23894
  */
23533
23895
  function getSideResizeHTML(_a, onShowResizeHandle) {
23534
- var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage, handlesExperimentalFeatures = _a.handlesExperimentalFeatures;
23896
+ var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage;
23535
23897
  if (isSmallImage) {
23536
23898
  return null;
23537
23899
  }
@@ -23539,9 +23901,7 @@ function getSideResizeHTML(_a, onShowResizeHandle) {
23539
23901
  Xs.forEach(function (x) {
23540
23902
  return Ys.forEach(function (y) {
23541
23903
  var elementData = (x == '') != (y == '')
23542
- ? getResizeHandleHTML(x, y, resizeBorderColor, handlesExperimentalFeatures
23543
- ? 1 /* CircularHandlesCorner */
23544
- : 0 /* SquareHandles */)
23904
+ ? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
23545
23905
  : null;
23546
23906
  if (onShowResizeHandle) {
23547
23907
  onShowResizeHandle(elementData, x, y);
@@ -23618,7 +23978,7 @@ var __assign = (this && this.__assign) || function () {
23618
23978
  return __assign.apply(this, arguments);
23619
23979
  };
23620
23980
  Object.defineProperty(exports, "__esModule", { value: true });
23621
- exports.getRotateHTML = exports.updateRotateHandlePosition = exports.Rotator = void 0;
23981
+ exports.getRotateHTML = exports.Rotator = void 0;
23622
23982
  var ROTATE_SIZE = 32;
23623
23983
  var ROTATE_GAP = 15;
23624
23984
  var DEG_PER_RAD = 180 / Math.PI;
@@ -23653,26 +24013,6 @@ exports.Rotator = {
23653
24013
  }
23654
24014
  },
23655
24015
  };
23656
- /**
23657
- * @internal
23658
- * Move rotate handle. When image is very close to the border of editor, rotate handle may not be visible.
23659
- * Fix it by reduce the distance from image to rotate handle
23660
- */
23661
- function updateRotateHandlePosition(editInfo, distance, marginVertical, rotateCenter, rotateHandle) {
23662
- if (rotateCenter && rotateHandle && distance) {
23663
- var angleRad = editInfo.angleRad, heightPx = editInfo.heightPx;
23664
- var cosAngle = Math.cos(angleRad);
23665
- var adjustedDistance = cosAngle <= 0
23666
- ? Number.MAX_SAFE_INTEGER
23667
- : (distance[1] + heightPx / 2 + marginVertical) / cosAngle - heightPx / 2;
23668
- var rotateGap = Math.max(Math.min(ROTATE_GAP, adjustedDistance), 0);
23669
- var rotateTop = Math.max(Math.min(ROTATE_SIZE, adjustedDistance - rotateGap), 0);
23670
- rotateCenter.style.top = -rotateGap + 'px';
23671
- rotateCenter.style.height = rotateGap + 'px';
23672
- rotateHandle.style.top = -rotateTop + 'px';
23673
- }
23674
- }
23675
- exports.updateRotateHandlePosition = updateRotateHandlePosition;
23676
24016
  /**
23677
24017
  * @internal
23678
24018
  * Get HTML for rotate elements, including the rotate handle with icon, and a line between the handle and the image
@@ -23684,12 +24024,12 @@ function getRotateHTML(_a) {
23684
24024
  {
23685
24025
  tag: 'div',
23686
24026
  className: "r_rotateC" /* RotateCenter */,
23687
- style: "position:absolute;left:50%;width:1px;background-color:" + borderColor,
24027
+ style: "position:absolute;left:50%;width:1px;background-color:" + borderColor + ";top:" + -ROTATE_GAP + "px;height:" + ROTATE_GAP + "px;",
23688
24028
  children: [
23689
24029
  {
23690
24030
  tag: 'div',
23691
24031
  className: "r_rotateH" /* RotateHandle */,
23692
- style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + ROTATE_SIZE + "px;height:" + ROTATE_SIZE + "px;left:-" + handleLeft + "px;cursor:move",
24032
+ style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + ROTATE_SIZE + "px;height:" + ROTATE_SIZE + "px;left:-" + handleLeft + "px;cursor:move;top:" + -ROTATE_SIZE + "px;",
23693
24033
  children: [getRotateIconHTML(borderColor)],
23694
24034
  },
23695
24035
  ],
@@ -23843,111 +24183,6 @@ var ImageResize_1 = __webpack_require__(/*! ./ImageResize */ "./packages/rooster
23843
24183
  Object.defineProperty(exports, "ImageResize", { enumerable: true, get: function () { return ImageResize_1.default; } });
23844
24184
 
23845
24185
 
23846
- /***/ }),
23847
-
23848
- /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts":
23849
- /*!****************************************************************************************!*\
23850
- !*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts ***!
23851
- \****************************************************************************************/
23852
- /*! no static exports found */
23853
- /***/ (function(module, exports, __webpack_require__) {
23854
-
23855
- "use strict";
23856
-
23857
- Object.defineProperty(exports, "__esModule", { value: true });
23858
- var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
23859
- var Escape = 'Escape';
23860
- var mouseRightButton = 2;
23861
- var mouseLeftButton = 0;
23862
- /**
23863
- * Requires @see ExperimentalFeatures.ImageSelection to be enabled.
23864
- * Detect image selection and help highlight the image
23865
- */
23866
- var ImageSelection = /** @class */ (function () {
23867
- function ImageSelection() {
23868
- this.editor = null;
23869
- }
23870
- /**
23871
- * Get a friendly name of this plugin
23872
- */
23873
- ImageSelection.prototype.getName = function () {
23874
- return 'ImageSelection';
23875
- };
23876
- /**
23877
- * Initialize this plugin. This should only be called from Editor
23878
- * @param editor Editor instance
23879
- */
23880
- ImageSelection.prototype.initialize = function (editor) {
23881
- this.editor = editor;
23882
- };
23883
- /**
23884
- * Dispose this plugin
23885
- */
23886
- ImageSelection.prototype.dispose = function () {
23887
- this.editor.select(null);
23888
- this.editor = null;
23889
- };
23890
- ImageSelection.prototype.onPluginEvent = function (event) {
23891
- if (this.editor && this.editor.isFeatureEnabled("ImageSelection" /* ImageSelection */)) {
23892
- switch (event.eventType) {
23893
- case 17 /* EnteredShadowEdit */:
23894
- case 18 /* LeavingShadowEdit */:
23895
- var selection = this.editor.getSelectionRangeEx();
23896
- if (selection.type == 2 /* ImageSelection */) {
23897
- this.editor.select(selection.image);
23898
- }
23899
- break;
23900
- case 5 /* MouseDown */:
23901
- var target = event.rawEvent.target;
23902
- if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
23903
- if (event.rawEvent.button === mouseRightButton) {
23904
- var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
23905
- this.editor.select(imageRange);
23906
- }
23907
- else if (event.rawEvent.button === mouseLeftButton) {
23908
- this.editor.select(target);
23909
- }
23910
- }
23911
- break;
23912
- case 0 /* KeyDown */:
23913
- var key = event.rawEvent.key;
23914
- var keyDownSelection = this.editor.getSelectionRangeEx();
23915
- if (keyDownSelection.type === 2 /* ImageSelection */) {
23916
- if (key === Escape) {
23917
- this.editor.select(keyDownSelection.image, -2 /* Before */);
23918
- this.editor.getSelectionRange().collapse();
23919
- event.rawEvent.stopPropagation();
23920
- }
23921
- else {
23922
- this.editor.select(keyDownSelection.ranges[0]);
23923
- }
23924
- }
23925
- break;
23926
- }
23927
- }
23928
- };
23929
- return ImageSelection;
23930
- }());
23931
- exports.default = ImageSelection;
23932
-
23933
-
23934
- /***/ }),
23935
-
23936
- /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts":
23937
- /*!*******************************************************************************!*\
23938
- !*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts ***!
23939
- \*******************************************************************************/
23940
- /*! no static exports found */
23941
- /***/ (function(module, exports, __webpack_require__) {
23942
-
23943
- "use strict";
23944
-
23945
- Object.defineProperty(exports, "__esModule", { value: true });
23946
- exports.ImageSelection = void 0;
23947
- var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts");
23948
- Object.defineProperty(exports, "ImageSelection", { enumerable: true, get: function () { return ImageSelection_1.default; } });
23949
-
23950
-
23951
24186
  /***/ }),
23952
24187
 
23953
24188
  /***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/Paste.ts":
@@ -25921,6 +26156,13 @@ var PickerPlugin = /** @class */ (function () {
25921
26156
  */
25922
26157
  PickerPlugin.prototype.dispose = function () {
25923
26158
  this.editor = null;
26159
+ this.isSuggesting = null;
26160
+ this.blockSuggestions = null;
26161
+ this.eventHandledOnKeyDown = null;
26162
+ this.lastKnownRange = null;
26163
+ this.isPendingInputEventHandling = null;
26164
+ this.currentInputLength = null;
26165
+ this.newInputLength = null;
25924
26166
  this.dataProvider.onDispose();
25925
26167
  };
25926
26168
  /**
@@ -29020,6 +29262,7 @@ var CompatibleExperimentalFeatures;
29020
29262
  */
29021
29263
  CompatibleExperimentalFeatures["ConvertSingleImageBody"] = "ConvertSingleImageBody";
29022
29264
  /**
29265
+ * @deprecated This feature is always enabled
29023
29266
  * Align table elements to left, center and right using setAlignment API
29024
29267
  */
29025
29268
  CompatibleExperimentalFeatures["TableAlignment"] = "TableAlignment";
@@ -29028,6 +29271,7 @@ var CompatibleExperimentalFeatures;
29028
29271
  */
29029
29272
  CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
29030
29273
  /**
29274
+ * @deprecated this feature is always enabled
29031
29275
  * Provide a circular resize handles that adaptive the number od handles to the size of the image
29032
29276
  */
29033
29277
  CompatibleExperimentalFeatures["AdaptiveHandlesResizer"] = "AdaptiveHandlesResizer";
@@ -29056,6 +29300,7 @@ var CompatibleExperimentalFeatures;
29056
29300
  */
29057
29301
  CompatibleExperimentalFeatures["NormalizeList"] = "NormalizeList";
29058
29302
  /**
29303
+ * @deprecated this feature is always enabled
29059
29304
  * When a html image is selected, the selected image data will be stored by editor core.
29060
29305
  */
29061
29306
  CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
@@ -29066,6 +29311,11 @@ var CompatibleExperimentalFeatures;
29066
29311
  * is the one closest to the item.
29067
29312
  */
29068
29313
  CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
29314
+ /**
29315
+ * When apply default format when initialize or user type, apply the format on a SPAN element rather than
29316
+ * the block element (In most case, the DIV element) so keep the block element clean.
29317
+ */
29318
+ CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
29069
29319
  })(CompatibleExperimentalFeatures = exports.CompatibleExperimentalFeatures || (exports.CompatibleExperimentalFeatures = {}));
29070
29320
 
29071
29321