roosterjs 9.60.0 → 9.62.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.
@@ -6469,7 +6469,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6469
6469
  exports.insertLink = void 0;
6470
6470
  var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
6471
6471
  var adjustTrailingSpaceSelection_1 = __webpack_require__(/*! ../../modelApi/selection/adjustTrailingSpaceSelection */ "./packages/roosterjs-content-model-api/lib/modelApi/selection/adjustTrailingSpaceSelection.ts");
6472
- var checkXss_1 = __webpack_require__(/*! ../utils/checkXss */ "./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts");
6473
6472
  var matchLink_1 = __webpack_require__(/*! ../../modelApi/link/matchLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts");
6474
6473
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
6475
6474
  // Regex matching Uri scheme
@@ -6493,7 +6492,7 @@ var FTP_REGEX = /^ftp\./i;
6493
6492
  */
6494
6493
  function insertLink(editor, link, anchorTitle, displayText, target) {
6495
6494
  editor.focus();
6496
- var url = ((0, checkXss_1.checkXss)(link) || '').trim();
6495
+ var url = ((0, roosterjs_content_model_dom_1.isUnsafeUrl)(link) ? '' : link || '').trim();
6497
6496
  if (url) {
6498
6497
  var linkData_1 = (0, matchLink_1.matchLink)(url);
6499
6498
  var linkUrl_1 = linkData_1 ? linkData_1.normalizedUrl : applyLinkPrefix(url);
@@ -8049,31 +8048,6 @@ function setTableCellShade(editor, color) {
8049
8048
  exports.setTableCellShade = setTableCellShade;
8050
8049
 
8051
8050
 
8052
- /***/ },
8053
-
8054
- /***/ "./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts"
8055
- /*!******************************************************************************!*\
8056
- !*** ./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts ***!
8057
- \******************************************************************************/
8058
- (__unused_webpack_module, exports) {
8059
-
8060
- "use strict";
8061
-
8062
- Object.defineProperty(exports, "__esModule", ({ value: true }));
8063
- exports.checkXss = void 0;
8064
- /**
8065
- * @internal Check if there is XSS attack in the link
8066
- * @param link The link to be checked
8067
- * @returns The safe link, or empty string if there is XSS attack
8068
- * @remarks This function checks for patterns like s\nc\nr\ni\np\nt: to prevent XSS attacks. This may block some valid links,
8069
- * but it is necessary for security reasons. We treat the word "script" as safe if there are "/" before it.
8070
- */
8071
- function checkXss(link) {
8072
- return link.match(/^[^\/]*s\n*c\n*r\n*i\n*p\n*t\n*:/i) ? '' : link;
8073
- }
8074
- exports.checkXss = checkXss;
8075
-
8076
-
8077
8051
  /***/ },
8078
8052
 
8079
8053
  /***/ "./packages/roosterjs-content-model-api/lib/publicApi/utils/createEditorContextForEntity.ts"
@@ -8856,7 +8830,6 @@ exports.AllowedTags = [
8856
8830
  'ul',
8857
8831
  'var',
8858
8832
  'wbr',
8859
- 'xmp',
8860
8833
  ];
8861
8834
  /**
8862
8835
  * @internal
@@ -9041,7 +9014,7 @@ function createSanitizedElement(doc, tag, attributes, styleSanitizers, attribute
9041
9014
  var attribute = attributes[i];
9042
9015
  var name_1 = attribute.name.toLowerCase().trim();
9043
9016
  var value = attribute.value;
9044
- var sanitizer = attributeSanitizers === null || attributeSanitizers === void 0 ? void 0 : attributeSanitizers[name_1];
9017
+ var sanitizer = getOwnValue(attributeSanitizers, name_1);
9045
9018
  var newValue = name_1 == 'style'
9046
9019
  ? processStyles(tag, value, styleSanitizers)
9047
9020
  : typeof sanitizer == 'function'
@@ -9053,10 +9026,7 @@ function createSanitizedElement(doc, tag, attributes, styleSanitizers, attribute
9053
9026
  : AllowedAttributes.indexOf(name_1) >= 0 || name_1.indexOf('data-') == 0
9054
9027
  ? value
9055
9028
  : null;
9056
- if (newValue !== null &&
9057
- newValue !== undefined &&
9058
- !newValue.match(/s\n*c\n*r\n*i\n*p\n*t\n*:/i) // match script: with any NewLine inside. Browser will ignore those NewLine char and still treat it as script prefix
9059
- ) {
9029
+ if (newValue !== null && newValue !== undefined && !(0, roosterjs_content_model_dom_1.isUnsafeUrl)(newValue)) {
9060
9030
  element.setAttribute(name_1, newValue);
9061
9031
  }
9062
9032
  }
@@ -9074,7 +9044,7 @@ function processStyles(tagName, value, styleSanitizers) {
9074
9044
  if (isCssVariable(value)) {
9075
9045
  value = processCssVariable(value);
9076
9046
  }
9077
- var sanitizer = styleSanitizers === null || styleSanitizers === void 0 ? void 0 : styleSanitizers[name];
9047
+ var sanitizer = getOwnValue(styleSanitizers, name);
9078
9048
  var sanitizedValue = typeof sanitizer == 'function'
9079
9049
  ? sanitizer(value, tagName)
9080
9050
  : sanitizer === false
@@ -9085,7 +9055,7 @@ function processStyles(tagName, value, styleSanitizers) {
9085
9055
  sanitizedValue != 'initial' &&
9086
9056
  sanitizedValue.indexOf('expression') < 0 &&
9087
9057
  !name.startsWith('-') &&
9088
- DefaultStyleValue[name] != sanitizedValue) {
9058
+ getOwnValue(DefaultStyleValue, name) != sanitizedValue) {
9089
9059
  result.push(name + ":" + sanitizedValue);
9090
9060
  }
9091
9061
  }
@@ -9096,6 +9066,12 @@ function processCssVariable(value) {
9096
9066
  var match = VARIABLE_REGEX.exec(value);
9097
9067
  return (match === null || match === void 0 ? void 0 : match[2]) || ''; // Without fallback value, we don't know what does the original value mean, so ignore it
9098
9068
  }
9069
+ // Attribute and style names come from the pasted content, so a name such as "valueOf" or
9070
+ // "hasOwnProperty" would otherwise resolve to the inherited member of Object.prototype and be
9071
+ // invoked as if it were a sanitizer, which throws and fails the whole conversion.
9072
+ function getOwnValue(map, name) {
9073
+ return map && Object.prototype.hasOwnProperty.call(map, name) ? map[name] : undefined;
9074
+ }
9099
9075
  function isCssVariable(value) {
9100
9076
  return value.indexOf(VARIABLE_PREFIX) == 0;
9101
9077
  }
@@ -11055,6 +11031,33 @@ function findTableCellElement(parsedTable, coordinate) {
11055
11031
  exports.findTableCellElement = findTableCellElement;
11056
11032
 
11057
11033
 
11034
+ /***/ },
11035
+
11036
+ /***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts"
11037
+ /*!****************************************************************************************************!*\
11038
+ !*** ./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts ***!
11039
+ \****************************************************************************************************/
11040
+ (__unused_webpack_module, exports) {
11041
+
11042
+ "use strict";
11043
+
11044
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
11045
+ exports.getTextSelectionStyle = exports.RANGE_SELECTION_CSS_KEY = void 0;
11046
+ /**
11047
+ * @internal
11048
+ */
11049
+ exports.RANGE_SELECTION_CSS_KEY = '_RangeSelection';
11050
+ /**
11051
+ * @internal
11052
+ * Get the text selection style for the current color mode, or null to use browser defaults.
11053
+ */
11054
+ function getTextSelectionStyle(state, isDarkMode) {
11055
+ var color = isDarkMode ? state.textSelectionColorDark : state.textSelectionColor;
11056
+ return color ? "background-color: " + color + " !important; color: currentColor !important;" : null;
11057
+ }
11058
+ exports.getTextSelectionStyle = getTextSelectionStyle;
11059
+
11060
+
11058
11061
  /***/ },
11059
11062
 
11060
11063
  /***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setDOMSelection.ts"
@@ -11072,6 +11075,7 @@ var ensureUniqueId_1 = __webpack_require__(/*! ../setEditorStyle/ensureUniqueId
11072
11075
  var findLastedCoInMergedCell_1 = __webpack_require__(/*! ./findLastedCoInMergedCell */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findLastedCoInMergedCell.ts");
11073
11076
  var findTableCellElement_1 = __webpack_require__(/*! ./findTableCellElement */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findTableCellElement.ts");
11074
11077
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
11078
+ var getTextSelectionStyle_1 = __webpack_require__(/*! ./getTextSelectionStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts");
11075
11079
  var setTableCellsStyle_1 = __webpack_require__(/*! ./setTableCellsStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setTableCellsStyle.ts");
11076
11080
  var toggleCaret_1 = __webpack_require__(/*! ./toggleCaret */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/toggleCaret.ts");
11077
11081
  var DOM_SELECTION_CSS_KEY = '_DOMSelection';
@@ -11096,6 +11100,7 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
11096
11100
  core.selection.skipReselectOnFocus = true;
11097
11101
  core.api.setEditorStyle(core, DOM_SELECTION_CSS_KEY, null /*cssRule*/);
11098
11102
  core.api.setEditorStyle(core, HIDE_SELECTION_CSS_KEY, null /*cssRule*/);
11103
+ core.api.setEditorStyle(core, getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, null /*cssRule*/);
11099
11104
  (0, toggleCaret_1.toggleCaret)(core, false /* hide */);
11100
11105
  try {
11101
11106
  switch (selection === null || selection === void 0 ? void 0 : selection.type) {
@@ -11148,6 +11153,14 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
11148
11153
  }
11149
11154
  break;
11150
11155
  case 'range':
11156
+ var textSelectionStyle = !selection.range.collapsed
11157
+ ? (0, getTextSelectionStyle_1.getTextSelectionStyle)(core.selection, isDarkMode)
11158
+ : null;
11159
+ if (textSelectionStyle) {
11160
+ core.api.setEditorStyle(core, getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, textSelectionStyle, [
11161
+ SELECTION_SELECTOR,
11162
+ ]);
11163
+ }
11151
11164
  core.domHelper.setSelectionRange(selection.range, selection.isReverted);
11152
11165
  core.selection.selection = core.domHelper.hasFocus() ? null : selection;
11153
11166
  break;
@@ -14544,6 +14557,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
14544
14557
  exports.createSelectionPlugin = exports.DEFAULT_TABLE_CELL_SELECTION_BACKGROUND_COLOR = exports.DEFAULT_SELECTION_BORDER_COLOR = void 0;
14545
14558
  var findCoordinate_1 = __webpack_require__(/*! ./findCoordinate */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/findCoordinate.ts");
14546
14559
  var findTableCellElement_1 = __webpack_require__(/*! ../../coreApi/setDOMSelection/findTableCellElement */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findTableCellElement.ts");
14560
+ var getTextSelectionStyle_1 = __webpack_require__(/*! ../../coreApi/setDOMSelection/getTextSelectionStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts");
14547
14561
  var isSingleImageInSelection_1 = __webpack_require__(/*! ./isSingleImageInSelection */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/isSingleImageInSelection.ts");
14548
14562
  var normalizePos_1 = __webpack_require__(/*! ./normalizePos */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/normalizePos.ts");
14549
14563
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
@@ -14663,6 +14677,7 @@ var SelectionPlugin = /** @class */ (function () {
14663
14677
  this.onSelectionChange = function () {
14664
14678
  var _a, _b;
14665
14679
  if (((_a = _this.editor) === null || _a === void 0 ? void 0 : _a.hasFocus()) && !_this.editor.isInShadowEdit()) {
14680
+ _this.editor.setEditorStyle(getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, null /* cssRule */);
14666
14681
  var newSelection = _this.editor.getDOMSelection();
14667
14682
  var domHelper = _this.editor.getDOMHelper();
14668
14683
  // If an image selection changed to a wider range due to a keyboard event, we should update the selection
@@ -14674,22 +14689,31 @@ var SelectionPlugin = /** @class */ (function () {
14674
14689
  var isReverted = sel
14675
14690
  ? sel.focusNode != range.endContainer || sel.focusOffset != range.endOffset
14676
14691
  : false;
14677
- _this.editor.setDOMSelection({
14692
+ newSelection = {
14678
14693
  type: 'range',
14679
14694
  range: range,
14680
14695
  isReverted: isReverted,
14681
- });
14696
+ };
14697
+ _this.editor.setDOMSelection(newSelection);
14682
14698
  }
14683
14699
  else if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) !== 'image' && image) {
14684
- _this.editor.setDOMSelection({
14700
+ newSelection = {
14685
14701
  type: 'image',
14686
14702
  image: image,
14687
- });
14703
+ };
14704
+ _this.editor.setDOMSelection(newSelection);
14688
14705
  }
14689
14706
  }
14690
- // Safari has problem to handle onBlur event. When blur, we cannot get the original selection from editor.
14691
- // So we always save a selection whenever editor has focus. Then after blur, we can still use this cached selection.
14692
14707
  if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) == 'range') {
14708
+ if (!newSelection.range.collapsed) {
14709
+ var textSelectionStyle = (0, getTextSelectionStyle_1.getTextSelectionStyle)(_this.state, _this.editor.isDarkMode());
14710
+ if (textSelectionStyle) {
14711
+ _this.editor.setEditorStyle(getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, textSelectionStyle, [
14712
+ '*::selection',
14713
+ ]);
14714
+ }
14715
+ }
14716
+ // Safari cannot retrieve the original selection on blur, so cache it while focused.
14693
14717
  if (_this.isSafari) {
14694
14718
  _this.state.selection = newSelection;
14695
14719
  }
@@ -14708,12 +14732,20 @@ var SelectionPlugin = /** @class */ (function () {
14708
14732
  ? undefined
14709
14733
  : exports.DEFAULT_TABLE_CELL_SELECTION_BACKGROUND_COLOR,
14710
14734
  };
14735
+ if (options.textSelectionColor) {
14736
+ this.state.textSelectionColor = options.textSelectionColor;
14737
+ }
14711
14738
  }
14712
14739
  SelectionPlugin.prototype.getName = function () {
14713
14740
  return 'Selection';
14714
14741
  };
14715
14742
  SelectionPlugin.prototype.initialize = function (editor) {
14716
14743
  this.editor = editor;
14744
+ if (!this.state.textSelectionColorDark && this.state.textSelectionColor) {
14745
+ this.state.textSelectionColorDark = editor
14746
+ .getColorManager()
14747
+ .getDarkColor(this.state.textSelectionColor, undefined, 'background');
14748
+ }
14717
14749
  if (!this.state.imageSelectionBorderColorDark && this.state.imageSelectionBorderColor) {
14718
14750
  this.state.imageSelectionBorderColorDark = editor
14719
14751
  .getColorManager()
@@ -17511,6 +17543,7 @@ exports.EmptySegmentFormat = {
17511
17543
  letterSpacing: '',
17512
17544
  lineHeight: '',
17513
17545
  strikethrough: false,
17546
+ superOrSubScriptFontSize: '',
17514
17547
  superOrSubScriptSequence: '',
17515
17548
  textColor: '',
17516
17549
  underline: false,
@@ -20630,6 +20663,48 @@ function isNodeOfType(node, expectedType) {
20630
20663
  exports.isNodeOfType = isNodeOfType;
20631
20664
 
20632
20665
 
20666
+ /***/ },
20667
+
20668
+ /***/ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts"
20669
+ /*!**************************************************************************!*\
20670
+ !*** ./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts ***!
20671
+ \**************************************************************************/
20672
+ (__unused_webpack_module, exports) {
20673
+
20674
+ "use strict";
20675
+
20676
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
20677
+ exports.isUnsafeUrl = void 0;
20678
+ var UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];
20679
+ var IgnoredCharacters = /[\t\n\r]/g;
20680
+ var MaxControlCharCode = 0x20;
20681
+ /**
20682
+ * Check whether the given URL uses a protocol that can execute script, such as "javascript:"
20683
+ * @param url The URL to check
20684
+ * @returns True if the URL can execute script when navigated to, otherwise false
20685
+ * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
20686
+ * character or space before they resolve its protocol. Those characters must be removed before the
20687
+ * protocol is checked here, otherwise a value such as "java&#9;script:" or "javascr&#13;ipt:" would
20688
+ * be treated as safe but still executed by the browser.
20689
+ */
20690
+ function isUnsafeUrl(url) {
20691
+ if (!url) {
20692
+ return false;
20693
+ }
20694
+ var normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();
20695
+ var colonIndex = normalizedUrl.indexOf(':');
20696
+ return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;
20697
+ }
20698
+ exports.isUnsafeUrl = isUnsafeUrl;
20699
+ function trimControlCharacters(url) {
20700
+ var start = 0;
20701
+ while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {
20702
+ start++;
20703
+ }
20704
+ return url.substring(start);
20705
+ }
20706
+
20707
+
20633
20708
  /***/ },
20634
20709
 
20635
20710
  /***/ "./packages/roosterjs-content-model-dom/lib/domUtils/isWhiteSpacePreserved.ts"
@@ -23098,6 +23173,7 @@ exports.listStyleFormatHandler = {
23098
23173
 
23099
23174
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23100
23175
  exports.boldFormatHandler = void 0;
23176
+ var isBlockElement_1 = __webpack_require__(/*! ../../domToModel/utils/isBlockElement */ "./packages/roosterjs-content-model-dom/lib/domToModel/utils/isBlockElement.ts");
23101
23177
  var shouldSetValue_1 = __webpack_require__(/*! ../utils/shouldSetValue */ "./packages/roosterjs-content-model-dom/lib/formatHandlers/utils/shouldSetValue.ts");
23102
23178
  var moveChildNodes_1 = __webpack_require__(/*! ../../domUtils/moveChildNodes */ "./packages/roosterjs-content-model-dom/lib/domUtils/moveChildNodes.ts");
23103
23179
  /**
@@ -23117,7 +23193,7 @@ exports.boldFormatHandler = {
23117
23193
  var blockFontWeight = context.implicitFormat.fontWeight;
23118
23194
  if ((blockFontWeight && blockFontWeight != format.fontWeight) ||
23119
23195
  (!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')) {
23120
- if (format.fontWeight == 'bold') {
23196
+ if (format.fontWeight == 'bold' && !(0, isBlockElement_1.isBlockElement)(element)) {
23121
23197
  (0, moveChildNodes_1.wrapAllChildNodes)(element, 'b');
23122
23198
  }
23123
23199
  else {
@@ -23395,6 +23471,7 @@ exports.letterSpacingFormatHandler = {
23395
23471
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23396
23472
  exports.linkFormatHandler = void 0;
23397
23473
  var isElementOfType_1 = __webpack_require__(/*! ../../domUtils/isElementOfType */ "./packages/roosterjs-content-model-dom/lib/domUtils/isElementOfType.ts");
23474
+ var isUnsafeUrl_1 = __webpack_require__(/*! ../../domUtils/isUnsafeUrl */ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts");
23398
23475
  /**
23399
23476
  * @internal
23400
23477
  */
@@ -23411,7 +23488,7 @@ exports.linkFormatHandler = {
23411
23488
  if (name_1) {
23412
23489
  format.name = name_1;
23413
23490
  }
23414
- if (href) {
23491
+ if (href && !(0, isUnsafeUrl_1.isUnsafeUrl)(href)) {
23415
23492
  format.href = href;
23416
23493
  }
23417
23494
  if (target) {
@@ -23433,7 +23510,7 @@ exports.linkFormatHandler = {
23433
23510
  },
23434
23511
  apply: function (format, element) {
23435
23512
  if ((0, isElementOfType_1.isElementOfType)(element, 'a') && (format.href || format.name)) {
23436
- if (format.href) {
23513
+ if (format.href && !(0, isUnsafeUrl_1.isUnsafeUrl)(format.href)) {
23437
23514
  element.href = format.href;
23438
23515
  }
23439
23516
  if (format.name) {
@@ -23510,12 +23587,17 @@ exports.superOrSubScriptFormatHandler = {
23510
23587
  parse: function (format, element, context, defaultStyle) {
23511
23588
  var verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;
23512
23589
  var fontSize = element.style.fontSize || defaultStyle.fontSize;
23513
- if (isSuperOrSubScript(fontSize, verticalAlign)) {
23590
+ var inheritFontSize = (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';
23591
+ if (isSuperOrSubScript(fontSize, verticalAlign) ||
23592
+ (inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))) {
23514
23593
  format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')
23515
23594
  .split(' ')
23516
23595
  .concat(verticalAlign)
23517
23596
  .join(' ')
23518
23597
  .trim();
23598
+ if (inheritFontSize) {
23599
+ format.superOrSubScriptFontSize = 'inherit';
23600
+ }
23519
23601
  }
23520
23602
  },
23521
23603
  apply: function (format, element) {
@@ -23526,7 +23608,10 @@ exports.superOrSubScriptFormatHandler = {
23526
23608
  .forEach(function (value) {
23527
23609
  var tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;
23528
23610
  if (tagName) {
23529
- (0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
23611
+ var wrapper = (0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
23612
+ if (format.superOrSubScriptFontSize) {
23613
+ wrapper.style.fontSize = format.superOrSubScriptFontSize;
23614
+ }
23530
23615
  }
23531
23616
  });
23532
23617
  }
@@ -24198,10 +24283,10 @@ exports.shouldSetValue = shouldSetValue;
24198
24283
  "use strict";
24199
24284
 
24200
24285
  Object.defineProperty(exports, "__esModule", ({ value: true }));
24201
- exports.createImage = exports.createText = exports.createTableCell = exports.createTable = exports.createSelectionMarker = exports.createParagraph = exports.createFormatContainer = exports.createListItem = exports.createBr = exports.isLinkUndeletable = exports.setLinkUndeletable = exports.scrollRectIntoView = exports.normalizeRect = exports.isWhiteSpacePreserved = exports.reuseCachedElement = exports.findClosestBlockEntityContainer = exports.isBlockEntityContainer = exports.isEntityDelimiter = exports.addDelimiters = exports.generateEntityClassNames = exports.parseEntityFormat = exports.getAllEntityWrappers = exports.findClosestEntityWrapper = exports.isEntityElement = exports.unwrap = exports.wrap = exports.wrapAllChildNodes = exports.moveChildNodes = exports.toArray = exports.getSafeIdSelector = exports.getObjectKeys = exports.isElementOfType = exports.isNodeOfType = exports.hasMetadata = exports.getMetadata = exports.updateMetadata = exports.buildSelectionMarker = exports.isBlockElement = exports.areSameFormats = exports.parseFormat = exports.getRegularSelectionOffsets = exports.formatContainerProcessor = exports.tableProcessor = exports.entityProcessor = exports.processChildNode = exports.handleRegularSelection = exports.childProcessor = exports.contentModelToText = exports.contentModelToDom = exports.domToContentModel = void 0;
24202
- exports.getDOMInsertPointRect = exports.getSelectionRootNode = exports.isBold = exports.createModelToDomConfig = exports.createModelToDomContextWithConfig = exports.createModelToDomContext = exports.createDomToModelConfig = exports.createDomToModelContextWithConfig = exports.createDomToModelContext = exports.defaultGenerateColorKey = exports.parseColor = exports.setColor = exports.getColor = exports.DeprecatedColors = exports.BorderKeys = exports.parseValueWithUnit = exports.getAutoListStyleType = exports.getOrderedListNumberStr = exports.ParagraphFormats = exports.ListFormatsToMove = exports.ListFormatsToKeep = exports.ListFormats = exports.copyFormat = exports.setParagraphNotImplicit = exports.normalizeSegmentFormat = exports.mergeTextSegments = exports.normalizeSingleSegment = exports.isEmpty = exports.addSegment = exports.unwrapBlock = exports.isGeneralSegment = exports.normalizeContentModel = exports.normalizeParagraph = exports.addTextSegment = exports.addLink = exports.addData = exports.addCode = exports.addBlock = exports.mutateSegment = exports.mutateSegments = exports.mutateBlock = exports.createTableRow = exports.createEmptyModel = exports.createListLevel = exports.createDivider = exports.createEntity = exports.createGeneralBlock = exports.createGeneralSegment = exports.createParagraphDecorator = exports.createContentModelDocument = void 0;
24203
- exports.retrieveModelFormatState = exports.setTableCellBackgroundColor = exports.MIN_ALLOWED_TABLE_CELL_HEIGHT = exports.MIN_ALLOWED_TABLE_CELL_WIDTH = exports.normalizeTable = exports.setFirstColumnFormatBorders = exports.applyTableFormat = exports.deleteBlock = exports.deleteSegment = exports.deleteSelection = exports.mergeModel = exports.canMergeCells = exports.cloneModelForPaste = exports.cloneModel = exports.setSelection = exports.hasSelectionInBlockGroup = exports.hasSelectionInSegment = exports.hasSelectionInBlock = exports.getSelectedCells = exports.getSelectedSegmentsAndParagraphs = exports.getSelectedSegments = exports.getSelectedParagraphs = exports.getOperationalBlocks = exports.getFirstSelectedTable = exports.getFirstSelectedListItem = exports.iterateSelections = exports.isBlockGroupOfType = exports.getRangesByText = exports.getImageState = exports.setImageState = exports.getParagraphMarker = exports.setParagraphMarker = exports.cacheGetEventData = exports.createPasteFragment = exports.extractClipboardItems = exports.normalizeFontFamily = exports.transformColor = exports.retrieveDocumentMetadata = exports.readFile = exports.parseTableCells = exports.normalizeText = exports.isSpace = exports.isPunctuation = exports.extractBorderValues = exports.combineBorderValue = exports.getNodePositionFromEvent = exports.isCursorMovingKey = exports.isModifierKey = exports.isCharacterValue = exports.trimModelForSelection = void 0;
24204
- exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = exports.getSegmentTextFormat = exports.getListStyleTypeFromString = void 0;
24286
+ exports.createText = exports.createTableCell = exports.createTable = exports.createSelectionMarker = exports.createParagraph = exports.createFormatContainer = exports.createListItem = exports.createBr = exports.isLinkUndeletable = exports.setLinkUndeletable = exports.scrollRectIntoView = exports.normalizeRect = exports.isWhiteSpacePreserved = exports.reuseCachedElement = exports.findClosestBlockEntityContainer = exports.isBlockEntityContainer = exports.isEntityDelimiter = exports.addDelimiters = exports.generateEntityClassNames = exports.parseEntityFormat = exports.getAllEntityWrappers = exports.findClosestEntityWrapper = exports.isEntityElement = exports.unwrap = exports.wrap = exports.wrapAllChildNodes = exports.moveChildNodes = exports.toArray = exports.getSafeIdSelector = exports.getObjectKeys = exports.isUnsafeUrl = exports.isElementOfType = exports.isNodeOfType = exports.hasMetadata = exports.getMetadata = exports.updateMetadata = exports.buildSelectionMarker = exports.isBlockElement = exports.areSameFormats = exports.parseFormat = exports.getRegularSelectionOffsets = exports.formatContainerProcessor = exports.tableProcessor = exports.entityProcessor = exports.processChildNode = exports.handleRegularSelection = exports.childProcessor = exports.contentModelToText = exports.contentModelToDom = exports.domToContentModel = void 0;
24287
+ exports.getSelectionRootNode = exports.isBold = exports.createModelToDomConfig = exports.createModelToDomContextWithConfig = exports.createModelToDomContext = exports.createDomToModelConfig = exports.createDomToModelContextWithConfig = exports.createDomToModelContext = exports.defaultGenerateColorKey = exports.parseColor = exports.setColor = exports.getColor = exports.DeprecatedColors = exports.BorderKeys = exports.parseValueWithUnit = exports.getAutoListStyleType = exports.getOrderedListNumberStr = exports.ParagraphFormats = exports.ListFormatsToMove = exports.ListFormatsToKeep = exports.ListFormats = exports.copyFormat = exports.setParagraphNotImplicit = exports.normalizeSegmentFormat = exports.mergeTextSegments = exports.normalizeSingleSegment = exports.isEmpty = exports.addSegment = exports.unwrapBlock = exports.isGeneralSegment = exports.normalizeContentModel = exports.normalizeParagraph = exports.addTextSegment = exports.addLink = exports.addData = exports.addCode = exports.addBlock = exports.mutateSegment = exports.mutateSegments = exports.mutateBlock = exports.createTableRow = exports.createEmptyModel = exports.createListLevel = exports.createDivider = exports.createEntity = exports.createGeneralBlock = exports.createGeneralSegment = exports.createParagraphDecorator = exports.createContentModelDocument = exports.createImage = void 0;
24288
+ exports.setTableCellBackgroundColor = exports.MIN_ALLOWED_TABLE_CELL_HEIGHT = exports.MIN_ALLOWED_TABLE_CELL_WIDTH = exports.normalizeTable = exports.setFirstColumnFormatBorders = exports.applyTableFormat = exports.deleteBlock = exports.deleteSegment = exports.deleteSelection = exports.mergeModel = exports.canMergeCells = exports.cloneModelForPaste = exports.cloneModel = exports.setSelection = exports.hasSelectionInBlockGroup = exports.hasSelectionInSegment = exports.hasSelectionInBlock = exports.getSelectedCells = exports.getSelectedSegmentsAndParagraphs = exports.getSelectedSegments = exports.getSelectedParagraphs = exports.getOperationalBlocks = exports.getFirstSelectedTable = exports.getFirstSelectedListItem = exports.iterateSelections = exports.isBlockGroupOfType = exports.getRangesByText = exports.getImageState = exports.setImageState = exports.getParagraphMarker = exports.setParagraphMarker = exports.cacheGetEventData = exports.createPasteFragment = exports.extractClipboardItems = exports.normalizeFontFamily = exports.transformColor = exports.retrieveDocumentMetadata = exports.readFile = exports.parseTableCells = exports.normalizeText = exports.isSpace = exports.isPunctuation = exports.extractBorderValues = exports.combineBorderValue = exports.getNodePositionFromEvent = exports.isCursorMovingKey = exports.isModifierKey = exports.isCharacterValue = exports.trimModelForSelection = exports.getDOMInsertPointRect = void 0;
24289
+ exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = exports.getSegmentTextFormat = exports.getListStyleTypeFromString = exports.retrieveModelFormatState = void 0;
24205
24290
  var domToContentModel_1 = __webpack_require__(/*! ./domToModel/domToContentModel */ "./packages/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts");
24206
24291
  Object.defineProperty(exports, "domToContentModel", ({ enumerable: true, get: function () { return domToContentModel_1.domToContentModel; } }));
24207
24292
  var contentModelToDom_1 = __webpack_require__(/*! ./modelToDom/contentModelToDom */ "./packages/roosterjs-content-model-dom/lib/modelToDom/contentModelToDom.ts");
@@ -24236,6 +24321,8 @@ var isNodeOfType_1 = __webpack_require__(/*! ./domUtils/isNodeOfType */ "./packa
24236
24321
  Object.defineProperty(exports, "isNodeOfType", ({ enumerable: true, get: function () { return isNodeOfType_1.isNodeOfType; } }));
24237
24322
  var isElementOfType_1 = __webpack_require__(/*! ./domUtils/isElementOfType */ "./packages/roosterjs-content-model-dom/lib/domUtils/isElementOfType.ts");
24238
24323
  Object.defineProperty(exports, "isElementOfType", ({ enumerable: true, get: function () { return isElementOfType_1.isElementOfType; } }));
24324
+ var isUnsafeUrl_1 = __webpack_require__(/*! ./domUtils/isUnsafeUrl */ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts");
24325
+ Object.defineProperty(exports, "isUnsafeUrl", ({ enumerable: true, get: function () { return isUnsafeUrl_1.isUnsafeUrl; } }));
24239
24326
  var getObjectKeys_1 = __webpack_require__(/*! ./domUtils/getObjectKeys */ "./packages/roosterjs-content-model-dom/lib/domUtils/getObjectKeys.ts");
24240
24327
  Object.defineProperty(exports, "getObjectKeys", ({ enumerable: true, get: function () { return getObjectKeys_1.getObjectKeys; } }));
24241
24328
  var getSafeIdSelector_1 = __webpack_require__(/*! ./domUtils/getSafeIdSelector */ "./packages/roosterjs-content-model-dom/lib/domUtils/getSafeIdSelector.ts");
@@ -25460,9 +25547,9 @@ exports.normalizeSegmentFormat = normalizeSegmentFormat;
25460
25547
  Object.defineProperty(exports, "__esModule", ({ value: true }));
25461
25548
  exports.stripInvisibleUnicode = void 0;
25462
25549
  // According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
25463
- // there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.
25550
+ // there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.
25464
25551
  // We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
25465
- var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{EFFFF}]/gu;
25552
+ var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{E007F}]/gu;
25466
25553
  /**
25467
25554
  * @internal
25468
25555
  * Strip invisible unicode characters from the given string
@@ -27443,21 +27530,22 @@ var KeysOfSegmentFormat = (0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_
27443
27530
  * @returns Insert point after merge, or null if there is no insert point
27444
27531
  */
27445
27532
  function mergeModel(target, source, context, options) {
27446
- var _a, _b;
27533
+ var _a, _b, _c;
27447
27534
  var insertPosition = (_a = options === null || options === void 0 ? void 0 : options.insertPosition) !== null && _a !== void 0 ? _a : (0, deleteSelection_1.deleteSelection)(target, [], context).insertPoint;
27448
- var _c = options || {}, addParagraphAfterMergedContent = _c.addParagraphAfterMergedContent, mergeFormat = _c.mergeFormat, mergeParagraphAfterList = _c.mergeParagraphAfterList, mergeTable = _c.mergeTable;
27535
+ var _d = options || {}, addParagraphAfterMergedContent = _d.addParagraphAfterMergedContent, mergeFormat = _d.mergeFormat, mergeParagraphAfterList = _d.mergeParagraphAfterList, mergeTable = _d.mergeTable;
27449
27536
  if (mergeParagraphAfterList && insertPosition && ((_b = source.blocks[0]) === null || _b === void 0 ? void 0 : _b.blockType) == 'Paragraph') {
27450
27537
  moveParagraphAfterListIntoList(insertPosition);
27451
27538
  }
27452
27539
  if (addParagraphAfterMergedContent && !mergeTable) {
27453
- var _d = insertPosition || {}, paragraph = _d.paragraph, marker = _d.marker;
27540
+ var _e = insertPosition || {}, paragraph = _e.paragraph, marker = _e.marker;
27454
27541
  var newPara = (0, createParagraph_1.createParagraph)(false /* isImplicit */, paragraph === null || paragraph === void 0 ? void 0 : paragraph.format, marker === null || marker === void 0 ? void 0 : marker.format);
27455
27542
  (0, addBlock_1.addBlock)(source, newPara);
27456
27543
  }
27457
27544
  if (insertPosition) {
27458
27545
  if (mergeFormat && mergeFormat != 'none') {
27459
- var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})), insertPosition.marker.format);
27460
- applyDefaultFormat(source, newFormat, mergeFormat);
27546
+ var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})), ((options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator)
27547
+ ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (_c = insertPosition.paragraph.decorator) === null || _c === void 0 ? void 0 : _c.format), insertPosition.paragraph.segmentFormat) : undefined)), insertPosition.marker.format);
27548
+ applyDefaultFormat(source, newFormat, mergeFormat, options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator);
27461
27549
  }
27462
27550
  for (var i = 0; i < source.blocks.length; i++) {
27463
27551
  var block = source.blocks[i];
@@ -27735,7 +27823,7 @@ function insertBlock(markerPosition, block) {
27735
27823
  (0, mutate_1.mutateBlock)(path[0]).blocks.splice(blockIndex, 0, block);
27736
27824
  }
27737
27825
  }
27738
- function applyDefaultFormat(group, format, applyDefaultFormatOption) {
27826
+ function applyDefaultFormat(group, format, applyDefaultFormatOption, preserveParagraphDecorator) {
27739
27827
  group.blocks.forEach(function (block) {
27740
27828
  var _a;
27741
27829
  mergeBlockFormat(applyDefaultFormatOption, block);
@@ -27744,28 +27832,32 @@ function applyDefaultFormat(group, format, applyDefaultFormatOption) {
27744
27832
  if (block.blockGroupType == 'ListItem') {
27745
27833
  (0, mutate_1.mutateBlock)(block).formatHolder.format = mergeSegmentFormat(applyDefaultFormatOption, format, block.formatHolder.format);
27746
27834
  }
27747
- applyDefaultFormat(block, format, applyDefaultFormatOption);
27835
+ applyDefaultFormat(block, format, applyDefaultFormatOption, preserveParagraphDecorator);
27748
27836
  break;
27749
27837
  case 'Table':
27750
27838
  block.rows.forEach(function (row) {
27751
27839
  return row.cells.forEach(function (cell) {
27752
- applyDefaultFormat(cell, format, applyDefaultFormatOption);
27840
+ applyDefaultFormat(cell, format, applyDefaultFormatOption, preserveParagraphDecorator);
27753
27841
  });
27754
27842
  });
27755
27843
  break;
27756
27844
  case 'Paragraph':
27757
27845
  var paragraphFormat_1 = ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.format) || {};
27758
27846
  var paragraph = (0, mutate_1.mutateBlock)(block);
27847
+ var paragraphTargetFormat_1 = applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
27848
+ preserveParagraphDecorator
27849
+ ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, format), paragraphFormat_1) : format;
27759
27850
  paragraph.segments.forEach(function (segment) {
27760
27851
  if (segment.segmentType == 'General') {
27761
- applyDefaultFormat(segment, format, applyDefaultFormatOption);
27852
+ applyDefaultFormat(segment, format, applyDefaultFormatOption, preserveParagraphDecorator);
27762
27853
  }
27763
- segment.format = mergeSegmentFormat(applyDefaultFormatOption, format, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
27854
+ segment.format = mergeSegmentFormat(applyDefaultFormatOption, paragraphTargetFormat_1, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
27764
27855
  if (segment.link) {
27765
27856
  segment.link.format = mergeLinkFormat(applyDefaultFormatOption, format, segment.link.format);
27766
27857
  }
27767
27858
  });
27768
- if (applyDefaultFormatOption === 'keepSourceEmphasisFormat') {
27859
+ if (applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
27860
+ !preserveParagraphDecorator) {
27769
27861
  delete paragraph.decorator;
27770
27862
  }
27771
27863
  break;
@@ -27815,7 +27907,7 @@ function mergeSegmentFormat(applyDefaultFormatOption, targetFormat, sourceFormat
27815
27907
  }
27816
27908
  function getSemanticFormat(segmentFormat) {
27817
27909
  var result = {};
27818
- var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline;
27910
+ var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline, strikethrough = segmentFormat.strikethrough;
27819
27911
  if (fontWeight && fontWeight != 'normal') {
27820
27912
  result.fontWeight = fontWeight;
27821
27913
  }
@@ -27825,6 +27917,9 @@ function getSemanticFormat(segmentFormat) {
27825
27917
  if (underline) {
27826
27918
  result.underline = underline;
27827
27919
  }
27920
+ if (strikethrough) {
27921
+ result.strikethrough = strikethrough;
27922
+ }
27828
27923
  return result;
27829
27924
  }
27830
27925
  /**
@@ -31816,11 +31911,27 @@ exports.createTableFromMarkdown = void 0;
31816
31911
  var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
31817
31912
  var createParagraphFromMarkdown_1 = __webpack_require__(/*! ./createParagraphFromMarkdown */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/creators/createParagraphFromMarkdown.ts");
31818
31913
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
31914
+ var DefaultMarkdownTable = {
31915
+ headerRowColor: null,
31916
+ topBorderColor: '#000',
31917
+ bottomBorderColor: '#000',
31918
+ verticalBorderColor: '#000',
31919
+ tableBorderFormat: roosterjs_content_model_dom_1.TableBorderFormat.Default,
31920
+ headerRowCustomStyles: {
31921
+ fontWeight: 'normal',
31922
+ italic: false,
31923
+ },
31924
+ firstColumnCustomStyles: {
31925
+ fontWeight: 'normal',
31926
+ italic: false,
31927
+ },
31928
+ };
31819
31929
  /**
31820
31930
  * @internal
31821
31931
  */
31822
31932
  function createTableFromMarkdown(tableLines, options) {
31823
31933
  var e_1, _a;
31934
+ var _b;
31824
31935
  var tableDivider = tableLines[1].split('|').filter(function (content) { return content.trim() !== ''; });
31825
31936
  tableLines.splice(1, 1);
31826
31937
  var table = (0, roosterjs_content_model_dom_1.createTable)(0, options.direction
@@ -31839,9 +31950,7 @@ function createTableFromMarkdown(tableLines, options) {
31839
31950
  }
31840
31951
  finally { if (e_1) throw e_1.error; }
31841
31952
  }
31842
- (0, roosterjs_content_model_dom_1.applyTableFormat)(table, {
31843
- hasHeaderRow: true,
31844
- });
31953
+ (0, roosterjs_content_model_dom_1.applyTableFormat)(table, (_b = options.tableStyles) !== null && _b !== void 0 ? _b : DefaultMarkdownTable);
31845
31954
  return table;
31846
31955
  }
31847
31956
  exports.createTableFromMarkdown = createTableFromMarkdown;
@@ -32821,12 +32930,16 @@ exports.modelProcessor = modelProcessor;
32821
32930
 
32822
32931
  Object.defineProperty(exports, "__esModule", ({ value: true }));
32823
32932
  exports.MarkdownPastePlugin = void 0;
32933
+ var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
32824
32934
  var convertMarkdownToContentModel_1 = __webpack_require__(/*! ../markdownToModel/convertMarkdownToContentModel */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/convertMarkdownToContentModel.ts");
32825
32935
  var isPastedContentMarkdown_1 = __webpack_require__(/*! ../publicApi/isPastedContentMarkdown */ "./packages/roosterjs-content-model-markdown/lib/publicApi/isPastedContentMarkdown.ts");
32826
32936
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
32827
32937
  var DefaultOptions = {
32828
32938
  autoConversion: false,
32829
32939
  undoConversion: false,
32940
+ markdownToModelOptions: {
32941
+ emptyLine: 'merge',
32942
+ },
32830
32943
  };
32831
32944
  /**
32832
32945
  * Markdown paste plugin. Handles the BeforePaste event and, when the pasted content
@@ -32839,8 +32952,9 @@ var MarkdownPastePlugin = /** @class */ (function () {
32839
32952
  * @param options Options to control the markdown paste behavior
32840
32953
  */
32841
32954
  function MarkdownPastePlugin(options) {
32955
+ var _a, _b;
32842
32956
  this.editor = null;
32843
- this.options = options !== null && options !== void 0 ? options : DefaultOptions;
32957
+ this.options = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions), options), { markdownToModelOptions: (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions.markdownToModelOptions), options === null || options === void 0 ? void 0 : options.markdownToModelOptions), { emptyLine: (_b = (_a = options === null || options === void 0 ? void 0 : options.markdownToModelOptions) === null || _a === void 0 ? void 0 : _a.emptyLine) !== null && _b !== void 0 ? _b : 'merge' }) });
32844
32958
  }
32845
32959
  /**
32846
32960
  * Get name of this plugin
@@ -32885,10 +32999,9 @@ var MarkdownPastePlugin = /** @class */ (function () {
32885
32999
  (0, isPastedContentMarkdown_1.isPastedContentMarkdown)(this.editor, clipboardData) &&
32886
33000
  clipboardData.modelBeforePaste) {
32887
33001
  var modelBeforePaste_1 = (0, roosterjs_content_model_dom_1.cloneModelForPaste)(clipboardData.modelBeforePaste);
32888
- (0, roosterjs_content_model_dom_1.mergeModel)(modelBeforePaste_1, (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(clipboardData.text, {
32889
- emptyLine: 'merge',
32890
- }), undefined /*context*/, {
32891
- mergeFormat: 'preferTarget',
33002
+ (0, roosterjs_content_model_dom_1.mergeModel)(modelBeforePaste_1, (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(clipboardData.text, this.options.markdownToModelOptions), undefined /*context*/, {
33003
+ mergeFormat: 'keepSourceEmphasisFormat',
33004
+ preserveParagraphDecorator: true,
32892
33005
  });
32893
33006
  if (this.options.undoConversion) {
32894
33007
  this.editor.takeSnapshot();
@@ -32906,17 +33019,15 @@ var MarkdownPastePlugin = /** @class */ (function () {
32906
33019
  else if (event.eventType === 'beforePaste' && !event.clipboardData.pasteNativeEvent) {
32907
33020
  var shouldConvert = event.pasteType === 'asMarkdown';
32908
33021
  if (shouldConvert && (0, isPastedContentMarkdown_1.isPastedContentMarkdown)(this.editor, event.clipboardData)) {
32909
- convertPastedTextToMarkdown(this.editor, event.fragment, event.clipboardData.text);
33022
+ convertPastedTextToMarkdown(this.editor, event.fragment, event.clipboardData.text, this.options.markdownToModelOptions);
32910
33023
  }
32911
33024
  }
32912
33025
  };
32913
33026
  return MarkdownPastePlugin;
32914
33027
  }());
32915
33028
  exports.MarkdownPastePlugin = MarkdownPastePlugin;
32916
- function convertPastedTextToMarkdown(editor, fragment, text) {
32917
- var model = (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(text, {
32918
- emptyLine: 'merge',
32919
- });
33029
+ function convertPastedTextToMarkdown(editor, fragment, text, markdownToModelOptions) {
33030
+ var model = (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(text, markdownToModelOptions);
32920
33031
  while (fragment.firstChild) {
32921
33032
  fragment.removeChild(fragment.firstChild);
32922
33033
  }
@@ -36407,6 +36518,9 @@ function handleTabOnParagraph(model, paragraph, rawEvent, context) {
36407
36518
  return false;
36408
36519
  }
36409
36520
  }
36521
+ else {
36522
+ return false;
36523
+ }
36410
36524
  }
36411
36525
  }
36412
36526
  }
@@ -37566,6 +37680,211 @@ var HyperlinkPlugin = /** @class */ (function () {
37566
37680
  exports.HyperlinkPlugin = HyperlinkPlugin;
37567
37681
 
37568
37682
 
37683
+ /***/ },
37684
+
37685
+ /***/ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts"
37686
+ /*!***************************************************************************************************!*\
37687
+ !*** ./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts ***!
37688
+ \***************************************************************************************************/
37689
+ (__unused_webpack_module, exports, __webpack_require__) {
37690
+
37691
+ "use strict";
37692
+
37693
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
37694
+ exports.ImageCropKeyboardHelper = void 0;
37695
+ var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
37696
+ var cropperContext_1 = __webpack_require__(/*! ./cropperContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/cropperContext.ts");
37697
+ var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
37698
+ var DefaultTopLeftLabel = 'Top left';
37699
+ var DefaultBottomRightLabel = 'Bottom right';
37700
+ var DefaultMoveCropLabel = 'Move Crop';
37701
+ var FocusTargetAttributes = [
37702
+ 'tabindex',
37703
+ 'contenteditable',
37704
+ 'role',
37705
+ 'aria-label',
37706
+ 'aria-describedby',
37707
+ 'part',
37708
+ ];
37709
+ /**
37710
+ * @internal
37711
+ * Keyboard cropping shares the pointer handler's geometry and constraints.
37712
+ */
37713
+ var ImageCropKeyboardHelper = /** @class */ (function () {
37714
+ function ImageCropKeyboardHelper(wrapper, imageId, editInfo, options, onCrop, onFinish) {
37715
+ var _this = this;
37716
+ this.wrapper = wrapper;
37717
+ this.editInfo = editInfo;
37718
+ this.options = options;
37719
+ this.onCrop = onCrop;
37720
+ this.onFinish = onFinish;
37721
+ this.cropFocusTargets = [];
37722
+ this.disposed = false;
37723
+ this.stopPropagation = function (event) {
37724
+ if (_this.contains(event.target)) {
37725
+ event.stopPropagation();
37726
+ }
37727
+ };
37728
+ this.onFocusOut = function (event) {
37729
+ if (!_this.disposed && _this.contains(event.target) && !_this.contains(event.relatedTarget)) {
37730
+ _this.onFinish(true, false);
37731
+ }
37732
+ };
37733
+ this.onKeyDown = function (event) {
37734
+ if (!_this.contains(event.target)) {
37735
+ return;
37736
+ }
37737
+ event.stopPropagation();
37738
+ if (event.key == 'Tab') {
37739
+ var index = _this.cropFocusTargets.findIndex(function (target) { return target === event.target; });
37740
+ var next = _this.cropFocusTargets[index + (event.shiftKey ? -1 : 1)];
37741
+ if (next) {
37742
+ event.preventDefault();
37743
+ next.focus();
37744
+ }
37745
+ }
37746
+ else if (event.key == 'Enter' || event.key == 'Escape') {
37747
+ event.preventDefault();
37748
+ _this.onFinish(event.key == 'Enter', true);
37749
+ }
37750
+ else if (event.key == 'ArrowLeft' ||
37751
+ event.key == 'ArrowRight' ||
37752
+ event.key == 'ArrowUp' ||
37753
+ event.key == 'ArrowDown') {
37754
+ event.preventDefault();
37755
+ if (!event.ctrlKey && !event.metaKey && !event.altKey) {
37756
+ _this.crop(event);
37757
+ }
37758
+ }
37759
+ else if (event.key == ' ' || event.key == 'Delete' || event.key == 'Backspace') {
37760
+ event.preventDefault();
37761
+ }
37762
+ };
37763
+ var cropLabels = options.cropLabels;
37764
+ if (cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.instructions) {
37765
+ this.instructions = this.createInstructions(imageId, cropLabels.instructions);
37766
+ wrapper.appendChild(this.instructions);
37767
+ }
37768
+ ['nw', 'se'].forEach(function (direction) {
37769
+ var _a;
37770
+ var handle = wrapper.querySelector("." + ImageEditElementClass_1.ImageEditElementClass.CropHandle + "[data-y=\"" + direction[0] + "\"][data-x=\"" + direction[1] + "\"]");
37771
+ if (handle) {
37772
+ _this.prepareTarget(handle, ((_a = cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.handleLabel) === null || _a === void 0 ? void 0 : _a.call(cropLabels, direction)) ||
37773
+ (direction == 'nw' ? DefaultTopLeftLabel : DefaultBottomRightLabel));
37774
+ }
37775
+ });
37776
+ this.cropMoveTarget = wrapper.querySelector("." + ImageEditElementClass_1.ImageEditElementClass.ImageBorder);
37777
+ if (this.cropMoveTarget) {
37778
+ wrapper.appendChild(this.cropMoveTarget);
37779
+ this.prepareTarget(this.cropMoveTarget, (cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.moveCropLabel) || DefaultMoveCropLabel);
37780
+ }
37781
+ // Make native tab entry start at the top-left corner as well.
37782
+ var first = this.cropFocusTargets[0];
37783
+ if (first === null || first === void 0 ? void 0 : first.parentElement) {
37784
+ first.parentElement.insertBefore(first, first.parentElement.firstChild);
37785
+ }
37786
+ wrapper.addEventListener('keydown', this.onKeyDown);
37787
+ wrapper.addEventListener('keyup', this.stopPropagation);
37788
+ wrapper.addEventListener('keypress', this.stopPropagation);
37789
+ wrapper.addEventListener('focusout', this.onFocusOut);
37790
+ }
37791
+ ImageCropKeyboardHelper.prototype.focus = function () {
37792
+ var _a;
37793
+ (_a = this.cropFocusTargets[0]) === null || _a === void 0 ? void 0 : _a.focus();
37794
+ };
37795
+ ImageCropKeyboardHelper.prototype.contains = function (target) {
37796
+ return this.cropFocusTargets.some(function (element) { return element === target; });
37797
+ };
37798
+ ImageCropKeyboardHelper.prototype.dispose = function () {
37799
+ var e_1, _a, e_2, _b;
37800
+ var _c;
37801
+ this.disposed = true;
37802
+ this.wrapper.removeEventListener('keydown', this.onKeyDown);
37803
+ this.wrapper.removeEventListener('keyup', this.stopPropagation);
37804
+ this.wrapper.removeEventListener('keypress', this.stopPropagation);
37805
+ this.wrapper.removeEventListener('focusout', this.onFocusOut);
37806
+ try {
37807
+ for (var _d = (0, tslib_1.__values)(this.cropFocusTargets), _e = _d.next(); !_e.done; _e = _d.next()) {
37808
+ var target = _e.value;
37809
+ try {
37810
+ for (var FocusTargetAttributes_1 = (e_2 = void 0, (0, tslib_1.__values)(FocusTargetAttributes)), FocusTargetAttributes_1_1 = FocusTargetAttributes_1.next(); !FocusTargetAttributes_1_1.done; FocusTargetAttributes_1_1 = FocusTargetAttributes_1.next()) {
37811
+ var attribute = FocusTargetAttributes_1_1.value;
37812
+ target.removeAttribute(attribute);
37813
+ }
37814
+ }
37815
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
37816
+ finally {
37817
+ try {
37818
+ if (FocusTargetAttributes_1_1 && !FocusTargetAttributes_1_1.done && (_b = FocusTargetAttributes_1.return)) _b.call(FocusTargetAttributes_1);
37819
+ }
37820
+ finally { if (e_2) throw e_2.error; }
37821
+ }
37822
+ target.classList.remove(ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
37823
+ }
37824
+ }
37825
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
37826
+ finally {
37827
+ try {
37828
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
37829
+ }
37830
+ finally { if (e_1) throw e_1.error; }
37831
+ }
37832
+ (_c = this.instructions) === null || _c === void 0 ? void 0 : _c.remove();
37833
+ };
37834
+ ImageCropKeyboardHelper.prototype.createInstructions = function (imageId, text) {
37835
+ var instructions = this.wrapper.ownerDocument.createElement('span');
37836
+ instructions.id = 'imageCropInstructions' + imageId;
37837
+ instructions.textContent = text;
37838
+ instructions.style.cssText =
37839
+ 'position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;';
37840
+ return instructions;
37841
+ };
37842
+ ImageCropKeyboardHelper.prototype.prepareTarget = function (target, label) {
37843
+ target.tabIndex = 0;
37844
+ target.contentEditable = 'false';
37845
+ target.setAttribute('role', 'application');
37846
+ if (label) {
37847
+ target.setAttribute('aria-label', label);
37848
+ }
37849
+ if (this.instructions) {
37850
+ target.setAttribute('aria-describedby', this.instructions.id);
37851
+ }
37852
+ target.classList.add(ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
37853
+ target.setAttribute('part', ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
37854
+ this.cropFocusTargets.push(target);
37855
+ };
37856
+ ImageCropKeyboardHelper.prototype.crop = function (event) {
37857
+ var _a, _b;
37858
+ var target = this.cropFocusTargets.find(function (element) { return element === event.target; });
37859
+ var context = {
37860
+ editInfo: this.editInfo,
37861
+ options: this.options,
37862
+ elementClass: target === this.cropMoveTarget
37863
+ ? ImageEditElementClass_1.ImageEditElementClass.CropContainer
37864
+ : ImageEditElementClass_1.ImageEditElementClass.CropHandle,
37865
+ x: (target === null || target === void 0 ? void 0 : target.dataset.x) == 'e' ? 'e' : (target === null || target === void 0 ? void 0 : target.dataset.x) == 'w' ? 'w' : '',
37866
+ y: (target === null || target === void 0 ? void 0 : target.dataset.y) == 'n' ? 'n' : (target === null || target === void 0 ? void 0 : target.dataset.y) == 's' ? 's' : '',
37867
+ };
37868
+ var dragEvent = {
37869
+ clientX: 0,
37870
+ clientY: 0,
37871
+ pageX: 0,
37872
+ pageY: 0,
37873
+ target: event.target,
37874
+ shiftKey: event.shiftKey,
37875
+ altKey: event.altKey,
37876
+ };
37877
+ var base = (_a = cropperContext_1.Cropper.onDragStart) === null || _a === void 0 ? void 0 : _a.call(cropperContext_1.Cropper, context, dragEvent);
37878
+ if (base &&
37879
+ ((_b = cropperContext_1.Cropper.onDragging) === null || _b === void 0 ? void 0 : _b.call(cropperContext_1.Cropper, context, dragEvent, base, event.key == 'ArrowLeft' ? -1 : event.key == 'ArrowRight' ? 1 : 0, event.key == 'ArrowUp' ? -1 : event.key == 'ArrowDown' ? 1 : 0))) {
37880
+ this.onCrop();
37881
+ }
37882
+ };
37883
+ return ImageCropKeyboardHelper;
37884
+ }());
37885
+ exports.ImageCropKeyboardHelper = ImageCropKeyboardHelper;
37886
+
37887
+
37569
37888
  /***/ },
37570
37889
 
37571
37890
  /***/ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/createImageCropper.ts"
@@ -37670,6 +37989,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
37670
37989
  exports.Cropper = void 0;
37671
37990
  var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
37672
37991
  var imageEditUtils_1 = __webpack_require__(/*! ../utils/imageEditUtils */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/imageEditUtils.ts");
37992
+ var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
37673
37993
  /**
37674
37994
  * @internal
37675
37995
  * Crop handle for DragAndDropHelper
@@ -37682,7 +38002,7 @@ exports.Cropper = {
37682
38002
  onDragging: function (_a, e, base, dx, dy) {
37683
38003
  var _b;
37684
38004
  var _c;
37685
- var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options;
38005
+ var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options, elementClass = _a.elementClass;
37686
38006
  _b = (0, tslib_1.__read)((0, imageEditUtils_1.rotateCoordinate)(dx, dy, (_c = editInfo.angleRad) !== null && _c !== void 0 ? _c : 0), 2), dx = _b[0], dy = _b[1];
37687
38007
  var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, bottomPercent = editInfo.bottomPercent;
37688
38008
  if (leftPercent === undefined ||
@@ -37706,6 +38026,15 @@ exports.Cropper = {
37706
38026
  minHeight !== undefined) {
37707
38027
  var fullWidth = widthPx / widthPercent;
37708
38028
  var fullHeight = heightPx / heightPercent;
38029
+ if (elementClass == ImageEditElementClass_1.ImageEditElementClass.CropContainer) {
38030
+ var deltaX = Math.max(-base.leftPercent, Math.min(dx / fullWidth, base.rightPercent));
38031
+ var deltaY = Math.max(-base.topPercent, Math.min(dy / fullHeight, base.bottomPercent));
38032
+ editInfo.leftPercent = base.leftPercent + deltaX;
38033
+ editInfo.rightPercent = base.rightPercent - deltaX;
38034
+ editInfo.topPercent = base.topPercent + deltaY;
38035
+ editInfo.bottomPercent = base.bottomPercent - deltaY;
38036
+ return true;
38037
+ }
37709
38038
  var newLeft = x != 'e'
37710
38039
  ? crop(base.leftPercent, dx, fullWidth, rightPercent, minWidth)
37711
38040
  : leftPercent;
@@ -37764,6 +38093,7 @@ var getHTMLImageOptions_1 = __webpack_require__(/*! ./utils/getHTMLImageOptions
37764
38093
  var getSelectedImage_1 = __webpack_require__(/*! ./utils/getSelectedImage */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/getSelectedImage.ts");
37765
38094
  var updateImageEditInfo_1 = __webpack_require__(/*! ./utils/updateImageEditInfo */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/updateImageEditInfo.ts");
37766
38095
  var ImageEditElementClass_1 = __webpack_require__(/*! ./types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
38096
+ var ImageCropKeyboardHelper_1 = __webpack_require__(/*! ./Cropper/ImageCropKeyboardHelper */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts");
37767
38097
  var normalizeImageSelection_1 = __webpack_require__(/*! ./utils/normalizeImageSelection */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/normalizeImageSelection.ts");
37768
38098
  var resizerContext_1 = __webpack_require__(/*! ./Resizer/resizerContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Resizer/resizerContext.ts");
37769
38099
  var rotatorContext_1 = __webpack_require__(/*! ./Rotator/rotatorContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Rotator/rotatorContext.ts");
@@ -37784,6 +38114,7 @@ var MouseRightButton = 2;
37784
38114
  var DRAG_ID = '_dragging';
37785
38115
  var IMAGE_EDIT_CLASS = 'imageEdit';
37786
38116
  var IMAGE_EDIT_CLASS_CARET = 'imageEditCaretColor';
38117
+ var IMAGE_EDIT_CLASS_CROP_KEYBOARD = 'imageEditCropKeyboard';
37787
38118
  var IMAGE_EDIT_FORMAT_EVENT = 'ImageEditEvent';
37788
38119
  /**
37789
38120
  * ImageEdit plugin handles the following image editing features:
@@ -37791,6 +38122,10 @@ var IMAGE_EDIT_FORMAT_EVENT = 'ImageEditEvent';
37791
38122
  * - Crop image
37792
38123
  * - Rotate image
37793
38124
  * - Flip image
38125
+ *
38126
+ * In crop mode, Tab focuses the top-left corner, bottom-right corner, then the
38127
+ * whole image. Arrow keys crop at corners or move the fixed-size crop viewport
38128
+ * by one pixel. Enter applies the crop; Escape cancels it.
37794
38129
  */
37795
38130
  var ImageEditPlugin = /** @class */ (function () {
37796
38131
  function ImageEditPlugin(options) {
@@ -37810,6 +38145,7 @@ var ImageEditPlugin = /** @class */ (function () {
37810
38145
  this.croppers = [];
37811
38146
  this.zoomScale = 1;
37812
38147
  this.disposer = null;
38148
+ this.cropKeyboardHelper = null;
37813
38149
  this.isEditing = false;
37814
38150
  this.options = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions), options);
37815
38151
  }
@@ -37829,8 +38165,19 @@ var ImageEditPlugin = /** @class */ (function () {
37829
38165
  var _this = this;
37830
38166
  this.editor = editor;
37831
38167
  this.disposer = editor.attachDomEvent({
38168
+ keydown: {
38169
+ capture: true,
38170
+ beforeDispatch: function (ev) {
38171
+ _this.focusCropHandle(ev);
38172
+ },
38173
+ },
37832
38174
  blur: {
37833
- beforeDispatch: function () {
38175
+ beforeDispatch: function (ev) {
38176
+ if (_this.cropKeyboardHelper &&
38177
+ (ev.relatedTarget === _this.shadowSpan ||
38178
+ _this.cropKeyboardHelper.contains(ev.relatedTarget))) {
38179
+ return;
38180
+ }
37834
38181
  if (_this.isEditing && _this.editor && !_this.editor.isDisposed()) {
37835
38182
  _this.applyFormatWithContentModel(_this.editor, _this.isCropMode, true /* shouldSelectImage */);
37836
38183
  }
@@ -37965,6 +38312,11 @@ var ImageEditPlugin = /** @class */ (function () {
37965
38312
  };
37966
38313
  ImageEditPlugin.prototype.keyDownHandler = function (editor, event) {
37967
38314
  if (this.isEditing) {
38315
+ if (this.cropKeyboardHelper &&
38316
+ (this.cropKeyboardHelper.contains(event.rawEvent.composedPath()[0]) ||
38317
+ this.focusCropHandle(event.rawEvent))) {
38318
+ return;
38319
+ }
37968
38320
  if (event.rawEvent.key === 'Escape' ||
37969
38321
  event.rawEvent.key === 'Delete' ||
37970
38322
  event.rawEvent.key === 'Backspace') {
@@ -37981,6 +38333,19 @@ var ImageEditPlugin = /** @class */ (function () {
37981
38333
  }
37982
38334
  }
37983
38335
  };
38336
+ ImageEditPlugin.prototype.focusCropHandle = function (event) {
38337
+ if (this.cropKeyboardHelper &&
38338
+ event.key == 'Tab' &&
38339
+ !event.shiftKey &&
38340
+ !this.cropKeyboardHelper.contains(event.composedPath()[0])) {
38341
+ // Enter crop controls before editing plugins can indent or rerender the image.
38342
+ event.preventDefault();
38343
+ event.stopPropagation();
38344
+ this.cropKeyboardHelper.focus();
38345
+ return true;
38346
+ }
38347
+ return false;
38348
+ };
37984
38349
  ImageEditPlugin.prototype.setContentHandler = function () {
37985
38350
  if (this.selectedImage) {
37986
38351
  this.cleanInfo();
@@ -38221,7 +38586,7 @@ var ImageEditPlugin = /** @class */ (function () {
38221
38586
  if (this.imageEditInfo) {
38222
38587
  this.startEditing(editor, image, ['crop']);
38223
38588
  if (this.imageEditInfo && this.selectedImage && this.wrapper && this.clonedImage) {
38224
- this.dndHelpers = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.CropHandle, cropperContext_1.Cropper, function () {
38589
+ var onCrop = function () {
38225
38590
  if (_this.imageEditInfo &&
38226
38591
  _this.selectedImage &&
38227
38592
  _this.wrapper &&
@@ -38229,11 +38594,46 @@ var ImageEditPlugin = /** @class */ (function () {
38229
38594
  (0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, _this.croppers, isRTL);
38230
38595
  _this.isCropMode = true;
38231
38596
  }
38232
- }, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet, !!editor.getEnvironment().isTouchSupported)), false);
38597
+ };
38598
+ this.dndHelpers = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.CropHandle, cropperContext_1.Cropper, onCrop, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet, !!editor.getEnvironment().isTouchSupported)), false);
38233
38599
  (0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined /* resizers */, this.croppers, isRTL);
38600
+ this.startCropWithKeyboard(editor, onCrop);
38234
38601
  }
38235
38602
  }
38236
38603
  };
38604
+ ImageEditPlugin.prototype.startCropWithKeyboard = function (editor, onCrop) {
38605
+ var _this = this;
38606
+ var _a;
38607
+ if (this.wrapper && this.selectedImage && this.imageEditInfo) {
38608
+ (_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
38609
+ this.cropKeyboardHelper = new ImageCropKeyboardHelper_1.ImageCropKeyboardHelper(this.wrapper, this.selectedImage.id, this.imageEditInfo, this.options, onCrop, function (apply, restoreFocus) { return _this.finishKeyboardCrop(editor, apply, restoreFocus); });
38610
+ editor.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, 'outline:2px solid Highlight;outline-offset:-2px;', ["span::part(" + ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget + "):focus"]);
38611
+ }
38612
+ };
38613
+ ImageEditPlugin.prototype.finishKeyboardCrop = function (editor, apply, restoreFocus) {
38614
+ var _a;
38615
+ (_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
38616
+ this.cropKeyboardHelper = null;
38617
+ editor.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, null);
38618
+ if (apply) {
38619
+ this.applyFormatWithContentModel(editor, true, true);
38620
+ }
38621
+ else {
38622
+ this.isEditing = false;
38623
+ var image = this.removeImageWrapper();
38624
+ if (image) {
38625
+ (0, roosterjs_content_model_dom_1.setImageState)(image, '');
38626
+ }
38627
+ this.cleanInfo();
38628
+ if (restoreFocus && image) {
38629
+ editor.focus();
38630
+ editor.setDOMSelection({ type: 'image', image: image });
38631
+ }
38632
+ }
38633
+ if (restoreFocus) {
38634
+ editor.focus();
38635
+ }
38636
+ };
38237
38637
  ImageEditPlugin.prototype.cropImage = function () {
38238
38638
  if (!this.editor) {
38239
38639
  return;
@@ -38259,9 +38659,12 @@ var ImageEditPlugin = /** @class */ (function () {
38259
38659
  * Exported for testing purpose only
38260
38660
  */
38261
38661
  ImageEditPlugin.prototype.cleanInfo = function () {
38262
- var _a, _b;
38263
- (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setEditorStyle(IMAGE_EDIT_CLASS, null);
38264
- (_b = this.editor) === null || _b === void 0 ? void 0 : _b.setEditorStyle(IMAGE_EDIT_CLASS_CARET, null);
38662
+ var _a, _b, _c, _d;
38663
+ (_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
38664
+ this.cropKeyboardHelper = null;
38665
+ (_b = this.editor) === null || _b === void 0 ? void 0 : _b.setEditorStyle(IMAGE_EDIT_CLASS, null);
38666
+ (_c = this.editor) === null || _c === void 0 ? void 0 : _c.setEditorStyle(IMAGE_EDIT_CLASS_CARET, null);
38667
+ (_d = this.editor) === null || _d === void 0 ? void 0 : _d.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, null);
38265
38668
  this.selectedImage = null;
38266
38669
  this.shadowSpan = null;
38267
38670
  this.wrapper = null;
@@ -38848,6 +39251,14 @@ exports.ImageEditElementClass = void 0;
38848
39251
  */
38849
39252
  var ImageEditElementClass;
38850
39253
  (function (ImageEditElementClass) {
39254
+ /**
39255
+ * CSS class name for the image border
39256
+ */
39257
+ ImageEditElementClass["ImageBorder"] = "r_imageB";
39258
+ /**
39259
+ * CSS class and part name for keyboard crop focus targets
39260
+ */
39261
+ ImageEditElementClass["CropKeyboardTarget"] = "r_cropK";
38851
39262
  /**
38852
39263
  * CSS class name for resize handle
38853
39264
  */
@@ -39087,6 +39498,7 @@ exports.createImageWrapper = void 0;
39087
39498
  var createImageCropper_1 = __webpack_require__(/*! ../Cropper/createImageCropper */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/createImageCropper.ts");
39088
39499
  var createImageResizer_1 = __webpack_require__(/*! ../Resizer/createImageResizer */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Resizer/createImageResizer.ts");
39089
39500
  var createImageRotator_1 = __webpack_require__(/*! ../Rotator/createImageRotator */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Rotator/createImageRotator.ts");
39501
+ var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
39090
39502
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
39091
39503
  /**
39092
39504
  * @internal
@@ -39163,6 +39575,7 @@ var createWrapper = function (editor, image, options, editInfo, resizers, rotato
39163
39575
  var createBorder = function (editor, borderColor) {
39164
39576
  var doc = editor.getDocument();
39165
39577
  var resizeBorder = doc.createElement('div');
39578
+ resizeBorder.className = ImageEditElementClass_1.ImageEditElementClass.ImageBorder;
39166
39579
  resizeBorder.setAttribute("style", "position:absolute;left:0;right:0;top:0;bottom:0;border:solid 2px " + borderColor + ";pointer-events:none;");
39167
39580
  return resizeBorder;
39168
39581
  };
@@ -40860,12 +41273,16 @@ var wacSubSuperParser = function (format, element) {
40860
41273
  if (verticalAlign === 'sub') {
40861
41274
  format.superOrSubScriptSequence = 'sub';
40862
41275
  }
41276
+ if ((verticalAlign === 'super' || verticalAlign === 'sub') &&
41277
+ element.style.fontSize !== 'smaller') {
41278
+ format.superOrSubScriptFontSize = 'inherit';
41279
+ }
40863
41280
  };
40864
41281
  /**
40865
41282
  * This processor does:
40866
41283
  * 1) Remove the display and margin of the element.
40867
41284
  * 2) When an element should be ignored but should handle the child elements call the default child processor.
40868
- * 3) Removes the End of Paragraph element to avoid empty lines, we should only remove this if the previous element of the EOP is an EmptyTextRun
41285
+ * 3) Removes selected End of Paragraph markers unless they are the paragraph's only content.
40869
41286
  * 4) Finally call the default processor.
40870
41287
  * @returns
40871
41288
  */
@@ -40879,12 +41296,19 @@ var wacElementProcessor = function (group, element, context) {
40879
41296
  context.elementProcessors.child(group, element, context);
40880
41297
  return;
40881
41298
  }
40882
- if (constants_1.TEMP_ELEMENTS_CLASSES.some(function (className) { return element.classList.contains(className); }) ||
40883
- // This is needed to remove some temporary End of paragraph elements that WAC sometimes preserves
40884
- (element.classList.contains(SELECTED_CLASS) && element.classList.contains(END_OF_PARAGRAPH))) {
41299
+ if (constants_1.TEMP_ELEMENTS_CLASSES.some(function (className) { return element.classList.contains(className); })) {
40885
41300
  return;
40886
41301
  }
40887
- else if (shouldClearListContext(elementTag, element, context)) {
41302
+ if (element.classList.contains(SELECTED_CLASS) &&
41303
+ element.classList.contains(END_OF_PARAGRAPH)) {
41304
+ var lastBlock = group.blocks[group.blocks.length - 1];
41305
+ if ((lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.blockType) != 'Paragraph' || lastBlock.segments.length > 0) {
41306
+ return;
41307
+ }
41308
+ element.style.removeProperty('background-color');
41309
+ element.style.removeProperty('border-color');
41310
+ }
41311
+ if (shouldClearListContext(elementTag, element, context)) {
40888
41312
  var listFormat = context.listFormat;
40889
41313
  listFormat.levels = [];
40890
41314
  listFormat.listParent = undefined;
@@ -40922,6 +41346,7 @@ var wacLiElementProcessor = function (group, element, context) {
40922
41346
  if (lastblock.blockType == 'BlockGroup' && lastblock.blockGroupType == 'ListItem') {
40923
41347
  var currentLevel = lastblock.levels[lastblock.levels.length - 1];
40924
41348
  updateStartOverride(currentLevel, element, context);
41349
+ updateHeading(lastblock, element, context);
40925
41350
  }
40926
41351
  }
40927
41352
  var newLevels = [];
@@ -40953,6 +41378,19 @@ var wacListLevelParser = function (format) {
40953
41378
  format.marginLeft = undefined;
40954
41379
  format.paddingLeft = BASE_PADDING_WAC_LISTS;
40955
41380
  };
41381
+ var wacTableCellPaddingParser = function (format, element) {
41382
+ var keys = [
41383
+ 'paddingTop',
41384
+ 'paddingRight',
41385
+ 'paddingBottom',
41386
+ 'paddingLeft',
41387
+ ];
41388
+ keys.forEach(function (key) {
41389
+ if (element.style[key]) {
41390
+ format[key] = element.style[key];
41391
+ }
41392
+ });
41393
+ };
40956
41394
  /**
40957
41395
  * This function returns whether we need to clear the list format.
40958
41396
  * Word Online wraps lists inside divs to have this structure:
@@ -40996,6 +41434,7 @@ function processPastedContentWacComponents(ev) {
40996
41434
  (0, addParser_1.addParser)(ev.domToModelOption, 'listLevel', wacListLevelParser);
40997
41435
  (0, addParser_1.addParser)(ev.domToModelOption, 'container', wacContainerParser);
40998
41436
  (0, addParser_1.addParser)(ev.domToModelOption, 'table', wacContainerParser);
41437
+ (0, addParser_1.addParser)(ev.domToModelOption, 'tableCell', wacTableCellPaddingParser);
40999
41438
  (0, addParser_1.addParser)(ev.domToModelOption, 'segment', wacCommentParser);
41000
41439
  (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wacElementProcessor);
41001
41440
  (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'li', wacLiElementProcessor);
@@ -41006,6 +41445,58 @@ var wacContainerParser = function (format, element) {
41006
41445
  delete format.marginLeft;
41007
41446
  }
41008
41447
  };
41448
+ function updateHeading(listItem, element, context) {
41449
+ var _a;
41450
+ var paragraph = element.querySelector('p');
41451
+ var styleName = (_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.querySelector('[data-ccp-parastyle]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-ccp-parastyle');
41452
+ var list = element.closest('ol');
41453
+ if (!paragraph || !list || !/^heading [1-6]$/i.test(styleName || '')) {
41454
+ return;
41455
+ }
41456
+ var headingParagraph = listItem.blocks.find(function (block) { var _a; return block.blockType == 'Paragraph' && ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.tagName) == 'p'; });
41457
+ if ((headingParagraph === null || headingParagraph === void 0 ? void 0 : headingParagraph.blockType) == 'Paragraph') {
41458
+ // An inside marker and a block paragraph would occupy separate lines.
41459
+ Object.assign(listItem.format, headingParagraph.format);
41460
+ headingParagraph.isImplicit = true;
41461
+ headingParagraph.format = {};
41462
+ delete headingParagraph.decorator;
41463
+ }
41464
+ listItem.levels.forEach(function (level) {
41465
+ level.format.paddingLeft = '0px';
41466
+ level.format.paddingRight = '0px';
41467
+ level.format.marginTop = '0px';
41468
+ level.format.marginBottom = '0px';
41469
+ });
41470
+ listItem.format.marginLeft = '0px';
41471
+ listItem.format.marginRight = '0px';
41472
+ listItem.format.listStylePosition = 'inside';
41473
+ (0, roosterjs_content_model_dom_1.parseFormat)(paragraph, context.formatParsers.segmentOnBlock, listItem.formatHolder.format, context);
41474
+ var listId = element.getAttribute('data-listid');
41475
+ var template = element.getAttribute('data-leveltext');
41476
+ var _b = (0, tslib_1.__read)(extractWordListMetadata(list, element), 2), start = _b[0], level = _b[1];
41477
+ if (!listId ||
41478
+ !template ||
41479
+ !/^%[1-9](?:\.%[1-9])*[.)]?$/.test(template) ||
41480
+ !(level > 0 && level <= 9) ||
41481
+ !Number.isFinite(start)) {
41482
+ return;
41483
+ }
41484
+ var listFormat = context.listFormat;
41485
+ var headings = (listFormat.headingNumbers = listFormat.headingNumbers || new Map());
41486
+ var numbers = headings.get(listId) || [];
41487
+ numbers[level - 1] = start;
41488
+ numbers.length = level;
41489
+ headings.set(listId, numbers);
41490
+ var complete = true;
41491
+ var label = template.replace(/%([1-9])/g, function (_match, index) {
41492
+ var number = numbers[parseInt(index) - 1];
41493
+ complete = complete && number !== undefined;
41494
+ return number === undefined ? '' : number.toString();
41495
+ });
41496
+ if (complete) {
41497
+ listItem.format.listStyleType = '"' + label + ' "';
41498
+ }
41499
+ }
41009
41500
  function updateStartOverride(currentLevel, element, ctx) {
41010
41501
  if (!currentLevel || currentLevel.listType == 'UL') {
41011
41502
  return;
@@ -41176,6 +41667,7 @@ var setProcessor_1 = __webpack_require__(/*! ../utils/setProcessor */ "./package
41176
41667
  var wordContainerParser_1 = __webpack_require__(/*! ../parsers/wordContainerParser */ "./packages/roosterjs-content-model-plugins/lib/paste/parsers/wordContainerParser.ts");
41177
41668
  var wordTableParser_1 = __webpack_require__(/*! ../parsers/wordTableParser */ "./packages/roosterjs-content-model-plugins/lib/paste/parsers/wordTableParser.ts");
41178
41669
  var removeListParagraphMargins_1 = __webpack_require__(/*! ./removeListParagraphMargins */ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/removeListParagraphMargins.ts");
41670
+ var wordBorderParser_1 = __webpack_require__(/*! ./wordBorderParser */ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts");
41179
41671
  /**
41180
41672
  * @internal
41181
41673
  * Handles pasted content when the source is Word Desktop.
@@ -41195,6 +41687,7 @@ function processPastedContentFromWordDesktop(domToModelOption, htmlString, globa
41195
41687
  (0, addParser_1.addParser)(domToModelOption, 'listLevel', listLevelParser_1.listLevelParser);
41196
41688
  (0, addParser_1.addParser)(domToModelOption, 'container', wordContainerParser_1.wordContainerParser);
41197
41689
  (0, addParser_1.addParser)(domToModelOption, 'table', wordTableParser_1.wordTableParser);
41690
+ (0, addParser_1.addParser)(domToModelOption, 'tableBorder', wordBorderParser_1.wordBorderParser);
41198
41691
  }
41199
41692
  exports.processPastedContentFromWordDesktop = processPastedContentFromWordDesktop;
41200
41693
  var wordDesktopElementProcessor = function (metadataKey) {
@@ -41293,30 +41786,66 @@ function processWordList(styles, group, element, context, metadata) {
41293
41786
  (listFormat.wordList && listFormat.wordKnownLevels.get(listFormat.wordList)) || [];
41294
41787
  }
41295
41788
  if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {
41296
- var wordLevel = listFormat.wordLevel, wordList = listFormat.wordList;
41789
+ var wordLevel_1 = listFormat.wordLevel, wordList = listFormat.wordList;
41790
+ var isHeading_1 = /^H[1-6]$/.test(element.tagName);
41297
41791
  // Retrieve the Fake bullet on the element and also the list type
41298
41792
  var listMetadata_1 = metadata.get(lNumber + ":" + level);
41299
41793
  var listType_1 = ((_a = listMetadata_1 === null || listMetadata_1 === void 0 ? void 0 : listMetadata_1['mso-level-number-format']) === null || _a === void 0 ? void 0 : _a.toLowerCase()) != BULLET_METADATA
41300
41794
  ? 'OL'
41301
41795
  : 'UL';
41302
41796
  // Create the new level of the list item and parse the format
41303
- (0, customListUtils_1.setupListFormat)(listType_1, element, context, wordLevel, listFormat, group, [
41797
+ (0, customListUtils_1.setupListFormat)(listType_1, element, context, wordLevel_1, listFormat, group, [
41304
41798
  wordListPaddingParser,
41305
41799
  ]);
41306
- listFormat.levels[listFormat.levels.length - 1]
41307
- .format.wordList = wordList;
41308
- var bullet = getBulletFromMetadata(listMetadata_1, listType_1);
41309
- var listFormatMetadata = bullet
41800
+ var currentLevelFormat = listFormat.levels[listFormat.levels.length - 1]
41801
+ .format;
41802
+ currentLevelFormat.wordList = wordList;
41803
+ if (isHeading_1) {
41804
+ // Keep Word's heading spacing on the item, not on synthesized list wrappers.
41805
+ currentLevelFormat.paddingLeft = '0px';
41806
+ currentLevelFormat.paddingRight = '0px';
41807
+ currentLevelFormat.marginTop = '0px';
41808
+ currentLevelFormat.marginBottom = '0px';
41809
+ }
41810
+ else if (wordLevel_1 > 1) {
41811
+ delete currentLevelFormat.paddingLeft;
41812
+ delete currentLevelFormat.paddingRight;
41813
+ }
41814
+ var bullet_1 = getBulletFromMetadata(listMetadata_1, listType_1);
41815
+ var bulletElement_1 = getBulletElement(element);
41816
+ var listFormatMetadata = bullet_1
41310
41817
  ? {
41311
- unorderedStyleType: listType_1 == 'UL' ? bullet : undefined,
41312
- orderedStyleType: listType_1 == 'OL' ? bullet : undefined,
41818
+ unorderedStyleType: listType_1 == 'UL' ? bullet_1 : undefined,
41819
+ orderedStyleType: listType_1 == 'OL' ? bullet_1 : undefined,
41313
41820
  }
41314
41821
  : undefined;
41315
- (0, customListUtils_1.processAsListItem)(context, element, group, listFormatMetadata, getBulletElement(element), function (listItem) {
41316
- if (listType_1 == 'OL') {
41317
- setStartNumber(listItem, context, listMetadata_1, element);
41318
- }
41319
- });
41822
+ var originalSegmentFormat = context.segmentFormat;
41823
+ try {
41824
+ context.segmentFormat = (0, tslib_1.__assign)({}, originalSegmentFormat);
41825
+ (0, customListUtils_1.processAsListItem)(context, element, group, listFormatMetadata, bulletElement_1, function (listItem) {
41826
+ var _a;
41827
+ if (isHeading_1 && listType_1 == 'OL') {
41828
+ listItem.format.marginLeft = '0px';
41829
+ listItem.format.marginRight = '0px';
41830
+ listItem.format.listStylePosition = 'inside';
41831
+ // Preserve Word's rendered number when its outline template is unsupported.
41832
+ var number = (_a = bulletElement_1 === null || bulletElement_1 === void 0 ? void 0 : bulletElement_1.textContent) === null || _a === void 0 ? void 0 : _a.trim();
41833
+ if (bullet_1 === undefined && number && /^\d+(?:\.\d+)*[.)]?$/.test(number)) {
41834
+ listItem.format.listStyleType = '"' + number + ' "';
41835
+ }
41836
+ }
41837
+ else if (wordLevel_1 > 1 && !isHeading_1) {
41838
+ delete listItem.format.marginLeft;
41839
+ delete listItem.format.marginRight;
41840
+ }
41841
+ if (listType_1 == 'OL') {
41842
+ setStartNumber(listItem, context, listMetadata_1, element);
41843
+ }
41844
+ });
41845
+ }
41846
+ finally {
41847
+ context.segmentFormat = originalSegmentFormat;
41848
+ }
41320
41849
  if (listFormat.levels.length > 0 &&
41321
41850
  listFormat.wordKnownLevels.get(wordList) != listFormat.levels) {
41322
41851
  listFormat.wordKnownLevels.set(wordList, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(listFormat.levels), false));
@@ -41437,8 +41966,13 @@ function wordListPaddingParser(format, element) {
41437
41966
  * @returns
41438
41967
  */
41439
41968
  function getBulletElement(element) {
41969
+ var _a;
41440
41970
  var firstChild = element.firstElementChild;
41441
41971
  var isBulletElement = false;
41972
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(firstChild, 'ELEMENT_NODE') &&
41973
+ ((_a = (0, getStyles_1.getStyles)(firstChild)[MSO_LIST]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === MSO_LIST_IGNORE) {
41974
+ return firstChild;
41975
+ }
41442
41976
  if (firstChild) {
41443
41977
  for (var i = 0; i < firstChild.childNodes.length; i++) {
41444
41978
  var child = firstChild.childNodes[i];
@@ -41485,35 +42019,108 @@ var WORD_LIST_PARAGRAPH_SELECTORS = new Set([
41485
42019
  ]);
41486
42020
  /**
41487
42021
  * @internal
41488
- * Strips all margin-* properties from a CSS property string.
42022
+ * Strips horizontal margin properties from a CSS property string while preserving
42023
+ * vertical values from the margin shorthand.
41489
42024
  * Empty tokens produced by a trailing semicolon are preserved so that the
41490
42025
  * resulting string still ends with ";" and remains safe to concatenate.
41491
- * For example, "margin-top: 0pt; color: red;" becomes " color: red;".
41492
- */
41493
- function removeMarginProperties(cssText) {
41494
- return cssText
41495
- .split(';')
41496
- .filter(function (prop) {
41497
- var name = prop.split(':')[0].trim().toLowerCase();
41498
- // Keep empty tokens (the trailing ';' produces one) and any non-margin property.
41499
- return !name || !/^margin/.test(name);
41500
- })
41501
- .join(';');
42026
+ * For example, "margin: 1pt 2pt 3pt 4pt; color: red;" becomes
42027
+ * "margin-top: 1pt; margin-bottom: 3pt; color: red;".
42028
+ */
42029
+ function removeHorizontalMarginProperties(cssText) {
42030
+ var result = [];
42031
+ cssText.split(';').forEach(function (prop) {
42032
+ var _a, _b;
42033
+ var separatorIndex = prop.indexOf(':');
42034
+ var name = prop
42035
+ .substring(0, separatorIndex < 0 ? prop.length : separatorIndex)
42036
+ .trim()
42037
+ .toLowerCase();
42038
+ if (name == 'margin-left' ||
42039
+ name == 'margin-right' ||
42040
+ name == 'margin-inline' ||
42041
+ name == 'margin-inline-start' ||
42042
+ name == 'margin-inline-end') {
42043
+ return;
42044
+ }
42045
+ if (name == 'margin' && separatorIndex >= 0) {
42046
+ var value = prop.substring(separatorIndex + 1).trim();
42047
+ var importantMatch = value.match(/\s*!important\s*$/i);
42048
+ var important = importantMatch ? ' !important' : '';
42049
+ var values = splitCssValue(value.substring(0, (_a = importantMatch === null || importantMatch === void 0 ? void 0 : importantMatch.index) !== null && _a !== void 0 ? _a : value.length));
42050
+ if (values.length >= 1 && values.length <= 4) {
42051
+ var leadingWhitespace = ((_b = prop.match(/^\s*/)) === null || _b === void 0 ? void 0 : _b[0]) || '';
42052
+ var top_1 = values[0];
42053
+ var bottom = values.length >= 3 ? values[2] : values[0];
42054
+ result.push(leadingWhitespace + "margin-top: " + top_1 + important);
42055
+ result.push(" margin-bottom: " + bottom + important);
42056
+ return;
42057
+ }
42058
+ }
42059
+ result.push(prop);
42060
+ });
42061
+ return result.join(';');
42062
+ }
42063
+ function splitCssValue(value) {
42064
+ var result = [];
42065
+ var current = '';
42066
+ var quote = null;
42067
+ var parenthesisDepth = 0;
42068
+ for (var i = 0; i < value.length; i++) {
42069
+ var char = value[i];
42070
+ if (quote) {
42071
+ current += char;
42072
+ if (char == '\\') {
42073
+ i++;
42074
+ current += value[i] || '';
42075
+ }
42076
+ else if (char == quote) {
42077
+ quote = null;
42078
+ }
42079
+ }
42080
+ else if (char == '"' || char == "'") {
42081
+ current += char;
42082
+ quote = char;
42083
+ }
42084
+ else if (char == '(') {
42085
+ current += char;
42086
+ parenthesisDepth++;
42087
+ }
42088
+ else if (char == ')') {
42089
+ current += char;
42090
+ parenthesisDepth = Math.max(0, parenthesisDepth - 1);
42091
+ }
42092
+ else if (parenthesisDepth == 0 && /\s/.test(char)) {
42093
+ if (current) {
42094
+ result.push(current);
42095
+ current = '';
42096
+ }
42097
+ }
42098
+ else {
42099
+ current += char;
42100
+ }
42101
+ }
42102
+ if (current) {
42103
+ result.push(current);
42104
+ }
42105
+ return result;
41502
42106
  }
41503
42107
  /**
41504
42108
  * @internal
41505
- * Removes margin properties from global CSS rules that target Word list paragraph
41506
- * classes (p.MsoListParagraph, p.MsoListParagraphCxSpFirst, etc.).
42109
+ * Removes horizontal margin properties from global CSS rules that target Word list
42110
+ * paragraph classes (p.MsoListParagraph, p.MsoListParagraphCxSpFirst, etc.).
41507
42111
  *
41508
42112
  * Word Desktop pastes a global stylesheet that typically includes rules like:
41509
42113
  * p.MsoListParagraph { margin: 0in; margin-bottom: .0001pt; ... }
41510
- * These margins conflict with RoosterJS's own list indentation, causing double
41511
- * indentation when the CSS is converted to inline styles via convertInlineCss.
42114
+ * Horizontal margins conflict with RoosterJS's own list indentation, causing double
42115
+ * indentation when the CSS is converted to inline styles via convertInlineCss. The
42116
+ * vertical margins are preserved so Word's margin-top: 0 is not replaced by the
42117
+ * browser's default paragraph margin when the list level is created.
41512
42118
  *
41513
- * When a rule's selectors are exclusively list paragraph classes the margins are
41514
- * removed in place. When a rule groups list paragraph classes with other selectors
41515
- * the rule is split: the non-list selectors keep the original text, and a new rule
41516
- * is inserted for the list paragraph selectors with margins stripped.
42119
+ * When a rule's selectors are exclusively list paragraph classes the horizontal
42120
+ * margins are removed in place. When a rule groups list paragraph classes with other
42121
+ * selectors the rule is split: the non-list selectors keep the original text, and a
42122
+ * new rule is inserted for the list paragraph selectors with horizontal margins
42123
+ * stripped.
41517
42124
  *
41518
42125
  * The array is mutated in place so the changes are reflected when convertInlineCss
41519
42126
  * subsequently processes the same array reference.
@@ -41528,17 +42135,16 @@ function removeListParagraphMargins(globalCssRules) {
41528
42135
  }
41529
42136
  var nonMatchingSelectors = rule.selectors.filter(function (s) { return !WORD_LIST_PARAGRAPH_SELECTORS.has(s); });
41530
42137
  if (nonMatchingSelectors.length === 0) {
41531
- // All selectors target list paragraphs — strip margins directly.
41532
- rule.text = removeMarginProperties(rule.text);
42138
+ // All selectors target list paragraphs — strip horizontal margins directly.
42139
+ rule.text = removeHorizontalMarginProperties(rule.text);
41533
42140
  }
41534
42141
  else {
41535
42142
  // Mixed rule: keep the non-list selectors on the original entry, then
41536
- // insert a new entry immediately after for the list paragraph selectors
41537
- // with margins removed.
42143
+ // insert a new entry immediately after for the list paragraph selectors.
41538
42144
  rule.selectors = nonMatchingSelectors;
41539
42145
  globalCssRules.splice(i + 1, 0, {
41540
42146
  selectors: matchingSelectors,
41541
- text: removeMarginProperties(rule.text),
42147
+ text: removeHorizontalMarginProperties(rule.text),
41542
42148
  });
41543
42149
  }
41544
42150
  }
@@ -41546,6 +42152,63 @@ function removeListParagraphMargins(globalCssRules) {
41546
42152
  exports.removeListParagraphMargins = removeListParagraphMargins;
41547
42153
 
41548
42154
 
42155
+ /***/ },
42156
+
42157
+ /***/ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts"
42158
+ /*!********************************************************************************************!*\
42159
+ !*** ./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts ***!
42160
+ \********************************************************************************************/
42161
+ (__unused_webpack_module, exports, __webpack_require__) {
42162
+
42163
+ "use strict";
42164
+
42165
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
42166
+ exports.wordBorderParser = void 0;
42167
+ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
42168
+ var BorderStyleNames = new Map([
42169
+ ['border-top', 'borderTop'],
42170
+ ['border-right', 'borderRight'],
42171
+ ['border-bottom', 'borderBottom'],
42172
+ ['border-left', 'borderLeft'],
42173
+ ]);
42174
+ /**
42175
+ * @internal
42176
+ */
42177
+ var wordBorderParser = function (format, element) {
42178
+ var style = element.getAttribute('style');
42179
+ if (style) {
42180
+ var noBorder_1 = new Map();
42181
+ style.split(';').forEach(function (declaration) {
42182
+ var separatorIndex = declaration.indexOf(':');
42183
+ if (separatorIndex < 0) {
42184
+ return;
42185
+ }
42186
+ var name = declaration.substring(0, separatorIndex).trim().toLowerCase();
42187
+ var value = declaration
42188
+ .substring(separatorIndex + 1)
42189
+ .trim()
42190
+ .toLowerCase();
42191
+ var isNone = /^none(?:\s|$|!important)/.test(value);
42192
+ if (name == 'border') {
42193
+ roosterjs_content_model_dom_1.BorderKeys.forEach(function (key) { return noBorder_1.set(key, isNone); });
42194
+ }
42195
+ else {
42196
+ var key = BorderStyleNames.get(name);
42197
+ if (key) {
42198
+ noBorder_1.set(key, isNone);
42199
+ }
42200
+ }
42201
+ });
42202
+ noBorder_1.forEach(function (isNone, key) {
42203
+ if (isNone) {
42204
+ format[key] = 'none';
42205
+ }
42206
+ });
42207
+ }
42208
+ };
42209
+ exports.wordBorderParser = wordBorderParser;
42210
+
42211
+
41549
42212
  /***/ },
41550
42213
 
41551
42214
  /***/ "./packages/roosterjs-content-model-plugins/lib/paste/oneNote/processPastedContentFromOneNote.ts"
@@ -41850,18 +42513,23 @@ var INVALID_LINKS_REGEX = /^file:\/\/\/[a-zA-Z\/]/i;
41850
42513
  * @internal
41851
42514
  */
41852
42515
  var parseLink = function (format, element) {
42516
+ var _a;
41853
42517
  if (!(0, roosterjs_content_model_dom_1.isElementOfType)(element, 'a')) {
41854
42518
  return;
41855
42519
  }
42520
+ // On an SVG anchor "href" is an SVGAnimatedString instead of a resolved URL string. Passing it
42521
+ // to the URL constructor always throws, which used to skip the protocol check altogether.
42522
+ var href = typeof element.href == 'string' ? element.href : (_a = element.getAttribute('href')) !== null && _a !== void 0 ? _a : '';
41856
42523
  var url;
41857
42524
  try {
41858
- url = new URL(element.href);
42525
+ url = new URL(href);
41859
42526
  }
41860
- catch (_a) {
42527
+ catch (_b) {
41861
42528
  url = undefined;
41862
42529
  }
41863
- if ((url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) === -1) ||
41864
- INVALID_LINKS_REGEX.test(element.href)) {
42530
+ if ((0, roosterjs_content_model_dom_1.isUnsafeUrl)(href) ||
42531
+ (url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) === -1) ||
42532
+ INVALID_LINKS_REGEX.test(href)) {
41865
42533
  element.removeAttribute('href');
41866
42534
  format.href = '';
41867
42535
  }
@@ -42523,8 +43191,12 @@ function processAsListItem(context, element, group, listFormatMetadata, bulletEl
42523
43191
  if (listFormatMetadata && lastLevel) {
42524
43192
  (0, roosterjs_content_model_dom_1.updateListMetadata)(lastLevel, function (metadata) { return Object.assign({}, metadata, listFormatMetadata); });
42525
43193
  }
42526
- var listItem = (0, roosterjs_content_model_dom_1.createListItem)(listFormat.levels, context.segmentFormat);
43194
+ // Parse the list item element's own segment format (e.g. font family/size) into
43195
+ // context.segmentFormat *before* creating the list item, so the format holder
43196
+ // (used to render the list bullet/number) reflects this list item's own font instead
43197
+ // of whatever was left over from the previously processed element.
42527
43198
  (0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
43199
+ var listItem = (0, roosterjs_content_model_dom_1.createListItem)(listFormat.levels, context.segmentFormat);
42528
43200
  (0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listItemElement, listItem.format, context);
42529
43201
  (0, roosterjs_content_model_dom_1.parseFormat)(element, [removeNegativeTextIndentParser_1.removeNegativeTextIndentParser, nonListElementParser], listItem.format, context);
42530
43202
  if (bulletElement) {