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