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.
@@ -2362,6 +2362,17 @@ exports.default = clearBlockFormat;
2362
2362
 
2363
2363
  "use strict";
2364
2364
 
2365
+ var __values = (this && this.__values) || function(o) {
2366
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2367
+ if (m) return m.call(o);
2368
+ if (o && typeof o.length === "number") return {
2369
+ next: function () {
2370
+ if (o && i >= o.length) o = void 0;
2371
+ return { value: o && o[i++], done: !o };
2372
+ }
2373
+ };
2374
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2375
+ };
2365
2376
  Object.defineProperty(exports, "__esModule", { value: true });
2366
2377
  var applyListItemWrap_1 = __webpack_require__(/*! ../utils/applyListItemWrap */ "./packages/roosterjs-editor-api/lib/utils/applyListItemWrap.ts");
2367
2378
  var blockFormat_1 = __webpack_require__(/*! ../utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
@@ -2418,20 +2429,30 @@ function clearNodeFormat(node) {
2418
2429
  return returnBlockElement;
2419
2430
  }
2420
2431
  function clearAttribute(element) {
2432
+ var e_1, _a;
2421
2433
  var isTableCell = (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLTableCellElement');
2422
2434
  var isTable = (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLTableElement');
2423
- for (var _i = 0, _a = (0, roosterjs_editor_dom_1.toArray)(element.attributes); _i < _a.length; _i++) {
2424
- var attr = _a[_i];
2425
- if (isTableCell && attr.name == 'style') {
2426
- removeNonBorderStyles(element);
2427
- }
2428
- else if (isTable && attr.name == 'style') {
2429
- removeNotTableDefaultStyles(element);
2435
+ try {
2436
+ for (var _b = __values((0, roosterjs_editor_dom_1.toArray)(element.attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
2437
+ var attr = _c.value;
2438
+ if (isTableCell && attr.name == 'style') {
2439
+ removeNonBorderStyles(element);
2440
+ }
2441
+ else if (isTable && attr.name == 'style') {
2442
+ removeNotTableDefaultStyles(element);
2443
+ }
2444
+ else if (ATTRIBUTES_TO_PRESERVE.indexOf(attr.name.toLowerCase()) < 0 &&
2445
+ attr.name.indexOf('data-') != 0) {
2446
+ element.removeAttribute(attr.name);
2447
+ }
2430
2448
  }
2431
- else if (ATTRIBUTES_TO_PRESERVE.indexOf(attr.name.toLowerCase()) < 0 &&
2432
- attr.name.indexOf('data-') != 0) {
2433
- element.removeAttribute(attr.name);
2449
+ }
2450
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2451
+ finally {
2452
+ try {
2453
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2434
2454
  }
2455
+ finally { if (e_1) throw e_1.error; }
2435
2456
  }
2436
2457
  }
2437
2458
  function updateStyles(element, callbackfn) {
@@ -2517,7 +2538,7 @@ function clearAutoDetectFormat(editor) {
2517
2538
  function clearBlockFormat(editor) {
2518
2539
  (0, formatUndoSnapshot_1.default)(editor, function () {
2519
2540
  (0, blockFormat_1.default)(editor, function (region) {
2520
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, undefined /* createBlockIfEmpty */, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
2541
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region);
2521
2542
  var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
2522
2543
  if (editor.contains(region.rootNode)) {
2523
2544
  // If there are styles on table cell, wrap all its children and move down all non-border styles.
@@ -2907,6 +2928,7 @@ var canMergeTableCell = function (editor) {
2907
2928
 
2908
2929
  Object.defineProperty(exports, "__esModule", { value: true });
2909
2930
  var commitListChains_1 = __webpack_require__(/*! ../utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
2931
+ var getFormatState_1 = __webpack_require__(/*! ./getFormatState */ "./packages/roosterjs-editor-api/lib/format/getFormatState.ts");
2910
2932
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
2911
2933
  /**
2912
2934
  * Insert an entity into editor.
@@ -2919,10 +2941,13 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
2919
2941
  * If isBlock is true, entity will be insert below this position
2920
2942
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2921
2943
  * Parent nodes will be split if need
2944
+ * @param focusAfterEntity @optional When pass true, focus will be moved next to the entity. For inline entity,
2945
+ * focus will be after right after the entity (and the delimiter if exist). For block entity, focus will be in
2946
+ * the new empty line below the entity
2922
2947
  */
2923
- function insertEntity(editor, type, contentNode, isBlock, isReadonly, position, insertToRegionRoot) {
2948
+ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position, insertToRegionRoot, focusAfterEntity) {
2924
2949
  var _a;
2925
- var wrapper = (0, roosterjs_editor_dom_1.wrap)(contentNode, isBlock ? 'DIV' : 'SPAN');
2950
+ var wrapper = (0, roosterjs_editor_dom_1.wrap)(contentNode, isBlock ? 'div' : 'span');
2926
2951
  // For inline & readonly entity, we need to set display to "inline-block" otherwise
2927
2952
  // there will be some weird behavior when move cursor around the entity node.
2928
2953
  // And we should only do this for readonly entity since "inline-block" has some side effect
@@ -2933,6 +2958,7 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
2933
2958
  wrapper.style.display = 'inline-block';
2934
2959
  }
2935
2960
  (0, roosterjs_editor_dom_1.commitEntity)(wrapper, type, isReadonly);
2961
+ var currentFormat = (0, getFormatState_1.default)(editor);
2936
2962
  if (!editor.contains(wrapper)) {
2937
2963
  var currentRange = null;
2938
2964
  var contentPosition = void 0;
@@ -2975,15 +3001,32 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
2975
3001
  }
2976
3002
  }
2977
3003
  }
