roosterjs 8.27.1 → 8.28.0-git
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 +22 -20
- package/dist/rooster-amd.js +145 -62
- 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 +22 -20
- package/dist/rooster.js +145 -62
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
- package/tsconfig.child.tsbuildinfo +1 -1
package/dist/rooster-amd.js
CHANGED
|
@@ -4592,7 +4592,6 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
4592
4592
|
* @param formatApiName Optional parameter to provide the ContentChangeEvent which FormatApi was invoked.
|
|
4593
4593
|
*/
|
|
4594
4594
|
var addUndoSnapshot = function (core, callback, changeSource, canUndoByBackspace, additionalData) {
|
|
4595
|
-
if (additionalData === void 0) { additionalData = undefined; }
|
|
4596
4595
|
var undoState = core.undo;
|
|
4597
4596
|
var isNested = undoState.isNested;
|
|
4598
4597
|
var data;
|
|
@@ -4670,8 +4669,9 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
4670
4669
|
* @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event
|
|
4671
4670
|
*/
|
|
4672
4671
|
var attachDomEvent = function (core, eventMap) {
|
|
4673
|
-
var disposers = (0, roosterjs_editor_dom_1.getObjectKeys)(eventMap || {}).map(function (
|
|
4674
|
-
var _a = extractHandler(eventMap[
|
|
4672
|
+
var disposers = (0, roosterjs_editor_dom_1.getObjectKeys)(eventMap || {}).map(function (key) {
|
|
4673
|
+
var _a = extractHandler(eventMap[key]), pluginEventType = _a.pluginEventType, beforeDispatch = _a.beforeDispatch;
|
|
4674
|
+
var eventName = key;
|
|
4675
4675
|
var onEvent = function (event) {
|
|
4676
4676
|
if (beforeDispatch) {
|
|
4677
4677
|
beforeDispatch(event);
|
|
@@ -4806,11 +4806,12 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4806
4806
|
var fragment = event.fragment, sanitizingOption = event.sanitizingOption;
|
|
4807
4807
|
var rawHtml = clipboardData.rawHtml, text = clipboardData.text, imageDataUri = clipboardData.imageDataUri;
|
|
4808
4808
|
var document = core.contentDiv.ownerDocument;
|
|
4809
|
-
var doc
|
|
4809
|
+
var doc = rawHtml
|
|
4810
|
+
? new DOMParser().parseFromString(core.trustedHTMLHandler(rawHtml), 'text/html')
|
|
4811
|
+
: undefined;
|
|
4810
4812
|
// Step 2: Retrieve Metadata from Html and the Html that was copied.
|
|
4811
|
-
if (rawHtml &&
|
|
4812
|
-
|
|
4813
|
-
var attributes = (_b = doc.querySelector('html')) === null || _b === void 0 ? void 0 : _b.attributes;
|
|
4813
|
+
if (rawHtml && (doc === null || doc === void 0 ? void 0 : doc.body)) {
|
|
4814
|
+
var attributes = (_a = doc.querySelector('html')) === null || _a === void 0 ? void 0 : _a.attributes;
|
|
4814
4815
|
(attributes ? (0, roosterjs_editor_dom_1.toArray)(attributes) : []).reduce(function (attrs, attr) {
|
|
4815
4816
|
attrs[attr.name] = attr.value;
|
|
4816
4817
|
return attrs;
|
|
@@ -4824,7 +4825,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4824
4825
|
for (var i = 0; i < (doc === null || doc === void 0 ? void 0 : doc.body.childNodes.length); i++) {
|
|
4825
4826
|
var node = doc === null || doc === void 0 ? void 0 : doc.body.childNodes.item(i);
|
|
4826
4827
|
if (node.nodeType == Node.TEXT_NODE) {
|
|
4827
|
-
var trimmedString = node.nodeValue.replace(/(\r\n|\r|\n)/gm, '').trim();
|
|
4828
|
+
var trimmedString = (_b = node.nodeValue) === null || _b === void 0 ? void 0 : _b.replace(/(\r\n|\r|\n)/gm, '').trim();
|
|
4828
4829
|
if (!trimmedString) {
|
|
4829
4830
|
continue;
|
|
4830
4831
|
}
|
|
@@ -4837,7 +4838,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4837
4838
|
// Move all STYLE nodes into header, and save them into sanitizing options.
|
|
4838
4839
|
// Because if we directly move them into a fragment, all sheets under STYLE will be lost.
|
|
4839
4840
|
processStyles(doc, function (style) {
|
|
4840
|
-
doc.head.appendChild(style);
|
|
4841
|
+
doc === null || doc === void 0 ? void 0 : doc.head.appendChild(style);
|
|
4841
4842
|
sanitizingOption.additionalGlobalStyleNodes.push(style);
|
|
4842
4843
|
});
|
|
4843
4844
|
var startIndex = rawHtml.indexOf(START_FRAGMENT);
|
|
@@ -4863,7 +4864,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4863
4864
|
fragment.appendChild(img);
|
|
4864
4865
|
}
|
|
4865
4866
|
else if (!pasteAsText && rawHtml && doc ? doc.body : false) {
|
|
4866
|
-
(0, roosterjs_editor_dom_1.moveChildNodes)(fragment, doc.body);
|
|
4867
|
+
(0, roosterjs_editor_dom_1.moveChildNodes)(fragment, doc === null || doc === void 0 ? void 0 : doc.body);
|
|
4867
4868
|
if (applyCurrentStyle && position) {
|
|
4868
4869
|
var format_1 = getCurrentFormat(core, position.node);
|
|
4869
4870
|
(0, roosterjs_editor_dom_1.applyTextStyle)(fragment, function (node) { return (0, roosterjs_editor_dom_1.applyFormat)(node, format_1); });
|
|
@@ -5142,9 +5143,11 @@ var getContent = function (core, mode) {
|
|
|
5142
5143
|
}
|
|
5143
5144
|
}
|
|
5144
5145
|
else {
|
|
5145
|
-
content = (0, roosterjs_editor_dom_1.getHtmlWithSelectionPath)(root, includeSelectionMarker
|
|
5146
|
+
content = (0, roosterjs_editor_dom_1.getHtmlWithSelectionPath)(root, includeSelectionMarker
|
|
5147
|
+
? core.api.getSelectionRange(core, true /*tryGetFromCache*/)
|
|
5148
|
+
: null);
|
|
5146
5149
|
}
|
|
5147
|
-
return content;
|
|
5150
|
+
return content !== null && content !== void 0 ? content : '';
|
|
5148
5151
|
};
|
|
5149
5152
|
exports.getContent = getContent;
|
|
5150
5153
|
function cloneNode(node) {
|
|
@@ -5247,7 +5250,7 @@ function queryCommandStateFromDOM(core, currentPosition) {
|
|
|
5247
5250
|
}
|
|
5248
5251
|
node = node.parentNode;
|
|
5249
5252
|
};
|
|
5250
|
-
while ((0, roosterjs_editor_dom_1.contains)(core.contentDiv, node)) {
|
|
5253
|
+
while (node && (0, roosterjs_editor_dom_1.contains)(core.contentDiv, node)) {
|
|
5251
5254
|
_loop_1();
|
|
5252
5255
|
}
|
|
5253
5256
|
return formatState;
|
|
@@ -5328,7 +5331,7 @@ var getSelectionRangeEx = function (core) {
|
|
|
5328
5331
|
var result = null;
|
|
5329
5332
|
if (core.lifecycle.shadowEditFragment) {
|
|
5330
5333
|
var _c = core.lifecycle, shadowEditTableSelectionPath = _c.shadowEditTableSelectionPath, shadowEditSelectionPath = _c.shadowEditSelectionPath;
|
|
5331
|
-
if ((shadowEditTableSelectionPath === null || shadowEditTableSelectionPath === void 0 ? void 0 : shadowEditTableSelectionPath.length) > 0) {
|
|
5334
|
+
if (((shadowEditTableSelectionPath === null || shadowEditTableSelectionPath === void 0 ? void 0 : shadowEditTableSelectionPath.length) || 0) > 0) {
|
|
5332
5335
|
var ranges = core.lifecycle.shadowEditTableSelectionPath.map(function (path) {
|
|
5333
5336
|
return (0, roosterjs_editor_dom_1.createRange)(core.contentDiv, path.start, path.end);
|
|
5334
5337
|
});
|
|
@@ -5337,7 +5340,7 @@ var getSelectionRangeEx = function (core) {
|
|
|
5337
5340
|
ranges: ranges,
|
|
5338
5341
|
areAllCollapsed: checkAllCollapsed(ranges),
|
|
5339
5342
|
table: (0, roosterjs_editor_dom_1.findClosestElementAncestor)(ranges[0].startContainer, core.contentDiv, 'table'),
|
|
5340
|
-
coordinates:
|
|
5343
|
+
coordinates: undefined,
|
|
5341
5344
|
};
|
|
5342
5345
|
}
|
|
5343
5346
|
else {
|
|
@@ -5415,14 +5418,16 @@ var getStyleBasedFormatState = function (core, node) {
|
|
|
5415
5418
|
? {
|
|
5416
5419
|
darkModeColor: styles[2],
|
|
5417
5420
|
lightModeColor: ogTextColorNode.dataset["ogsc" /* OriginalStyleColor */] ||
|
|
5418
|
-
ogTextColorNode.dataset["ogac" /* OriginalAttributeColor */]
|
|
5421
|
+
ogTextColorNode.dataset["ogac" /* OriginalAttributeColor */] ||
|
|
5422
|
+
styles[2],
|
|
5419
5423
|
}
|
|
5420
5424
|
: undefined,
|
|
5421
5425
|
backgroundColors: ogBackgroundColorNode
|
|
5422
5426
|
? {
|
|
5423
5427
|
darkModeColor: styles[3],
|
|
5424
5428
|
lightModeColor: ogBackgroundColorNode.dataset["ogsb" /* OriginalStyleBackgroundColor */] ||
|
|
5425
|
-
ogBackgroundColorNode.dataset["ogab" /* OriginalAttributeBackgroundColor */]
|
|
5429
|
+
ogBackgroundColorNode.dataset["ogab" /* OriginalAttributeBackgroundColor */] ||
|
|
5430
|
+
styles[3],
|
|
5426
5431
|
}
|
|
5427
5432
|
: undefined,
|
|
5428
5433
|
};
|
|
@@ -5452,7 +5457,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
5452
5457
|
*/
|
|
5453
5458
|
var hasFocus = function (core) {
|
|
5454
5459
|
var activeElement = core.contentDiv.ownerDocument.activeElement;
|
|
5455
|
-
return (activeElement && (0, roosterjs_editor_dom_1.contains)(core.contentDiv, activeElement, true /*treatSameNodeAsContain*/));
|
|
5460
|
+
return !!(activeElement && (0, roosterjs_editor_dom_1.contains)(core.contentDiv, activeElement, true /*treatSameNodeAsContain*/));
|
|
5456
5461
|
};
|
|
5457
5462
|
exports.hasFocus = hasFocus;
|
|
5458
5463
|
|
|
@@ -5494,6 +5499,7 @@ function getInitialRange(core, option) {
|
|
|
5494
5499
|
* @param option An insert option object to specify how to insert the node
|
|
5495
5500
|
*/
|
|
5496
5501
|
var insertNode = function (core, node, option) {
|
|
5502
|
+
var _a;
|
|
5497
5503
|
option = option || {
|
|
5498
5504
|
position: 3 /* SelectionStart */,
|
|
5499
5505
|
insertOnNewLine: false,
|
|
@@ -5505,10 +5511,11 @@ var insertNode = function (core, node, option) {
|
|
|
5505
5511
|
core.api.focus(core);
|
|
5506
5512
|
}
|
|
5507
5513
|
if (option.position == 4 /* Outside */) {
|
|
5508
|
-
contentDiv.parentNode.insertBefore(node, contentDiv.nextSibling);
|
|
5514
|
+
(_a = contentDiv.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(node, contentDiv.nextSibling);
|
|
5509
5515
|
return true;
|
|
5510
5516
|
}
|
|
5511
5517
|
core.api.transformColor(core, node, true /*includeSelf*/, function () {
|
|
5518
|
+
var _a, _b;
|
|
5512
5519
|
switch (option.position) {
|
|
5513
5520
|
case 0 /* Begin */:
|
|
5514
5521
|
case 1 /* End */: {
|
|
@@ -5527,10 +5534,10 @@ var insertNode = function (core, node, option) {
|
|
|
5527
5534
|
// if the node to be inserted is DocumentFragment, use its childNodes as insertedNode
|
|
5528
5535
|
// because insertBefore() returns an empty DocumentFragment
|
|
5529
5536
|
insertedNode_1 = (0, roosterjs_editor_dom_1.toArray)(node.childNodes);
|
|
5530
|
-
refNode.parentNode.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
5537
|
+
(_a = refNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
5531
5538
|
}
|
|
5532
5539
|
else {
|
|
5533
|
-
insertedNode_1 = refNode.parentNode.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
5540
|
+
insertedNode_1 = (_b = refNode.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
5534
5541
|
}
|
|
5535
5542
|
}
|
|
5536
5543
|
else {
|
|
@@ -5564,7 +5571,7 @@ var insertNode = function (core, node, option) {
|
|
|
5564
5571
|
break;
|
|
5565
5572
|
case 5 /* Range */:
|
|
5566
5573
|
case 3 /* SelectionStart */:
|
|
5567
|
-
var
|
|
5574
|
+
var _c = getInitialRange(core, option), range = _c.range, rangeToRestore = _c.rangeToRestore;
|
|
5568
5575
|
if (!range) {
|
|
5569
5576
|
return;
|
|
5570
5577
|
}
|
|
@@ -5576,7 +5583,7 @@ var insertNode = function (core, node, option) {
|
|
|
5576
5583
|
var blockElement = void 0;
|
|
5577
5584
|
if (option.insertOnNewLine &&
|
|
5578
5585
|
(blockElement = (0, roosterjs_editor_dom_1.getBlockElementAtNode)(contentDiv, pos.normalize().node))) {
|
|
5579
|
-
pos =
|
|
5586
|
+
pos = adjustInsertPositionNewLine(blockElement, core, pos);
|
|
5580
5587
|
}
|
|
5581
5588
|
else {
|
|
5582
5589
|
pos = (0, roosterjs_editor_dom_1.adjustInsertPosition)(contentDiv, node, pos, range);
|
|
@@ -5587,13 +5594,25 @@ var insertNode = function (core, node, option) {
|
|
|
5587
5594
|
if (option.updateCursor && nodeForCursor) {
|
|
5588
5595
|
rangeToRestore = (0, roosterjs_editor_dom_1.createRange)(new roosterjs_editor_dom_1.Position(nodeForCursor, -3 /* After */).normalize());
|
|
5589
5596
|
}
|
|
5590
|
-
|
|
5597
|
+
if (rangeToRestore) {
|
|
5598
|
+
core.api.selectRange(core, rangeToRestore);
|
|
5599
|
+
}
|
|
5591
5600
|
break;
|
|
5592
5601
|
}
|
|
5593
5602
|
}, 0 /* LightToDark */);
|
|
5594
5603
|
return true;
|
|
5595
5604
|
};
|
|
5596
5605
|
exports.insertNode = insertNode;
|
|
5606
|
+
function adjustInsertPositionNewLine(blockElement, core, pos) {
|
|
5607
|
+
var tempPos = new roosterjs_editor_dom_1.Position(blockElement.getEndNode(), -3 /* After */);
|
|
5608
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(tempPos.node, 'HTMLTableRowElement')) {
|
|
5609
|
+
var div = core.contentDiv.ownerDocument.createElement('div');
|
|
5610
|
+
var range = (0, roosterjs_editor_dom_1.createRange)(pos);
|
|
5611
|
+
range.insertNode(div);
|
|
5612
|
+
tempPos = new roosterjs_editor_dom_1.Position(div, 0 /* Begin */);
|
|
5613
|
+
}
|
|
5614
|
+
return tempPos;
|
|
5615
|
+
}
|
|
5597
5616
|
|
|
5598
5617
|
|
|
5599
5618
|
/***/ }),
|
|
@@ -5616,6 +5635,7 @@ exports.restoreUndoSnapshot = void 0;
|
|
|
5616
5635
|
* @param step Steps to move, can be 0, positive or negative
|
|
5617
5636
|
*/
|
|
5618
5637
|
var restoreUndoSnapshot = function (core, step) {
|
|
5638
|
+
var _a;
|
|
5619
5639
|
if (core.undo.hasNewContent && step < 0) {
|
|
5620
5640
|
core.api.addUndoSnapshot(core, null /*callback*/, null /*changeSource*/, false /*canUndoByBackspace*/);
|
|
5621
5641
|
}
|
|
@@ -5623,7 +5643,7 @@ var restoreUndoSnapshot = function (core, step) {
|
|
|
5623
5643
|
if (snapshot && snapshot.html != null) {
|
|
5624
5644
|
try {
|
|
5625
5645
|
core.undo.isRestoring = true;
|
|
5626
|
-
core.api.setContent(core, snapshot.html, true /*triggerContentChangedEvent*/, snapshot.metadata);
|
|
5646
|
+
core.api.setContent(core, snapshot.html, true /*triggerContentChangedEvent*/, (_a = snapshot.metadata) !== null && _a !== void 0 ? _a : undefined);
|
|
5627
5647
|
}
|
|
5628
5648
|
finally {
|
|
5629
5649
|
core.undo.isRestoring = false;
|
|
@@ -5685,11 +5705,14 @@ function restorePendingFormatState(core) {
|
|
|
5685
5705
|
var formatState_1 = (0, roosterjs_editor_dom_1.getPendableFormatState)(document_1);
|
|
5686
5706
|
(0, roosterjs_editor_dom_1.getObjectKeys)(roosterjs_editor_dom_1.PendableFormatCommandMap).forEach(function (key) {
|
|
5687
5707
|
if (!!pendingFormatState.pendableFormatState[key] != formatState_1[key]) {
|
|
5688
|
-
document_1.execCommand(roosterjs_editor_dom_1.PendableFormatCommandMap[key], false
|
|
5708
|
+
document_1.execCommand(roosterjs_editor_dom_1.PendableFormatCommandMap[key], false /* showUI */, undefined /* value */);
|
|
5689
5709
|
}
|
|
5690
5710
|
});
|
|
5691
5711
|
var range = getSelectionRange(core, true /*tryGetFromCache*/);
|
|
5692
|
-
|
|
5712
|
+
var position = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
5713
|
+
if (position) {
|
|
5714
|
+
pendingFormatState.pendableFormatPosition = position;
|
|
5715
|
+
}
|
|
5693
5716
|
}
|
|
5694
5717
|
}
|
|
5695
5718
|
|
|
@@ -5721,15 +5744,18 @@ var STYLE_ID = 'tableStyle';
|
|
|
5721
5744
|
* @returns true if successful
|
|
5722
5745
|
*/
|
|
5723
5746
|
var selectTable = function (core, table, coordinates) {
|
|
5747
|
+
var _a;
|
|
5724
5748
|
unselect(core);
|
|
5725
5749
|
if (areValidCoordinates(coordinates) && table) {
|
|
5726
5750
|
ensureUniqueId(table, TABLE_ID);
|
|
5727
5751
|
ensureUniqueId(core.contentDiv, CONTENT_DIV_ID);
|
|
5728
5752
|
var ranges = select(core, table, coordinates);
|
|
5729
5753
|
if (!isMergedCell(table, coordinates)) {
|
|
5730
|
-
|
|
5731
|
-
.item(coordinates.firstCell.y)
|
|
5732
|
-
|
|
5754
|
+
var cellToSelect = (_a = table.rows
|
|
5755
|
+
.item(coordinates.firstCell.y)) === null || _a === void 0 ? void 0 : _a.cells.item(coordinates.firstCell.x);
|
|
5756
|
+
if (cellToSelect) {
|
|
5757
|
+
core.api.selectRange(core, (0, roosterjs_editor_dom_1.createRange)(new roosterjs_editor_dom_1.Position(cellToSelect, 0 /* Begin */)));
|
|
5758
|
+
}
|
|
5733
5759
|
}
|
|
5734
5760
|
return {
|
|
5735
5761
|
type: 1 /* TableSelection */,
|
|
@@ -5743,6 +5769,7 @@ var selectTable = function (core, table, coordinates) {
|
|
|
5743
5769
|
};
|
|
5744
5770
|
exports.selectTable = selectTable;
|
|
5745
5771
|
function buildCss(table, coordinates, contentDivSelector) {
|
|
5772
|
+
var _a;
|
|
5746
5773
|
var tr1 = coordinates.firstCell.y;
|
|
5747
5774
|
var td1 = coordinates.firstCell.x;
|
|
5748
5775
|
var tr2 = coordinates.lastCell.y;
|
|
@@ -5766,7 +5793,7 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
5766
5793
|
cont = result.end;
|
|
5767
5794
|
return result;
|
|
5768
5795
|
});
|
|
5769
|
-
vTable.cells.forEach(function (row, rowIndex) {
|
|
5796
|
+
(_a = vTable.cells) === null || _a === void 0 ? void 0 : _a.forEach(function (row, rowIndex) {
|
|
5770
5797
|
var tdCount = 0;
|
|
5771
5798
|
var thCount = 0;
|
|
5772
5799
|
firstSelected = null;
|
|
@@ -5778,8 +5805,9 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
5778
5805
|
? rowIndex + 1 - midElement.start
|
|
5779
5806
|
: rowIndex + 1;
|
|
5780
5807
|
for (var cellIndex = 0; cellIndex < row.length; cellIndex++) {
|
|
5781
|
-
|
|
5782
|
-
|
|
5808
|
+
var cell = row[cellIndex].td;
|
|
5809
|
+
if (cell) {
|
|
5810
|
+
var tag = (0, roosterjs_editor_dom_1.getTagOfNode)(cell);
|
|
5783
5811
|
if (tag == 'TD') {
|
|
5784
5812
|
tdCount++;
|
|
5785
5813
|
}
|
|
@@ -5793,7 +5821,7 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
5793
5821
|
else if (!css.endsWith(',')) {
|
|
5794
5822
|
css += ',';
|
|
5795
5823
|
}
|
|
5796
|
-
removeImportant(
|
|
5824
|
+
removeImportant(cell);
|
|
5797
5825
|
var selector = generateCssFromCell(contentDivSelector, table.id, middleElSelector, currentRow, tag, tag == 'TD' ? tdCount : thCount);
|
|
5798
5826
|
css += selector;
|
|
5799
5827
|
firstSelected = firstSelected || table.querySelector(selector);
|
|
@@ -5812,16 +5840,17 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
5812
5840
|
return { css: css, ranges: ranges };
|
|
5813
5841
|
}
|
|
5814
5842
|
function select(core, table, coordinates) {
|
|
5843
|
+
var _a;
|
|
5815
5844
|
var doc = core.contentDiv.ownerDocument;
|
|
5816
5845
|
var contentDivSelector = '#' + core.contentDiv.id;
|
|
5817
|
-
var
|
|
5846
|
+
var _b = buildCss(table, coordinates, contentDivSelector), css = _b.css, ranges = _b.ranges;
|
|
5818
5847
|
var styleElement = doc.getElementById(STYLE_ID + core.contentDiv.id);
|
|
5819
5848
|
if (!styleElement) {
|
|
5820
5849
|
styleElement = doc.createElement('style');
|
|
5821
5850
|
doc.head.appendChild(styleElement);
|
|
5822
5851
|
styleElement.id = STYLE_ID + core.contentDiv.id;
|
|
5823
5852
|
}
|
|
5824
|
-
styleElement.sheet.insertRule(css);
|
|
5853
|
+
(_a = styleElement.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(css);
|
|
5825
5854
|
return ranges;
|
|
5826
5855
|
}
|
|
5827
5856
|
function unselect(core) {
|
|
@@ -5901,8 +5930,9 @@ function isValidCoordinate(input) {
|
|
|
5901
5930
|
return (!!input || input == 0) && input > -1;
|
|
5902
5931
|
}
|
|
5903
5932
|
function isMergedCell(table, coordinates) {
|
|
5933
|
+
var _a;
|
|
5904
5934
|
var firstCell = coordinates.firstCell;
|
|
5905
|
-
return !(table.rows.item(firstCell.y) && table.rows.item(firstCell.y).cells.item(firstCell.x));
|
|
5935
|
+
return !(table.rows.item(firstCell.y) && ((_a = table.rows.item(firstCell.y)) === null || _a === void 0 ? void 0 : _a.cells.item(firstCell.x)));
|
|
5906
5936
|
}
|
|
5907
5937
|
|
|
5908
5938
|
|
|
@@ -5997,8 +6027,11 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
5997
6027
|
var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
|
|
5998
6028
|
shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
|
|
5999
6029
|
shadowEditTableSelectionPath =
|
|
6000
|
-
(selection === null || selection === void 0 ? void 0 : selection.type) == 1 /* TableSelection */ &&
|
|
6001
|
-
selection.ranges
|
|
6030
|
+
((selection === null || selection === void 0 ? void 0 : selection.type) == 1 /* TableSelection */ &&
|
|
6031
|
+
selection.ranges
|
|
6032
|
+
.map(function (range) { return (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range); })
|
|
6033
|
+
.map(function (w) { return w; })) ||
|
|
6034
|
+
null;
|
|
6002
6035
|
shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
|
|
6003
6036
|
(0, roosterjs_editor_dom_1.moveChildNodes)(shadowEditFragment, contentDiv);
|
|
6004
6037
|
shadowEditFragment.normalize();
|
|
@@ -6012,7 +6045,9 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6012
6045
|
lifecycle.shadowEditTableSelectionPath = shadowEditTableSelectionPath;
|
|
6013
6046
|
}
|
|
6014
6047
|
(0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
|
|
6015
|
-
|
|
6048
|
+
if (lifecycle.shadowEditFragment) {
|
|
6049
|
+
contentDiv.appendChild(lifecycle.shadowEditFragment.cloneNode(true /*deep*/));
|
|
6050
|
+
}
|
|
6016
6051
|
}
|
|
6017
6052
|
else {
|
|
6018
6053
|
lifecycle.shadowEditFragment = null;
|
|
@@ -6022,7 +6057,9 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6022
6057
|
eventType: 18 /* LeavingShadowEdit */,
|
|
6023
6058
|
}, false /*broadcast*/);
|
|
6024
6059
|
(0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
|
|
6025
|
-
|
|
6060
|
+
if (shadowEditFragment) {
|
|
6061
|
+
contentDiv.appendChild(shadowEditFragment);
|
|
6062
|
+
}
|
|
6026
6063
|
core.api.focus(core);
|
|
6027
6064
|
if (shadowEditSelectionPath) {
|
|
6028
6065
|
core.api.selectRange(core, (0, roosterjs_editor_dom_1.createRange)(contentDiv, shadowEditSelectionPath.start, shadowEditSelectionPath.end));
|
|
@@ -6103,8 +6140,8 @@ function transformToLightMode(elements) {
|
|
|
6103
6140
|
element.style.setProperty(names[0 /* CssColor */], getValueOrDefault(element.dataset[names[2 /* CssDataSet */]], ''));
|
|
6104
6141
|
delete element.dataset[names[2 /* CssDataSet */]];
|
|
6105
6142
|
// Some elements might have set attribute colors. We need to reset these as well.
|
|
6106
|
-
var value = element.dataset[names[3 /* HtmlDataSet */]];
|
|
6107
|
-
if (
|
|
6143
|
+
var value = getValueOrDefault(element.dataset[names[3 /* HtmlDataSet */]], null);
|
|
6144
|
+
if (value) {
|
|
6108
6145
|
element.setAttribute(names[1 /* HtmlColor */], value);
|
|
6109
6146
|
}
|
|
6110
6147
|
else {
|
|
@@ -6136,8 +6173,11 @@ function transformToDarkMode(elements, getDarkColor) {
|
|
|
6136
6173
|
: null;
|
|
6137
6174
|
})
|
|
6138
6175
|
.filter(function (x) { return !!x; })
|
|
6139
|
-
.forEach(function (
|
|
6140
|
-
|
|
6176
|
+
.forEach(function (entry) {
|
|
6177
|
+
if (!entry) {
|
|
6178
|
+
return;
|
|
6179
|
+
}
|
|
6180
|
+
var element = entry.element, styleColor = entry.styleColor, attrColor = entry.attrColor, newColor = entry.newColor;
|
|
6141
6181
|
element.style.setProperty(names[0 /* CssColor */], newColor, 'important');
|
|
6142
6182
|
element.dataset[names[2 /* CssDataSet */]] = styleColor || '';
|
|
6143
6183
|
if (attrColor) {
|
|
@@ -7607,6 +7647,7 @@ var TypeInContainerPlugin = /** @class */ (function () {
|
|
|
7607
7647
|
* @param event PluginEvent object
|
|
7608
7648
|
*/
|
|
7609
7649
|
TypeInContainerPlugin.prototype.onPluginEvent = function (event) {
|
|
7650
|
+
var _this = this;
|
|
7610
7651
|
if (event.eventType == 1 /* KeyPress */) {
|
|
7611
7652
|
// If normalization was not possible before the keypress,
|
|
7612
7653
|
// check again after the keyboard event has been processed by browser native behavior.
|
|
@@ -7625,9 +7666,17 @@ var TypeInContainerPlugin = /** @class */ (function () {
|
|
|
7625
7666
|
this.editor.ensureTypeInContainer(roosterjs_editor_dom_1.Position.getStart(range), event.rawEvent);
|
|
7626
7667
|
}
|
|
7627
7668
|
else {
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7669
|
+
var callback = function () {
|
|
7670
|
+
if (_this.editor) {
|
|
7671
|
+
_this.editor.ensureTypeInContainer(_this.editor.getFocusedPosition(), event.rawEvent);
|
|
7672
|
+
}
|
|
7673
|
+
};
|
|
7674
|
+
if (roosterjs_editor_dom_1.Browser.isMobileOrTablet) {
|
|
7675
|
+
this.editor.getDocument().defaultView.setTimeout(callback, 100);
|
|
7676
|
+
}
|
|
7677
|
+
else {
|
|
7678
|
+
this.editor.runAsync(callback);
|
|
7679
|
+
}
|
|
7631
7680
|
}
|
|
7632
7681
|
}
|
|
7633
7682
|
};
|
|
@@ -17566,14 +17615,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17566
17615
|
*/
|
|
17567
17616
|
function normalizeRect(clientRect) {
|
|
17568
17617
|
var _a = clientRect || { left: 0, right: 0, top: 0, bottom: 0 }, left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
|
|
17569
|
-
return left
|
|
17570
|
-
?
|
|
17618
|
+
return left === 0 && right === 0 && top === 0 && bottom === 0
|
|
17619
|
+
? null
|
|
17620
|
+
: {
|
|
17571
17621
|
left: Math.round(left),
|
|
17572
17622
|
right: Math.round(right),
|
|
17573
17623
|
top: Math.round(top),
|
|
17574
17624
|
bottom: Math.round(bottom),
|
|
17575
|
-
}
|
|
17576
|
-
: null;
|
|
17625
|
+
};
|
|
17577
17626
|
}
|
|
17578
17627
|
exports.default = normalizeRect;
|
|
17579
17628
|
|
|
@@ -20543,12 +20592,13 @@ var CustomReplacePlugin = /** @class */ (function () {
|
|
|
20543
20592
|
}
|
|
20544
20593
|
var searcher = this.editor.getContentSearcherOfCursor(event);
|
|
20545
20594
|
var stringToSearch = searcher.getSubStringBefore(this.longestReplacementLength);
|
|
20595
|
+
var sourceEditor = this.editor;
|
|
20546
20596
|
var replacement = this.getMatchingReplacement(stringToSearch);
|
|
20547
20597
|
if (replacement == null) {
|
|
20548
20598
|
return;
|
|
20549
20599
|
}
|
|
20550
20600
|
if (replacement.shouldReplace &&
|
|
20551
|
-
!replacement.shouldReplace(replacement, searcher.getWordBefore())) {
|
|
20601
|
+
!replacement.shouldReplace(replacement, searcher.getWordBefore(), sourceEditor)) {
|
|
20552
20602
|
return;
|
|
20553
20603
|
}
|
|
20554
20604
|
// Reconstruct a selection of the text on the document that matches the
|
|
@@ -22832,10 +22882,11 @@ function handleLineMerge(root) {
|
|
|
22832
22882
|
});
|
|
22833
22883
|
}
|
|
22834
22884
|
if (blocks.length > 0) {
|
|
22885
|
+
var blocksLength = blocks.length - 1;
|
|
22835
22886
|
processBlock(blocks[0]);
|
|
22836
|
-
processBlock(blocks[
|
|
22887
|
+
processBlock(blocks[blocksLength]);
|
|
22837
22888
|
checkAndAddBr(root, blocks[0], true /*isFirst*/);
|
|
22838
|
-
checkAndAddBr(root, blocks[
|
|
22889
|
+
checkAndAddBr(root, blocks[blocksLength], false /*isFirst*/, blocks[0]);
|
|
22839
22890
|
}
|
|
22840
22891
|
}
|
|
22841
22892
|
exports.default = handleLineMerge;
|
|
@@ -22857,14 +22908,34 @@ function processBlock(block) {
|
|
|
22857
22908
|
(_b = end.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(end);
|
|
22858
22909
|
}
|
|
22859
22910
|
}
|
|
22860
|
-
function checkAndAddBr(root, block, isFirst) {
|
|
22861
|
-
var _a;
|
|
22911
|
+
function checkAndAddBr(root, block, isFirst, firstBlock) {
|
|
22912
|
+
var _a, _b, _c, _d;
|
|
22862
22913
|
var blockElement = (0, roosterjs_editor_dom_1.getBlockElementAtNode)(root, block.start);
|
|
22863
22914
|
var sibling = isFirst
|
|
22864
22915
|
? (0, roosterjs_editor_dom_1.getNextLeafSibling)(root, block.end)
|
|
22865
22916
|
: (0, roosterjs_editor_dom_1.getPreviousLeafSibling)(root, block.start);
|
|
22917
|
+
if (!sibling) {
|
|
22918
|
+
return;
|
|
22919
|
+
}
|
|
22866
22920
|
if (blockElement === null || blockElement === void 0 ? void 0 : blockElement.contains(sibling)) {
|
|
22867
|
-
|
|
22921
|
+
var br = (_a = block.start.ownerDocument) === null || _a === void 0 ? void 0 : _a.createElement('br');
|
|
22922
|
+
if (br) {
|
|
22923
|
+
var blockToUse = isFirst ? block.end : block.start;
|
|
22924
|
+
(_b = blockToUse.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(br, isFirst ? block.end.nextSibling : block.start);
|
|
22925
|
+
}
|
|
22926
|
+
}
|
|
22927
|
+
else if (firstBlock &&
|
|
22928
|
+
firstBlock.end == firstBlock.start &&
|
|
22929
|
+
(0, roosterjs_editor_dom_1.getTagOfNode)(firstBlock.end) == 'SPAN') {
|
|
22930
|
+
// If the first block and the last block are Siblings, add a BR before so the only two
|
|
22931
|
+
// lines that are being pasted are not merged.
|
|
22932
|
+
var previousSibling = (0, roosterjs_editor_dom_1.getPreviousLeafSibling)(root, block.start);
|
|
22933
|
+
if (firstBlock.end.contains(previousSibling)) {
|
|
22934
|
+
var br = (_c = block.start.ownerDocument) === null || _c === void 0 ? void 0 : _c.createElement('br');
|
|
22935
|
+
if (br) {
|
|
22936
|
+
(_d = block.start.parentNode) === null || _d === void 0 ? void 0 : _d.insertBefore(br, block.start);
|
|
22937
|
+
}
|
|
22938
|
+
}
|
|
22868
22939
|
}
|
|
22869
22940
|
}
|
|
22870
22941
|
|
|
@@ -25461,7 +25532,7 @@ var TableResize = /** @class */ (function () {
|
|
|
25461
25532
|
TableResize.prototype.dispose = function () {
|
|
25462
25533
|
this.onMouseMoveDisposer();
|
|
25463
25534
|
this.invalidateTableRects();
|
|
25464
|
-
this.
|
|
25535
|
+
this.disposeTableEditor();
|
|
25465
25536
|
this.editor = null;
|
|
25466
25537
|
};
|
|
25467
25538
|
/**
|
|
@@ -25480,14 +25551,18 @@ var TableResize = /** @class */ (function () {
|
|
|
25480
25551
|
}
|
|
25481
25552
|
};
|
|
25482
25553
|
TableResize.prototype.setTableEditor = function (table, e) {
|
|
25483
|
-
if (this.tableEditor && table != this.tableEditor.table) {
|
|
25484
|
-
this.
|
|
25485
|
-
this.tableEditor = null;
|
|
25554
|
+
if (this.tableEditor && !this.tableEditor.isEditing() && table != this.tableEditor.table) {
|
|
25555
|
+
this.disposeTableEditor();
|
|
25486
25556
|
}
|
|
25487
25557
|
if (!this.tableEditor && table) {
|
|
25488
25558
|
this.tableEditor = new TableEditor_1.default(this.editor, table, this.invalidateTableRects, this.onShowHelperElement, e.currentTarget);
|
|
25489
25559
|
}
|
|
25490
25560
|
};
|
|
25561
|
+
TableResize.prototype.disposeTableEditor = function () {
|
|
25562
|
+
var _a;
|
|
25563
|
+
(_a = this.tableEditor) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
25564
|
+
this.tableEditor = null;
|
|
25565
|
+
};
|
|
25491
25566
|
TableResize.prototype.ensureTableRects = function () {
|
|
25492
25567
|
var _this = this;
|
|
25493
25568
|
if (!this.tableRectMap) {
|
|
@@ -25740,12 +25815,15 @@ var TableEditor = /** @class */ (function () {
|
|
|
25740
25815
|
_this.editor.select(_this.start, _this.end);
|
|
25741
25816
|
_this.editor.addUndoSnapshot(null /*callback*/, "Format" /* Format */);
|
|
25742
25817
|
_this.onChanged();
|
|
25818
|
+
_this.isCurrentlyEditing = false;
|
|
25743
25819
|
return false;
|
|
25744
25820
|
};
|
|
25745
25821
|
this.onStartTableResize = function () {
|
|
25822
|
+
_this.isCurrentlyEditing = true;
|
|
25746
25823
|
_this.onStartResize();
|
|
25747
25824
|
};
|
|
25748
25825
|
this.onStartCellResize = function () {
|
|
25826
|
+
_this.isCurrentlyEditing = true;
|
|
25749
25827
|
_this.disposeTableResizer();
|
|
25750
25828
|
_this.onStartResize();
|
|
25751
25829
|
};
|
|
@@ -25783,6 +25861,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
25783
25861
|
this.isRTL = (0, roosterjs_editor_dom_1.getComputedStyle)(table, 'direction') == 'rtl';
|
|
25784
25862
|
this.tableResizer = (0, TableResizer_1.default)(table, editor.getZoomScale(), this.isRTL, this.onStartTableResize, this.onFinishEditing, this.onShowHelperElement);
|
|
25785
25863
|
this.tableSelector = (0, TableSelector_1.default)(table, editor.getZoomScale(), this.onSelect, this.onShowHelperElement, this.getShouldShowTableSelectorHandler(this.editor.getScrollContainer(), eventTarget));
|
|
25864
|
+
this.isCurrentlyEditing = false;
|
|
25786
25865
|
}
|
|
25787
25866
|
TableEditor.prototype.dispose = function () {
|
|
25788
25867
|
this.disposeTableResizer();
|
|
@@ -25790,6 +25869,9 @@ var TableEditor = /** @class */ (function () {
|
|
|
25790
25869
|
this.disposeTableInserter();
|
|
25791
25870
|
this.disposeTableSelector();
|
|
25792
25871
|
};
|
|
25872
|
+
TableEditor.prototype.isEditing = function () {
|
|
25873
|
+
return this.isCurrentlyEditing;
|
|
25874
|
+
};
|
|
25793
25875
|
TableEditor.prototype.onMouseMove = function (x, y) {
|
|
25794
25876
|
var _a;
|
|
25795
25877
|
for (var i = 0; i < this.table.rows.length; i++) {
|
|
@@ -25891,6 +25973,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
25891
25973
|
}
|
|
25892
25974
|
};
|
|
25893
25975
|
TableEditor.prototype.onStartResize = function () {
|
|
25976
|
+
this.isCurrentlyEditing = true;
|
|
25894
25977
|
var range = this.editor.getSelectionRange();
|
|
25895
25978
|
if (range) {
|
|
25896
25979
|
this.start = roosterjs_editor_dom_1.Position.getStart(range);
|