roosterjs 9.9.0 → 9.9.1

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 9.9.0)
1
+ // Type definitions for roosterjs (Version 9.9.1)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -11965,6 +11965,8 @@ var applyPendingFormat_1 = __webpack_require__(/*! ./applyPendingFormat */ "./pa
11965
11965
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
11966
11966
  // During IME input, KeyDown event will have "Process" as key
11967
11967
  var ProcessKey = 'Process';
11968
+ // For some Android IME, KeyDown event will have "Unidentified" as key
11969
+ var UnidentifiedKey = 'Unidentified';
11968
11970
  var DefaultStyleKeyMap = {
11969
11971
  backgroundColor: 'backgroundColor',
11970
11972
  textColor: 'color',
@@ -12043,12 +12045,15 @@ var FormatPlugin = /** @class */ (function () {
12043
12045
  this.checkAndApplyPendingFormat(event.rawEvent.data);
12044
12046
  break;
12045
12047
  case 'keyDown':
12048
+ var isAndroidIME = this.editor.getEnvironment().isAndroid && event.rawEvent.key == UnidentifiedKey;
12046
12049
  if ((0, roosterjs_content_model_dom_1.isCursorMovingKey)(event.rawEvent)) {
12047
12050
  this.clearPendingFormat();
12048
12051
  this.lastCheckedNode = null;
12049
12052
  }
12050
12053
  else if (this.defaultFormatKeys.size > 0 &&
12051
- ((0, roosterjs_content_model_dom_1.isCharacterValue)(event.rawEvent) || event.rawEvent.key == ProcessKey) &&
12054
+ (isAndroidIME ||
12055
+ (0, roosterjs_content_model_dom_1.isCharacterValue)(event.rawEvent) ||
12056
+ event.rawEvent.key == ProcessKey) &&
12052
12057
  this.shouldApplyDefaultFormat(this.editor)) {
12053
12058
  (0, applyDefaultFormat_1.applyDefaultFormat)(this.editor, this.state.defaultFormat);
12054
12059
  }
@@ -12838,6 +12843,9 @@ var SelectionPlugin = /** @class */ (function () {
12838
12843
  if (collapsed && td) {
12839
12844
  this.setRangeSelectionInTable(td, key == Up ? td.childNodes.length : 0, this.editor);
12840
12845
  }
12846
+ else if (!td && (lastCo.row == -1 || lastCo.row <= parsedTable.length)) {
12847
+ this.selectBeforeOrAfterElement(this.editor, table, change == 1 /* after */, change != 1 /* setSelectionInNextSiblingElement */);
12848
+ }
12841
12849
  }
12842
12850
  else if (key == 'TabLeft' || key == 'TabRight') {
12843
12851
  var reverse = key == 'TabLeft';
@@ -12909,14 +12917,23 @@ var SelectionPlugin = /** @class */ (function () {
12909
12917
  }
12910
12918
  }
12911
12919
  };
12912
- SelectionPlugin.prototype.selectBeforeOrAfterElement = function (editor, element, after) {
12920
+ SelectionPlugin.prototype.selectBeforeOrAfterElement = function (editor, element, after, setSelectionInNextSiblingElement) {
12913
12921
  var doc = editor.getDocument();
12914
12922
  var parent = element.parentNode;
12915
12923
  var index = parent && (0, roosterjs_content_model_dom_1.toArray)(parent.childNodes).indexOf(element);
12924
+ var sibling;
12916
12925
  if (parent && index !== null && index >= 0) {
12917
12926
  var range = doc.createRange();
12918
- range.setStart(parent, index + (after ? 1 : 0));
12919
- range.collapse();
12927
+ if (setSelectionInNextSiblingElement &&
12928
+ (sibling = after ? element.nextElementSibling : element.previousElementSibling) &&
12929
+ (0, roosterjs_content_model_dom_1.isNodeOfType)(sibling, 'ELEMENT_NODE')) {
12930
+ range.selectNodeContents(sibling);
12931
+ range.collapse(false /* toStart */);
12932
+ }
12933
+ else {
12934
+ range.setStart(parent, index + (after ? 1 : 0));
12935
+ range.collapse();
12936
+ }
12920
12937
  this.setDOMSelection({
12921
12938
  type: 'range',
12922
12939
  range: range,
@@ -19163,8 +19180,9 @@ exports.listLevelThreadFormatHandler = {
19163
19180
  var listFormat = context.listFormat;
19164
19181
  var threadItemCounts = listFormat.threadItemCounts, levels = listFormat.levels;
19165
19182
  var depth = levels.length;
19166
- if (typeof threadItemCounts[depth] === 'number' &&
19167
- element.start != threadItemCounts[depth] + 1) {
19183
+ if (element.start == 1 ||
19184
+ (typeof threadItemCounts[depth] === 'number' &&
19185
+ element.start != threadItemCounts[depth] + 1)) {
19168
19186
  format.startNumberOverride = element.start;
19169
19187
  }
19170
19188
  threadItemCounts[depth] = element.start - 1;
@@ -27041,15 +27059,18 @@ var getOrdinal = function (value) {
27041
27059
  return ORDINALS[value] || 'th';
27042
27060
  };
27043
27061
  /**
27044
- * @internal
27062
+ * The two last characters of ordinal number (st, nd, rd, th)
27045
27063
  */
27046
- function transformOrdinals(previousSegment, paragraph, context) {
27064
+ var ORDINAL_LENGTH = 2;
27065
+ /**
27066
+ * @internal
27067
+ */ function transformOrdinals(previousSegment, paragraph, context) {
27047
27068
  var _a;
27048
27069
  var value = (_a = previousSegment.text.split(' ').pop()) === null || _a === void 0 ? void 0 : _a.trim();
27049
27070
  if (value) {
27050
- var ordinal = value.substring(value.length - 2);
27051
- var ordinalValue = parseInt(value);
27052
- if (ordinalValue && getOrdinal(ordinalValue) === ordinal) {
27071
+ var ordinal = value.substring(value.length - ORDINAL_LENGTH); // This value is equal st, nd, rd, th
27072
+ var numericValue = getNumericValue(value); //This is the numeric part. Ex: 10th, numeric value = 10
27073
+ if (numericValue && getOrdinal(numericValue) === ordinal) {
27053
27074
  var ordinalSegment = (0, roosterjs_content_model_api_1.splitTextSegment)(previousSegment, paragraph, previousSegment.text.length - 3, previousSegment.text.length - 1);
27054
27075
  ordinalSegment.format.superOrSubScriptSequence = 'super';
27055
27076
  context.canUndoByBackspace = true;
@@ -27059,6 +27080,14 @@ function transformOrdinals(previousSegment, paragraph, context) {
27059
27080
  return false;
27060
27081
  }
27061
27082
  exports.transformOrdinals = transformOrdinals;
27083
+ function getNumericValue(text) {
27084
+ var number = text.substring(0, text.length - ORDINAL_LENGTH);
27085
+ var isNumber = /^-?\d+$/.test(number);
27086
+ if (isNumber) {
27087
+ return parseInt(text);
27088
+ }
27089
+ return null;
27090
+ }
27062
27091
 
27063
27092
 
27064
27093
  /***/ }),
@@ -31266,14 +31295,16 @@ var roosterjs_content_model_api_1 = __webpack_require__(/*! roosterjs-content-mo
31266
31295
  function setFormat(editor, character, format, codeFormat) {
31267
31296
  (0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (_model, previousSegment, paragraph, markerFormat, context) {
31268
31297
  if (previousSegment.text[previousSegment.text.length - 1] == character) {
31269
- var textBeforeMarker = previousSegment.text.slice(0, -1);
31298
+ var textSegment = previousSegment.text;
31299
+ var textBeforeMarker = textSegment.slice(0, -1);
31270
31300
  context.newPendingFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, markerFormat), { strikethrough: !!markerFormat.strikethrough, italic: !!markerFormat.italic, fontWeight: (markerFormat === null || markerFormat === void 0 ? void 0 : markerFormat.fontWeight) ? 'bold' : undefined });
31271
31301
  if (textBeforeMarker.indexOf(character) > -1) {
31272
- var lastCharIndex = previousSegment.text.length;
31273
- var firstCharIndex = previousSegment.text
31302
+ var lastCharIndex = textSegment.length;
31303
+ var firstCharIndex = textSegment
31274
31304
  .substring(0, lastCharIndex - 1)
31275
31305
  .lastIndexOf(character);
31276
- if (lastCharIndex - firstCharIndex > 2) {
31306
+ if (hasSpaceBeforeFirstCharacter(textSegment, firstCharIndex) &&
31307
+ lastCharIndex - firstCharIndex > 2) {
31277
31308
  var formattedText = (0, roosterjs_content_model_api_1.splitTextSegment)(previousSegment, paragraph, firstCharIndex, lastCharIndex);
31278
31309
  formattedText.text = formattedText.text.replace(character, '').slice(0, -1);
31279
31310
  formattedText.format = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, formattedText.format), format);
@@ -31291,6 +31322,14 @@ function setFormat(editor, character, format, codeFormat) {
31291
31322
  });
31292
31323
  }
31293
31324
  exports.setFormat = setFormat;
31325
+ /**
31326
+ * The markdown should not be trigger inside a word, then check if exist a space before the trigger character
31327
+ * Should trigger markdown example: _one two_
31328
+ * Should not trigger markdown example: one_two_
31329
+ */
31330
+ function hasSpaceBeforeFirstCharacter(text, index) {
31331
+ return !text[index - 1] || text[index - 1].trim().length == 0;
31332
+ }
31294
31333
 
31295
31334
 
31296
31335
  /***/ }),