roosterjs 8.35.1 → 8.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2154,12 +2154,14 @@ Object.defineProperty(exports, "getDarkColor", { enumerable: true, get: function
2154
2154
 
2155
2155
  Object.defineProperty(exports, "__esModule", { value: true });
2156
2156
  var Color = __webpack_require__(/*! color */ "./node_modules/color/index.js");
2157
- var baseLValue = 21.247; // L-value of #333333
2157
+ var DefaultBaseLValue = 21.247; // L-value of #333333
2158
2158
  /**
2159
2159
  * Get dark mode color for a given color
2160
2160
  * @param color The color to calculate from
2161
+ * @param baseLValue The Light value for base dark color in LAB format. @default the Light value for #333333
2161
2162
  */
2162
- function getDarkColor(color) {
2163
+ function getDarkColor(color, baseLValue) {
2164
+ if (baseLValue === void 0) { baseLValue = DefaultBaseLValue; }
2163
2165
  try {
2164
2166
  var computedColor = Color(color || undefined);
2165
2167
  var colorLab = computedColor.lab().array();
@@ -3083,8 +3085,7 @@ function setAlignment(editor, alignment) {
3083
3085
  var selection = editor.getSelectionRangeEx();
3084
3086
  var isATable = selection && selection.type === 1 /* TableSelection */;
3085
3087
  var elementAtCursor = editor.getElementAtCursor();
3086
- if (editor.isFeatureEnabled("TableAlignment" /* TableAlignment */) &&
3087
- isATable &&
3088
+ if (isATable &&
3088
3089
  (0, roosterjs_editor_dom_1.isWholeTableSelected)(new roosterjs_editor_dom_1.VTable(selection.table), selection.coordinates)) {
3089
3090
  alignTable(selection, alignment);
3090
3091
  }
@@ -4195,7 +4196,9 @@ function applyInlineStyle(editor, callback, apiName) {
4195
4196
  else if (editor.isFeatureEnabled("PendingStyleBasedFormat" /* PendingStyleBasedFormat */)) {
4196
4197
  editor.triggerPluginEvent(13 /* PendingFormatStateChanged */, {
4197
4198
  formatState: {},
4198
- formatCallback: safeCallback,
4199
+ // Here we use callback instead of safeCallback because we know it's contentEditable.
4200
+ // In addition, for elements that are not added to the DOM tree, isContentEditable always returns false on Safari.
4201
+ formatCallback: callback,
4199
4202
  });
4200
4203
  editor.triggerContentChangedEvent("Format" /* Format */);
4201
4204
  }
@@ -5096,7 +5099,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
5096
5099
  * When typing goes directly under content div, many things can go wrong
5097
5100
  * We fix it by wrapping it with a div and reposition cursor within the div
5098
5101
  */
5099
- var ensureTypeInContainer = function (core, position, keyboardEvent) {
5102
+ var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
5100
5103
  var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
5101
5104
  var td;
5102
5105
  if (table && (td = table.querySelector('td,th'))) {
@@ -5117,20 +5120,28 @@ var ensureTypeInContainer = function (core, position, keyboardEvent) {
5117
5120
  var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
5118
5121
  (keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
5119
5122
  formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
5123
+ if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
5124
+ var firstChild = formatNode.firstChild;
5125
+ formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
5126
+ ? firstChild
5127
+ : (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
5128
+ position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5129
+ }
5120
5130
  }
5121
5131
  else {
5122
5132
  // Only reason we don't get the selection block is that we have an empty content div
5123
5133
  // which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
5124
5134
  // The fix is to add a DIV wrapping, apply default format and move cursor over
5125
- formatNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5126
- core.api.insertNode(core, formatNode, {
5135
+ var newNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5136
+ core.api.insertNode(core, newNode, {
5127
5137
  position: 1 /* End */,
5128
5138
  updateCursor: false,
5129
5139
  replaceSelection: false,
5130
5140
  insertOnNewLine: false,
5131
5141
  });
5142
+ formatNode = newNode.firstChild;
5132
5143
  // element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
5133
- position = new roosterjs_editor_dom_1.Position(formatNode.firstChild, 0 /* Begin */);
5144
+ position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5134
5145
  }
5135
5146
  if (formatNode && core.lifecycle.defaultFormat) {
5136
5147
  (0, roosterjs_editor_dom_1.applyFormat)(formatNode, core.lifecycle.defaultFormat, core.lifecycle.isDarkMode);
@@ -5849,7 +5860,6 @@ exports.restoreUndoSnapshot = restoreUndoSnapshot;
5849
5860
 
5850
5861
  Object.defineProperty(exports, "__esModule", { value: true });
5851
5862
  exports.selectImage = void 0;
5852
- var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
5853
5863
  var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
5854
5864
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5855
5865
  var IMAGE_ID = 'imageSelected';
@@ -5884,7 +5894,7 @@ exports.selectImage = selectImage;
5884
5894
  var select = function (core, image) {
5885
5895
  (0, roosterjs_editor_dom_1.removeImportantStyleRule)(image, ['border', 'margin']);
5886
5896
  var borderCSS = buildBorderCSS(core, image.id);
5887
- (0, addSelectionStyle_1.default)(core, borderCSS, STYLE_ID);
5897
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, borderCSS, STYLE_ID + core.contentDiv.id);
5888
5898
  };
5889
5899
  var buildBorderCSS = function (core, imageId) {
5890
5900
  var divId = core.contentDiv.id;
@@ -5893,10 +5903,7 @@ var buildBorderCSS = function (core, imageId) {
5893
5903
  };
5894
5904
  var unselect = function (core) {
5895
5905
  var doc = core.contentDiv.ownerDocument;
5896
- var styleTag = doc.getElementById(STYLE_ID + core.contentDiv.id);
5897
- if (styleTag) {
5898
- doc.head.removeChild(styleTag);
5899
- }
5906
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
5900
5907
  };
5901
5908
 
5902
5909
 
@@ -5978,7 +5985,6 @@ function restorePendingFormatState(core) {
5978
5985
 
5979
5986
  Object.defineProperty(exports, "__esModule", { value: true });
5980
5987
  exports.selectTable = void 0;
5981
- var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
5982
5988
  var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
5983
5989
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5984
5990
  var TABLE_ID = 'tableSelected';
@@ -6079,19 +6085,13 @@ function buildCss(table, coordinates, contentDivSelector) {
6079
6085
  function select(core, table, coordinates) {
6080
6086
  var contentDivSelector = '#' + core.contentDiv.id;
6081
6087
  var _a = buildCss(table, coordinates, contentDivSelector), css = _a.css, ranges = _a.ranges;
6082
- (0, addSelectionStyle_1.default)(core, css, STYLE_ID);
6088
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, css, STYLE_ID + core.contentDiv.id);
6083
6089
  return ranges;
6084
6090
  }
6085
- function unselect(core) {
6086
- var _a;
6087
- var div = core.contentDiv;
6088
- var styleElement = div.ownerDocument.getElementById(STYLE_ID + div.id);
6089
- if ((_a = styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
6090
- while (styleElement.sheet.cssRules.length > 0) {
6091
- styleElement.sheet.deleteRule(0);
6092
- }
6093
- }
6094
- }
6091
+ var unselect = function (core) {
6092
+ var doc = core.contentDiv.ownerDocument;
6093
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
6094
+ };
6095
6095
  function generateCssFromCell(contentDivSelector, tableId, middleElSelector, rowIndex, cellTag, index) {
6096
6096
  return (contentDivSelector +
6097
6097
  ' #' +
@@ -6486,39 +6486,6 @@ function handledExclusively(event, plugin) {
6486
6486
  }
6487
6487
 
6488
6488
 
6489
- /***/ }),
6490
-
6491
- /***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts":
6492
- /*!*******************************************************************************!*\
6493
- !*** ./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts ***!
6494
- \*******************************************************************************/
6495
- /*! no static exports found */
6496
- /***/ (function(module, exports, __webpack_require__) {
6497
-
6498
- "use strict";
6499
-
6500
- Object.defineProperty(exports, "__esModule", { value: true });
6501
- /**
6502
- * Add style to selected elements
6503
- * @param core The Editor core object
6504
- * @param cssRule The css rule that must added to the selection
6505
- * @param styleId the ID of the style tag
6506
- */
6507
- function addSelectionStyle(core, cssRule, styleId) {
6508
- var _a;
6509
- var styleTagId = styleId + core.contentDiv.id;
6510
- var doc = core.contentDiv.ownerDocument;
6511
- var styleTag = doc.getElementById(styleTagId);
6512
- if (!styleTag) {
6513
- styleTag = doc.createElement('style');
6514
- styleTag.id = styleTagId;
6515
- doc.head.appendChild(styleTag);
6516
- }
6517
- (_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
6518
- }
6519
- exports.default = addSelectionStyle;
6520
-
6521
-
6522
6489
  /***/ }),
6523
6490
 
6524
6491
  /***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts":
@@ -6671,6 +6638,9 @@ var CopyPastePlugin = /** @class */ (function () {
6671
6638
  var image = tempDiv_1.querySelector('#' + selection_1.image.id);
6672
6639
  if (image) {
6673
6640
  newRange = (0, roosterjs_editor_dom_1.createRange)(image);
6641
+ if (isCut) {
6642
+ this.deleteImage(this.editor, selection_1.image.id);
6643
+ }
6674
6644
  }
6675
6645
  }
6676
6646
  else {
@@ -6780,6 +6750,11 @@ var CopyPastePlugin = /** @class */ (function () {
6780
6750
  table.style.removeProperty('height');
6781
6751
  }
6782
6752
  };
6753
+ CopyPastePlugin.prototype.deleteImage = function (editor, imageId) {
6754
+ editor.queryElements('#' + imageId, function (node) {
6755
+ editor.deleteNode(node);
6756
+ });
6757
+ };
6783
6758
  return CopyPastePlugin;
6784
6759
  }());
6785
6760
  exports.default = CopyPastePlugin;
@@ -7479,6 +7454,95 @@ var workaroundSelectionIssueForIE = roosterjs_editor_dom_1.Browser.isIE
7479
7454
  : function () { };
7480
7455
 
7481
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
+
7482
7546
  /***/ }),
7483
7547
 
7484
7548
  /***/ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts":
@@ -8421,6 +8485,7 @@ var CopyPastePlugin_1 = __webpack_require__(/*! ./CopyPastePlugin */ "./packages
8421
8485
  var DOMEventPlugin_1 = __webpack_require__(/*! ./DOMEventPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/DOMEventPlugin.ts");
8422
8486
  var EditPlugin_1 = __webpack_require__(/*! ./EditPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EditPlugin.ts");
8423
8487
  var EntityPlugin_1 = __webpack_require__(/*! ./EntityPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EntityPlugin.ts");
8488
+ var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts");
8424
8489
  var LifecyclePlugin_1 = __webpack_require__(/*! ./LifecyclePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts");
8425
8490
  var MouseUpPlugin_1 = __webpack_require__(/*! ./MouseUpPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/MouseUpPlugin.ts");
8426
8491
  var NormalizeTablePlugin_1 = __webpack_require__(/*! ./NormalizeTablePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/NormalizeTablePlugin.ts");
@@ -8448,6 +8513,7 @@ function createCorePlugins(contentDiv, options) {
8448
8513
  mouseUp: map.mouseUp || new MouseUpPlugin_1.default(),
8449
8514
  copyPaste: map.copyPaste || new CopyPastePlugin_1.default(options),
8450
8515
  entity: map.entity || new EntityPlugin_1.default(),
8516
+ imageSelection: map.imageSelection || new ImageSelection_1.default(),
8451
8517
  normalizeTable: map.normalizeTable || new NormalizeTablePlugin_1.default(),
8452
8518
  lifecycle: map.lifecycle || new LifecyclePlugin_1.default(options, contentDiv),
8453
8519
  };
@@ -8893,9 +8959,7 @@ var Editor = /** @class */ (function () {
8893
8959
  coordinates: arg2,
8894
8960
  };
8895
8961
  }
8896
- else if (this.isFeatureEnabled("ImageSelection" /* ImageSelection */) &&
8897
- (0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') &&
8898
- typeof arg2 == 'undefined') {
8962
+ else if ((0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') && typeof arg2 == 'undefined') {
8899
8963
  rangeEx = {
8900
8964
  type: 2 /* ImageSelection */,
8901
8965
  ranges: [],
@@ -12261,8 +12325,8 @@ exports.isCssVariable = isCssVariable;
12261
12325
 
12262
12326
  Object.defineProperty(exports, "__esModule", { value: true });
12263
12327
  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;
12264
- 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;
12265
- 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;
12328
+ exports.setGlobalCssStyles = 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;
12329
+ 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 = void 0;
12266
12330
  var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
12267
12331
  Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
12268
12332
  var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
@@ -12450,6 +12514,10 @@ var setStyles_1 = __webpack_require__(/*! ./style/setStyles */ "./packages/roost
12450
12514
  Object.defineProperty(exports, "setStyles", { enumerable: true, get: function () { return setStyles_1.default; } });
12451
12515
  var removeImportantStyleRule_1 = __webpack_require__(/*! ./style/removeImportantStyleRule */ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts");
12452
12516
  Object.defineProperty(exports, "removeImportantStyleRule", { enumerable: true, get: function () { return removeImportantStyleRule_1.default; } });
12517
+ var setGlobalCssStyles_1 = __webpack_require__(/*! ./style/setGlobalCssStyles */ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts");
12518
+ Object.defineProperty(exports, "setGlobalCssStyles", { enumerable: true, get: function () { return setGlobalCssStyles_1.default; } });
12519
+ var removeGlobalCssStyle_1 = __webpack_require__(/*! ./style/removeGlobalCssStyle */ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts");
12520
+ Object.defineProperty(exports, "removeGlobalCssStyle", { enumerable: true, get: function () { return removeGlobalCssStyle_1.default; } });
12453
12521
  var adjustInsertPosition_1 = __webpack_require__(/*! ./edit/adjustInsertPosition */ "./packages/roosterjs-editor-dom/lib/edit/adjustInsertPosition.ts");
12454
12522
  Object.defineProperty(exports, "adjustInsertPosition", { enumerable: true, get: function () { return adjustInsertPosition_1.default; } });
12455
12523
  var deleteSelectedContent_1 = __webpack_require__(/*! ./edit/deleteSelectedContent */ "./packages/roosterjs-editor-dom/lib/edit/deleteSelectedContent.ts");
@@ -13810,6 +13878,17 @@ function createListChainName() {
13810
13878
 
13811
13879
  "use strict";
13812
13880
 
13881
+ var __assign = (this && this.__assign) || function () {
13882
+ __assign = Object.assign || function(t) {
13883
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
13884
+ s = arguments[i];
13885
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13886
+ t[p] = s[p];
13887
+ }
13888
+ return t;
13889
+ };
13890
+ return __assign.apply(this, arguments);
13891
+ };
13813
13892
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13814
13893
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
13815
13894
  if (ar || !(i in from)) {
@@ -13823,6 +13902,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13823
13902
  exports.ListStyleDefinitionMetadata = void 0;
13824
13903
  var contains_1 = __webpack_require__(/*! ../utils/contains */ "./packages/roosterjs-editor-dom/lib/utils/contains.ts");
13825
13904
  var getListTypeFromNode_1 = __webpack_require__(/*! ./getListTypeFromNode */ "./packages/roosterjs-editor-dom/lib/list/getListTypeFromNode.ts");
13905
+ var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
13826
13906
  var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
13827
13907
  var isBlockElement_1 = __webpack_require__(/*! ../utils/isBlockElement */ "./packages/roosterjs-editor-dom/lib/utils/isBlockElement.ts");
13828
13908
  var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
@@ -13830,6 +13910,7 @@ var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./pac
13830
13910
  var setBulletListMarkers_1 = __webpack_require__(/*! ./setBulletListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setBulletListMarkers.ts");
13831
13911
  var setListItemStyle_1 = __webpack_require__(/*! ./setListItemStyle */ "./packages/roosterjs-editor-dom/lib/list/setListItemStyle.ts");
13832
13912
  var setNumberingListMarkers_1 = __webpack_require__(/*! ./setNumberingListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setNumberingListMarkers.ts");
13913
+ var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
13833
13914
  var toArray_1 = __webpack_require__(/*! ../jsUtils/toArray */ "./packages/roosterjs-editor-dom/lib/jsUtils/toArray.ts");
13834
13915
  var unwrap_1 = __webpack_require__(/*! ../utils/unwrap */ "./packages/roosterjs-editor-dom/lib/utils/unwrap.ts");
13835
13916
  var wrap_1 = __webpack_require__(/*! ../utils/wrap */ "./packages/roosterjs-editor-dom/lib/utils/wrap.ts");
@@ -14100,7 +14181,29 @@ var VListItem = /** @class */ (function () {
14100
14181
  }
14101
14182
  // 5. If this is not a list item now, need to unwrap the LI node and do proper handling
14102
14183
  if (this.listTypes.length <= 1) {
14103
- wrapIfNotBlockNode((0, getTagOfNode_1.default)(this.node) == 'LI' ? getChildrenAndUnwrap(this.node) : [this.node], true /*checkFirst*/, true /*checkLast*/);
14184
+ // If original <LI> node has styles for font and color, we need to apply it to new parent
14185
+ var isLi = (0, getTagOfNode_1.default)(this.node) == 'LI';
14186
+ var stylesToApply = isLi
14187
+ ? {
14188
+ 'font-family': this.node.style.fontFamily,
14189
+ 'font-size': this.node.style.fontSize,
14190
+ color: this.node.style.color,
14191
+ }
14192
+ : undefined;
14193
+ var childNodes = isLi ? getChildrenAndUnwrap(this.node) : [this.node];
14194
+ if (stylesToApply) {
14195
+ for (var i = 0; i < childNodes.length; i++) {
14196
+ if ((0, safeInstanceOf_1.default)(childNodes[i], 'Text')) {
14197
+ childNodes[i] = (0, wrap_1.default)(childNodes[i], 'span');
14198
+ }
14199
+ var node = childNodes[i];
14200
+ if ((0, safeInstanceOf_1.default)(node, 'HTMLElement')) {
14201
+ var styles = __assign(__assign({}, stylesToApply), (0, getStyles_1.default)(node));
14202
+ (0, setStyles_1.default)(node, styles);
14203
+ }
14204
+ }
14205
+ }
14206
+ wrapIfNotBlockNode(childNodes, true /*checkFirst*/, true /*checkLast*/);
14104
14207
  }
14105
14208
  };
14106
14209
  /**
@@ -14573,27 +14676,31 @@ function setListItemStyle(element, styles) {
14573
14676
  }
14574
14677
  exports.default = setListItemStyle;
14575
14678
  function getInlineChildElementsStyle(element, styles) {
14576
- var _a;
14679
+ var _a, _b;
14577
14680
  var result = [];
14578
14681
  var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
14579
14682
  var currentInlineElement = null;
14580
14683
  var _loop_1 = function () {
14581
14684
  currentInlineElement = contentTraverser.currentInlineElement;
14582
14685
  var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
14583
- var currentStyle = {};
14686
+ var currentStyle = null;
14584
14687
  currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
14585
- // we should consider of when it is the single childnode of element, the parentNode's style should add
14688
+ // we should consider of when it is the single child node of element, the parentNode's style should add
14586
14689
  // such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
14587
14690
  while (currentNode &&
14588
14691
  currentNode !== element &&
14589
- (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
14692
+ (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement') &&
14693
+ (result.length == 0 || (((_a = currentNode.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) || 0) > 0)) {
14590
14694
  styles.forEach(function (styleName) {
14591
14695
  var styleValue = currentNode.style.getPropertyValue(styleName);
14696
+ if (!currentStyle) {
14697
+ currentStyle = {};
14698
+ }
14592
14699
  if (styleValue && !currentStyle[styleName]) {
14593
14700
  currentStyle[styleName] = styleValue;
14594
14701
  }
14595
14702
  });
14596
- if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _a === void 0 ? void 0 : _a.childNodes.length) === 1) {
14703
+ if (((_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.childNodes.length) === 1) {
14597
14704
  currentNode = currentNode.parentNode;
14598
14705
  }
14599
14706
  else {
@@ -16303,6 +16410,33 @@ function getStyles(element) {
16303
16410
  exports.default = getStyles;
16304
16411
 
16305
16412
 
16413
+ /***/ }),
16414
+
16415
+ /***/ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts":
16416
+ /*!*************************************************************************!*\
16417
+ !*** ./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts ***!
16418
+ \*************************************************************************/
16419
+ /*! no static exports found */
16420
+ /***/ (function(module, exports, __webpack_require__) {
16421
+
16422
+ "use strict";
16423
+
16424
+ /**
16425
+ * Remove a css rule style from a style sheet
16426
+ * @param doc The document object
16427
+ * @param styleId the ID of the style tag
16428
+ */
16429
+ Object.defineProperty(exports, "__esModule", { value: true });
16430
+ function removeGlobalCssStyle(doc, styleId) {
16431
+ var _a;
16432
+ var styleTag = doc.getElementById(styleId);
16433
+ if (styleTag) {
16434
+ (_a = styleTag.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(styleTag);
16435
+ }
16436
+ }
16437
+ exports.default = removeGlobalCssStyle;
16438
+
16439
+
16306
16440
  /***/ }),
16307
16441
 
16308
16442
  /***/ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts":
@@ -16340,6 +16474,38 @@ function removeImportantStyleRule(element, styleProperties) {
16340
16474
  exports.default = removeImportantStyleRule;
16341
16475
 
16342
16476
 
16477
+ /***/ }),
16478
+
16479
+ /***/ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts":
16480
+ /*!***********************************************************************!*\
16481
+ !*** ./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts ***!
16482
+ \***********************************************************************/
16483
+ /*! no static exports found */
16484
+ /***/ (function(module, exports, __webpack_require__) {
16485
+
16486
+ "use strict";
16487
+
16488
+ /**
16489
+ * Add global css styles
16490
+ * @param doc The document object
16491
+ * @param cssRule The css rule that must added to the selection
16492
+ * @param editorId Te id of the editor
16493
+ * @param styleId the ID of the style tag
16494
+ */
16495
+ Object.defineProperty(exports, "__esModule", { value: true });
16496
+ function setGlobalCssStyles(doc, cssRule, styleId) {
16497
+ var _a;
16498
+ var styleTag = doc.getElementById(styleId);
16499
+ if (!styleTag) {
16500
+ styleTag = doc.createElement('style');
16501
+ styleTag.id = styleId;
16502
+ doc.head.appendChild(styleTag);
16503
+ }
16504
+ (_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
16505
+ }
16506
+ exports.default = setGlobalCssStyles;
16507
+
16508
+
16343
16509
  /***/ }),
16344
16510
 
16345
16511
  /***/ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts":
@@ -17907,7 +18073,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17907
18073
  exports.KnownCreateElementData = void 0;
17908
18074
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
17909
18075
  var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
17910
- var Browser_1 = __webpack_require__(/*! ./Browser */ "./packages/roosterjs-editor-dom/lib/utils/Browser.ts");
17911
18076
  /**
17912
18077
  * All known CreateElementData used by roosterjs to create elements
17913
18078
  */
@@ -17915,9 +18080,10 @@ exports.KnownCreateElementData = (_a = {},
17915
18080
  _a[0 /* None */] = { tag: '' },
17916
18081
  // Edge can sometimes lose current format when Enter to new line.
17917
18082
  // So here we add an extra SPAN for Edge to workaround this bug
17918
- _a[1 /* EmptyLine */] = Browser_1.Browser.isEdge
17919
- ? { tag: 'div', children: [{ tag: 'span', children: [{ tag: 'br' }] }] }
17920
- : { tag: 'div', children: [{ tag: 'br' }] },
18083
+ _a[1 /* EmptyLine */] = {
18084
+ tag: 'div',
18085
+ children: [{ tag: 'span', children: [{ tag: 'br' }] }],
18086
+ },
17921
18087
  _a[2 /* BlockquoteWrapper */] = {
17922
18088
  tag: 'blockquote',
17923
18089
  style: 'margin-top:0;margin-bottom:0',
@@ -17935,8 +18101,14 @@ exports.KnownCreateElementData = (_a = {},
17935
18101
  style: 'position: fixed; width: 0; height: 0',
17936
18102
  },
17937
18103
  _a[6 /* ImageEditWrapper */] = {
17938
- tag: 'div',
17939
- style: 'width:100%;height:100%;position:relative;overflow:hidden',
18104
+ tag: 'span',
18105
+ style: 'max-width:100%;position:fixed',
18106
+ children: [
18107
+ {
18108
+ tag: 'div',
18109
+ style: 'width:100%;height:100%;position:relative;overflow:hidden',
18110
+ },
18111
+ ],
17940
18112
  },
17941
18113
  _a[7 /* TableHorizontalResizer */] = {
17942
18114
  tag: 'div',
@@ -19513,31 +19685,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
19513
19685
  __exportStar(__webpack_require__(/*! ./plugins/ImageResize/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageResize/index.ts"), exports);
19514
19686
 
19515
19687
 
19516
- /***/ }),
19517
-
19518
- /***/ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts":
19519
- /*!*****************************************************************!*\
19520
- !*** ./packages/roosterjs-editor-plugins/lib/ImageSelection.ts ***!
19521
- \*****************************************************************/
19522
- /*! no static exports found */
19523
- /***/ (function(module, exports, __webpack_require__) {
19524
-
19525
- "use strict";
19526
-
19527
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19528
- if (k2 === undefined) k2 = k;
19529
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
19530
- }) : (function(o, m, k, k2) {
19531
- if (k2 === undefined) k2 = k;
19532
- o[k2] = m[k];
19533
- }));
19534
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19535
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19536
- };
19537
- Object.defineProperty(exports, "__esModule", { value: true });
19538
- __exportStar(__webpack_require__(/*! ./plugins/ImageSelection/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts"), exports);
19539
-
19540
-
19541
19688
  /***/ }),
19542
19689
 
19543
19690
  /***/ "./packages/roosterjs-editor-plugins/lib/Paste.ts":
@@ -19698,7 +19845,6 @@ __exportStar(__webpack_require__(/*! ./TableResize */ "./packages/roosterjs-edit
19698
19845
  __exportStar(__webpack_require__(/*! ./Watermark */ "./packages/roosterjs-editor-plugins/lib/Watermark.ts"), exports);
19699
19846
  __exportStar(__webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/TableCellSelection.ts"), exports);
19700
19847
  __exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-editor-plugins/lib/AutoFormat.ts"), exports);
19701
- __exportStar(__webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts"), exports);
19702
19848
 
19703
19849
 
19704
19850
  /***/ }),
@@ -20359,6 +20505,8 @@ var getAutoBulletListStyle_1 = __webpack_require__(/*! ../utils/getAutoBulletLis
20359
20505
  var getAutoNumberingListStyle_1 = __webpack_require__(/*! ../utils/getAutoNumberingListStyle */ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/getAutoNumberingListStyle.ts");
20360
20506
  var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
20361
20507
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
20508
+ var PREVIOUS_BLOCK_CACHE_KEY = 'previousBlock';
20509
+ var NEXT_BLOCK_CACHE_KEY = 'nextBlock';
20362
20510
  var ListStyleDefinitionMetadata = (0, roosterjs_editor_dom_1.createObjectDefinition)({
20363
20511
  orderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 20 /* Max */),
20364
20512
  unorderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 9 /* Max */),
@@ -20578,7 +20726,7 @@ var AutoNumberingList = {
20578
20726
  var number = isFirstItemOfAList(textBeforeCursor)
20579
20727
  ? 1
20580
20728
  : parseInt(textBeforeCursor);
20581
- var isLi = getPreviousList(editor, textRange);
20729
+ var isLi = getPreviousListItem(editor, textRange);
20582
20730
  var listStyle = (0, getAutoNumberingListStyle_1.default)(textBeforeCursor);
20583
20731
  prepareAutoBullet(editor, textRange);
20584
20732
  (0, roosterjs_editor_api_1.toggleNumbering)(editor, isLi && number !== 1 ? undefined : number /** startNumber */, listStyle, 'autoToggleList' /** apiNameOverride */);
@@ -20587,7 +20735,7 @@ var AutoNumberingList = {
20587
20735
  }, null /*changeSource*/, true /*canUndoByBackspace*/);
20588
20736
  },
20589
20737
  };
20590
- var getPreviousList = function (editor, textRange) {
20738
+ var getPreviousListItem = function (editor, textRange) {
20591
20739
  var _a;
20592
20740
  var previousNode = (_a = editor
20593
20741
  .getBodyTraverser(textRange === null || textRange === void 0 ? void 0 : textRange.startContainer)
@@ -20596,10 +20744,12 @@ var getPreviousList = function (editor, textRange) {
20596
20744
  };
20597
20745
  var getPreviousListType = function (editor, textRange, listType) {
20598
20746
  var type = listType === 1 /* Ordered */ ? 'orderedStyleType' : 'unorderedStyleType';
20599
- var previousNode = getPreviousList(editor, textRange);
20600
- return previousNode && (0, roosterjs_editor_dom_1.getTagOfNode)(previousNode) === 'LI'
20601
- ? (0, roosterjs_editor_dom_1.getMetadata)(previousNode.parentElement, ListStyleDefinitionMetadata)[type]
20747
+ var listItem = getPreviousListItem(editor, textRange);
20748
+ var list = listItem
20749
+ ? (0, roosterjs_editor_dom_1.findClosestElementAncestor)(listItem, undefined /** root*/, listType === 1 /* Ordered */ ? 'ol' : 'ul')
20602
20750
  : null;
20751
+ var metadata = list ? (0, roosterjs_editor_dom_1.getMetadata)(list, ListStyleDefinitionMetadata) : null;
20752
+ return metadata ? metadata[type] : null;
20603
20753
  };
20604
20754
  var isFirstItemOfAList = function (item) {
20605
20755
  var number = parseInt(item);
@@ -20691,6 +20841,57 @@ function shouldTriggerList(event, editor, getListStyle, listType) {
20691
20841
  listStyle &&
20692
20842
  shouldTriggerNewListStyle);
20693
20843
  }
20844
+ /**
20845
+ * MergeListOnBackspaceAfterList edit feature, provides the ability to merge list on backspace on block after a list.
20846
+ */
20847
+ var MergeListOnBackspaceAfterList = {
20848
+ keys: [8 /* BACKSPACE */],
20849
+ shouldHandleEvent: function (event, editor) {
20850
+ var _a, _b;
20851
+ var target = editor.getElementAtCursor();
20852
+ if (target) {
20853
+ var cursorBlock = (_a = editor.getBlockElementAtNode(target)) === null || _a === void 0 ? void 0 : _a.getStartNode();
20854
+ var previousBlock_1 = (_b = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.previousElementSibling) !== null && _b !== void 0 ? _b : null;
20855
+ if (isList(previousBlock_1)) {
20856
+ var range = editor.getSelectionRange();
20857
+ var searcher = editor.getContentSearcherOfCursor(event);
20858
+ var textBeforeCursor = searcher === null || searcher === void 0 ? void 0 : searcher.getSubStringBefore(4);
20859
+ var nearestInline = searcher === null || searcher === void 0 ? void 0 : searcher.getNearestNonTextInlineElement();
20860
+ if (range && range.collapsed && textBeforeCursor === '' && !nearestInline) {
20861
+ var tempBlock = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.nextElementSibling;
20862
+ var nextBlock_1 = isList(tempBlock) ? tempBlock : tempBlock === null || tempBlock === void 0 ? void 0 : tempBlock.firstChild;
20863
+ if (isList(nextBlock_1) &&
20864
+ (0, roosterjs_editor_dom_1.getTagOfNode)(previousBlock_1) == (0, roosterjs_editor_dom_1.getTagOfNode)(nextBlock_1)) {
20865
+ var element = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return previousBlock_1; });
20866
+ var nextElement = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return nextBlock_1; });
20867
+ return !!element && !!nextElement;
20868
+ }
20869
+ }
20870
+ }
20871
+ }
20872
+ return false;
20873
+ },
20874
+ handleEvent: function (event, editor) {
20875
+ editor.runAsync(function (editor) {
20876
+ var previousList = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return null; });
20877
+ var targetBlock = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return null; });
20878
+ var rangeBeforeWriteBack = editor.getSelectionRange();
20879
+ if (previousList && targetBlock && rangeBeforeWriteBack) {
20880
+ var fvList = new roosterjs_editor_dom_1.VList(previousList);
20881
+ fvList.mergeVList(new roosterjs_editor_dom_1.VList(targetBlock));
20882
+ var span = editor.getDocument().createElement('span');
20883
+ span.id = 'restoreRange';
20884
+ rangeBeforeWriteBack.insertNode(span);
20885
+ fvList.writeBack();
20886
+ span = editor.queryElements('#restoreRange')[0];
20887
+ if (span.parentElement) {
20888
+ editor.select(new roosterjs_editor_dom_1.Position(span, -3 /* After */));
20889
+ span.parentElement.removeChild(span);
20890
+ }
20891
+ }
20892
+ });
20893
+ },
20894
+ };
20694
20895
  /**
20695
20896
  * @internal
20696
20897
  */
@@ -20705,7 +20906,12 @@ exports.ListFeatures = {
20705
20906
  maintainListChainWhenDelete: MaintainListChainWhenDelete,
20706
20907
  autoNumberingList: AutoNumberingList,
20707
20908
  autoBulletList: AutoBulletList,
20909
+ mergeListOnBackspaceAfterList: MergeListOnBackspaceAfterList,
20708
20910
  };
20911
+ function isList(element) {
20912
+ return (!!element &&
20913
+ ((0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLOListElement') || (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLUListElement')));
20914
+ }
20709
20915
 
20710
20916
 
20711
20917
  /***/ }),
@@ -22310,12 +22516,8 @@ var getGeneratedImageSize_1 = __webpack_require__(/*! ./editInfoUtils/getGenerat
22310
22516
  var Cropper_1 = __webpack_require__(/*! ./imageEditors/Cropper */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Cropper.ts");
22311
22517
  var editInfo_1 = __webpack_require__(/*! ./editInfoUtils/editInfo */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/editInfo.ts");
22312
22518
  var Rotator_1 = __webpack_require__(/*! ./imageEditors/Rotator */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Rotator.ts");
22313
- var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
22314
22519
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
22315
22520
  var Resizer_1 = __webpack_require__(/*! ./imageEditors/Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
22316
- var SHIFT_KEYCODE = 16;
22317
- var CTRL_KEYCODE = 17;
22318
- var ALT_KEYCODE = 18;
22319
22521
  var DIRECTIONS = 8;
22320
22522
  var DirectionRad = (Math.PI * 2) / DIRECTIONS;
22321
22523
  var DirectionOrder = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
@@ -22344,10 +22546,6 @@ var ImageEditHTMLMap = (_a = {},
22344
22546
  _a[4 /* Rotate */] = Rotator_1.getRotateHTML,
22345
22547
  _a[8 /* Crop */] = Cropper_1.getCropHTML,
22346
22548
  _a);
22347
- /**
22348
- * Image edit entity name
22349
- */
22350
- var IMAGE_EDIT_WRAPPER_ENTITY_TYPE = 'IMAGE_EDIT_WRAPPER';
22351
22549
  /**
22352
22550
  * Default background colors for rotate handle
22353
22551
  */
@@ -22375,35 +22573,31 @@ var ImageEdit = /** @class */ (function () {
22375
22573
  * quit editing mode when editor lose focus
22376
22574
  */
22377
22575
  this.onBlur = function () {
22378
- _this.setEditingImage(null);
22576
+ _this.setEditingImage(null, true);
22379
22577
  };
22380
22578
  /**
22381
22579
  * Remove the temp wrapper of the image
22382
- * @param wrapper The wrapper object to remove. If not specified, remove all existing wrappers.
22383
22580
  */
22384
- this.removeWrapper = function (wrapper) {
22385
- var parent = wrapper === null || wrapper === void 0 ? void 0 : wrapper.parentNode;
22386
- var img = wrapper === null || wrapper === void 0 ? void 0 : wrapper.querySelector('img');
22387
- if (img && parent) {
22388
- img.style.position = '';
22389
- img.style.margin = null;
22390
- img.style.textAlign = null;
22391
- parent.insertBefore(img, wrapper);
22392
- parent.removeChild(wrapper);
22581
+ this.removeWrapper = function () {
22582
+ var _a, _b;
22583
+ var doc = _this.editor.getDocument();
22584
+ if (_this.zoomWrapper && ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.contains(_this.zoomWrapper))) {
22585
+ (_b = doc.body) === null || _b === void 0 ? void 0 : _b.removeChild(_this.zoomWrapper);
22586
+ _this.toggleImageVisibility(_this.image, true /** showImage */);
22393
22587
  }
22588
+ _this.wrapper = null;
22589
+ _this.zoomWrapper = null;
22394
22590
  };
22395
22591
  /**
22396
22592
  * Update image edit elements to reflect current editing result
22397
22593
  * @param context
22398
22594
  */
22399
22595
  this.updateWrapper = function (context) {
22400
- var wrapper = _this.getImageWrapper(_this.image);
22596
+ var wrapper = _this.wrapper;
22401
22597
  if (wrapper) {
22402
22598
  // Prepare: get related editing elements
22403
22599
  var cropContainers = getEditElements(wrapper, "r_cropC" /* CropContainer */);
22404
22600
  var cropOverlays = getEditElements(wrapper, "r_cropO" /* CropOverlay */);
22405
- var rotateCenter = getEditElements(wrapper, "r_rotateC" /* RotateCenter */)[0];
22406
- var rotateHandle = getEditElements(wrapper, "r_rotateH" /* RotateHandle */)[0];
22407
22601
  var resizeHandles = getEditElements(wrapper, "r_resizeH" /* ResizeHandle */);
22408
22602
  var cropHandles = getEditElements(wrapper, "r_cropH" /* CropHandle */);
22409
22603
  // Cropping and resizing will show different UI, so check if it is cropping here first
@@ -22422,12 +22616,14 @@ var ImageEdit = /** @class */ (function () {
22422
22616
  wrapper.style.height = getPx(visibleHeight);
22423
22617
  wrapper.style.margin = marginVertical + "px " + marginHorizontal + "px";
22424
22618
  wrapper.style.transform = "rotate(" + angleRad + "rad)";
22619
+ _this.zoomWrapper.style.width = getPx(visibleWidth);
22620
+ _this.zoomWrapper.style.height = getPx(visibleHeight);
22425
22621
  // Update the text-alignment to avoid the image to overflow if the parent element have align center or right
22426
22622
  // or if the direction is Right To Left
22427
22623
  wrapper.style.textAlign = isRtl(wrapper.parentNode) ? 'right' : 'left';
22428
22624
  // Update size of the image
22429
- _this.image.style.width = getPx(originalWidth);
22430
- _this.image.style.height = getPx(originalHeight);
22625
+ _this.clonedImage.style.width = getPx(originalWidth);
22626
+ _this.clonedImage.style.height = getPx(originalHeight);
22431
22627
  if (isCropping) {
22432
22628
  // For crop, we also need to set position of the overlays
22433
22629
  setSize(cropContainers[0], cropLeftPx, cropTopPx, cropRightPx, cropBottomPx, undefined, undefined);
@@ -22439,7 +22635,7 @@ var ImageEdit = /** @class */ (function () {
22439
22635
  }
22440
22636
  else {
22441
22637
  // For rotate/resize, set the margin of the image so that cropped part won't be visible
22442
- _this.image.style.margin = -cropTopPx + "px 0 0 " + -cropLeftPx + "px";
22638
+ _this.clonedImage.style.margin = -cropTopPx + "px 0 0 " + -cropLeftPx + "px";
22443
22639
  // Double check resize
22444
22640
  if ((context === null || context === void 0 ? void 0 : context.elementClass) == "r_resizeH" /* ResizeHandle */) {
22445
22641
  var clientWidth = wrapper.clientWidth;
@@ -22448,7 +22644,6 @@ var ImageEdit = /** @class */ (function () {
22448
22644
  (0, Resizer_1.doubleCheckResize)(_this.editInfo, _this.options.preserveRatio, clientWidth, clientHeight);
22449
22645
  _this.updateWrapper();
22450
22646
  }
22451
- (0, Rotator_1.updateRotateHandlePosition)(_this.editInfo, _this.editor.getRelativeDistanceToEditor(wrapper, true /*addScroll*/), marginVertical, rotateCenter, rotateHandle);
22452
22647
  updateHandleCursor(resizeHandles, angleRad);
22453
22648
  }
22454
22649
  }
@@ -22485,56 +22680,26 @@ var ImageEdit = /** @class */ (function () {
22485
22680
  };
22486
22681
  /**
22487
22682
  * Handle events triggered from editor
22488
- * @param event PluginEvent object
22683
+ * @param e PluginEvent object
22489
22684
  */
22490
22685
  ImageEdit.prototype.onPluginEvent = function (e) {
22491
22686
  switch (e.eventType) {
22687
+ case 22 /* SelectionChanged */:
22688
+ if (e.selectionRangeEx &&
22689
+ e.selectionRangeEx.type === 2 /* ImageSelection */) {
22690
+ this.setEditingImage(e.selectionRangeEx.image, 7 /* ResizeAndRotate */);
22691
+ }
22692
+ break;
22492
22693
  case 5 /* MouseDown */:
22493
22694
  this.setEditingImage(null);
22494
22695
  break;
22495
- case 6 /* MouseUp */:
22496
- var target = e.rawEvent.target;
22497
- if (e.isClicking &&
22498
- e.rawEvent.button == 0 &&
22499
- (0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
22500
- target.isContentEditable &&
22501
- (0, roosterjs_editor_dom_1.matchesSelector)(target, this.options.imageSelector)) {
22502
- this.setEditingImage(target, 7 /* ResizeAndRotate */);
22503
- }
22504
- break;
22505
22696
  case 0 /* KeyDown */:
22506
- var key = e.rawEvent.which;
22507
- if (key == 46 /* DELETE */ || key == 8 /* BACKSPACE */) {
22508
- // Set current editing image to null and select the image if any, and do not prevent default of the event
22509
- // so that browser will delete the selected image for us
22510
- this.setEditingImage(null, true /*selectImage*/);
22511
- }
22512
- else if (key == 27 /* ESCAPE */ && this.image) {
22513
- // Press ESC should cancel current editing operation, resume back to original edit info
22514
- this.editInfo = (0, editInfo_1.getEditInfoFromImage)(this.image);
22515
- this.setEditingImage(null);
22516
- e.rawEvent.preventDefault();
22517
- }
22518
- else if (key != SHIFT_KEYCODE && key != CTRL_KEYCODE && key != ALT_KEYCODE) {
22519
- // For other key, just unselect current image and select it. If this is an input key, the image will be replaced
22520
- this.setEditingImage(null, true /*selectImage*/);
22521
- }
22697
+ this.setEditingImage(null);
22522
22698
  break;
22523
22699
  case 7 /* ContentChanged */:
22524
- if (e.source != "InsertEntity" /* InsertEntity */ ||
22525
- e.data.type != IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
22700
+ if (e.source !== "Format" /* Format */) {
22526
22701
  // After contentChanged event, the current image wrapper may not be valid any more, remove all of them if any
22527
- this.editor.queryElements((0, roosterjs_editor_dom_1.getEntitySelector)(IMAGE_EDIT_WRAPPER_ENTITY_TYPE), this.removeWrapper);
22528
- }
22529
- break;
22530
- case 15 /* EntityOperation */:
22531
- if (e.entity.type == IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
22532
- if (e.operation == 8 /* ReplaceTemporaryContent */) {
22533
- this.removeWrapper(e.entity.wrapper);
22534
- }
22535
- else if (e.operation == 1 /* Click */) {
22536
- e.rawEvent.preventDefault();
22537
- }
22702
+ this.removeWrapper();
22538
22703
  }
22539
22704
  break;
22540
22705
  case 8 /* ExtractContentWithDom */:
@@ -22543,10 +22708,13 @@ var ImageEdit = /** @class */ (function () {
22543
22708
  (0, editInfo_1.deleteEditInfo)(img);
22544
22709
  });
22545
22710
  break;
22711
+ case 14 /* Scroll */:
22712
+ this.setEditingImage(null);
22713
+ break;
22546
22714
  }
22547
22715
  };
22548
22716
  /**
22549
- * Check if the given image edit operation is allowed by this pluign
22717
+ * Check if the given image edit operation is allowed by this plugin
22550
22718
  * @param operation The image edit operation to check
22551
22719
  * @returns True means it is allowed, otherwise false
22552
22720
  */
@@ -22557,16 +22725,13 @@ var ImageEdit = /** @class */ (function () {
22557
22725
  var _this = this;
22558
22726
  var operation = typeof operationOrSelect === 'number' ? operationOrSelect : 0 /* None */;
22559
22727
  var selectImage = typeof operationOrSelect === 'number' ? false : !!operationOrSelect;
22560
- if (this.image) {
22728
+ if (!image && this.image) {
22561
22729
  // When there is image in editing, clean up any cached objects and elements
22562
22730
  this.clearDndHelpers();
22563
22731
  // Apply the changes, and add undo snapshot if necessary
22564
- (0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized);
22732
+ (0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized, this.clonedImage);
22565
22733
  // Remove editing wrapper
22566
- var wrapper = this.getImageWrapper(this.image);
22567
- if (wrapper) {
22568
- this.removeWrapper(wrapper);
22569
- }
22734
+ this.removeWrapper();
22570
22735
  this.editor.addUndoSnapshot(function () { return _this.image; }, "ImageResize" /* ImageResize */);
22571
22736
  if (selectImage) {
22572
22737
  this.editor.select(this.image);
@@ -22574,6 +22739,7 @@ var ImageEdit = /** @class */ (function () {
22574
22739
  this.image = null;
22575
22740
  this.editInfo = null;
22576
22741
  this.lastSrc = null;
22742
+ this.clonedImage = null;
22577
22743
  }
22578
22744
  if (!this.image && (image === null || image === void 0 ? void 0 : image.isContentEditable)) {
22579
22745
  // If there is new image to edit, enter editing mode for this image
@@ -22587,12 +22753,12 @@ var ImageEdit = /** @class */ (function () {
22587
22753
  ((0, canRegenerateImage_1.default)(image) ? operation : 3 /* Resize */) &
22588
22754
  this.allowedOperations;
22589
22755
  // Create and update editing wrapper and elements
22590
- var wrapper = this.createWrapper(operation);
22756
+ this.createWrapper(operation);
22591
22757
  this.updateWrapper();
22592
22758
  // Init drag and drop
22593
22759
  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);
22594
- // Put cursor next to the image
22595
- this.editor.select(wrapper, -3 /* After */);
22760
+ this.editor.select(this.image);
22761
+ this.toggleImageVisibility(this.image, false /** showImage */);
22596
22762
  }
22597
22763
  };
22598
22764
  /**
@@ -22600,25 +22766,22 @@ var ImageEdit = /** @class */ (function () {
22600
22766
  */
22601
22767
  ImageEdit.prototype.createWrapper = function (operation) {
22602
22768
  var _this = this;
22603
- // Wrap the image with an entity so that we can easily retrieve it later
22604
- 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;
22605
- wrapper.style.position = 'relative';
22606
- wrapper.style.maxWidth = '100%';
22769
+ //Clone the image and insert the clone in a entity
22770
+ this.clonedImage = this.image.cloneNode(true);
22771
+ this.wrapper = (0, roosterjs_editor_dom_1.createElement)(6 /* ImageEditWrapper */, this.image.ownerDocument);
22772
+ this.wrapper.firstChild.appendChild(this.clonedImage);
22607
22773
  // keep the same vertical align
22608
- var originalVerticalAlign = this.image.ownerDocument.defaultView
22609
- .getComputedStyle(this.image)
22610
- .getPropertyValue('vertical-align');
22774
+ var originalVerticalAlign = this.getStylePropertyValue(this.image, 'vertical-align');
22611
22775
  if (originalVerticalAlign) {
22612
- wrapper.style.verticalAlign = originalVerticalAlign;
22776
+ this.wrapper.style.verticalAlign = originalVerticalAlign;
22613
22777
  }
22614
- wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
22778
+ this.wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
22615
22779
  // Cache current src so that we can compare it after edit see if src is changed
22616
22780
  this.lastSrc = this.image.getAttribute('src');
22617
22781
  // Set image src to original src to help show editing UI, also it will be used when regenerate image dataURL after editing
22618
- this.image.src = this.editInfo.src;
22619
- this.image.style.position = 'absolute';
22620
- this.image.style.maxWidth = null;
22621
- var isExperimentalHandlesEnabled = this.editor.isFeatureEnabled("AdaptiveHandlesResizer" /* AdaptiveHandlesResizer */);
22782
+ this.clonedImage.src = this.editInfo.src;
22783
+ this.clonedImage.style.position = 'absolute';
22784
+ this.clonedImage.style.maxWidth = null;
22622
22785
  // Get HTML for all edit elements (resize handle, rotate handle, crop handle and overlay, ...) and create HTML element
22623
22786
  var options = {
22624
22787
  borderColor: getColorString(this.options.borderColor, this.editor.isDarkMode()),
@@ -22626,8 +22789,7 @@ var ImageEdit = /** @class */ (function () {
22626
22789
  rotateHandleBackColor: this.editor.isDarkMode()
22627
22790
  ? DARK_MODE_BGCOLOR
22628
22791
  : LIGHT_MODE_BGCOLOR,
22629
- isSmallImage: isASmallImage(this.editInfo, isExperimentalHandlesEnabled),
22630
- handlesExperimentalFeatures: isExperimentalHandlesEnabled,
22792
+ isSmallImage: isASmallImage(this.editInfo),
22631
22793
  };
22632
22794
  var htmlData = [(0, Resizer_1.getResizeBordersHTML)(options)];
22633
22795
  (0, roosterjs_editor_dom_1.getObjectKeys)(ImageEditHTMLMap).forEach(function (thisOperation) {
@@ -22638,20 +22800,47 @@ var ImageEdit = /** @class */ (function () {
22638
22800
  htmlData.forEach(function (data) {
22639
22801
  var element = (0, roosterjs_editor_dom_1.createElement)(data, _this.image.ownerDocument);
22640
22802
  if (element) {
22641
- wrapper.appendChild(element);
22803
+ _this.wrapper.appendChild(element);
22642
22804
  }
22643
22805
  });
22644
- return wrapper;
22806
+ this.insertImageWrapper(this.image, this.wrapper, this.editor.getZoomScale());
22645
22807
  };
22646
- /**
22647
- * Get image wrapper from image
22648
- * @param image The image to get wrapper from
22649
- */
22650
- ImageEdit.prototype.getImageWrapper = function (image) {
22651
- var _a;
22652
- // Get the image wrapper from image using Entity API
22653
- 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);
22654
- return (entity === null || entity === void 0 ? void 0 : entity.type) == IMAGE_EDIT_WRAPPER_ENTITY_TYPE ? entity.wrapper : null;
22808
+ ImageEdit.prototype.toggleImageVisibility = function (image, showImage) {
22809
+ var editorId = this.editor.getEditorDomAttribute('id');
22810
+ var doc = this.editor.getDocument();
22811
+ var editingId = 'editingId' + editorId;
22812
+ if (showImage) {
22813
+ (0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, editingId);
22814
+ }
22815
+ else {
22816
+ var cssRule = "#" + editorId + " #" + image.id + " {visibility: hidden}";
22817
+ (0, roosterjs_editor_dom_1.setGlobalCssStyles)(doc, cssRule, editingId);
22818
+ }
22819
+ };
22820
+ ImageEdit.prototype.createZoomWrapper = function (wrapper, scale) {
22821
+ var zoomWrapper = this.editor.getDocument().createElement('div');
22822
+ zoomWrapper.style.transform = "scale(" + (scale || 1) + ")";
22823
+ zoomWrapper.style.transformOrigin = 'top left';
22824
+ zoomWrapper.style.position = 'fixed';
22825
+ zoomWrapper.appendChild(wrapper);
22826
+ return zoomWrapper;
22827
+ };
22828
+ ImageEdit.prototype.copyImageSize = function (image, element) {
22829
+ var _a = image.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
22830
+ element.style.top = top + "px";
22831
+ element.style.bottom = bottom + "px";
22832
+ element.style.right = right + "px";
22833
+ element.style.left = left + "px";
22834
+ return element;
22835
+ };
22836
+ ImageEdit.prototype.insertImageWrapper = function (image, wrapper, scale) {
22837
+ this.zoomWrapper = this.copyImageSize(image, this.createZoomWrapper(wrapper, scale));
22838
+ this.editor.getDocument().body.appendChild(this.zoomWrapper);
22839
+ };
22840
+ ImageEdit.prototype.getStylePropertyValue = function (element, property) {
22841
+ return element.ownerDocument.defaultView
22842
+ .getComputedStyle(this.image)
22843
+ .getPropertyValue(property);
22655
22844
  };
22656
22845
  /**
22657
22846
  * Create drag and drop helpers
@@ -22666,7 +22855,7 @@ var ImageEdit = /** @class */ (function () {
22666
22855
  options: this.options,
22667
22856
  elementClass: elementClass,
22668
22857
  };
22669
- var wrapper = this.getImageWrapper(this.image);
22858
+ var wrapper = this.wrapper;
22670
22859
  return wrapper
22671
22860
  ? getEditElements(wrapper, elementClass).map(function (element) {
22672
22861
  return new DragAndDropHelper_1.default(element, __assign(__assign({}, commonContext), { x: element.dataset.x, y: element.dataset.y }), _this.updateWrapper, dragAndDrop, _this.editor.getZoomScale());
@@ -22747,9 +22936,9 @@ function isFixedNumberValue(value) {
22747
22936
  var numberValue = typeof value === 'string' ? parseInt(value) : value;
22748
22937
  return !isNaN(numberValue);
22749
22938
  }
22750
- function isASmallImage(editInfo, isFeatureEnabled) {
22939
+ function isASmallImage(editInfo) {
22751
22940
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx;
22752
- return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE && isFeatureEnabled;
22941
+ return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE;
22753
22942
  }
22754
22943
  function getColorString(color, isDarkMode) {
22755
22944
  if (typeof color === 'string') {
@@ -22936,10 +23125,11 @@ var editInfo_1 = __webpack_require__(/*! ./editInfo */ "./packages/roosterjs-edi
22936
23125
  * @param image The image to apply the change
22937
23126
  * @param editInfo Edit info that contains the changed information of the image
22938
23127
  * @param previousSrc Last src value of the image before the change was made
23128
+ * @param editingImage (optional) Image in editing state
22939
23129
  */
22940
- function applyChange(editor, image, editInfo, previousSrc, wasResized) {
23130
+ function applyChange(editor, image, editInfo, previousSrc, wasResized, editingImage) {
22941
23131
  var newSrc = '';
22942
- var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(image);
23132
+ var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(editingImage !== null && editingImage !== void 0 ? editingImage : image);
22943
23133
  var state = (0, checkEditInfoState_1.default)(editInfo, initEditInfo);
22944
23134
  switch (state) {
22945
23135
  case 1 /* ResizeOnly */:
@@ -22953,7 +23143,7 @@ function applyChange(editor, image, editInfo, previousSrc, wasResized) {
22953
23143
  break;
22954
23144
  case 3 /* FullyChanged */:
22955
23145
  // For other cases (cropped, rotated, ...) we need to create a new image to reflect the change
22956
- newSrc = (0, generateDataURL_1.default)(image, editInfo);
23146
+ newSrc = (0, generateDataURL_1.default)(editingImage !== null && editingImage !== void 0 ? editingImage : image, editInfo);
22957
23147
  break;
22958
23148
  }
22959
23149
  var srcChanged = newSrc != previousSrc;
@@ -23505,14 +23695,12 @@ exports.doubleCheckResize = doubleCheckResize;
23505
23695
  * Get HTML for resize handles at the corners
23506
23696
  */
23507
23697
  function getCornerResizeHTML(_a, onShowResizeHandle) {
23508
- var resizeBorderColor = _a.borderColor, handlesExperimentalFeatures = _a.handlesExperimentalFeatures;
23698
+ var resizeBorderColor = _a.borderColor;
23509
23699
  var result = [];
23510
23700
  Xs.forEach(function (x) {
23511
23701
  return Ys.forEach(function (y) {
23512
23702
  var elementData = (x == '') == (y == '')
23513
- ? getResizeHandleHTML(x, y, resizeBorderColor, handlesExperimentalFeatures
23514
- ? 1 /* CircularHandlesCorner */
23515
- : 0 /* SquareHandles */)
23703
+ ? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
23516
23704
  : null;
23517
23705
  if (onShowResizeHandle) {
23518
23706
  onShowResizeHandle(elementData, x, y);
@@ -23528,7 +23716,7 @@ exports.getCornerResizeHTML = getCornerResizeHTML;
23528
23716
  * Get HTML for resize handles on the sides
23529
23717
  */
23530
23718
  function getSideResizeHTML(_a, onShowResizeHandle) {
23531
- var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage, handlesExperimentalFeatures = _a.handlesExperimentalFeatures;
23719
+ var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage;
23532
23720
  if (isSmallImage) {
23533
23721
  return null;
23534
23722
  }
@@ -23536,9 +23724,7 @@ function getSideResizeHTML(_a, onShowResizeHandle) {
23536
23724
  Xs.forEach(function (x) {
23537
23725
  return Ys.forEach(function (y) {
23538
23726
  var elementData = (x == '') != (y == '')
23539
- ? getResizeHandleHTML(x, y, resizeBorderColor, handlesExperimentalFeatures
23540
- ? 1 /* CircularHandlesCorner */
23541
- : 0 /* SquareHandles */)
23727
+ ? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
23542
23728
  : null;
23543
23729
  if (onShowResizeHandle) {
23544
23730
  onShowResizeHandle(elementData, x, y);
@@ -23615,7 +23801,7 @@ var __assign = (this && this.__assign) || function () {
23615
23801
  return __assign.apply(this, arguments);
23616
23802
  };
23617
23803
  Object.defineProperty(exports, "__esModule", { value: true });
23618
- exports.getRotateHTML = exports.updateRotateHandlePosition = exports.Rotator = void 0;
23804
+ exports.getRotateHTML = exports.Rotator = void 0;
23619
23805
  var ROTATE_SIZE = 32;
23620
23806
  var ROTATE_GAP = 15;
23621
23807
  var DEG_PER_RAD = 180 / Math.PI;
@@ -23650,26 +23836,6 @@ exports.Rotator = {
23650
23836
  }
23651
23837
  },
23652
23838
  };
23653
- /**
23654
- * @internal
23655
- * Move rotate handle. When image is very close to the border of editor, rotate handle may not be visible.
23656
- * Fix it by reduce the distance from image to rotate handle
23657
- */
23658
- function updateRotateHandlePosition(editInfo, distance, marginVertical, rotateCenter, rotateHandle) {
23659
- if (rotateCenter && rotateHandle && distance) {
23660
- var angleRad = editInfo.angleRad, heightPx = editInfo.heightPx;
23661
- var cosAngle = Math.cos(angleRad);
23662
- var adjustedDistance = cosAngle <= 0
23663
- ? Number.MAX_SAFE_INTEGER
23664
- : (distance[1] + heightPx / 2 + marginVertical) / cosAngle - heightPx / 2;
23665
- var rotateGap = Math.max(Math.min(ROTATE_GAP, adjustedDistance), 0);
23666
- var rotateTop = Math.max(Math.min(ROTATE_SIZE, adjustedDistance - rotateGap), 0);
23667
- rotateCenter.style.top = -rotateGap + 'px';
23668
- rotateCenter.style.height = rotateGap + 'px';
23669
- rotateHandle.style.top = -rotateTop + 'px';
23670
- }
23671
- }
23672
- exports.updateRotateHandlePosition = updateRotateHandlePosition;
23673
23839
  /**
23674
23840
  * @internal
23675
23841
  * Get HTML for rotate elements, including the rotate handle with icon, and a line between the handle and the image
@@ -23681,12 +23847,12 @@ function getRotateHTML(_a) {
23681
23847
  {
23682
23848
  tag: 'div',
23683
23849
  className: "r_rotateC" /* RotateCenter */,
23684
- style: "position:absolute;left:50%;width:1px;background-color:" + borderColor,
23850
+ style: "position:absolute;left:50%;width:1px;background-color:" + borderColor + ";top:" + -ROTATE_GAP + "px;height:" + ROTATE_GAP + "px;",
23685
23851
  children: [
23686
23852
  {
23687
23853
  tag: 'div',
23688
23854
  className: "r_rotateH" /* RotateHandle */,
23689
- 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",
23855
+ 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;",
23690
23856
  children: [getRotateIconHTML(borderColor)],
23691
23857
  },
23692
23858
  ],
@@ -23840,111 +24006,6 @@ var ImageResize_1 = __webpack_require__(/*! ./ImageResize */ "./packages/rooster
23840
24006
  Object.defineProperty(exports, "ImageResize", { enumerable: true, get: function () { return ImageResize_1.default; } });
23841
24007
 
23842
24008
 
23843
- /***/ }),
23844
-
23845
- /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts":
23846
- /*!****************************************************************************************!*\
23847
- !*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts ***!
23848
- \****************************************************************************************/
23849
- /*! no static exports found */
23850
- /***/ (function(module, exports, __webpack_require__) {
23851
-
23852
- "use strict";
23853
-
23854
- Object.defineProperty(exports, "__esModule", { value: true });
23855
- var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
23856
- var Escape = 'Escape';
23857
- var mouseRightButton = 2;
23858
- var mouseLeftButton = 0;
23859
- /**
23860
- * Requires @see ExperimentalFeatures.ImageSelection to be enabled.
23861
- * Detect image selection and help highlight the image
23862
- */
23863
- var ImageSelection = /** @class */ (function () {
23864
- function ImageSelection() {
23865
- this.editor = null;
23866
- }
23867
- /**
23868
- * Get a friendly name of this plugin
23869
- */
23870
- ImageSelection.prototype.getName = function () {
23871
- return 'ImageSelection';
23872
- };
23873
- /**
23874
- * Initialize this plugin. This should only be called from Editor
23875
- * @param editor Editor instance
23876
- */
23877
- ImageSelection.prototype.initialize = function (editor) {
23878
- this.editor = editor;
23879
- };
23880
- /**
23881
- * Dispose this plugin
23882
- */
23883
- ImageSelection.prototype.dispose = function () {
23884
- this.editor.select(null);
23885
- this.editor = null;
23886
- };
23887
- ImageSelection.prototype.onPluginEvent = function (event) {
23888
- if (this.editor && this.editor.isFeatureEnabled("ImageSelection" /* ImageSelection */)) {
23889
- switch (event.eventType) {
23890
- case 17 /* EnteredShadowEdit */:
23891
- case 18 /* LeavingShadowEdit */:
23892
- var selection = this.editor.getSelectionRangeEx();
23893
- if (selection.type == 2 /* ImageSelection */) {
23894
- this.editor.select(selection.image);
23895
- }
23896
- break;
23897
- case 5 /* MouseDown */:
23898
- var target = event.rawEvent.target;
23899
- if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
23900
- if (event.rawEvent.button === mouseRightButton) {
23901
- var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
23902
- this.editor.select(imageRange);
23903
- }
23904
- else if (event.rawEvent.button === mouseLeftButton) {
23905
- this.editor.select(target);
23906
- }
23907
- }
23908
- break;
23909
- case 0 /* KeyDown */:
23910
- var key = event.rawEvent.key;
23911
- var keyDownSelection = this.editor.getSelectionRangeEx();
23912
- if (keyDownSelection.type === 2 /* ImageSelection */) {
23913
- if (key === Escape) {
23914
- this.editor.select(keyDownSelection.image, -2 /* Before */);
23915
- this.editor.getSelectionRange().collapse();
23916
- event.rawEvent.stopPropagation();
23917
- }
23918
- else {
23919
- this.editor.select(keyDownSelection.ranges[0]);
23920
- }
23921
- }
23922
- break;
23923
- }
23924
- }
23925
- };
23926
- return ImageSelection;
23927
- }());
23928
- exports.default = ImageSelection;
23929
-
23930
-
23931
- /***/ }),
23932
-
23933
- /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts":
23934
- /*!*******************************************************************************!*\
23935
- !*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts ***!
23936
- \*******************************************************************************/
23937
- /*! no static exports found */
23938
- /***/ (function(module, exports, __webpack_require__) {
23939
-
23940
- "use strict";
23941
-
23942
- Object.defineProperty(exports, "__esModule", { value: true });
23943
- exports.ImageSelection = void 0;
23944
- var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts");
23945
- Object.defineProperty(exports, "ImageSelection", { enumerable: true, get: function () { return ImageSelection_1.default; } });
23946
-
23947
-
23948
24009
  /***/ }),
23949
24010
 
23950
24011
  /***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/Paste.ts":
@@ -25918,6 +25979,13 @@ var PickerPlugin = /** @class */ (function () {
25918
25979
  */
25919
25980
  PickerPlugin.prototype.dispose = function () {
25920
25981
  this.editor = null;
25982
+ this.isSuggesting = null;
25983
+ this.blockSuggestions = null;
25984
+ this.eventHandledOnKeyDown = null;
25985
+ this.lastKnownRange = null;
25986
+ this.isPendingInputEventHandling = null;
25987
+ this.currentInputLength = null;
25988
+ this.newInputLength = null;
25921
25989
  this.dataProvider.onDispose();
25922
25990
  };
25923
25991
  /**
@@ -29017,6 +29085,7 @@ var CompatibleExperimentalFeatures;
29017
29085
  */
29018
29086
  CompatibleExperimentalFeatures["ConvertSingleImageBody"] = "ConvertSingleImageBody";
29019
29087
  /**
29088
+ * @deprecated This feature is always enabled
29020
29089
  * Align table elements to left, center and right using setAlignment API
29021
29090
  */
29022
29091
  CompatibleExperimentalFeatures["TableAlignment"] = "TableAlignment";
@@ -29025,6 +29094,7 @@ var CompatibleExperimentalFeatures;
29025
29094
  */
29026
29095
  CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
29027
29096
  /**
29097
+ * @deprecated this feature is always enabled
29028
29098
  * Provide a circular resize handles that adaptive the number od handles to the size of the image
29029
29099
  */
29030
29100
  CompatibleExperimentalFeatures["AdaptiveHandlesResizer"] = "AdaptiveHandlesResizer";
@@ -29053,6 +29123,7 @@ var CompatibleExperimentalFeatures;
29053
29123
  */
29054
29124
  CompatibleExperimentalFeatures["NormalizeList"] = "NormalizeList";
29055
29125
  /**
29126
+ * @deprecated this feature is always enabled
29056
29127
  * When a html image is selected, the selected image data will be stored by editor core.
29057
29128
  */
29058
29129
  CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
@@ -29063,6 +29134,11 @@ var CompatibleExperimentalFeatures;
29063
29134
  * is the one closest to the item.
29064
29135
  */
29065
29136
  CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
29137
+ /**
29138
+ * When apply default format when initialize or user type, apply the format on a SPAN element rather than
29139
+ * the block element (In most case, the DIV element) so keep the block element clean.
29140
+ */
29141
+ CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
29066
29142
  })(CompatibleExperimentalFeatures = exports.CompatibleExperimentalFeatures || (exports.CompatibleExperimentalFeatures = {}));
29067
29143
 
29068
29144