roosterjs 9.56.0 → 9.57.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 +37 -5
- package/dist/rooster-amd.js +159 -65
- 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-amd.js +55 -55
- package/dist/rooster-react-amd.js.map +1 -1
- package/dist/rooster-react.js +53 -53
- package/dist/rooster-react.js.map +1 -1
- package/dist/rooster.d.ts +37 -5
- package/dist/rooster.js +159 -65
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for roosterjs (Version 9.
|
|
1
|
+
// Type definitions for roosterjs (Version 9.57.0)
|
|
2
2
|
// Generated by dts tool from roosterjs
|
|
3
3
|
// Project: https://github.com/Microsoft/roosterjs
|
|
4
4
|
|
|
@@ -3891,6 +3891,11 @@ interface IEditor {
|
|
|
3891
3891
|
* @param featureName The name of feature to check
|
|
3892
3892
|
*/
|
|
3893
3893
|
isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean;
|
|
3894
|
+
/**
|
|
3895
|
+
* Get all experimental features enabled in this editor
|
|
3896
|
+
* @returns An array of experimental feature names
|
|
3897
|
+
*/
|
|
3898
|
+
getExperimentalFeatures(): ExperimentalFeature[];
|
|
3894
3899
|
}
|
|
3895
3900
|
|
|
3896
3901
|
/**
|
|
@@ -3921,7 +3926,11 @@ type ExperimentalFeature = GraduatedExperimentalFeature
|
|
|
3921
3926
|
* These characters can be used to hide text in HTML and may cause unexpected behavior.
|
|
3922
3927
|
* @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
|
|
3923
3928
|
*/
|
|
3924
|
-
| 'FilterInvisibleUnicode'
|
|
3929
|
+
| 'FilterInvisibleUnicode'
|
|
3930
|
+
/**
|
|
3931
|
+
* Handle the drop event for content that is dropped from the same editor instance.
|
|
3932
|
+
*/
|
|
3933
|
+
| 'HandleDropInternalContent';
|
|
3925
3934
|
|
|
3926
3935
|
/**
|
|
3927
3936
|
* Predefined experiment features (Graduated, only keep them for backward compatibility)
|
|
@@ -5102,6 +5111,10 @@ interface FormatContentModelOptions {
|
|
|
5102
5111
|
* When pass to true, scroll the editing caret into view after write DOM tree if need
|
|
5103
5112
|
*/
|
|
5104
5113
|
scrollCaretIntoView?: boolean;
|
|
5114
|
+
/**
|
|
5115
|
+
* When pass to true, skip setting DOM selection after write DOM tree. @default false
|
|
5116
|
+
*/
|
|
5117
|
+
skipDOMSelection?: boolean;
|
|
5105
5118
|
}
|
|
5106
5119
|
|
|
5107
5120
|
/**
|
|
@@ -5260,9 +5273,19 @@ interface ContentModelFormatState {
|
|
|
5260
5273
|
|
|
5261
5274
|
/**
|
|
5262
5275
|
* Represents the PasteType parameter used to set the paste type to use.
|
|
5263
|
-
* It can be either the Paste Type value or a callback that
|
|
5276
|
+
* It can be either the Paste Type value or a callback that returns the Paste Type to use.
|
|
5264
5277
|
*/
|
|
5265
|
-
type PasteTypeOrGetter = PasteType |
|
|
5278
|
+
type PasteTypeOrGetter = PasteType | PasteTypeGetter;
|
|
5279
|
+
|
|
5280
|
+
/**
|
|
5281
|
+
* A function that returns the Paste Type to use based on the pasted content and clipboard data.
|
|
5282
|
+
* @param document The document parsed from the clipboard raw HTML, or null when there is no HTML
|
|
5283
|
+
* @param clipboardData Clipboard data retrieved from clipboard
|
|
5284
|
+
* @param environment The editor environment information
|
|
5285
|
+
* @param htmlAttributes The metadata (HTML attributes) retrieved from the pasted content
|
|
5286
|
+
* @returns The Paste Type to use
|
|
5287
|
+
*/
|
|
5288
|
+
type PasteTypeGetter = (document: Document | null, clipboardData: ClipboardData, environment: EditorEnvironment, htmlAttributes: Record<string, string>) => PasteType;
|
|
5266
5289
|
|
|
5267
5290
|
/**
|
|
5268
5291
|
* Image Format
|
|
@@ -8387,6 +8410,10 @@ const ChangeSource: {
|
|
|
8387
8410
|
* Content changed by paste
|
|
8388
8411
|
*/
|
|
8389
8412
|
Paste: string;
|
|
8413
|
+
/**
|
|
8414
|
+
* Content changed by auto markdown conversion
|
|
8415
|
+
*/
|
|
8416
|
+
AutoMarkdownConversion: string;
|
|
8390
8417
|
/**
|
|
8391
8418
|
* Content changed by setContent API
|
|
8392
8419
|
*/
|
|
@@ -8863,6 +8890,11 @@ class Editor implements IEditor {
|
|
|
8863
8890
|
* @param featureName The name of feature to check
|
|
8864
8891
|
*/
|
|
8865
8892
|
isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean;
|
|
8893
|
+
/**
|
|
8894
|
+
* Get all experimental features enabled in this editor
|
|
8895
|
+
* @returns An array of experimental feature names
|
|
8896
|
+
* */
|
|
8897
|
+
getExperimentalFeatures(): ExperimentalFeature[];
|
|
8866
8898
|
/**
|
|
8867
8899
|
* @returns the current EditorCore object
|
|
8868
8900
|
* @throws a standard Error if there's no core object
|
|
@@ -10934,7 +10966,7 @@ class AnnouncePlugin implements EditorPlugin {
|
|
|
10934
10966
|
class DragAndDropPlugin implements EditorPlugin {
|
|
10935
10967
|
private editor;
|
|
10936
10968
|
private forbiddenElements;
|
|
10937
|
-
private
|
|
10969
|
+
private internalDrag;
|
|
10938
10970
|
private disposer;
|
|
10939
10971
|
/**
|
|
10940
10972
|
* Construct a new instance of DragAndDropPlugin
|
package/dist/rooster.js
CHANGED
|
@@ -8545,9 +8545,9 @@ var DefaultSanitizingOption = {
|
|
|
8545
8545
|
/**
|
|
8546
8546
|
* @internal
|
|
8547
8547
|
*/
|
|
8548
|
-
function createDomToModelContextForSanitizing(document, defaultFormat, defaultOption, additionalSanitizingOption, domHelper) {
|
|
8548
|
+
function createDomToModelContextForSanitizing(document, defaultFormat, defaultOption, additionalSanitizingOption, domHelper, experimentalFeatures) {
|
|
8549
8549
|
var sanitizingOption = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultSanitizingOption), additionalSanitizingOption);
|
|
8550
|
-
return (0, roosterjs_content_model_dom_1.createDomToModelContext)((0, tslib_1.__assign)((0, tslib_1.__assign)({ defaultFormat: defaultFormat }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(document)), { experimentalFeatures: [], editorViewWidth: domHelper === null || domHelper === void 0 ? void 0 : domHelper.getClientWidth() }), defaultOption, {
|
|
8550
|
+
return (0, roosterjs_content_model_dom_1.createDomToModelContext)((0, tslib_1.__assign)((0, tslib_1.__assign)({ defaultFormat: defaultFormat }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(document)), { experimentalFeatures: experimentalFeatures !== null && experimentalFeatures !== void 0 ? experimentalFeatures : [], editorViewWidth: domHelper === null || domHelper === void 0 ? void 0 : domHelper.getClientWidth() }), defaultOption, {
|
|
8551
8551
|
processorOverride: {
|
|
8552
8552
|
'#text': pasteTextProcessor_1.pasteTextProcessor,
|
|
8553
8553
|
entity: (0, pasteEntityProcessor_1.createPasteEntityProcessor)(sanitizingOption),
|
|
@@ -9389,12 +9389,13 @@ var BlackColor = 'rgb(0,0,0)';
|
|
|
9389
9389
|
*/
|
|
9390
9390
|
function mergePasteContent(editor, eventResult, isFirstPaste) {
|
|
9391
9391
|
var fragment = eventResult.fragment, domToModelOption = eventResult.domToModelOption, customizedMerge = eventResult.customizedMerge, pasteType = eventResult.pasteType, clipboardData = eventResult.clipboardData, containsBlockElements = eventResult.containsBlockElements;
|
|
9392
|
+
var shouldScrollCaretIntoView = !isImageOnlyFragment(fragment);
|
|
9392
9393
|
editor.formatContentModel(function (model, context) {
|
|
9393
9394
|
if (!isFirstPaste && clipboardData.modelBeforePaste) {
|
|
9394
9395
|
var clonedModel = (0, roosterjs_content_model_dom_1.cloneModelForPaste)(clipboardData.modelBeforePaste);
|
|
9395
9396
|
model.blocks = clonedModel.blocks;
|
|
9396
9397
|
}
|
|
9397
|
-
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(editor.getDocument(), undefined /*defaultFormat*/, editor.getEnvironment().domToModelSettings.customized, domToModelOption, editor.getDOMHelper());
|
|
9398
|
+
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(editor.getDocument(), undefined /*defaultFormat*/, editor.getEnvironment().domToModelSettings.customized, domToModelOption, editor.getDOMHelper(), editor.getExperimentalFeatures());
|
|
9398
9399
|
domToModelContext.segmentFormat = getSegmentFormatForPaste(model, pasteType);
|
|
9399
9400
|
var pasteModel = (0, roosterjs_content_model_dom_1.domToContentModel)(fragment, domToModelContext);
|
|
9400
9401
|
var mergeOption = {
|
|
@@ -9414,7 +9415,7 @@ function mergePasteContent(editor, eventResult, isFirstPaste) {
|
|
|
9414
9415
|
}, {
|
|
9415
9416
|
changeSource: roosterjs_content_model_dom_1.ChangeSource.Paste,
|
|
9416
9417
|
getChangeData: function () { return clipboardData; },
|
|
9417
|
-
scrollCaretIntoView:
|
|
9418
|
+
scrollCaretIntoView: shouldScrollCaretIntoView,
|
|
9418
9419
|
apiName: 'paste',
|
|
9419
9420
|
});
|
|
9420
9421
|
}
|
|
@@ -9455,6 +9456,13 @@ function getLastSegmentFormat(pasteModel) {
|
|
|
9455
9456
|
}
|
|
9456
9457
|
return {};
|
|
9457
9458
|
}
|
|
9459
|
+
function isImageOnlyFragment(pasteFragment) {
|
|
9460
|
+
var _a;
|
|
9461
|
+
var images = pasteFragment.querySelectorAll('img');
|
|
9462
|
+
return (images.length === 1 &&
|
|
9463
|
+
pasteFragment.childNodes.length === 1 &&
|
|
9464
|
+
((_a = pasteFragment.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === '');
|
|
9465
|
+
}
|
|
9458
9466
|
|
|
9459
9467
|
|
|
9460
9468
|
/***/ },
|
|
@@ -9500,11 +9508,11 @@ function paste(editor, clipboardData, pasteTypeOrGetter) {
|
|
|
9500
9508
|
clipboardData.rawHtml = (0, cleanHtmlComments_1.cleanHtmlComments)(clipboardData.rawHtml);
|
|
9501
9509
|
}
|
|
9502
9510
|
var doc = createDOMFromHtml(clipboardData.rawHtml, domCreator);
|
|
9503
|
-
var pasteType = typeof pasteTypeOrGetter == 'function'
|
|
9504
|
-
? pasteTypeOrGetter(doc, clipboardData)
|
|
9505
|
-
: pasteTypeOrGetter;
|
|
9506
9511
|
// 2. Handle HTML from clipboard
|
|
9507
9512
|
var htmlFromClipboard = (0, retrieveHtmlInfo_1.retrieveHtmlInfo)(doc, clipboardData);
|
|
9513
|
+
var pasteType = typeof pasteTypeOrGetter == 'function'
|
|
9514
|
+
? pasteTypeOrGetter(doc, clipboardData, editor.getEnvironment(), htmlFromClipboard.metadata)
|
|
9515
|
+
: pasteTypeOrGetter;
|
|
9508
9516
|
// 3. Create target fragment
|
|
9509
9517
|
var sourceFragment = (0, createPasteFragment_1.createPasteFragment)(editor.getDocument(), clipboardData, pasteType, (_a = (clipboardData.rawHtml == clipboardData.html
|
|
9510
9518
|
? doc
|
|
@@ -10289,7 +10297,7 @@ var formatContentModel = function (core, formatter, options, domToModelOptions)
|
|
|
10289
10297
|
try {
|
|
10290
10298
|
handleImages(core, context);
|
|
10291
10299
|
selection =
|
|
10292
|
-
(_a = core.api.setContentModel(core, model, hasFocus ? undefined : { ignoreSelection: true }, // If editor did not have focus before format, do not set focus after format
|
|
10300
|
+
(_a = core.api.setContentModel(core, model, hasFocus && !(options === null || options === void 0 ? void 0 : options.skipDOMSelection) ? undefined : { ignoreSelection: true }, // If editor did not have focus before format, do not set focus after format
|
|
10293
10301
|
onNodeCreated)) !== null && _a !== void 0 ? _a : undefined;
|
|
10294
10302
|
handlePendingFormat(core, context, selection);
|
|
10295
10303
|
if (scroll && ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range' || (selection === null || selection === void 0 ? void 0 : selection.type) == 'image')) {
|
|
@@ -14491,6 +14499,7 @@ var Down = 'ArrowDown';
|
|
|
14491
14499
|
var Left = 'ArrowLeft';
|
|
14492
14500
|
var Right = 'ArrowRight';
|
|
14493
14501
|
var Tab = 'Tab';
|
|
14502
|
+
var F10 = 'F10';
|
|
14494
14503
|
/**
|
|
14495
14504
|
* @internal
|
|
14496
14505
|
*/
|
|
@@ -14507,7 +14516,6 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14507
14516
|
this.disposer = null;
|
|
14508
14517
|
this.logicalRootDisposer = null;
|
|
14509
14518
|
this.isSafari = false;
|
|
14510
|
-
this.isMac = false;
|
|
14511
14519
|
this.scrollTopCache = 0;
|
|
14512
14520
|
this.onMouseMove = function (event) {
|
|
14513
14521
|
var _a, _b, _c;
|
|
@@ -14559,7 +14567,7 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14559
14567
|
// MacOS will not create a mouseUp event if contextMenu event is not prevent defaulted.
|
|
14560
14568
|
// Make sure we capture image target even if image is wrapped
|
|
14561
14569
|
this.getContainedTargetImage = function (event, previousSelection) {
|
|
14562
|
-
if (!
|
|
14570
|
+
if (!previousSelection || previousSelection.type !== 'image') {
|
|
14563
14571
|
return null;
|
|
14564
14572
|
}
|
|
14565
14573
|
var target = event.target;
|
|
@@ -14599,11 +14607,11 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14599
14607
|
if (((_a = _this.editor) === null || _a === void 0 ? void 0 : _a.hasFocus()) && !_this.editor.isInShadowEdit()) {
|
|
14600
14608
|
var newSelection = _this.editor.getDOMSelection();
|
|
14601
14609
|
var domHelper = _this.editor.getDOMHelper();
|
|
14602
|
-
//If
|
|
14610
|
+
// If an image selection changed to a wider range due to a keyboard event, we should update the selection
|
|
14603
14611
|
var range = domHelper.getSelectionRange();
|
|
14604
14612
|
if (range) {
|
|
14605
14613
|
var image = (0, isSingleImageInSelection_1.isSingleImageInSelection)(range);
|
|
14606
|
-
if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) == 'image' && !image) {
|
|
14614
|
+
if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) == 'image' && !image && !range.collapsed) {
|
|
14607
14615
|
var sel = (_b = _this.editor.getDocument().defaultView) === null || _b === void 0 ? void 0 : _b.getSelection();
|
|
14608
14616
|
var isReverted = sel
|
|
14609
14617
|
? sel.focusNode != range.endContainer || sel.focusOffset != range.endOffset
|
|
@@ -14662,7 +14670,6 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14662
14670
|
var env = this.editor.getEnvironment();
|
|
14663
14671
|
var document = this.editor.getDocument();
|
|
14664
14672
|
this.isSafari = !!env.isSafari;
|
|
14665
|
-
this.isMac = !!env.isMac;
|
|
14666
14673
|
document.addEventListener('selectionchange', this.onSelectionChange);
|
|
14667
14674
|
if (this.isSafari) {
|
|
14668
14675
|
this.disposer = this.editor.attachDomEvent({
|
|
@@ -14815,6 +14822,7 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14815
14822
|
}
|
|
14816
14823
|
break;
|
|
14817
14824
|
case 'range':
|
|
14825
|
+
var image = void 0;
|
|
14818
14826
|
if (key == Up || key == Down || key == Left || key == Right || key == Tab) {
|
|
14819
14827
|
var start = selection.range.startContainer;
|
|
14820
14828
|
this.state.tableSelection = this.parseTableSelection(start, start, editor.getDOMHelper());
|
|
@@ -14830,6 +14838,14 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14830
14838
|
}
|
|
14831
14839
|
}
|
|
14832
14840
|
}
|
|
14841
|
+
else if (key == F10 &&
|
|
14842
|
+
rawEvent.shiftKey &&
|
|
14843
|
+
(image = (0, isSingleImageInSelection_1.isSingleImageInSelection)(selection.range))) {
|
|
14844
|
+
this.setDOMSelection({
|
|
14845
|
+
type: 'image',
|
|
14846
|
+
image: image,
|
|
14847
|
+
}, null /* tableSelection */);
|
|
14848
|
+
}
|
|
14833
14849
|
break;
|
|
14834
14850
|
case 'table':
|
|
14835
14851
|
// After a content change event is handled tableSelection state is reset to null
|
|
@@ -15973,6 +15989,13 @@ var Editor = /** @class */ (function () {
|
|
|
15973
15989
|
Editor.prototype.isExperimentalFeatureEnabled = function (featureName) {
|
|
15974
15990
|
return this.getCore().experimentalFeatures.indexOf(featureName) >= 0;
|
|
15975
15991
|
};
|
|
15992
|
+
/**
|
|
15993
|
+
* Get all experimental features enabled in this editor
|
|
15994
|
+
* @returns An array of experimental feature names
|
|
15995
|
+
* */
|
|
15996
|
+
Editor.prototype.getExperimentalFeatures = function () {
|
|
15997
|
+
return this.getCore().experimentalFeatures;
|
|
15998
|
+
};
|
|
15976
15999
|
/**
|
|
15977
16000
|
* @returns the current EditorCore object
|
|
15978
16001
|
* @throws a standard Error if there's no core object
|
|
@@ -17204,6 +17227,10 @@ exports.ChangeSource = {
|
|
|
17204
17227
|
* Content changed by paste
|
|
17205
17228
|
*/
|
|
17206
17229
|
Paste: 'Paste',
|
|
17230
|
+
/**
|
|
17231
|
+
* Content changed by auto markdown conversion
|
|
17232
|
+
*/
|
|
17233
|
+
AutoMarkdownConversion: 'AutoMarkdownConversion',
|
|
17207
17234
|
/**
|
|
17208
17235
|
* Content changed by setContent API
|
|
17209
17236
|
*/
|
|
@@ -27013,6 +27040,11 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27013
27040
|
var newTableRowCount = newTable.rows.length;
|
|
27014
27041
|
var lastTargetColIndex = getTargetColIndex(table, rowIndex, colIndex, newTableColCount);
|
|
27015
27042
|
var extraColsNeeded = lastTargetColIndex - table.rows[0].cells.length;
|
|
27043
|
+
newTable.rows.forEach(function (row) {
|
|
27044
|
+
row.cells.forEach(function (cell) {
|
|
27045
|
+
cell.spanAbove = false;
|
|
27046
|
+
});
|
|
27047
|
+
});
|
|
27016
27048
|
if (extraColsNeeded > 0) {
|
|
27017
27049
|
var currentColCount = table.rows[0].cells.length;
|
|
27018
27050
|
for (var col = 0; col < extraColsNeeded; col++) {
|
|
@@ -31044,9 +31076,9 @@ var MarkdownBlockGroupType = {
|
|
|
31044
31076
|
/**
|
|
31045
31077
|
* @internal
|
|
31046
31078
|
*/
|
|
31047
|
-
function createBlockGroupFromMarkdown(text, patternName, options, group) {
|
|
31079
|
+
function createBlockGroupFromMarkdown(text, patternName, options, group, list) {
|
|
31048
31080
|
if (MarkdownBlockGroupType[patternName] === 'ListItem') {
|
|
31049
|
-
return (0, createListFromMarkdown_1.createListFromMarkdown)(text, patternName === 'ordered_list' ? 'OL' : 'UL', options);
|
|
31081
|
+
return (0, createListFromMarkdown_1.createListFromMarkdown)(text, patternName === 'ordered_list' ? 'OL' : 'UL', options, list);
|
|
31050
31082
|
}
|
|
31051
31083
|
else {
|
|
31052
31084
|
return (0, createBlockQuoteFromMarkdown_1.createBlockQuoteFromMarkdown)(text, options, group);
|
|
@@ -31134,12 +31166,13 @@ var createParagraphFromMarkdown_1 = __webpack_require__(/*! ./createParagraphFro
|
|
|
31134
31166
|
/**
|
|
31135
31167
|
* @internal
|
|
31136
31168
|
*/
|
|
31137
|
-
function createListFromMarkdown(text, listType, options) {
|
|
31169
|
+
function createListFromMarkdown(text, listType, options, list) {
|
|
31138
31170
|
var marker = text.trim().split(' ')[0];
|
|
31139
31171
|
var isDummy = isDummyListItem(marker);
|
|
31172
|
+
var startNumber = listType === 'OL' && !list ? parseInt(marker, 10) : undefined;
|
|
31140
31173
|
var itemText = isDummy ? text : text.trim().substring(marker.length);
|
|
31141
31174
|
var paragraph = (0, createParagraphFromMarkdown_1.createParagraphFromMarkdown)(itemText.trim(), options);
|
|
31142
|
-
var levels = createLevels(text, listType, isDummy, options);
|
|
31175
|
+
var levels = createLevels(text, listType, isDummy, options, startNumber);
|
|
31143
31176
|
var listModel = (0, roosterjs_content_model_dom_1.createListItem)(levels);
|
|
31144
31177
|
if (options.direction) {
|
|
31145
31178
|
listModel.format.direction = options.direction;
|
|
@@ -31148,8 +31181,11 @@ function createListFromMarkdown(text, listType, options) {
|
|
|
31148
31181
|
return listModel;
|
|
31149
31182
|
}
|
|
31150
31183
|
exports.createListFromMarkdown = createListFromMarkdown;
|
|
31151
|
-
function createLevels(text, listType, isDummy, options) {
|
|
31184
|
+
function createLevels(text, listType, isDummy, options, startNumberOverride) {
|
|
31152
31185
|
var level = (0, roosterjs_content_model_dom_1.createListLevel)(listType, options.direction ? { direction: options.direction } : undefined);
|
|
31186
|
+
if (startNumberOverride) {
|
|
31187
|
+
level.format.startNumberOverride = startNumberOverride;
|
|
31188
|
+
}
|
|
31153
31189
|
if (isDummy) {
|
|
31154
31190
|
level.format.displayForDummyItem = 'block';
|
|
31155
31191
|
}
|
|
@@ -31438,7 +31474,7 @@ function addMarkdownBlockToModel(model, blockType, markdown, patternName, markdo
|
|
|
31438
31474
|
model.blocks.push(divider);
|
|
31439
31475
|
break;
|
|
31440
31476
|
case 'BlockGroup':
|
|
31441
|
-
var blockGroup = (0, createBlockGroupFromMarkdown_1.createBlockGroupFromMarkdown)(markdown, patternName, options, markdownContext.lastQuote);
|
|
31477
|
+
var blockGroup = (0, createBlockGroupFromMarkdown_1.createBlockGroupFromMarkdown)(markdown, patternName, options, markdownContext.lastQuote, markdownContext.lastList);
|
|
31442
31478
|
if (!markdownContext.lastQuote) {
|
|
31443
31479
|
model.blocks.push(blockGroup);
|
|
31444
31480
|
}
|
|
@@ -32290,6 +32326,7 @@ var MarkdownPastePlugin = /** @class */ (function () {
|
|
|
32290
32326
|
return true;
|
|
32291
32327
|
}, {
|
|
32292
32328
|
apiName: 'MarkdownConversion',
|
|
32329
|
+
changeSource: roosterjs_content_model_dom_1.ChangeSource.AutoMarkdownConversion,
|
|
32293
32330
|
scrollCaretIntoView: true,
|
|
32294
32331
|
});
|
|
32295
32332
|
}
|
|
@@ -33871,7 +33908,8 @@ exports.CustomReplacePlugin = CustomReplacePlugin;
|
|
|
33871
33908
|
|
|
33872
33909
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
33873
33910
|
exports.DragAndDropPlugin = void 0;
|
|
33874
|
-
var
|
|
33911
|
+
var handleDroppedExternalContent_1 = __webpack_require__(/*! ./utils/handleDroppedExternalContent */ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedExternalContent.ts");
|
|
33912
|
+
var handleDroppedInternalContent_1 = __webpack_require__(/*! ./utils/handleDroppedInternalContent */ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedInternalContent.ts");
|
|
33875
33913
|
var DefaultOptions = {
|
|
33876
33914
|
forbiddenElements: ['iframe'],
|
|
33877
33915
|
};
|
|
@@ -33888,7 +33926,7 @@ var DragAndDropPlugin = /** @class */ (function () {
|
|
|
33888
33926
|
var _a;
|
|
33889
33927
|
this.editor = null;
|
|
33890
33928
|
this.forbiddenElements = [];
|
|
33891
|
-
this.
|
|
33929
|
+
this.internalDrag = false;
|
|
33892
33930
|
this.disposer = null;
|
|
33893
33931
|
this.forbiddenElements = (_a = options.forbiddenElements) !== null && _a !== void 0 ? _a : [];
|
|
33894
33932
|
}
|
|
@@ -33910,7 +33948,7 @@ var DragAndDropPlugin = /** @class */ (function () {
|
|
|
33910
33948
|
this.disposer = editor.attachDomEvent({
|
|
33911
33949
|
dragstart: {
|
|
33912
33950
|
beforeDispatch: function (_ev) {
|
|
33913
|
-
_this.
|
|
33951
|
+
_this.internalDrag = true;
|
|
33914
33952
|
},
|
|
33915
33953
|
},
|
|
33916
33954
|
});
|
|
@@ -33926,7 +33964,6 @@ var DragAndDropPlugin = /** @class */ (function () {
|
|
|
33926
33964
|
this.disposer();
|
|
33927
33965
|
this.disposer = null;
|
|
33928
33966
|
}
|
|
33929
|
-
this.isInternalDragging = false;
|
|
33930
33967
|
this.forbiddenElements = [];
|
|
33931
33968
|
};
|
|
33932
33969
|
/**
|
|
@@ -33938,17 +33975,18 @@ var DragAndDropPlugin = /** @class */ (function () {
|
|
|
33938
33975
|
DragAndDropPlugin.prototype.onPluginEvent = function (event) {
|
|
33939
33976
|
var _a;
|
|
33940
33977
|
if (this.editor && event.eventType == 'beforeDrop') {
|
|
33941
|
-
|
|
33942
|
-
|
|
33978
|
+
var dropEvent = event.rawEvent;
|
|
33979
|
+
if (this.internalDrag &&
|
|
33980
|
+
this.editor.isExperimentalFeatureEnabled('HandleDropInternalContent')) {
|
|
33981
|
+
(0, handleDroppedInternalContent_1.handleDroppedInternalContent)(this.editor, dropEvent);
|
|
33943
33982
|
}
|
|
33944
|
-
else {
|
|
33945
|
-
var dropEvent = event.rawEvent;
|
|
33983
|
+
else if (!this.internalDrag) {
|
|
33946
33984
|
var html = (_a = dropEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
|
33947
33985
|
if (html) {
|
|
33948
|
-
(0,
|
|
33986
|
+
(0, handleDroppedExternalContent_1.handleDroppedExternalContent)(this.editor, dropEvent, html, this.forbiddenElements);
|
|
33949
33987
|
}
|
|
33950
33988
|
}
|
|
33951
|
-
|
|
33989
|
+
this.internalDrag = false;
|
|
33952
33990
|
}
|
|
33953
33991
|
};
|
|
33954
33992
|
return DragAndDropPlugin;
|
|
@@ -34002,23 +34040,23 @@ exports.cleanForbiddenElements = cleanForbiddenElements;
|
|
|
34002
34040
|
|
|
34003
34041
|
/***/ },
|
|
34004
34042
|
|
|
34005
|
-
/***/ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/
|
|
34006
|
-
|
|
34007
|
-
!*** ./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/
|
|
34008
|
-
|
|
34043
|
+
/***/ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedExternalContent.ts"
|
|
34044
|
+
/*!********************************************************************************************************!*\
|
|
34045
|
+
!*** ./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedExternalContent.ts ***!
|
|
34046
|
+
\********************************************************************************************************/
|
|
34009
34047
|
(__unused_webpack_module, exports, __webpack_require__) {
|
|
34010
34048
|
|
|
34011
34049
|
"use strict";
|
|
34012
34050
|
|
|
34013
34051
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
34014
|
-
exports.
|
|
34052
|
+
exports.handleDroppedExternalContent = void 0;
|
|
34015
34053
|
var cleanForbiddenElements_1 = __webpack_require__(/*! ./cleanForbiddenElements */ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/cleanForbiddenElements.ts");
|
|
34016
34054
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
34017
34055
|
/**
|
|
34018
34056
|
* @internal
|
|
34019
34057
|
* Handle dropped HTML content by inserting it at the drop position
|
|
34020
34058
|
*/
|
|
34021
|
-
function
|
|
34059
|
+
function handleDroppedExternalContent(editor, event, html, forbiddenElements) {
|
|
34022
34060
|
var doc = editor.getDocument();
|
|
34023
34061
|
var domPosition = (0, roosterjs_content_model_dom_1.getNodePositionFromEvent)(doc, editor.getDOMHelper(), event.x, event.y);
|
|
34024
34062
|
if (domPosition) {
|
|
@@ -34042,7 +34080,56 @@ function handleDroppedContent(editor, event, html, forbiddenElements) {
|
|
|
34042
34080
|
});
|
|
34043
34081
|
}
|
|
34044
34082
|
}
|
|
34045
|
-
exports.
|
|
34083
|
+
exports.handleDroppedExternalContent = handleDroppedExternalContent;
|
|
34084
|
+
|
|
34085
|
+
|
|
34086
|
+
/***/ },
|
|
34087
|
+
|
|
34088
|
+
/***/ "./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedInternalContent.ts"
|
|
34089
|
+
/*!********************************************************************************************************!*\
|
|
34090
|
+
!*** ./packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedInternalContent.ts ***!
|
|
34091
|
+
\********************************************************************************************************/
|
|
34092
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
34093
|
+
|
|
34094
|
+
"use strict";
|
|
34095
|
+
|
|
34096
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
34097
|
+
exports.handleDroppedInternalContent = void 0;
|
|
34098
|
+
var roosterjs_content_model_api_1 = __webpack_require__(/*! roosterjs-content-model-api */ "./packages/roosterjs-content-model-api/lib/index.ts");
|
|
34099
|
+
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
34100
|
+
/**
|
|
34101
|
+
* @internal
|
|
34102
|
+
* Handle dropped internal HTML content by inserting it at the drop position
|
|
34103
|
+
*/
|
|
34104
|
+
function handleDroppedInternalContent(editor, event) {
|
|
34105
|
+
var doc = editor.getDocument();
|
|
34106
|
+
var domPosition = (0, roosterjs_content_model_dom_1.getNodePositionFromEvent)(doc, editor.getDOMHelper(), event.x, event.y);
|
|
34107
|
+
var selection = editor.getDOMSelection();
|
|
34108
|
+
if (domPosition && selection) {
|
|
34109
|
+
event.preventDefault();
|
|
34110
|
+
event.stopPropagation();
|
|
34111
|
+
(0, roosterjs_content_model_api_1.formatInsertPointWithContentModel)(editor, domPosition, function (model, context, insertPoint) {
|
|
34112
|
+
if (insertPoint) {
|
|
34113
|
+
var cloneModel = (0, roosterjs_content_model_dom_1.cloneModelForPaste)(model);
|
|
34114
|
+
(0, roosterjs_content_model_dom_1.trimModelForSelection)(cloneModel, selection);
|
|
34115
|
+
if ((0, roosterjs_content_model_dom_1.deleteSelection)(model, [], context).deleteResult == 'range') {
|
|
34116
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
34117
|
+
}
|
|
34118
|
+
var startMarker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(insertPoint.marker.format);
|
|
34119
|
+
var startParagraph = (0, roosterjs_content_model_dom_1.mutateBlock)(insertPoint.paragraph);
|
|
34120
|
+
var startIndex = startParagraph.segments.indexOf(insertPoint.marker);
|
|
34121
|
+
startParagraph.segments.splice(startIndex, 0, startMarker);
|
|
34122
|
+
var newInsertPoint = (0, roosterjs_content_model_dom_1.mergeModel)(model, cloneModel, context, {
|
|
34123
|
+
insertPosition: insertPoint,
|
|
34124
|
+
});
|
|
34125
|
+
if (newInsertPoint) {
|
|
34126
|
+
(0, roosterjs_content_model_dom_1.setSelection)(model, startMarker, newInsertPoint.marker);
|
|
34127
|
+
}
|
|
34128
|
+
}
|
|
34129
|
+
});
|
|
34130
|
+
}
|
|
34131
|
+
}
|
|
34132
|
+
exports.handleDroppedInternalContent = handleDroppedInternalContent;
|
|
34046
34133
|
|
|
34047
34134
|
|
|
34048
34135
|
/***/ },
|
|
@@ -37116,7 +37203,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37116
37203
|
if (event.rawEvent.key == 'Enter' && this.isCropMode) {
|
|
37117
37204
|
event.rawEvent.preventDefault();
|
|
37118
37205
|
}
|
|
37119
|
-
this.applyFormatWithContentModel(editor, this.isCropMode,
|
|
37206
|
+
this.applyFormatWithContentModel(editor, this.isCropMode, false /** should selectImage */, false /* isApiOperation */);
|
|
37120
37207
|
}
|
|
37121
37208
|
}
|
|
37122
37209
|
};
|
|
@@ -37156,6 +37243,28 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37156
37243
|
var editingImageModel;
|
|
37157
37244
|
var selection = editor.getDOMSelection();
|
|
37158
37245
|
var isRTL = false;
|
|
37246
|
+
var formatContentModelOptions = {
|
|
37247
|
+
onNodeCreated: function (model, node) {
|
|
37248
|
+
var _a;
|
|
37249
|
+
if (!isApiOperation &&
|
|
37250
|
+
editingImageModel &&
|
|
37251
|
+
editingImageModel == model &&
|
|
37252
|
+
editingImageModel.format.imageState == findEditingImage_1.EDITING_MARKER &&
|
|
37253
|
+
(0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') &&
|
|
37254
|
+
(0, roosterjs_content_model_dom_1.isElementOfType)(node, 'img')) {
|
|
37255
|
+
if (_this.isCropMode) {
|
|
37256
|
+
_this.startCropMode(editor, node, isRTL);
|
|
37257
|
+
}
|
|
37258
|
+
else {
|
|
37259
|
+
(_a = editor.getDocument().defaultView) === null || _a === void 0 ? void 0 : _a.requestAnimationFrame(function () {
|
|
37260
|
+
_this.startRotateAndResize(editor, node, isRTL);
|
|
37261
|
+
});
|
|
37262
|
+
}
|
|
37263
|
+
}
|
|
37264
|
+
},
|
|
37265
|
+
apiName: IMAGE_EDIT_FORMAT_EVENT,
|
|
37266
|
+
skipDOMSelection: false,
|
|
37267
|
+
};
|
|
37159
37268
|
editor.formatContentModel(function (model, context) {
|
|
37160
37269
|
var editingImage = (0, getSelectedImage_1.getSelectedImage)(model);
|
|
37161
37270
|
var previousSelectedImage = isApiOperation
|
|
@@ -37214,28 +37323,12 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37214
37323
|
_this.imageEditInfo = (0, updateImageEditInfo_1.updateImageEditInfo)(image, selection.image);
|
|
37215
37324
|
image.format.imageState = 'isEditing';
|
|
37216
37325
|
});
|
|
37326
|
+
formatContentModelOptions.skipDOMSelection = !isCropMode;
|
|
37217
37327
|
result = true;
|
|
37218
37328
|
}
|
|
37219
37329
|
}
|
|
37220
37330
|
return result;
|
|
37221
|
-
}, {
|
|
37222
|
-
onNodeCreated: function (model, node) {
|
|
37223
|
-
if (!isApiOperation &&
|
|
37224
|
-
editingImageModel &&
|
|
37225
|
-
editingImageModel == model &&
|
|
37226
|
-
editingImageModel.format.imageState == findEditingImage_1.EDITING_MARKER &&
|
|
37227
|
-
(0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') &&
|
|
37228
|
-
(0, roosterjs_content_model_dom_1.isElementOfType)(node, 'img')) {
|
|
37229
|
-
if (isCropMode) {
|
|
37230
|
-
_this.startCropMode(editor, node, isRTL);
|
|
37231
|
-
}
|
|
37232
|
-
else {
|
|
37233
|
-
_this.startRotateAndResize(editor, node, isRTL);
|
|
37234
|
-
}
|
|
37235
|
-
}
|
|
37236
|
-
},
|
|
37237
|
-
apiName: IMAGE_EDIT_FORMAT_EVENT,
|
|
37238
|
-
}, {
|
|
37331
|
+
}, formatContentModelOptions, {
|
|
37239
37332
|
tryGetFromCache: true,
|
|
37240
37333
|
});
|
|
37241
37334
|
};
|
|
@@ -38221,7 +38314,6 @@ var createImageCropper_1 = __webpack_require__(/*! ../Cropper/createImageCropper
|
|
|
38221
38314
|
var createImageResizer_1 = __webpack_require__(/*! ../Resizer/createImageResizer */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Resizer/createImageResizer.ts");
|
|
38222
38315
|
var createImageRotator_1 = __webpack_require__(/*! ../Rotator/createImageRotator */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Rotator/createImageRotator.ts");
|
|
38223
38316
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
38224
|
-
var IMAGE_EDIT_SHADOW_ROOT = 'ImageEditShadowRoot';
|
|
38225
38317
|
/**
|
|
38226
38318
|
* @internal
|
|
38227
38319
|
*/
|
|
@@ -38254,15 +38346,8 @@ var createShadowSpan = function (wrapper, imageSpan, imageWidth, imageHeight) {
|
|
|
38254
38346
|
var shadowRoot = imageSpan.attachShadow({
|
|
38255
38347
|
mode: 'open',
|
|
38256
38348
|
});
|
|
38257
|
-
imageSpan.id = IMAGE_EDIT_SHADOW_ROOT;
|
|
38258
|
-
// Pin the shadow host to the original image's box so that wrapping the image does not grow the
|
|
38259
|
-
// surrounding line box. Without this, the taller edit wrapper enlarges the line and the browser
|
|
38260
|
-
// scrolls the selection back into view, making the editor jump. The wrapper and handles still
|
|
38261
|
-
// overflow the host visually because overflow is left visible.
|
|
38262
38349
|
if (imageWidth > 0 && imageHeight > 0) {
|
|
38263
38350
|
imageSpan.style.display = 'inline-block';
|
|
38264
|
-
imageSpan.style.width = imageWidth + "px";
|
|
38265
|
-
imageSpan.style.height = imageHeight + "px";
|
|
38266
38351
|
imageSpan.style.verticalAlign = 'bottom';
|
|
38267
38352
|
imageSpan.style.overflow = 'visible';
|
|
38268
38353
|
}
|
|
@@ -38936,7 +39021,7 @@ function getSelectedImageMetadata(editor, image) {
|
|
|
38936
39021
|
(0, roosterjs_content_model_dom_1.mutateSegment)(selectedImage.paragraph, selectedImage === null || selectedImage === void 0 ? void 0 : selectedImage.image, function (modelImage) {
|
|
38937
39022
|
imageMetadata = updateImageEditInfo(modelImage, image);
|
|
38938
39023
|
});
|
|
38939
|
-
return
|
|
39024
|
+
return false;
|
|
38940
39025
|
}
|
|
38941
39026
|
return false;
|
|
38942
39027
|
});
|
|
@@ -39746,6 +39831,7 @@ var BulletSelector = '* > span > span[style*=mso-special-format]';
|
|
|
39746
39831
|
var MsOfficeSpecialFormat = 'mso-special-format';
|
|
39747
39832
|
var CssStyleKey = 'style';
|
|
39748
39833
|
var MsoSpecialFormatRegex = /mso-special-format:\s*([^;]*)/;
|
|
39834
|
+
var TableElementTags = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TD', 'TH']);
|
|
39749
39835
|
var clearListItemStyles = function (format) {
|
|
39750
39836
|
delete format.textAlign;
|
|
39751
39837
|
delete format.marginLeft;
|
|
@@ -39772,7 +39858,9 @@ function processPastedContentFromPowerPoint(event, domCreator) {
|
|
|
39772
39858
|
if (style.includes(MsOfficeSpecialFormat) && context.listFormat.levels.length > 0) {
|
|
39773
39859
|
return;
|
|
39774
39860
|
}
|
|
39775
|
-
var bulletElement = element.
|
|
39861
|
+
var bulletElement = !TableElementTags.has(element.tagName)
|
|
39862
|
+
? element.querySelector(BulletSelector)
|
|
39863
|
+
: null;
|
|
39776
39864
|
if (bulletElement) {
|
|
39777
39865
|
var _c = extractPowerPointListInfo(element, bulletElement), depth = _c.depth, unorderedBulletType = _c.unorderedBulletType, orderedBulletType = _c.orderedBulletType, startNumberOverrideOrBullet_1 = _c.startNumberOverrideOrBullet, isOrderedList = _c.isOrderedList, isNewList_1 = _c.isNewList;
|
|
39778
39866
|
// Setup the listformat with the metadata extracted from the bullet element
|
|
@@ -39793,6 +39881,12 @@ function processPastedContentFromPowerPoint(event, domCreator) {
|
|
|
39793
39881
|
}
|
|
39794
39882
|
clearListItemStyles(listItem.levels[listItem.levels.length - 1].format);
|
|
39795
39883
|
clearListItemStyles(listItem.format);
|
|
39884
|
+
// When the list is inside a table cell, remove the font size from the
|
|
39885
|
+
// list marker so it does not inherit the list's font size. Otherwise a
|
|
39886
|
+
// large marker may be rendered outside of the table cell.
|
|
39887
|
+
if (element.closest('td,th')) {
|
|
39888
|
+
delete listItem.formatHolder.format.fontSize;
|
|
39889
|
+
}
|
|
39796
39890
|
});
|
|
39797
39891
|
}
|
|
39798
39892
|
else {
|