3004
+ var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(wrapper);
2978
3005
  if (isBlock) {
2979
3006
  // Insert an extra empty line for block entity to make sure
2980
3007
  // user can still put cursor below the entity.
2981
- var br = editor.getDocument().createElement('BR');
2982
- (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(br, wrapper.nextSibling);
2983
- }
2984
- var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(wrapper);
2985
- if (!isBlock &&
2986
- isReadonly &&
3008
+ var newLine = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, editor.getDocument());
3009
+ (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newLine, wrapper.nextSibling);
3010
+ if (newLine) {
3011
+ (0, roosterjs_editor_dom_1.applyFormat)(newLine, {
3012
+ backgroundColor: currentFormat.backgroundColor,
3013
+ textColor: currentFormat.textColor,
3014
+ bold: currentFormat.isBold,
3015
+ fontFamily: currentFormat.fontName,
3016
+ fontSize: currentFormat.fontSize,
3017
+ italic: currentFormat.isItalic,
3018
+ underline: currentFormat.isUnderline,
3019
+ }, editor.isDarkMode(), editor.getDarkColorHandler());
3020
+ }
3021
+ if (focusAfterEntity) {
3022
+ var br = newLine === null || newLine === void 0 ? void 0 : newLine.querySelector('br');
3023
+ var pos = br && new roosterjs_editor_dom_1.Position(br, -2 /* Before */);
3024
+ if (pos) {
3025
+ editor.select(pos);
3026
+ }
3027
+ }
3028
+ }
3029
+ else if (isReadonly &&
2987
3030
  editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
2988
3031
  (0, roosterjs_editor_dom_1.addDelimiters)(entity.wrapper);
2989
3032
  if (entity.wrapper.nextElementSibling) {
@@ -3185,9 +3228,7 @@ function setAlignment(editor, alignment) {
3185
3228
  (0, roosterjs_editor_dom_1.isWholeTableSelected)(new roosterjs_editor_dom_1.VTable(selection.table), selection.coordinates)) {
3186
3229
  alignTable(selection, alignment);
3187
3230
  }
3188
- else if (elementAtCursor &&
3189
- isList(elementAtCursor) &&
3190
- editor.isFeatureEnabled("ListItemAlignment" /* ListItemAlignment */)) {
3231
+ else if (elementAtCursor && isList(elementAtCursor)) {
3191
3232
  alignList(editor, alignment);
3192
3233
  }
3193
3234
  else {
@@ -3253,7 +3294,7 @@ function isList(element) {
3253
3294
  }
3254
3295
  function alignList(editor, alignment) {
3255
3296
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3256
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, undefined /* createBlockIfEmpty */, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
3297
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region);
3257
3298
  var startNode = blocks[0].getStartNode();
3258
3299
  var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(region, true /*includeSiblingLists*/, startNode);
3259
3300
  if (start && end) {
@@ -3452,7 +3493,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
3452
3493
  function setIndentation(editor, indentation) {
3453
3494
  var handler = indentation == 0 /* Increase */ ? indent : outdent;
3454
3495
  (0, blockFormat_1.default)(editor, function (region, start, end) {
3455
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
3496
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/);
3456
3497
  var blockGroups = [[]];
3457
3498
  for (var i = 0; i < blocks.length; i++) {
3458
3499
  var startNode = blocks[i].getStartNode();
@@ -4474,7 +4515,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
4474
4515
  */
4475
4516
  function blockWrap(editor, wrapFunction, beforeRunCallback, apiName) {
4476
4517
  (0, blockFormat_1.default)(editor, function (region) {
4477
- var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/, editor.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
4518
+ var blocks = (0, roosterjs_editor_dom_1.getSelectedBlockElementsInRegion)(region, true /*createBlockIfEmpty*/);
4478
4519
  var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
4479
4520
  if (nodes.length > 0) {
4480
4521
  if (nodes.length == 1) {
@@ -5049,12 +5090,13 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
5049
5090
  if (!clipboardData) {
5050
5091
  return null;
5051
5092
  }
5093
+ var pasteType = getPasteType(pasteAsText, applyCurrentStyle, pasteAsImage);
5052
5094
  // Step 1: Prepare BeforePasteEvent object
5053
- var event = createBeforePasteEvent(core, clipboardData);
5095
+ var event = createBeforePasteEvent(core, clipboardData, pasteType);
5054
5096
  return (0, roosterjs_editor_dom_1.createFragmentFromClipboardData)(core, clipboardData, position, pasteAsText, applyCurrentStyle, pasteAsImage, event);
5055
5097
  };
5056
5098
  exports.createPasteFragment = createPasteFragment;
5057
- function createBeforePasteEvent(core, clipboardData) {
5099
+ function createBeforePasteEvent(core, clipboardData, pasteType) {
5058
5100
  var options = (0, roosterjs_editor_dom_1.createDefaultHtmlSanitizerOptions)();
5059
5101
  // Remove "caret-color" style generated by Safari to make sure caret shows in right color after paste
5060
5102
  options.cssStyleCallbacks['caret-color'] = function () { return false; };
@@ -5066,8 +5108,23 @@ function createBeforePasteEvent(core, clipboardData) {
5066
5108
  htmlBefore: '',
5067
5109
  htmlAfter: '',
5068
5110
  htmlAttributes: {},
5111
+ pasteType: pasteType,
5069
5112
  };
5070
5113
  }
5114
+ function getPasteType(pasteAsText, applyCurrentStyle, pasteAsImage) {
5115
+ if (pasteAsText) {
5116
+ return 1 /* AsPlainText */;
5117
+ }
5118
+ else if (applyCurrentStyle) {
5119
+ return 2 /* MergeFormat */;
5120
+ }
5121
+ else if (pasteAsImage) {
5122
+ return 3 /* AsImage */;
5123
+ }
5124
+ else {
5125
+ return 0 /* Normal */;
5126
+ }
5127
+ }
5071
5128
 
5072
5129
 
5073
5130
  /***/ }),
@@ -5089,7 +5146,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
5089
5146
  * When typing goes directly under content div, many things can go wrong
5090
5147
  * We fix it by wrapping it with a div and reposition cursor within the div
5091
5148
  */
5092
- var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
5149
+ var ensureTypeInContainer = function (core, position, keyboardEvent) {
5093
5150
  var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
5094
5151
  var td;
5095
5152
  if (table && (td = table.querySelector('td,th'))) {
@@ -5110,27 +5167,18 @@ var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormat
5110
5167
  var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
5111
5168
  (keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
5112
5169
  formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
5113
- if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
5114
- var firstChild = formatNode.firstChild;
5115
- formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
5116
- ? firstChild
5117
- : (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
5118
- }
5119
5170
  }
5120
5171
  else {
5121
5172
  // Only reason we don't get the selection block is that we have an empty content div
5122
5173
  // which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
5123
5174
  // The fix is to add a DIV wrapping, apply default format and move cursor over
5124
- formatNode = (0, roosterjs_editor_dom_1.createElement)(applyFormatToSpan
5125
- ? 12 /* EmptyLineFormatInSpan */
5126
- : 1 /* EmptyLine */, core.contentDiv.ownerDocument);
5175
+ formatNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
5127
5176
  core.api.insertNode(core, formatNode, {
5128
5177
  position: 1 /* End */,
5129
5178
  updateCursor: false,
5130
5179
  replaceSelection: false,
5131
5180
  insertOnNewLine: false,
5132
5181
  });
5133
- formatNode = applyFormatToSpan ? formatNode.firstChild : formatNode;
5134
5182
  // element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
5135
5183
  position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
5136
5184
  }
@@ -5231,7 +5279,7 @@ var getContent = function (core, mode) {
5231
5279
  else if (mode == 3 /* PlainText */) {
5232
5280
  content = (0, roosterjs_editor_dom_1.getTextContent)(root);
5233
5281
  }
5234
- else if (triggerExtractContentEvent || core.lifecycle.isDarkMode || core.darkColorHandler) {
5282
+ else {
5235
5283
  var clonedRoot = cloneNode(root);
5236
5284
  clonedRoot.normalize();
5237
5285
  var originalRange = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
@@ -5243,9 +5291,7 @@ var getContent = function (core, mode) {
5243
5291
  ? (0, roosterjs_editor_dom_1.getSelectionPath)(core.contentDiv, originalRange)
5244
5292
  : null;
5245
5293
  var range = path && (0, roosterjs_editor_dom_1.createRange)(clonedRoot, path.start, path.end);
5246
- if (core.lifecycle.isDarkMode || core.darkColorHandler) {
5247
- core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, !!core.darkColorHandler, core.lifecycle.isDarkMode);
5248
- }
5294
+ core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, true /*forceTransform*/, core.lifecycle.isDarkMode);
5249
5295
  if (triggerExtractContentEvent) {
5250
5296
  core.api.triggerEvent(core, {
5251
5297
  eventType: 8 /* ExtractContentWithDom */,
@@ -5261,11 +5307,6 @@ var getContent = function (core, mode) {
5261
5307
  content = clonedRoot.innerHTML;
5262
5308
  }
5263
5309
  }
5264
- else {
5265
- content = (0, roosterjs_editor_dom_1.getHtmlWithSelectionPath)(root, includeSelectionMarker
5266
- ? core.api.getSelectionRange(core, true /*tryGetFromCache*/)
5267
- : null);
5268
- }
5269
5310
  return content !== null && content !== void 0 ? content : '';
5270
5311
  };
5271
5312
  exports.getContent = getContent;
@@ -5535,8 +5576,6 @@ function checkAllCollapsed(ranges) {
5535
5576
  Object.defineProperty(exports, "__esModule", { value: true });
5536
5577
  exports.getStyleBasedFormatState = void 0;
5537
5578
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
5538
- var ORIGINAL_STYLE_COLOR_SELECTOR = "[data-" + "ogsc" /* OriginalStyleColor */ + "],[data-" + "ogac" /* OriginalAttributeColor */ + "]";
5539
- var ORIGINAL_STYLE_BACK_COLOR_SELECTOR = "[data-" + "ogsb" /* OriginalStyleBackgroundColor */ + "],[data-" + "ogab" /* OriginalAttributeBackgroundColor */ + "]";
5540
5579
  /**
5541
5580
  * @internal
5542
5581
  * Get style based format state from current selection, including font name/size and colors
@@ -5570,86 +5609,48 @@ var getStyleBasedFormatState = function (core, node) {
5570
5609
  'direction',
5571
5610
  ])
5572
5611
  : [];
5573
- var contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler, isDarkMode = core.lifecycle.isDarkMode;
5574
- if (darkColorHandler) {
5575
- var styleTextColor = void 0;
5576
- var styleBackColor = void 0;
5577
- while (node &&
5578
- (0, roosterjs_editor_dom_1.contains)(contentDiv, node, true /*treatSameNodeAsContain*/) &&
5579
- !(styleTextColor && styleBackColor)) {
5580
- if (node.nodeType == 1 /* Element */) {
5581
- var element = node;
5582
- styleTextColor = styleTextColor || element.style.getPropertyValue('color');
5583
- styleBackColor =
5584
- styleBackColor || element.style.getPropertyValue('background-color');
5585
- }
5586
- node = node.parentNode;
5587
- }
5588
- if (!core.lifecycle.isDarkMode && node == core.contentDiv) {
5589
- styleTextColor = styleTextColor || styles[2];
5590
- styleBackColor = styleBackColor || styles[3];
5612
+ var contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler;
5613
+ var styleTextColor;
5614
+ var styleBackColor;
5615
+ while (node &&
5616
+ (0, roosterjs_editor_dom_1.contains)(contentDiv, node, true /*treatSameNodeAsContain*/) &&
5617
+ !(styleTextColor && styleBackColor)) {
5618
+ if (node.nodeType == 1 /* Element */) {
5619
+ var element = node;
5620
+ styleTextColor = styleTextColor || element.style.getPropertyValue('color');
5621
+ styleBackColor = styleBackColor || element.style.getPropertyValue('background-color');
5591
5622
  }
5592
- var textColor = darkColorHandler.parseColorValue(override[2] || styleTextColor);
5593
- var backColor = darkColorHandler.parseColorValue(override[3] || styleBackColor);
5594
- return {
5595
- fontName: override[0] || styles[0],
5596
- fontSize: override[1] || styles[1],
5597
- textColor: textColor.lightModeColor,
5598
- backgroundColor: backColor.lightModeColor,
5599
- textColors: textColor.darkModeColor
5600
- ? {
5601
- lightModeColor: textColor.lightModeColor,
5602
- darkModeColor: textColor.darkModeColor,
5603
- }
5604
- : undefined,
5605
- backgroundColors: backColor.darkModeColor
5606
- ? {
5607
- lightModeColor: backColor.lightModeColor,
5608
- darkModeColor: backColor.darkModeColor,
5609
- }
5610
- : undefined,
5611
- lineHeight: styles[4],
5612
- marginTop: styles[5],
5613
- marginBottom: styles[6],
5614
- textAlign: styles[7],
5615
- direction: styles[8],
5616
- };
5623
+ node = node.parentNode;
5617
5624
  }
5618
- else {
5619
- var ogTextColorNode = isDarkMode &&
5620
- (override[2]
5621
- ? pendableFormatSpan
5622
- : (0, roosterjs_editor_dom_1.findClosestElementAncestor)(node, contentDiv, ORIGINAL_STYLE_COLOR_SELECTOR));
5623
- var ogBackgroundColorNode = isDarkMode &&
5624
- (override[3]
5625
- ? pendableFormatSpan
5626
- : (0, roosterjs_editor_dom_1.findClosestElementAncestor)(node, contentDiv, ORIGINAL_STYLE_BACK_COLOR_SELECTOR));
5627
- return {
5628
- fontName: override[0] || styles[0],
5629
- fontSize: override[1] || styles[1],
5630
- textColor: override[2] || styles[2],
5631
- backgroundColor: override[3] || styles[3],
5632
- textColors: ogTextColorNode
5633
- ? {
5634
- darkModeColor: override[2] || styles[2],
5635
- lightModeColor: ogTextColorNode.dataset["ogsc" /* OriginalStyleColor */] ||
5636
- ogTextColorNode.dataset["ogac" /* OriginalAttributeColor */] ||
5637
- styles[2],
5638
- }
5639
- : undefined,
5640
- backgroundColors: ogBackgroundColorNode
5641
- ? {
5642
- darkModeColor: override[3] || styles[3],
5643
- lightModeColor: ogBackgroundColorNode.dataset["ogsb" /* OriginalStyleBackgroundColor */] ||
5644
- ogBackgroundColorNode.dataset["ogab" /* OriginalAttributeBackgroundColor */] ||
5645
- styles[3],
5646
- }
5647
- : undefined,
5648
- lineHeight: styles[4],
5649
- textAlign: styles[7],
5650
- direction: styles[8],
5651
- };
5625
+ if (!core.lifecycle.isDarkMode && node == core.contentDiv) {
5626
+ styleTextColor = styleTextColor || styles[2];
5627
+ styleBackColor = styleBackColor || styles[3];
5652
5628
  }
5629
+ var textColor = darkColorHandler.parseColorValue(override[2] || styleTextColor);
5630
+ var backColor = darkColorHandler.parseColorValue(override[3] || styleBackColor);
5631
+ return {
5632
+ fontName: override[0] || styles[0],
5633
+ fontSize: override[1] || styles[1],
5634
+ textColor: textColor.lightModeColor,
5635
+ backgroundColor: backColor.lightModeColor,
5636
+ textColors: textColor.darkModeColor
5637
+ ? {
5638
+ lightModeColor: textColor.lightModeColor,
5639
+ darkModeColor: textColor.darkModeColor,
5640
+ }
5641
+ : undefined,
5642
+ backgroundColors: backColor.darkModeColor
5643
+ ? {
5644
+ lightModeColor: backColor.lightModeColor,
5645
+ darkModeColor: backColor.darkModeColor,
5646
+ }
5647
+ : undefined,
5648
+ lineHeight: styles[4],
5649
+ marginTop: styles[5],
5650
+ marginBottom: styles[6],
5651
+ textAlign: styles[7],
5652
+ direction: styles[8],
5653
+ };
5653
5654
  };
5654
5655
  exports.getStyleBasedFormatState = getStyleBasedFormatState;
5655
5656
 
@@ -5891,11 +5892,9 @@ var restoreUndoSnapshot = function (core, step) {
5891
5892
  core.api.setContent(core, snapshot.html, true /*triggerContentChangedEvent*/, (_a = snapshot.metadata) !== null && _a !== void 0 ? _a : undefined);
5892
5893
  var darkColorHandler_1 = core.darkColorHandler;
5893
5894
  var isDarkModel_1 = core.lifecycle.isDarkMode;
5894
- if (darkColorHandler_1) {
5895
- snapshot.knownColors.forEach(function (color) {
5896
- darkColorHandler_1.registerColor(color.lightModeColor, isDarkModel_1, color.darkModeColor);
5897
- });
5898
- }
5895
+ snapshot.knownColors.forEach(function (color) {
5896
+ darkColorHandler_1.registerColor(color.lightModeColor, isDarkModel_1, color.darkModeColor);
5897
+ });
5899
5898
  }
5900
5899
  finally {
5901
5900
  core.undo.isRestoring = false;
@@ -6509,14 +6508,10 @@ var ColorAttributeName = [
6509
6508
  (_a = {},
6510
6509
  _a[0 /* CssColor */] = 'color',
6511
6510
  _a[1 /* HtmlColor */] = 'color',
6512
- _a[2 /* CssDataSet */] = "ogsc" /* OriginalStyleColor */,
6513
- _a[3 /* HtmlDataSet */] = "ogac" /* OriginalAttributeColor */,
6514
6511
  _a),
6515
6512
  (_b = {},
6516
6513
  _b[0 /* CssColor */] = 'background-color',
6517
6514
  _b[1 /* HtmlColor */] = 'bgcolor',
6518
- _b[2 /* CssDataSet */] = "ogsb" /* OriginalStyleBackgroundColor */,
6519
- _b[3 /* HtmlDataSet */] = "ogab" /* OriginalAttributeBackgroundColor */,
6520
6515
  _b),
6521
6516
  ];
6522
6517
  /**
@@ -6536,20 +6531,7 @@ var transformColor = function (core, rootNode, includeSelf, callback, direction,
6536
6531
  ? getAll(rootNode, includeSelf)
6537
6532
  : [];
6538
6533
  callback === null || callback === void 0 ? void 0 : callback();
6539
- if (darkColorHandler) {
6540
- transformV2(elements, darkColorHandler, !!fromDarkMode, direction == 0 /* LightToDark */);
6541
- }
6542
- else {
6543
- if (direction == 1 /* DarkToLight */) {
6544
- transformToLightMode(elements);
6545
- }
6546
- else if (core.lifecycle.onExternalContentTransform) {
6547
- elements.forEach(function (element) { return core.lifecycle.onExternalContentTransform(element); });
6548
- }
6549
- else {
6550
- transformToDarkMode(elements, core.lifecycle.getDarkColor);
6551
- }
6552
- }
6534
+ transformV2(elements, darkColorHandler, !!fromDarkMode, direction == 0 /* LightToDark */);
6553
6535
  };
6554
6536
  exports.transformColor = transformColor;
6555
6537
  function transformV2(elements, darkColorHandler, fromDark, toDark) {
@@ -6565,66 +6547,6 @@ function transformV2(elements, darkColorHandler, fromDark, toDark) {
6565
6547
  });
6566
6548
  });
6567
6549
  }
6568
- function transformToLightMode(elements) {
6569
- elements.forEach(function (element) {
6570
- ColorAttributeName.forEach(function (names) {
6571
- // Reset color styles based on the content of the ogsc/ogsb data element.
6572
- // If those data properties are empty or do not exist, set them anyway to clear the content.
6573
- element.style.setProperty(names[0 /* CssColor */], getValueOrDefault(element.dataset[names[2 /* CssDataSet */]], ''));
6574
- delete element.dataset[names[2 /* CssDataSet */]];
6575
- // Some elements might have set attribute colors. We need to reset these as well.
6576
- var value = getValueOrDefault(element.dataset[names[3 /* HtmlDataSet */]], null);
6577
- if (value) {
6578
- element.setAttribute(names[1 /* HtmlColor */], value);
6579
- }
6580
- else {
6581
- element.removeAttribute(names[1 /* HtmlColor */]);
6582
- }
6583
- delete element.dataset[names[3 /* HtmlDataSet */]];
6584
- });
6585
- });
6586
- }
6587
- function transformToDarkMode(elements, getDarkColor) {
6588
- ColorAttributeName.forEach(function (names) {
6589
- elements
6590
- .map(function (element) {
6591
- var styleColor = element.style.getPropertyValue(names[0 /* CssColor */]);
6592
- var attrColor = element.getAttribute(names[1 /* HtmlColor */]);
6593
- var existingDataSetCssValue = element.dataset[names[2 /* CssDataSet */]];
6594
- var existingDataSetHtmlValue = element.dataset[names[3 /* HtmlDataSet */]];
6595
- var needProcess = (!existingDataSetCssValue || existingDataSetCssValue == styleColor) &&
6596
- (!existingDataSetHtmlValue || existingDataSetHtmlValue == attrColor) &&
6597
- (styleColor || attrColor) &&
6598
- styleColor != 'inherit'; // For inherit style, no need to change it and let it keep inherit from parent element
6599
- return needProcess
6600
- ? {
6601
- element: element,
6602
- styleColor: styleColor,
6603
- attrColor: attrColor,
6604
- newColor: styleColor || attrColor
6605
- ? getDarkColor((styleColor || attrColor))
6606
- : null,
6607
- }
6608
- : null;
6609
- })
6610
- .filter(function (x) { return !!x; })
6611
- .forEach(function (entry) {
6612
- if (!entry) {
6613
- return;
6614
- }
6615
- var element = entry.element, styleColor = entry.styleColor, attrColor = entry.attrColor, newColor = entry.newColor;
6616
- element.style.setProperty(names[0 /* CssColor */], newColor, 'important');
6617
- element.dataset[names[2 /* CssDataSet */]] = styleColor || '';
6618
- if (attrColor && newColor) {
6619
- element.setAttribute(names[1 /* HtmlColor */], newColor);
6620
- element.dataset[names[3 /* HtmlDataSet */]] = attrColor;
6621
- }
6622
- });
6623
- });
6624
- }
6625
- function getValueOrDefault(value, defaultValue) {
6626
- return value && value != 'undefined' && value != 'null' ? value : defaultValue;
6627
- }
6628
6550
  function getAll(rootNode, includeSelf) {
6629
6551
  var result = [];
6630
6552
  if ((0, roosterjs_editor_dom_1.safeInstanceOf)(rootNode, 'HTMLElement')) {
@@ -7698,7 +7620,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7698
7620
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
7699
7621
  var Escape = 'Escape';
7700
7622
  var Delete = 'Delete';
7701
- var mouseRightButton = 2;
7702
7623
  var mouseLeftButton = 0;
7703
7624
  /**
7704
7625
  * Detect image selection and help highlight the image
@@ -7741,14 +7662,9 @@ var ImageSelection = /** @class */ (function () {
7741
7662
  break;
7742
7663
  case 6 /* MouseUp */:
7743
7664
  var target = event.rawEvent.target;
7744
- if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
7745
- if (event.rawEvent.button === mouseRightButton) {
7746
- var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
7747
- this.editor.select(imageRange);
7748
- }
7749
- else if (event.rawEvent.button === mouseLeftButton) {
7750
- this.editor.select(target);
7751
- }
7665
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
7666
+ event.rawEvent.button === mouseLeftButton) {
7667
+ this.editor.select(target);
7752
7668
  }
7753
7669
  break;
7754
7670
  case 5 /* MouseDown */:
@@ -7778,6 +7694,14 @@ var ImageSelection = /** @class */ (function () {
7778
7694
  }
7779
7695
  }
7780
7696
  break;
7697
+ case 16 /* ContextMenu */:
7698
+ var contextMenuTarget = event.rawEvent.target;
7699
+ var actualSelection = this.editor.getSelectionRangeEx();
7700
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(contextMenuTarget, 'HTMLImageElement') &&
7701
+ (actualSelection.type !== 2 /* ImageSelection */ ||
7702
+ actualSelection.image !== contextMenuTarget)) {
7703
+ this.editor.select(contextMenuTarget);
7704
+ }
7781
7705
  }
7782
7706
  }
7783
7707
  };
@@ -8441,7 +8365,7 @@ var TypeInContainerPlugin = /** @class */ (function () {
8441
8365
  */
8442
8366
  TypeInContainerPlugin.prototype.onPluginEvent = function (event) {
8443
8367
  var _this = this;
8444
- var _a, _b, _c, _d, _e, _f;
8368
+ var _a;
8445
8369
  // We need to check if the ctrl key or the meta key is pressed,
8446
8370
  // browsers like Safari fire the "keypress" event when the meta key is pressed.
8447
8371
  if (event.eventType == 1 /* KeyPress */ &&
@@ -8479,24 +8403,6 @@ var TypeInContainerPlugin = /** @class */ (function () {
8479
8403
  }
8480
8404
  }
8481
8405
  }
8482
- /**
8483
- * Add a Span with default format to the previous element when pressing backspace
8484
- */
8485
- if (event.eventType == 0 /* KeyDown */ &&
8486
- event.rawEvent.which == 8 /* BACKSPACE */ &&
8487
- ((_b = this.editor) === null || _b === void 0 ? void 0 : _b.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */))) {
8488
- var element = (_c = this.editor) === null || _c === void 0 ? void 0 : _c.getElementAtCursor();
8489
- var block_1 = element &&
8490
- ((_e = (_d = this.editor) === null || _d === void 0 ? void 0 : _d.getBlockElementAtNode(element)) === null || _e === void 0 ? void 0 : _e.getStartNode().previousSibling);
8491
- if (block_1) {
8492
- (_f = this.editor) === null || _f === void 0 ? void 0 : _f.runAsync(function (editor) {
8493
- var position = editor.getFocusedPosition();
8494
- if (position && block_1 == position.element) {
8495
- editor.ensureTypeInContainer(position, event.rawEvent);
8496
- }
8497
- });
8498
- }
8499
- }
8500
8406
  };
8501
8407
  return TypeInContainerPlugin;
8502
8408
  }());
@@ -8606,6 +8512,9 @@ var UndoPlugin = /** @class */ (function () {
8606
8512
  case 7 /* ContentChanged */:
8607
8513
  this.onContentChanged(event);
8608
8514
  break;
8515
+ case 23 /* BeforeKeyboardEditing */:
8516
+ this.onBeforeKeyboardEditing(event.rawEvent);
8517
+ break;
8609
8518
  }
8610
8519
  };
8611
8520
  UndoPlugin.prototype.onKeyDown = function (evt) {
@@ -8620,7 +8529,7 @@ var UndoPlugin = /** @class */ (function () {
8620
8529
  this.state.autoCompletePosition = null;
8621
8530
  this.lastKeyPress = evt.which;
8622
8531
  }
8623
- else {
8532
+ else if (!evt.defaultPrevented) {
8624
8533
  var selectionRange = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getSelectionRange();
8625
8534
  // Add snapshot when
8626
8535
  // 1. Something has been selected (not collapsed), or
@@ -8644,6 +8553,11 @@ var UndoPlugin = /** @class */ (function () {
8644
8553
  }
8645
8554
  this.lastKeyPress = 0;
8646
8555
  }
8556
+ else if (this.lastKeyPress == 8 /* BACKSPACE */ || this.lastKeyPress == 46 /* DELETE */) {
8557
+ if (this.state.hasNewContent) {
8558
+ this.addUndoSnapshot();
8559
+ }
8560
+ }
8647
8561
  };
8648
8562
  UndoPlugin.prototype.onKeyPress = function (evt) {
8649
8563
  var _a;
@@ -8668,22 +8582,21 @@ var UndoPlugin = /** @class */ (function () {
8668
8582
  }
8669
8583
  this.lastKeyPress = evt.which;
8670
8584
  };
8671
- UndoPlugin.prototype.onContentChanged = function (event) {
8672
- if (event.source == "Keyboard" /* Keyboard */) {
8673
- if (Number.isInteger(event.data)) {
8674
- // For keyboard event (triggered from Content Model), we can get its keycode from event.data
8675
- // And when user is keep pressing the same key, mark editor with "hasNewContent" so that next time user
8676
- // do some other action or press a different key, we will add undo snapshot
8677
- if (event.data != this.lastKeyPress) {
8678
- this.addUndoSnapshot();
8679
- }
8680
- this.lastKeyPress = event.data;
8681
- this.state.hasNewContent = true;
8682
- }
8585
+ UndoPlugin.prototype.onBeforeKeyboardEditing = function (event) {
8586
+ // For keyboard event (triggered from Content Model), we can get its keycode from event.data
8587
+ // And when user is keep pressing the same key, mark editor with "hasNewContent" so that next time user
8588
+ // do some other action or press a different key, we will add undo snapshot
8589
+ if (event.which != this.lastKeyPress) {
8590
+ this.addUndoSnapshot();
8683
8591
  }
8684
- else if (!(this.state.isRestoring ||
8592
+ this.lastKeyPress = event.which;
8593
+ this.state.hasNewContent = true;
8594
+ };
8595
+ UndoPlugin.prototype.onContentChanged = function (event) {
8596
+ if (!(this.state.isRestoring ||
8685
8597
  event.source == "SwitchToDarkMode" /* SwitchToDarkMode */ ||
8686
- event.source == "SwitchToLightMode" /* SwitchToLightMode */)) {
8598
+ event.source == "SwitchToLightMode" /* SwitchToLightMode */ ||
8599
+ event.source == "Keyboard" /* Keyboard */)) {
8687
8600
  this.clearRedoForInput();
8688
8601
  }
8689
8602
  };
@@ -8882,7 +8795,14 @@ function inlineEntityOnPluginEvent(event, editor) {
8882
8795
  break;
8883
8796
  case 8 /* ExtractContentWithDom */:
8884
8797
  case 9 /* BeforeCutCopy */:
8885
- event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(removeNode);
8798
+ event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(function (node) {
8799
+ if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(node)) {
8800
+ removeNode(node);
8801
+ }
8802
+ else {
8803
+ removeDelimiterAttr(node);
8804
+ }
8805
+ });
8886
8806
  break;
8887
8807
  case 0 /* KeyDown */:
8888
8808
  handleKeyDownEvent(editor, event);
@@ -8979,10 +8899,9 @@ function removeDelimiterAttr(node, checkEntity) {
8979
8899
  });
8980
8900
  }
8981
8901
  function handleCollapsedEnter(editor, delimiter) {
8982
- var _a;
8983
8902
  var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
8984
8903
  var entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;
8985
- var block = (_a = editor.getBlockElementAtNode(delimiter)) === null || _a === void 0 ? void 0 : _a.getStartNode();
8904
+ var block = getBlock(editor, delimiter);
8986
8905
  editor.runAsync(function () {
8987
8906
  if (!block) {
8988
8907
  return;
@@ -9015,6 +8934,17 @@ var getPosition = function (container) {
9015
8934
  }
9016
8935
  return undefined;
9017
8936
  };
8937
+ function getBlock(editor, element) {
8938
+ var _a;
8939
+ if (!element) {
8940
+ return undefined;
8941
+ }
8942
+ var block = (_a = editor.getBlockElementAtNode(element)) === null || _a === void 0 ? void 0 : _a.getStartNode();
8943
+ while (block && !(0, roosterjs_editor_dom_1.isBlockElement)(block)) {
8944
+ block = editor.contains(block.parentElement) ? block.parentElement : undefined;
8945
+ }
8946
+ return block;
8947
+ }
9018
8948
  function handleSelectionNotCollapsed(editor, range, event) {
9019
8949
  var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
9020
8950
  var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
@@ -9319,6 +9249,31 @@ var __assign = (this && this.__assign) || function () {
9319
9249
  };
9320
9250
  return __assign.apply(this, arguments);
9321
9251
  };
9252
+ var __read = (this && this.__read) || function (o, n) {
9253
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
9254
+ if (!m) return o;
9255
+ var i = m.call(o), r, ar = [], e;
9256
+ try {
9257
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9258
+ }
9259
+ catch (error) { e = { error: error }; }
9260
+ finally {
9261
+ try {
9262
+ if (r && !r.done && (m = i["return"])) m.call(i);
9263
+ }
9264
+ finally { if (e) throw e.error; }
9265
+ }
9266
+ return ar;
9267
+ };
9268
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9269
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
9270
+ if (ar || !(i in from)) {
9271
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9272
+ ar[i] = from[i];
9273
+ }
9274
+ }
9275
+ return to.concat(ar || Array.prototype.slice.call(from));
9276
+ };
9322
9277
  Object.defineProperty(exports, "__esModule", { value: true });
9323
9278
  exports.EditorBase = void 0;
9324
9279
  var isFeatureEnabled_1 = __webpack_require__(/*! ./isFeatureEnabled */ "./packages/roosterjs-editor-core/lib/editor/isFeatureEnabled.ts");
@@ -9351,12 +9306,11 @@ var EditorBase = /** @class */ (function () {
9351
9306
  * Dispose this editor, dispose all plugins and custom data
9352
9307
  */
9353
9308
  EditorBase.prototype.dispose = function () {
9354
- var _a;
9355
9309
  var core = this.getCore();
9356
9310
  for (var i = core.plugins.length - 1; i >= 0; i--) {
9357
9311
  core.plugins[i].dispose();
9358
9312
  }
9359
- (_a = core.darkColorHandler) === null || _a === void 0 ? void 0 : _a.reset();
9313
+ core.darkColorHandler.reset();
9360
9314
  this.core = null;
9361
9315
  };
9362
9316
  /**
@@ -9434,7 +9388,7 @@ var EditorBase = /** @class */ (function () {
9434
9388
  var selectionEx = scope == 0 /* Body */ ? null : this.getSelectionRangeEx();
9435
9389
  if (selectionEx) {
9436
9390
  selectionEx.ranges.forEach(function (range) {
9437
- result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range));
9391
+ result.push.apply(result, __spreadArray([], __read((0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range)), false));
9438
9392
  });
9439
9393
  }
9440
9394
  else {
@@ -9666,7 +9620,7 @@ var EditorBase = /** @class */ (function () {
9666
9620
  var result = [];
9667
9621
  var contentDiv = this.getCore().contentDiv;
9668
9622
  selection.ranges.forEach(function (range) {
9669
- result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : []));
9623
+ result.push.apply(result, __spreadArray([], __read((range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : [])), false));
9670
9624
  });
9671
9625
  return result.filter(function (value, index, self) {
9672
9626
  return self.indexOf(value) === index;
@@ -9961,7 +9915,7 @@ var EditorBase = /** @class */ (function () {
9961
9915
  */
9962
9916
  EditorBase.prototype.ensureTypeInContainer = function (position, keyboardEvent) {
9963
9917
  var core = this.getCore();
9964
- core.api.ensureTypeInContainer(core, position, keyboardEvent, this.isFeatureEnabled("DefaultFormatInSpan" /* DefaultFormatInSpan */));
9918
+ core.api.ensureTypeInContainer(core, position, keyboardEvent);
9965
9919
  };
9966
9920
  //#endregion
9967
9921
  //#region Dark mode APIs
@@ -9996,10 +9950,10 @@ var EditorBase = /** @class */ (function () {
9996
9950
  core.api.transformColor(core, node, true /*includeSelf*/, null /*callback*/, 0 /* LightToDark */);
9997
9951
  };
9998
9952
  /**
9999
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
9953
+ * Get a darkColorHandler object for this editor.
10000
9954
  */
10001
9955
  EditorBase.prototype.getDarkColorHandler = function () {
10002
- return this.getCore().darkColorHandler || null;
9956
+ return this.getCore().darkColorHandler;
10003
9957
  };
10004
9958
  /**
10005
9959
  * Make the editor in "Shadow Edit" mode.
@@ -10125,7 +10079,6 @@ var createCorePlugins_1 = __webpack_require__(/*! ../corePlugins/createCorePlugi
10125
10079
  var DarkColorHandlerImpl_1 = __webpack_require__(/*! ./DarkColorHandlerImpl */ "./packages/roosterjs-editor-core/lib/editor/DarkColorHandlerImpl.ts");
10126
10080
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
10127
10081
  var coreApiMap_1 = __webpack_require__(/*! ../coreApi/coreApiMap */ "./packages/roosterjs-editor-core/lib/coreApi/coreApiMap.ts");
10128
- var isFeatureEnabled_1 = __webpack_require__(/*! ./isFeatureEnabled */ "./packages/roosterjs-editor-core/lib/editor/isFeatureEnabled.ts");
10129
10082
  /**
10130
10083
  * Create a new instance of Editor Core
10131
10084
  * @param contentDiv The DIV HTML element which will be the container element of editor
@@ -10154,9 +10107,7 @@ var createEditorCore = function (contentDiv, options) {
10154
10107
  ? [scrollContainer]
10155
10108
  : [scrollContainer, core.contentDiv]);
10156
10109
  });
10157
- 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 */)
10158
- ? new DarkColorHandlerImpl_1.default(contentDiv, pluginState.lifecycle.getDarkColor)
10159
- : undefined });
10110
+ 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) });
10160
10111
  return core;
10161
10112
  };
10162
10113
  exports.createEditorCore = createEditorCore;
@@ -11724,6 +11675,22 @@ exports.default = SelectionScoper;
11724
11675
 
11725
11676
  "use strict";
11726
11677
 
11678
+ var __read = (this && this.__read) || function (o, n) {
11679
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
11680
+ if (!m) return o;
11681
+ var i = m.call(o), r, ar = [], e;
11682
+ try {
11683
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11684
+ }
11685
+ catch (error) { e = { error: error }; }
11686
+ finally {
11687
+ try {
11688
+ if (r && !r.done && (m = i["return"])) m.call(i);
11689
+ }
11690
+ finally { if (e) throw e.error; }
11691
+ }
11692
+ return ar;
11693
+ };
11727
11694
  Object.defineProperty(exports, "__esModule", { value: true });
11728
11695
  exports.addDelimiterBefore = exports.addDelimiterAfter = void 0;
11729
11696
  var createElement_1 = __webpack_require__(/*! ../utils/createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
@@ -11734,7 +11701,7 @@ var ZERO_WIDTH_SPACE = '\u200B';
11734
11701
  * @param node the node to add the delimiters
11735
11702
  */
11736
11703
  function addDelimiters(node) {
11737
- var _a = getDelimiters(node), delimiterAfter = _a[0], delimiterBefore = _a[1];
11704
+ var _a = __read(getDelimiters(node), 2), delimiterAfter = _a[0], delimiterBefore = _a[1];
11738
11705
  if (!delimiterAfter) {
11739
11706
  delimiterAfter = addDelimiterAfter(node);
11740
11707
  }
@@ -12073,6 +12040,22 @@ function safeRemove(node) {
12073
12040
 
12074
12041
  "use strict";
12075
12042
 
12043
+ var __read = (this && this.__read) || function (o, n) {
12044
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
12045
+ if (!m) return o;
12046
+ var i = m.call(o), r, ar = [], e;
12047
+ try {
12048
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12049
+ }
12050
+ catch (error) { e = { error: error }; }
12051
+ finally {
12052
+ try {
12053
+ if (r && !r.done && (m = i["return"])) m.call(i);
12054
+ }
12055
+ finally { if (e) throw e.error; }
12056
+ }
12057
+ return ar;
12058
+ };
12076
12059
  Object.defineProperty(exports, "__esModule", { value: true });
12077
12060
  var arrayPush_1 = __webpack_require__(/*! ../jsUtils/arrayPush */ "./packages/roosterjs-editor-dom/lib/jsUtils/arrayPush.ts");
12078
12061
  var collapseNodesInRegion_1 = __webpack_require__(/*! ../region/collapseNodesInRegion */ "./packages/roosterjs-editor-dom/lib/region/collapseNodesInRegion.ts");
@@ -12112,8 +12095,8 @@ function deleteSelectedContent(root, range) {
12112
12095
  // Make sure there are node before and after the merging point.
12113
12096
  // This is required by mergeBlocksInRegion API.
12114
12097
  // This may create some empty text node as anchor
12115
- var _a = ensureBeforeAndAfter(endContainer, endOffset, false /*isStart*/), beforeEnd = _a[0], afterEnd = _a[1];
12116
- var _b = ensureBeforeAndAfter(startContainer, startOffset, true /*isStart*/), beforeStart = _b[0], afterStart = _b[1];
12098
+ var _a = __read(ensureBeforeAndAfter(endContainer, endOffset, false /*isStart*/), 2), beforeEnd = _a[0], afterEnd = _a[1];
12099
+ var _b = __read(ensureBeforeAndAfter(startContainer, startOffset, true /*isStart*/), 2), beforeStart = _b[0], afterStart = _b[1];
12117
12100
  nodeBefore = nodeBefore || beforeStart;
12118
12101
  // Find out all nodes to be deleted
12119
12102
  var nodes = (0, collapseNodesInRegion_1.default)(region, [afterStart, beforeEnd]);
@@ -12606,6 +12589,17 @@ exports.default = isModifierKey;
12606
12589
 
12607
12590
  "use strict";
12608
12591
 
12592
+ var __values = (this && this.__values) || function(o) {
12593
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
12594
+ if (m) return m.call(o);
12595
+ if (o && typeof o.length === "number") return {
12596
+ next: function () {
12597
+ if (o && i >= o.length) o = void 0;
12598
+ return { value: o && o[i++], done: !o };
12599
+ }
12600
+ };
12601
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12602
+ };
12609
12603
  Object.defineProperty(exports, "__esModule", { value: true });
12610
12604
  var changeElementTag_1 = __webpack_require__(/*! ../utils/changeElementTag */ "./packages/roosterjs-editor-dom/lib/utils/changeElementTag.ts");
12611
12605
  var getInheritableStyles_1 = __webpack_require__(/*! ./getInheritableStyles */ "./packages/roosterjs-editor-dom/lib/htmlSanitizer/getInheritableStyles.ts");
@@ -12709,40 +12703,60 @@ var HtmlSanitizer = /** @class */ (function () {
12709
12703
  * @param rootNode The HTML Document
12710
12704
  */
12711
12705
  HtmlSanitizer.prototype.convertGlobalCssToInlineCss = function (rootNode) {
12706
+ var e_1, _a;
12712
12707
  var styleNodes = (0, toArray_1.default)(rootNode.querySelectorAll('style'));
12713
12708
  var styleSheets = this.additionalGlobalStyleNodes
12714
12709
  .reverse()
12715
12710
  .map(function (node) { return node.sheet; })
12716
12711
  .concat(styleNodes.map(function (node) { return node.sheet; }).reverse())
12717
12712
  .filter(function (sheet) { return sheet; });
12718
- for (var _i = 0, styleSheets_1 = styleSheets; _i < styleSheets_1.length; _i++) {
12719
- var styleSheet = styleSheets_1[_i];
12720
- var _loop_1 = function (j) {
12721
- // Skip any none-style rule, i.e. @page
12722
- var styleRule = styleSheet.cssRules[j];
12723
- var text = styleRule && styleRule.style ? styleRule.style.cssText : null;
12724
- if (styleRule.type != CSSRule.STYLE_RULE || !text || !styleRule.selectorText) {
12725
- return "continue";
12726
- }
12727
- // Make sure the selector is not empty
12728
- for (var _a = 0, _b = styleRule.selectorText.split(','); _a < _b.length; _a++) {
12729
- var selector = _b[_a];
12730
- if (!selector || !selector.trim() || selector.indexOf(':') >= 0) {
12731
- continue;
12713
+ try {
12714
+ for (var styleSheets_1 = __values(styleSheets), styleSheets_1_1 = styleSheets_1.next(); !styleSheets_1_1.done; styleSheets_1_1 = styleSheets_1.next()) {
12715
+ var styleSheet = styleSheets_1_1.value;
12716
+ var _loop_1 = function (j) {
12717
+ var e_2, _b;
12718
+ // Skip any none-style rule, i.e. @page
12719
+ var styleRule = styleSheet.cssRules[j];
12720
+ var text = styleRule && styleRule.style ? styleRule.style.cssText : null;
12721
+ if (styleRule.type != CSSRule.STYLE_RULE || !text || !styleRule.selectorText) {
12722
+ return "continue";
12732
12723
  }
12733
- var nodes = (0, toArray_1.default)(rootNode.querySelectorAll(selector));
12734
- // Always put existing styles after so that they have higher priority
12735
- // Which means if both global style and inline style apply to the same element,
12736
- // inline style will have higher priority
12737
- nodes.forEach(function (node) {
12738
- return node.setAttribute('style', text + (node.getAttribute('style') || ''));
12739
- });
12724
+ try {
12725
+ // Make sure the selector is not empty
12726
+ for (var _c = (e_2 = void 0, __values(styleRule.selectorText.split(','))), _d = _c.next(); !_d.done; _d = _c.next()) {
12727
+ var selector = _d.value;
12728
+ if (!selector || !selector.trim() || selector.indexOf(':') >= 0) {
12729
+ continue;
12730
+ }
12731
+ var nodes = (0, toArray_1.default)(rootNode.querySelectorAll(selector));
12732
+ // Always put existing styles after so that they have higher priority
12733
+ // Which means if both global style and inline style apply to the same element,
12734
+ // inline style will have higher priority
12735
+ nodes.forEach(function (node) {
12736
+ return node.setAttribute('style', text + (node.getAttribute('style') || ''));
12737
+ });
12738
+ }
12739
+ }
12740
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
12741
+ finally {
12742
+ try {
12743
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
12744
+ }
12745
+ finally { if (e_2) throw e_2.error; }
12746
+ }
12747
+ };
12748
+ for (var j = styleSheet.cssRules.length - 1; j >= 0; j--) {
12749
+ _loop_1(j);
12740
12750
  }
12741
- };
12742
- for (var j = styleSheet.cssRules.length - 1; j >= 0; j--) {
12743
- _loop_1(j);
12744
12751
  }
12745
12752
  }
12753
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
12754
+ finally {
12755
+ try {
12756
+ if (styleSheets_1_1 && !styleSheets_1_1.done && (_a = styleSheets_1.return)) _a.call(styleSheets_1);
12757
+ }
12758
+ finally { if (e_1) throw e_1.error; }
12759
+ }
12746
12760
  styleNodes.forEach(function (node) {
12747
12761
  if (node.parentNode) {
12748
12762
  node.parentNode.removeChild(node);
@@ -12917,6 +12931,31 @@ exports.default = HtmlSanitizer;
12917
12931
 
12918
12932
  "use strict";
12919
12933
 
12934
+ var __read = (this && this.__read) || function (o, n) {
12935
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
12936
+ if (!m) return o;
12937
+ var i = m.call(o), r, ar = [], e;
12938
+ try {
12939
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12940
+ }
12941
+ catch (error) { e = { error: error }; }
12942
+ finally {
12943
+ try {
12944
+ if (r && !r.done && (m = i["return"])) m.call(i);
12945
+ }
12946
+ finally { if (e) throw e.error; }
12947
+ }
12948
+ return ar;
12949
+ };
12950
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
12951
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
12952
+ if (ar || !(i in from)) {
12953
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12954
+ ar[i] = from[i];
12955
+ }
12956
+ }
12957
+ return to.concat(ar || Array.prototype.slice.call(from));
12958
+ };
12920
12959
  Object.defineProperty(exports, "__esModule", { value: true });
12921
12960
  /**
12922
12961
  * Chain all callback for an attribute together
@@ -12937,8 +12976,8 @@ function chainSanitizerCallback(map, name, newCallback) {
12937
12976
  for (var _i = 0; _i < arguments.length; _i++) {
12938
12977
  args[_i] = arguments[_i];
12939
12978
  }
12940
- originalCallback_1.apply(void 0, args);
12941
- return newCallback.apply(void 0, args);
12979
+ originalCallback_1.apply(void 0, __spreadArray([], __read(args), false));
12980
+ return newCallback.apply(void 0, __spreadArray([], __read(args), false));
12942
12981
  };
12943
12982
  }
12944
12983
  }
@@ -12956,6 +12995,17 @@ exports.default = chainSanitizerCallback;
12956
12995
 
12957
12996
  "use strict";
12958
12997
 
12998
+ var __values = (this && this.__values) || function(o) {
12999
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
13000
+ if (m) return m.call(o);
13001
+ if (o && typeof o.length === "number") return {
13002
+ next: function () {
13003
+ if (o && i >= o.length) o = void 0;
13004
+ return { value: o && o[i++], done: !o };
13005
+ }
13006
+ };
13007
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
13008
+ };
12959
13009
  Object.defineProperty(exports, "__esModule", { value: true });
12960
13010
  exports.cloneObject = void 0;
12961
13011
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
@@ -12963,11 +13013,21 @@ function nativeClone(source, existingObj) {
12963
13013
  return Object.assign(existingObj || {}, source);
12964
13014
  }
12965
13015
  function customClone(source, existingObj) {
13016
+ var e_1, _a;
12966
13017
  var result = existingObj || {};
12967
13018
  if (source) {
12968
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(source); _i < _a.length; _i++) {
12969
- var key = _a[_i];
12970
- result[key] = source[key];
13019
+ try {
13020
+ for (var _b = __values((0, getObjectKeys_1.default)(source)), _c = _b.next(); !_c.done; _c = _b.next()) {
13021
+ var key = _c.value;
13022
+ result[key] = source[key];
13023
+ }
13024
+ }
13025
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
13026
+ finally {
13027
+ try {
13028
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
13029
+ }
13030
+ finally { if (e_1) throw e_1.error; }
12971
13031
  }
12972
13032
  }
12973
13033
  return result;
@@ -14377,6 +14437,22 @@ exports.default = toArray;
14377
14437
 
14378
14438
  "use strict";
14379
14439
 
14440
+ var __read = (this && this.__read) || function (o, n) {
14441
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14442
+ if (!m) return o;
14443
+ var i = m.call(o), r, ar = [], e;
14444
+ try {
14445
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
14446
+ }
14447
+ catch (error) { e = { error: error }; }
14448
+ finally {
14449
+ try {
14450
+ if (r && !r.done && (m = i["return"])) m.call(i);
14451
+ }
14452
+ finally { if (e) throw e.error; }
14453
+ }
14454
+ return ar;
14455
+ };
14380
14456
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14381
14457
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14382
14458
  if (ar || !(i in from)) {
@@ -14563,6 +14639,7 @@ var VList = /** @class */ (function () {
14563
14639
  }
14564
14640
  item.writeBack(listStack, _this.rootList, shouldReuseAllAncestorListElements);
14565
14641
  var topList = listStack[1];
14642
+ item.applyListStyle(_this.rootList, start);
14566
14643
  if ((0, safeInstanceOf_1.default)(topList, 'HTMLOListElement')) {
14567
14644
  if (lastList != topList) {
14568
14645
  if (start == 1) {
@@ -14572,12 +14649,10 @@ var VList = /** @class */ (function () {
14572
14649
  topList.start = start;
14573
14650
  }
14574
14651
  }
14575
- if (item.getLevel() == 1) {
14652
+ if (item.getLevel() == 1 && !item.isDummy()) {
14576
14653
  start++;
14577
14654
  }
14578
14655
  }
14579
- var itemIndex = _this.getListItemIndex(item.getNode());
14580
- item.applyListStyle(_this.rootList, itemIndex);
14581
14656
  lastList = topList;
14582
14657
  });
14583
14658
  // Restore the content to the position of placeholder
@@ -14772,12 +14847,12 @@ var VList = /** @class */ (function () {
14772
14847
  var type = (0, getListTypeFromNode_1.default)(list);
14773
14848
  var items = (0, toArray_1.default)(list.childNodes);
14774
14849
  items.forEach(function (item) {
14775
- var newListTypes = __spreadArray(__spreadArray([], listTypes, true), [type], false);
14850
+ var newListTypes = __spreadArray(__spreadArray([], __read(listTypes), false), [type], false);
14776
14851
  if ((0, getListTypeFromNode_1.isListElement)(item)) {
14777
14852
  _this.populateItems(item, newListTypes);
14778
14853
  }
14779
14854
  else if (item.nodeType != 3 /* Text */ || (item.nodeValue || '').trim() != '') {
14780
- _this.items.push(new (VListItem_1.default.bind.apply(VListItem_1.default, __spreadArray([void 0, item], newListTypes, false)))());
14855
+ _this.items.push(new (VListItem_1.default.bind.apply(VListItem_1.default, __spreadArray([void 0, item], __read(newListTypes), false)))());
14781
14856
  }
14782
14857
  });
14783
14858
  };
@@ -14946,7 +15021,13 @@ var VListChain = /** @class */ (function () {
14946
15021
  var lastNumber = 0;
14947
15022
  for (var i = 0; i < lists.length; i++) {
14948
15023
  var list = lists[i];
14949
- list.start = list.start > 1 ? list.start : lastNumber + 1;
15024
+ //If there is a list chain sequence, ensure the list chain keep increasing correctly
15025
+ if (list.start > 1) {
15026
+ list.start = list.start === lastNumber ? lastNumber + 1 : list.start;
15027
+ }
15028
+ else {
15029
+ list.start = lastNumber + 1;
15030
+ }
14950
15031
  var vlist = new VList_1.default(list);
14951
15032
  lastNumber = vlist.getLastItemNumber() || 0;
14952
15033
  delete list.dataset[CHAIN_DATASET_NAME];
@@ -15013,6 +15094,22 @@ var __assign = (this && this.__assign) || function () {
15013
15094
  };
15014
15095
  return __assign.apply(this, arguments);
15015
15096
  };
15097
+ var __read = (this && this.__read) || function (o, n) {
15098
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15099
+ if (!m) return o;
15100
+ var i = m.call(o), r, ar = [], e;
15101
+ try {
15102
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
15103
+ }
15104
+ catch (error) { e = { error: error }; }
15105
+ finally {
15106
+ try {
15107
+ if (r && !r.done && (m = i["return"])) m.call(i);
15108
+ }
15109
+ finally { if (e) throw e.error; }
15110
+ }
15111
+ return ar;
15112
+ };
15016
15113
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
15017
15114
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15018
15115
  if (ar || !(i in from)) {
@@ -15085,7 +15182,7 @@ var VListItem = /** @class */ (function () {
15085
15182
  var display = this.node.style.display;
15086
15183
  this.dummy = display != 'list-item' && display != '';
15087
15184
  // Always add a None list type in front of all other types to represent non-list scenario.
15088
- this.listTypes = __spreadArray([0 /* None */], listTypes, true);
15185
+ this.listTypes = __spreadArray([0 /* None */], __read(listTypes), false);
15089
15186
  }
15090
15187
  /**
15091
15188
  * Get type of current list item
@@ -15497,6 +15594,17 @@ exports.default = convertDecimalsToAlpha;
15497
15594
 
15498
15595
  "use strict";
15499
15596
 
15597
+ var __values = (this && this.__values) || function(o) {
15598
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15599
+ if (m) return m.call(o);
15600
+ if (o && typeof o.length === "number") return {
15601
+ next: function () {
15602
+ if (o && i >= o.length) o = void 0;
15603
+ return { value: o && o[i++], done: !o };
15604
+ }
15605
+ };
15606
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
15607
+ };
15500
15608
  Object.defineProperty(exports, "__esModule", { value: true });
15501
15609
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
15502
15610
  var RomanValues = {
@@ -15522,12 +15630,22 @@ var RomanValues = {
15522
15630
  * @returns
15523
15631
  */
15524
15632
  function convertDecimalsToRoman(decimal, isLowerCase) {
15633
+ var e_1, _a;
15525
15634
  var romanValue = '';
15526
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(RomanValues); _i < _a.length; _i++) {
15527
- var i = _a[_i];
15528
- var timesRomanCharAppear = Math.floor(decimal / RomanValues[i]);
15529
- decimal = decimal - timesRomanCharAppear * RomanValues[i];
15530
- romanValue = romanValue + i.repeat(timesRomanCharAppear);
15635
+ try {
15636
+ for (var _b = __values((0, getObjectKeys_1.default)(RomanValues)), _c = _b.next(); !_c.done; _c = _b.next()) {
15637
+ var i = _c.value;
15638
+ var timesRomanCharAppear = Math.floor(decimal / RomanValues[i]);
15639
+ decimal = decimal - timesRomanCharAppear * RomanValues[i];
15640
+ romanValue = romanValue + i.repeat(timesRomanCharAppear);
15641
+ }
15642
+ }
15643
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
15644
+ finally {
15645
+ try {
15646
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
15647
+ }
15648
+ finally { if (e_1) throw e_1.error; }
15531
15649
  }
15532
15650
  return isLowerCase ? romanValue.toLocaleLowerCase() : romanValue;
15533
15651
  }
@@ -15598,7 +15716,7 @@ function createVListFromRegion(region, includeSiblingLists, startNode) {
15598
15716
  }
15599
15717
  });
15600
15718
  if (nodes.length == 0 && !region.rootNode.firstChild) {
15601
- var newNode = (0, createElement_1.default)(12 /* EmptyLineFormatInSpan */, region.rootNode.ownerDocument);
15719
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, region.rootNode.ownerDocument);
15602
15720
  region.rootNode.appendChild(newNode);
15603
15721
  nodes.push(newNode);
15604
15722
  region.fullSelectionStart = new Position_1.default(newNode, 0 /* Begin */);
@@ -16587,6 +16705,22 @@ exports.default = collapseNodesInRegion;
16587
16705
 
16588
16706
  "use strict";
16589
16707
 
16708
+ var __read = (this && this.__read) || function (o, n) {
16709
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
16710
+ if (!m) return o;
16711
+ var i = m.call(o), r, ar = [], e;
16712
+ try {
16713
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
16714
+ }
16715
+ catch (error) { e = { error: error }; }
16716
+ finally {
16717
+ try {
16718
+ if (r && !r.done && (m = i["return"])) m.call(i);
16719
+ }
16720
+ finally { if (e) throw e.error; }
16721
+ }
16722
+ return ar;
16723
+ };
16590
16724
  var _a;
16591
16725
  Object.defineProperty(exports, "__esModule", { value: true });
16592
16726
  exports.getRegionCreator = void 0;
@@ -16610,14 +16744,15 @@ var regionTypeData = (_a = {},
16610
16744
  * @param type Type of region. Currently we only support TABLE region.
16611
16745
  */
16612
16746
  function getRegionsFromRange(root, range, type) {
16747
+ var _a;
16613
16748
  var regions = [];
16614
16749
  if (root && range) {
16615
- var _a = regionTypeData[type], innerSelector = _a.innerSelector, skipTags = _a.skipTags;
16750
+ var _b = regionTypeData[type], innerSelector = _b.innerSelector, skipTags = _b.skipTags;
16616
16751
  var boundaryTree = buildBoundaryTree(root, range, type);
16617
16752
  var start = (0, findClosestElementAncestor_1.default)(range.startContainer, root, innerSelector) || root;
16618
16753
  var end = (0, findClosestElementAncestor_1.default)(range.endContainer, root, innerSelector) || root;
16619
16754
  var creator = getRegionCreator(range, skipTags);
16620
- regions = iterateNodes(creator, boundaryTree, start, end)[0];
16755
+ _a = __read(iterateNodes(creator, boundaryTree, start, end), 1), regions = _a[0];
16621
16756
  }
16622
16757
  return regions.filter(function (r) { return !!r; });
16623
16758
  }
@@ -16711,7 +16846,7 @@ function iterateNodes(creator, boundary, start, end, started) {
16711
16846
  boundaries === null || boundaries === void 0 ? void 0 : boundaries.forEach(function (child) {
16712
16847
  var _a;
16713
16848
  var newRegions;
16714
- _a = iterateNodes(creator, child, start, end, started), newRegions = _a[0], started = _a[1], ended = _a[2];
16849
+ _a = __read(iterateNodes(creator, child, start, end, started), 3), newRegions = _a[0], started = _a[1], ended = _a[2];
16715
16850
  regions = regions.concat(newRegions);
16716
16851
  });
16717
16852
  }
@@ -16772,8 +16907,9 @@ var shouldSkipNode_1 = __webpack_require__(/*! ../utils/shouldSkipNode */ "./pac
16772
16907
  * @param regionBase The region to get block elements from
16773
16908
  * @param createBlockIfEmpty When set to true, a new empty block element will be created if there is not
16774
16909
  * any blocks in the region. Default value is false
16910
+ * @param deprecated Deprecated parameter, not used
16775
16911
  */
16776
- function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, shouldApplyFormatToSpan) {
16912
+ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, deprecated) {
16777
16913
  var range = (0, getSelectionRangeInRegion_1.default)(regionBase);
16778
16914
  var blocks = [];
16779
16915
  if (range) {
@@ -16797,9 +16933,7 @@ function getSelectedBlockElementsInRegion(regionBase, createBlockIfEmpty, should
16797
16933
  });
16798
16934
  }
16799
16935
  if (blocks.length == 0 && regionBase && !regionBase.rootNode.firstChild && createBlockIfEmpty) {
16800
- var newNode = (0, createElement_1.default)(shouldApplyFormatToSpan
16801
- ? 12 /* EmptyLineFormatInSpan */
16802
- : 1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16936
+ var newNode = (0, createElement_1.default)(1 /* EmptyLine */, regionBase.rootNode.ownerDocument);
16803
16937
  regionBase.rootNode.appendChild(newNode);
16804
16938
  var block = (0, getBlockElementAtNode_1.default)(regionBase.rootNode, newNode);
16805
16939
  if (block) {
@@ -19352,6 +19486,22 @@ exports.default = applyFormat;
19352
19486
 
19353
19487
  "use strict";
19354
19488
 
19489
+ var __read = (this && this.__read) || function (o, n) {
19490
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19491
+ if (!m) return o;
19492
+ var i = m.call(o), r, ar = [], e;
19493
+ try {
19494
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19495
+ }
19496
+ catch (error) { e = { error: error }; }
19497
+ finally {
19498
+ try {
19499
+ if (r && !r.done && (m = i["return"])) m.call(i);
19500
+ }
19501
+ finally { if (e) throw e.error; }
19502
+ }
19503
+ return ar;
19504
+ };
19355
19505
  Object.defineProperty(exports, "__esModule", { value: true });
19356
19506
  var getComputedStyles_1 = __webpack_require__(/*! ./getComputedStyles */ "./packages/roosterjs-editor-dom/lib/utils/getComputedStyles.ts");
19357
19507
  var getTagOfNode_1 = __webpack_require__(/*! ./getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
@@ -19373,10 +19523,10 @@ function changeElementTag(element, newTag) {
19373
19523
  }
19374
19524
  (0, moveChildNodes_1.default)(newElement, element);
19375
19525
  if (origianlTag == 'P' || (0, getTagOfNode_1.default)(newElement) == 'P') {
19376
- _a = (0, getComputedStyles_1.default)(element, [
19526
+ _a = __read((0, getComputedStyles_1.default)(element, [
19377
19527
  'margin-top',
19378
19528
  'margin-bottom',
19379
- ]), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19529
+ ]), 2), newElement.style.marginTop = _a[0], newElement.style.marginBottom = _a[1];
19380
19530
  }
19381
19531
  if (element.parentNode) {
19382
19532
  element.parentNode.replaceChild(newElement, element);
@@ -19725,6 +19875,17 @@ exports.default = fromHtml;
19725
19875
 
19726
19876
  "use strict";
19727
19877
 
19878
+ var __values = (this && this.__values) || function(o) {
19879
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19880
+ if (m) return m.call(o);
19881
+ if (o && typeof o.length === "number") return {
19882
+ next: function () {
19883
+ if (o && i >= o.length) o = void 0;
19884
+ return { value: o && o[i++], done: !o };
19885
+ }
19886
+ };
19887
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
19888
+ };
19728
19889
  Object.defineProperty(exports, "__esModule", { value: true });
19729
19890
  exports.getComputedStyle = void 0;
19730
19891
  var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
@@ -19736,6 +19897,7 @@ var findClosestElementAncestor_1 = __webpack_require__(/*! ./findClosestElementA
19736
19897
  * @returns An array of the computed styles
19737
19898
  */
19738
19899
  function getComputedStyles(node, styleNames) {
19900
+ var e_1, _a;
19739
19901
  if (styleNames === void 0) { styleNames = ['font-family', 'font-size', 'color', 'background-color']; }
19740
19902
  var element = (0, findClosestElementAncestor_1.default)(node);
19741
19903
  var result = [];
@@ -19744,12 +19906,21 @@ function getComputedStyles(node, styleNames) {
19744
19906
  var win = element.ownerDocument.defaultView || window;
19745
19907
  var styles = win.getComputedStyle(element);
19746
19908
  if (styles) {
19747
- for (var _i = 0, styleNames_1 = styleNames; _i < styleNames_1.length; _i++) {
19748
- var style = styleNames_1[_i];
19749
- var value = styles.getPropertyValue(style) || '';
19750
- value = style != 'font-family' ? value.toLowerCase() : value;
19751
- value = style == 'font-size' ? px2Pt(value) : value;
19752
- result.push(value);
19909
+ try {
19910
+ for (var styleNames_1 = __values(styleNames), styleNames_1_1 = styleNames_1.next(); !styleNames_1_1.done; styleNames_1_1 = styleNames_1.next()) {
19911
+ var style = styleNames_1_1.value;
19912
+ var value = styles.getPropertyValue(style) || '';
19913
+ value = style != 'font-family' ? value.toLowerCase() : value;
19914
+ value = style == 'font-size' ? px2Pt(value) : value;
19915
+ result.push(value);
19916
+ }
19917
+ }
19918
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
19919
+ finally {
19920
+ try {
19921
+ if (styleNames_1_1 && !styleNames_1_1.done && (_a = styleNames_1.return)) _a.call(styleNames_1);
19922
+ }
19923
+ finally { if (e_1) throw e_1.error; }
19753
19924
  }
19754
19925
  }
19755
19926
  }
@@ -19820,6 +19991,31 @@ exports.default = getInnerHTML;
19820
19991
 
19821
19992
  "use strict";
19822
19993
 
19994
+ var __read = (this && this.__read) || function (o, n) {
19995
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19996
+ if (!m) return o;
19997
+ var i = m.call(o), r, ar = [], e;
19998
+ try {
19999
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20000
+ }
20001
+ catch (error) { e = { error: error }; }
20002
+ finally {
20003
+ try {
20004
+ if (r && !r.done && (m = i["return"])) m.call(i);
20005
+ }
20006
+ finally { if (e) throw e.error; }
20007
+ }
20008
+ return ar;
20009
+ };
20010
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20011
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20012
+ if (ar || !(i in from)) {
20013
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20014
+ ar[i] = from[i];
20015
+ }
20016
+ }
20017
+ return to.concat(ar || Array.prototype.slice.call(from));
20018
+ };
19823
20019
  Object.defineProperty(exports, "__esModule", { value: true });
19824
20020
  var normalizeRect_1 = __webpack_require__(/*! ./normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
19825
20021
  /**
@@ -19854,10 +20050,10 @@ function getIntersectedRect(elements, additionalRects) {
19854
20050
  .concat(additionalRects)
19855
20051
  .filter(function (element) { return !!element; });
19856
20052
  var result = {
19857
- top: Math.max.apply(Math, rects.map(function (r) { return r.top; })),
19858
- bottom: Math.min.apply(Math, rects.map(function (r) { return r.bottom; })),
19859
- left: Math.max.apply(Math, rects.map(function (r) { return r.left; })),
19860
- right: Math.min.apply(Math, rects.map(function (r) { return r.right; })),
20053
+ top: Math.max.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.top; })), false)),
20054
+ bottom: Math.min.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.bottom; })), false)),
20055
+ left: Math.max.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.left; })), false)),
20056
+ right: Math.min.apply(Math, __spreadArray([], __read(rects.map(function (r) { return r.right; })), false)),
19861
20057
  };
19862
20058
  return result.top < result.bottom && result.left < result.right ? result : null;
19863
20059
  }
@@ -20225,6 +20421,17 @@ exports.default = isVoidHtmlElement;
20225
20421
 
20226
20422
  "use strict";
20227
20423
 
20424
+ var __values = (this && this.__values) || function(o) {
20425
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
20426
+ if (m) return m.call(o);
20427
+ if (o && typeof o.length === "number") return {
20428
+ next: function () {
20429
+ if (o && i >= o.length) o = void 0;
20430
+ return { value: o && o[i++], done: !o };
20431
+ }
20432
+ };
20433
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
20434
+ };
20228
20435
  Object.defineProperty(exports, "__esModule", { value: true });
20229
20436
  var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
20230
20437
  // http exclude matching regex
@@ -20288,19 +20495,29 @@ var linkMatchRules = {
20288
20495
  * The link data includes an original url and a normalized url
20289
20496
  */
20290
20497
  function matchLink(url) {
20498
+ var e_1, _a;
20291
20499
  if (url) {
20292
- for (var _i = 0, _a = (0, getObjectKeys_1.default)(linkMatchRules); _i < _a.length; _i++) {
20293
- var schema = _a[_i];
20294
- var rule = linkMatchRules[schema];
20295
- var matches = url.match(rule.match);
20296
- if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
20297
- return {
20298
- scheme: schema,
20299
- originalUrl: url,
20300
- normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
20301
- };
20500
+ try {
20501
+ for (var _b = __values((0, getObjectKeys_1.default)(linkMatchRules)), _c = _b.next(); !_c.done; _c = _b.next()) {
20502
+ var schema = _c.value;
20503
+ var rule = linkMatchRules[schema];
20504
+ var matches = url.match(rule.match);
20505
+ if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
20506
+ return {
20507
+ scheme: schema,
20508
+ originalUrl: url,
20509
+ normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
20510
+ };
20511
+ }
20302
20512
  }
20303
20513
  }
20514
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20515
+ finally {
20516
+ try {
20517
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
20518
+ }
20519
+ finally { if (e_1) throw e_1.error; }
20520
+ }
20304
20521
  }
20305
20522
  return null;
20306
20523
  }
@@ -20617,7 +20834,6 @@ var TRANSPARENT = 'transparent';
20617
20834
  var DARK_COLORS_LIGHTNESS = 20;
20618
20835
  //If the value of the lightness is more than 80, the color is bright
20619
20836
  var BRIGHT_COLORS_LIGHTNESS = 80;
20620
- var TRANSPARENT_COLOR = 'transparent';
20621
20837
  /**
20622
20838
  * Set text color or background color to the given element
20623
20839
  * @param element The element to set color to
@@ -20625,7 +20841,8 @@ var TRANSPARENT_COLOR = 'transparent';
20625
20841
  * @param isBackgroundColor Whether set background color or text color
20626
20842
  * @param isDarkMode Whether current mode is dark mode. @default false
20627
20843
  * @param shouldAdaptTheFontColor Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
20628
- * @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
20844
+ * @param darkColorHandler A dark color handler object. This is now required.
20845
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
20629
20846
  */
20630
20847
  function setColor(element, color, isBackgroundColor, isDarkMode, shouldAdaptTheFontColor, darkColorHandler) {
20631
20848
  var colorString = typeof color === 'string' ? color.trim() : '';
@@ -20636,22 +20853,6 @@ function setColor(element, color, isBackgroundColor, isDarkMode, shouldAdaptTheF
20636
20853
  var colorValue = darkColorHandler.registerColor((modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString, !!isDarkMode, modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.darkModeColor);
20637
20854
  element.style.setProperty(cssName, colorValue);
20638
20855
  }
20639
- else {
20640
- element.style.setProperty(cssName, (isDarkMode
20641
- ? modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.darkModeColor
20642
- : modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString);
20643
- if (element.dataset) {
20644
- var dataSetName = isBackgroundColor
20645
- ? "ogsb" /* OriginalStyleBackgroundColor */
20646
- : "ogsc" /* OriginalStyleColor */;
20647
- if (!isDarkMode || color == TRANSPARENT_COLOR) {
20648
- delete element.dataset[dataSetName];
20649
- }
20650
- else if (modeIndependentColor) {
20651
- element.dataset[dataSetName] = modeIndependentColor.lightModeColor;
20652
- }
20653
- }
20654
- }
20655
20856
  if (isBackgroundColor && shouldAdaptTheFontColor) {
20656
20857
  adaptFontColorToBackgroundColor(element, (modeIndependentColor === null || modeIndependentColor === void 0 ? void 0 : modeIndependentColor.lightModeColor) || colorString, isDarkMode, darkColorHandler);
20657
20858
  }
@@ -20663,7 +20864,8 @@ exports.default = setColor;
20663
20864
  * @param element The element that contains text.
20664
20865
  * @param lightModeBackgroundColor Existing background color in light mode
20665
20866
  * @param isDarkMode Whether the content is in dark mode
20666
- * @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
20867
+ * @param darkColorHandler A dark color handler object. This is now required.
20868
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
20667
20869
  */
20668
20870
  function adaptFontColorToBackgroundColor(element, lightModeBackgroundColor, isDarkMode, darkColorHandler) {
20669
20871
  if (!lightModeBackgroundColor || lightModeBackgroundColor === TRANSPARENT) {
@@ -20939,11 +21141,23 @@ exports.default = unwrap;
20939
21141
 
20940
21142
  "use strict";
20941
21143
 
21144
+ var __values = (this && this.__values) || function(o) {
21145
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21146
+ if (m) return m.call(o);
21147
+ if (o && typeof o.length === "number") return {
21148
+ next: function () {
21149
+ if (o && i >= o.length) o = void 0;
21150
+ return { value: o && o[i++], done: !o };
21151
+ }
21152
+ };
21153
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
21154
+ };
20942
21155
  Object.defineProperty(exports, "__esModule", { value: true });
20943
21156
  var createElement_1 = __webpack_require__(/*! ./createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
20944
21157
  var fromHtml_1 = __webpack_require__(/*! ./fromHtml */ "./packages/roosterjs-editor-dom/lib/utils/fromHtml.ts");
20945
21158
  var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
20946
21159
  function wrap(nodes, wrapper) {
21160
+ var e_1, _a;
20947
21161
  nodes = !nodes ? [] : (0, safeInstanceOf_1.default)(nodes, 'Node') ? [nodes] : nodes;
20948
21162
  if (nodes.length == 0 || !nodes[0] || !nodes[0].ownerDocument) {
20949
21163
  return null;
@@ -20966,9 +21180,18 @@ function wrap(nodes, wrapper) {
20966
21180
  if (parentNode) {
20967
21181
  parentNode.insertBefore(wrapper, nodes[0]);
20968
21182
  }
20969
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
20970
- var node = nodes_1[_i];
20971
- wrapper.appendChild(node);
21183
+ try {
21184
+ for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
21185
+ var node = nodes_1_1.value;
21186
+ wrapper.appendChild(node);
21187
+ }
21188
+ }
21189
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
21190
+ finally {
21191
+ try {
21192
+ if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
21193
+ }
21194
+ finally { if (e_1) throw e_1.error; }
20972
21195
  }
20973
21196
  return wrapper;
20974
21197
  }
@@ -21348,6 +21571,22 @@ __exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-edito
21348
21571
 
21349
21572
  "use strict";
21350
21573
 
21574
+ var __read = (this && this.__read) || function (o, n) {
21575
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
21576
+ if (!m) return o;
21577
+ var i = m.call(o), r, ar = [], e;
21578
+ try {
21579
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21580
+ }
21581
+ catch (error) { e = { error: error }; }
21582
+ finally {
21583
+ try {
21584
+ if (r && !r.done && (m = i["return"])) m.call(i);
21585
+ }
21586
+ finally { if (e) throw e.error; }
21587
+ }
21588
+ return ar;
21589
+ };
21351
21590
  Object.defineProperty(exports, "__esModule", { value: true });
21352
21591
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
21353
21592
  /**
@@ -21414,13 +21653,13 @@ var DragAndDropHelper = /** @class */ (function () {
21414
21653
  e.preventDefault();
21415
21654
  e.stopPropagation();
21416
21655
  _this.addDocumentEvents();
21417
- _a = _this.dndMouse.getPageXY(e), _this.initX = _a[0], _this.initY = _a[1];
21656
+ _a = __read(_this.dndMouse.getPageXY(e), 2), _this.initX = _a[0], _this.initY = _a[1];
21418
21657
  _this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, e);
21419
21658
  };
21420
21659
  this.onMouseMove = function (e) {
21421
21660
  var _a, _b, _c;
21422
21661
  e.preventDefault();
21423
- var _d = _this.dndMouse.getPageXY(e), pageX = _d[0], pageY = _d[1];
21662
+ var _d = __read(_this.dndMouse.getPageXY(e), 2), pageX = _d[0], pageY = _d[1];
21424
21663
  var deltaX = (pageX - _this.initX) / _this.zoomScale;
21425
21664
  var deltaY = (pageY - _this.initY) / _this.zoomScale;
21426
21665
  if (_this.initValue &&
@@ -21925,6 +22164,22 @@ exports.CursorFeatures = {
21925
22164
 
21926
22165
  "use strict";
21927
22166
 
22167
+ var __read = (this && this.__read) || function (o, n) {
22168
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
22169
+ if (!m) return o;
22170
+ var i = m.call(o), r, ar = [], e;
22171
+ try {
22172
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22173
+ }
22174
+ catch (error) { e = { error: error }; }
22175
+ finally {
22176
+ try {
22177
+ if (r && !r.done && (m = i["return"])) m.call(i);
22178
+ }
22179
+ finally { if (e) throw e.error; }
22180
+ }
22181
+ return ar;
22182
+ };
21928
22183
  Object.defineProperty(exports, "__esModule", { value: true });
21929
22184
  exports.EntityFeatures = void 0;
21930
22185
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
@@ -22239,7 +22494,7 @@ function triggerOperation(entity, editor, operation, event) {
22239
22494
  removeDelimiters(nextElementSibling, previousElementSibling);
22240
22495
  }
22241
22496
  else {
22242
- var delimiterAfter = (0, roosterjs_editor_dom_2.addDelimiters)(entity.wrapper)[0];
22497
+ var _a = __read((0, roosterjs_editor_dom_2.addDelimiters)(entity.wrapper), 1), delimiterAfter = _a[0];
22243
22498
  if (delimiterAfter) {
22244
22499
  editor.select(delimiterAfter, -3 /* After */);
22245
22500
  }
@@ -23964,6 +24219,33 @@ Object.defineProperty(exports, "ContextMenu", { enumerable: true, get: function
23964
24219
 
23965
24220
  "use strict";
23966
24221
 
24222
+ var __values = (this && this.__values) || function(o) {
24223
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
24224
+ if (m) return m.call(o);
24225
+ if (o && typeof o.length === "number") return {
24226
+ next: function () {
24227
+ if (o && i >= o.length) o = void 0;
24228
+ return { value: o && o[i++], done: !o };
24229
+ }
24230
+ };
24231
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
24232
+ };
24233
+ var __read = (this && this.__read) || function (o, n) {
24234
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24235
+ if (!m) return o;
24236
+ var i = m.call(o), r, ar = [], e;
24237
+ try {
24238
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
24239
+ }
24240
+ catch (error) { e = { error: error }; }
24241
+ finally {
24242
+ try {
24243
+ if (r && !r.done && (m = i["return"])) m.call(i);
24244
+ }
24245
+ finally { if (e) throw e.error; }
24246
+ }
24247
+ return ar;
24248
+ };
23967
24249
  Object.defineProperty(exports, "__esModule", { value: true });
23968
24250
  var makeReplacement = function (sourceString, replacementHTML, matchSourceCaseSensitive, shouldReplace) { return ({
23969
24251
  sourceString: sourceString,
@@ -24070,21 +24352,31 @@ var CustomReplacePlugin = /** @class */ (function () {
24070
24352
  }
24071
24353
  };
24072
24354
  CustomReplacePlugin.prototype.getMatchingReplacement = function (stringToSearch) {
24355
+ var e_1, _a;
24073
24356
  if (stringToSearch.length == 0 || !this.replacements) {
24074
24357
  return null;
24075
24358
  }
24076
24359
  var originalStringToSearch = stringToSearch.replace(/\s/g, ' ');
24077
24360
  var lowerCaseStringToSearch = originalStringToSearch.toLocaleLowerCase();
24078
- for (var _i = 0, _a = this.replacements; _i < _a.length; _i++) {
24079
- var replacement = _a[_i];
24080
- var _b = replacement.matchSourceCaseSensitive
24081
- ? [originalStringToSearch, replacement.sourceString]
24082
- : [lowerCaseStringToSearch, replacement.sourceString.toLocaleLowerCase()], sourceMatch = _b[0], replacementMatch = _b[1];
24083
- if (sourceMatch.substring(sourceMatch.length - replacementMatch.length) ==
24084
- replacementMatch) {
24085
- return replacement;
24361
+ try {
24362
+ for (var _b = __values(this.replacements), _c = _b.next(); !_c.done; _c = _b.next()) {
24363
+ var replacement = _c.value;
24364
+ var _d = __read(replacement.matchSourceCaseSensitive
24365
+ ? [originalStringToSearch, replacement.sourceString]
24366
+ : [lowerCaseStringToSearch, replacement.sourceString.toLocaleLowerCase()], 2), sourceMatch = _d[0], replacementMatch = _d[1];
24367
+ if (sourceMatch.substring(sourceMatch.length - replacementMatch.length) ==
24368
+ replacementMatch) {
24369
+ return replacement;
24370
+ }
24086
24371
  }
24087
24372
  }
24373
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
24374
+ finally {
24375
+ try {
24376
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
24377
+ }
24378
+ finally { if (e_1) throw e_1.error; }
24379
+ }
24088
24380
  return null;
24089
24381
  };
24090
24382
  return CustomReplacePlugin;
@@ -24094,21 +24386,31 @@ function getLongestReplacementSourceLength(replacements) {
24094
24386
  return Math.max.apply(null, replacements.map(function (replacement) { return replacement.sourceString.length; }));
24095
24387
  }
24096
24388
  function getReplacementEndCharacters(replacements) {
24389
+ var e_2, _a;
24097
24390
  var endChars = new Set();
24098
- for (var _i = 0, replacements_1 = replacements; _i < replacements_1.length; _i++) {
24099
- var replacement = replacements_1[_i];
24100
- var sourceString = replacement.sourceString;
24101
- if (sourceString.length == 0) {
24102
- continue;
24103
- }
24104
- var lastChar = sourceString[sourceString.length - 1];
24105
- if (!replacement.matchSourceCaseSensitive) {
24106
- endChars.add(lastChar.toLocaleLowerCase());
24107
- endChars.add(lastChar.toLocaleUpperCase());
24391
+ try {
24392
+ for (var replacements_1 = __values(replacements), replacements_1_1 = replacements_1.next(); !replacements_1_1.done; replacements_1_1 = replacements_1.next()) {
24393
+ var replacement = replacements_1_1.value;
24394
+ var sourceString = replacement.sourceString;
24395
+ if (sourceString.length == 0) {
24396
+ continue;
24397
+ }
24398
+ var lastChar = sourceString[sourceString.length - 1];
24399
+ if (!replacement.matchSourceCaseSensitive) {
24400
+ endChars.add(lastChar.toLocaleLowerCase());
24401
+ endChars.add(lastChar.toLocaleUpperCase());
24402
+ }
24403
+ else {
24404
+ endChars.add(lastChar);
24405
+ }
24108
24406
  }
24109
- else {
24110
- endChars.add(lastChar);
24407
+ }
24408
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
24409
+ finally {
24410
+ try {
24411
+ if (replacements_1_1 && !replacements_1_1.done && (_a = replacements_1.return)) _a.call(replacements_1);
24111
24412
  }
24413
+ finally { if (e_2) throw e_2.error; }
24112
24414
  }
24113
24415
  return endChars;
24114
24416
  }
@@ -24486,6 +24788,22 @@ var __assign = (this && this.__assign) || function () {
24486
24788
  };
24487
24789
  return __assign.apply(this, arguments);
24488
24790
  };
24791
+ var __read = (this && this.__read) || function (o, n) {
24792
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24793
+ if (!m) return o;
24794
+ var i = m.call(o), r, ar = [], e;
24795
+ try {
24796
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
24797
+ }
24798
+ catch (error) { e = { error: error }; }
24799
+ finally {
24800
+ try {
24801
+ if (r && !r.done && (m = i["return"])) m.call(i);
24802
+ }
24803
+ finally { if (e) throw e.error; }
24804
+ }
24805
+ return ar;
24806
+ };
24489
24807
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24490
24808
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24491
24809
  if (ar || !(i in from)) {
@@ -24805,7 +25123,7 @@ var ImageEdit = /** @class */ (function () {
24805
25123
  this.createWrapper(operation);
24806
25124
  this.updateWrapper();
24807
25125
  // Init drag and drop
24808
- this.dndHelpers = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], this.createDndHelpers("r_resizeH" /* ResizeHandle */, Resizer_1.Resizer), true), this.createDndHelpers("r_rotateH" /* RotateHandle */, Rotator_1.Rotator), true), this.createDndHelpers("r_cropH" /* CropHandle */, Cropper_1.Cropper), true), this.createDndHelpers("r_cropC" /* CropContainer */, Cropper_1.Cropper), true);
25126
+ this.dndHelpers = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(this.createDndHelpers("r_resizeH" /* ResizeHandle */, Resizer_1.Resizer)), false), __read(this.createDndHelpers("r_rotateH" /* RotateHandle */, Rotator_1.Rotator)), false), __read(this.createDndHelpers("r_cropH" /* CropHandle */, Cropper_1.Cropper)), false), __read(this.createDndHelpers("r_cropC" /* CropContainer */, Cropper_1.Cropper)), false);
24809
25127
  this.editor.select(this.image);
24810
25128
  }
24811
25129
  };
@@ -24980,7 +25298,9 @@ function handleRadIndexCalculator(angleRad) {
24980
25298
  var idx = Math.round(angleRad / DirectionRad) % DIRECTIONS;
24981
25299
  return idx < 0 ? idx + DIRECTIONS : idx;
24982
25300
  }
24983
- function rotateHandles(y, x, angleRad) {
25301
+ function rotateHandles(angleRad, y, x) {
25302
+ if (y === void 0) { y = ''; }
25303
+ if (x === void 0) { x = ''; }
24984
25304
  var radIndex = handleRadIndexCalculator(angleRad);
24985
25305
  var originalDirection = y + x;
24986
25306
  var originalIndex = DirectionOrder.indexOf(originalDirection);
@@ -24996,9 +25316,7 @@ function updateHandleCursor(handles, angleRad) {
24996
25316
  handles.map(function (handle) {
24997
25317
  var y = handle.dataset.y;
24998
25318
  var x = handle.dataset.x;
24999
- if (y && x) {
25000
- handle.style.cursor = rotateHandles(y, x, angleRad) + "-resize";
25001
- }
25319
+ handle.style.cursor = rotateHandles(angleRad, y, x) + "-resize";
25002
25320
  });
25003
25321
  }
25004
25322
  /**
@@ -25290,6 +25608,22 @@ exports.default = applyChange;
25290
25608
 
25291
25609
  "use strict";
25292
25610
 
25611
+ var __read = (this && this.__read) || function (o, n) {
25612
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25613
+ if (!m) return o;
25614
+ var i = m.call(o), r, ar = [], e;
25615
+ try {
25616
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
25617
+ }
25618
+ catch (error) { e = { error: error }; }
25619
+ finally {
25620
+ try {
25621
+ if (r && !r.done && (m = i["return"])) m.call(i);
25622
+ }
25623
+ finally { if (e) throw e.error; }
25624
+ }
25625
+ return ar;
25626
+ };
25293
25627
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25294
25628
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25295
25629
  if (ar || !(i in from)) {
@@ -25308,8 +25642,8 @@ var CROP_KEYS = [
25308
25642
  'topPercent',
25309
25643
  'bottomPercent',
25310
25644
  ];
25311
- var ROTATE_CROP_KEYS = __spreadArray(__spreadArray([], ROTATE_KEYS, true), CROP_KEYS, true);
25312
- var ALL_KEYS = __spreadArray(__spreadArray([], ROTATE_CROP_KEYS, true), RESIZE_KEYS, true);
25645
+ var ROTATE_CROP_KEYS = __spreadArray(__spreadArray([], __read(ROTATE_KEYS), false), __read(CROP_KEYS), false);
25646
+ var ALL_KEYS = __spreadArray(__spreadArray([], __read(ROTATE_CROP_KEYS), false), __read(RESIZE_KEYS), false);
25313
25647
  /**
25314
25648
  * @internal
25315
25649
  * Check the state of an edit info
@@ -25561,6 +25895,22 @@ var __assign = (this && this.__assign) || function () {
25561
25895
  };
25562
25896
  return __assign.apply(this, arguments);
25563
25897
  };
25898
+ var __read = (this && this.__read) || function (o, n) {
25899
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25900
+ if (!m) return o;
25901
+ var i = m.call(o), r, ar = [], e;
25902
+ try {
25903
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
25904
+ }
25905
+ catch (error) { e = { error: error }; }
25906
+ finally {
25907
+ try {
25908
+ if (r && !r.done && (m = i["return"])) m.call(i);
25909
+ }
25910
+ finally { if (e) throw e.error; }
25911
+ }
25912
+ return ar;
25913
+ };
25564
25914
  Object.defineProperty(exports, "__esModule", { value: true });
25565
25915
  exports.getCropHTML = exports.Cropper = void 0;
25566
25916
  var Resizer_1 = __webpack_require__(/*! ./Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
@@ -25586,7 +25936,7 @@ exports.Cropper = {
25586
25936
  onDragging: function (_a, e, base, dx, dy) {
25587
25937
  var _b;
25588
25938
  var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options;
25589
- _b = (0, Resizer_1.rotateCoordinate)(dx, dy, editInfo.angleRad), dx = _b[0], dy = _b[1];
25939
+ _b = __read((0, Resizer_1.rotateCoordinate)(dx, dy, editInfo.angleRad), 2), dx = _b[0], dy = _b[1];
25590
25940
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, bottomPercent = editInfo.bottomPercent;
25591
25941
  var minWidth = options.minWidth, minHeight = options.minHeight;
25592
25942
  var widthPercent = 1 - leftPercent - rightPercent;
@@ -25705,6 +26055,22 @@ var __assign = (this && this.__assign) || function () {
25705
26055
  };
25706
26056
  return __assign.apply(this, arguments);
25707
26057
  };
26058
+ var __read = (this && this.__read) || function (o, n) {
26059
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26060
+ if (!m) return o;
26061
+ var i = m.call(o), r, ar = [], e;
26062
+ try {
26063
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
26064
+ }
26065
+ catch (error) { e = { error: error }; }
26066
+ finally {
26067
+ try {
26068
+ if (r && !r.done && (m = i["return"])) m.call(i);
26069
+ }
26070
+ finally { if (e) throw e.error; }
26071
+ }
26072
+ return ar;
26073
+ };
25708
26074
  Object.defineProperty(exports, "__esModule", { value: true });
25709
26075
  exports.getResizeBordersHTML = exports.getSideResizeHTML = exports.getCornerResizeHTML = exports.doubleCheckResize = exports.rotateCoordinate = exports.Resizer = void 0;
25710
26076
  var RESIZE_HANDLE_SIZE = 10;
@@ -25724,7 +26090,7 @@ exports.Resizer = {
25724
26090
  var _b;
25725
26091
  var x = _a.x, y = _a.y, editInfo = _a.editInfo, options = _a.options;
25726
26092
  var ratio = base.widthPx > 0 && base.heightPx > 0 ? (base.widthPx * 1.0) / base.heightPx : 0;
25727
- _b = rotateCoordinate(deltaX, deltaY, editInfo.angleRad), deltaX = _b[0], deltaY = _b[1];
26093
+ _b = __read(rotateCoordinate(deltaX, deltaY, editInfo.angleRad), 2), deltaX = _b[0], deltaY = _b[1];
25728
26094
  if (options.minWidth !== undefined && options.minHeight !== undefined) {
25729
26095
  var horizontalOnly = x == '';
25730
26096
  var verticalOnly = y == '';
@@ -26237,14 +26603,17 @@ var Paste = /** @class */ (function () {
26237
26603
  break;
26238
26604
  case 1 /* ExcelDesktop */:
26239
26605
  case 2 /* ExcelOnline */:
26240
- // Handle HTML copied from Excel
26241
- (0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
26606
+ if (event.pasteType === 0 /* Normal */ ||
26607
+ event.pasteType === 2 /* MergeFormat */) {
26608
+ // Handle HTML copied from Excel
26609
+ (0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
26610
+ }
26242
26611
  break;
26243
26612
  case 3 /* PowerPointDesktop */:
26244
26613
  (0, convertPastedContentFromPowerPoint_1.default)(event, trustedHTMLHandler);
26245
26614
  break;
26246
26615
  case 5 /* WacComponents */:
26247
- (0, convertPastedContentFromOfficeOnline_1.default)(fragment);
26616
+ (0, convertPastedContentFromOfficeOnline_1.default)(fragment, sanitizingOption);
26248
26617
  break;
26249
26618
  case 4 /* GoogleSheets */:
26250
26619
  sanitizingOption.additionalTagReplacements[GOOGLE_SHEET_NODE_NAME] = '*';
@@ -26573,6 +26942,7 @@ exports.createListItemBlock = createListItemBlock;
26573
26942
  "use strict";
26574
26943
 
26575
26944
  Object.defineProperty(exports, "__esModule", { value: true });
26945
+ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
26576
26946
  var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
26577
26947
  var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
26578
26948
  /**
@@ -26582,7 +26952,7 @@ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[cla
26582
26952
  * We need to remove the display property and margin from all the list item
26583
26953
  * @param event The BeforePaste event
26584
26954
  */
26585
- function convertPastedContentFromOfficeOnline(fragment) {
26955
+ function convertPastedContentFromOfficeOnline(fragment, sanitizingOption) {
26586
26956
  fragment.querySelectorAll(WAC_IDENTIFY_SELECTOR).forEach(function (el) {
26587
26957
  var element = el;
26588
26958
  element.style.removeProperty('display');
@@ -26593,6 +26963,10 @@ function convertPastedContentFromOfficeOnline(fragment) {
26593
26963
  if ((0, convertPastedContentFromWordOnline_1.isWordOnlineWithList)(fragment)) {
26594
26964
  (0, convertPastedContentFromWordOnline_1.default)(fragment);
26595
26965
  }
26966
+ // Remove "border:none" for image to fix image resize behavior
26967
+ // We found a problem that when paste an image with "border:none" then the resize border will be
26968
+ // displayed incorrectly when resize it. So we need to drop this style
26969
+ (0, roosterjs_editor_dom_1.chainSanitizerCallback)(sanitizingOption.cssStyleCallbacks, 'border', function (value, element) { return element.tagName != 'IMG' || value != 'none'; });
26596
26970
  }
26597
26971
  exports.default = convertPastedContentFromOfficeOnline;
26598
26972
 
@@ -27053,9 +27427,7 @@ exports.default = sanitizeHtmlColorsFromPastedContent;
27053
27427
 
27054
27428
  Object.defineProperty(exports, "__esModule", { value: true });
27055
27429
  var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
27056
- var HTTP = 'http:';
27057
- var HTTPS = 'https:';
27058
- var NOTES = 'notes:';
27430
+ var SUPPORTED_PROTOCOLS = ['http:', 'https:', 'notes:', 'mailto:', 'onenote:'];
27059
27431
  /**
27060
27432
  * @internal
27061
27433
  * Clear local paths and remove link
@@ -27073,10 +27445,8 @@ function validateLink(link, htmlElement) {
27073
27445
  catch (_a) {
27074
27446
  url = undefined;
27075
27447
  }
27076
- if (url &&
27077
- (url.protocol === HTTP ||
27078
- url.protocol === HTTPS ||
27079
- url.protocol === NOTES) /* whitelist Notes protocol */) {
27448
+ /* whitelist supported protocols */
27449
+ if (url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) > -1) {
27080
27450
  return link;
27081
27451
  }
27082
27452
  htmlElement.removeAttribute('href');
@@ -27967,8 +28337,15 @@ var PickerPlugin = /** @class */ (function () {
27967
28337
  function PickerPlugin(dataProvider, pickerOptions) {
27968
28338
  this.dataProvider = dataProvider;
27969
28339
  this.pickerOptions = pickerOptions;
28340
+ this.editor = null;
28341
+ this.eventHandledOnKeyDown = false;
28342
+ this.blockSuggestions = false;
28343
+ this.isSuggesting = false;
28344
+ this.lastKnownRange = null;
27970
28345
  // For detecting backspace in Android
27971
28346
  this.isPendingInputEventHandling = false;
28347
+ this.currentInputLength = 0;
28348
+ this.newInputLength = 0;
27972
28349
  }
27973
28350
  /**
27974
28351
  * Get a friendly name
@@ -27984,24 +28361,27 @@ var PickerPlugin = /** @class */ (function () {
27984
28361
  var _this = this;
27985
28362
  this.editor = editor;
27986
28363
  this.dataProvider.onInitalize(function (htmlNode) {
27987
- _this.editor.focus();
27988
- var wordToReplace = _this.getWord(null);
27989
- // Safari drops our focus out so we get an empty word to replace when we call getWord.
27990
- // We fall back to using the lastKnownRange to try to get around this.
27991
- if ((!wordToReplace || wordToReplace.length == 0) && _this.lastKnownRange) {
27992
- _this.editor.select(_this.lastKnownRange);
27993
- wordToReplace = _this.getWord(null);
27994
- }
27995
- var insertNode = function () {
27996
- if (wordToReplace) {
27997
- (0, roosterjs_editor_api_1.replaceWithNode)(_this.editor, wordToReplace, htmlNode, true /* exactMatch */);
27998
- }
27999
- else {
28000
- _this.editor.insertNode(htmlNode);
28364
+ if (_this.editor) {
28365
+ _this.editor.focus();
28366
+ var wordToReplace_1 = _this.getWord(null);
28367
+ // Safari drops our focus out so we get an empty word to replace when we call getWord.
28368
+ // We fall back to using the lastKnownRange to try to get around this.
28369
+ if ((!wordToReplace_1 || wordToReplace_1.length == 0) && _this.lastKnownRange) {
28370
+ _this.editor.select(_this.lastKnownRange);
28371
+ wordToReplace_1 = _this.getWord(null);
28001
28372
  }
28002
- _this.setIsSuggesting(false);
28003
- };
28004
- _this.editor.addUndoSnapshot(insertNode, _this.pickerOptions.changeSource, _this.pickerOptions.handleAutoComplete);
28373
+ var insertNode = function () {
28374
+ var _a;
28375
+ if (wordToReplace_1 && _this.editor) {
28376
+ (0, roosterjs_editor_api_1.replaceWithNode)(_this.editor, wordToReplace_1, htmlNode, true /* exactMatch */);
28377
+ }
28378
+ else {
28379
+ (_a = _this.editor) === null || _a === void 0 ? void 0 : _a.insertNode(htmlNode);
28380
+ }
28381
+ _this.setIsSuggesting(false);
28382
+ };
28383
+ _this.editor.addUndoSnapshot(insertNode, _this.pickerOptions.changeSource, _this.pickerOptions.handleAutoComplete);
28384
+ }
28005
28385
  }, function (isSuggesting) {
28006
28386
  _this.setIsSuggesting(isSuggesting);
28007
28387
  }, editor);
@@ -28011,13 +28391,13 @@ var PickerPlugin = /** @class */ (function () {
28011
28391
  */
28012
28392
  PickerPlugin.prototype.dispose = function () {
28013
28393
  this.editor = null;
28014
- this.isSuggesting = null;
28015
- this.blockSuggestions = null;
28016
- this.eventHandledOnKeyDown = null;
28394
+ this.isSuggesting = false;
28395
+ this.blockSuggestions = false;
28396
+ this.eventHandledOnKeyDown = false;
28017
28397
  this.lastKnownRange = null;
28018
- this.isPendingInputEventHandling = null;
28019
- this.currentInputLength = null;
28020
- this.newInputLength = null;
28398
+ this.isPendingInputEventHandling = false;
28399
+ this.currentInputLength = 0;
28400
+ this.newInputLength = 0;
28021
28401
  this.dataProvider.onDispose();
28022
28402
  };
28023
28403
  /**
@@ -28039,6 +28419,7 @@ var PickerPlugin = /** @class */ (function () {
28039
28419
  * @param event PluginEvent object
28040
28420
  */
28041
28421
  PickerPlugin.prototype.onPluginEvent = function (event) {
28422
+ var _a;
28042
28423
  switch (event.eventType) {
28043
28424
  case 7 /* ContentChanged */:
28044
28425
  if (event.source == "SetContent" /* SetContent */ && this.dataProvider.onContentChanged) {
@@ -28049,7 +28430,7 @@ var PickerPlugin = /** @class */ (function () {
28049
28430
  // Undo and other major changes to document content fire this type of event.
28050
28431
  // Inform the data provider of the current picker placed elements in the body.
28051
28432
  var elementIds_1 = [];
28052
- this.editor.queryElements("[id^='" + this.pickerOptions.elementIdPrefix + "']", function (element) {
28433
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.queryElements("[id^='" + this.pickerOptions.elementIdPrefix + "']", function (element) {
28053
28434
  if (element.id) {
28054
28435
  elementIds_1.push(element.id);
28055
28436
  }
@@ -28114,29 +28495,35 @@ var PickerPlugin = /** @class */ (function () {
28114
28495
  event.rawEvent.stopImmediatePropagation();
28115
28496
  };
28116
28497
  PickerPlugin.prototype.getIdValue = function (node) {
28117
- var element = node;
28118
- return element.attributes && element.attributes.getNamedItem('id')
28119
- ? element.attributes.getNamedItem('id').value
28120
- : null;
28498
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(node, 'HTMLElement')) {
28499
+ var attribute = node.attributes.getNamedItem('id');
28500
+ return attribute ? attribute.value : null;
28501
+ }
28502
+ else {
28503
+ return null;
28504
+ }
28121
28505
  };
28122
28506
  PickerPlugin.prototype.getWordBeforeCursor = function (event) {
28123
- var searcher = this.editor.getContentSearcherOfCursor(event);
28507
+ var _a;
28508
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28124
28509
  return searcher ? searcher.getWordBefore() : null;
28125
28510
  };
28126
28511
  PickerPlugin.prototype.replaceNode = function (currentNode, replacementNode) {
28512
+ var _a, _b;
28127
28513
  if (currentNode) {
28128
- this.editor.deleteNode(currentNode);
28514
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.deleteNode(currentNode);
28129
28515
  }
28130
28516
  if (replacementNode) {
28131
- this.editor.insertNode(replacementNode);
28517
+ (_b = this.editor) === null || _b === void 0 ? void 0 : _b.insertNode(replacementNode);
28132
28518
  }
28133
28519
  };
28134
28520
  PickerPlugin.prototype.getRangeUntilAt = function (event) {
28135
28521
  var _this = this;
28136
- var positionContentSearcher = this.editor.getContentSearcherOfCursor(event);
28137
- var startPos;
28138
- var endPos;
28139
- positionContentSearcher.forEachTextInlineElement(function (textInline) {
28522
+ var _a, _b, _c;
28523
+ var positionContentSearcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28524
+ var startPos = undefined;
28525
+ var endPos = undefined;
28526
+ positionContentSearcher === null || positionContentSearcher === void 0 ? void 0 : positionContentSearcher.forEachTextInlineElement(function (textInline) {
28140
28527
  var hasMatched = false;
28141
28528
  var nodeContent = textInline.getTextContent();
28142
28529
  var nodeIndex = nodeContent ? nodeContent.length : -1;
@@ -28153,7 +28540,9 @@ var PickerPlugin = /** @class */ (function () {
28153
28540
  }
28154
28541
  return hasMatched;
28155
28542
  });
28156
- return (0, roosterjs_editor_dom_1.createRange)(startPos, endPos) || this.editor.getDocument().createRange();
28543
+ return startPos
28544
+ ? (0, roosterjs_editor_dom_1.createRange)(startPos, endPos)
28545
+ : (_c = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getDocument().createRange()) !== null && _c !== void 0 ? _c : null;
28157
28546
  };
28158
28547
  PickerPlugin.prototype.shouldHandleKeyUpEvent = function (event) {
28159
28548
  // onKeyUpDomEvent should only be called when a key that produces a character value is pressed
@@ -28164,78 +28553,89 @@ var PickerPlugin = /** @class */ (function () {
28164
28553
  (this.isSuggesting && !(0, roosterjs_editor_dom_1.isModifierKey)(event.rawEvent)));
28165
28554
  };
28166
28555
  PickerPlugin.prototype.onKeyUpDomEvent = function (event) {
28167
- if (this.isSuggesting) {
28168
- // Word before cursor represents the text prior to the cursor, up to and including the trigger symbol.
28169
- var wordBeforeCursor = this.getWord(event);
28170
- var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28171
- var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28172
- // If we hit a case where wordBeforeCursor is just the trigger character,
28173
- // that means we've gotten a onKeyUp event right after it's been typed.
28174
- // Otherwise, update the query string when:
28175
- // 1. There's an actual value
28176
- // 2. That actual value isn't just pure whitespace
28177
- // 3. That actual value isn't more than 4 words long (at which point we assume the person kept typing)
28178
- // Otherwise, we want to dismiss the picker plugin's UX.
28179
- if (wordBeforeCursor == this.pickerOptions.triggerCharacter ||
28180
- (trimmedWordBeforeCursor &&
28181
- trimmedWordBeforeCursor.length > 0 &&
28182
- trimmedWordBeforeCursor.split(' ').length <= 4)) {
28183
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28184
- this.setLastKnownRange(this.editor.getSelectionRange());
28185
- }
28186
- else {
28187
- this.setIsSuggesting(false);
28188
- }
28189
- }
28190
- else {
28191
- var wordBeforeCursor = this.getWordBeforeCursor(event);
28192
- if (!this.blockSuggestions) {
28193
- if (wordBeforeCursor != null &&
28194
- wordBeforeCursor.split(' ').length <= 4 &&
28195
- wordBeforeCursor[0] == this.pickerOptions.triggerCharacter) {
28196
- this.setIsSuggesting(true);
28556
+ var _a, _b, _c, _d, _e;
28557
+ if (this.editor) {
28558
+ if (this.isSuggesting) {
28559
+ // Word before cursor represents the text prior to the cursor, up to and including the trigger symbol.
28560
+ var wordBeforeCursor = this.getWord(event);
28561
+ if (wordBeforeCursor !== null) {
28197
28562
  var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28198
28563
  var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28199
- this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28200
- this.setLastKnownRange(this.editor.getSelectionRange());
28201
- if (this.dataProvider.setCursorPoint) {
28202
- // Determine the bounding rectangle for the @mention
28203
- var searcher = this.editor.getContentSearcherOfCursor(event);
28204
- var rangeNode = this.editor.getDocument().createRange();
28205
- var nodeBeforeCursor = searcher.getInlineElementBefore().getContainerNode();
28206
- var rangeStartSuccessfullySet = this.setRangeStart(rangeNode, nodeBeforeCursor, wordBeforeCursor);
28207
- if (!rangeStartSuccessfullySet) {
28208
- // VSO 24891: Out of range error is occurring because nodeBeforeCursor
28209
- // is not including the trigger character. In this case, the node before
28210
- // the node before cursor is the trigger character, and this is where the range should start.
28211
- var nodeBeforeNodeBeforeCursor = nodeBeforeCursor.previousSibling;
28212
- this.setRangeStart(rangeNode, nodeBeforeNodeBeforeCursor, this.pickerOptions.triggerCharacter);
28213
- }
28214
- var rect = rangeNode.getBoundingClientRect();
28215
- // Safari's support for range.getBoundingClientRect is incomplete.
28216
- // We perform this check to fall back to getClientRects in case it's at the page origin.
28217
- if (rect.left == 0 && rect.bottom == 0 && rect.top == 0) {
28218
- rect = rangeNode.getClientRects()[0];
28219
- }
28220
- if (rect) {
28221
- rangeNode.detach();
28222
- // Display the @mention popup in the correct place
28223
- var targetPoint = { x: rect.left, y: (rect.bottom + rect.top) / 2 };
28224
- var bufferZone = (rect.bottom - rect.top) / 2;
28225
- this.dataProvider.setCursorPoint(targetPoint, bufferZone);
28226
- }
28564
+ // If we hit a case where wordBeforeCursor is just the trigger character,
28565
+ // that means we've gotten a onKeyUp event right after it's been typed.
28566
+ // Otherwise, update the query string when:
28567
+ // 1. There's an actual value
28568
+ // 2. That actual value isn't just pure whitespace
28569
+ // 3. That actual value isn't more than 4 words long (at which point we assume the person kept typing)
28570
+ // Otherwise, we want to dismiss the picker plugin's UX.
28571
+ if (wordBeforeCursor == this.pickerOptions.triggerCharacter ||
28572
+ (trimmedWordBeforeCursor &&
28573
+ trimmedWordBeforeCursor.length > 0 &&
28574
+ trimmedWordBeforeCursor.split(' ').length <= 4)) {
28575
+ this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28576
+ this.setLastKnownRange((_a = this.editor.getSelectionRange()) !== null && _a !== void 0 ? _a : null);
28577
+ }
28578
+ else {
28579
+ this.setIsSuggesting(false);
28227
28580
  }
28228
28581
  }
28229
28582
  }
28230
28583
  else {
28231
- if (wordBeforeCursor != null &&
28232
- wordBeforeCursor[0] != this.pickerOptions.triggerCharacter) {
28233
- this.blockSuggestions = false;
28584
+ var wordBeforeCursor = this.getWordBeforeCursor(event);
28585
+ if (!this.blockSuggestions) {
28586
+ if (wordBeforeCursor != null &&
28587
+ wordBeforeCursor.split(' ').length <= 4 &&
28588
+ wordBeforeCursor[0] == this.pickerOptions.triggerCharacter) {
28589
+ this.setIsSuggesting(true);
28590
+ var wordBeforeCursorWithoutTriggerChar = wordBeforeCursor.substring(1);
28591
+ var trimmedWordBeforeCursor = wordBeforeCursorWithoutTriggerChar.trim();
28592
+ this.dataProvider.queryStringUpdated(trimmedWordBeforeCursor, wordBeforeCursorWithoutTriggerChar == trimmedWordBeforeCursor);
28593
+ this.setLastKnownRange((_b = this.editor.getSelectionRange()) !== null && _b !== void 0 ? _b : null);
28594
+ if (this.dataProvider.setCursorPoint) {
28595
+ // Determine the bounding rectangle for the @mention
28596
+ var searcher = this.editor.getContentSearcherOfCursor(event);
28597
+ var rangeNode = this.editor.getDocument().createRange();
28598
+ if (rangeNode) {
28599
+ var nodeBeforeCursor = (_d = (_c = searcher === null || searcher === void 0 ? void 0 : searcher.getInlineElementBefore()) === null || _c === void 0 ? void 0 : _c.getContainerNode()) !== null && _d !== void 0 ? _d : null;
28600
+ var rangeStartSuccessfullySet = this.setRangeStart(rangeNode, nodeBeforeCursor, wordBeforeCursor);
28601
+ if (!rangeStartSuccessfullySet) {
28602
+ // VSO 24891: Out of range error is occurring because nodeBeforeCursor
28603
+ // is not including the trigger character. In this case, the node before
28604
+ // the node before cursor is the trigger character, and this is where the range should start.
28605
+ var nodeBeforeNodeBeforeCursor = (_e = nodeBeforeCursor === null || nodeBeforeCursor === void 0 ? void 0 : nodeBeforeCursor.previousSibling) !== null && _e !== void 0 ? _e : null;
28606
+ this.setRangeStart(rangeNode, nodeBeforeNodeBeforeCursor, this.pickerOptions.triggerCharacter);
28607
+ }
28608
+ var rect = rangeNode.getBoundingClientRect();
28609
+ // Safari's support for range.getBoundingClientRect is incomplete.
28610
+ // We perform this check to fall back to getClientRects in case it's at the page origin.
28611
+ if (rect.left == 0 && rect.bottom == 0 && rect.top == 0) {
28612
+ rect = rangeNode.getClientRects()[0];
28613
+ }
28614
+ if (rect) {
28615
+ rangeNode.detach();
28616
+ // Display the @mention popup in the correct place
28617
+ var targetPoint = {
28618
+ x: rect.left,
28619
+ y: (rect.bottom + rect.top) / 2,
28620
+ };
28621
+ var bufferZone = (rect.bottom - rect.top) / 2;
28622
+ this.dataProvider.setCursorPoint(targetPoint, bufferZone);
28623
+ }
28624
+ }
28625
+ }
28626
+ }
28627
+ }
28628
+ else {
28629
+ if (wordBeforeCursor != null &&
28630
+ wordBeforeCursor[0] != this.pickerOptions.triggerCharacter) {
28631
+ this.blockSuggestions = false;
28632
+ }
28234
28633
  }
28235
28634
  }
28236
28635
  }
28237
28636
  };
28238
28637
  PickerPlugin.prototype.onKeyDownEvent = function (event) {
28638
+ var _a, _b;
28239
28639
  var keyboardEvent = event.rawEvent;
28240
28640
  if (this.isSuggesting) {
28241
28641
  if (keyboardEvent.key == ESC_CHAR_CODE) {
@@ -28282,15 +28682,19 @@ var PickerPlugin = /** @class */ (function () {
28282
28682
  }
28283
28683
  }
28284
28684
  else if (keyboardEvent.key == DELETE_CHAR_CODE) {
28285
- var searcher = this.editor.getContentSearcherOfCursor(event);
28286
- var nodeAfterCursor = searcher.getInlineElementAfter()
28287
- ? searcher.getInlineElementAfter().getContainerNode()
28288
- : null;
28289
- var nodeId = nodeAfterCursor ? this.getIdValue(nodeAfterCursor) : null;
28290
- if (nodeId && nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0) {
28291
- var replacementNode = this.dataProvider.onRemove(nodeAfterCursor, false);
28292
- this.replaceNode(nodeAfterCursor, replacementNode);
28293
- this.cancelDefaultKeyDownEvent(event);
28685
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28686
+ if (searcher) {
28687
+ var nodeAfterCursor = searcher.getInlineElementAfter()
28688
+ ? (_b = searcher.getInlineElementAfter()) === null || _b === void 0 ? void 0 : _b.getContainerNode()
28689
+ : null;
28690
+ var nodeId = nodeAfterCursor ? this.getIdValue(nodeAfterCursor) : null;
28691
+ if (nodeId &&
28692
+ nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0 &&
28693
+ nodeAfterCursor) {
28694
+ var replacementNode = this.dataProvider.onRemove(nodeAfterCursor, false);
28695
+ this.replaceNode(nodeAfterCursor, replacementNode);
28696
+ this.cancelDefaultKeyDownEvent(event);
28697
+ }
28294
28698
  }
28295
28699
  }
28296
28700
  }
@@ -28310,14 +28714,21 @@ var PickerPlugin = /** @class */ (function () {
28310
28714
  return wordBeforeCursor ? wordBeforeCursor.length : 0;
28311
28715
  };
28312
28716
  PickerPlugin.prototype.tryRemoveNode = function (event) {
28717
+ if (!this.editor) {
28718
+ return false;
28719
+ }
28313
28720
  var searcher = this.editor.getContentSearcherOfCursor(event);
28721
+ if (!searcher) {
28722
+ return false;
28723
+ }
28314
28724
  var inlineElementBefore = searcher.getInlineElementBefore();
28315
28725
  var nodeBeforeCursor = inlineElementBefore
28316
28726
  ? inlineElementBefore.getContainerNode()
28317
28727
  : null;
28318
28728
  var nodeId = nodeBeforeCursor ? this.getIdValue(nodeBeforeCursor) : null;
28319
28729
  var inlineElementAfter = searcher.getInlineElementAfter();
28320
- if (nodeId &&
28730
+ if (nodeBeforeCursor &&
28731
+ nodeId &&
28321
28732
  nodeId.indexOf(this.pickerOptions.elementIdPrefix) == 0 &&
28322
28733
  (inlineElementAfter == null || !(inlineElementAfter instanceof roosterjs_editor_dom_1.PartialInlineElement))) {
28323
28734
  var replacementNode_1 = this.dataProvider.onRemove(nodeBeforeCursor, true);
@@ -28331,16 +28742,19 @@ var PickerPlugin = /** @class */ (function () {
28331
28742
  else {
28332
28743
  this.editor.select(replacementNode_1, -3 /* After */);
28333
28744
  }
28745
+ return true;
28334
28746
  }
28335
28747
  else {
28336
- this.editor.deleteNode(nodeBeforeCursor);
28748
+ // Select the node then let browser delete it
28749
+ this.editor.select(nodeBeforeCursor);
28750
+ return false;
28337
28751
  }
28338
- return true;
28339
28752
  }
28340
28753
  return false;
28341
28754
  };
28342
28755
  PickerPlugin.prototype.getWord = function (event) {
28343
- var wordFromRange = this.getRangeUntilAt(event).toString();
28756
+ var _a, _b;
28757
+ var wordFromRange = (_b = (_a = this.getRangeUntilAt(event)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
28344
28758
  var wordFromCache = this.getWordBeforeCursor(event);
28345
28759
  // VSO 24891: In picker, trigger and mention are separated into two nodes.
28346
28760
  // In this case, wordFromRange is the trigger character while wordFromCache is the whole string,
@@ -28352,25 +28766,28 @@ var PickerPlugin = /** @class */ (function () {
28352
28766
  return wordFromRange;
28353
28767
  };
28354
28768
  PickerPlugin.prototype.setRangeStart = function (rangeNode, node, target) {
28355
- var nodeOffset = node ? node.textContent.lastIndexOf(target) : -1;
28356
- if (nodeOffset > -1) {
28769
+ var nodeOffset = (node === null || node === void 0 ? void 0 : node.textContent) ? node.textContent.lastIndexOf(target) : -1;
28770
+ if (node && nodeOffset > -1) {
28357
28771
  rangeNode.setStart(node, nodeOffset);
28358
28772
  return true;
28359
28773
  }
28360
28774
  return false;
28361
28775
  };
28362
28776
  PickerPlugin.prototype.setAriaOwns = function (isSuggesting) {
28363
- this.editor.setEditorDomAttribute('aria-owns', isSuggesting && this.pickerOptions.suggestionsLabel
28777
+ var _a;
28778
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorDomAttribute('aria-owns', isSuggesting && this.pickerOptions.suggestionsLabel
28364
28779
  ? this.pickerOptions.suggestionsLabel
28365
28780
  : null);
28366
28781
  };
28367
28782
  PickerPlugin.prototype.setAriaActiveDescendant = function (selectedIndex) {
28368
- this.editor.setEditorDomAttribute('aria-activedescendant', selectedIndex != null && this.pickerOptions.suggestionLabelPrefix
28783
+ var _a;
28784
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorDomAttribute('aria-activedescendant', selectedIndex != null && this.pickerOptions.suggestionLabelPrefix
28369
28785
  ? this.pickerOptions.suggestionLabelPrefix + selectedIndex.toString()
28370
28786
  : null);
28371
28787
  };
28372
28788
  PickerPlugin.prototype.getInlineElementBeforeCursor = function (event) {
28373
- var searcher = this.editor.getContentSearcherOfCursor(event);
28789
+ var _a;
28790
+ var searcher = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getContentSearcherOfCursor(event);
28374
28791
  var element = searcher ? searcher.getInlineElementBefore() : null;
28375
28792
  return element ? element.getTextContent() : null;
28376
28793
  };
@@ -30940,6 +31357,7 @@ var CompatibleContentType;
30940
31357
  Object.defineProperty(exports, "__esModule", { value: true });
30941
31358
  exports.CompatibleDarkModeDatasetNames = void 0;
30942
31359
  /**
31360
+ * @deprecated
30943
31361
  * Constants string for dataset names used by dark mode
30944
31362
  */
30945
31363
  var CompatibleDarkModeDatasetNames;
@@ -31557,15 +31975,31 @@ var CompatibleExperimentalFeatures;
31557
31975
  * When a html image is selected, the selected image data will be stored by editor core.
31558
31976
  */
31559
31977
  CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
31560
- //#endregion
31561
31978
  /**
31562
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
31979
+ * @deprecated this feature is always enabled
31980
+ * Use variable-based dark mode solution rather than dataset-based solution.
31981
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
31982
+ * if you need them work for dark mode
31563
31983
  */
31564
- CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
31984
+ CompatibleExperimentalFeatures["VariableBasedDarkColor"] = "VariableBasedDarkColor";
31565
31985
  /**
31986
+ * @deprecated this feature is always enabled
31566
31987
  * Align list elements elements to left, center and right using setAlignment API
31567
31988
  */
31568
31989
  CompatibleExperimentalFeatures["ListItemAlignment"] = "ListItemAlignment";
31990
+ /**
31991
+ * @deprecated
31992
+ */
31993
+ CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31994
+ /**
31995
+ * @deprecated
31996
+ */
31997
+ CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
31998
+ //#endregion
31999
+ /**
32000
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
32001
+ */
32002
+ CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
31569
32003
  /**
31570
32004
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
31571
32005
  */
@@ -31577,25 +32011,14 @@ var CompatibleExperimentalFeatures;
31577
32011
  * is the one closest to the item.
31578
32012
  */
31579
32013
  CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
31580
- /**
31581
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
31582
- * the block element (In most case, the DIV element) so keep the block element clean.
31583
- */
31584
- CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
31585
- /**
31586
- * Use variable-based dark mode solution rather than dataset-based solution.
31587
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
31588
- * if you need them work for dark mode
31589
- */
31590
- CompatibleExperimentalFeatures["VariableBasedDarkColor"] = "VariableBasedDarkColor";
31591
32014
  /**
31592
32015
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
31593
32016
  */
31594
32017
  CompatibleExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
31595
32018
  /**
31596
- * Apply default format on editor container
32019
+ * Handle keyboard editing event with Content Model
31597
32020
  */
31598
- CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
32021
+ CompatibleExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
31599
32022
  /**
31600
32023
  * Delete table with Backspace key with the whole was selected with table selector
31601
32024
  */
@@ -31906,7 +32329,7 @@ var CompatibleKnownCreateElementDataIndex;
31906
32329
  */
31907
32330
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["TableSelector"] = 11] = "TableSelector";
31908
32331
  /**
31909
- * An empty line without format with span inside of it.
32332
+ * @deprecated
31910
32333
  */
31911
32334
  CompatibleKnownCreateElementDataIndex[CompatibleKnownCreateElementDataIndex["EmptyLineFormatInSpan"] = 12] = "EmptyLineFormatInSpan";
31912
32335
  })(CompatibleKnownCreateElementDataIndex = exports.CompatibleKnownCreateElementDataIndex || (exports.CompatibleKnownCreateElementDataIndex = {}));
@@ -32141,6 +32564,43 @@ var CompatibleNumberingListType;
32141
32564
  })(CompatibleNumberingListType = exports.CompatibleNumberingListType || (exports.CompatibleNumberingListType = {}));
32142
32565
 
32143
32566
 
32567
+ /***/ }),
32568
+
32569
+ /***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts":
32570
+ /*!*************************************************************************!*\
32571
+ !*** ./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts ***!
32572
+ \*************************************************************************/
32573
+ /*! no static exports found */
32574
+ /***/ (function(module, exports, __webpack_require__) {
32575
+
32576
+ "use strict";
32577
+
32578
+ Object.defineProperty(exports, "__esModule", { value: true });
32579
+ exports.CompatiblePasteType = void 0;
32580
+ /**
32581
+ * Enum for paste options
32582
+ */
32583
+ var CompatiblePasteType;
32584
+ (function (CompatiblePasteType) {
32585
+ /**
32586
+ * Default paste behavior
32587
+ */
32588
+ CompatiblePasteType[CompatiblePasteType["Normal"] = 0] = "Normal";
32589
+ /**
32590
+ * Paste only the plain text
32591
+ */
32592
+ CompatiblePasteType[CompatiblePasteType["AsPlainText"] = 1] = "AsPlainText";
32593
+ /**
32594
+ * Apply the current style to pasted content
32595
+ */
32596
+ CompatiblePasteType[CompatiblePasteType["MergeFormat"] = 2] = "MergeFormat";
32597
+ /**
32598
+ * If there is a image uri in the clipboard, paste the content as image element
32599
+ */
32600
+ CompatiblePasteType[CompatiblePasteType["AsImage"] = 3] = "AsImage";
32601
+ })(CompatiblePasteType = exports.CompatiblePasteType || (exports.CompatiblePasteType = {}));
32602
+
32603
+
32144
32604
  /***/ }),
32145
32605
 
32146
32606
  /***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/PluginEventType.ts":
@@ -32256,6 +32716,12 @@ var CompatiblePluginEventType;
32256
32716
  * Editor changed the selection.
32257
32717
  */
32258
32718
  CompatiblePluginEventType[CompatiblePluginEventType["SelectionChanged"] = 22] = "SelectionChanged";
32719
+ /**
32720
+ * EXPERIMENTAL FEATURE
32721
+ * Editor content is about to be changed by keyboard event.
32722
+ * This is only used by Content Model editing
32723
+ */
32724
+ CompatiblePluginEventType[CompatiblePluginEventType["BeforeKeyboardEditing"] = 23] = "BeforeKeyboardEditing";
32259
32725
  })(CompatiblePluginEventType = exports.CompatiblePluginEventType || (exports.CompatiblePluginEventType = {}));
32260
32726
 
32261
32727
 
@@ -32602,7 +33068,7 @@ var CompatibleTableOperation;
32602
33068
  "use strict";
32603
33069
 
32604
33070
  Object.defineProperty(exports, "__esModule", { value: true });
32605
- 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;
33071
+ 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;
32606
33072
  var Alignment_1 = __webpack_require__(/*! ./Alignment */ "./packages/roosterjs-editor-types/lib/compatibleEnum/Alignment.ts");
32607
33073
  Object.defineProperty(exports, "CompatibleAlignment", { enumerable: true, get: function () { return Alignment_1.CompatibleAlignment; } });
32608
33074
  var BulletListType_1 = __webpack_require__(/*! ./BulletListType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/BulletListType.ts");
@@ -32658,6 +33124,8 @@ var NodeType_1 = __webpack_require__(/*! ./NodeType */ "./packages/roosterjs-edi
32658
33124
  Object.defineProperty(exports, "CompatibleNodeType", { enumerable: true, get: function () { return NodeType_1.CompatibleNodeType; } });
32659
33125
  var NumberingListType_1 = __webpack_require__(/*! ./NumberingListType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/NumberingListType.ts");
32660
33126
  Object.defineProperty(exports, "CompatibleNumberingListType", { enumerable: true, get: function () { return NumberingListType_1.CompatibleNumberingListType; } });
33127
+ var PasteType_1 = __webpack_require__(/*! ./PasteType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PasteType.ts");
33128
+ Object.defineProperty(exports, "CompatiblePasteType", { enumerable: true, get: function () { return PasteType_1.CompatiblePasteType; } });
32661
33129
  var PluginEventType_1 = __webpack_require__(/*! ./PluginEventType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PluginEventType.ts");
32662
33130
  Object.defineProperty(exports, "CompatiblePluginEventType", { enumerable: true, get: function () { return PluginEventType_1.CompatiblePluginEventType; } });
32663
33131
  var PositionType_1 = __webpack_require__(/*! ./PositionType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/PositionType.ts");