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