roosterjs 8.47.0 → 8.48.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.
@@ -2362,6 +2362,17 @@ exports.default = clearBlockFormat;
2362
2362
 
2363
2363
  "use strict";
2364
2364
 
2365
+ var __values = (this && this.__values) || function(o) {
2366
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2367
+ if (m) return m.call(o);
2368
+ if (o && typeof o.length === "number") return {
2369
+ next: function () {
2370
+ if (o && i >= o.length) o = void 0;
2371
+ return { value: o && o[i++], done: !o };
2372
+ }
2373
+ };
2374
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2375
+ };
2365
2376
  Object.defineProperty(exports, "__esModule", { value: true });
2366
2377
  var applyListItemWrap_1 = __webpack_require__(/*! ../utils/applyListItemWrap */ "./packages/roosterjs-editor-api/lib/utils/applyListItemWrap.ts");
2367
2378
  var blockFormat_1 = __webpack_require__(/*! ../utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
@@ -2418,20 +2429,30 @@ function clearNodeFormat(node) {
2418
2429
  return returnBlockElement;
2419
2430
  }
2420
2431
  function clearAttribute(element) {
2432
+ var e_1, _a;
2421
2433
  var isTableCell = (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLTableCellElement');
2422
2434
  var isTable = (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLTableElement');
2423
- for (var _i = 0, _a = (0, roosterjs_editor_dom_1.toArray)(element.attributes); _i < _a.length; _i++) {
2424
- var attr = _a[_i];
2425
- if (isTableCell && attr.name == 'style') {
2426
- removeNonBorderStyles(element);
2427
- }
2428
- else if (isTable && attr.name == 'style') {
2429
- removeNotTableDefaultStyles(element);
2435
+ try {
2436
+ for (var _b = __values((0, roosterjs_editor_dom_1.toArray)(element.attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
2437
+ var attr = _c.value;
2438
+ if (isTableCell && attr.name == 'style') {
2439
+ removeNonBorderStyles(element);
2440
+ }
2441
+ else if (isTable && attr.name == 'style') {
2442
+ removeNotTableDefaultStyles(element);
2443
+ }
2444
+ else if (ATTRIBUTES_TO_PRESERVE.indexOf(attr.name.toLowerCase()) < 0 &&
2445
+ attr.name.indexOf('data-') != 0) {
2446
+ element.removeAttribute(attr.name);
2447
+ }
2430
2448
  }
2431
- else if (ATTRIBUTES_TO_PRESERVE.indexOf(attr.name.toLowerCase()) < 0 &&
2432
- attr.name.indexOf('data-') != 0) {
2433
- element.removeAttribute(attr.name);
2449
+ }
2450
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2451
+ finally {
2452
+ try {
2453
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2434
2454
  }
2455
+ finally { if (e_1) throw e_1.error; }
2435
2456
  }
2436
2457
  }
2437
2458
  function updateStyles(element, callbackfn) {
@@ -2517,7 +2538,7 @@ function clearAutoDetectFormat(editor) {
2517
2538
  function clearBlockFormat(editor) {
2518
2539
  (0, formatUndoSnapshot_1.default)(editor, function () {
2519
2540
  (0, blockFormat_1.default)(editor, function (region) {
2520
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, undefined /* createBlockIfEmpty */, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
2541
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region);
2521
2542
  var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
2522
2543
  if (editor.contains(region.rootNode)) {
2523
2544
  // If there are styles on table cell, wrap all its children and move down all non-border styles.
@@ -2984,14 +3005,10 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
2984
3005
  if (isBlock) {
2985
3006
  // Insert an extra empty line for block entity to make sure
2986
3007
  // user can still put cursor below the entity.
2987
- var formatOnSpan = editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */);
2988
- var newLine = (0, roosterjs_editor_dom_1.createElement)(formatOnSpan
2989
- ? 12 /* EmptyLineFormatInSpan */
2990
- : 1 /* EmptyLine */, editor.getDocument());
3008
+ var newLine = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, editor.getDocument());
2991
3009
  (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newLine, wrapper.nextSibling);
