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