roosterjs 8.46.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.
@@ -2908,6 +2929,7 @@ var canMergeTableCell = function (editor) {
2908
2929
 
2909
2930
  Object.defineProperty(exports, "__esModule", { value: true });
2910
2931
  var commitListChains_1 = __webpack_require__(/*! ../utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
2932
+ var getFormatState_1 = __webpack_require__(/*! ./getFormatState */ "./packages/roosterjs-editor-api/lib/format/getFormatState.ts");
2911
2933
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
2912
2934
  /**
2913
2935
  * Insert an entity into editor.
@@ -2920,10 +2942,13 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
2920
2942
  * If isBlock is true, entity will be insert below this position
2921
2943
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2922
2944
  * Parent nodes will be split if need
2945
+ * @param focusAfterEntity @optional When pass true, focus will be moved next to the entity. For inline entity,
2946
+ * focus will be after right after the entity (and the delimiter if exist). For block entity, focus will be in
2947
+ * the new empty line below the entity
2923
2948
  */
2924
- function insertEntity(editor, type, contentNode, isBlock, isReadonly, position, insertToRegionRoot) {
2949
+ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position, insertToRegionRoot, focusAfterEntity) {
2925
2950
  var _a;
2926
- var wrapper = (0, roosterjs_editor_dom_1.wrap)(contentNode, isBlock ? 'DIV' : 'SPAN');
2951
+ var wrapper = (0, roosterjs_editor_dom_1.wrap)(contentNode, isBlock ? 'div' : 'span');
2927
2952
  // For inline & readonly entity, we need to set display to "inline-block" otherwise
2928
2953
  // there will be some weird behavior when move cursor around the entity node.
2929
2954
  // And we should only do this for readonly entity since "inline-block" has some side effect
@@ -2934,6 +2959,7 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
2934
2959
  wrapper.style.display = 'inline-block';
2935
2960
  }
2936
2961
  (0, roosterjs_editor_dom_1.commitEntity)(wrapper, type, isReadonly);
2962
+ var currentFormat = (0, getFormatState_1.default)(editor);
2937
2963
  if (!editor.contains(wrapper)) {
2938
2964
  var currentRange = null;
2939
2965
  var contentPosition = void 0;
@@ -2976,15 +3002,32 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
2976
3002
  }
2977
3003
  }
2978
3004
  }
