roosterjs 9.52.0 → 9.53.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.
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +30 -2
- package/dist/rooster-amd.js +389 -365
- 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-react.js +53 -53
- package/dist/rooster-react.js.map +1 -1
- package/dist/rooster.d.ts +30 -2
- package/dist/rooster.js +389 -365
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster-amd.js
CHANGED
|
@@ -9056,9 +9056,12 @@ function getContentForCopy(editor, isCut, event) {
|
|
|
9056
9056
|
rawEvent: event,
|
|
9057
9057
|
isCut: isCut,
|
|
9058
9058
|
}).clonedRoot;
|
|
9059
|
+
// Build the text content from the (possibly modified) cloned root DOM tree so that any
|
|
9060
|
+
// changes made by beforeCutCopy event handlers are reflected in the plain text result as well
|
|
9061
|
+
var textModel = (0, roosterjs_content_model_dom_1.domToContentModel)(clonedRoot, (0, roosterjs_content_model_dom_1.createDomToModelContext)());
|
|
9059
9062
|
return {
|
|
9060
9063
|
htmlContent: clonedRoot,
|
|
9061
|
-
textContent: (0, roosterjs_content_model_dom_1.contentModelToText)(
|
|
9064
|
+
textContent: (0, roosterjs_content_model_dom_1.contentModelToText)(textModel),
|
|
9062
9065
|
};
|
|
9063
9066
|
}
|
|
9064
9067
|
}
|
|
@@ -9926,6 +9929,7 @@ var announce = function (core, announceData) {
|
|
|
9926
9929
|
var textToAnnounce = formatString(template || text, formatStrings);
|
|
9927
9930
|
if (!core.lifecycle.announceContainer) {
|
|
9928
9931
|
core.lifecycle.announceContainer = (0, createAriaLiveElement_1.createAriaLiveElement)(core.physicalRoot.ownerDocument);
|
|
9932
|
+
core.domHelper.appendToRoot(core.lifecycle.announceContainer);
|
|
9929
9933
|
}
|
|
9930
9934
|
if (textToAnnounce && core.lifecycle.announceContainer) {
|
|
9931
9935
|
var announceContainer = core.lifecycle.announceContainer;
|
|
@@ -10417,16 +10421,19 @@ var getDOMSelection = function (core) {
|
|
|
10417
10421
|
exports.getDOMSelection = getDOMSelection;
|
|
10418
10422
|
function getNewSelection(core) {
|
|
10419
10423
|
var _a;
|
|
10424
|
+
var range = core.domHelper.getSelectionRange();
|
|
10425
|
+
if (!range || !core.logicalRoot.contains(range.commonAncestorContainer)) {
|
|
10426
|
+
return null;
|
|
10427
|
+
}
|
|
10420
10428
|
var selection = (_a = core.logicalRoot.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
10421
|
-
var
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
: null;
|
|
10429
|
+
var isReverted = selection
|
|
10430
|
+
? selection.focusNode != range.endContainer || selection.focusOffset != range.endOffset
|
|
10431
|
+
: false;
|
|
10432
|
+
return {
|
|
10433
|
+
type: 'range',
|
|
10434
|
+
range: range,
|
|
10435
|
+
isReverted: isReverted,
|
|
10436
|
+
};
|
|
10430
10437
|
}
|
|
10431
10438
|
|
|
10432
10439
|
|
|
@@ -10870,43 +10877,6 @@ var setContentModel = function (core, model, option, onNodeCreated, isInitializi
|
|
|
10870
10877
|
exports.setContentModel = setContentModel;
|
|
10871
10878
|
|
|
10872
10879
|
|
|
10873
|
-
/***/ },
|
|
10874
|
-
|
|
10875
|
-
/***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/addRangeToSelection.ts"
|
|
10876
|
-
/*!**************************************************************************************************!*\
|
|
10877
|
-
!*** ./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/addRangeToSelection.ts ***!
|
|
10878
|
-
\**************************************************************************************************/
|
|
10879
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
10880
|
-
|
|
10881
|
-
"use strict";
|
|
10882
|
-
|
|
10883
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10884
|
-
exports.addRangeToSelection = void 0;
|
|
10885
|
-
var areSameSelections_1 = __webpack_require__(/*! ../../corePlugin/cache/areSameSelections */ "./packages/roosterjs-content-model-core/lib/corePlugin/cache/areSameSelections.ts");
|
|
10886
|
-
/**
|
|
10887
|
-
* @internal
|
|
10888
|
-
*/
|
|
10889
|
-
function addRangeToSelection(doc, range, isReverted) {
|
|
10890
|
-
var _a;
|
|
10891
|
-
if (isReverted === void 0) { isReverted = false; }
|
|
10892
|
-
var selection = (_a = doc.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
10893
|
-
if (selection) {
|
|
10894
|
-
var currentRange = selection.rangeCount > 0 && selection.getRangeAt(0);
|
|
10895
|
-
if (currentRange && (0, areSameSelections_1.areSameRanges)(currentRange, range)) {
|
|
10896
|
-
return;
|
|
10897
|
-
}
|
|
10898
|
-
selection.removeAllRanges();
|
|
10899
|
-
if (!isReverted) {
|
|
10900
|
-
selection.addRange(range);
|
|
10901
|
-
}
|
|
10902
|
-
else {
|
|
10903
|
-
selection.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
|
|
10904
|
-
}
|
|
10905
|
-
}
|
|
10906
|
-
}
|
|
10907
|
-
exports.addRangeToSelection = addRangeToSelection;
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
10880
|
/***/ },
|
|
10911
10881
|
|
|
10912
10882
|
/***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findLastedCoInMergedCell.ts"
|
|
@@ -11008,7 +10978,6 @@ exports.findTableCellElement = findTableCellElement;
|
|
|
11008
10978
|
|
|
11009
10979
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11010
10980
|
exports.setDOMSelection = void 0;
|
|
11011
|
-
var addRangeToSelection_1 = __webpack_require__(/*! ./addRangeToSelection */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/addRangeToSelection.ts");
|
|
11012
10981
|
var areSameSelections_1 = __webpack_require__(/*! ../../corePlugin/cache/areSameSelections */ "./packages/roosterjs-content-model-core/lib/corePlugin/cache/areSameSelections.ts");
|
|
11013
10982
|
var ensureUniqueId_1 = __webpack_require__(/*! ../setEditorStyle/ensureUniqueId */ "./packages/roosterjs-content-model-core/lib/coreApi/setEditorStyle/ensureUniqueId.ts");
|
|
11014
10983
|
var findLastedCoInMergedCell_1 = __webpack_require__(/*! ./findLastedCoInMergedCell */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findLastedCoInMergedCell.ts");
|
|
@@ -11034,7 +11003,6 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11034
11003
|
// We are applying a new selection, so we don't need to apply cached selection in DOMEventPlugin.
|
|
11035
11004
|
// Set skipReselectOnFocus to skip this behavior
|
|
11036
11005
|
var skipReselectOnFocus = core.selection.skipReselectOnFocus;
|
|
11037
|
-
var doc = core.physicalRoot.ownerDocument;
|
|
11038
11006
|
var isDarkMode = core.lifecycle.isDarkMode;
|
|
11039
11007
|
core.selection.skipReselectOnFocus = true;
|
|
11040
11008
|
core.api.setEditorStyle(core, DOM_SELECTION_CSS_KEY, null /*cssRule*/);
|
|
@@ -11050,7 +11018,7 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11050
11018
|
: core.selection.imageSelectionBorderColor;
|
|
11051
11019
|
core.api.setEditorStyle(core, DOM_SELECTION_CSS_KEY, "outline-style:solid!important; outline-color:" + (imageSelectionColor || DEFAULT_SELECTION_BORDER_COLOR) + "!important;", [(0, roosterjs_content_model_dom_1.getSafeIdSelector)((0, ensureUniqueId_1.ensureUniqueId)(image, IMAGE_ID))]);
|
|
11052
11020
|
core.api.setEditorStyle(core, HIDE_SELECTION_CSS_KEY, TRANSPARENT_SELECTION_CSS_RULE, [SELECTION_SELECTOR]);
|
|
11053
|
-
setRangeSelection(
|
|
11021
|
+
setRangeSelection(core, image, false /* collapse */);
|
|
11054
11022
|
break;
|
|
11055
11023
|
case 'table':
|
|
11056
11024
|
var table = selection.table, firstColumn = selection.firstColumn, firstRow = selection.firstRow, lastColumn = selection.lastColumn, lastRow = selection.lastRow;
|
|
@@ -11087,11 +11055,11 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11087
11055
|
(0, toggleCaret_1.toggleCaret)(core, true /* hide */);
|
|
11088
11056
|
var nodeToSelect = ((_a = firstCell.cell) === null || _a === void 0 ? void 0 : _a.firstElementChild) || firstCell.cell;
|
|
11089
11057
|
if (nodeToSelect) {
|
|
11090
|
-
setRangeSelection(
|
|
11058
|
+
setRangeSelection(core, nodeToSelect || undefined, true /* collapse */);
|
|
11091
11059
|
}
|
|
11092
11060
|
break;
|
|
11093
11061
|
case 'range':
|
|
11094
|
-
|
|
11062
|
+
core.domHelper.setSelectionRange(selection.range, selection.isReverted);
|
|
11095
11063
|
core.selection.selection = core.domHelper.hasFocus() ? null : selection;
|
|
11096
11064
|
break;
|
|
11097
11065
|
default:
|
|
@@ -11111,9 +11079,10 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11111
11079
|
}
|
|
11112
11080
|
};
|
|
11113
11081
|
exports.setDOMSelection = setDOMSelection;
|
|
11114
|
-
function setRangeSelection(
|
|
11082
|
+
function setRangeSelection(core, element, collapse) {
|
|
11115
11083
|
var _a;
|
|
11116
|
-
if (element &&
|
|
11084
|
+
if (element && core.domHelper.isNodeInEditor(element)) {
|
|
11085
|
+
var doc = core.physicalRoot.ownerDocument;
|
|
11117
11086
|
var range = doc.createRange();
|
|
11118
11087
|
var isReverted = undefined;
|
|
11119
11088
|
range.selectNode(element);
|
|
@@ -11129,7 +11098,7 @@ function setRangeSelection(doc, element, collapse) {
|
|
|
11129
11098
|
selection.focusOffset != range_1.endOffset;
|
|
11130
11099
|
}
|
|
11131
11100
|
}
|
|
11132
|
-
|
|
11101
|
+
core.domHelper.setSelectionRange(range, isReverted);
|
|
11133
11102
|
}
|
|
11134
11103
|
}
|
|
11135
11104
|
|
|
@@ -11316,9 +11285,9 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
|
|
|
11316
11285
|
*/
|
|
11317
11286
|
function ensureUniqueId(element, idPrefix) {
|
|
11318
11287
|
idPrefix = element.id || idPrefix;
|
|
11319
|
-
var
|
|
11288
|
+
var root = element.getRootNode();
|
|
11320
11289
|
var i = 0;
|
|
11321
|
-
while (!element.id ||
|
|
11290
|
+
while (!element.id || root.querySelectorAll((0, roosterjs_content_model_dom_1.getSafeIdSelector)(element.id)).length > 1) {
|
|
11322
11291
|
element.id = idPrefix + '_' + i++;
|
|
11323
11292
|
}
|
|
11324
11293
|
return element.id;
|
|
@@ -11351,7 +11320,7 @@ var setEditorStyle = function (core, key, cssRule, subSelectors, maxRuleLength)
|
|
|
11351
11320
|
if (!styleElement && cssRule) {
|
|
11352
11321
|
var doc = core.physicalRoot.ownerDocument;
|
|
11353
11322
|
styleElement = doc.createElement('style');
|
|
11354
|
-
|
|
11323
|
+
core.domHelper.appendToRoot(styleElement);
|
|
11355
11324
|
styleElement.dataset.roosterjsStyleKey = key;
|
|
11356
11325
|
core.lifecycle.styleElements[key] = styleElement;
|
|
11357
11326
|
}
|
|
@@ -11829,12 +11798,13 @@ exports.createParagraphMap = createParagraphMap;
|
|
|
11829
11798
|
/*!*****************************************************************************************!*\
|
|
11830
11799
|
!*** ./packages/roosterjs-content-model-core/lib/corePlugin/cache/areSameSelections.ts ***!
|
|
11831
11800
|
\*****************************************************************************************/
|
|
11832
|
-
(__unused_webpack_module, exports) {
|
|
11801
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11833
11802
|
|
|
11834
11803
|
"use strict";
|
|
11835
11804
|
|
|
11836
11805
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11837
|
-
exports.
|
|
11806
|
+
exports.areSameTableSelections = exports.areSameSelections = void 0;
|
|
11807
|
+
var areSameRanges_1 = __webpack_require__(/*! ../../utils/areSameRanges */ "./packages/roosterjs-content-model-core/lib/utils/areSameRanges.ts");
|
|
11838
11808
|
/**
|
|
11839
11809
|
* @internal
|
|
11840
11810
|
* Check if the given selections are the same
|
|
@@ -11860,7 +11830,7 @@ function areSameSelections(sel1, sel2) {
|
|
|
11860
11830
|
range1.endOffset == end.offset);
|
|
11861
11831
|
}
|
|
11862
11832
|
else {
|
|
11863
|
-
return areSameRanges(range1, sel2.range);
|
|
11833
|
+
return (0, areSameRanges_1.areSameRanges)(range1, sel2.range);
|
|
11864
11834
|
}
|
|
11865
11835
|
}
|
|
11866
11836
|
else {
|
|
@@ -11879,7 +11849,6 @@ var TableSelectionKeys = [
|
|
|
11879
11849
|
'firstRow',
|
|
11880
11850
|
'lastRow',
|
|
11881
11851
|
];
|
|
11882
|
-
var RangeKeys = ['startContainer', 'endContainer', 'startOffset', 'endOffset'];
|
|
11883
11852
|
/**
|
|
11884
11853
|
* @internal
|
|
11885
11854
|
*/
|
|
@@ -11887,13 +11856,6 @@ function areSameTableSelections(t1, t2) {
|
|
|
11887
11856
|
return areSame(t1, t2, TableSelectionKeys);
|
|
11888
11857
|
}
|
|
11889
11858
|
exports.areSameTableSelections = areSameTableSelections;
|
|
11890
|
-
/**
|
|
11891
|
-
* @internal
|
|
11892
|
-
*/
|
|
11893
|
-
function areSameRanges(r1, r2) {
|
|
11894
|
-
return areSame(r1, r2, RangeKeys);
|
|
11895
|
-
}
|
|
11896
|
-
exports.areSameRanges = areSameRanges;
|
|
11897
11859
|
function isCacheSelection(sel) {
|
|
11898
11860
|
return !!sel.start;
|
|
11899
11861
|
}
|
|
@@ -12071,7 +12033,13 @@ var DomIndexerImpl = /** @class */ (function () {
|
|
|
12071
12033
|
}
|
|
12072
12034
|
else {
|
|
12073
12035
|
var marker1 = this.reconcileNodeSelection(startContainer, startOffset);
|
|
12074
|
-
|
|
12036
|
+
// Pass marker1 to the second call so its adjacent-marker cleanup
|
|
12037
|
+
// does not consume the SelectionMarker we just inserted. Without
|
|
12038
|
+
// this guard, when marker1 lands directly next to endContainer's
|
|
12039
|
+
// segment in paragraph.segments (e.g. startOffset == startContainer
|
|
12040
|
+
// text length), the second splice would absorb marker1 and leave
|
|
12041
|
+
// setSelection with a dangling reference. See issue #3341.
|
|
12042
|
+
var marker2 = this.reconcileNodeSelection(endContainer, endOffset, undefined, undefined, marker1);
|
|
12075
12043
|
if (marker1 && marker2) {
|
|
12076
12044
|
if (newSelection.isReverted) {
|
|
12077
12045
|
model.hasRevertedRangeSelection = true;
|
|
@@ -12147,10 +12115,10 @@ var DomIndexerImpl = /** @class */ (function () {
|
|
|
12147
12115
|
var start = selection.start, end = selection.end;
|
|
12148
12116
|
return start.node == end.node && start.offset == end.offset;
|
|
12149
12117
|
};
|
|
12150
|
-
DomIndexerImpl.prototype.reconcileNodeSelection = function (node, offset, defaultFormat, selectionMarker) {
|
|
12118
|
+
DomIndexerImpl.prototype.reconcileNodeSelection = function (node, offset, defaultFormat, selectionMarker, preserveMarker) {
|
|
12151
12119
|
if ((0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'TEXT_NODE')) {
|
|
12152
12120
|
if (isIndexedSegment(node)) {
|
|
12153
|
-
return this.reconcileTextSelection(node, offset, undefined, selectionMarker);
|
|
12121
|
+
return this.reconcileTextSelection(node, offset, undefined, selectionMarker, preserveMarker);
|
|
12154
12122
|
}
|
|
12155
12123
|
else if (isIndexedDelimiter(node)) {
|
|
12156
12124
|
return this.reconcileDelimiterSelection(node, defaultFormat);
|
|
@@ -12180,7 +12148,7 @@ var DomIndexerImpl = /** @class */ (function () {
|
|
|
12180
12148
|
}
|
|
12181
12149
|
return marker;
|
|
12182
12150
|
};
|
|
12183
|
-
DomIndexerImpl.prototype.reconcileTextSelection = function (textNode, startOffset, endOffset, selectionMarker) {
|
|
12151
|
+
DomIndexerImpl.prototype.reconcileTextSelection = function (textNode, startOffset, endOffset, selectionMarker, preserveMarker) {
|
|
12184
12152
|
var _a;
|
|
12185
12153
|
var _b, _c, _d, _e, _f, _g;
|
|
12186
12154
|
var _h = textNode.__roosterjsContentModel, paragraph = _h.paragraph, segments = _h.segments;
|
|
@@ -12233,11 +12201,13 @@ var DomIndexerImpl = /** @class */ (function () {
|
|
|
12233
12201
|
var lastIndex = paragraph.segments.indexOf(last);
|
|
12234
12202
|
if (firstIndex >= 0 && lastIndex >= 0) {
|
|
12235
12203
|
while (firstIndex > 0 &&
|
|
12236
|
-
paragraph.segments[firstIndex - 1].segmentType == 'SelectionMarker'
|
|
12204
|
+
paragraph.segments[firstIndex - 1].segmentType == 'SelectionMarker' &&
|
|
12205
|
+
paragraph.segments[firstIndex - 1] !== preserveMarker) {
|
|
12237
12206
|
firstIndex--;
|
|
12238
12207
|
}
|
|
12239
12208
|
while (lastIndex < paragraph.segments.length - 1 &&
|
|
12240
|
-
paragraph.segments[lastIndex + 1].segmentType == 'SelectionMarker'
|
|
12209
|
+
paragraph.segments[lastIndex + 1].segmentType == 'SelectionMarker' &&
|
|
12210
|
+
paragraph.segments[lastIndex + 1] !== preserveMarker) {
|
|
12241
12211
|
lastIndex++;
|
|
12242
12212
|
}
|
|
12243
12213
|
(_a = paragraph.segments).splice.apply(_a, (0, tslib_1.__spreadArray)([firstIndex, lastIndex - firstIndex + 1], (0, tslib_1.__read)(newSegments), false));
|
|
@@ -14355,6 +14325,7 @@ var LifecyclePlugin = /** @class */ (function () {
|
|
|
14355
14325
|
delete this.state.rewriteFromModel;
|
|
14356
14326
|
// Initialize the Announce container.
|
|
14357
14327
|
this.state.announceContainer = (0, createAriaLiveElement_1.createAriaLiveElement)(editor.getDocument());
|
|
14328
|
+
editor.getDOMHelper().appendToRoot(this.state.announceContainer);
|
|
14358
14329
|
};
|
|
14359
14330
|
/**
|
|
14360
14331
|
* Dispose this plugin
|
|
@@ -14548,20 +14519,23 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14548
14519
|
}
|
|
14549
14520
|
};
|
|
14550
14521
|
this.onSelectionChange = function () {
|
|
14551
|
-
var _a;
|
|
14522
|
+
var _a, _b;
|
|
14552
14523
|
if (((_a = _this.editor) === null || _a === void 0 ? void 0 : _a.hasFocus()) && !_this.editor.isInShadowEdit()) {
|
|
14553
14524
|
var newSelection = _this.editor.getDOMSelection();
|
|
14525
|
+
var domHelper = _this.editor.getDOMHelper();
|
|
14554
14526
|
//If am image selection changed to a wider range due a keyboard event, we should update the selection
|
|
14555
|
-
var
|
|
14556
|
-
if (
|
|
14557
|
-
var image = (0, isSingleImageInSelection_1.isSingleImageInSelection)(
|
|
14527
|
+
var range = domHelper.getSelectionRange();
|
|
14528
|
+
if (range) {
|
|
14529
|
+
var image = (0, isSingleImageInSelection_1.isSingleImageInSelection)(range);
|
|
14558
14530
|
if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) == 'image' && !image) {
|
|
14559
|
-
var
|
|
14531
|
+
var sel = (_b = _this.editor.getDocument().defaultView) === null || _b === void 0 ? void 0 : _b.getSelection();
|
|
14532
|
+
var isReverted = sel
|
|
14533
|
+
? sel.focusNode != range.endContainer || sel.focusOffset != range.endOffset
|
|
14534
|
+
: false;
|
|
14560
14535
|
_this.editor.setDOMSelection({
|
|
14561
14536
|
type: 'range',
|
|
14562
14537
|
range: range,
|
|
14563
|
-
isReverted:
|
|
14564
|
-
selection.focusOffset != range.endOffset,
|
|
14538
|
+
isReverted: isReverted,
|
|
14565
14539
|
});
|
|
14566
14540
|
}
|
|
14567
14541
|
else if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) !== 'image' && image) {
|
|
@@ -15950,10 +15924,23 @@ exports.Editor = Editor;
|
|
|
15950
15924
|
|
|
15951
15925
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15952
15926
|
exports.createDOMHelper = void 0;
|
|
15927
|
+
var areSameRanges_1 = __webpack_require__(/*! ../../utils/areSameRanges */ "./packages/roosterjs-content-model-core/lib/utils/areSameRanges.ts");
|
|
15953
15928
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
15929
|
+
function isSelectionWithComposedRanges(sel) {
|
|
15930
|
+
return 'getComposedRanges' in sel;
|
|
15931
|
+
}
|
|
15932
|
+
function isShadowRoot(node) {
|
|
15933
|
+
return 'host' in node;
|
|
15934
|
+
}
|
|
15954
15935
|
var DOMHelperImpl = /** @class */ (function () {
|
|
15955
15936
|
function DOMHelperImpl(contentDiv, options) {
|
|
15937
|
+
var _a;
|
|
15956
15938
|
this.contentDiv = contentDiv;
|
|
15939
|
+
var rootNode = contentDiv.getRootNode();
|
|
15940
|
+
this.shadowRoot = (options === null || options === void 0 ? void 0 : options.useShadowDom) && isShadowRoot(rootNode) ? rootNode : null;
|
|
15941
|
+
this.doc = contentDiv.ownerDocument;
|
|
15942
|
+
var sel = (_a = this.doc.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
15943
|
+
this.useComposedRanges = !!(this.shadowRoot && sel && 'getComposedRanges' in sel);
|
|
15957
15944
|
}
|
|
15958
15945
|
DOMHelperImpl.prototype.queryElements = function (selector) {
|
|
15959
15946
|
return (0, roosterjs_content_model_dom_1.toArray)(this.contentDiv.querySelectorAll(selector));
|
|
@@ -16015,7 +16002,9 @@ var DOMHelperImpl = /** @class */ (function () {
|
|
|
16015
16002
|
return this.contentDiv;
|
|
16016
16003
|
};
|
|
16017
16004
|
DOMHelperImpl.prototype.hasFocus = function () {
|
|
16018
|
-
var activeElement = this.
|
|
16005
|
+
var activeElement = this.shadowRoot
|
|
16006
|
+
? this.shadowRoot.activeElement
|
|
16007
|
+
: this.doc.activeElement;
|
|
16019
16008
|
return !!(activeElement && this.contentDiv.contains(activeElement));
|
|
16020
16009
|
};
|
|
16021
16010
|
/**
|
|
@@ -16082,6 +16071,51 @@ var DOMHelperImpl = /** @class */ (function () {
|
|
|
16082
16071
|
DOMHelperImpl.prototype.getRangesByText = function (text, matchCase, wholeWord) {
|
|
16083
16072
|
return (0, roosterjs_content_model_dom_1.getRangesByText)(this.contentDiv, text, matchCase, wholeWord, true /*editableOnly*/);
|
|
16084
16073
|
};
|
|
16074
|
+
DOMHelperImpl.prototype.getSelectionRange = function () {
|
|
16075
|
+
var _a;
|
|
16076
|
+
var sel = (_a = this.doc.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
16077
|
+
if (!sel) {
|
|
16078
|
+
return null;
|
|
16079
|
+
}
|
|
16080
|
+
if (this.useComposedRanges && this.shadowRoot && isSelectionWithComposedRanges(sel)) {
|
|
16081
|
+
var staticRanges = sel.getComposedRanges({
|
|
16082
|
+
shadowRoots: [this.shadowRoot],
|
|
16083
|
+
});
|
|
16084
|
+
if ((staticRanges === null || staticRanges === void 0 ? void 0 : staticRanges.length) > 0) {
|
|
16085
|
+
var sr = staticRanges[0];
|
|
16086
|
+
var range = this.doc.createRange();
|
|
16087
|
+
range.setStart(sr.startContainer, sr.startOffset);
|
|
16088
|
+
range.setEnd(sr.endContainer, sr.endOffset);
|
|
16089
|
+
return range;
|
|
16090
|
+
}
|
|
16091
|
+
return null;
|
|
16092
|
+
}
|
|
16093
|
+
return sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
|
|
16094
|
+
};
|
|
16095
|
+
DOMHelperImpl.prototype.setSelectionRange = function (range, isReverted) {
|
|
16096
|
+
var _a;
|
|
16097
|
+
if (isReverted === void 0) { isReverted = false; }
|
|
16098
|
+
var sel = (_a = this.doc.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
16099
|
+
var currentRange = this.getSelectionRange();
|
|
16100
|
+
if (!sel || (currentRange && (0, areSameRanges_1.areSameRanges)(range, currentRange))) {
|
|
16101
|
+
return;
|
|
16102
|
+
}
|
|
16103
|
+
var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
|
|
16104
|
+
if (!isReverted) {
|
|
16105
|
+
sel.setBaseAndExtent(startContainer, startOffset, endContainer, endOffset);
|
|
16106
|
+
}
|
|
16107
|
+
else {
|
|
16108
|
+
sel.setBaseAndExtent(endContainer, endOffset, startContainer, startOffset);
|
|
16109
|
+
}
|
|
16110
|
+
};
|
|
16111
|
+
DOMHelperImpl.prototype.appendToRoot = function (element) {
|
|
16112
|
+
if (this.shadowRoot) {
|
|
16113
|
+
this.shadowRoot.appendChild(element);
|
|
16114
|
+
}
|
|
16115
|
+
else {
|
|
16116
|
+
this.doc.body.appendChild(element);
|
|
16117
|
+
}
|
|
16118
|
+
};
|
|
16085
16119
|
return DOMHelperImpl;
|
|
16086
16120
|
}());
|
|
16087
16121
|
/**
|
|
@@ -16198,7 +16232,10 @@ function createEditorCore(contentDiv, options) {
|
|
|
16198
16232
|
corePlugins.lifecycle,
|
|
16199
16233
|
], false), environment: createEditorEnvironment(contentDiv, options), darkColorHandler: (0, DarkColorHandlerImpl_1.createDarkColorHandler)(contentDiv, (_b = options.getDarkColor) !== null && _b !== void 0 ? _b : getDarkColorFallback, options.knownColors, options.generateColorKey), trustedHTMLHandler: options.trustedHTMLHandler && !(0, domCreator_1.isDOMCreator)(options.trustedHTMLHandler)
|
|
16200
16234
|
? options.trustedHTMLHandler
|
|
16201
|
-
: (0, domCreator_1.createTrustedHTMLHandler)(domCreator), domCreator: domCreator, domHelper: (0, DOMHelperImpl_1.createDOMHelper)(contentDiv
|
|
16235
|
+
: (0, domCreator_1.createTrustedHTMLHandler)(domCreator), domCreator: domCreator, domHelper: (0, DOMHelperImpl_1.createDOMHelper)(contentDiv, {
|
|
16236
|
+
useShadowDom: !!options.experimentalFeatures &&
|
|
16237
|
+
options.experimentalFeatures.indexOf('ShadowDom') >= 0,
|
|
16238
|
+
}) }, getPluginState(corePlugins)), { disposeErrorHandler: options.disposeErrorHandler, onFixUpModel: options.onFixUpModel, experimentalFeatures: options.experimentalFeatures ? (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(options.experimentalFeatures), false) : [] });
|
|
16202
16239
|
}
|
|
16203
16240
|
exports.createEditorCore = createEditorCore;
|
|
16204
16241
|
function createEditorEnvironment(contentDiv, options) {
|
|
@@ -16356,6 +16393,8 @@ var containerSizeFormatParser = function (format, element) {
|
|
|
16356
16393
|
if (element.tagName == 'DIV' || element.tagName == 'P') {
|
|
16357
16394
|
delete format.width;
|
|
16358
16395
|
delete format.height;
|
|
16396
|
+
delete format.maxHeight;
|
|
16397
|
+
delete format.maxWidth;
|
|
16359
16398
|
}
|
|
16360
16399
|
};
|
|
16361
16400
|
exports.containerSizeFormatParser = containerSizeFormatParser;
|
|
@@ -16652,6 +16691,29 @@ var pasteWhiteSpaceFormatParser = function (format, element, context, defaultSty
|
|
|
16652
16691
|
exports.pasteWhiteSpaceFormatParser = pasteWhiteSpaceFormatParser;
|
|
16653
16692
|
|
|
16654
16693
|
|
|
16694
|
+
/***/ },
|
|
16695
|
+
|
|
16696
|
+
/***/ "./packages/roosterjs-content-model-core/lib/utils/areSameRanges.ts"
|
|
16697
|
+
/*!**************************************************************************!*\
|
|
16698
|
+
!*** ./packages/roosterjs-content-model-core/lib/utils/areSameRanges.ts ***!
|
|
16699
|
+
\**************************************************************************/
|
|
16700
|
+
(__unused_webpack_module, exports) {
|
|
16701
|
+
|
|
16702
|
+
"use strict";
|
|
16703
|
+
|
|
16704
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
16705
|
+
exports.areSameRanges = void 0;
|
|
16706
|
+
var RangeKeys = ['startContainer', 'endContainer', 'startOffset', 'endOffset'];
|
|
16707
|
+
/**
|
|
16708
|
+
* @internal
|
|
16709
|
+
* Check if two ranges have the same start and end positions.
|
|
16710
|
+
*/
|
|
16711
|
+
function areSameRanges(r1, r2) {
|
|
16712
|
+
return RangeKeys.every(function (k) { return r1[k] == r2[k]; });
|
|
16713
|
+
}
|
|
16714
|
+
exports.areSameRanges = areSameRanges;
|
|
16715
|
+
|
|
16716
|
+
|
|
16655
16717
|
/***/ },
|
|
16656
16718
|
|
|
16657
16719
|
/***/ "./packages/roosterjs-content-model-core/lib/utils/createAriaLiveElement.ts"
|
|
@@ -16677,7 +16739,6 @@ function createAriaLiveElement(document) {
|
|
|
16677
16739
|
div.style.whiteSpace = 'nowrap';
|
|
16678
16740
|
div.style.width = '1px';
|
|
16679
16741
|
div.ariaLive = 'assertive';
|
|
16680
|
-
document.body.appendChild(div);
|
|
16681
16742
|
return div;
|
|
16682
16743
|
}
|
|
16683
16744
|
exports.createAriaLiveElement = createAriaLiveElement;
|
|
@@ -21168,11 +21229,13 @@ exports.directionFormatHandler = {
|
|
|
21168
21229
|
format.direction = dir == 'rtl' ? 'rtl' : 'ltr';
|
|
21169
21230
|
}
|
|
21170
21231
|
},
|
|
21171
|
-
apply: function (format, element) {
|
|
21232
|
+
apply: function (format, element, context) {
|
|
21172
21233
|
if (format.direction) {
|
|
21173
21234
|
element.style.direction = format.direction;
|
|
21174
21235
|
}
|
|
21175
|
-
if (format.direction == 'rtl' &&
|
|
21236
|
+
if (format.direction == 'rtl' &&
|
|
21237
|
+
(0, isElementOfType_1.isElementOfType)(element, 'table') &&
|
|
21238
|
+
context.implicitFormat.direction != 'rtl') {
|
|
21176
21239
|
element.style.justifySelf = 'flex-end';
|
|
21177
21240
|
}
|
|
21178
21241
|
},
|
|
@@ -21709,6 +21772,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
21709
21772
|
exports.borderFormatHandler = void 0;
|
|
21710
21773
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
21711
21774
|
var borderKeys_1 = __webpack_require__(/*! ../utils/borderKeys */ "./packages/roosterjs-content-model-dom/lib/formatHandlers/utils/borderKeys.ts");
|
|
21775
|
+
var borderValues_1 = __webpack_require__(/*! ../../domUtils/style/borderValues */ "./packages/roosterjs-content-model-dom/lib/domUtils/style/borderValues.ts");
|
|
21712
21776
|
// This array needs to match BorderKeys array
|
|
21713
21777
|
var BorderWidthKeys = [
|
|
21714
21778
|
'borderTopWidth',
|
|
@@ -21737,7 +21801,17 @@ exports.borderFormatHandler = {
|
|
|
21737
21801
|
width = '0px';
|
|
21738
21802
|
}
|
|
21739
21803
|
if (value && width != defaultWidth) {
|
|
21740
|
-
|
|
21804
|
+
var result = value;
|
|
21805
|
+
if (result.includes('initial')) {
|
|
21806
|
+
// Remove 'initial' from the last part (color) of the border value
|
|
21807
|
+
// since browsers ignore it when setting the inline style property
|
|
21808
|
+
var border = (0, borderValues_1.extractBorderValues)(value);
|
|
21809
|
+
if (border.color === 'initial') {
|
|
21810
|
+
border.color = '';
|
|
21811
|
+
}
|
|
21812
|
+
result = (0, borderValues_1.combineBorderValue)(border);
|
|
21813
|
+
}
|
|
21814
|
+
format[key] = result == 'none' ? '' : result;
|
|
21741
21815
|
}
|
|
21742
21816
|
});
|
|
21743
21817
|
var borderRadius = element.style.borderRadius;
|
|
@@ -24139,6 +24213,7 @@ var createText_1 = __webpack_require__(/*! ../creators/createText */ "./packages
|
|
|
24139
24213
|
var ensureParagraph_1 = __webpack_require__(/*! ./ensureParagraph */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/ensureParagraph.ts");
|
|
24140
24214
|
var hasSpacesOnly_1 = __webpack_require__(/*! ./hasSpacesOnly */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/hasSpacesOnly.ts");
|
|
24141
24215
|
var isWhiteSpacePreserved_1 = __webpack_require__(/*! ../../domUtils/isWhiteSpacePreserved */ "./packages/roosterjs-content-model-dom/lib/domUtils/isWhiteSpacePreserved.ts");
|
|
24216
|
+
var stripInvisibleUnicode_1 = __webpack_require__(/*! ./stripInvisibleUnicode */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts");
|
|
24142
24217
|
/**
|
|
24143
24218
|
* Add a new text segment to current paragraph
|
|
24144
24219
|
* @param group Current BlockGroup that the paragraph belong to
|
|
@@ -24154,7 +24229,11 @@ function addTextSegment(group, text, context) {
|
|
|
24154
24229
|
if (!(0, hasSpacesOnly_1.hasSpacesOnly)(text) ||
|
|
24155
24230
|
((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.segments.length) !== null && _a !== void 0 ? _a : 0) > 0 ||
|
|
24156
24231
|
(0, isWhiteSpacePreserved_1.isWhiteSpacePreserved)(paragraph === null || paragraph === void 0 ? void 0 : paragraph.format.whiteSpace)) {
|
|
24157
|
-
|
|
24232
|
+
var filteredText = context.experimentalFeatures &&
|
|
24233
|
+
context.experimentalFeatures.indexOf('FilterInvisibleUnicode') > -1
|
|
24234
|
+
? (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(text)
|
|
24235
|
+
: text;
|
|
24236
|
+
textModel = (0, createText_1.createText)(filteredText, context.segmentFormat);
|
|
24158
24237
|
if (context.isInSelection) {
|
|
24159
24238
|
textModel.isSelected = true;
|
|
24160
24239
|
}
|
|
@@ -24789,6 +24868,34 @@ function normalizeSegmentFormat(format, environment) {
|
|
|
24789
24868
|
exports.normalizeSegmentFormat = normalizeSegmentFormat;
|
|
24790
24869
|
|
|
24791
24870
|
|
|
24871
|
+
/***/ },
|
|
24872
|
+
|
|
24873
|
+
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"
|
|
24874
|
+
/*!*******************************************************************************************!*\
|
|
24875
|
+
!*** ./packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts ***!
|
|
24876
|
+
\*******************************************************************************************/
|
|
24877
|
+
(__unused_webpack_module, exports) {
|
|
24878
|
+
|
|
24879
|
+
"use strict";
|
|
24880
|
+
|
|
24881
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24882
|
+
exports.stripInvisibleUnicode = void 0;
|
|
24883
|
+
// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
|
|
24884
|
+
// there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.
|
|
24885
|
+
// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
|
|
24886
|
+
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{EFFFF}]/gu;
|
|
24887
|
+
/**
|
|
24888
|
+
* @internal
|
|
24889
|
+
* Strip invisible unicode characters from the given string
|
|
24890
|
+
* @param value The string to be processed
|
|
24891
|
+
* @returns The string with invisible unicode characters removed
|
|
24892
|
+
*/
|
|
24893
|
+
function stripInvisibleUnicode(value) {
|
|
24894
|
+
return value.replace(INVISIBLE_UNICODE_REGEX, '');
|
|
24895
|
+
}
|
|
24896
|
+
exports.stripInvisibleUnicode = stripInvisibleUnicode;
|
|
24897
|
+
|
|
24898
|
+
|
|
24792
24899
|
/***/ },
|
|
24793
24900
|
|
|
24794
24901
|
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/common/unwrapBlock.ts"
|
|
@@ -25247,16 +25354,25 @@ exports.createParagraphDecorator = createParagraphDecorator;
|
|
|
25247
25354
|
|
|
25248
25355
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25249
25356
|
exports.createSelectionMarker = void 0;
|
|
25250
|
-
var
|
|
25357
|
+
var EmptySegmentFormat_1 = __webpack_require__(/*! ../../constants/EmptySegmentFormat */ "./packages/roosterjs-content-model-dom/lib/constants/EmptySegmentFormat.ts");
|
|
25358
|
+
var getObjectKeys_1 = __webpack_require__(/*! ../../domUtils/getObjectKeys */ "./packages/roosterjs-content-model-dom/lib/domUtils/getObjectKeys.ts");
|
|
25251
25359
|
/**
|
|
25252
25360
|
* Create a ContentModelSelectionMarker model
|
|
25253
25361
|
* @param format @optional The format of this model
|
|
25254
25362
|
*/
|
|
25255
25363
|
function createSelectionMarker(format) {
|
|
25364
|
+
var filteredFormat = {};
|
|
25365
|
+
if (format) {
|
|
25366
|
+
(0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_1.EmptySegmentFormat).forEach(function (key) {
|
|
25367
|
+
if (key in format) {
|
|
25368
|
+
filteredFormat[key] = format[key];
|
|
25369
|
+
}
|
|
25370
|
+
});
|
|
25371
|
+
}
|
|
25256
25372
|
return {
|
|
25257
25373
|
segmentType: 'SelectionMarker',
|
|
25258
25374
|
isSelected: true,
|
|
25259
|
-
format:
|
|
25375
|
+
format: filteredFormat,
|
|
25260
25376
|
};
|
|
25261
25377
|
}
|
|
25262
25378
|
exports.createSelectionMarker = createSelectionMarker;
|
|
@@ -29331,14 +29447,16 @@ var handleFormatContainer = function (doc, parent, container, context, refNode)
|
|
|
29331
29447
|
(0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.segmentOnBlock, container.format, context);
|
|
29332
29448
|
(0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.container, container.format, context);
|
|
29333
29449
|
});
|
|
29334
|
-
|
|
29335
|
-
(
|
|
29450
|
+
(0, stackFormat_1.stackFormat)(context, container.format.direction ? { direction: container.format.direction } : null, function () {
|
|
29451
|
+
if (container.tagName == 'pre') {
|
|
29452
|
+
(0, stackFormat_1.stackFormat)(context, PreChildFormat, function () {
|
|
29453
|
+
context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
|
|
29454
|
+
});
|
|
29455
|
+
}
|
|
29456
|
+
else {
|
|
29336
29457
|
context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
|
|
29337
|
-
}
|
|
29338
|
-
}
|
|
29339
|
-
else {
|
|
29340
|
-
context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
|
|
29341
|
-
}
|
|
29458
|
+
}
|
|
29459
|
+
});
|
|
29342
29460
|
element = containerNode_1;
|
|
29343
29461
|
}
|
|
29344
29462
|
if (element) {
|
|
@@ -29628,7 +29746,9 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
|
29628
29746
|
// Need to apply listItemElement formats after applying metadata since the list numbers value relies on the result of metadata handling
|
|
29629
29747
|
(0, applyFormat_1.applyFormat)(li, context.formatAppliers.listItemElement, listItem.format, context);
|
|
29630
29748
|
(0, stackFormat_1.stackFormat)(context, listItem.formatHolder.format, function () {
|
|
29631
|
-
|
|
29749
|
+
(0, stackFormat_1.stackFormat)(context, listItem.format.direction ? { direction: listItem.format.direction } : null, function () {
|
|
29750
|
+
context.modelHandlers.blockGroupChildren(doc, li, listItem, context);
|
|
29751
|
+
});
|
|
29632
29752
|
});
|
|
29633
29753
|
}
|
|
29634
29754
|
else {
|
|
@@ -30000,7 +30120,9 @@ var handleTable = function (doc, parent, table, context, refNode) {
|
|
|
30000
30120
|
(0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.tableCellBorder, cell.format, context);
|
|
30001
30121
|
(0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.dataset, cell.dataset, context);
|
|
30002
30122
|
}
|
|
30003
|
-
|
|
30123
|
+
(0, stackFormat_1.stackFormat)(context, cell.format.direction ? { direction: cell.format.direction } : null, function () {
|
|
30124
|
+
context.modelHandlers.blockGroupChildren(doc, td_1, cell, context);
|
|
30125
|
+
});
|
|
30004
30126
|
});
|
|
30005
30127
|
(_f = context.onNodeCreated) === null || _f === void 0 ? void 0 : _f.call(context, cell, td_1);
|
|
30006
30128
|
}
|
|
@@ -30526,35 +30648,6 @@ var convertContentModelToMarkdown_1 = __webpack_require__(/*! ./modelToMarkdown/
|
|
|
30526
30648
|
Object.defineProperty(exports, "convertContentModelToMarkdown", ({ enumerable: true, get: function () { return convertContentModelToMarkdown_1.convertContentModelToMarkdown; } }));
|
|
30527
30649
|
|
|
30528
30650
|
|
|
30529
|
-
/***/ },
|
|
30530
|
-
|
|
30531
|
-
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyLink.ts"
|
|
30532
|
-
/*!*********************************************************************************************!*\
|
|
30533
|
-
!*** ./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyLink.ts ***!
|
|
30534
|
-
\*********************************************************************************************/
|
|
30535
|
-
(__unused_webpack_module, exports) {
|
|
30536
|
-
|
|
30537
|
-
"use strict";
|
|
30538
|
-
|
|
30539
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
30540
|
-
exports.applyLink = void 0;
|
|
30541
|
-
/**
|
|
30542
|
-
* @internal
|
|
30543
|
-
*/
|
|
30544
|
-
function applyLink(textSegment, text, url) {
|
|
30545
|
-
textSegment.text = text;
|
|
30546
|
-
textSegment.link = {
|
|
30547
|
-
dataset: {},
|
|
30548
|
-
format: {
|
|
30549
|
-
href: url,
|
|
30550
|
-
underline: true,
|
|
30551
|
-
},
|
|
30552
|
-
};
|
|
30553
|
-
return textSegment;
|
|
30554
|
-
}
|
|
30555
|
-
exports.applyLink = applyLink;
|
|
30556
|
-
|
|
30557
|
-
|
|
30558
30651
|
/***/ },
|
|
30559
30652
|
|
|
30560
30653
|
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applySegmentFormatting.ts"
|
|
@@ -30569,46 +30662,39 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
30569
30662
|
exports.applySegmentFormatting = void 0;
|
|
30570
30663
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
30571
30664
|
var adjustHeading_1 = __webpack_require__(/*! ../utils/adjustHeading */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/adjustHeading.ts");
|
|
30572
|
-
var applyLink_1 = __webpack_require__(/*! ./applyLink */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyLink.ts");
|
|
30573
|
-
var applyTextFormatting_1 = __webpack_require__(/*! ./applyTextFormatting */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyTextFormatting.ts");
|
|
30574
30665
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
30575
|
-
var
|
|
30576
|
-
var splitParagraphSegments_1 = __webpack_require__(/*! ../utils/splitParagraphSegments */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/splitParagraphSegments.ts");
|
|
30666
|
+
var parseInlineSegments_1 = __webpack_require__(/*! ../utils/parseInlineSegments */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/parseInlineSegments.ts");
|
|
30577
30667
|
/**
|
|
30578
30668
|
* @internal
|
|
30579
30669
|
*/
|
|
30580
30670
|
function applySegmentFormatting(text, paragraph, decorator) {
|
|
30581
|
-
var e_1, _a
|
|
30671
|
+
var e_1, _a;
|
|
30582
30672
|
if (text.length === 0) {
|
|
30583
30673
|
var br = (0, roosterjs_content_model_dom_1.createBr)();
|
|
30584
30674
|
paragraph.segments.push(br);
|
|
30585
30675
|
}
|
|
30586
30676
|
else {
|
|
30587
|
-
var
|
|
30677
|
+
var segments = [];
|
|
30678
|
+
(0, parseInlineSegments_1.parseInlineSegments)(text, segments);
|
|
30679
|
+
// Apply heading adjustment to the first text-bearing segment, if any.
|
|
30680
|
+
var headingAdjusted = false;
|
|
30588
30681
|
try {
|
|
30589
|
-
for (var
|
|
30590
|
-
var segment =
|
|
30591
|
-
|
|
30592
|
-
|
|
30593
|
-
|
|
30594
|
-
|
|
30595
|
-
|
|
30596
|
-
else {
|
|
30597
|
-
if (segment.type === 'link') {
|
|
30598
|
-
(0, applyLink_1.applyLink)(formattedSegment, segment.text, segment.url);
|
|
30599
|
-
}
|
|
30600
|
-
var segmentWithAdjustedHeading = (0, adjustHeading_1.adjustHeading)(formattedSegment, decorator);
|
|
30601
|
-
if (segmentWithAdjustedHeading) {
|
|
30602
|
-
var formattedSegments = (0, applyTextFormatting_1.applyTextFormatting)(formattedSegment);
|
|
30603
|
-
(_b = paragraph.segments).push.apply(_b, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(formattedSegments), false));
|
|
30682
|
+
for (var segments_1 = (0, tslib_1.__values)(segments), segments_1_1 = segments_1.next(); !segments_1_1.done; segments_1_1 = segments_1.next()) {
|
|
30683
|
+
var segment = segments_1_1.value;
|
|
30684
|
+
if (!headingAdjusted && segment.segmentType === 'Text') {
|
|
30685
|
+
var adjusted = (0, adjustHeading_1.adjustHeading)(segment, decorator);
|
|
30686
|
+
headingAdjusted = true;
|
|
30687
|
+
if (!adjusted) {
|
|
30688
|
+
continue;
|
|
30604
30689
|
}
|
|
30605
30690
|
}
|
|
30691
|
+
paragraph.segments.push(segment);
|
|
30606
30692
|
}
|
|
30607
30693
|
}
|
|
30608
30694
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
30609
30695
|
finally {
|
|
30610
30696
|
try {
|
|
30611
|
-
if (
|
|
30697
|
+
if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
|
|
30612
30698
|
}
|
|
30613
30699
|
finally { if (e_1) throw e_1.error; }
|
|
30614
30700
|
}
|
|
@@ -30618,148 +30704,6 @@ function applySegmentFormatting(text, paragraph, decorator) {
|
|
|
30618
30704
|
exports.applySegmentFormatting = applySegmentFormatting;
|
|
30619
30705
|
|
|
30620
30706
|
|
|
30621
|
-
/***/ },
|
|
30622
|
-
|
|
30623
|
-
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyTextFormatting.ts"
|
|
30624
|
-
/*!*******************************************************************************************************!*\
|
|
30625
|
-
!*** ./packages/roosterjs-content-model-markdown/lib/markdownToModel/appliers/applyTextFormatting.ts ***!
|
|
30626
|
-
\*******************************************************************************************************/
|
|
30627
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
30628
|
-
|
|
30629
|
-
"use strict";
|
|
30630
|
-
|
|
30631
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
30632
|
-
exports.applyTextFormatting = void 0;
|
|
30633
|
-
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
30634
|
-
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
30635
|
-
/**
|
|
30636
|
-
* @internal
|
|
30637
|
-
*/
|
|
30638
|
-
function applyTextFormatting(textSegment) {
|
|
30639
|
-
var text = textSegment.text;
|
|
30640
|
-
// Quick check: if the text contains only formatting markers, return original
|
|
30641
|
-
if (isOnlyFormattingMarkers(text)) {
|
|
30642
|
-
return [textSegment];
|
|
30643
|
-
}
|
|
30644
|
-
var textSegments = [];
|
|
30645
|
-
var currentState = { bold: false, italic: false, strikethrough: false };
|
|
30646
|
-
var currentText = '';
|
|
30647
|
-
var i = 0;
|
|
30648
|
-
while (i < text.length) {
|
|
30649
|
-
var marker = parseMarkerAt(text, i);
|
|
30650
|
-
if (marker) {
|
|
30651
|
-
// Check if this marker should be treated as formatting or as literal text
|
|
30652
|
-
if (shouldToggleFormatting(text, i, marker, currentState)) {
|
|
30653
|
-
// If we have accumulated text, create a segment for it
|
|
30654
|
-
if (currentText.length > 0) {
|
|
30655
|
-
textSegments.push(createFormattedSegment(currentText, textSegment.format, currentState, textSegment.link));
|
|
30656
|
-
currentText = '';
|
|
30657
|
-
}
|
|
30658
|
-
// Toggle the formatting state
|
|
30659
|
-
toggleFormatting(currentState, marker.type);
|
|
30660
|
-
// Skip the marker characters
|
|
30661
|
-
i += marker.length;
|
|
30662
|
-
}
|
|
30663
|
-
else {
|
|
30664
|
-
// Treat as regular text if marker is not valid in this context
|
|
30665
|
-
currentText += text[i];
|
|
30666
|
-
i++;
|
|
30667
|
-
}
|
|
30668
|
-
}
|
|
30669
|
-
else {
|
|
30670
|
-
// Regular character, add to current text
|
|
30671
|
-
currentText += text[i];
|
|
30672
|
-
i++;
|
|
30673
|
-
}
|
|
30674
|
-
}
|
|
30675
|
-
// Add any remaining text as a final segment
|
|
30676
|
-
if (currentText.length > 0) {
|
|
30677
|
-
textSegments.push(createFormattedSegment(currentText, textSegment.format, currentState, textSegment.link));
|
|
30678
|
-
}
|
|
30679
|
-
// If no meaningful formatting was applied, return the original segment
|
|
30680
|
-
if (textSegments.length === 0 ||
|
|
30681
|
-
(textSegments.length === 1 && textSegments[0].text === textSegment.text)) {
|
|
30682
|
-
return [textSegment];
|
|
30683
|
-
}
|
|
30684
|
-
return textSegments;
|
|
30685
|
-
}
|
|
30686
|
-
exports.applyTextFormatting = applyTextFormatting;
|
|
30687
|
-
function isOnlyFormattingMarkers(text) {
|
|
30688
|
-
// Remove all potential formatting markers and see if anything remains
|
|
30689
|
-
var remaining = text;
|
|
30690
|
-
remaining = remaining.replace(/\*\*/g, ''); // Remove **
|
|
30691
|
-
remaining = remaining.replace(/~~/g, ''); // Remove ~~
|
|
30692
|
-
remaining = remaining.replace(/\*/g, ''); // Remove *
|
|
30693
|
-
// If nothing remains after removing all markers, it was only markers
|
|
30694
|
-
return remaining.length === 0;
|
|
30695
|
-
}
|
|
30696
|
-
function parseMarkerAt(text, index) {
|
|
30697
|
-
var remaining = text.substring(index);
|
|
30698
|
-
if (remaining.startsWith('~~')) {
|
|
30699
|
-
return { type: 'strikethrough', length: 2 };
|
|
30700
|
-
}
|
|
30701
|
-
if (remaining.startsWith('**')) {
|
|
30702
|
-
return { type: 'bold', length: 2 };
|
|
30703
|
-
}
|
|
30704
|
-
if (remaining.startsWith('*')) {
|
|
30705
|
-
return { type: 'italic', length: 1 };
|
|
30706
|
-
}
|
|
30707
|
-
return null;
|
|
30708
|
-
}
|
|
30709
|
-
function shouldToggleFormatting(text, index, marker, currentState) {
|
|
30710
|
-
var nextChar = index + marker.length < text.length ? text.charAt(index + marker.length) : '';
|
|
30711
|
-
var isCurrentlyActive = getCurrentFormatState(currentState, marker.type);
|
|
30712
|
-
if (isCurrentlyActive) {
|
|
30713
|
-
// We're currently in this format, so any marker can close it
|
|
30714
|
-
return true;
|
|
30715
|
-
}
|
|
30716
|
-
else {
|
|
30717
|
-
// We're not in this format, so this marker would open it
|
|
30718
|
-
// Opening markers must be followed by non-whitespace
|
|
30719
|
-
return nextChar.length > 0 && !isWhitespace(nextChar);
|
|
30720
|
-
}
|
|
30721
|
-
}
|
|
30722
|
-
function isWhitespace(char) {
|
|
30723
|
-
return /\s/.test(char);
|
|
30724
|
-
}
|
|
30725
|
-
function toggleFormatting(state, type) {
|
|
30726
|
-
switch (type) {
|
|
30727
|
-
case 'bold':
|
|
30728
|
-
state.bold = !state.bold;
|
|
30729
|
-
break;
|
|
30730
|
-
case 'italic':
|
|
30731
|
-
state.italic = !state.italic;
|
|
30732
|
-
break;
|
|
30733
|
-
case 'strikethrough':
|
|
30734
|
-
state.strikethrough = !state.strikethrough;
|
|
30735
|
-
break;
|
|
30736
|
-
}
|
|
30737
|
-
}
|
|
30738
|
-
function getCurrentFormatState(state, type) {
|
|
30739
|
-
switch (type) {
|
|
30740
|
-
case 'bold':
|
|
30741
|
-
return state.bold;
|
|
30742
|
-
case 'italic':
|
|
30743
|
-
return state.italic;
|
|
30744
|
-
case 'strikethrough':
|
|
30745
|
-
return state.strikethrough;
|
|
30746
|
-
}
|
|
30747
|
-
}
|
|
30748
|
-
function createFormattedSegment(text, baseFormat, state, link) {
|
|
30749
|
-
var format = (0, tslib_1.__assign)({}, baseFormat);
|
|
30750
|
-
if (state.bold) {
|
|
30751
|
-
format.fontWeight = 'bold';
|
|
30752
|
-
}
|
|
30753
|
-
if (state.italic) {
|
|
30754
|
-
format.italic = true;
|
|
30755
|
-
}
|
|
30756
|
-
if (state.strikethrough) {
|
|
30757
|
-
format.strikethrough = true;
|
|
30758
|
-
}
|
|
30759
|
-
return (0, roosterjs_content_model_dom_1.createText)(text, format, link);
|
|
30760
|
-
}
|
|
30761
|
-
|
|
30762
|
-
|
|
30763
30707
|
/***/ },
|
|
30764
30708
|
|
|
30765
30709
|
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/convertMarkdownToContentModel.ts"
|
|
@@ -31357,29 +31301,143 @@ exports.isMarkdownTable = isMarkdownTable;
|
|
|
31357
31301
|
|
|
31358
31302
|
/***/ },
|
|
31359
31303
|
|
|
31360
|
-
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/
|
|
31361
|
-
|
|
31362
|
-
!*** ./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/
|
|
31363
|
-
|
|
31364
|
-
(__unused_webpack_module, exports) {
|
|
31304
|
+
/***/ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/parseInlineSegments.ts"
|
|
31305
|
+
/*!****************************************************************************************************!*\
|
|
31306
|
+
!*** ./packages/roosterjs-content-model-markdown/lib/markdownToModel/utils/parseInlineSegments.ts ***!
|
|
31307
|
+
\****************************************************************************************************/
|
|
31308
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
31365
31309
|
|
|
31366
31310
|
"use strict";
|
|
31367
31311
|
|
|
31368
31312
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
31369
|
-
exports.
|
|
31370
|
-
|
|
31371
|
-
|
|
31372
|
-
//
|
|
31373
|
-
|
|
31374
|
-
//
|
|
31375
|
-
|
|
31376
|
-
|
|
31377
|
-
|
|
31378
|
-
|
|
31313
|
+
exports.parseInlineSegments = void 0;
|
|
31314
|
+
var createImageSegment_1 = __webpack_require__(/*! ../creators/createImageSegment */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/creators/createImageSegment.ts");
|
|
31315
|
+
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
31316
|
+
// Matches a markdown link [text](url) anchored at the start of the input.
|
|
31317
|
+
var linkPattern = /^\[([^\[\]]+)\]\(([^\)]+)\)/;
|
|
31318
|
+
// Matches a markdown image  anchored at the start of the input.
|
|
31319
|
+
var imagePattern = /^!\[([^\[\]]+)\]\(([^\)]+)\)/;
|
|
31320
|
+
/**
|
|
31321
|
+
* @internal
|
|
31322
|
+
* Parse a markdown inline string into Content Model segments. Supports bold/italic/
|
|
31323
|
+
* strikethrough markers, links, and images, and keeps formatting state active across
|
|
31324
|
+
* link boundaries (e.g. **[link](url)**).
|
|
31325
|
+
*/
|
|
31326
|
+
function parseInlineSegments(text, segments, state, link) {
|
|
31327
|
+
if (state === void 0) { state = { bold: false, italic: false, strikethrough: false }; }
|
|
31328
|
+
var buffer = '';
|
|
31329
|
+
var i = 0;
|
|
31330
|
+
var flushBuffer = function () {
|
|
31331
|
+
if (buffer.length > 0) {
|
|
31332
|
+
segments.push(createFormattedSegment(buffer, state, link));
|
|
31333
|
+
buffer = '';
|
|
31334
|
+
}
|
|
31335
|
+
};
|
|
31336
|
+
while (i < text.length) {
|
|
31337
|
+
var remaining = text.substring(i);
|
|
31338
|
+
// Image: 
|
|
31339
|
+
var imgMatch = imagePattern.exec(remaining);
|
|
31340
|
+
if (imgMatch && isValidUrl(imgMatch[2])) {
|
|
31341
|
+
flushBuffer();
|
|
31342
|
+
segments.push((0, createImageSegment_1.createImageSegment)(imgMatch[1], imgMatch[2]));
|
|
31343
|
+
i += imgMatch[0].length;
|
|
31344
|
+
continue;
|
|
31345
|
+
}
|
|
31346
|
+
// Link: [text](url) — keep outer formatting state active inside the link
|
|
31347
|
+
var linkMatch = linkPattern.exec(remaining);
|
|
31348
|
+
if (linkMatch && isValidUrl(linkMatch[2])) {
|
|
31349
|
+
flushBuffer();
|
|
31350
|
+
var innerLink = {
|
|
31351
|
+
dataset: {},
|
|
31352
|
+
format: { href: linkMatch[2], underline: true },
|
|
31353
|
+
};
|
|
31354
|
+
parseInlineSegments(linkMatch[1], segments, state, innerLink);
|
|
31355
|
+
i += linkMatch[0].length;
|
|
31356
|
+
continue;
|
|
31357
|
+
}
|
|
31358
|
+
// Formatting marker
|
|
31359
|
+
var marker = parseMarkerAt(text, i);
|
|
31360
|
+
if (marker && shouldToggleFormatting(text, i, marker, state)) {
|
|
31361
|
+
flushBuffer();
|
|
31362
|
+
toggleFormatting(state, marker.type);
|
|
31363
|
+
i += marker.length;
|
|
31364
|
+
continue;
|
|
31365
|
+
}
|
|
31366
|
+
buffer += text[i];
|
|
31367
|
+
i++;
|
|
31368
|
+
}
|
|
31369
|
+
flushBuffer();
|
|
31370
|
+
}
|
|
31371
|
+
exports.parseInlineSegments = parseInlineSegments;
|
|
31372
|
+
function parseMarkerAt(text, index) {
|
|
31373
|
+
var remaining = text.substring(index);
|
|
31374
|
+
if (remaining.startsWith('~~')) {
|
|
31375
|
+
return { type: 'strikethrough', length: 2 };
|
|
31376
|
+
}
|
|
31377
|
+
if (remaining.startsWith('**')) {
|
|
31378
|
+
return { type: 'bold', length: 2 };
|
|
31379
|
+
}
|
|
31380
|
+
if (remaining.startsWith('*')) {
|
|
31381
|
+
return { type: 'italic', length: 1 };
|
|
31382
|
+
}
|
|
31383
|
+
return null;
|
|
31384
|
+
}
|
|
31385
|
+
function shouldToggleFormatting(text, index, marker, currentState) {
|
|
31386
|
+
var isCurrentlyActive = getCurrentFormatState(currentState, marker.type);
|
|
31387
|
+
if (isCurrentlyActive) {
|
|
31388
|
+
return true;
|
|
31389
|
+
}
|
|
31390
|
+
// Opening marker must be followed by a non-whitespace character.
|
|
31391
|
+
var nextIndex = index + marker.length;
|
|
31392
|
+
var nextChar = nextIndex < text.length ? text.charAt(nextIndex) : '';
|
|
31393
|
+
if (nextChar.length === 0 || isWhitespace(nextChar)) {
|
|
31394
|
+
return false;
|
|
31395
|
+
}
|
|
31396
|
+
return true;
|
|
31397
|
+
}
|
|
31398
|
+
function isWhitespace(char) {
|
|
31399
|
+
return /\s/.test(char);
|
|
31400
|
+
}
|
|
31401
|
+
function toggleFormatting(state, type) {
|
|
31402
|
+
switch (type) {
|
|
31403
|
+
case 'bold':
|
|
31404
|
+
state.bold = !state.bold;
|
|
31405
|
+
break;
|
|
31406
|
+
case 'italic':
|
|
31407
|
+
state.italic = !state.italic;
|
|
31408
|
+
break;
|
|
31409
|
+
case 'strikethrough':
|
|
31410
|
+
state.strikethrough = !state.strikethrough;
|
|
31411
|
+
break;
|
|
31412
|
+
}
|
|
31413
|
+
}
|
|
31414
|
+
function getCurrentFormatState(state, type) {
|
|
31415
|
+
switch (type) {
|
|
31416
|
+
case 'bold':
|
|
31417
|
+
return state.bold;
|
|
31418
|
+
case 'italic':
|
|
31419
|
+
return state.italic;
|
|
31420
|
+
case 'strikethrough':
|
|
31421
|
+
return state.strikethrough;
|
|
31422
|
+
}
|
|
31423
|
+
}
|
|
31424
|
+
function createFormattedSegment(text, state, link) {
|
|
31425
|
+
var format = {};
|
|
31426
|
+
if (state.bold) {
|
|
31427
|
+
format.fontWeight = 'bold';
|
|
31428
|
+
}
|
|
31429
|
+
if (state.italic) {
|
|
31430
|
+
format.italic = true;
|
|
31431
|
+
}
|
|
31432
|
+
if (state.strikethrough) {
|
|
31433
|
+
format.strikethrough = true;
|
|
31434
|
+
}
|
|
31435
|
+
return (0, roosterjs_content_model_dom_1.createText)(text, format, link);
|
|
31436
|
+
}
|
|
31437
|
+
function isValidUrl(url) {
|
|
31379
31438
|
if (!url) {
|
|
31380
31439
|
return false;
|
|
31381
31440
|
}
|
|
31382
|
-
// Accept common non-http schemes and relative paths
|
|
31383
31441
|
if (url.startsWith('data:') ||
|
|
31384
31442
|
url.startsWith('blob:') ||
|
|
31385
31443
|
url.startsWith('/') ||
|
|
@@ -31394,51 +31452,7 @@ var isValidUrl = function (url) {
|
|
|
31394
31452
|
catch (_) {
|
|
31395
31453
|
return false;
|
|
31396
31454
|
}
|
|
31397
|
-
};
|
|
31398
|
-
function pushText(result, text) {
|
|
31399
|
-
var last = result[result.length - 1];
|
|
31400
|
-
if (last && last.type === 'text') {
|
|
31401
|
-
last.text += text;
|
|
31402
|
-
}
|
|
31403
|
-
else {
|
|
31404
|
-
result.push({ type: 'text', text: text, url: '' });
|
|
31405
|
-
}
|
|
31406
|
-
}
|
|
31407
|
-
/**
|
|
31408
|
-
* @internal
|
|
31409
|
-
*/
|
|
31410
|
-
function splitParagraphSegments(text) {
|
|
31411
|
-
var result = [];
|
|
31412
|
-
var lastIndex = 0;
|
|
31413
|
-
var match = null;
|
|
31414
|
-
while ((match = linkRegex.exec(text)) !== null) {
|
|
31415
|
-
if (match.index > lastIndex) {
|
|
31416
|
-
pushText(result, text.slice(lastIndex, match.index));
|
|
31417
|
-
}
|
|
31418
|
-
if (match[2] && match[3]) {
|
|
31419
|
-
if (isValidUrl(match[3])) {
|
|
31420
|
-
result.push({ type: 'link', text: match[2], url: match[3] });
|
|
31421
|
-
}
|
|
31422
|
-
else {
|
|
31423
|
-
pushText(result, match[0]);
|
|
31424
|
-
}
|
|
31425
|
-
}
|
|
31426
|
-
else if (match[5] && match[6]) {
|
|
31427
|
-
if (isValidUrl(match[6])) {
|
|
31428
|
-
result.push({ type: 'image', text: match[5], url: match[6] });
|
|
31429
|
-
}
|
|
31430
|
-
else {
|
|
31431
|
-
pushText(result, match[0]);
|
|
31432
|
-
}
|
|
31433
|
-
}
|
|
31434
|
-
lastIndex = linkRegex.lastIndex;
|
|
31435
|
-
}
|
|
31436
|
-
if (lastIndex < text.length) {
|
|
31437
|
-
pushText(result, text.slice(lastIndex));
|
|
31438
|
-
}
|
|
31439
|
-
return result;
|
|
31440
31455
|
}
|
|
31441
|
-
exports.splitParagraphSegments = splitParagraphSegments;
|
|
31442
31456
|
|
|
31443
31457
|
|
|
31444
31458
|
/***/ },
|
|
@@ -31699,20 +31713,30 @@ function createMarkdownParagraph(paragraph, context) {
|
|
|
31699
31713
|
}
|
|
31700
31714
|
exports.createMarkdownParagraph = createMarkdownParagraph;
|
|
31701
31715
|
function textProcessor(text) {
|
|
31702
|
-
var
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31706
|
-
|
|
31707
|
-
|
|
31708
|
-
|
|
31709
|
-
|
|
31710
|
-
|
|
31716
|
+
var _a = text.format, fontWeight = _a.fontWeight, italic = _a.italic, strikethrough = _a.strikethrough;
|
|
31717
|
+
var hasInlineFormat = fontWeight == 'bold' || italic || strikethrough;
|
|
31718
|
+
if (!hasInlineFormat) {
|
|
31719
|
+
return text.link ? "[" + text.text + "](" + text.link.format.href + ")" : text.text;
|
|
31720
|
+
}
|
|
31721
|
+
// Move leading/trailing whitespace outside the markers so the emitted
|
|
31722
|
+
// markdown is valid (CommonMark requires emphasis markers to hug
|
|
31723
|
+
// non-whitespace), e.g. "world " with <b> => " " + "**world**".
|
|
31724
|
+
var match = /^(\s*)([\s\S]*?)(\s*)$/.exec(text.text);
|
|
31725
|
+
var _b = (0, tslib_1.__read)(match ? match : ['', '', text.text, ''], 4), leading = _b[1], core = _b[2], trailing = _b[3];
|
|
31726
|
+
if (!core) {
|
|
31727
|
+
return text.text;
|
|
31728
|
+
}
|
|
31729
|
+
var inner = text.link ? "[" + core + "](" + text.link.format.href + ")" : core;
|
|
31730
|
+
if (fontWeight == 'bold') {
|
|
31731
|
+
inner = "**" + inner + "**";
|
|
31732
|
+
}
|
|
31733
|
+
if (strikethrough) {
|
|
31734
|
+
inner = "~~" + inner + "~~";
|
|
31711
31735
|
}
|
|
31712
|
-
if (
|
|
31713
|
-
|
|
31736
|
+
if (italic) {
|
|
31737
|
+
inner = "*" + inner + "*";
|
|
31714
31738
|
}
|
|
31715
|
-
return
|
|
31739
|
+
return "" + leading + inner + trailing;
|
|
31716
31740
|
}
|
|
31717
31741
|
|
|
31718
31742
|
|