2992
- var formatNode = formatOnSpan ? newLine === null || newLine === void 0 ? void 0 : newLine.querySelector('span') : newLine;
2993
- if (formatNode) {
2994
- (0, roosterjs_editor_dom_1.applyFormat)(formatNode, {
3010
+ if (newLine) {
3011
+ (0, roosterjs_editor_dom_1.applyFormat)(newLine, {
2995
3012
  backgroundColor: currentFormat.backgroundColor,
2996
3013
  textColor: currentFormat.textColor,
2997
3014
  bold: currentFormat.isBold,
@@ -3277,7 +3294,7 @@ function isList(element) {
3277
3294
  }
3278
3295
  function alignList(editor, alignment) {
3279
3296
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3280
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, undefined /* createBlockIfEmpty */, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
3297
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region);
3281
3298
  var startNode = blocks[0].getStartNode();
3282
3299
  var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(region, true /*includeSiblingLists*/, startNode);
3283
3300
  if (start && end) {
@@ -3476,7 +3493,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
3476
3493
  function setIndentation(editor, indentation) {
3477
3494
  var handler = indentation == 0 /* Increase */ ? indent : outdent;
3478
3495
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3479
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
3496
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/);
3480
3497
  var blockGroups = [[]];
3481
3498
  for (var i = 0; i < blocks.length; i++) {
3482
3499
  var startNode = blocks[i].getStartNode();
@@ -4498,7 +4515,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
4498
4515
  */
4499
4516
  function blockWrap(editor, wrapFunction, beforeRunCallback, apiName) {
4500
4517
  (0, blockFormat_1.default)(editor, function (region) {
4501
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
4518
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/);
4502
4519
  var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
4503
4520
  if (nodes.length > 0) {
4504
4521
  if (nodes.length == 1) {
@@ -5129,7 +5146,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
5129
5146
  * When typing goes directly under content div, many things can go wrong
5130
5147
  * We fix it by wrapping it with a div and reposition cursor within the div
5131
5148
  */
5132
- var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
5149
+ var ensureTypeInContainer = function (core, position, keyboardEvent) {
5133
5150
  var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
5134
5151
  var td;
5135
5152
  if (table && (td = table.querySelector('td,th'))) {
@@ -5150,27 +5167,18 @@ var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormat
5150
5167
  var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
5151
5168
  (keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
5152
5169
  formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
5153
- if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
5154
- var firstChild = formatNode.firstChild;
5155
- formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
5156
- ? firstChild
5157
- : (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
5158
- }
5159
5170
  }
5160
5171
  else {
5161
5172
  // Only reason we don't get the selection block is that we have an empty content div
5162
5173
  // which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
5163
5174
  // The fix is to add a DIV wrapping, apply default format and move cursor over
5164
- formatNode = (0, roosterjs_editor_dom_1.createElement)(applyFormatToSpan
5165
- ? 12 /* EmptyLineFormatInSpan */
5166
- : 1 /* EmptyLine */, core.contentDiv.ownerDocument);
5175
+ formatNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5167
5176
  core.api.insertNode(core, formatNode, {
5168
5177
  position: 1 /* End */,
5169
5178
  updateCursor: false,
5170
5179
  replaceSelection: false,
5171
5180
  insertOnNewLine: false,
5172
5181
  });
5173
- formatNode = applyFormatToSpan ? formatNode.firstChild : formatNode;
5174
5182
  // element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
5175
5183
  position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5176
5184
  }
@@ -7612,7 +7620,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7612
7620
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
7613
7621
  var Escape = 'Escape';
7614
7622
  var Delete = 'Delete';
7615
- var mouseRightButton = 2;
7616
7623
  var mouseLeftButton = 0;
7617
7624
  /**
7618
7625
  * Detect image selection and help highlight the image
@@ -7655,14 +7662,9 @@ var ImageSelection = /** @class */ (function () {
7655
7662
  break;
7656
7663
  case 6 /* MouseUp */:
7657
7664
  var target = event.rawEvent.target;
7658
- if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
7659
- if (event.rawEvent.button === mouseRightButton) {
7660
- var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
7661
- this.editor.select(imageRange);
7662
- }
7663
- else if (event.rawEvent.button === mouseLeftButton) {
7664
- this.editor.select(target);
7665
- }
7665
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
7666
+ event.rawEvent.button === mouseLeftButton) {
7667
+ this.editor.select(target);
7666
7668
  }
7667
7669
  break;
7668
7670
  case 5 /* MouseDown */:
@@ -7692,6 +7694,14 @@ var ImageSelection = /** @class */ (function () {
7692
7694
  }
7693
7695
  }
7694
7696
  break;
7697
+ case 16 /* ContextMenu */:
7698
+ var contextMenuTarget = event.rawEvent.target;
7699
+ var actualSelection = this.editor.getSelectionRangeEx();
7700
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(contextMenuTarget, 'HTMLImageElement') &&
7701
+ (actualSelection.type !== 2 /* ImageSelection */ ||
7702
+ actualSelection.image !== contextMenuTarget)) {
7703
+ this.editor.select(contextMenuTarget);
7704
+ }
7695
7705
  }
7696
7706
  }
7697
7707
  };
@@ -8355,7 +8365,7 @@ var TypeInContainerPlugin = /** @class */ (function () {
8355
8365
  */
8356
8366
  TypeInContainerPlugin.prototype.onPluginEvent = function (event) {
8357
8367
  var _this = this;
8358
- var _a, _b, _c, _d, _e, _f;
8368
+ var _a;
8359
8369
  // We need to check if the ctrl key or the meta key is pressed,
8360
8370
  // browsers like Safari fire the "keypress" event when the meta key is pressed.
8361
8371
  if (event.eventType == 1 /* KeyPress */ &&
@@ -8393,24 +8403,6 @@ var TypeInContainerPlugin = /** @class */ (function () {
8393
8403
  }
8394
8404
  }
8395
8405
  }
8396
- /**
8397
- * Add a Span with default format to the previous element when pressing backspace
8398
- */
8399
- if (event.eventType == 0 /* KeyDown */ &&
8400
- event.rawEvent.which == 8 /* BACKSPACE */ &&
8401
- ((_b = this.editor) === null || _b === void 0 ? void 0 : _b.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */))) {
8402
- var element = (_c = this.editor) === null || _c === void 0 ? void 0 : _c.getElementAtCursor();
8403
- var block_1 = element &&
8404
- ((_e = (_d = this.editor) === null || _d === void 0 ? void 0 : _d.getBlockElementAtNode(element)) === null || _e === void 0 ? void 0 : _e.getStartNode().previousSibling);
8405
- if (block_1) {
8406
- (_f = this.editor) === null || _f === void 0 ? void 0 : _f.runAsync(function (editor) {
8407
- var position = editor.getFocusedPosition();
8408
- if (position && block_1 == position.element) {
8409
- editor.ensureTypeInContainer(position, event.rawEvent);
8410
- }
8411
- });
8412
- }
8413
- }
8414
8406
  };
8415
8407
  return TypeInContainerPlugin;
8416
8408
  }());
@@ -8561,6 +8553,11 @@ var UndoPlugin = /** @class */ (function () {
8561
8553
  }
8562
8554
  this.lastKeyPress = 0;
8563
8555
  }
8556
+ else if (this.lastKeyPress == 8 /* BACKSPACE */ || this.lastKeyPress == 46 /* DELETE */) {
8557
+ if (this.state.hasNewContent) {
8558
+ this.addUndoSnapshot();
8559
+ }
8560
+ }
8564
8561
  };
8565
8562
  UndoPlugin.prototype.onKeyPress = function (evt) {
8566
8563
  var _a;
@@ -8798,7 +8795,14 @@ function inlineEntityOnPluginEvent(event, editor) {
8798
8795
  break;
8799
8796
  case 8 /* ExtractContentWithDom */:
8800
8797
  case 9 /* BeforeCutCopy */:
8801
- event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(removeNode);
8798
+ event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(function (node) {
8799
+ if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(node)) {
8800
+ removeNode(node);
8801
+ }
8802
+ else {
8803
+ removeDelimiterAttr(node);
8804
+ }
8805
+ });
8802
8806
  break;
8803
8807
  case 0 /* KeyDown */:
8804
8808
  handleKeyDownEvent(editor, event);
@@ -8895,10 +8899,9 @@ function removeDelimiterAttr(node, checkEntity) {
8895
8899
  });
8896
8900
  }
8897
8901
  function handleCollapsedEnter(editor, delimiter) {
8898
- var _a;
8899
8902
  var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
8900
8903
  var entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;
8901
- var block = (_a = editor.getBlockElementAtNode(delimiter)) === null || _a === void 0 ? void 0 : _a.getStartNode();
8904
+ var block = getBlock(editor, delimiter);
8902
8905
  editor.runAsync(function () {
8903
8906
  if (!block) {
8904
8907
  return;
@@ -8931,6 +8934,17 @@ var getPosition = function (container) {
8931
8934
  }
8932
8935
  return undefined;
8933
8936
  };
8937
+ function getBlock(editor, element) {
8938
+ var _a;
8939
+ if (!element) {
8940
+ return undefined;
8941
+ }
8942
+ var block = (_a = editor.getBlockElementAtNode(element)) === null || _a === void 0 ? void 0 : _a.getStartNode();
8943
+ while (block && !(0, roosterjs_editor_dom_1.isBlockElement)(block)) {
8944
+ block = editor.contains(block.parentElement) ? block.parentElement : undefined;
8945
+ }
8946
+ return block;
8947
+ }
8934
8948
  function handleSelectionNotCollapsed(editor, range, event) {
8935
8949
  var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
8936
8950
  var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
@@ -9235,6 +9249,31 @@ var __assign = (this && this.__assign) || function () {
9235
9249
  };
9236
9250
  return __assign.apply(this, arguments);
9237
9251
  };
9252
+ var __read = (this && this.__read) || function (o, n) {
9253
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
9254
+ if (!m) return o;
9255
+ var i = m.call(o), r, ar = [], e;
9256
+ try {
9257
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9258
+ }
9259
+ catch (error) { e = { error: error }; }
9260
+ finally {
9261
+ try {
9262
+ if (r && !r.done && (m = i["return"])) m.call(i);
9263
+ }
9264
+ finally { if (e) throw e.error; }
9265
+ }
9266
+ return ar;
9267
+ };
9268
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9269
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
9270
+ if (ar || !(i in from)) {
9271
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9272
+ ar[i] = from[i];
9273
+ }
9274
+ }
9275
+ return to.concat(ar || Array.prototype.slice.call(from));
9276
+ };
9238
9277
  Object.defineProperty(exports, "__esModule", { value: true });
9239
9278
  exports.EditorBase = void 0;
9240
9279
  var isFeatureEnabled_1 = __webpack_require__(/*! ./isFeatureEnabled */ "./packages/roosterjs-editor-core/lib/editor/isFeatureEnabled.ts");
@@ -9349,7 +9388,7 @@ var EditorBase = /** @class */ (function () {
9349
9388
  var selectionEx = scope == 0 /* Body */ ? null : this.getSelectionRangeEx();
9350
9389
  if (selectionEx) {
9351
9390
  selectionEx.ranges.forEach(function (range) {
9352
- result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range));
9391
+ result.push.apply(result, __spreadArray([], __read((0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range)), false));
9353
9392
  });
9354
9393
  }
9355
9394
  else {
@@ -9581,7 +9620,7 @@ var EditorBase = /** @class */ (function () {
9581
9620
  var result = [];
9582
9621
  var contentDiv = this.getCore().contentDiv;
9583
9622
  selection.ranges.forEach(function (range) {
9584
- result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : []));
9623
+ result.push.apply(result, __spreadArray([], __read((range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : [])), false));
9585
9624
  });
9586
9625
  return result.filter(function (value, index, self) {
9587
9626
  return self.indexOf(value) === index;
@@ -9876,7 +9915,7 @@ var EditorBase = /** @class */ (function () {
9876
9915
  */
9877
9916
  EditorBase.prototype.ensureTypeInContainer = function (position, keyboardEvent) {
9878
9917
  var core = this.getCore();
9879
- core.api.ensureTypeInContainer(core, position, keyboardEvent, this.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
9918
+ core.api.ensureTypeInContainer(core, position, keyboardEvent);
9880
9919
  };
9881
9920
  //#endregion
9882
9921
  //#region Dark mode APIs
@@ -11636,6 +11675,22 @@ exports.default = SelectionScoper;
11636
11675
 
11637
11676
  "use strict";
11638
11677
 
11678
+ var __read = (this && this.__read) || function (o, n) {
11679
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
11680
+ if (!m) return o;
11681
+ var i = m.call(o), r, ar = [], e;
11682
+ try {
11683
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11684
+ }
11685
+ catch (error) { e = { error: error }; }
11686
+ finally {
11687
+ try {
11688
+ if (r && !r.done && (m = i["return"])) m.call(i);
11689
+ }
11690
+ finally { if (e) throw e.error; }
11691
+ }
11692
+ return ar;
11693
+ };
11639
11694
  Object.defineProperty(exports, "__esModule", { value: true });
11640
11695
  exports.addDelimiterBefore = exports.addDelimiterAfter = void 0;
11641
11696
  var createElement_1 = __webpack_require__(/*! ../utils/createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
@@ -11646,7 +11701,7 @@ var ZERO_WIDTH_SPACE = '\u200B';
11646
11701
  * @param node the node to add the delimiters
11647
11702
  */
11648
11703
  function addDelimiters(node) {
11649
- var _a = getDelimiters(node), delimiterAfter = _a[0], delimiterBefore = _a[1];
11704
+ var _a = __read(getDelimiters(node), 2), delimiterAfter = _a[0], delimiterBefore = _a[1];
11650
11705
  if (!delimiterAfter) {
11651
11706
  delimiterAfter = addDelimiterAfter(node);
11652
11707
  }
@@ -11985,6 +12040,22 @@ function safeRemove(node) {
11985
12040
 
11986
12041
  "use strict";
11987
12042
 
12043
+ var __read = (this && this.__read) || function (o, n) {
12044
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
12045
+ if (!m) return o;
12046
+ var i = m.call(o), r, ar = [], e;
12047
+ try {
12048
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12049
+ }
12050
+ catch (error) { e = { error: error }; }
12051
+ finally {
12052
+ try {
12053
+ if (r && !r.done && (m = i["return"])) m.call(i);
12054
+ }
12055
+ finally { if (e) throw e.error; }
12056
+ }
12057
+ return ar;
12058
+ };
11988
12059
  Object.defineProperty(exports, "__esModule", { value: true });
11989
12060
  var arrayPush_1 = __webpack_require__(/*! ../jsUtils/arrayPush */ "./packages/roosterjs-editor-dom/lib/jsUtils/arrayPush.ts");
11990
12061
  var collapseNodesInRegion_1 = __webpack_require__(/*! ../region/collapseNodesInRegion */ "./packages/roosterjs-editor-dom/lib/region/collapseNodesInRegion.ts");
@@ -12024,8 +12095,8 @@ function deleteSelectedContent(root, range) {
12024
12095
  // Make sure there are node before and after the merging point.
12025
12096
  // This is required by mergeBlocksInRegion API.
12026
12097
  // This may create some empty text node as anchor
12027
- var _a = ensureBeforeAndAfter(endContainer, endOffset, false /*isStart*/), beforeEnd = _a[0], afterEnd = _a[1];
12028
- var _b = ensureBeforeAndAfter(startContainer, startOffset, true /*isStart*/), beforeStart = _b[0], afterStart = _b[1];
12098
+ var _a = __read(ensureBeforeAndAfter(endContainer, endOffset, false /*isStart*/), 2), beforeEnd = _a[0], afterEnd = _a[1];
12099
+ var _b = __read(ensureBeforeAndAfter(startContainer, startOffset, true /*isStart*/), 2), beforeStart = _b[0], afterStart = _b[1];
12029
12100
  nodeBefore = nodeBefore || beforeStart;
12030
12101
  // Find out all nodes to be deleted
12031
12102
  var nodes = (0, collapseNodesInRegion_1.default)(region, [afterStart, beforeEnd]);
@@ -12518,6 +12589,17 @@ exports.default = isModifierKey;
12518
12589
 
12519
12590
  "use strict";
12520
12591
 
12592
+ var __values = (this && this.__values) || function(o) {
12593
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
12594
+ if (m) return m.call(o);
12595
+ if (o && typeof o.length === "number") return {
12596
+ next: function () {
12597
+ if (o && i >= o.length) o = void 0;
12598
+ return { value: o && o[i++], done: !o };
12599
+ }
12600
+ };
12601
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12602
+ };
12521
12603
  Object.defineProperty(exports, "__esModule", { value: true });
12522
12604
  var changeElementTag_1 = __webpack_require__(/*! ../utils/changeElementTag */ "./packages/roosterjs-editor-dom/lib/utils/changeElementTag.ts");
12523
12605
  var getInheritableStyles_1 = __webpack_require__(/*! ./getInheritableStyles */ "./packages/roosterjs-editor-dom/lib/htmlSanitizer/getInheritableStyles.ts");
@@ -12621,40 +12703,60 @@ var HtmlSanitizer = /** @class */ (function () {
12621
12703
  * @param rootNode The HTML Document
12622
12704
  */
12623
12705
  HtmlSanitizer.prototype.convertGlobalCssToInlineCss = function (rootNode) {
12706
+ var e_1, _a;
12624
12707
  var styleNodes = (0, toArray_1.default)(rootNode.querySelectorAll('style'));
12625
12708
  var styleSheets = this.additionalGlobalStyleNodes
12626
12709
  .reverse()
12627
12710
  .map(function (node) { return node.sheet; })
12628
12711
  .concat(styleNodes.map(function (node) { return node.sheet; }).reverse())
12629
12712
  .filter(function (sheet) { return sheet; });
12630
- for (var _i = 0, styleSheets_1 = styleSheets; _i < styleSheets_1.length; _i++) {
12631
- var styleSheet = styleSheets_1[_i];
12632
- var _loop_1 = function (j) {
12633
- // Skip any none-style rule, i.e. @page
12634
- var styleRule = styleSheet.cssRules[j];
12635
- var text = styleRule && styleRule.style ? styleRule.style.cssText : null;
12636
- if (styleRule.type != CSSRule.STYLE_RULE || !text || !styleRule.selectorText) {
12637
- return "continue";
12638
- }
12639
- // Make sure the selector is not empty
12640
- for (var _a = 0, _b = styleRule.selectorText.split(','); _a < _b.length; _a++) {
12641
- var selector = _b[_a];
12642
- if (!selector || !selector.trim() || selector.indexOf(':') >= 0) {
12643
- continue;
12713
+ try {
12714
+ for (var styleSheets_1 = __values(styleSheets), styleSheets_1_1 = styleSheets_1.next(); !styleSheets_1_1.done; styleSheets_1_1 = styleSheets_1.next()) {
12715
+ var styleSheet = styleSheets_1_1.value;
12716
+ var _loop_1 = function (j) {
12717
+ var e_2, _b;
12718
+ // Skip any none-style rule, i.e. @page
12719
+ var styleRule = styleSheet.cssRules[j];
12720
+ var text = styleRule && styleRule.style ? styleRule.style.cssText : null;
12721
+ if (styleRule.type != CSSRule.STYLE_RULE || !text || !styleRule.selectorText) {
12722
+ return "continue";
12644
12723
  }
12645
- var nodes = (0, toArray_1.default)(rootNode.querySelectorAll(selector));
12646
- // Always put existing styles after so that they have higher priority
12647
- // Which means if both global style and inline style apply to the same element,
12648
- // inline style will have higher priority
12649
- nodes.forEach(function (node) {
12650
- return node.setAttribute('style', text + (node.getAttribute('style') || ''));
12651
- });
12724
+ try {
12725
+ // Make sure the selector is not empty
12726
+ for (var _c = (e_2 = void 0, __values(styleRule.selectorText.split(','))), _d = _c.next(); !_d.done; _d = _c.next()) {
12727
+ var selector = _d.value;
12728
+ if (!selector || !selector.trim() || selector.indexOf(':') >= 0) {
12729
+ continue;
12730
+ }
12731
+ var nodes = (0, toArray_1.default)(rootNode.querySelectorAll(selector));
12732
+ // Always put existing styles after so that they have higher priority
12733
+ // Which means if both global style and inline style apply to the same element,
12734
+ // inline style will have higher priority
12735
+ nodes.forEach(function (node) {
12736
+ return node.setAttribute('style', text + (node.getAttribute('style') || ''));
12737
+ });
12738
+ }
12739
+ }
12740
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
12741
+ finally {
12742
+ try {
12743
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
12744
+ }
12745
+ finally { if (e_2) throw e_2.error; }
12746
+ }
12747
+ };
12748
+ for (var j = styleSheet.cssRules.length - 1; j >= 0; j--) {
12749
+ _loop_1(j);
12652
12750
  }
12653
- };
12654
- for (var j = styleSheet.cssRules.length - 1; j >= 0; j--) {
12655
- _loop_1(j);
12656
12751
  }
12657
12752
  }
12753
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
12754
+ finally {
12755
+ try {
12756
+ if (styleSheets_1_1 && !styleSheets_1_1.done && (_a = styleSheets_1.return)) _a.call(styleSheets_1);
12757
+ }
12758
+ finally { if (e_1) throw e_1.error; }
12759
+ }
12658
12760
  styleNodes.forEach(function (node) {
12659
12761
  if (node.parentNode) {
12660
12762
  node.parentNode.removeChild(node);
@@ -12829,6 +12931,31 @@ exports.default = HtmlSanitizer;
12829
12931
 
12830
12932
  "use strict";
12831
12933
 
12934
+ var __read = (this && this.__read) || function (o, n) {
12935
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
12936
+ if (!m) return o;
12937
+ var i = m.call(o), r, ar = [], e;
12938
+ try {
12939
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12940
+ }
12941
+ catch (error) { e = { error: error }; }
12942
+ finally {
12943
+ try {
12944
+ if (r && !r.done && (m = i["return"])) m.call(i);
12945
+ }
12946
+ finally { if (e) throw e.error; }
12947
+ }
12948
+ return ar;
12949
+ };
12950
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
12951
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
12952
+ if (ar || !(i in from)) {
12953
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12954
+ ar[i] = from[i];
12955
+ }
12956
+ }
12957
+ return to.concat(ar || Array.prototype.slice.call(from));
12958
+ };
12832
12959
  Object.defineProperty(exports, "__esModule", { value: true });
12833
12960
  /**
12834
12961
  * Chain all callback for an attribute together
@@ -12849,8 +12976,8 @@ function chainSanitizerCallback(map, name, newCallback) {
12849
12976
  for (var _i = 0; _i < arguments.length; _i++) {
12850
12977
  args[_i] = arguments[_i];
12851
12978
  }
12852
- originalCallback_1.apply(void 0, args);
12853
- return newCallback.apply(void 0, args);
12979
+ originalCallback_1.apply(void 0, __spreadArray([], __read(args), false));
12980
+ return newCallback.apply(void 0, __spreadArray([], __read(args), false));
12854
12981
  };
12855
12982
  }
12856
12983
  }
@@ -12868,6 +12995,17 @@ exports.default = chainSanitizerCallback;
12868
12995
 
12869
12996
  "use strict";
12870
12997
 
12998
+ var __values = (this && this.__values) || function(o) {
12999
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
13000
+ if (m) return m.call(o);
13001
+ if (o && typeof o.length === "number") return {
13002
+ next: function () {
13003
+ if (o && i >= o.length) o = void 0;
13004
+ return { value: o && o[i++], done: !o };
13005
+ }
13006
+ };
13007
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
13008
+ };
12871
13009
  Object.defineProperty(exports, "__esModule", { value: true });
12872
13010
  exports.cloneObject = void 0;
12873
13011
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
@@ -12875,11 +13013,21 @@ function nativeClone(source, existingObj) {
12875
13013
  return Object.assign(existingObj || {}, source);
12876
13014
  }
12877
13015
  function customClone(source, existingObj) {
13016
+ var e_1, _a;
12878
13017
  var result = existingObj || {};
12879
13018
  if (source) {
12880
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(source); _i < _a.length; _i++) {
12881
- var key = _a[_i];
12882
- result[key] = source[key];
13019
+ try {
13020
+ for (var _b = __values((0, getObjectKeys_1.default)(source)), _c = _b.next(); !_c.done; _c = _b.next()) {
13021
+ var key = _c.value;
13022
+ result[key] = source[key];
13023
+ }
13024
+ }
13025
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
13026
+ finally {
13027
+ try {
13028
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
13029
+ }
13030
+ finally { if (e_1) throw e_1.error; }
12883
13031
  }
12884
13032
  }
12885
13033
  return result;
@@ -14289,6 +14437,22 @@ exports.default = toArray;
14289
14437
 
14290
14438
  "use strict";
14291
14439
 
14440
+ var __read = (this && this.__read) || function (o, n) {
14441
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14442
+ if (!m) return o;
14443
+ var i = m.call(o), r, ar = [], e;
14444
+ try {
14445
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
14446
+ }
14447
+ catch (error) { e = { error: error }; }
14448
+ finally {
14449
+ try {
14450
+ if (r && !r.done && (m = i["return"])) m.call(i);
14451
+ }
14452
+ finally { if (e) throw e.error; }
14453
+ }
14454
+ return ar;
14455
+ };
14292
14456
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14293
14457
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14294
14458
  if (ar || !(i in from)) {
@@ -14485,7 +14649,7 @@ var VList = /** @class */ (function () {
14485
14649
  topList.start = start;
14486
14650
  }
14487
14651
  }
14488
- if (item.getLevel() == 1) {
14652
+ if (item.getLevel() == 1 && !item.isDummy()) {
14489
14653
  start++;
14490
14654
  }
14491
14655
  }
@@ -14683,12 +14847,12 @@ var VList = /** @class */ (function () {
14683
14847
  var type = (0, getListTypeFromNode_1.default)(list);
14684
14848
  var items = (0, toArray_1.default)(list.childNodes);
14685
14849
  items.forEach(function (item) {
14686
- var newListTypes = __spreadArray(__spreadArray([], listTypes, true), [type], false);
14850
+ var newListTypes = __spreadArray(__spreadArray([], __read(listTypes), false), [type], false);
14687
14851
  if ((0, getListTypeFromNode_1.isListElement)(item)) {
14688
14852
  _this.populateItems(item, newListTypes);
14689
14853
  }
14690
14854
  else if (item.nodeType != 3 /* Text */ || (item.nodeValue || '').trim() != '') {
14691
- _this.items.push(new (VListItem_1.default.bind.apply(VListItem_1.default, __spreadArray([void 0, item], newListTypes, false)))());
14855
+ _this.items.push(new (VListItem_1.default.bind.apply(VListItem_1.default, __spreadArray([void 0, item], __read(newListTypes), false)))());
14692
14856
  }
14693
14857
  });
14694
14858
  };
@@ -14930,6 +15094,22 @@ var __assign = (this && this.__assign) || function () {
14930
15094
  };
14931
15095
  return __assign.apply(this, arguments);
14932
15096
  };
15097
+ var __read = (this && this.__read) || function (o, n) {
15098
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15099
+ if (!m) return o;
15100
+ var i = m.call(o), r, ar = [], e;
15101
+ try {
15102
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
15103
+ }
15104
+ catch (error) { e = { error: error }; }
15105
+ finally {
15106
+ try {
15107
+ if (r && !r.done && (m = i["return"])) m.call(i);
15108
+ }
15109
+ finally { if (e) throw e.error; }
15110
+ }
15111
+ return ar;
15112
+ };
14933
15113
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14934
15114
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14935
15115
  if (ar || !(i in from)) {
@@ -15002,7 +15182,7 @@ var VListItem = /** @class */ (function () {
15002
15182
  var display = this.node.style.display;
15003
15183
  this.dummy = display != 'list-item' && display != '';
15004
15184
  // Always add a None list type in front of all other types to represent non-list scenario.
15005
- this.listTypes = __spreadArray([0 /* None */], listTypes, true);
15185
+ this.listTypes = __spreadArray([0 /* None */], __read(listTypes), false);
15006
15186
  }
15007
15187
  /**
15008
15188
  * Get type of current list item
@@ -15414,6 +15594,17 @@ exports.default = convertDecimalsToAlpha;
15414
15594
 
15415
15595
  "use strict";
15416
15596
 
15597
+ var __values = (this && this.__values) || function(o) {
15598
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15599
+ if (m) return m.call(o);
15600
+ if (o && typeof o.length === "number") return {
15601
+ next: function () {
15602
+ if (o && i >= o.length) o = void 0;
15603
+ return { value: o && o[i++], done: !o };
15604
+ }
15605
+ };
15606
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
15607
+ };
15417
15608
  Object.defineProperty(exports, "__esModule", { value: true });
15418
15609
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
15419
15610
  var RomanValues = {
@@ -15439,12 +15630,22 @@ var RomanValues = {
15439
15630
  * @returns
15440
15631
  */
15441
15632
  function convertDecimalsToRoman(decimal, isLowerCase) {
15633
+ var e_1, _a;
15442
15634
  var romanValue = '';
15443
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(RomanValues); _i < _a.length; _i++) {
15444
- var i = _a[_i];
15445
- var timesRomanCharAppear = Math.floor(decimal / RomanValues[i]);
15446
- decimal = decimal - timesRomanCharAppear * RomanValues[i];
15447
- romanValue = romanValue + i.repeat(timesRomanCharAppear);
15635
+ try {
15636
+ for (var _b = __values((0, getObjectKeys_1.default)(RomanValues)), _c = _b.next(); !_c.done; _c = _b.next()) {
15637
+ var i = _c.value;
15638
+ var timesRomanCharAppear = Math.floor(decimal / RomanValues[i]);
15639
+ decimal = decimal - timesRomanCharAppear * RomanValues[i];
15640
+ romanValue = romanValue + i.repeat(timesRomanCharAppear);
15641
+ }
15642
+ }
15643
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
15644
+ finally {
15645
+ try {
15646
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
15647
+ }
15648
+ finally { if (e_1) throw e_1.error; }
15448
15649
  }
15449
15650
  return isLowerCase ? romanValue.toLocaleLowerCase() : romanValue;
15450
15651
  }
@@ -15515,7 +15716,7 @@ function createVListFromRegion(region, includeSiblingLists, startNode) {
15515
15716
  }
15516
15717
  });
15517
15718
  if (nodes.length == 0 && !region.rootNode.firstChild) {
15518
- var newNode = (0, createElement_1.default)(12 /* EmptyLineFormatInSpan */, region.rootNode.ownerDocument);
15719
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, region.rootNode.ownerDocument);
15519
15720
  region.rootNode.appendChild(newNode);
15520
15721
  nodes.push(newNode);
15521
15722
  region.fullSelectionStart = new Position_1.default(newNode, 0 /* Begin */);
@@ -16504,6 +16705,22 @@ exports.default = collapseNodesInRegion;
16504
16705
 
16505
16706
  "use strict";
16506
16707
 
16708
+ var __read = (this && this.__read) || function (o, n) {
16709
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
16710
+ if (!m) return o;
16711
+ var i = m.call(o), r, ar = [], e;
16712
+ try {
16713
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
16714
+ }
16715
+ catch (error) { e = { error: error }; }
16716
+ finally {
16717
+ try {
16718
+ if (r && !r.done && (m = i["return"])) m.call(i);
16719
+ }
16720
+ finally { if (e) throw e.error; }
16721
+ }
16722
+ return ar;
16723
+ };
16507
16724
  var _a;
16508
16725
  Object.defineProperty(exports, "__esModule", { value: true });
16509
16726
  exports.getRegionCreator = void 0;
@@ -16527,14 +16744,15 @@ var regionTypeData = (_a = {},
16527
16744
  * @param type Type of region. Currently we only support TABLE region.
16528
16745
  */
16529
16746
  function getRegionsFromRange(root, range, type) {
16747
+ var _a;
16530
16748
  var regions = [];
16531
16749
  if (root && range) {
16532
- var _a = regionTypeData[type], innerSelector = _a.innerSelector, skipTags = _a.skipTags;
16750
+ var _b = regionTypeData[type], innerSelector = _b.innerSelector, skipTags = _b.skipTags;
16533
16751
  var boundaryTree = buildBoundaryTree(root, range, type);
16534
16752
  var start = (0, findClosestElementAncestor_1.default)(range.startContainer, root, innerSelector) || root;
16535
16753
  var end = (0, findClosestElementAncestor_1.default)(range.endContainer, root, innerSelector) || root;
16536
16754
  var creator = getRegionCreator(range, skipTags);
16537
- regions = iterateNodes(creator, boundaryTree, start, end)[0];
16755
+ _a = __read(iterateNodes(creator, boundaryTree, start, end), 1), regions = _a[0];
16538
16756
  }
16539
16757
  return regions.filter(function (r) { return !!r; });
16540
16758
  }
@@ -16628,7 +16846,7 @@ function iterateNodes(creator, boundary, start, end, started) {
16628
16846
  boundaries === null || boundaries === void 0 ? void 0 : boundaries.forEach(function (child) {
16629
16847
  var _a;
16630
16848
  var newRegions;
16631
- _a = iterateNodes(creator, child, start, end, started), newRegions = _a[0], started = _a[1], ended = _a[2];
16849
+ _a = __read(iterateNodes(creator, child, start, end, started), 3), newRegions = _a[0], started = _a[1], ended = _a[2];
16632
16850
  regions = regions.concat(newRegions);
16633
16851
  });
16634
16852
  }
@@ -16689,8 +16907,9 @@ var shouldSkipNode_1 = __webpack_require__(/*! ../utils/shouldSkipNode */ "./pac
16689
16907
  * @param regionBase The region to get block elements from
16690
16908
  * @param createBlockIfEmpty When set to true, a new empty block element will be created if there is not
16691
16909
  * any blocks in the region. Default value is false
16910
+ * @param deprecated Deprecated parameter, not used
16692
16911
  */
16693
- function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, shouldApplyFormatToSpan) {
16912
+ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, deprecated) {
16694
16913
  var range = (0, getSelectionRangeInRegion_1.default)(regionBase);
16695
16914
  var blocks = [];
16696
16915
  if (range) {
@@ -16714,9 +16933,7 @@ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, should
16714
16933
  });
16715
16934
  }
16716
16935
  if (blocks.length == 0 && regionBase && !regionBase.rootNode.firstChild && createBlockIfEmpty) {
16717
- var newNode = (0, createElement_1.default)(shouldApplyFormatToSpan
16718
- ? 12 /* EmptyLineFormatInSpan */
16719
- : 1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16936
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16720
16937
  regionBase.rootNode.appendChild(newNode);
16721
16938
  var block = (0, getBlockElementAtNode_1.default)(regionBase.rootNode, newNode);
16722
16939
  if (block) {
@@ -19269,6 +19486,22 @@ exports.default = applyFormat;
19269
19486
 
19270
19487
  "use strict";
19271
19488
 
19489
+ var __read = (this && this.__read) || function (o, n) {
19490
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19491
+ if (!m) return o;
19492
+ var i = m.call(o), r, ar = [], e;
19493
+ try {
19494
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19495
+ }
19496
+ catch (error) { e = { error: error }; }
19497
+ finally {
19498
+ try {
19499
+ if (r && !r.done && (m = i["return"])) m.call(i);
19500
+ }
19501
+ finally { if (e) throw e.error; }
19502
+ }
19503
+ return ar;
19504
+ };
19272
19505
  Object.defineProperty(exports, "__esModule", { value: true });
19273
19506
  var getComputedStyles_1 = __webpack_require__(/*! ./getComputedStyles */ "./packages/roosterjs-editor-dom/lib/utils/getComputedStyles.ts");
19274
19507
  var getTagOfNode_1 = __webpack_require__(/*! ./getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
@@ -19290,10 +19523,10 @@ function changeElementTag(element, newTag) {
19290
19523
  }
19291
19524
  (0, moveChildNodes_1.default)(newElement, element);
19292
19525
  if (origianlTag == 'P' || (0, getTagOfNode_1.default)(newElement) == 'P') {
19293
- _a = (0, getComputedStyles_1.default)(element, [
19526
+ _a = __read((0, getComputedStyles_1.default)(element, [
19294
19527
  'margin-top',
19295
19528
  'margin-bottom',
19296
- ]), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19529
+ ]), 2), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19297
19530
  }
19298
19531
  if (element.parentNode) {
19299
19532
  element.parentNode.replaceChild(newElement, element);
@@ -19642,6 +19875,17 @@ exports.default = fromHtml;
19642
19875
 
19643
19876
  "use strict";
19644
19877
 
19878
+ var __values = (this && this.__values) || function(o) {
19879
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19880
+ if (m) return m.call(o);
19881
+ if (o && typeof o.length === "number") return {
19882
+ next: function () {
19883
+ if (o && i >= o.length) o = void 0;
19884
+ return { value: o && o[i++], done: !o };
19885
+ }
19886
+ };
19887
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
19888
+ };
19645
19889
  Object.defineProperty(exports, "__esModule", { value: true });
19646
19890
  exports.getComputedStyle = void 0;
19647
19891
  var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
@@ -19653,6 +19897,7 @@ var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementA
19653
19897
  * @returns An array of the computed styles
19654
19898
  */
19655
19899
  function getComputedStyles(node, styleNames) {
19900
+ var e_1, _a;
19656
19901
  if (styleNames === void 0) { styleNames = ['font-family', 'font-size', 'color', 'background-color']; }
19657
19902
  var element = (0, findClosestElementAncestor_1.default)(node);
19658
19903
  var result = [];
@@ -19661,12 +19906,21 @@ function getComputedStyles(node, styleNames) {
19661
19906
  var win = element.ownerDocument.defaultView || window;
19662
19907
  var styles = win.getComputedStyle(element);
19663
19908
  if (styles) {
19664
- for (var _i = 0, styleNames_1 = styleNames; _i < styleNames_1.length; _i++) {
19665
- var style = styleNames_1[_i];
19666
- var value = styles.getPropertyValue(style) || '';
19667
- value = style != 'font-family' ? value.toLowerCase() : value;
19668
- value = style == 'font-size' ? px2Pt(value) : value;
19669
- result.push(value);
19909
+ try {
19910
+ for (var styleNames_1 = __values(styleNames), styleNames_1_1 = styleNames_1.next(); !styleNames_1_1.done; styleNames_1_1 = styleNames_1.next()) {
19911
+ var style = styleNames_1_1.value;
19912
+ var value = styles.getPropertyValue(style) || '';
19913
+ value = style != 'font-family' ? value.toLowerCase() : value;
19914
+ value = style == 'font-size' ? px2Pt(value) : value;
19915
+ result.push(value);
19916
+ }
19917
+ }
19918
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
19919
+ finally {
19920
+ try {
19921
+ if (styleNames_1_1 && !styleNames_1_1.done && (_a = styleNames_1.return)) _a.call(styleNames_1);
19922
+ }
19923
+ finally { if (e_1) throw e_1.error; }
19670
19924
  }
19671
19925
  }
19672
19926
  }
@@ -19737,6 +19991,31 @@ exports.default = getInnerHTML;
19737
19991
 
19738
19992
  "use strict";
19739
19993
 
19994
+ var __read = (this && this.__read) || function (o, n) {
19995
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19996
+ if (!m) return o;
19997
+ var i = m.call(o), r, ar = [], e;
19998
+ try {
19999
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20000
+ }
20001
+ catch (error) { e = { error: error }; }
20002
+ finally {
20003
+ try {
20004
+ if (r && !r.done && (m = i["return"])) m.call(i);
20005
+ }
20006
+ finally { if (e) throw e.error; }
20007
+ }
20008
+ return ar;
20009
+ };
20010
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20011
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20012
+ if (ar || !(i in from)) {
20013
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20014
+ ar[i] = from[i];
20015
+ }
20016
+ }
20017
+ return to.concat(ar || Array.prototype.slice.call(from));
20018
+ };
19740
20019
  Object.defineProperty(exports, "__esModule", { value: true });
19741
20020
  var normalizeRect_1 = __webpack_require__(/*! ./normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
19742
20021
  /**
@@ -19771,10 +20050,10 @@ function getIntersectedRect(elements, additionalRects) {
19771
20050
  .concat(additionalRects)
19772
20051
  .filter(function (element) { return !!element; });
19773
20052
  var result = {
19774
- top: Math.max.apply(Math, rects.map(function (r) { return r.top; })),
19775
- bottom: Math.min.apply(Math, rects.map(function (r) { return r.bottom; })),
19776
- left: Math.max.apply(Math, rects.map(function (r) { return r.left; })),
19777
- right: Math.min.apply(Math, rects.map(function (r) { return r.right; })),
20053
+ top: Math.max.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.top; })), false)),
20054
+ bottom: Math.min.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.bottom; })), false)),
20055
+ left: Math.max.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.left; })), false)),
20056
+ right: Math.min.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.right; })), false)),
19778
20057
  };
19779
20058
  return result.top < result.bottom && result.left < result.right ? result : null;
19780
20059
  }
@@ -20142,6 +20421,17 @@ exports.default = isVoidHtmlElement;
20142
20421
 
20143
20422
  "use strict";
20144
20423
 
20424
+ var __values = (this && this.__values) || function(o) {
20425
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
20426
+ if (m) return m.call(o);
20427
+ if (o && typeof o.length === "number") return {
20428
+ next: function () {
20429
+ if (o && i >= o.length) o = void 0;
20430
+ return { value: o && o[i++], done: !o };
20431
+ }
20432
+ };
20433
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
20434
+ };
20145
20435
  Object.defineProperty(exports, "__esModule", { value: true });
20146
20436
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
20147
20437
  // http exclude matching regex
@@ -20205,18 +20495,28 @@ var linkMatchRules = {
20205
20495
  * The link data includes an original url and a normalized url
20206
20496
  */
20207
20497
  function matchLink(url) {
20498
+ var e_1, _a;
20208
20499
  if (url) {
20209
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(linkMatchRules); _i < _a.length; _i++) {
20210
- var schema = _a[_i];
20211
- var rule = linkMatchRules[schema];
20212
- var matches = url.match(rule.match);
20213
- if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
20214
- return {
20215
- scheme: schema,
20216
- originalUrl: url,
20217
- normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
20218
- };
20500
+ try {
20501
+ for (var _b = __values((0, getObjectKeys_1.default)(linkMatchRules)), _c = _b.next(); !_c.done; _c = _b.next()) {
20502
+ var schema = _c.value;
20503
+ var rule = linkMatchRules[schema];
20504
+ var matches = url.match(rule.match);
20505
+ if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
20506
+ return {
20507
+ scheme: schema,
20508
+ originalUrl: url,
20509
+ normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
20510
+ };
20511
+ }
20512
+ }
20513
+ }
20514
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20515
+ finally {
20516
+ try {
20517
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
20219
20518
  }
20519
+ finally { if (e_1) throw e_1.error; }
20220
20520
  }
20221
20521
  }
20222
20522
  return null;
@@ -20841,11 +21141,23 @@ exports.default = unwrap;
20841
21141
 
20842
21142
  "use strict";
20843
21143
 
21144
+ var __values = (this && this.__values) || function(o) {
21145
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21146
+ if (m) return m.call(o);
21147
+ if (o && typeof o.length === "number") return {
21148
+ next: function () {
21149
+ if (o && i >= o.length) o = void 0;
21150
+ return { value: o && o[i++], done: !o };
21151
+ }
21152
+ };
21153
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
21154
+ };
20844
21155
  Object.defineProperty(exports, "__esModule", { value: true });
20845
21156
  var createElement_1 = __webpack_require__(/*! ./createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
20846
21157
  var fromHtml_1 = __webpack_require__(/*! ./fromHtml */ "./packages/roosterjs-editor-dom/lib/utils/fromHtml.ts");
20847
21158
  var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
20848
21159
  function wrap(nodes, wrapper) {
21160
+ var e_1, _a;
20849
21161
  nodes = !nodes ? [] : (0, safeInstanceOf_1.default)(nodes, 'Node') ? [nodes] : nodes;
20850
21162
  if (nodes.length == 0 || !nodes[0] || !nodes[0].ownerDocument) {
20851
21163
  return null;
@@ -20868,9 +21180,18 @@ function wrap(nodes, wrapper) {
20868
21180
  if (parentNode) {
20869
21181
  parentNode.insertBefore(wrapper, nodes[0]);
20870
21182
  }
20871
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
20872
- var node = nodes_1[_i];
20873
- wrapper.appendChild(node);
21183
+ try {
21184
+ for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
21185
+ var node = nodes_1_1.value;
21186
+ wrapper.appendChild(node);
21187
+ }
21188
+ }
21189
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
21190
+ finally {
21191
+ try {
21192
+ if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
21193
+ }
21194
+ finally { if (e_1) throw e_1.error; }
20874
21195
  }
20875
21196
  return wrapper;
20876
21197
  }
@@ -21250,6 +21571,22 @@ __exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-edito
21250
21571
 
21251
21572
  "use strict";
21252
21573
 
21574
+ var __read = (this && this.__read) || function (o, n) {
21575
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
21576
+ if (!m) return o;
21577
+ var i = m.call(o), r, ar = [], e;
21578
+ try {
21579
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21580
+ }
21581
+ catch (error) { e = { error: error }; }
21582
+ finally {
21583
+ try {
21584
+ if (r && !r.done && (m = i["return"])) m.call(i);
21585
+ }
21586
+ finally { if (e) throw e.error; }
21587
+ }
21588
+ return ar;
21589
+ };
21253
21590
  Object.defineProperty(exports, "__esModule", { value: true });
21254
21591
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
21255
21592
  /**
@@ -21316,13 +21653,13 @@ var DragAndDropHelper = /** @class */ (function () {
21316
21653
  e.preventDefault();
21317
21654
  e.stopPropagation();
21318
21655
  _this.addDocumentEvents();
21319
- _a = _this.dndMouse.getPageXY(e), _this.initX = _a[0], _this.initY = _a[1];
21656
+ _a = __read(_this.dndMouse.getPageXY(e), 2), _this.initX = _a[0], _this.initY = _a[1];
21320
21657
  _this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, e);
21321
21658
  };
21322
21659
  this.onMouseMove = function (e) {
21323
21660
  var _a, _b, _c;
21324
21661
  e.preventDefault();
21325
- var _d = _this.dndMouse.getPageXY(e), pageX = _d[0], pageY = _d[1];
21662
+ var _d = __read(_this.dndMouse.getPageXY(e), 2), pageX = _d[0], pageY = _d[1];
21326
21663
  var deltaX = (pageX - _this.initX) / _this.zoomScale;
21327
21664
  var deltaY = (pageY - _this.initY) / _this.zoomScale;
21328
21665
  if (_this.initValue &&
@@ -21827,6 +22164,22 @@ exports.CursorFeatures = {
21827
22164
 
21828
22165
  "use strict";
21829
22166
 
22167
+ var __read = (this && this.__read) || function (o, n) {
22168
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
22169
+ if (!m) return o;
22170
+ var i = m.call(o), r, ar = [], e;
22171
+ try {
22172
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22173
+ }
22174
+ catch (error) { e = { error: error }; }
22175
+ finally {
22176
+ try {
22177
+ if (r && !r.done && (m = i["return"])) m.call(i);
22178
+ }
22179
+ finally { if (e) throw e.error; }
22180
+ }
22181
+ return ar;
22182
+ };
21830
22183
  Object.defineProperty(exports, "__esModule", { value: true });
21831
22184
  exports.EntityFeatures = void 0;
21832
22185
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
@@ -22141,7 +22494,7 @@ function triggerOperation(entity, editor, operation, event) {
22141
22494
  removeDelimiters(nextElementSibling, previousElementSibling);
22142
22495
  }
22143
22496
  else {
22144
- var delimiterAfter = (0, roosterjs_editor_dom_2.addDelimiters)(entity.wrapper)[0];
22497
+ var _a = __read((0, roosterjs_editor_dom_2.addDelimiters)(entity.wrapper), 1), delimiterAfter = _a[0];
22145
22498
  if (delimiterAfter) {
22146
22499
  editor.select(delimiterAfter, -3 /* After */);
22147
22500
  }
@@ -23866,6 +24219,33 @@ Object.defineProperty(exports, "ContextMenu", { enumerable: true, get: function
23866
24219
 
23867
24220
  "use strict";
23868
24221
 
24222
+ var __values = (this && this.__values) || function(o) {
24223
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
24224
+ if (m) return m.call(o);
24225
+ if (o && typeof o.length === "number") return {
24226
+ next: function () {
24227
+ if (o && i >= o.length) o = void 0;
24228
+ return { value: o && o[i++], done: !o };
24229
+ }
24230
+ };
24231
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
24232
+ };
24233
+ var __read = (this && this.__read) || function (o, n) {
24234
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24235
+ if (!m) return o;
24236
+ var i = m.call(o), r, ar = [], e;
24237
+ try {
24238
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
24239
+ }
24240
+ catch (error) { e = { error: error }; }
24241
+ finally {
24242
+ try {
24243
+ if (r && !r.done && (m = i["return"])) m.call(i);
24244
+ }
24245
+ finally { if (e) throw e.error; }
24246
+ }
24247
+ return ar;
24248
+ };
23869
24249
  Object.defineProperty(exports, "__esModule", { value: true });
23870
24250
  var makeReplacement = function (sourceString, replacementHTML, matchSourceCaseSensitive, shouldReplace) { return ({
23871
24251
  sourceString: sourceString,
@@ -23972,21 +24352,31 @@ var CustomReplacePlugin = /** @class */ (function () {
23972
24352
  }
23973
24353
  };
23974
24354
  CustomReplacePlugin.prototype.getMatchingReplacement = function (stringToSearch) {
24355
+ var e_1, _a;
23975
24356
  if (stringToSearch.length == 0 || !this.replacements) {
23976
24357
  return null;
23977
24358
  }
23978
24359
  var originalStringToSearch = stringToSearch.replace(/\s/g, ' ');
23979
24360
  var lowerCaseStringToSearch = originalStringToSearch.toLocaleLowerCase();
23980
- for (var _i = 0, _a = this.replacements; _i < _a.length; _i++) {
23981
- var replacement = _a[_i];
23982
- var _b = replacement.matchSourceCaseSensitive
23983
- ? [originalStringToSearch, replacement.sourceString]
23984
- : [lowerCaseStringToSearch, replacement.sourceString.toLocaleLowerCase()], sourceMatch = _b[0], replacementMatch = _b[1];
23985
- if (sourceMatch.substring(sourceMatch.length - replacementMatch.length) ==
23986
- replacementMatch) {
23987
- return replacement;
24361
+ try {
24362
+ for (var _b = __values(this.replacements), _c = _b.next(); !_c.done; _c = _b.next()) {
24363
+ var replacement = _c.value;
24364
+ var _d = __read(replacement.matchSourceCaseSensitive
24365
+ ? [originalStringToSearch, replacement.sourceString]
24366
+ : [lowerCaseStringToSearch, replacement.sourceString.toLocaleLowerCase()], 2), sourceMatch = _d[0], replacementMatch = _d[1];
24367
+ if (sourceMatch.substring(sourceMatch.length - replacementMatch.length) ==
24368
+ replacementMatch) {
24369
+ return replacement;
24370
+ }
23988
24371
  }
23989
24372
  }
24373
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
24374
+ finally {
24375
+ try {
24376
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
24377
+ }
24378
+ finally { if (e_1) throw e_1.error; }
24379
+ }
23990
24380
  return null;
23991
24381
  };
23992
24382
  return CustomReplacePlugin;
@@ -23996,21 +24386,31 @@ function getLongestReplacementSourceLength(replacements) {
23996
24386
  return Math.max.apply(null, replacements.map(function (replacement) { return replacement.sourceString.length; }));
23997
24387
  }
23998
24388
  function getReplacementEndCharacters(replacements) {
24389
+ var e_2, _a;
23999
24390
  var endChars = new Set();
24000
- for (var _i = 0, replacements_1 = replacements; _i < replacements_1.length; _i++) {
24001
- var replacement = replacements_1[_i];
24002
- var sourceString = replacement.sourceString;
24003
- if (sourceString.length == 0) {
24004
- continue;
24005
- }
24006
- var lastChar = sourceString[sourceString.length - 1];
24007
- if (!replacement.matchSourceCaseSensitive) {
24008
- endChars.add(lastChar.toLocaleLowerCase());
24009
- endChars.add(lastChar.toLocaleUpperCase());
24391
+ try {
24392
+ for (var replacements_1 = __values(replacements), replacements_1_1 = replacements_1.next(); !replacements_1_1.done; replacements_1_1 = replacements_1.next()) {
24393
+ var replacement = replacements_1_1.value;
24394
+ var sourceString = replacement.sourceString;
24395
+ if (sourceString.length == 0) {
24396
+ continue;
24397
+ }
24398
+ var lastChar = sourceString[sourceString.length - 1];
24399
+ if (!replacement.matchSourceCaseSensitive) {
24400
+ endChars.add(lastChar.toLocaleLowerCase());
24401
+ endChars.add(lastChar.toLocaleUpperCase());
24402
+ }
24403
+ else {
24404
+ endChars.add(lastChar);
24405
+ }
24010
24406
  }
24011
- else {
24012
- endChars.add(lastChar);
24407
+ }
24408
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
24409
+ finally {
24410
+ try {
24411
+ if (replacements_1_1 && !replacements_1_1.done && (_a = replacements_1.return)) _a.call(replacements_1);
24013
24412
  }
24413
+ finally { if (e_2) throw e_2.error; }
24014
24414
  }
24015
24415
  return endChars;
24016
24416
  }
@@ -24388,6 +24788,22 @@ var __assign = (this && this.__assign) || function () {
24388
24788
  };
24389
24789
  return __assign.apply(this, arguments);
24390
24790
  };
24791
+ var __read = (this && this.__read) || function (o, n) {
24792
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24793
+ if (!m) return o;
24794
+ var i = m.call(o), r, ar = [], e;
24795
+ try {
24796
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
24797
+ }
24798
+ catch (error) { e = { error: error }; }
24799
+ finally {
24800
+ try {
24801
+ if (r && !r.done && (m = i["return"])) m.call(i);
24802
+ }
24803
+ finally { if (e) throw e.error; }
24804
+ }
24805
+ return ar;
24806
+ };
24391
24807
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24392
24808
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24393
24809
  if (ar || !(i in from)) {
@@ -24707,7 +25123,7 @@ var ImageEdit = /** @class */ (function () {
24707
25123
  this.createWrapper(operation);
24708
25124
  this.updateWrapper();
24709
25125
  // Init drag and drop
24710
- 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);
25126
+ this.dndHelpers = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(this.createDndHelpers("r_resizeH" /* ResizeHandle */, Resizer_1.Resizer)), false), __read(this.createDndHelpers("r_rotateH" /* RotateHandle */, Rotator_1.Rotator)), false), __read(this.createDndHelpers("r_cropH" /* CropHandle */, Cropper_1.Cropper)), false), __read(this.createDndHelpers("r_cropC" /* CropContainer */, Cropper_1.Cropper)), false);
24711
25127
  this.editor.select(this.image);
24712
25128
  }
24713
25129
  };
@@ -24882,7 +25298,9 @@ function handleRadIndexCalculator(angleRad) {
24882
25298
  var idx = Math.round(angleRad / DirectionRad) % DIRECTIONS;
24883
25299
  return idx < 0 ? idx + DIRECTIONS : idx;
24884
25300
  }
24885
- function rotateHandles(y, x, angleRad) {
25301
+ function rotateHandles(angleRad, y, x) {
25302
+ if (y === void 0) { y = ''; }
25303
+ if (x === void 0) { x = ''; }
24886
25304
  var radIndex = handleRadIndexCalculator(angleRad);
24887
25305
  var originalDirection = y + x;
24888
25306
  var originalIndex = DirectionOrder.indexOf(originalDirection);
@@ -24898,9 +25316,7 @@ function updateHandleCursor(handles, angleRad) {
24898
25316
  handles.map(function (handle) {
24899
25317
  var y = handle.dataset.y;
24900
25318
  var x = handle.dataset.x;
24901
- if (y && x) {
24902
- handle.style.cursor = rotateHandles(y, x, angleRad) + "-resize";
24903
- }
25319
+ handle.style.cursor = rotateHandles(angleRad, y, x) + "-resize";
24904
25320
  });
24905
25321
  }
24906
25322
  /**
@@ -25192,6 +25608,22 @@ exports.default = applyChange;
25192
25608
 
25193
25609
  "use strict";
25194
25610
 
25611
+ var __read = (this && this.__read) || function (o, n) {
25612
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25613
+ if (!m) return o;
25614
+ var i = m.call(o), r, ar = [], e;
25615
+ try {
25616
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
25617
+ }
25618
+ catch (error) { e = { error: error }; }
25619
+ finally {
25620
+ try {
25621
+ if (r && !r.done && (m = i["return"])) m.call(i);
25622
+ }
25623
+ finally { if (e) throw e.error; }
25624
+ }
25625
+ return ar;
25626
+ };
25195
25627
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25196
25628
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25197
25629
  if (ar || !(i in from)) {
@@ -25210,8 +25642,8 @@ var CROP_KEYS = [
25210
25642
  'topPercent',
25211
25643
  'bottomPercent',
25212
25644
  ];
25213
- var ROTATE_CROP_KEYS = __spreadArray(__spreadArray([], ROTATE_KEYS, true), CROP_KEYS, true);
25214
- var ALL_KEYS = __spreadArray(__spreadArray([], ROTATE_CROP_KEYS, true), RESIZE_KEYS, true);
25645
+ var ROTATE_CROP_KEYS = __spreadArray(__spreadArray([], __read(ROTATE_KEYS), false), __read(CROP_KEYS), false);
25646
+ var ALL_KEYS = __spreadArray(__spreadArray([], __read(ROTATE_CROP_KEYS), false), __read(RESIZE_KEYS), false);
25215
25647
  /**
25216
25648
  * @internal
25217
25649
  * Check the state of an edit info
@@ -25463,6 +25895,22 @@ var __assign = (this && this.__assign) || function () {
25463
25895
  };
25464
25896
  return __assign.apply(this, arguments);
25465
25897
  };
25898
+ var __read = (this && this.__read) || function (o, n) {
25899
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25900
+ if (!m) return o;
25901
+ var i = m.call(o), r, ar = [], e;
25902
+ try {
25903
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
25904
+ }
25905
+ catch (error) { e = { error: error }; }
25906
+ finally {
25907
+ try {
25908
+ if (r && !r.done && (m = i["return"])) m.call(i);
25909
+ }
25910
+ finally { if (e) throw e.error; }
25911
+ }
25912
+ return ar;
25913
+ };
25466
25914
  Object.defineProperty(exports, "__esModule", { value: true });
25467
25915
  exports.getCropHTML = exports.Cropper = void 0;
25468
25916
  var Resizer_1 = __webpack_require__(/*! ./Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
@@ -25488,7 +25936,7 @@ exports.Cropper = {
25488
25936
  onDragging: function (_a, e, base, dx, dy) {
25489
25937
  var _b;
25490
25938
  var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options;
25491
- _b = (0, Resizer_1.rotateCoordinate)(dx, dy, editInfo.angleRad), dx = _b[0], dy = _b[1];
25939
+ _b = __read((0, Resizer_1.rotateCoordinate)(dx, dy, editInfo.angleRad), 2), dx = _b[0], dy = _b[1];
25492
25940
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, bottomPercent = editInfo.bottomPercent;
25493
25941
  var minWidth = options.minWidth, minHeight = options.minHeight;
25494
25942
  var widthPercent = 1 - leftPercent - rightPercent;
@@ -25607,6 +26055,22 @@ var __assign = (this && this.__assign) || function () {
25607
26055
  };
25608
26056
  return __assign.apply(this, arguments);
25609
26057
  };
26058
+ var __read = (this && this.__read) || function (o, n) {
26059
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26060
+ if (!m) return o;
26061
+ var i = m.call(o), r, ar = [], e;
26062
+ try {
26063
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
26064
+ }
26065
+ catch (error) { e = { error: error }; }
26066
+ finally {
26067
+ try {
26068
+ if (r && !r.done && (m = i["return"])) m.call(i);
26069
+ }
26070
+ finally { if (e) throw e.error; }
26071
+ }
26072
+ return ar;
26073
+ };
25610
26074
  Object.defineProperty(exports, "__esModule", { value: true });
25611
26075
  exports.getResizeBordersHTML = exports.getSideResizeHTML = exports.getCornerResizeHTML = exports.doubleCheckResize = exports.rotateCoordinate = exports.Resizer = void 0;
25612
26076
  var RESIZE_HANDLE_SIZE = 10;
@@ -25626,7 +26090,7 @@ exports.Resizer = {
25626
26090
  var _b;
25627
26091
  var x = _a.x, y = _a.y, editInfo = _a.editInfo, options = _a.options;
25628
26092
  var ratio = base.widthPx > 0 && base.heightPx > 0 ? (base.widthPx * 1.0) / base.heightPx : 0;
25629
- _b = rotateCoordinate(deltaX, deltaY, editInfo.angleRad), deltaX = _b[0], deltaY = _b[1];
26093
+ _b = __read(rotateCoordinate(deltaX, deltaY, editInfo.angleRad), 2), deltaX = _b[0], deltaY = _b[1];
25630
26094
  if (options.minWidth !== undefined && options.minHeight !== undefined) {
25631
26095
  var horizontalOnly = x == '';
25632
26096
  var verticalOnly = y == '';
@@ -26149,7 +26613,7 @@ var Paste = /** @class */ (function () {
26149
26613
  (0, convertPastedContentFromPowerPoint_1.default)(event, trustedHTMLHandler);
26150
26614
  break;
26151
26615
  case 5 /* WacComponents */:
26152
- (0, convertPastedContentFromOfficeOnline_1.default)(fragment);
26616
+ (0, convertPastedContentFromOfficeOnline_1.default)(fragment, sanitizingOption);
26153
26617
  break;
26154
26618
  case 4 /* GoogleSheets */:
26155
26619
  sanitizingOption.additionalTagReplacements[GOOGLE_SHEET_NODE_NAME] = '*';
@@ -26478,6 +26942,7 @@ exports.createListItemBlock = createListItemBlock;
26478
26942
  "use strict";
26479
26943
 
26480
26944
  Object.defineProperty(exports, "__esModule", { value: true });
26945
+ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
26481
26946
  var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
26482
26947
  var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
26483
26948
  /**
@@ -26487,7 +26952,7 @@ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[cla
26487
26952
  * We need to remove the display property and margin from all the list item
26488
26953
  * @param event The BeforePaste event
26489
26954
  */
26490
- function convertPastedContentFromOfficeOnline(fragment) {
26955
+ function convertPastedContentFromOfficeOnline(fragment, sanitizingOption) {
26491
26956
  fragment.querySelectorAll(WAC_IDENTIFY_SELECTOR).forEach(function (el) {
26492
26957
  var element = el;
26493
26958
  element.style.removeProperty('display');
@@ -26498,6 +26963,10 @@ function convertPastedContentFromOfficeOnline(fragment) {
26498
26963
  if ((0, convertPastedContentFromWordOnline_1.isWordOnlineWithList)(fragment)) {
26499
26964
  (0, convertPastedContentFromWordOnline_1.default)(fragment);
26500
26965
  }
26966
+ // Remove "border:none" for image to fix image resize behavior
26967
+ // We found a problem that when paste an image with "border:none" then the resize border will be
26968
+ // displayed incorrectly when resize it. So we need to drop this style
26969
+ (0, roosterjs_editor_dom_1.chainSanitizerCallback)(sanitizingOption.cssStyleCallbacks, 'border', function (value, element) { return element.tagName != 'IMG' || value != 'none'; });
26501
26970
  }
26502
26971
  exports.default = convertPastedContentFromOfficeOnline;
26503
26972
 
@@ -27868,8 +28337,15 @@ var PickerPlugin = /** @class */ (function () {
27868
28337
  function PickerPlugin(dataProvider, pickerOptions) {
27869
28338
  this.dataProvider = dataProvider;
27870
28339
  this.pickerOptions = pickerOptions;
28340
+ this.editor = null;
28341
+ this.eventHandledOnKeyDown = false;
28342
+ this.blockSuggestions = false;
28343
+ this.isSuggesting = false;
28344
+ this.lastKnownRange = null;
27871
28345
  // For detecting backspace in Android
27872
28346
  this.isPendingInputEventHandling = false;
28347
+ this.currentInputLength = 0;
28348
+ this.newInputLength = 0;
27873
28349
  }
27874
28350
  /**
27875
28351
  * Get a friendly name
@@ -27885,24 +28361,27 @@ var PickerPlugin = /** @class */ (function () {
27885
28361
  var _this = this;
27886
28362
  this.editor = editor;
27887
28363
  this.dataProvider.onInitalize(function (htmlNode) {
27888
- _this.editor.focus();
27889
- var wordToReplace = _this.getWord(null);
27890
- // Safari drops our focus out so we get an empty word to replace when we call getWord.
27891
- // We fall back to using the lastKnownRange to try to get around this.
27892
- if ((!wordToReplace || wordToReplace.length == 0) && _this.lastKnownRange) {
27893
- _this.editor.select(_this.lastKnownRange);
27894
- wordToReplace = _this.getWord(null);
27895
- }
27896
- var insertNode = function () {
27897
- if (wordToReplace) {
27898
- (0, roosterjs_editor_api_1.replaceWithNode)(_this.editor, wordToReplace, htmlNode, true /* exactMatch */);
27899
- }
27900
- else {
27901
- _this.editor.insertNode(htmlNode);
28364
+ if (_this.editor) {
28365
+ _this.editor.focus();
28366
+ var wordToReplace_1 = _this.getWord(null);
28367
+ // Safari drops our focus out so we get an empty word to replace when we call getWord.
28368
+ // We fall back to using the lastKnownRange to try to get around this.
28369
+ if ((!wordToReplace_1 || wordToReplace_1.length == 0) && _this.lastKnownRange) {
28370
+ _this.editor.select(_this.lastKnownRange);
28371
+ wordToReplace_1 = _this.getWord(null);
27902
28372
  }
27903
- _this.setIsSuggesting(false);
27904
- };
27905
- _this.editor.addUndoSnapshot(insertNode, _this.pickerOptions.changeSource, _this.pickerOptions.handleAutoComplete);
28373
+ var insertNode = function () {
28374
+ var _a;
28375
+ if (wordToReplace_1 && _this.editor) {
28376
+ (0, roosterjs_editor_api_1.replaceWithNode)(_this.editor, wordToReplace_1, htmlNode, true /* exactMatch */);
28377
+ }
28378
+ else {
28379
+ (_a = _this.editor) === null || _a === void 0 ? void 0 : _a.insertNode(htmlNode);
28380
+ }
28381
+ _this.setIsSuggesting(false);
28382
+ };
28383
+ _this.editor.addUndoSnapshot(insertNode, _this.pickerOptions.changeSource, _this.pickerOptions.handleAutoComplete);
28384
+ }
27906
28385
  }, function (isSuggesting) {
27907
28386
  _this.setIsSuggesting(isSuggesting);
27908
28387
  }, editor);
@@ -27912,13 +28391,13 @@ var PickerPlugin = /** @class */ (function () {
27912
28391
  */
27913
28392
  PickerPlugin.prototype.dispose = function () {
27914
28393
  this.editor = null;
27915
- this.isSuggesting = null;
27916
- this.blockSuggestions = null;
27917
- this.eventHandledOnKeyDown = null;
28394
+ this.isSuggesting = false;
28395
+ this.blockSuggestions = false;
28396
+ this.eventHandledOnKeyDown = false;
27918
28397
  this.lastKnownRange = null;
27919
- this.isPendingInputEventHandling = null;
27920
- this.currentInputLength = null;
27921
- this.newInputLength = null;
28398
+ this.isPendingInputEventHandling = false;
28399
+ this.currentInputLength = 0;
28400
+ this.newInputLength = 0;
27922
28401
  this.dataProvider.onDispose();
27923
28402
  };
27924
28403
  /**
@@ -27940,6 +28419,7 @@ var PickerPlugin = /** @class */ (function () {
27940
28419
  * @param event PluginEvent object
27941
28420
  */
27942
28421
  PickerPlugin.prototype.onPluginEvent = function (event) {
28422
+ var _a;
27943
28423
  switch (event.eventType) {
27944
28424
  case 7 /* ContentChanged */:
27945
28425
  if (event.source == "SetContent" /* SetContent */ && this.dataProvider.onContentChanged) {
@@ -27950,7 +28430,7 @@ var PickerPlugin = /** @class */ (function () {
27950
28430
  // Undo and other major changes to document content fire this type of event.
27951
28431
  // Inform the data provider of the current picker placed elements in the body.
27952
28432
  var elementIds_1 = [];
27953
- this.editor.queryElements("[id^='" + this.pickerOptions.elementIdPrefix + "']", function (element) {
28433
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.queryElements("[id^='" + this.pickerOptions.elementIdPrefix + "']", function (element) {
27954
28434
  if (element.id) {
27955
28435
  elementIds_1.push(element.id);
27956
28436
  }
@@ -28015,29 +28495,35 @@ var PickerPlugin = /** @class */ (function () {
28015
28495
  event.rawEvent.stopImmediatePropagation();
28016
28496
  };
28017
28497
  PickerPlugin.prototype.getIdValue = function (node) {
28018
- var element = node;
28019
- return element.attributes && element.attributes.getNamedItem('id')
28020
- ? element.attributes.getNamedItem('id').value
28021
- : null;
28498
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(node, 'HTMLElement')) {
28499
+ var attribute = node.attributes.getNamedItem('id');
28500
+ return attribute ? attribute.value : null;
28501
+ }
28502
+ else {
28503
+ return null;
28504
+ }
28022
28505
  };
28023
28506
  PickerPlugin.prototype.getWordBeforeCursor = function (event) {
28024
- var searcher = this.editor.getContentSearcherOfCursor(event);
28507
+ var _a;
28508
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28025
28509
  return searcher ? searcher.getWordBefore() : null;
28026
28510
  };
28027
28511
  PickerPlugin.prototype.replaceNode = function (currentNode, replacementNode) {
28512
+ var _a, _b;
28028
28513
  if (currentNode) {
28029
- this.editor.deleteNode(currentNode);
28514
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.deleteNode(currentNode);
28030
28515
  }
28031
28516
  if (replacementNode) {
28032
- this.editor.insertNode(replacementNode);
28517
+ (_b = this.editor) === null || _b === void 0 ? void 0 : _b.insertNode(replacementNode);
28033
28518
  }
28034
28519
  };
28035
28520
  PickerPlugin.prototype.getRangeUntilAt = function (event) {
28036
28521
  var _this = this;
28037
- var positionContentSearcher = this.editor.getContentSearcherOfCursor(event);
28038
- var startPos;
28039
- var endPos;
28040
- positionContentSearcher.forEachTextInlineElement(function (textInline) {
28522
+ var _a, _b, _c;
28523
+ var positionContentSearcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28524
+ var startPos = undefined;
28525
+ var endPos = undefined;
28526
+ positionContentSearcher === null || positionContentSearcher === void 0 ? void 0 : positionContentSearcher.forEachTextInlineElement(function (textInline) {
28041
28527
  var hasMatched = false;
28042
28528
  var nodeContent = textInline.getTextContent();
28043
28529
  var nodeIndex = nodeContent ? nodeContent.length : -1;
@@ -28054,7 +28540,9 @@ var PickerPlugin = /** @class */ (function () {
28054
28540
  }
28055
28541
  return hasMatched;
28056
28542
  });
28057
- return (0, roosterjs_editor_dom_1.createRange)(startPos, endPos) || this.editor.getDocument().createRange();
28543
+ return startPos
28544
+ ? (0, roosterjs_editor_dom_1.createRange)(startPos, endPos)
28545
+ : (_c = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getDocument().createRange()) !== null && _c !== void 0 ? _c : null;
28058
28546
  };
28059
28547
  PickerPlugin.prototype.shouldHandleKeyUpEvent = function (event) {
28060
28548
  // onKeyUpDomEvent should only be called when a key that produces a character value is pressed
@@ -28065,78 +28553,89 @@ var PickerPlugin = /** @class */ (function () {
28065
28553
  (this.isSuggesting && !(0, roosterjs_editor_dom_1.isModifierKey)(event.rawEvent)));
28066
28554
  };
28067
28555
  PickerPlugin.prototype.onKeyUpDomEvent = function (event) {
28068
- if (this.isSuggesting) {
28069
- // Word before cursor represents the text prior to the cursor, up to and including the trigger symbol.
28070
- var wordBeforeCursor = this.getWord(event);
28071
- var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28072
- var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28073
- // If we hit a case where wordBeforeCursor is just the trigger character,
28074
- // that means we've gotten a onKeyUp event right after it's been typed.
28075
- // Otherwise, update the query string when:
28076
- // 1. There's an actual value
28077
- // 2. That actual value isn't just pure whitespace
28078
- // 3. That actual value isn't more than 4 words long (at which point we assume the person kept typing)
28079
- // Otherwise, we want to dismiss the picker plugin's UX.
28080
- if (wordBeforeCursor == this.pickerOptions.triggerCharacter ||
28081
- (trimmedWordBeforeCursor &&
28082
- trimmedWordBeforeCursor.length > 0 &&
28083
- trimmedWordBeforeCursor.split(' ').length <= 4)) {
28084
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28085
- this.setLastKnownRange(this.editor.getSelectionRange());
28086
- }
28087
- else {
28088
- this.setIsSuggesting(false);
28089
- }
28090
- }
28091
- else {
28092
- var wordBeforeCursor = this.getWordBeforeCursor(event);
28093
- if (!this.blockSuggestions) {
28094
- if (wordBeforeCursor != null &&
28095
- wordBeforeCursor.split(' ').length <= 4 &&
28096
- wordBeforeCursor[0] == this.pickerOptions.triggerCharacter) {
28097
- this.setIsSuggesting(true);
28556
+ var _a, _b, _c, _d, _e;
28557
+ if (this.editor) {
28558
+ if (this.isSuggesting) {
28559
+ // Word before cursor represents the text prior to the cursor, up to and including the trigger symbol.
28560
+ var wordBeforeCursor = this.getWord(event);
28561
+ if (wordBeforeCursor !== null) {
28098
28562
  var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28099
28563
  var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28100
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28101
- this.setLastKnownRange(this.editor.getSelectionRange());
28102
- if (this.dataProvider.setCursorPoint) {
28103
- // Determine the bounding rectangle for the @mention
28104
- var searcher = this.editor.getContentSearcherOfCursor(event);
28105
- var rangeNode = this.editor.getDocument().createRange();
28106
- var nodeBeforeCursor = searcher.getInlineElementBefore().getContainerNode();
28107
- var rangeStartSuccessfullySet = this.setRangeStart(rangeNode, nodeBeforeCursor, wordBeforeCursor);
28108
- if (!rangeStartSuccessfullySet) {
28109
- // VSO 24891: Out of range error is occurring because nodeBeforeCursor
28110
- // is not including the trigger character. In this case, the node before
28111
- // the node before cursor is the trigger character, and this is where the range should start.
28112
- var nodeBeforeNodeBeforeCursor = nodeBeforeCursor.previousSibling;
28113
- this.setRangeStart(rangeNode, nodeBeforeNodeBeforeCursor, this.pickerOptions.triggerCharacter);
28114
- }
28115
- var rect = rangeNode.getBoundingClientRect();
28116
- // Safari's support for range.getBoundingClientRect is incomplete.
28117
- // We perform this check to fall back to getClientRects in case it's at the page origin.
28118
- if (rect.left == 0 && rect.bottom == 0 && rect.top == 0) {
28119
- rect = rangeNode.getClientRects()[0];
28120
- }
28121
- if (rect) {
28122
- rangeNode.detach();
28123
- // Display the @mention popup in the correct place
28124
- var targetPoint = { x: rect.left, y: (rect.bottom + rect.top) / 2 };
28125
- var bufferZone = (rect.bottom - rect.top) / 2;
28126
- this.dataProvider.setCursorPoint(targetPoint, bufferZone);
28127
- }
28564
+ // If we hit a case where wordBeforeCursor is just the trigger character,
28565
+ // that means we've gotten a onKeyUp event right after it's been typed.
28566
+ // Otherwise, update the query string when:
28567
+ // 1. There's an actual value
28568
+ // 2. That actual value isn't just pure whitespace
28569
+ // 3. That actual value isn't more than 4 words long (at which point we assume the person kept typing)
28570
+ // Otherwise, we want to dismiss the picker plugin's UX.
28571
+ if (wordBeforeCursor == this.pickerOptions.triggerCharacter ||
28572
+ (trimmedWordBeforeCursor &&
28573
+ trimmedWordBeforeCursor.length > 0 &&
28574
+ trimmedWordBeforeCursor.split(' ').length <= 4)) {
28575
+ this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28576
+ this.setLastKnownRange((_a = this.editor.getSelectionRange()) !== null && _a !== void 0 ? _a : null);
28577
+ }
28578
+ else {
28579
+ this.setIsSuggesting(false);
28128
28580
  }
28129
28581
  }
28130
28582
  }
28131
28583
  else {
28132
- if (wordBeforeCursor != null &&
28133
- wordBeforeCursor[0] != this.pickerOptions.triggerCharacter) {
28134
- this.blockSuggestions = false;
28584
+ var wordBeforeCursor = this.getWordBeforeCursor(event);
28585
+ if (!this.blockSuggestions) {
28586
+ if (wordBeforeCursor != null &&
28587
+ wordBeforeCursor.split(' ').length <= 4 &&
28588
+ wordBeforeCursor[0] == this.pickerOptions.triggerCharacter) {
28589
+ this.setIsSuggesting(true);
28590
+ var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28591
+ var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28592
+ this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28593
+ this.setLastKnownRange((_b = this.editor.getSelectionRange()) !== null && _b !== void 0 ? _b : null);
28594
+ if (this.dataProvider.setCursorPoint) {
28595
+ // Determine the bounding rectangle for the @mention
28596
+ var searcher = this.editor.getContentSearcherOfCursor(event);
28597
+ var rangeNode = this.editor.getDocument().createRange();
28598
+ if (rangeNode) {
28599
+ var nodeBeforeCursor = (_d = (_c = searcher === null || searcher === void 0 ? void 0 : searcher.getInlineElementBefore()) === null || _c === void 0 ? void 0 : _c.getContainerNode()) !== null && _d !== void 0 ? _d : null;
28600
+ var rangeStartSuccessfullySet = this.setRangeStart(rangeNode, nodeBeforeCursor, wordBeforeCursor);
28601
+ if (!rangeStartSuccessfullySet) {
28602
+ // VSO 24891: Out of range error is occurring because nodeBeforeCursor
28603
+ // is not including the trigger character. In this case, the node before
28604
+ // the node before cursor is the trigger character, and this is where the range should start.
28605
+ var nodeBeforeNodeBeforeCursor = (_e = nodeBeforeCursor === null || nodeBeforeCursor === void 0 ? void 0 : nodeBeforeCursor.previousSibling) !== null && _e !== void 0 ? _e : null;
28606
+ this.setRangeStart(rangeNode, nodeBeforeNodeBeforeCursor, this.pickerOptions.triggerCharacter);
28607
+ }
28608
+ var rect = rangeNode.getBoundingClientRect();
28609
+ // Safari's support for range.getBoundingClientRect is incomplete.
28610
+ // We perform this check to fall back to getClientRects in case it's at the page origin.
28611
+ if (rect.left == 0 && rect.bottom == 0 && rect.top == 0) {
28612
+ rect = rangeNode.getClientRects()[0];
28613
+ }
28614
+ if (rect) {
28615
+ rangeNode.detach();
28616
+ // Display the @mention popup in the correct place
28617
+ var targetPoint = {
28618
+ x: rect.left,
28619
+ y: (rect.bottom + rect.top) / 2,
28620
+ };
28621
+ var bufferZone = (rect.bottom - rect.top) / 2;
28622
+ this.dataProvider.setCursorPoint(targetPoint, bufferZone);
28623
+ }
28624
+ }
28625
+ }
28626
+ }
28627
+ }
28628
+ else {
28629
+ if (wordBeforeCursor != null &&
28630
+ wordBeforeCursor[0] != this.pickerOptions.triggerCharacter) {
28631
+ this.blockSuggestions = false;
28632
+ }
28135
28633
  }
28136
28634
  }
28137
28635
  }
28138
28636
  };
28139
28637
  PickerPlugin.prototype.onKeyDownEvent = function (event) {
28638
+ var _a, _b;
28140
28639
  var keyboardEvent = event.rawEvent;
28141
28640
  if (this.isSuggesting) {
28142
28641
  if (keyboardEvent.key == ESC_CHAR_CODE) {
@@ -28183,15 +28682,19 @@ var PickerPlugin = /** @class */ (function () {
28183
28682
  }
28184
28683
  }
28185
28684
  else if (keyboardEvent.key == DELETE_CHAR_CODE) {
28186
- var searcher = this.editor.getContentSearcherOfCursor(event);
28187
- var nodeAfterCursor = searcher.getInlineElementAfter()
28188
- ? searcher.getInlineElementAfter().getContainerNode()
28189
- : null;
28190
- var nodeId = nodeAfterCursor ? this.getIdValue(nodeAfterCursor) : null;
28191
- if (nodeId && nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0) {
28192
- var replacementNode = this.dataProvider.onRemove(nodeAfterCursor, false);
28193
- this.replaceNode(nodeAfterCursor, replacementNode);
28194
- this.cancelDefaultKeyDownEvent(event);
28685
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28686
+ if (searcher) {
28687
+ var nodeAfterCursor = searcher.getInlineElementAfter()
28688
+ ? (_b = searcher.getInlineElementAfter()) === null || _b === void 0 ? void 0 : _b.getContainerNode()
28689
+ : null;
28690
+ var nodeId = nodeAfterCursor ? this.getIdValue(nodeAfterCursor) : null;
28691
+ if (nodeId &&
28692
+ nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0 &&
28693
+ nodeAfterCursor) {
28694
+ var replacementNode = this.dataProvider.onRemove(nodeAfterCursor, false);
28695
+ this.replaceNode(nodeAfterCursor, replacementNode);
28696
+ this.cancelDefaultKeyDownEvent(event);
28697
+ }
28195
28698
  }
28196
28699
  }
28197
28700
  }
@@ -28211,6 +28714,9 @@ var PickerPlugin = /** @class */ (function () {
28211
28714
  return wordBeforeCursor ? wordBeforeCursor.length : 0;
28212
28715
  };
28213
28716
  PickerPlugin.prototype.tryRemoveNode = function (event) {
28717
+ if (!this.editor) {
28718
+ return false;
28719
+ }
28214
28720
  var searcher = this.editor.getContentSearcherOfCursor(event);
28215
28721
  if (!searcher) {
28216
28722
  return false;
@@ -28247,7 +28753,8 @@ var PickerPlugin = /** @class */ (function () {
28247
28753
  return false;
28248
28754
  };
28249
28755
  PickerPlugin.prototype.getWord = function (event) {
28250
- var wordFromRange = this.getRangeUntilAt(event).toString();
28756
+ var _a, _b;
28757
+ var wordFromRange = (_b = (_a = this.getRangeUntilAt(event)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
28251
28758
  var wordFromCache = this.getWordBeforeCursor(event);
28252
28759
  // VSO 24891: In picker, trigger and mention are separated into two nodes.
28253
28760
  // In this case, wordFromRange is the trigger character while wordFromCache is the whole string,
@@ -28259,25 +28766,28 @@ var PickerPlugin = /** @class */ (function () {
28259
28766
  return wordFromRange;
28260
28767
  };
28261
28768
  PickerPlugin.prototype.setRangeStart = function (rangeNode, node, target) {
28262
- var nodeOffset = node ? node.textContent.lastIndexOf(target) : -1;
28263
- if (nodeOffset > -1) {
28769
+ var nodeOffset = (node === null || node === void 0 ? void 0 : node.textContent) ? node.textContent.lastIndexOf(target) : -1;
28770
+ if (node && nodeOffset > -1) {
28264
28771
  rangeNode.setStart(node, nodeOffset);
28265
28772
  return true;
28266
28773
  }
28267
28774
  return false;
28268
28775
  };
28269
28776
  PickerPlugin.prototype.setAriaOwns = function (isSuggesting) {
28270
- this.editor.setEditorDomAttribute('aria-owns', isSuggesting && this.pickerOptions.suggestionsLabel
28777
+ var _a;
28778
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorDomAttribute('aria-owns', isSuggesting && this.pickerOptions.suggestionsLabel
28271
28779
  ? this.pickerOptions.suggestionsLabel
28272
28780
  : null);
28273
28781
  };
28274
28782
  PickerPlugin.prototype.setAriaActiveDescendant = function (selectedIndex) {
28275
- this.editor.setEditorDomAttribute('aria-activedescendant', selectedIndex != null && this.pickerOptions.suggestionLabelPrefix
28783
+ var _a;
28784
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorDomAttribute('aria-activedescendant', selectedIndex != null && this.pickerOptions.suggestionLabelPrefix
28276
28785
  ? this.pickerOptions.suggestionLabelPrefix + selectedIndex.toString()
28277
28786
  : null);
28278
28787
  };
28279
28788
  PickerPlugin.prototype.getInlineElementBeforeCursor = function (event) {
28280
- var searcher = this.editor.getContentSearcherOfCursor(event);
28789
+ var _a;
28790
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28281
28791
  var element = searcher ? searcher.getInlineElementBefore() : null;
28282
28792
  return element ? element.getTextContent() : null;
28283
28793
  };
@@ -31477,6 +31987,14 @@ var CompatibleExperimentalFeatures;
31477
31987
  * Align list elements elements to left, center and right using setAlignment API
31478
31988
  */
31479
31989
  CompatibleExperimentalFeatures["ListItemAlignment"] = "ListItemAlignment";
31990
+ /**
31991
+ * @deprecated
31992
+ */
31993
+ CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31994
+ /**
31995
+ * @deprecated
31996
+ */
31997
+ CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
31480
31998
  //#endregion
31481
31999
  /**
31482
32000
  * Provide additional Tab Key Features. Requires Text Features Content Editable Features
@@ -31493,11 +32011,6 @@ var CompatibleExperimentalFeatures;
31493
32011
  * is the one closest to the item.
31494
32012
  */
31495
32013
  CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
31496
- /**
31497
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
31498
- * the block element (In most case, the DIV element) so keep the block element clean.
31499
- */
31500
- CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31501
32014
  /**
31502
32015
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
31503
32016
  */
@@ -31506,10 +32019,6 @@ var CompatibleExperimentalFeatures;
31506
32019
  * Handle keyboard editing event with Content Model
31507
32020
  */
31508
32021
  CompatibleExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
31509
- /**
31510
- * Apply default format on editor container
31511
- */
31512
- CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
31513
32022
  /**
31514
32023
  * Delete table with Backspace key with the whole was selected with table selector
31515
32024
  */
@@ -31820,7 +32329,7 @@ var CompatibleKnownCreateElementDataIndex;
31820
32329
  */
31821
32330
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["TableSelector"] = 11] = "TableSelector";
31822
32331
  /**
31823
- * An empty line without format with span inside of it.
32332
+ * @deprecated
31824
32333
  */
31825
32334
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["EmptyLineFormatInSpan"] = 12] = "EmptyLineFormatInSpan";
31826
32335
  })(CompatibleKnownCreateElementDataIndex = exports.CompatibleKnownCreateElementDataIndex || (exports.CompatibleKnownCreateElementDataIndex = {}));