3005
+ var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(wrapper);
2979
3006
  if (isBlock) {
2980
3007
  // Insert an extra empty line for block entity to make sure
2981
3008
  // user can still put cursor below the entity.
2982
- var br = editor.getDocument().createElement('BR');
2983
- (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(br, wrapper.nextSibling);
2984
- }
2985
- var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(wrapper);
2986
- if (!isBlock &&
2987
- isReadonly &&
3009
+ var newLine = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, editor.getDocument());
3010
+ (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newLine, wrapper.nextSibling);
3011
+ if (newLine) {
3012
+ (0, roosterjs_editor_dom_1.applyFormat)(newLine, {
3013
+ backgroundColor: currentFormat.backgroundColor,
3014
+ textColor: currentFormat.textColor,
3015
+ bold: currentFormat.isBold,
3016
+ fontFamily: currentFormat.fontName,
3017
+ fontSize: currentFormat.fontSize,
3018
+ italic: currentFormat.isItalic,
3019
+ underline: currentFormat.isUnderline,
3020
+ }, editor.isDarkMode(), editor.getDarkColorHandler());
3021
+ }
3022
+ if (focusAfterEntity) {
3023
+ var br = newLine === null || newLine === void 0 ? void 0 : newLine.querySelector('br');
3024
+ var pos = br && new roosterjs_editor_dom_1.Position(br, -2 /* Before */);
3025
+ if (pos) {
3026
+ editor.select(pos);
3027
+ }
3028
+ }
3029
+ }
3030
+ else if (isReadonly &&
2988
3031
  editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
2989
3032
  (0, roosterjs_editor_dom_1.addDelimiters)(entity.wrapper);
2990
3033
  if (entity.wrapper.nextElementSibling) {
@@ -3186,9 +3229,7 @@ function setAlignment(editor, alignment) {
3186
3229
  (0, roosterjs_editor_dom_1.isWholeTableSelected)(new roosterjs_editor_dom_1.VTable(selection.table), selection.coordinates)) {
3187
3230
  alignTable(selection, alignment);
3188
3231
  }
3189
- else if (elementAtCursor &&
3190
- isList(elementAtCursor) &&
3191
- editor.isFeatureEnabled("ListItemAlignment" /* ListItemAlignment */)) {
3232
+ else if (elementAtCursor && isList(elementAtCursor)) {
3192
3233
  alignList(editor, alignment);
3193
3234
  }
3194
3235
  else {
@@ -3254,7 +3295,7 @@ function isList(element) {
3254
3295
  }
3255
3296
  function alignList(editor, alignment) {
3256
3297
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3257
- 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);
3258
3299
  var startNode = blocks[0].getStartNode();
3259
3300
  var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(region, true /*includeSiblingLists*/, startNode);
3260
3301
  if (start && end) {
@@ -3453,7 +3494,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
3453
3494
  function setIndentation(editor, indentation) {
3454
3495
  var handler = indentation == 0 /* Increase */ ? indent : outdent;
3455
3496
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3456
- 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*/);
3457
3498
  var blockGroups = [[]];
3458
3499
  for (var i = 0; i < blocks.length; i++) {
3459
3500
  var startNode = blocks[i].getStartNode();
@@ -4475,7 +4516,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
4475
4516
  */
4476
4517
  function blockWrap(editor, wrapFunction, beforeRunCallback, apiName) {
4477
4518
  (0, blockFormat_1.default)(editor, function (region) {
4478
- 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*/);
4479
4520
  var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
4480
4521
  if (nodes.length > 0) {
4481
4522
  if (nodes.length == 1) {
@@ -5050,12 +5091,13 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
5050
5091
  if (!clipboardData) {
5051
5092
  return null;
5052
5093
  }
5094
+ var pasteType = getPasteType(pasteAsText, applyCurrentStyle, pasteAsImage);
5053
5095
  // Step 1: Prepare BeforePasteEvent object
5054
- var event = createBeforePasteEvent(core, clipboardData);
5096
+ var event = createBeforePasteEvent(core, clipboardData, pasteType);
5055
5097
  return (0, roosterjs_editor_dom_1.createFragmentFromClipboardData)(core, clipboardData, position, pasteAsText, applyCurrentStyle, pasteAsImage, event);
5056
5098
  };
5057
5099
  exports.createPasteFragment = createPasteFragment;
5058
- function createBeforePasteEvent(core, clipboardData) {
5100
+ function createBeforePasteEvent(core, clipboardData, pasteType) {
5059
5101
  var options = (0, roosterjs_editor_dom_1.createDefaultHtmlSanitizerOptions)();
5060
5102
  // Remove "caret-color" style generated by Safari to make sure caret shows in right color after paste
5061
5103
  options.cssStyleCallbacks['caret-color'] = function () { return false; };
@@ -5067,8 +5109,23 @@ function createBeforePasteEvent(core, clipboardData) {
5067
5109
  htmlBefore: '',
5068
5110
  htmlAfter: '',
5069
5111
  htmlAttributes: {},
5112
+ pasteType: pasteType,
5070
5113
  };
5071
5114
  }
5115
+ function getPasteType(pasteAsText, applyCurrentStyle, pasteAsImage) {
5116
+ if (pasteAsText) {
5117
+ return 1 /* AsPlainText */;
5118
+ }
5119
+ else if (applyCurrentStyle) {
5120
+ return 2 /* MergeFormat */;
5121
+ }
5122
+ else if (pasteAsImage) {
5123
+ return 3 /* AsImage */;
5124
+ }
5125
+ else {
5126
+ return 0 /* Normal */;
5127
+ }
5128
+ }
5072
5129
 
5073
5130
 
5074
5131
  /***/ }),
@@ -5090,7 +5147,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
5090
5147
  * When typing goes directly under content div, many things can go wrong
5091
5148
  * We fix it by wrapping it with a div and reposition cursor within the div
5092
5149
  */
5093
- var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
5150
+ var ensureTypeInContainer = function (core, position, keyboardEvent) {
5094
5151
  var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
5095
5152
  var td;
5096
5153
  if (table && (td = table.querySelector('td,th'))) {
@@ -5111,27 +5168,18 @@ var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormat
5111
5168
  var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
5112
5169
  (keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
5113
5170
  formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
5114
- if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
5115
- var firstChild = formatNode.firstChild;
5116
- formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
5117
- ? firstChild
5118
- : (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
5119
- }
5120
5171
  }
5121
5172
  else {
5122
5173
  // Only reason we don't get the selection block is that we have an empty content div
5123
5174
  // which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
5124
5175
  // The fix is to add a DIV wrapping, apply default format and move cursor over
5125
- formatNode = (0, roosterjs_editor_dom_1.createElement)(applyFormatToSpan
5126
- ? 12 /* EmptyLineFormatInSpan */
5127
- : 1 /* EmptyLine */, core.contentDiv.ownerDocument);
5176
+ formatNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5128
5177
  core.api.insertNode(core, formatNode, {
5129
5178
  position: 1 /* End */,
5130
5179
  updateCursor: false,
5131
5180
  replaceSelection: false,
5132
5181
  insertOnNewLine: false,
5133
5182
  });
5134
- formatNode = applyFormatToSpan ? formatNode.firstChild : formatNode;
5135
5183
  // element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
5136
5184
  position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5137
5185
  }
@@ -5232,7 +5280,7 @@ var getContent = function (core, mode) {
5232
5280
  else if (mode == 3 /* PlainText */) {
5233
5281
  content = (0, roosterjs_editor_dom_1.getTextContent)(root);
5234
5282
  }
5235
- else if (triggerExtractContentEvent || core.lifecycle.isDarkMode || core.darkColorHandler) {
5283
+ else {
5236
5284
  var clonedRoot = cloneNode(root);
5237
5285
  clonedRoot.normalize();
5238
5286
  var originalRange = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
@@ -5244,9 +5292,7 @@ var getContent = function (core, mode) {
5244
5292
  ? (0, roosterjs_editor_dom_1.getSelectionPath)(core.contentDiv, originalRange)
5245
5293
  : null;
5246
5294
  var range = path && (0, roosterjs_editor_dom_1.createRange)(clonedRoot, path.start, path.end);
5247
- if (core.lifecycle.isDarkMode || core.darkColorHandler) {
5248
- core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, !!core.darkColorHandler, core.lifecycle.isDarkMode);
5249
- }
5295
+ core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, true /*forceTransform*/, core.lifecycle.isDarkMode);
5250
5296
  if (triggerExtractContentEvent) {
5251
5297
  core.api.triggerEvent(core, {
5252
5298
  eventType: 8 /* ExtractContentWithDom */,
@@ -5262,11 +5308,6 @@ var getContent = function (core, mode) {
5262
5308
  content = clonedRoot.innerHTML;
5263
5309
  }
5264
5310
  }
5265
- else {
5266
- content = (0, roosterjs_editor_dom_1.getHtmlWithSelectionPath)(root, includeSelectionMarker
5267
- ? core.api.getSelectionRange(core, true /*tryGetFromCache*/)
5268
- : null);
5269
- }
5270
5311
  return content !== null && content !== void 0 ? content : '';
5271
5312
  };
5272
5313
  exports.getContent = getContent;
@@ -5536,8 +5577,6 @@ function checkAllCollapsed(ranges) {
5536
5577
  Object.defineProperty(exports, "__esModule", { value: true });
5537
5578
  exports.getStyleBasedFormatState = void 0;
5538
5579
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5539
- var ORIGINAL_STYLE_COLOR_SELECTOR = "[data-" + "ogsc" /* OriginalStyleColor */ + "],[data-" + "ogac" /* OriginalAttributeColor */ + "]";
5540
- var ORIGINAL_STYLE_BACK_COLOR_SELECTOR = "[data-" + "ogsb" /* OriginalStyleBackgroundColor */ + "],[data-" + "ogab" /* OriginalAttributeBackgroundColor */ + "]";
5541
5580
  /**
5542
5581
  * @internal
5543
5582
  * Get style based format state from current selection, including font name/size and colors
@@ -5571,86 +5610,48 @@ var getStyleBasedFormatState = function (core, node) {
5571
5610
  'direction',
5572
5611
  ])
5573
5612
  : [];
5574
- var contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler, isDarkMode = core.lifecycle.isDarkMode;
5575
- if (darkColorHandler) {
5576
- var styleTextColor = void 0;
5577
- var styleBackColor = void 0;
5578
- while (node &&
5579
- (0, roosterjs_editor_dom_1.contains)(contentDiv, node, true /*treatSameNodeAsContain*/) &&
5580
- !(styleTextColor && styleBackColor)) {
5581
- if (node.nodeType == 1 /* Element */) {
5582
- var element = node;
5583
- styleTextColor = styleTextColor || element.style.getPropertyValue('color');
5584
- styleBackColor =
5585
- styleBackColor || element.style.getPropertyValue('background-color');
5586
- }
5587
- node = node.parentNode;
5588
- }
5589
- if (!core.lifecycle.isDarkMode && node == core.contentDiv) {
5590
- styleTextColor = styleTextColor || styles[2];
5591
- styleBackColor = styleBackColor || styles[3];
5613
+ var contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler;
5614
+ var styleTextColor;
5615
+ var styleBackColor;
5616
+ while (node &&
5617
+ (0, roosterjs_editor_dom_1.contains)(contentDiv, node, true /*treatSameNodeAsContain*/) &&
5618
+ !(styleTextColor && styleBackColor)) {
5619
+ if (node.nodeType == 1 /* Element */) {
5620
+ var element = node;
5621
+ styleTextColor = styleTextColor || element.style.getPropertyValue('color');
5622
+ styleBackColor = styleBackColor || element.style.getPropertyValue('background-color');
5592
5623
  }
5593
- var textColor = darkColorHandler.parseColorValue(override[2] || styleTextColor);
5594
- var backColor = darkColorHandler.parseColorValue(override[3] || styleBackColor);
5595
- return {
5596
- fontName: override[0] || styles[0],
5597
- fontSize: override[1] || styles[1],
5598
- textColor: textColor.lightModeColor,
5599
- backgroundColor: backColor.lightModeColor,
5600
- textColors: textColor.darkModeColor
5601
- ? {
5602
- lightModeColor: textColor.lightModeColor,
5603
- darkModeColor: textColor.darkModeColor,
5604
- }
5605
- : undefined,
5606
- backgroundColors: backColor.darkModeColor
5607
- ? {
5608
- lightModeColor: backColor.lightModeColor,
5609
- darkModeColor: backColor.darkModeColor,
5610
- }
5611
- : undefined,
5612
- lineHeight: styles[4],
5613
- marginTop: styles[5],
5614
- marginBottom: styles[6],
5615
- textAlign: styles[7],
5616
- direction: styles[8],
5617
- };
5624
+ node = node.parentNode;
5618
5625
  }
5619
- else {
5620
- var ogTextColorNode = isDarkMode &&
5621
- (override[2]
5622
- ? pendableFormatSpan
5623
- : (0, roosterjs_editor_dom_1.findClosestElementAncestor)(node, contentDiv, ORIGINAL_STYLE_COLOR_SELECTOR));
5624
- var ogBackgroundColorNode = isDarkMode &&
5625
- (override[3]
5626
- ? pendableFormatSpan
5627
- : (0, roosterjs_editor_dom_1.findClosestElementAncestor)(node, contentDiv, ORIGINAL_STYLE_BACK_COLOR_SELECTOR));
5628
- return {
5629
- fontName: override[0] || styles[0],
5630
- fontSize: override[1] || styles[1],
5631
- textColor: override[2] || styles[2],
5632
- backgroundColor: override[3] || styles[3],
5633
- textColors: ogTextColorNode
5634
- ? {
5635
- darkModeColor: override[2] || styles[2],
5636
- lightModeColor: ogTextColorNode.dataset["ogsc" /* OriginalStyleColor */] ||
5637
- ogTextColorNode.dataset["ogac" /* OriginalAttributeColor */] ||
5638
- styles[2],
5639
- }
5640
- : undefined,
5641
- backgroundColors: ogBackgroundColorNode
5642
- ? {
5643
- darkModeColor: override[3] || styles[3],
5644
- lightModeColor: ogBackgroundColorNode.dataset["ogsb" /* OriginalStyleBackgroundColor */] ||
5645
- ogBackgroundColorNode.dataset["ogab" /* OriginalAttributeBackgroundColor */] ||
5646
- styles[3],
5647
- }
5648
- : undefined,
5649
- lineHeight: styles[4],
5650
- textAlign: styles[7],
5651
- direction: styles[8],
5652
- };
5626
+ if (!core.lifecycle.isDarkMode && node == core.contentDiv) {
5627
+ styleTextColor = styleTextColor || styles[2];
5628
+ styleBackColor = styleBackColor || styles[3];
5653
5629
  }
5630
+ var textColor = darkColorHandler.parseColorValue(override[2] || styleTextColor);
5631
+ var backColor = darkColorHandler.parseColorValue(override[3] || styleBackColor);
5632
+ return {
5633
+ fontName: override[0] || styles[0],
5634
+ fontSize: override[1] || styles[1],
5635
+ textColor: textColor.lightModeColor,
5636
+ backgroundColor: backColor.lightModeColor,
5637
+ textColors: textColor.darkModeColor
5638
+ ? {
5639
+ lightModeColor: textColor.lightModeColor,
5640
+ darkModeColor: textColor.darkModeColor,
5641
+ }
5642
+ : undefined,
5643
+ backgroundColors: backColor.darkModeColor
5644
+ ? {
5645
+ lightModeColor: backColor.lightModeColor,
5646
+ darkModeColor: backColor.darkModeColor,
5647
+ }
5648
+ : undefined,
5649
+ lineHeight: styles[4],
5650
+ marginTop: styles[5],
5651
+ marginBottom: styles[6],
5652
+ textAlign: styles[7],
5653
+ direction: styles[8],
5654
+ };
5654
5655
  };
5655
5656
  exports.getStyleBasedFormatState = getStyleBasedFormatState;
5656
5657
 
@@ -5892,11 +5893,9 @@ var restoreUndoSnapshot = function (core, step) {
5892
5893
  core.api.setContent(core, snapshot.html, true /*triggerContentChangedEvent*/, (_a = snapshot.metadata) !== null && _a !== void 0 ? _a : undefined);
5893
5894
  var darkColorHandler_1 = core.darkColorHandler;
5894
5895
  var isDarkModel_1 = core.lifecycle.isDarkMode;
5895
- if (darkColorHandler_1) {
5896
- snapshot.knownColors.forEach(function (color) {
5897
- darkColorHandler_1.registerColor(color.lightModeColor, isDarkModel_1, color.darkModeColor);
5898
- });
5899
- }
5896
+ snapshot.knownColors.forEach(function (color) {
5897
+ darkColorHandler_1.registerColor(color.lightModeColor, isDarkModel_1, color.darkModeColor);
5898
+ });
5900
5899
  }
5901
5900
  finally {
5902
5901
  core.undo.isRestoring = false;
@@ -6510,14 +6509,10 @@ var ColorAttributeName = [
6510
6509
  (_a = {},
6511
6510
  _a[0 /* CssColor */] = 'color',
6512
6511
  _a[1 /* HtmlColor */] = 'color',
6513
- _a[2 /* CssDataSet */] = "ogsc" /* OriginalStyleColor */,
6514
- _a[3 /* HtmlDataSet */] = "ogac" /* OriginalAttributeColor */,
6515
6512
  _a),
6516
6513
  (_b = {},
6517
6514
  _b[0 /* CssColor */] = 'background-color',
6518
6515
  _b[1 /* HtmlColor */] = 'bgcolor',
6519
- _b[2 /* CssDataSet */] = "ogsb" /* OriginalStyleBackgroundColor */,
6520
- _b[3 /* HtmlDataSet */] = "ogab" /* OriginalAttributeBackgroundColor */,
6521
6516
  _b),
6522
6517
  ];
6523
6518
  /**
@@ -6537,20 +6532,7 @@ var transformColor = function (core, rootNode, includeSelf, callback, direction,
6537
6532
  ? getAll(rootNode, includeSelf)
6538
6533
  : [];
6539
6534
  callback === null || callback === void 0 ? void 0 : callback();
6540
- if (darkColorHandler) {
6541
- transformV2(elements, darkColorHandler, !!fromDarkMode, direction == 0 /* LightToDark */);
6542
- }
6543
- else {
6544
- if (direction == 1 /* DarkToLight */) {
6545
- transformToLightMode(elements);
6546
- }
6547
- else if (core.lifecycle.onExternalContentTransform) {
6548
- elements.forEach(function (element) { return core.lifecycle.onExternalContentTransform(element); });
6549
- }
6550
- else {
6551
- transformToDarkMode(elements, core.lifecycle.getDarkColor);
6552
- }
6553
- }
6535
+ transformV2(elements, darkColorHandler, !!fromDarkMode, direction == 0 /* LightToDark */);
6554
6536
  };
6555
6537
  exports.transformColor = transformColor;
6556
6538
  function transformV2(elements, darkColorHandler, fromDark, toDark) {
@@ -6566,66 +6548,6 @@ function transformV2(elements, darkColorHandler, fromDark, toDark) {
6566
6548
  });
6567
6549
  });
6568
6550
  }
6569
- function transformToLightMode(elements) {
6570
- elements.forEach(function (element) {
6571
- ColorAttributeName.forEach(function (names) {
6572
- // Reset color styles based on the content of the ogsc/ogsb data element.
6573
- // If those data properties are empty or do not exist, set them anyway to clear the content.
6574
- element.style.setProperty(names[0 /* CssColor */], getValueOrDefault(element.dataset[names[2 /* CssDataSet */]], ''));
6575
- delete element.dataset[names[2 /* CssDataSet */]];
6576
- // Some elements might have set attribute colors. We need to reset these as well.
6577
- var value = getValueOrDefault(element.dataset[names[3 /* HtmlDataSet */]], null);
6578
- if (value) {
6579
- element.setAttribute(names[1 /* HtmlColor */], value);
6580
- }
6581
- else {
6582
- element.removeAttribute(names[1 /* HtmlColor */]);
6583
- }
6584
- delete element.dataset[names[3 /* HtmlDataSet */]];
6585
- });
6586
- });
6587
- }
6588
- function transformToDarkMode(elements, getDarkColor) {
6589
- ColorAttributeName.forEach(function (names) {
6590
- elements
6591
- .map(function (element) {
6592
- var styleColor = element.style.getPropertyValue(names[0 /* CssColor */]);
6593
- var attrColor = element.getAttribute(names[1 /* HtmlColor */]);
6594
- var existingDataSetCssValue = element.dataset[names[2 /* CssDataSet */]];
6595
- var existingDataSetHtmlValue = element.dataset[names[3 /* HtmlDataSet */]];
6596
- var needProcess = (!existingDataSetCssValue || existingDataSetCssValue == styleColor) &&
6597
- (!existingDataSetHtmlValue || existingDataSetHtmlValue == attrColor) &&
6598
- (styleColor || attrColor) &&
6599
- styleColor != 'inherit'; // For inherit style, no need to change it and let it keep inherit from parent element
6600
- return needProcess
6601
- ? {
6602
- element: element,
6603
- styleColor: styleColor,
6604
- attrColor: attrColor,
6605
- newColor: styleColor || attrColor
6606
- ? getDarkColor((styleColor || attrColor))
6607
- : null,
6608
- }
6609
- : null;
6610
- })
6611
- .filter(function (x) { return !!x; })
6612
- .forEach(function (entry) {
6613
- if (!entry) {
6614
- return;
6615
- }
6616
- var element = entry.element, styleColor = entry.styleColor, attrColor = entry.attrColor, newColor = entry.newColor;
6617
- element.style.setProperty(names[0 /* CssColor */], newColor, 'important');
6618
- element.dataset[names[2 /* CssDataSet */]] = styleColor || '';
6619
- if (attrColor && newColor) {
6620
- element.setAttribute(names[1 /* HtmlColor */], newColor);
6621
- element.dataset[names[3 /* HtmlDataSet */]] = attrColor;
6622
- }
6623
- });
6624
- });
6625
- }
6626
- function getValueOrDefault(value, defaultValue) {
6627
- return value && value != 'undefined' && value != 'null' ? value : defaultValue;
6628
- }
6629
6551
  function getAll(rootNode, includeSelf) {
6630
6552
  var result = [];
6631
6553
  if ((0, roosterjs_editor_dom_1.safeInstanceOf)(rootNode, 'HTMLElement')) {
@@ -7699,7 +7621,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7699
7621
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
7700
7622
  var Escape = 'Escape';
7701
7623
  var Delete = 'Delete';
7702
- var mouseRightButton = 2;
7703
7624
  var mouseLeftButton = 0;
7704
7625
  /**
7705
7626
  * Detect image selection and help highlight the image
@@ -7742,14 +7663,9 @@ var ImageSelection = /** @class */ (function () {
7742
7663
  break;
7743
7664
  case 6 /* MouseUp */:
7744
7665
  var target = event.rawEvent.target;
7745
- if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
7746
- if (event.rawEvent.button === mouseRightButton) {
7747
- var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
7748
- this.editor.select(imageRange);
7749
- }
7750
- else if (event.rawEvent.button === mouseLeftButton) {
7751
- this.editor.select(target);
7752
- }
7666
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
7667
+ event.rawEvent.button === mouseLeftButton) {
7668
+ this.editor.select(target);
7753
7669
  }
7754
7670
  break;
7755
7671
  case 5 /* MouseDown */:
@@ -7779,6 +7695,14 @@ var ImageSelection = /** @class */ (function () {
7779
7695
  }
7780
7696
  }
7781
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
+ }
7782
7706
  }
7783
7707
  }
7784
7708
  };
@@ -8442,7 +8366,7 @@ var TypeInContainerPlugin = /** @class */ (function () {
8442
8366
  */
8443
8367
  TypeInContainerPlugin.prototype.onPluginEvent = function (event) {
8444
8368
  var _this = this;
8445
- var _a, _b, _c, _d, _e, _f;
8369
+ var _a;
8446
8370
  // We need to check if the ctrl key or the meta key is pressed,
8447
8371
  // browsers like Safari fire the "keypress" event when the meta key is pressed.
8448
8372
  if (event.eventType == 1 /* KeyPress */ &&
@@ -8480,24 +8404,6 @@ var TypeInContainerPlugin = /** @class */ (function () {
8480
8404
  }
8481
8405
  }
8482
8406
  }
8483
- /**
8484
- * Add a Span with default format to the previous element when pressing backspace
8485
- */
8486
- if (event.eventType == 0 /* KeyDown */ &&
8487
- event.rawEvent.which == 8 /* BACKSPACE */ &&
8488
- ((_b = this.editor) === null || _b === void 0 ? void 0 : _b.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */))) {
8489
- var element = (_c = this.editor) === null || _c === void 0 ? void 0 : _c.getElementAtCursor();
8490
- var block_1 = element &&
8491
- ((_e = (_d = this.editor) === null || _d === void 0 ? void 0 : _d.getBlockElementAtNode(element)) === null || _e === void 0 ? void 0 : _e.getStartNode().previousSibling);
8492
- if (block_1) {
8493
- (_f = this.editor) === null || _f === void 0 ? void 0 : _f.runAsync(function (editor) {
8494
- var position = editor.getFocusedPosition();
8495
- if (position && block_1 == position.element) {
8496
- editor.ensureTypeInContainer(position, event.rawEvent);
8497
- }
8498
- });
8499
- }
8500
- }
8501
8407
  };
8502
8408
  return TypeInContainerPlugin;
8503
8409
  }());
@@ -8607,6 +8513,9 @@ var UndoPlugin = /** @class */ (function () {
8607
8513
  case 7 /* ContentChanged */:
8608
8514
  this.onContentChanged(event);
8609
8515
  break;
8516
+ case 23 /* BeforeKeyboardEditing */:
8517
+ this.onBeforeKeyboardEditing(event.rawEvent);
8518
+ break;
8610
8519
  }
8611
8520
  };
8612
8521
  UndoPlugin.prototype.onKeyDown = function (evt) {
@@ -8621,7 +8530,7 @@ var UndoPlugin = /** @class */ (function () {
8621
8530
  this.state.autoCompletePosition = null;
8622
8531
  this.lastKeyPress = evt.which;
8623
8532
  }
8624
- else {
8533
+ else if (!evt.defaultPrevented) {
8625
8534
  var selectionRange = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getSelectionRange();
8626
8535
  // Add snapshot when
8627
8536
  // 1. Something has been selected (not collapsed), or
@@ -8645,6 +8554,11 @@ var UndoPlugin = /** @class */ (function () {
8645
8554
  }
8646
8555
  this.lastKeyPress = 0;
8647
8556
  }
8557
+ else if (this.lastKeyPress == 8 /* BACKSPACE */ || this.lastKeyPress == 46 /* DELETE */) {
8558
+ if (this.state.hasNewContent) {
8559
+ this.addUndoSnapshot();
8560
+ }
8561
+ }
8648
8562
  };
8649
8563
  UndoPlugin.prototype.onKeyPress = function (evt) {
8650
8564
  var _a;
@@ -8669,22 +8583,21 @@ var UndoPlugin = /** @class */ (function () {
8669
8583
  }
8670
8584
  this.lastKeyPress = evt.which;
8671
8585
  };
8672
- UndoPlugin.prototype.onContentChanged = function (event) {
8673
- if (event.source == "Keyboard" /* Keyboard */) {
8674
- if (Number.isInteger(event.data)) {
8675
- // For keyboard event (triggered from Content Model), we can get its keycode from event.data
8676
- // And when user is keep pressing the same key, mark editor with "hasNewContent" so that next time user
8677
- // do some other action or press a different key, we will add undo snapshot
8678
- if (event.data != this.lastKeyPress) {
8679
- this.addUndoSnapshot();
8680
- }
8681
- this.lastKeyPress = event.data;
8682
- this.state.hasNewContent = true;
8683
- }
8586
+ UndoPlugin.prototype.onBeforeKeyboardEditing = function (event) {
8587
+ // For keyboard event (triggered from Content Model), we can get its keycode from event.data
8588
+ // And when user is keep pressing the same key, mark editor with "hasNewContent" so that next time user
8589
+ // do some other action or press a different key, we will add undo snapshot
8590
+ if (event.which != this.lastKeyPress) {
8591
+ this.addUndoSnapshot();
8684
8592
  }
8685
- else if (!(this.state.isRestoring ||
8593
+ this.lastKeyPress = event.which;
8594
+ this.state.hasNewContent = true;
8595
+ };
8596
+ UndoPlugin.prototype.onContentChanged = function (event) {
8597
+ if (!(this.state.isRestoring ||
8686
8598
  event.source == "SwitchToDarkMode" /* SwitchToDarkMode */ ||
8687
- event.source == "SwitchToLightMode" /* SwitchToLightMode */)) {
8599
+ event.source == "SwitchToLightMode" /* SwitchToLightMode */ ||
8600
+ event.source == "Keyboard" /* Keyboard */)) {
8688
8601
  this.clearRedoForInput();
8689
8602
  }
8690
8603
  };
@@ -8883,7 +8796,14 @@ function inlineEntityOnPluginEvent(event, editor) {
8883
8796
  break;
8884
8797
  case 8 /* ExtractContentWithDom */:
8885
8798
  case 9 /* BeforeCutCopy */:
8886
- 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
+ });
8887
8807
  break;
8888
8808
  case 0 /* KeyDown */:
8889
8809
  handleKeyDownEvent(editor, event);
@@ -8980,10 +8900,9 @@ function removeDelimiterAttr(node, checkEntity) {
8980
8900
  });
8981
8901
  }
8982
8902
  function handleCollapsedEnter(editor, delimiter) {
8983
- var _a;
8984
8903
  var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
8985
8904
  var entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;
8986
- var block = (_a = editor.getBlockElementAtNode(delimiter)) === null || _a === void 0 ? void 0 : _a.getStartNode();
8905
+ var block = getBlock(editor, delimiter);
8987
8906
  editor.runAsync(function () {
8988
8907
  if (!block) {
8989
8908
  return;
@@ -9016,6 +8935,17 @@ var getPosition = function (container) {
9016
8935
  }
9017
8936
  return undefined;
9018
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
+ }
9019
8949
  function handleSelectionNotCollapsed(editor, range, event) {
9020
8950
  var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
9021
8951
  var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
@@ -9320,6 +9250,31 @@ var __assign = (this && this.__assign) || function () {
9320
9250
  };
9321
9251
  return __assign.apply(this, arguments);
9322
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
+ };
9323
9278
  Object.defineProperty(exports, "__esModule", { value: true });
9324
9279
  exports.EditorBase = void 0;
9325
9280
  var isFeatureEnabled_1 = __webpack_require__(/*! ./isFeatureEnabled */ "./packages/roosterjs-editor-core/lib/editor/isFeatureEnabled.ts");
@@ -9352,12 +9307,11 @@ var EditorBase = /** @class */ (function () {
9352
9307
  * Dispose this editor, dispose all plugins and custom data
9353
9308
  */
9354
9309
  EditorBase.prototype.dispose = function () {
9355
- var _a;
9356
9310
  var core = this.getCore();
9357
9311
  for (var i = core.plugins.length - 1; i >= 0; i--) {
9358
9312
  core.plugins[i].dispose();
9359
9313
  }
9360
- (_a = core.darkColorHandler) === null || _a === void 0 ? void 0 : _a.reset();
9314
+ core.darkColorHandler.reset();
9361
9315
  this.core = null;
9362
9316
  };
9363
9317
  /**
@@ -9435,7 +9389,7 @@ var EditorBase = /** @class */ (function () {
9435
9389
  var selectionEx = scope == 0 /* Body */ ? null : this.getSelectionRangeEx();
9436
9390
  if (selectionEx) {
9437
9391
  selectionEx.ranges.forEach(function (range) {
9438
- 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));
9439
9393
  });
9440
9394
  }
9441
9395
  else {
@@ -9667,7 +9621,7 @@ var EditorBase = /** @class */ (function () {
9667
9621
  var result = [];
9668
9622
  var contentDiv = this.getCore().contentDiv;
9669
9623
  selection.ranges.forEach(function (range) {
9670
- 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));
9671
9625
  });
9672
9626
  return result.filter(function (value, index, self) {
9673
9627
  return self.indexOf(value) === index;
@@ -9962,7 +9916,7 @@ var EditorBase = /** @class */ (function () {
9962
9916
  */
9963
9917
  EditorBase.prototype.ensureTypeInContainer = function (position, keyboardEvent) {
9964
9918
  var core = this.getCore();
9965
- core.api.ensureTypeInContainer(core, position, keyboardEvent, this.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
9919
+ core.api.ensureTypeInContainer(core, position, keyboardEvent);
9966
9920
  };
9967
9921
  //#endregion
9968
9922
  //#region Dark mode APIs
@@ -9997,10 +9951,10 @@ var EditorBase = /** @class */ (function () {
9997
9951
  core.api.transformColor(core, node, true /*includeSelf*/, null /*callback*/, 0 /* LightToDark */);
9998
9952
  };
9999
9953
  /**
10000
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
9954
+ * Get a darkColorHandler object for this editor.
10001
9955
  */
10002
9956
  EditorBase.prototype.getDarkColorHandler = function () {
10003
- return this.getCore().darkColorHandler || null;
9957
+ return this.getCore().darkColorHandler;
10004
9958
  };
10005
9959
  /**
10006
9960
  * Make the editor in "Shadow Edit" mode.
@@ -10126,7 +10080,6 @@ var createCorePlugins_1 = __webpack_require__(/*! ../corePlugins/createCorePlugi
10126
10080
  var DarkColorHandlerImpl_1 = __webpack_require__(/*! ./DarkColorHandlerImpl */ "./packages/roosterjs-editor-core/lib/editor/DarkColorHandlerImpl.ts");
10127
10081
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
10128
10082
  var coreApiMap_1 = __webpack_require__(/*! ../coreApi/coreApiMap */ "./packages/roosterjs-editor-core/lib/coreApi/coreApiMap.ts");
10129
- var isFeatureEnabled_1 = __webpack_require__(/*! ./isFeatureEnabled */ "./packages/roosterjs-editor-core/lib/editor/isFeatureEnabled.ts");
10130
10083
  /**
10131
10084
  * Create a new instance of Editor Core
10132
10085
  * @param contentDiv The DIV HTML element which will be the container element of editor
@@ -10155,9 +10108,7 @@ var createEditorCore = function (contentDiv, options) {
10155
10108
  ? [scrollContainer]
10156
10109
  : [scrollContainer, core.contentDiv]);
10157
10110
  });
10158
- var core = __assign(__assign({ contentDiv: contentDiv, api: __assign(__assign({}, coreApiMap_1.coreApiMap), (options.coreApiOverride || {})), originalApi: coreApiMap_1.coreApiMap, plugins: plugins.filter(function (x) { return !!x; }) }, pluginState), { trustedHTMLHandler: options.trustedHTMLHandler || (function (html) { return html; }), zoomScale: zoomScale, sizeTransformer: options.sizeTransformer || (function (size) { return size / zoomScale; }), getVisibleViewport: getVisibleViewport, imageSelectionBorderColor: options.imageSelectionBorderColor, darkColorHandler: (0, isFeatureEnabled_1.isFeatureEnabled)(options.experimentalFeatures, "VariableBasedDarkColor" /* VariableBasedDarkColor */)
10159
- ? new DarkColorHandlerImpl_1.default(contentDiv, pluginState.lifecycle.getDarkColor)
10160
- : undefined });
10111
+ var core = __assign(__assign({ contentDiv: contentDiv, api: __assign(__assign({}, coreApiMap_1.coreApiMap), (options.coreApiOverride || {})), originalApi: coreApiMap_1.coreApiMap, plugins: plugins.filter(function (x) { return !!x; }) }, pluginState), { trustedHTMLHandler: options.trustedHTMLHandler || (function (html) { return html; }), zoomScale: zoomScale, sizeTransformer: options.sizeTransformer || (function (size) { return size / zoomScale; }), getVisibleViewport: getVisibleViewport, imageSelectionBorderColor: options.imageSelectionBorderColor, darkColorHandler: new DarkColorHandlerImpl_1.default(contentDiv, pluginState.lifecycle.getDarkColor) });
10161
10112
  return core;
10162
10113
  };
10163
10114
  exports.createEditorCore = createEditorCore;
@@ -11725,6 +11676,22 @@ exports.default = SelectionScoper;
11725
11676
 
11726
11677
  "use strict";
11727
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
+ };
11728
11695
  Object.defineProperty(exports, "__esModule", { value: true });
11729
11696
  exports.addDelimiterBefore = exports.addDelimiterAfter = void 0;
11730
11697
  var createElement_1 = __webpack_require__(/*! ../utils/createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
@@ -11735,7 +11702,7 @@ var ZERO_WIDTH_SPACE = '\u200B';
11735
11702
  * @param node the node to add the delimiters
11736
11703
  */
11737
11704
  function addDelimiters(node) {
11738
- var _a = getDelimiters(node), delimiterAfter = _a[0], delimiterBefore = _a[1];
11705
+ var _a = __read(getDelimiters(node), 2), delimiterAfter = _a[0], delimiterBefore = _a[1];
11739
11706
  if (!delimiterAfter) {
11740
11707
  delimiterAfter = addDelimiterAfter(node);
11741
11708
  }
@@ -12074,6 +12041,22 @@ function safeRemove(node) {
12074
12041
 
12075
12042
  "use strict";
12076
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
+ };
12077
12060
  Object.defineProperty(exports, "__esModule", { value: true });
12078
12061
  var arrayPush_1 = __webpack_require__(/*! ../jsUtils/arrayPush */ "./packages/roosterjs-editor-dom/lib/jsUtils/arrayPush.ts");
12079
12062
  var collapseNodesInRegion_1 = __webpack_require__(/*! ../region/collapseNodesInRegion */ "./packages/roosterjs-editor-dom/lib/region/collapseNodesInRegion.ts");
@@ -12113,8 +12096,8 @@ function deleteSelectedContent(root, range) {
12113
12096
  // Make sure there are node before and after the merging point.
12114
12097
  // This is required by mergeBlocksInRegion API.
12115
12098
  // This may create some empty text node as anchor
12116
- var _a = ensureBeforeAndAfter(endContainer, endOffset, false /*isStart*/), beforeEnd = _a[0], afterEnd = _a[1];
12117
- 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];
12118
12101
  nodeBefore = nodeBefore || beforeStart;
12119
12102
  // Find out all nodes to be deleted
12120
12103
  var nodes = (0, collapseNodesInRegion_1.default)(region, [afterStart, beforeEnd]);
@@ -12607,6 +12590,17 @@ exports.default = isModifierKey;
12607
12590
 
12608
12591
  "use strict";
12609
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
+ };
12610
12604
  Object.defineProperty(exports, "__esModule", { value: true });
12611
12605
  var changeElementTag_1 = __webpack_require__(/*! ../utils/changeElementTag */ "./packages/roosterjs-editor-dom/lib/utils/changeElementTag.ts");
12612
12606
  var getInheritableStyles_1 = __webpack_require__(/*! ./getInheritableStyles */ "./packages/roosterjs-editor-dom/lib/htmlSanitizer/getInheritableStyles.ts");
@@ -12710,40 +12704,60 @@ var HtmlSanitizer = /** @class */ (function () {
12710
12704
  * @param rootNode The HTML Document
12711
12705
  */
12712
12706
  HtmlSanitizer.prototype.convertGlobalCssToInlineCss = function (rootNode) {
12707
+ var e_1, _a;
12713
12708
  var styleNodes = (0, toArray_1.default)(rootNode.querySelectorAll('style'));
12714
12709
  var styleSheets = this.additionalGlobalStyleNodes
12715
12710
  .reverse()
12716
12711
  .map(function (node) { return node.sheet; })
12717
12712
  .concat(styleNodes.map(function (node) { return node.sheet; }).reverse())
12718
12713
  .filter(function (sheet) { return sheet; });
12719
- for (var _i = 0, styleSheets_1 = styleSheets; _i < styleSheets_1.length; _i++) {
12720
- var styleSheet = styleSheets_1[_i];
12721
- var _loop_1 = function (j) {
12722
- // Skip any none-style rule, i.e. @page
12723
- var styleRule = styleSheet.cssRules[j];
12724
- var text = styleRule && styleRule.style ? styleRule.style.cssText : null;
12725
- if (styleRule.type != CSSRule.STYLE_RULE || !text || !styleRule.selectorText) {
12726
- return "continue";
12727
- }
12728
- // Make sure the selector is not empty
12729
- for (var _a = 0, _b = styleRule.selectorText.split(','); _a < _b.length; _a++) {
12730
- var selector = _b[_a];
12731
- if (!selector || !selector.trim() || selector.indexOf(':') >= 0) {
12732
- 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";
12733
12724
  }
12734
- var nodes = (0, toArray_1.default)(rootNode.querySelectorAll(selector));
12735
- // Always put existing styles after so that they have higher priority
12736
- // Which means if both global style and inline style apply to the same element,
12737
- // inline style will have higher priority
12738
- nodes.forEach(function (node) {
12739
- return node.setAttribute('style', text + (node.getAttribute('style') || ''));
12740
- });
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);
12741
12751
  }
12742
- };
12743
- for (var j = styleSheet.cssRules.length - 1; j >= 0; j--) {
12744
- _loop_1(j);
12745
12752
  }
12746
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
+ }
12747
12761
  styleNodes.forEach(function (node) {
12748
12762
  if (node.parentNode) {
12749
12763
  node.parentNode.removeChild(node);
@@ -12918,6 +12932,31 @@ exports.default = HtmlSanitizer;
12918
12932
 
12919
12933
  "use strict";
12920
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
+ };
12921
12960
  Object.defineProperty(exports, "__esModule", { value: true });
12922
12961
  /**
12923
12962
  * Chain all callback for an attribute together
@@ -12938,8 +12977,8 @@ function chainSanitizerCallback(map, name, newCallback) {
12938
12977
  for (var _i = 0; _i < arguments.length; _i++) {
12939
12978
  args[_i] = arguments[_i];
12940
12979
  }
12941
- originalCallback_1.apply(void 0, args);
12942
- 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));
12943
12982
  };
12944
12983
  }
12945
12984
  }
@@ -12957,6 +12996,17 @@ exports.default = chainSanitizerCallback;
12957
12996
 
12958
12997
  "use strict";
12959
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
+ };
12960
13010
  Object.defineProperty(exports, "__esModule", { value: true });
12961
13011
  exports.cloneObject = void 0;
12962
13012
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
@@ -12964,11 +13014,21 @@ function nativeClone(source, existingObj) {
12964
13014
  return Object.assign(existingObj || {}, source);
12965
13015
  }
12966
13016
  function customClone(source, existingObj) {
13017
+ var e_1, _a;
12967
13018
  var result = existingObj || {};
12968
13019
  if (source) {
12969
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(source); _i < _a.length; _i++) {
12970
- var key = _a[_i];
12971
- 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; }
12972
13032
  }
12973
13033
  }
12974
13034
  return result;
@@ -14378,6 +14438,22 @@ exports.default = toArray;
14378
14438
 
14379
14439
  "use strict";
14380
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
+ };
14381
14457
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14382
14458
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14383
14459
  if (ar || !(i in from)) {
@@ -14564,6 +14640,7 @@ var VList = /** @class */ (function () {
14564
14640
  }
14565
14641
  item.writeBack(listStack, _this.rootList, shouldReuseAllAncestorListElements);
14566
14642
  var topList = listStack[1];
14643
+ item.applyListStyle(_this.rootList, start);
14567
14644
  if ((0, safeInstanceOf_1.default)(topList, 'HTMLOListElement')) {
14568
14645
  if (lastList != topList) {
14569
14646
  if (start == 1) {
@@ -14573,12 +14650,10 @@ var VList = /** @class */ (function () {
14573
14650
  topList.start = start;
14574
14651
  }
14575
14652
  }
14576
- if (item.getLevel() == 1) {
14653
+ if (item.getLevel() == 1 && !item.isDummy()) {
14577
14654
  start++;
14578
14655
  }
14579
14656
  }
14580
- var itemIndex = _this.getListItemIndex(item.getNode());
14581
- item.applyListStyle(_this.rootList, itemIndex);
14582
14657
  lastList = topList;
14583
14658
  });
14584
14659
  // Restore the content to the position of placeholder
@@ -14773,12 +14848,12 @@ var VList = /** @class */ (function () {
14773
14848
  var type = (0, getListTypeFromNode_1.default)(list);
14774
14849
  var items = (0, toArray_1.default)(list.childNodes);
14775
14850
  items.forEach(function (item) {
14776
- var newListTypes = __spreadArray(__spreadArray([], listTypes, true), [type], false);
14851
+ var newListTypes = __spreadArray(__spreadArray([], __read(listTypes), false), [type], false);
14777
14852
  if ((0, getListTypeFromNode_1.isListElement)(item)) {
14778
14853
  _this.populateItems(item, newListTypes);
14779
14854
  }
14780
14855
  else if (item.nodeType != 3 /* Text */ || (item.nodeValue || '').trim() != '') {
14781
- _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)))());
14782
14857
  }
14783
14858
  });
14784
14859
  };
@@ -14947,7 +15022,13 @@ var VListChain = /** @class */ (function () {
14947
15022
  var lastNumber = 0;
14948
15023
  for (var i = 0; i < lists.length; i++) {
14949
15024
  var list = lists[i];
14950
- list.start = list.start > 1 ? list.start : lastNumber + 1;
15025
+ //If there is a list chain sequence, ensure the list chain keep increasing correctly
15026
+ if (list.start > 1) {
15027
+ list.start = list.start === lastNumber ? lastNumber + 1 : list.start;
15028
+ }
15029
+ else {
15030
+ list.start = lastNumber + 1;
15031
+ }
14951
15032
  var vlist = new VList_1.default(list);
14952
15033
  lastNumber = vlist.getLastItemNumber() || 0;
14953
15034
  delete list.dataset[CHAIN_DATASET_NAME];
@@ -15014,6 +15095,22 @@ var __assign = (this && this.__assign) || function () {
15014
15095
  };
15015
15096
  return __assign.apply(this, arguments);
15016
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
+ };
15017
15114
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
15018
15115
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15019
15116
  if (ar || !(i in from)) {
@@ -15086,7 +15183,7 @@ var VListItem = /** @class */ (function () {
15086
15183
  var display = this.node.style.display;
15087
15184
  this.dummy = display != 'list-item' && display != '';
15088
15185
  // Always add a None list type in front of all other types to represent non-list scenario.
15089
- this.listTypes = __spreadArray([0 /* None */], listTypes, true);
15186
+ this.listTypes = __spreadArray([0 /* None */], __read(listTypes), false);
15090
15187
  }
15091
15188
  /**
15092
15189
  * Get type of current list item
@@ -15498,6 +15595,17 @@ exports.default = convertDecimalsToAlpha;
15498
15595
 
15499
15596
  "use strict";
15500
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
+ };
15501
15609
  Object.defineProperty(exports, "__esModule", { value: true });
15502
15610
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
15503
15611
  var RomanValues = {
@@ -15523,12 +15631,22 @@ var RomanValues = {
15523
15631
  * @returns
15524
15632
  */
15525
15633
  function convertDecimalsToRoman(decimal, isLowerCase) {
15634
+ var e_1, _a;
15526
15635
  var romanValue = '';
15527
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(RomanValues); _i < _a.length; _i++) {
15528
- var i = _a[_i];
15529
- var timesRomanCharAppear = Math.floor(decimal / RomanValues[i]);
15530
- decimal = decimal - timesRomanCharAppear * RomanValues[i];
15531
- 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; }
15532
15650
  }
15533
15651
  return isLowerCase ? romanValue.toLocaleLowerCase() : romanValue;
15534
15652
  }
@@ -15599,7 +15717,7 @@ function createVListFromRegion(region, includeSiblingLists, startNode) {
15599
15717
  }
15600
15718
  });
15601
15719
  if (nodes.length == 0 && !region.rootNode.firstChild) {
15602
- var newNode = (0, createElement_1.default)(12 /* EmptyLineFormatInSpan */, region.rootNode.ownerDocument);
15720
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, region.rootNode.ownerDocument);
15603
15721
  region.rootNode.appendChild(newNode);
15604
15722
  nodes.push(newNode);
15605
15723
  region.fullSelectionStart = new Position_1.default(newNode, 0 /* Begin */);
@@ -16588,6 +16706,22 @@ exports.default = collapseNodesInRegion;
16588
16706
 
16589
16707
  "use strict";
16590
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
+ };
16591
16725
  var _a;
16592
16726
  Object.defineProperty(exports, "__esModule", { value: true });
16593
16727
  exports.getRegionCreator = void 0;
@@ -16611,14 +16745,15 @@ var regionTypeData = (_a = {},
16611
16745
  * @param type Type of region. Currently we only support TABLE region.
16612
16746
  */
16613
16747
  function getRegionsFromRange(root, range, type) {
16748
+ var _a;
16614
16749
  var regions = [];
16615
16750
  if (root && range) {
16616
- var _a = regionTypeData[type], innerSelector = _a.innerSelector, skipTags = _a.skipTags;
16751
+ var _b = regionTypeData[type], innerSelector = _b.innerSelector, skipTags = _b.skipTags;
16617
16752
  var boundaryTree = buildBoundaryTree(root, range, type);
16618
16753
  var start = (0, findClosestElementAncestor_1.default)(range.startContainer, root, innerSelector) || root;
16619
16754
  var end = (0, findClosestElementAncestor_1.default)(range.endContainer, root, innerSelector) || root;
16620
16755
  var creator = getRegionCreator(range, skipTags);
16621
- regions = iterateNodes(creator, boundaryTree, start, end)[0];
16756
+ _a = __read(iterateNodes(creator, boundaryTree, start, end), 1), regions = _a[0];
16622
16757
  }
16623
16758
  return regions.filter(function (r) { return !!r; });
16624
16759
  }
@@ -16712,7 +16847,7 @@ function iterateNodes(creator, boundary, start, end, started) {
16712
16847
  boundaries === null || boundaries === void 0 ? void 0 : boundaries.forEach(function (child) {
16713
16848
  var _a;
16714
16849
  var newRegions;
16715
- _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];
16716
16851
  regions = regions.concat(newRegions);
16717
16852
  });
16718
16853
  }
@@ -16773,8 +16908,9 @@ var shouldSkipNode_1 = __webpack_require__(/*! ../utils/shouldSkipNode */ "./pac
16773
16908
  * @param regionBase The region to get block elements from
16774
16909
  * @param createBlockIfEmpty When set to true, a new empty block element will be created if there is not
16775
16910
  * any blocks in the region. Default value is false
16911
+ * @param deprecated Deprecated parameter, not used
16776
16912
  */
16777
- function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, shouldApplyFormatToSpan) {
16913
+ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, deprecated) {
16778
16914
  var range = (0, getSelectionRangeInRegion_1.default)(regionBase);
16779
16915
  var blocks = [];
16780
16916
  if (range) {
@@ -16798,9 +16934,7 @@ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, should
16798
16934
  });
16799
16935
  }
16800
16936
  if (blocks.length == 0 && regionBase && !regionBase.rootNode.firstChild && createBlockIfEmpty) {
16801
- var newNode = (0, createElement_1.default)(shouldApplyFormatToSpan
16802
- ? 12 /* EmptyLineFormatInSpan */
16803
- : 1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16937
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16804
16938
  regionBase.rootNode.appendChild(newNode);
16805
16939
  var block = (0, getBlockElementAtNode_1.default)(regionBase.rootNode, newNode);
16806
16940
  if (block) {
@@ -19353,6 +19487,22 @@ exports.default = applyFormat;
19353
19487
 
19354
19488
  "use strict";
19355
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
+ };
19356
19506
  Object.defineProperty(exports, "__esModule", { value: true });
19357
19507
  var getComputedStyles_1 = __webpack_require__(/*! ./getComputedStyles */ "./packages/roosterjs-editor-dom/lib/utils/getComputedStyles.ts");
19358
19508
  var getTagOfNode_1 = __webpack_require__(/*! ./getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
@@ -19374,10 +19524,10 @@ function changeElementTag(element, newTag) {
19374
19524
  }
19375
19525
  (0, moveChildNodes_1.default)(newElement, element);
19376
19526
  if (origianlTag == 'P' || (0, getTagOfNode_1.default)(newElement) == 'P') {
19377
- _a = (0, getComputedStyles_1.default)(element, [
19527
+ _a = __read((0, getComputedStyles_1.default)(element, [
19378
19528
  'margin-top',
19379
19529
  'margin-bottom',
19380
- ]), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19530
+ ]), 2), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19381
19531
  }
19382
19532
  if (element.parentNode) {
19383
19533
  element.parentNode.replaceChild(newElement, element);
@@ -19726,6 +19876,17 @@ exports.default = fromHtml;
19726
19876
 
19727
19877
  "use strict";
19728
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
+ };
19729
19890
  Object.defineProperty(exports, "__esModule", { value: true });
19730
19891
  exports.getComputedStyle = void 0;
19731
19892
  var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
@@ -19737,6 +19898,7 @@ var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementA
19737
19898
  * @returns An array of the computed styles
19738
19899
  */
19739
19900
  function getComputedStyles(node, styleNames) {
19901
+ var e_1, _a;
19740
19902
  if (styleNames === void 0) { styleNames = ['font-family', 'font-size', 'color', 'background-color']; }
19741
19903
  var element = (0, findClosestElementAncestor_1.default)(node);
19742
19904
  var result = [];
@@ -19745,12 +19907,21 @@ function getComputedStyles(node, styleNames) {
19745
19907
  var win = element.ownerDocument.defaultView || window;
19746
19908
  var styles = win.getComputedStyle(element);
19747
19909
  if (styles) {
19748
- for (var _i = 0, styleNames_1 = styleNames; _i < styleNames_1.length; _i++) {
19749
- var style = styleNames_1[_i];
19750
- var value = styles.getPropertyValue(style) || '';
19751
- value = style != 'font-family' ? value.toLowerCase() : value;
19752
- value = style == 'font-size' ? px2Pt(value) : value;
19753
- 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; }
19754
19925
  }
19755
19926
  }
19756
19927
  }
@@ -19821,6 +19992,31 @@ exports.default = getInnerHTML;
19821
19992
 
19822
19993
  "use strict";
19823
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
+ };
19824
20020
  Object.defineProperty(exports, "__esModule", { value: true });
19825
20021
  var normalizeRect_1 = __webpack_require__(/*! ./normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
19826
20022
  /**
@@ -19855,10 +20051,10 @@ function getIntersectedRect(elements, additionalRects) {
19855
20051
  .concat(additionalRects)
19856
20052
  .filter(function (element) { return !!element; });
19857
20053
  var result = {
19858
- top: Math.max.apply(Math, rects.map(function (r) { return r.top; })),
19859
- bottom: Math.min.apply(Math, rects.map(function (r) { return r.bottom; })),
19860
- left: Math.max.apply(Math, rects.map(function (r) { return r.left; })),
19861
- 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)),
19862
20058
  };
19863
20059
  return result.top < result.bottom && result.left < result.right ? result : null;
19864
20060
  }
@@ -20226,6 +20422,17 @@ exports.default = isVoidHtmlElement;
20226
20422
 
20227
20423
  "use strict";
20228
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
+ };
20229
20436
  Object.defineProperty(exports, "__esModule", { value: true });
20230
20437
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
20231
20438
  // http exclude matching regex
@@ -20289,19 +20496,29 @@ var linkMatchRules = {
20289
20496
  * The link data includes an original url and a normalized url
20290
20497
  */
20291
20498
  function matchLink(url) {
20499
+ var e_1, _a;
20292
20500
  if (url) {
20293
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(linkMatchRules); _i < _a.length; _i++) {
20294
- var schema = _a[_i];
20295
- var rule = linkMatchRules[schema];
20296
- var matches = url.match(rule.match);
20297
- if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
20298
- return {
20299
- scheme: schema,
20300
- originalUrl: url,
20301
- normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
20302
- };
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
+ }
20303
20513
  }
20304
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);
20519
+ }
20520
+ finally { if (e_1) throw e_1.error; }
20521
+ }
20305
20522
  }
20306
20523
  return null;
20307
20524
  }
@@ -20618,7 +20835,6 @@ var TRANSPARENT = 'transparent';
20618
20835
  var DARK_COLORS_LIGHTNESS = 20;
20619
20836
  //If the value of the lightness is more than 80, the color is bright
20620
20837
  var BRIGHT_COLORS_LIGHTNESS = 80;
20621
- var TRANSPARENT_COLOR = 'transparent';
20622
20838
  /**
20623
20839
  * Set text color or background color to the given element
20624
20840
  * @param element The element to set color to
@@ -20626,7 +20842,8 @@ var TRANSPARENT_COLOR = 'transparent';
20626
20842
  * @param isBackgroundColor Whether set background color or text color
20627
20843
  * @param isDarkMode Whether current mode is dark mode. @default false
20628
20844
  * @param shouldAdaptTheFontColor Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
20629
- * @param darkColorHandler An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
20845
+ * @param darkColorHandler A dark color handler object. This is now required.
20846
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
20630
20847
  */
20631
20848
  function setColor(element, color, isBackgroundColor, isDarkMode, shouldAdaptTheFontColor, darkColorHandler) {
20632
20849
  var colorString = typeof color === 'string' ? color.trim() : '';
@@ -20637,22 +20854,6 @@ function setColor(element, color, isBackgroundColor, isDarkMode, shouldAdaptTheF
20637
20854
  var colorValue = darkColorHandler.registerColor((modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString, !!isDarkMode, modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.darkModeColor);
20638
20855
  element.style.setProperty(cssName, colorValue);
20639
20856
  }
20640
- else {
20641
- element.style.setProperty(cssName, (isDarkMode
20642
- ? modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.darkModeColor
20643
- : modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString);
20644
- if (element.dataset) {
20645
- var dataSetName = isBackgroundColor
20646
- ? "ogsb" /* OriginalStyleBackgroundColor */
20647
- : "ogsc" /* OriginalStyleColor */;
20648
- if (!isDarkMode || color == TRANSPARENT_COLOR) {
20649
- delete element.dataset[dataSetName];
20650
- }
20651
- else if (modeIndependentColor) {
20652
- element.dataset[dataSetName] = modeIndependentColor.lightModeColor;
20653
- }
20654
- }
20655
- }
20656
20857
  if (isBackgroundColor && shouldAdaptTheFontColor) {
20657
20858
  adaptFontColorToBackgroundColor(element, (modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString, isDarkMode, darkColorHandler);
20658
20859
  }
@@ -20664,7 +20865,8 @@ exports.default = setColor;
20664
20865
  * @param element The element that contains text.
20665
20866
  * @param lightModeBackgroundColor Existing background color in light mode
20666
20867
  * @param isDarkMode Whether the content is in dark mode
20667
- * @param darkColorHandler An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
20868
+ * @param darkColorHandler A dark color handler object. This is now required.
20869
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
20668
20870
  */
20669
20871
  function adaptFontColorToBackgroundColor(element, lightModeBackgroundColor, isDarkMode, darkColorHandler) {
20670
20872
  if (!lightModeBackgroundColor || lightModeBackgroundColor === TRANSPARENT) {
@@ -20940,11 +21142,23 @@ exports.default = unwrap;
20940
21142
 
20941
21143
  "use strict";
20942
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
+ };
20943
21156
  Object.defineProperty(exports, "__esModule", { value: true });
20944
21157
  var createElement_1 = __webpack_require__(/*! ./createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
20945
21158
  var fromHtml_1 = __webpack_require__(/*! ./fromHtml */ "./packages/roosterjs-editor-dom/lib/utils/fromHtml.ts");
20946
21159
  var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
20947
21160
  function wrap(nodes, wrapper) {
21161
+ var e_1, _a;
20948
21162
  nodes = !nodes ? [] : (0, safeInstanceOf_1.default)(nodes, 'Node') ? [nodes] : nodes;
20949
21163
  if (nodes.length == 0 || !nodes[0] || !nodes[0].ownerDocument) {
20950
21164
  return null;
@@ -20967,9 +21181,18 @@ function wrap(nodes, wrapper) {
20967
21181
  if (parentNode) {
20968
21182
  parentNode.insertBefore(wrapper, nodes[0]);
20969
21183
  }
20970
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
20971
- var node = nodes_1[_i];
20972
- 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; }
20973
21196
  }
20974
21197
  return wrapper;
20975
21198
  }
@@ -21349,6 +21572,22 @@ __exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-edito
21349
21572
 
21350
21573
  "use strict";
21351
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
+ };
21352
21591
  Object.defineProperty(exports, "__esModule", { value: true });
21353
21592
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
21354
21593
  /**
@@ -21415,13 +21654,13 @@ var DragAndDropHelper = /** @class */ (function () {
21415
21654
  e.preventDefault();
21416
21655
  e.stopPropagation();
21417
21656
  _this.addDocumentEvents();
21418
- _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];
21419
21658
  _this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, e);
21420
21659
  };
21421
21660
  this.onMouseMove = function (e) {
21422
21661
  var _a, _b, _c;
21423
21662
  e.preventDefault();
21424
- 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];
21425
21664
  var deltaX = (pageX - _this.initX) / _this.zoomScale;
21426
21665
  var deltaY = (pageY - _this.initY) / _this.zoomScale;
21427
21666
  if (_this.initValue &&
@@ -21926,6 +22165,22 @@ exports.CursorFeatures = {
21926
22165
 
21927
22166
  "use strict";
21928
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
+ };
21929
22184
  Object.defineProperty(exports, "__esModule", { value: true });
21930
22185
  exports.EntityFeatures = void 0;
21931
22186
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
@@ -22240,7 +22495,7 @@ function triggerOperation(entity, editor, operation, event) {
22240
22495
  removeDelimiters(nextElementSibling, previousElementSibling);
22241
22496
  }
22242
22497
  else {
22243
- 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];
22244
22499
  if (delimiterAfter) {
22245
22500
  editor.select(delimiterAfter, -3 /* After */);
22246
22501
  }
@@ -23965,6 +24220,33 @@ Object.defineProperty(exports, "ContextMenu", { enumerable: true, get: function
23965
24220
 
23966
24221
  "use strict";
23967
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
+ };
23968
24250
  Object.defineProperty(exports, "__esModule", { value: true });
23969
24251
  var makeReplacement = function (sourceString, replacementHTML, matchSourceCaseSensitive, shouldReplace) { return ({
23970
24252
  sourceString: sourceString,
@@ -24071,21 +24353,31 @@ var CustomReplacePlugin = /** @class */ (function () {
24071
24353
  }
24072
24354
  };
24073
24355
  CustomReplacePlugin.prototype.getMatchingReplacement = function (stringToSearch) {
24356
+ var e_1, _a;
24074
24357
  if (stringToSearch.length == 0 || !this.replacements) {
24075
24358
  return null;
24076
24359
  }
24077
24360
  var originalStringToSearch = stringToSearch.replace(/\s/g, ' ');
24078
24361
  var lowerCaseStringToSearch = originalStringToSearch.toLocaleLowerCase();
24079
- for (var _i = 0, _a = this.replacements; _i < _a.length; _i++) {
24080
- var replacement = _a[_i];
24081
- var _b = replacement.matchSourceCaseSensitive
24082
- ? [originalStringToSearch, replacement.sourceString]
24083
- : [lowerCaseStringToSearch, replacement.sourceString.toLocaleLowerCase()], sourceMatch = _b[0], replacementMatch = _b[1];
24084
- if (sourceMatch.substring(sourceMatch.length - replacementMatch.length) ==
24085
- replacementMatch) {
24086
- 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
+ }
24087
24372
  }
24088
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
+ }
24089
24381
  return null;
24090
24382
  };
24091
24383
  return CustomReplacePlugin;
@@ -24095,21 +24387,31 @@ function getLongestReplacementSourceLength(replacements) {
24095
24387
  return Math.max.apply(null, replacements.map(function (replacement) { return replacement.sourceString.length; }));
24096
24388
  }
24097
24389
  function getReplacementEndCharacters(replacements) {
24390
+ var e_2, _a;
24098
24391
  var endChars = new Set();
24099
- for (var _i = 0, replacements_1 = replacements; _i < replacements_1.length; _i++) {
24100
- var replacement = replacements_1[_i];
24101
- var sourceString = replacement.sourceString;
24102
- if (sourceString.length == 0) {
24103
- continue;
24104
- }
24105
- var lastChar = sourceString[sourceString.length - 1];
24106
- if (!replacement.matchSourceCaseSensitive) {
24107
- endChars.add(lastChar.toLocaleLowerCase());
24108
- 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
+ }
24109
24407
  }
24110
- else {
24111
- 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);
24112
24413
  }
24414
+ finally { if (e_2) throw e_2.error; }
24113
24415
  }
24114
24416
  return endChars;
24115
24417
  }
@@ -24487,6 +24789,22 @@ var __assign = (this && this.__assign) || function () {
24487
24789
  };
24488
24790
  return __assign.apply(this, arguments);
24489
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
+ };
24490
24808
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24491
24809
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24492
24810
  if (ar || !(i in from)) {
@@ -24806,7 +25124,7 @@ var ImageEdit = /** @class */ (function () {
24806
25124
  this.createWrapper(operation);
24807
25125
  this.updateWrapper();
24808
25126
  // Init drag and drop
24809
- 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);
24810
25128
  this.editor.select(this.image);
24811
25129
  }
24812
25130
  };
@@ -24981,7 +25299,9 @@ function handleRadIndexCalculator(angleRad) {
24981
25299
  var idx = Math.round(angleRad / DirectionRad) % DIRECTIONS;
24982
25300
  return idx < 0 ? idx + DIRECTIONS : idx;
24983
25301
  }
24984
- function rotateHandles(y, x, angleRad) {
25302
+ function rotateHandles(angleRad, y, x) {
25303
+ if (y === void 0) { y = ''; }
25304
+ if (x === void 0) { x = ''; }
24985
25305
  var radIndex = handleRadIndexCalculator(angleRad);
24986
25306
  var originalDirection = y + x;
24987
25307
  var originalIndex = DirectionOrder.indexOf(originalDirection);
@@ -24997,9 +25317,7 @@ function updateHandleCursor(handles, angleRad) {
24997
25317
  handles.map(function (handle) {
24998
25318
  var y = handle.dataset.y;
24999
25319
  var x = handle.dataset.x;
25000
- if (y && x) {
25001
- handle.style.cursor = rotateHandles(y, x, angleRad) + "-resize";
25002
- }
25320
+ handle.style.cursor = rotateHandles(angleRad, y, x) + "-resize";
25003
25321
  });
25004
25322
  }
25005
25323
  /**
@@ -25291,6 +25609,22 @@ exports.default = applyChange;
25291
25609
 
25292
25610
  "use strict";
25293
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
+ };
25294
25628
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25295
25629
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25296
25630
  if (ar || !(i in from)) {
@@ -25309,8 +25643,8 @@ var CROP_KEYS = [
25309
25643
  'topPercent',
25310
25644
  'bottomPercent',
25311
25645
  ];
25312
- var ROTATE_CROP_KEYS = __spreadArray(__spreadArray([], ROTATE_KEYS, true), CROP_KEYS, true);
25313
- 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);
25314
25648
  /**
25315
25649
  * @internal
25316
25650
  * Check the state of an edit info
@@ -25562,6 +25896,22 @@ var __assign = (this && this.__assign) || function () {
25562
25896
  };
25563
25897
  return __assign.apply(this, arguments);
25564
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
+ };
25565
25915
  Object.defineProperty(exports, "__esModule", { value: true });
25566
25916
  exports.getCropHTML = exports.Cropper = void 0;
25567
25917
  var Resizer_1 = __webpack_require__(/*! ./Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
@@ -25587,7 +25937,7 @@ exports.Cropper = {
25587
25937
  onDragging: function (_a, e, base, dx, dy) {
25588
25938
  var _b;
25589
25939
  var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options;
25590
- _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];
25591
25941
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, bottomPercent = editInfo.bottomPercent;
25592
25942
  var minWidth = options.minWidth, minHeight = options.minHeight;
25593
25943
  var widthPercent = 1 - leftPercent - rightPercent;
@@ -25706,6 +26056,22 @@ var __assign = (this && this.__assign) || function () {
25706
26056
  };
25707
26057
  return __assign.apply(this, arguments);
25708
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
+ };
25709
26075
  Object.defineProperty(exports, "__esModule", { value: true });
25710
26076
  exports.getResizeBordersHTML = exports.getSideResizeHTML = exports.getCornerResizeHTML = exports.doubleCheckResize = exports.rotateCoordinate = exports.Resizer = void 0;
25711
26077
  var RESIZE_HANDLE_SIZE = 10;
@@ -25725,7 +26091,7 @@ exports.Resizer = {
25725
26091
  var _b;
25726
26092
  var x = _a.x, y = _a.y, editInfo = _a.editInfo, options = _a.options;
25727
26093
  var ratio = base.widthPx > 0 && base.heightPx > 0 ? (base.widthPx * 1.0) / base.heightPx : 0;
25728
- _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];
25729
26095
  if (options.minWidth !== undefined && options.minHeight !== undefined) {
25730
26096
  var horizontalOnly = x == '';
25731
26097
  var verticalOnly = y == '';
@@ -26238,14 +26604,17 @@ var Paste = /** @class */ (function () {
26238
26604
  break;
26239
26605
  case 1 /* ExcelDesktop */:
26240
26606
  case 2 /* ExcelOnline */:
26241
- // Handle HTML copied from Excel
26242
- (0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
26607
+ if (event.pasteType === 0 /* Normal */ ||
26608
+ event.pasteType === 2 /* MergeFormat */) {
26609
+ // Handle HTML copied from Excel
26610
+ (0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
26611
+ }
26243
26612
  break;
26244
26613
  case 3 /* PowerPointDesktop */:
26245
26614
  (0, convertPastedContentFromPowerPoint_1.default)(event, trustedHTMLHandler);
26246
26615
  break;
26247
26616
  case 5 /* WacComponents */:
26248
- (0, convertPastedContentFromOfficeOnline_1.default)(fragment);
26617
+ (0, convertPastedContentFromOfficeOnline_1.default)(fragment, sanitizingOption);
26249
26618
  break;
26250
26619
  case 4 /* GoogleSheets */:
26251
26620
  sanitizingOption.additionalTagReplacements[GOOGLE_SHEET_NODE_NAME] = '*';
@@ -26574,6 +26943,7 @@ exports.createListItemBlock = createListItemBlock;
26574
26943
  "use strict";
26575
26944
 
26576
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");
26577
26947
  var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
26578
26948
  var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
26579
26949
  /**
@@ -26583,7 +26953,7 @@ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[cla
26583
26953
  * We need to remove the display property and margin from all the list item
26584
26954
  * @param event The BeforePaste event
26585
26955
  */
26586
- function convertPastedContentFromOfficeOnline(fragment) {
26956
+ function convertPastedContentFromOfficeOnline(fragment, sanitizingOption) {
26587
26957
  fragment.querySelectorAll(WAC_IDENTIFY_SELECTOR).forEach(function (el) {
26588
26958
  var element = el;
26589
26959
  element.style.removeProperty('display');
@@ -26594,6 +26964,10 @@ function convertPastedContentFromOfficeOnline(fragment) {
26594
26964
  if ((0, convertPastedContentFromWordOnline_1.isWordOnlineWithList)(fragment)) {
26595
26965
  (0, convertPastedContentFromWordOnline_1.default)(fragment);
26596
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'; });
26597
26971
  }
26598
26972
  exports.default = convertPastedContentFromOfficeOnline;
26599
26973
 
@@ -27054,9 +27428,7 @@ exports.default = sanitizeHtmlColorsFromPastedContent;
27054
27428
 
27055
27429
  Object.defineProperty(exports, "__esModule", { value: true });
27056
27430
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
27057
- var HTTP = 'http:';
27058
- var HTTPS = 'https:';
27059
- var NOTES = 'notes:';
27431
+ var SUPPORTED_PROTOCOLS = ['http:', 'https:', 'notes:', 'mailto:', 'onenote:'];
27060
27432
  /**
27061
27433
  * @internal
27062
27434
  * Clear local paths and remove link
@@ -27074,10 +27446,8 @@ function validateLink(link, htmlElement) {
27074
27446
  catch (_a) {
27075
27447
  url = undefined;
27076
27448
  }
27077
- if (url &&
27078
- (url.protocol === HTTP ||
27079
- url.protocol === HTTPS ||
27080
- url.protocol === NOTES) /* whitelist Notes protocol */) {
27449
+ /* whitelist supported protocols */
27450
+ if (url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) > -1) {
27081
27451
  return link;
27082
27452
  }
27083
27453
  htmlElement.removeAttribute('href');
@@ -27968,8 +28338,15 @@ var PickerPlugin = /** @class */ (function () {
27968
28338
  function PickerPlugin(dataProvider, pickerOptions) {
27969
28339
  this.dataProvider = dataProvider;
27970
28340
  this.pickerOptions = pickerOptions;
28341
+ this.editor = null;
28342
+ this.eventHandledOnKeyDown = false;
28343
+ this.blockSuggestions = false;
28344
+ this.isSuggesting = false;
28345
+ this.lastKnownRange = null;
27971
28346
  // For detecting backspace in Android
27972
28347
  this.isPendingInputEventHandling = false;
28348
+ this.currentInputLength = 0;
28349
+ this.newInputLength = 0;
27973
28350
  }
27974
28351
  /**
27975
28352
  * Get a friendly name
@@ -27985,24 +28362,27 @@ var PickerPlugin = /** @class */ (function () {
27985
28362
  var _this = this;
27986
28363
  this.editor = editor;
27987
28364
  this.dataProvider.onInitalize(function (htmlNode) {
27988
- _this.editor.focus();
27989
- var wordToReplace = _this.getWord(null);
27990
- // Safari drops our focus out so we get an empty word to replace when we call getWord.
27991
- // We fall back to using the lastKnownRange to try to get around this.
27992
- if ((!wordToReplace || wordToReplace.length == 0) && _this.lastKnownRange) {
27993
- _this.editor.select(_this.lastKnownRange);
27994
- wordToReplace = _this.getWord(null);
27995
- }
27996
- var insertNode = function () {
27997
- if (wordToReplace) {
27998
- (0, roosterjs_editor_api_1.replaceWithNode)(_this.editor, wordToReplace, htmlNode, true /* exactMatch */);
27999
- }
28000
- else {
28001
- _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);
28002
28373
  }
28003
- _this.setIsSuggesting(false);
28004
- };
28005
- _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
+ }
28006
28386
  }, function (isSuggesting) {
28007
28387
  _this.setIsSuggesting(isSuggesting);
28008
28388
  }, editor);
@@ -28012,13 +28392,13 @@ var PickerPlugin = /** @class */ (function () {
28012
28392
  */
28013
28393
  PickerPlugin.prototype.dispose = function () {
28014
28394
  this.editor = null;
28015
- this.isSuggesting = null;
28016
- this.blockSuggestions = null;
28017
- this.eventHandledOnKeyDown = null;
28395
+ this.isSuggesting = false;
28396
+ this.blockSuggestions = false;
28397
+ this.eventHandledOnKeyDown = false;
28018
28398
  this.lastKnownRange = null;
28019
- this.isPendingInputEventHandling = null;
28020
- this.currentInputLength = null;
28021
- this.newInputLength = null;
28399
+ this.isPendingInputEventHandling = false;
28400
+ this.currentInputLength = 0;
28401
+ this.newInputLength = 0;
28022
28402
  this.dataProvider.onDispose();
28023
28403
  };
28024
28404
  /**
@@ -28040,6 +28420,7 @@ var PickerPlugin = /** @class */ (function () {
28040
28420
  * @param event PluginEvent object
28041
28421
  */
28042
28422
  PickerPlugin.prototype.onPluginEvent = function (event) {
28423
+ var _a;
28043
28424
  switch (event.eventType) {
28044
28425
  case 7 /* ContentChanged */:
28045
28426
  if (event.source == "SetContent" /* SetContent */ && this.dataProvider.onContentChanged) {
@@ -28050,7 +28431,7 @@ var PickerPlugin = /** @class */ (function () {
28050
28431
  // Undo and other major changes to document content fire this type of event.
28051
28432
  // Inform the data provider of the current picker placed elements in the body.
28052
28433
  var elementIds_1 = [];
28053
- 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) {
28054
28435
  if (element.id) {
28055
28436
  elementIds_1.push(element.id);
28056
28437
  }
@@ -28115,29 +28496,35 @@ var PickerPlugin = /** @class */ (function () {
28115
28496
  event.rawEvent.stopImmediatePropagation();
28116
28497
  };
28117
28498
  PickerPlugin.prototype.getIdValue = function (node) {
28118
- var element = node;
28119
- return element.attributes && element.attributes.getNamedItem('id')
28120
- ? element.attributes.getNamedItem('id').value
28121
- : 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
+ }
28122
28506
  };
28123
28507
  PickerPlugin.prototype.getWordBeforeCursor = function (event) {
28124
- var searcher = this.editor.getContentSearcherOfCursor(event);
28508
+ var _a;
28509
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28125
28510
  return searcher ? searcher.getWordBefore() : null;
28126
28511
  };
28127
28512
  PickerPlugin.prototype.replaceNode = function (currentNode, replacementNode) {
28513
+ var _a, _b;
28128
28514
  if (currentNode) {
28129
- this.editor.deleteNode(currentNode);
28515
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.deleteNode(currentNode);
28130
28516
  }
28131
28517
  if (replacementNode) {
28132
- this.editor.insertNode(replacementNode);
28518
+ (_b = this.editor) === null || _b === void 0 ? void 0 : _b.insertNode(replacementNode);
28133
28519
  }
28134
28520
  };
28135
28521
  PickerPlugin.prototype.getRangeUntilAt = function (event) {
28136
28522
  var _this = this;
28137
- var positionContentSearcher = this.editor.getContentSearcherOfCursor(event);
28138
- var startPos;
28139
- var endPos;
28140
- 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) {
28141
28528
  var hasMatched = false;
28142
28529
  var nodeContent = textInline.getTextContent();
28143
28530
  var nodeIndex = nodeContent ? nodeContent.length : -1;
@@ -28154,7 +28541,9 @@ var PickerPlugin = /** @class */ (function () {
28154
28541
  }
28155
28542
  return hasMatched;
28156
28543
  });
28157
- 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;
28158
28547
  };
28159
28548
  PickerPlugin.prototype.shouldHandleKeyUpEvent = function (event) {
28160
28549
  // onKeyUpDomEvent should only be called when a key that produces a character value is pressed
@@ -28165,78 +28554,89 @@ var PickerPlugin = /** @class */ (function () {
28165
28554
  (this.isSuggesting && !(0, roosterjs_editor_dom_1.isModifierKey)(event.rawEvent)));
28166
28555
  };
28167
28556
  PickerPlugin.prototype.onKeyUpDomEvent = function (event) {
28168
- if (this.isSuggesting) {
28169
- // Word before cursor represents the text prior to the cursor, up to and including the trigger symbol.
28170
- var wordBeforeCursor = this.getWord(event);
28171
- var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28172
- var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28173
- // If we hit a case where wordBeforeCursor is just the trigger character,
28174
- // that means we've gotten a onKeyUp event right after it's been typed.
28175
- // Otherwise, update the query string when:
28176
- // 1. There's an actual value
28177
- // 2. That actual value isn't just pure whitespace
28178
- // 3. That actual value isn't more than 4 words long (at which point we assume the person kept typing)
28179
- // Otherwise, we want to dismiss the picker plugin's UX.
28180
- if (wordBeforeCursor == this.pickerOptions.triggerCharacter ||
28181
- (trimmedWordBeforeCursor &&
28182
- trimmedWordBeforeCursor.length > 0 &&
28183
- trimmedWordBeforeCursor.split(' ').length <= 4)) {
28184
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28185
- this.setLastKnownRange(this.editor.getSelectionRange());
28186
- }
28187
- else {
28188
- this.setIsSuggesting(false);
28189
- }
28190
- }
28191
- else {
28192
- var wordBeforeCursor = this.getWordBeforeCursor(event);
28193
- if (!this.blockSuggestions) {
28194
- if (wordBeforeCursor != null &&
28195
- wordBeforeCursor.split(' ').length <= 4 &&
28196
- wordBeforeCursor[0] == this.pickerOptions.triggerCharacter) {
28197
- 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) {
28198
28563
  var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28199
28564
  var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28200
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28201
- this.setLastKnownRange(this.editor.getSelectionRange());
28202
- if (this.dataProvider.setCursorPoint) {
28203
- // Determine the bounding rectangle for the @mention
28204
- var searcher = this.editor.getContentSearcherOfCursor(event);
28205
- var rangeNode = this.editor.getDocument().createRange();
28206
- var nodeBeforeCursor = searcher.getInlineElementBefore().getContainerNode();
28207
- var rangeStartSuccessfullySet = this.setRangeStart(rangeNode, nodeBeforeCursor, wordBeforeCursor);
28208
- if (!rangeStartSuccessfullySet) {
28209
- // VSO 24891: Out of range error is occurring because nodeBeforeCursor
28210
- // is not including the trigger character. In this case, the node before
28211
- // the node before cursor is the trigger character, and this is where the range should start.
28212
- var nodeBeforeNodeBeforeCursor = nodeBeforeCursor.previousSibling;
28213
- this.setRangeStart(rangeNode, nodeBeforeNodeBeforeCursor, this.pickerOptions.triggerCharacter);
28214
- }
28215
- var rect = rangeNode.getBoundingClientRect();
28216
- // Safari's support for range.getBoundingClientRect is incomplete.
28217
- // We perform this check to fall back to getClientRects in case it's at the page origin.
28218
- if (rect.left == 0 && rect.bottom == 0 && rect.top == 0) {
28219
- rect = rangeNode.getClientRects()[0];
28220
- }
28221
- if (rect) {
28222
- rangeNode.detach();
28223
- // Display the @mention popup in the correct place
28224
- var targetPoint = { x: rect.left, y: (rect.bottom + rect.top) / 2 };
28225
- var bufferZone = (rect.bottom - rect.top) / 2;
28226
- this.dataProvider.setCursorPoint(targetPoint, bufferZone);
28227
- }
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);
28228
28581
  }
28229
28582
  }
28230
28583
  }
28231
28584
  else {
28232
- if (wordBeforeCursor != null &&
28233
- wordBeforeCursor[0] != this.pickerOptions.triggerCharacter) {
28234
- 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
+ }
28235
28634
  }
28236
28635
  }
28237
28636
  }
28238
28637
  };
28239
28638
  PickerPlugin.prototype.onKeyDownEvent = function (event) {
28639
+ var _a, _b;
28240
28640
  var keyboardEvent = event.rawEvent;
28241
28641
  if (this.isSuggesting) {
28242
28642
  if (keyboardEvent.key == ESC_CHAR_CODE) {
@@ -28283,15 +28683,19 @@ var PickerPlugin = /** @class */ (function () {
28283
28683
  }
28284
28684
  }
28285
28685
  else if (keyboardEvent.key == DELETE_CHAR_CODE) {
28286
- var searcher = this.editor.getContentSearcherOfCursor(event);
28287
- var nodeAfterCursor = searcher.getInlineElementAfter()
28288
- ? searcher.getInlineElementAfter().getContainerNode()
28289
- : null;
28290
- var nodeId = nodeAfterCursor ? this.getIdValue(nodeAfterCursor) : null;
28291
- if (nodeId && nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0) {
28292
- var replacementNode = this.dataProvider.onRemove(nodeAfterCursor, false);
28293
- this.replaceNode(nodeAfterCursor, replacementNode);
28294
- 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
+ }
28295
28699
  }
28296
28700
  }
28297
28701
  }
@@ -28311,14 +28715,21 @@ var PickerPlugin = /** @class */ (function () {
28311
28715
  return wordBeforeCursor ? wordBeforeCursor.length : 0;
28312
28716
  };
28313
28717
  PickerPlugin.prototype.tryRemoveNode = function (event) {
28718
+ if (!this.editor) {
28719
+ return false;
28720
+ }
28314
28721
  var searcher = this.editor.getContentSearcherOfCursor(event);
28722
+ if (!searcher) {
28723
+ return false;
28724
+ }
28315
28725
  var inlineElementBefore = searcher.getInlineElementBefore();
28316
28726
  var nodeBeforeCursor = inlineElementBefore
28317
28727
  ? inlineElementBefore.getContainerNode()
28318
28728
  : null;
28319
28729
  var nodeId = nodeBeforeCursor ? this.getIdValue(nodeBeforeCursor) : null;
28320
28730
  var inlineElementAfter = searcher.getInlineElementAfter();
28321
- if (nodeId &&
28731
+ if (nodeBeforeCursor &&
28732
+ nodeId &&
28322
28733
  nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0 &&
28323
28734
  (inlineElementAfter == null || !(inlineElementAfter instanceof roosterjs_editor_dom_1.PartialInlineElement))) {
28324
28735
  var replacementNode_1 = this.dataProvider.onRemove(nodeBeforeCursor, true);
@@ -28332,16 +28743,19 @@ var PickerPlugin = /** @class */ (function () {
28332
28743
  else {
28333
28744
  this.editor.select(replacementNode_1, -3 /* After */);
28334
28745
  }
28746
+ return true;
28335
28747
  }
28336
28748
  else {
28337
- this.editor.deleteNode(nodeBeforeCursor);
28749
+ // Select the node then let browser delete it
28750
+ this.editor.select(nodeBeforeCursor);
28751
+ return false;
28338
28752
  }
28339
- return true;
28340
28753
  }
28341
28754
  return false;
28342
28755
  };
28343
28756
  PickerPlugin.prototype.getWord = function (event) {
28344
- 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 : '';
28345
28759
  var wordFromCache = this.getWordBeforeCursor(event);
28346
28760
  // VSO 24891: In picker, trigger and mention are separated into two nodes.
28347
28761
  // In this case, wordFromRange is the trigger character while wordFromCache is the whole string,
@@ -28353,25 +28767,28 @@ var PickerPlugin = /** @class */ (function () {
28353
28767
  return wordFromRange;
28354
28768
  };
28355
28769
  PickerPlugin.prototype.setRangeStart = function (rangeNode, node, target) {
28356
- var nodeOffset = node ? node.textContent.lastIndexOf(target) : -1;
28357
- 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) {
28358
28772
  rangeNode.setStart(node, nodeOffset);
28359
28773
  return true;
28360
28774
  }
28361
28775
  return false;
28362
28776
  };
28363
28777
  PickerPlugin.prototype.setAriaOwns = function (isSuggesting) {
28364
- 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
28365
28780
  ? this.pickerOptions.suggestionsLabel
28366
28781
  : null);
28367
28782
  };
28368
28783
  PickerPlugin.prototype.setAriaActiveDescendant = function (selectedIndex) {
28369
- 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
28370
28786
  ? this.pickerOptions.suggestionLabelPrefix + selectedIndex.toString()
28371
28787
  : null);
28372
28788
  };
28373
28789
  PickerPlugin.prototype.getInlineElementBeforeCursor = function (event) {
28374
- var searcher = this.editor.getContentSearcherOfCursor(event);
28790
+ var _a;
28791
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28375
28792
  var element = searcher ? searcher.getInlineElementBefore() : null;
28376
28793
  return element ? element.getTextContent() : null;
28377
28794
  };
@@ -30941,6 +31358,7 @@ var CompatibleContentType;
30941
31358
  Object.defineProperty(exports, "__esModule", { value: true });
30942
31359
  exports.CompatibleDarkModeDatasetNames = void 0;
30943
31360
  /**
31361
+ * @deprecated
30944
31362
  * Constants string for dataset names used by dark mode
30945
31363
  */
30946
31364
  var CompatibleDarkModeDatasetNames;
@@ -31558,15 +31976,31 @@ var CompatibleExperimentalFeatures;
31558
31976
  * When a html image is selected, the selected image data will be stored by editor core.
31559
31977
  */
31560
31978
  CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
31561
- //#endregion
31562
31979
  /**
31563
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
31980
+ * @deprecated this feature is always enabled
31981
+ * Use variable-based dark mode solution rather than dataset-based solution.
31982
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
31983
+ * if you need them work for dark mode
31564
31984
  */
31565
- CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
31985
+ CompatibleExperimentalFeatures["VariableBasedDarkColor"] = "VariableBasedDarkColor";
31566
31986
  /**
31987
+ * @deprecated this feature is always enabled
31567
31988
  * Align list elements elements to left, center and right using setAlignment API
31568
31989
  */
31569
31990
  CompatibleExperimentalFeatures["ListItemAlignment"] = "ListItemAlignment";
31991
+ /**
31992
+ * @deprecated
31993
+ */
31994
+ CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31995
+ /**
31996
+ * @deprecated
31997
+ */
31998
+ CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
31999
+ //#endregion
32000
+ /**
32001
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
32002
+ */
32003
+ CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
31570
32004
  /**
31571
32005
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
31572
32006
  */
@@ -31578,25 +32012,14 @@ var CompatibleExperimentalFeatures;
31578
32012
  * is the one closest to the item.
31579
32013
  */
31580
32014
  CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
31581
- /**
31582
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
31583
- * the block element (In most case, the DIV element) so keep the block element clean.
31584
- */
31585
- CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31586
- /**
31587
- * Use variable-based dark mode solution rather than dataset-based solution.
31588
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
31589
- * if you need them work for dark mode
31590
- */
31591
- CompatibleExperimentalFeatures["VariableBasedDarkColor"] = "VariableBasedDarkColor";
31592
32015
  /**
31593
32016
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
31594
32017
  */
31595
32018
  CompatibleExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
31596
32019
  /**
31597
- * Apply default format on editor container
32020
+ * Handle keyboard editing event with Content Model
31598
32021
  */
31599
- CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
32022
+ CompatibleExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
31600
32023
  /**
31601
32024
  * Delete table with Backspace key with the whole was selected with table selector
31602
32025
  */
@@ -31907,7 +32330,7 @@ var CompatibleKnownCreateElementDataIndex;
31907
32330
  */
31908
32331
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["TableSelector"] = 11] = "TableSelector";
31909
32332
  /**
31910
- * An empty line without format with span inside of it.
32333
+ * @deprecated
31911
32334
  */
31912
32335
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["EmptyLineFormatInSpan"] = 12] = "EmptyLineFormatInSpan";
31913
32336
  })(CompatibleKnownCreateElementDataIndex = exports.CompatibleKnownCreateElementDataIndex || (exports.CompatibleKnownCreateElementDataIndex = {}));
@@ -32142,6 +32565,43 @@ var CompatibleNumberingListType;
32142
32565
  })(CompatibleNumberingListType = exports.CompatibleNumberingListType || (exports.CompatibleNumberingListType = {}));
32143
32566
 
32144
32567
 
32568
+ /***/ }),
32569
+
32570
+ /***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts":
32571
+ /*!*************************************************************************!*\
32572
+ !*** ./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts ***!
32573
+ \*************************************************************************/
32574
+ /*! no static exports found */
32575
+ /***/ (function(module, exports, __webpack_require__) {
32576
+
32577
+ "use strict";
32578
+
32579
+ Object.defineProperty(exports, "__esModule", { value: true });
32580
+ exports.CompatiblePasteType = void 0;
32581
+ /**
32582
+ * Enum for paste options
32583
+ */
32584
+ var CompatiblePasteType;
32585
+ (function (CompatiblePasteType) {
32586
+ /**
32587
+ * Default paste behavior
32588
+ */
32589
+ CompatiblePasteType[CompatiblePasteType["Normal"] = 0] = "Normal";
32590
+ /**
32591
+ * Paste only the plain text
32592
+ */
32593
+ CompatiblePasteType[CompatiblePasteType["AsPlainText"] = 1] = "AsPlainText";
32594
+ /**
32595
+ * Apply the current style to pasted content
32596
+ */
32597
+ CompatiblePasteType[CompatiblePasteType["MergeFormat"] = 2] = "MergeFormat";
32598
+ /**
32599
+ * If there is a image uri in the clipboard, paste the content as image element
32600
+ */
32601
+ CompatiblePasteType[CompatiblePasteType["AsImage"] = 3] = "AsImage";
32602
+ })(CompatiblePasteType = exports.CompatiblePasteType || (exports.CompatiblePasteType = {}));
32603
+
32604
+
32145
32605
  /***/ }),
32146
32606
 
32147
32607
  /***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/PluginEventType.ts":
@@ -32257,6 +32717,12 @@ var CompatiblePluginEventType;
32257
32717
  * Editor changed the selection.
32258
32718
  */
32259
32719
  CompatiblePluginEventType[CompatiblePluginEventType["SelectionChanged"] = 22] = "SelectionChanged";
32720
+ /**
32721
+ * EXPERIMENTAL FEATURE
32722
+ * Editor content is about to be changed by keyboard event.
32723
+ * This is only used by Content Model editing
32724
+ */
32725
+ CompatiblePluginEventType[CompatiblePluginEventType["BeforeKeyboardEditing"] = 23] = "BeforeKeyboardEditing";
32260
32726
  })(CompatiblePluginEventType = exports.CompatiblePluginEventType || (exports.CompatiblePluginEventType = {}));
32261
32727
 
32262
32728
 
@@ -32603,7 +33069,7 @@ var CompatibleTableOperation;
32603
33069
  "use strict";
32604
33070
 
32605
33071
  Object.defineProperty(exports, "__esModule", { value: true });
32606
- exports.CompatibleTableOperation = exports.CompatibleTableBorderFormat = exports.CompatibleSelectionRangeTypes = exports.CompatibleRegionType = exports.CompatibleQueryScope = exports.CompatiblePositionType = exports.CompatiblePluginEventType = exports.CompatibleNumberingListType = exports.CompatibleNodeType = exports.CompatibleListType = exports.CompatibleKnownPasteSourceType = exports.CompatibleKnownCreateElementDataIndex = exports.CompatibleKeys = exports.CompatibleIndentation = exports.CompatibleImageEditOperation = exports.CompatibleGetContentMode = exports.CompatibleFontSizeChange = exports.CompatibleExperimentalFeatures = exports.CompatibleEntityOperation = exports.CompatibleEntityClasses = exports.CompatibleDocumentPosition = exports.CompatibleDocumentCommand = exports.CompatibleDirection = exports.CompatibleDelimiterClasses = exports.CompatibleDefinitionType = exports.CompatibleDarkModeDatasetNames = exports.CompatibleContentType = exports.CompatibleContentTypePrefix = exports.CompatibleContentPosition = exports.CompatibleColorTransformDirection = exports.CompatibleClearFormatMode = exports.CompatibleChangeSource = exports.CompatibleCapitalization = exports.CompatibleBulletListType = exports.CompatibleAlignment = void 0;
33072
+ exports.CompatibleTableOperation = exports.CompatibleTableBorderFormat = exports.CompatibleSelectionRangeTypes = exports.CompatibleRegionType = exports.CompatibleQueryScope = exports.CompatiblePositionType = exports.CompatiblePluginEventType = exports.CompatiblePasteType = exports.CompatibleNumberingListType = exports.CompatibleNodeType = exports.CompatibleListType = exports.CompatibleKnownPasteSourceType = exports.CompatibleKnownCreateElementDataIndex = exports.CompatibleKeys = exports.CompatibleIndentation = exports.CompatibleImageEditOperation = exports.CompatibleGetContentMode = exports.CompatibleFontSizeChange = exports.CompatibleExperimentalFeatures = exports.CompatibleEntityOperation = exports.CompatibleEntityClasses = exports.CompatibleDocumentPosition = exports.CompatibleDocumentCommand = exports.CompatibleDirection = exports.CompatibleDelimiterClasses = exports.CompatibleDefinitionType = exports.CompatibleDarkModeDatasetNames = exports.CompatibleContentType = exports.CompatibleContentTypePrefix = exports.CompatibleContentPosition = exports.CompatibleColorTransformDirection = exports.CompatibleClearFormatMode = exports.CompatibleChangeSource = exports.CompatibleCapitalization = exports.CompatibleBulletListType = exports.CompatibleAlignment = void 0;
32607
33073
  var Alignment_1 = __webpack_require__(/*! ./Alignment */ "./packages/roosterjs-editor-types/lib/compatibleEnum/Alignment.ts");
32608
33074
  Object.defineProperty(exports, "CompatibleAlignment", { enumerable: true, get: function () { return Alignment_1.CompatibleAlignment; } });
32609
33075
  var BulletListType_1 = __webpack_require__(/*! ./BulletListType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/BulletListType.ts");
@@ -32659,6 +33125,8 @@ var NodeType_1 = __webpack_require__(/*! ./NodeType */ "./packages/roosterjs-edi
32659
33125
  Object.defineProperty(exports, "CompatibleNodeType", { enumerable: true, get: function () { return NodeType_1.CompatibleNodeType; } });
32660
33126
  var NumberingListType_1 = __webpack_require__(/*! ./NumberingListType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/NumberingListType.ts");
32661
33127
  Object.defineProperty(exports, "CompatibleNumberingListType", { enumerable: true, get: function () { return NumberingListType_1.CompatibleNumberingListType; } });
33128
+ var PasteType_1 = __webpack_require__(/*! ./PasteType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts");
33129
+ Object.defineProperty(exports, "CompatiblePasteType", { enumerable: true, get: function () { return PasteType_1.CompatiblePasteType; } });
32662
33130
  var PluginEventType_1 = __webpack_require__(/*! ./PluginEventType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PluginEventType.ts");
32663
33131
  Object.defineProperty(exports, "CompatiblePluginEventType", { enumerable: true, get: function () { return PluginEventType_1.CompatiblePluginEventType; } });
32664
33132
  var PositionType_1 = __webpack_require__(/*! ./PositionType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PositionType.ts");