roosterjs 8.40.0 → 8.40.2

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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.40.0)
1
+ // Type definitions for roosterjs (Version 8.40.2)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -6714,9 +6714,7 @@ var CopyPastePlugin = /** @class */ (function () {
6714
6714
  CopyPastePlugin.prototype.getTempDiv = function (editor, forceInLightMode) {
6715
6715
  var div = editor.getCustomData('CopyPasteTempDiv', function () {
6716
6716
  var tempDiv = (0, roosterjs_editor_dom_1.createElement)(3 /* CopyPasteTempDiv */, editor.getDocument());
6717
- editor.insertNode(tempDiv, {
6718
- position: 4 /* Outside */,
6719
- });
6717
+ editor.getDocument().body.appendChild(tempDiv);
6720
6718
  return tempDiv;
6721
6719
  }, function (tempDiv) { var _a; return (_a = tempDiv.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(tempDiv); });
6722
6720
  if (forceInLightMode) {
@@ -7559,6 +7557,15 @@ var ImageSelection = /** @class */ (function () {
7559
7557
  }
7560
7558
  }
7561
7559
  break;
7560
+ case 5 /* MouseDown */:
7561
+ var mouseTarget = event.rawEvent.target;
7562
+ var mouseSelection = this.editor.getSelectionRangeEx();
7563
+ if (mouseSelection &&
7564
+ mouseSelection.type === 2 /* ImageSelection */ &&
7565
+ mouseSelection.image !== mouseTarget) {
7566
+ this.editor.select(null);
7567
+ }
7568
+ break;
7562
7569
  case 2 /* KeyUp */:
7563
7570
  var key = event.rawEvent.key;
7564
7571
  var keyDownSelection = this.editor.getSelectionRangeEx();
@@ -21109,7 +21116,11 @@ function cacheGetListElement(event, editor) {
21109
21116
  function shouldTriggerList(event, editor, getListStyle, listType) {
21110
21117
  var searcher = editor.getContentSearcherOfCursor(event);
21111
21118
  var textBeforeCursor = searcher.getSubStringBefore(4);
21112
- var itHasSpace = /\s/g.test(textBeforeCursor);
21119
+ var traverser = editor.getBlockTraverser();
21120
+ var text = traverser && traverser.currentBlockElement
21121
+ ? traverser.currentBlockElement.getTextContent()
21122
+ : null;
21123
+ var isATheBeginning = text && text === textBeforeCursor;
21113
21124
  var listChains = getListChains(editor);
21114
21125
  var textRange = searcher.getRangeFromText(textBeforeCursor, true /*exactMatch*/);
21115
21126
  var previousListType = getPreviousListType(editor, textRange, listType);
@@ -21119,7 +21130,7 @@ function shouldTriggerList(event, editor, getListStyle, listType) {
21119
21130
  !previousListType ||
21120
21131
  previousListType === listStyle ||
21121
21132
  listType === 2 /* Unordered */;
21122
- return (!itHasSpace &&
21133
+ return (isATheBeginning &&
21123
21134
  !searcher.getNearestNonTextInlineElement() &&
21124
21135
  listStyle &&
21125
21136
  shouldTriggerNewListStyle);
@@ -21980,6 +21991,36 @@ var getAllFeatures_1 = __webpack_require__(/*! ./getAllFeatures */ "./packages/r
21980
21991
  Object.defineProperty(exports, "getAllFeatures", { enumerable: true, get: function () { return getAllFeatures_1.default; } });
21981
21992
 
21982
21993
 
21994
+ /***/ }),
21995
+
21996
+ /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/convertAlphaToDecimals.ts":
21997
+ /*!***************************************************************************************************!*\
21998
+ !*** ./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/convertAlphaToDecimals.ts ***!
21999
+ \***************************************************************************************************/
22000
+ /*! no static exports found */
22001
+ /***/ (function(module, exports, __webpack_require__) {
22002
+
22003
+ "use strict";
22004
+
22005
+ Object.defineProperty(exports, "__esModule", { value: true });
22006
+ /**
22007
+ * @internal
22008
+ * Convert english alphabet numbers into decimal numbers
22009
+ * @param letter The letter that needs to be converted
22010
+ * @returns
22011
+ */
22012
+ function convertAlphaToDecimals(letter) {
22013
+ var alpha = letter.toLocaleLowerCase();
22014
+ if (alpha) {
22015
+ var size = alpha.length - 1;
22016
+ var number = 26 * size + alpha.charCodeAt(size) - 96;
22017
+ return number;
22018
+ }
22019
+ return null;
22020
+ }
22021
+ exports.default = convertAlphaToDecimals;
22022
+
22023
+
21983
22024
  /***/ }),
21984
22025
 
21985
22026
  /***/ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/getAutoBulletListStyle.ts":
@@ -22031,6 +22072,7 @@ exports.default = getAutoBulletListStyle;
22031
22072
 
22032
22073
  var _a, _b, _c, _d, _e, _f;
22033
22074
  Object.defineProperty(exports, "__esModule", { value: true });
22075
+ var convertAlphaToDecimals_1 = __webpack_require__(/*! ./convertAlphaToDecimals */ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/convertAlphaToDecimals.ts");
22034
22076
  var characters = {
22035
22077
  '.': 1 /* Dot */,
22036
22078
  '-': 2 /* Dash */,
@@ -22135,10 +22177,15 @@ var identifyNumberingListType = function (numbering, isDoubleParenthesis, previo
22135
22177
  function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previousListStyle) {
22136
22178
  var _a;
22137
22179
  var trigger = textBeforeCursor.trim();
22180
+ var isDoubleParenthesis = trigger[0] === '(' && trigger[trigger.length - 1] === ')';
22138
22181
  //Only the staring items ['1', 'a', 'A', 'I', 'i'] must trigger a new list. All the other triggers is used to keep the list chain.
22139
- //The index is always the character before the last character
22140
- var listIndex = trigger[trigger.length - 2];
22141
- var index = parseInt(listIndex);
22182
+ //The index is always the characters before the last character
22183
+ var listIndex = isDoubleParenthesis ? trigger.slice(1, -1) : trigger.slice(0, -1);
22184
+ var indexNumber = parseInt(listIndex);
22185
+ var index = !isNaN(indexNumber) ? indexNumber : (0, convertAlphaToDecimals_1.default)(listIndex);
22186
+ if (!index || index < 1) {
22187
+ return null;
22188
+ }
22142
22189
  if (previousListChain && index > 1) {
22143
22190
  if ((previousListChain.length < 1 && numberingTriggers.indexOf(listIndex) < 0) ||
22144
22191
  ((previousListChain === null || previousListChain === void 0 ? void 0 : previousListChain.length) > 0 &&
@@ -22146,8 +22193,7 @@ function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previous
22146
22193
  return null;
22147
22194
  }
22148
22195
  }
22149
- var isDoubleParenthesis = trigger[0] === '(' && trigger[trigger.length - 1] === ')';
22150
- var numberingType = isValidNumbering(trigger, isDoubleParenthesis)
22196
+ var numberingType = isValidNumbering(listIndex)
22151
22197
  ? identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle)
22152
22198
  : null;
22153
22199
  return numberingType;
@@ -22155,14 +22201,10 @@ function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previous
22155
22201
  exports.default = getAutoNumberingListStyle;
22156
22202
  /**
22157
22203
  * Check if index has only numbers or only letters to avoid sequence of character such 1:1. trigger a list.
22158
- * @param textBeforeCursor
22159
- * @param isDoubleParenthesis
22204
+ * @param index
22160
22205
  * @returns
22161
22206
  */
22162
- function isValidNumbering(textBeforeCursor, isDoubleParenthesis) {
22163
- var index = isDoubleParenthesis
22164
- ? textBeforeCursor.slice(1, -1)
22165
- : textBeforeCursor.slice(0, -1);
22207
+ function isValidNumbering(index) {
22166
22208
  return Number(index) || /^[A-Za-z\s]*$/.test(index);
22167
22209
  }
22168
22210
 
@@ -23003,10 +23045,8 @@ var ImageEdit = /** @class */ (function () {
23003
23045
  this.setEditingImage(null);
23004
23046
  break;
23005
23047
  case 7 /* ContentChanged */:
23006
- if (e.source !== "Format" /* Format */) {
23007
- // After contentChanged event, the current image wrapper may not be valid any more, remove all of them if any
23008
- this.removeWrapper();
23009
- }
23048
+ //After contentChanged event, the current image wrapper may not be valid any more, remove all of them if any
23049
+ this.removeWrapper();
23010
23050
  break;
23011
23051
  case 8 /* ExtractContentWithDom */:
23012
23052
  // When extract content, remove all image info since they may not be valid when load the content again
@@ -23748,9 +23788,9 @@ function getLatestZIndex(editorDiv) {
23748
23788
  var child = editorDiv;
23749
23789
  var zIndex = 0;
23750
23790
  while (child && (0, roosterjs_editor_dom_1.getTagOfNode)(child) !== 'BODY') {
23751
- var childZIndex = child.style.zIndex || getComputedStyle(child).zIndex;
23791
+ var childZIndex = parseInt(child.style.zIndex || getComputedStyle(child).zIndex, 10);
23752
23792
  if (childZIndex) {
23753
- zIndex = parseInt(child.style.zIndex);
23793
+ zIndex = Math.max(zIndex, childZIndex);
23754
23794
  }
23755
23795
  child = child.parentElement;
23756
23796
  }