roosterjs-content-model-plugins 0.22.1 → 0.24.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/lib/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib/edit/ContentModelEditPlugin.js +1 -2
- package/lib/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteList.js +24 -0
- package/lib/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib/edit/handleKeyboardEventCommon.js +1 -1
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +2 -2
- package/lib/edit/keyboardDelete.js +8 -1
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +2 -2
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib/paste/ContentModelPastePlugin.js +17 -36
- package/lib/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/constants.d.ts +0 -8
- package/lib/paste/WacComponents/constants.js +1 -24
- package/lib/paste/WacComponents/constants.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +61 -65
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.js +39 -12
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +14 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib/paste/pasteSourceValidations/constants.js +5 -6
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +2 -2
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib-amd/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-amd/edit/ContentModelEditPlugin.js +1 -2
- package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteList.js +25 -0
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-amd/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +2 -2
- package/lib-amd/edit/keyboardDelete.js +8 -2
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +2 -2
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib-amd/paste/ContentModelPastePlugin.js +17 -36
- package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/constants.d.ts +0 -8
- package/lib-amd/paste/WacComponents/constants.js +1 -24
- package/lib-amd/paste/WacComponents/constants.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +61 -66
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -18
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js +39 -13
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +16 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-amd/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -3
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +2 -2
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js +1 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js +20 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-mjs/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +2 -2
- package/lib-mjs/edit/keyboardDelete.js +8 -1
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +2 -2
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib-mjs/paste/ContentModelPastePlugin.js +17 -36
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/constants.d.ts +0 -8
- package/lib-mjs/paste/WacComponents/constants.js +0 -23
- package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +63 -67
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.js +40 -13
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +10 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-mjs/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +2 -2
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { getListStyleTypeFromString, updateListMetadata } from 'roosterjs-content-model-core';
|
|
3
|
-
import {
|
|
3
|
+
import { removeNegativeTextIndentParser } from './removeNegativeTextIndentParser';
|
|
4
|
+
import { addBlock, createListItem, createListLevel, isEmpty, parseFormat, } from 'roosterjs-content-model-dom';
|
|
4
5
|
/** Word list metadata style name */
|
|
5
6
|
var MSO_LIST = 'mso-list';
|
|
6
7
|
var MSO_LIST_IGNORE = 'ignore';
|
|
@@ -45,7 +46,7 @@ export function processWordList(styles, group, element, context, metadata) {
|
|
|
45
46
|
: 'UL';
|
|
46
47
|
// Create the new level of the list item and parse the format
|
|
47
48
|
var newLevel = createListLevel(listType);
|
|
48
|
-
parseFormat(element, context.formatParsers.listLevel, newLevel.format, context);
|
|
49
|
+
parseFormat(element, __spreadArray(__spreadArray([], __read(context.formatParsers.listLevel), false), [wordListPaddingParser], false), newLevel.format, context);
|
|
49
50
|
// If the list format is in a different level, update the array so we get the new item
|
|
50
51
|
// To be in the same level as the provided level metadata.
|
|
51
52
|
if (wordLevel > listFormat.levels.length) {
|
|
@@ -57,6 +58,8 @@ export function processWordList(styles, group, element, context, metadata) {
|
|
|
57
58
|
listFormat.levels.splice(wordLevel, listFormat.levels.length - 1);
|
|
58
59
|
listFormat.levels[wordLevel - 1] = newLevel;
|
|
59
60
|
}
|
|
61
|
+
listFormat.levels[listFormat.levels.length - 1]
|
|
62
|
+
.format.wordList = wordList;
|
|
60
63
|
listFormat.listParent = group;
|
|
61
64
|
processAsListItem(listFormat, context, element, group, listMetadata);
|
|
62
65
|
if (listFormat.levels.length > 0 &&
|
|
@@ -82,8 +85,9 @@ function processAsListItem(listFormat, context, element, group, listMetadata) {
|
|
|
82
85
|
var listItem = createListItem(listFormat.levels, context.segmentFormat);
|
|
83
86
|
parseFormat(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
84
87
|
parseFormat(element, context.formatParsers.listItemElement, listItem.format, context);
|
|
88
|
+
parseFormat(element, [removeNegativeTextIndentParser], listItem.format, context);
|
|
85
89
|
if (listType == 'OL') {
|
|
86
|
-
|
|
90
|
+
setStartNumber(listItem, context, listMetadata);
|
|
87
91
|
}
|
|
88
92
|
context.elementProcessors.child(listItem, element, context);
|
|
89
93
|
addBlock(group, listItem);
|
|
@@ -134,16 +138,39 @@ function getBulletFromMetadata(listMetadata, listType) {
|
|
|
134
138
|
}
|
|
135
139
|
return getListStyleTypeFromString(listType, templateFinal);
|
|
136
140
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
function wordListPaddingParser(format, element) {
|
|
142
|
+
if (element.style.marginLeft && element.style.marginLeft != '0in') {
|
|
143
|
+
format.paddingLeft = '0px';
|
|
144
|
+
}
|
|
145
|
+
if (element.style.marginRight && element.style.marginRight != '0in') {
|
|
146
|
+
format.paddingRight = '0px';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function setStartNumber(listItem, context, listMetadata) {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
var _c = context.listFormat, listParent = _c.listParent, wordList = _c.wordList, wordKnownLevels = _c.wordKnownLevels, wordLevel = _c.wordLevel, levels = _c.levels;
|
|
152
|
+
var block = getLastNotEmptyBlock(listParent);
|
|
153
|
+
if (((block === null || block === void 0 ? void 0 : block.blockType) != 'BlockGroup' ||
|
|
154
|
+
block.blockGroupType != 'ListItem' ||
|
|
155
|
+
(wordLevel &&
|
|
156
|
+
((_b = (_a = block.levels[wordLevel]) === null || _a === void 0 ? void 0 : _a.format) === null || _b === void 0 ? void 0 : _b.wordList) != wordList)) &&
|
|
157
|
+
wordList) {
|
|
158
|
+
var start = (listMetadata === null || listMetadata === void 0 ? void 0 : listMetadata['mso-level-start-at'])
|
|
159
|
+
? parseInt(listMetadata['mso-level-start-at'])
|
|
160
|
+
: NaN;
|
|
161
|
+
var knownLevel = (wordKnownLevels === null || wordKnownLevels === void 0 ? void 0 : wordKnownLevels.get(wordList)) || [];
|
|
162
|
+
if (start != undefined && !isNaN(start) && knownLevel.length != levels.length) {
|
|
163
|
+
listItem.levels[listItem.levels.length - 1].format.startNumberOverride = start;
|
|
146
164
|
}
|
|
147
|
-
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function getLastNotEmptyBlock(listParent) {
|
|
168
|
+
for (var index = ((listParent === null || listParent === void 0 ? void 0 : listParent.blocks.length) || 0) - 1; index > 0; index--) {
|
|
169
|
+
var result = listParent === null || listParent === void 0 ? void 0 : listParent.blocks[index];
|
|
170
|
+
if (result && !isEmpty(result)) {
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
148
175
|
}
|
|
149
176
|
//# sourceMappingURL=processWordLists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processWordLists.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/processWordLists.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAE9F,OAAO,EACH,QAAQ,EACR,cAAc,EACd,eAAe,EACf,WAAW,GACd,MAAM,6BAA6B,CAAC;AAUrC,oCAAoC;AACpC,IAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,IAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAQ9C,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,MAA8B,EAC9B,KAA6B,EAC7B,OAAoB,EACpB,O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ACJ;IAED,OAAO,0BAA0B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,yBAAyB,CAC9B,YAAsC;IAEtC,OAAO,UAAC,MAAM,EAAE,CAAC,EAAE,OAAO;QAChB,IAAA,KAKF,OAAO,CAAC,UAAmC,EAJ3C,eAAe,qBAAA,EACf,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,MAAM,YACqC,CAAC;QAChD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,QAAQ,EAAE;YAC3C,IAAM,KAAK,GAAG,QAAQ,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,oBAAoB,CAAC,KAAI,GAAG,CAAC,CAAC;YACpE,IAAM,UAAU,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,GAAG,CAAC,QAAQ,CAAC,KAAI,EAAE,CAAC;YAExD,IAAI,KAAK,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;gBAC3E,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;aACtC;SACJ;IACL,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { getListStyleTypeFromString, updateListMetadata } from 'roosterjs-content-model-core';\nimport type { WordMetadata } from './WordMetadata';\nimport {\n addBlock,\n createListItem,\n createListLevel,\n parseFormat,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockGroup,\n ContentModelListItemLevelFormat,\n ContentModelListLevel,\n DomToModelContext,\n DomToModelListFormat,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\n/** Word list metadata style name */\nconst MSO_LIST = 'mso-list';\nconst MSO_LIST_IGNORE = 'ignore';\nconst WORD_FIRST_LIST = 'l0';\n\nconst TEMPLATE_VALUE_REGEX = /%[0-9a-zA-Z]+/g;\n\ninterface WordDesktopListFormat extends DomToModelListFormat {\n wordLevel?: number | '';\n wordList?: string;\n wordKnownLevels?: Map<string, ContentModelListLevel[]>;\n}\n\nconst BULLET_METADATA = 'bullet';\n/**\n * @internal\n * @param styles\n * @param group\n * @param element\n * @param context\n * @returns\n */\nexport function processWordList(\n styles: Record<string, string>,\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext,\n metadata: Map<string, WordMetadata>\n) {\n const listFormat = context.listFormat as WordDesktopListFormat;\n if (!listFormat.wordKnownLevels) {\n listFormat.wordKnownLevels = new Map<string, ContentModelListLevel[]>();\n }\n const wordListStyle = styles[MSO_LIST] || '';\n\n // If the element contains Ignore style, do not process it,\n // Usually this element contains the fake bullet used in Word Desktop.\n if (wordListStyle.toLowerCase() === MSO_LIST_IGNORE) {\n return true;\n }\n\n const [lNumber, level] = wordListStyle.split(' ');\n // Try get the list metadata from word, which follows this format: l1 level1 lfo2\n // If we are able to get the level property means we can process this element to be a list\n listFormat.wordLevel = level && parseInt(level.substr('level'.length));\n\n listFormat.wordList = lNumber || WORD_FIRST_LIST;\n if (listFormat.levels.length == 0) {\n listFormat.levels =\n (listFormat.wordList && listFormat.wordKnownLevels.get(listFormat.wordList)) || [];\n }\n\n if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {\n const { wordLevel, wordList } = listFormat;\n // Retrieve the Fake bullet on the element and also the list type\n const listMetadata = metadata.get(`${lNumber}:${level}`);\n const listType =\n listMetadata?.['mso-level-number-format']?.toLowerCase() != BULLET_METADATA\n ? 'OL'\n : 'UL';\n\n // Create the new level of the list item and parse the format\n const newLevel: ContentModelListLevel = createListLevel(listType);\n parseFormat(element, context.formatParsers.listLevel, newLevel.format, context);\n\n // If the list format is in a different level, update the array so we get the new item\n // To be in the same level as the provided level metadata.\n if (wordLevel > listFormat.levels.length) {\n while (wordLevel != listFormat.levels.length) {\n listFormat.levels.push(newLevel);\n }\n } else {\n listFormat.levels.splice(wordLevel, listFormat.levels.length - 1);\n listFormat.levels[wordLevel - 1] = newLevel;\n }\n\n listFormat.listParent = group;\n\n processAsListItem(listFormat, context, element, group, listMetadata);\n\n if (\n listFormat.levels.length > 0 &&\n listFormat.wordKnownLevels.get(wordList) != listFormat.levels\n ) {\n listFormat.wordKnownLevels.set(wordList, [...listFormat.levels]);\n }\n return true;\n }\n\n return false;\n}\n\nfunction processAsListItem(\n listFormat: WordDesktopListFormat,\n context: DomToModelContext,\n element: HTMLElement,\n group: ContentModelBlockGroup,\n listMetadata: WordMetadata | undefined\n) {\n const listLevel = listFormat.levels[listFormat.levels.length - 1];\n const { listType } = listLevel;\n const bullet = getBulletFromMetadata(listMetadata, listType);\n if (bullet) {\n updateListMetadata(listFormat.levels[listFormat.levels.length - 1], metadata =>\n Object.assign({}, metadata, {\n unorderedStyleType: listType == 'UL' ? bullet : undefined,\n orderedStyleType: listType == 'OL' ? bullet : undefined,\n })\n );\n }\n\n const listItem = createListItem(listFormat.levels, context.segmentFormat);\n\n parseFormat(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n parseFormat(element, context.formatParsers.listItemElement, listItem.format, context);\n\n if (listType == 'OL') {\n parseFormat(\n element,\n [startNumberOverrideParser(listMetadata)],\n listItem.levels[listItem.levels.length - 1].format,\n context\n );\n }\n\n context.elementProcessors.child(listItem, element, context);\n addBlock(group, listItem);\n}\n\nfunction getBulletFromMetadata(listMetadata: WordMetadata | undefined, listType: 'OL' | 'UL') {\n const templateType = listMetadata?.['mso-level-number-format'] || 'decimal';\n let templateFinal: string;\n\n if (listMetadata?.['mso-level-text']) {\n let templateValue: string = '';\n switch (templateType) {\n case 'alpha-upper':\n templateValue = 'UpperAlpha';\n break;\n case 'alpha-lower':\n templateValue = 'LowerAlpha';\n break;\n case 'roman-lower':\n templateValue = 'LowerRoman';\n break;\n case 'roman-upper':\n templateValue = 'UpperRoman';\n break;\n default:\n templateValue = 'Number';\n break;\n }\n const template = (listMetadata['mso-level-text'] || '')\n .replace('\\\\', '')\n .replace('\"', '')\n .replace(TEMPLATE_VALUE_REGEX, '${' + templateValue + '}');\n\n templateFinal = '\"' + template + ' \"';\n } else {\n switch (templateType) {\n case 'alpha-lower':\n templateFinal = 'lower-alpha';\n break;\n case 'roman-lower':\n templateFinal = 'lower-roman';\n break;\n case 'roman-upper':\n templateFinal = 'upper-roman';\n break;\n default:\n templateFinal = 'decimal';\n break;\n }\n }\n\n return getListStyleTypeFromString(listType, templateFinal);\n}\n\nfunction startNumberOverrideParser(\n listMetadata: WordMetadata | undefined\n): FormatParser<ContentModelListItemLevelFormat> | null {\n return (format, _, context) => {\n const {\n wordKnownLevels,\n wordLevel,\n wordList,\n levels,\n } = context.listFormat as WordDesktopListFormat;\n if (typeof wordLevel === 'number' && wordList) {\n const start = parseInt(listMetadata?.['mso-level-start-at'] || '1');\n const knownLevel = wordKnownLevels?.get(wordList) || [];\n\n if (start != undefined && !isNaN(start) && knownLevel.length != levels.length) {\n format.startNumberOverride = start;\n }\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"processWordLists.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/processWordLists.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,EACH,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,GACd,MAAM,6BAA6B,CAAC;AAWrC,oCAAoC;AACpC,IAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,IAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAY9C,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,MAA8B,EAC9B,KAA6B,EAC7B,OAAoB,EACpB,OAA0B,EAC1B,QAAmC;;IAEnC,I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,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,GAAG,CAAC,QAAQ,CAAC,KAAI,EAAE,CAAC;QAExD,IAAI,KAAK,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YAC3E,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;SAClF;KACJ;AACL,CAAC;AAED,SAAS,oBAAoB,CAAC,UAA8C;IACxE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAC,MAAM,KAAI,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;QACvE,IAAM,MAAM,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,MAAM,CAAC;SACjB;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import { getListStyleTypeFromString, updateListMetadata } from 'roosterjs-content-model-core';\nimport { removeNegativeTextIndentParser } from './removeNegativeTextIndentParser';\nimport type { WordMetadata } from './WordMetadata';\nimport {\n addBlock,\n createListItem,\n createListLevel,\n isEmpty,\n parseFormat,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockGroup,\n ContentModelListItem,\n ContentModelListItemFormat,\n ContentModelListItemLevelFormat,\n ContentModelListLevel,\n DomToModelContext,\n DomToModelListFormat,\n} from 'roosterjs-content-model-types';\n\n/** Word list metadata style name */\nconst MSO_LIST = 'mso-list';\nconst MSO_LIST_IGNORE = 'ignore';\nconst WORD_FIRST_LIST = 'l0';\nconst TEMPLATE_VALUE_REGEX = /%[0-9a-zA-Z]+/g;\n\ninterface WordDesktopListFormat extends DomToModelListFormat {\n wordLevel?: number | '';\n wordList?: string;\n wordKnownLevels?: Map<string, ContentModelListLevel[]>;\n}\n\ninterface WordListFormat extends ContentModelListItemFormat {\n wordList?: string;\n}\n\nconst BULLET_METADATA = 'bullet';\n/**\n * @internal\n * @param styles\n * @param group\n * @param element\n * @param context\n * @returns\n */\nexport function processWordList(\n styles: Record<string, string>,\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext,\n metadata: Map<string, WordMetadata>\n) {\n const listFormat = context.listFormat as WordDesktopListFormat;\n if (!listFormat.wordKnownLevels) {\n listFormat.wordKnownLevels = new Map<string, ContentModelListLevel[]>();\n }\n const wordListStyle = styles[MSO_LIST] || '';\n\n // If the element contains Ignore style, do not process it,\n // Usually this element contains the fake bullet used in Word Desktop.\n if (wordListStyle.toLowerCase() === MSO_LIST_IGNORE) {\n return true;\n }\n\n const [lNumber, level] = wordListStyle.split(' ');\n // Try get the list metadata from word, which follows this format: l1 level1 lfo2\n // If we are able to get the level property means we can process this element to be a list\n listFormat.wordLevel = level && parseInt(level.substr('level'.length));\n\n listFormat.wordList = lNumber || WORD_FIRST_LIST;\n if (listFormat.levels.length == 0) {\n listFormat.levels =\n (listFormat.wordList && listFormat.wordKnownLevels.get(listFormat.wordList)) || [];\n }\n\n if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {\n const { wordLevel, wordList } = listFormat;\n // Retrieve the Fake bullet on the element and also the list type\n const listMetadata = metadata.get(`${lNumber}:${level}`);\n const listType =\n listMetadata?.['mso-level-number-format']?.toLowerCase() != BULLET_METADATA\n ? 'OL'\n : 'UL';\n\n // Create the new level of the list item and parse the format\n const newLevel: ContentModelListLevel = createListLevel(listType);\n parseFormat(\n element,\n [...context.formatParsers.listLevel, wordListPaddingParser],\n newLevel.format,\n context\n );\n\n // If the list format is in a different level, update the array so we get the new item\n // To be in the same level as the provided level metadata.\n if (wordLevel > listFormat.levels.length) {\n while (wordLevel != listFormat.levels.length) {\n listFormat.levels.push(newLevel);\n }\n } else {\n listFormat.levels.splice(wordLevel, listFormat.levels.length - 1);\n listFormat.levels[wordLevel - 1] = newLevel;\n }\n (listFormat.levels[listFormat.levels.length - 1]\n .format as WordListFormat).wordList = wordList;\n\n listFormat.listParent = group;\n\n processAsListItem(listFormat, context, element, group, listMetadata);\n\n if (\n listFormat.levels.length > 0 &&\n listFormat.wordKnownLevels.get(wordList) != listFormat.levels\n ) {\n listFormat.wordKnownLevels.set(wordList, [...listFormat.levels]);\n }\n return true;\n }\n\n return false;\n}\n\nfunction processAsListItem(\n listFormat: WordDesktopListFormat,\n context: DomToModelContext,\n element: HTMLElement,\n group: ContentModelBlockGroup,\n listMetadata: WordMetadata | undefined\n) {\n const listLevel = listFormat.levels[listFormat.levels.length - 1];\n const { listType } = listLevel;\n const bullet = getBulletFromMetadata(listMetadata, listType);\n if (bullet) {\n updateListMetadata(listFormat.levels[listFormat.levels.length - 1], metadata =>\n Object.assign({}, metadata, {\n unorderedStyleType: listType == 'UL' ? bullet : undefined,\n orderedStyleType: listType == 'OL' ? bullet : undefined,\n })\n );\n }\n\n const listItem = createListItem(listFormat.levels, context.segmentFormat);\n\n parseFormat(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n parseFormat(element, context.formatParsers.listItemElement, listItem.format, context);\n parseFormat(element, [removeNegativeTextIndentParser], listItem.format, context);\n\n if (listType == 'OL') {\n setStartNumber(listItem, context, listMetadata);\n }\n\n context.elementProcessors.child(listItem, element, context);\n addBlock(group, listItem);\n}\n\nfunction getBulletFromMetadata(listMetadata: WordMetadata | undefined, listType: 'OL' | 'UL') {\n const templateType = listMetadata?.['mso-level-number-format'] || 'decimal';\n let templateFinal: string;\n\n if (listMetadata?.['mso-level-text']) {\n let templateValue: string = '';\n switch (templateType) {\n case 'alpha-upper':\n templateValue = 'UpperAlpha';\n break;\n case 'alpha-lower':\n templateValue = 'LowerAlpha';\n break;\n case 'roman-lower':\n templateValue = 'LowerRoman';\n break;\n case 'roman-upper':\n templateValue = 'UpperRoman';\n break;\n default:\n templateValue = 'Number';\n break;\n }\n const template = (listMetadata['mso-level-text'] || '')\n .replace('\\\\', '')\n .replace('\"', '')\n .replace(TEMPLATE_VALUE_REGEX, '${' + templateValue + '}');\n\n templateFinal = '\"' + template + ' \"';\n } else {\n switch (templateType) {\n case 'alpha-lower':\n templateFinal = 'lower-alpha';\n break;\n case 'roman-lower':\n templateFinal = 'lower-roman';\n break;\n case 'roman-upper':\n templateFinal = 'upper-roman';\n break;\n default:\n templateFinal = 'decimal';\n break;\n }\n }\n\n return getListStyleTypeFromString(listType, templateFinal);\n}\n\nfunction wordListPaddingParser(\n format: ContentModelListItemLevelFormat,\n element: HTMLElement\n): void {\n if (element.style.marginLeft && element.style.marginLeft != '0in') {\n format.paddingLeft = '0px';\n }\n if (element.style.marginRight && element.style.marginRight != '0in') {\n format.paddingRight = '0px';\n }\n}\n\nfunction setStartNumber(\n listItem: ContentModelListItem,\n context: DomToModelContext,\n listMetadata: WordMetadata | undefined\n) {\n const {\n listParent,\n wordList,\n wordKnownLevels,\n wordLevel,\n levels,\n } = context.listFormat as WordDesktopListFormat;\n\n const block = getLastNotEmptyBlock(listParent);\n if (\n (block?.blockType != 'BlockGroup' ||\n block.blockGroupType != 'ListItem' ||\n (wordLevel &&\n (block.levels[wordLevel]?.format as WordListFormat)?.wordList != wordList)) &&\n wordList\n ) {\n const start = listMetadata?.['mso-level-start-at']\n ? parseInt(listMetadata['mso-level-start-at'])\n : NaN;\n const knownLevel = wordKnownLevels?.get(wordList) || [];\n\n if (start != undefined && !isNaN(start) && knownLevel.length != levels.length) {\n listItem.levels[listItem.levels.length - 1].format.startNumberOverride = start;\n }\n }\n}\n\nfunction getLastNotEmptyBlock(listParent: ContentModelBlockGroup | undefined) {\n for (let index = (listParent?.blocks.length || 0) - 1; index > 0; index--) {\n const result = listParent?.blocks[index];\n if (result && !isEmpty(result)) {\n return result;\n }\n }\n\n return undefined;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export var removeNegativeTextIndentParser = function (format, element) {
|
|
5
|
+
var _a;
|
|
6
|
+
if ((_a = format.textIndent) === null || _a === void 0 ? void 0 : _a.startsWith('-')) {
|
|
7
|
+
delete format.textIndent;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=removeNegativeTextIndentParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeNegativeTextIndentParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/removeNegativeTextIndentParser.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,IAAM,8BAA8B,GAAmC,UAAC,MAAM,EAAE,OAAO;;IAC1F,IAAI,MAAA,MAAM,CAAC,UAAU,0CAAE,UAAU,CAAC,GAAG,CAAC,EAAE;QACpC,OAAO,MAAM,CAAC,UAAU,CAAC;KAC5B;AACL,CAAC,CAAC","sourcesContent":["import type { FormatParser, TextIndentFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const removeNegativeTextIndentParser: FormatParser<TextIndentFormat> = (format, element) => {\n if (format.textIndent?.startsWith('-')) {\n delete format.textIndent;\n }\n};\n"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const PastePropertyNames: {
|
|
5
5
|
/**
|
|
6
6
|
* Node attribute used to identify if the content is from Google Sheets.
|
|
7
7
|
*/
|
|
8
|
-
GOOGLE_SHEET_NODE_NAME
|
|
8
|
+
GOOGLE_SHEET_NODE_NAME: string;
|
|
9
9
|
/**
|
|
10
10
|
* Name of the HTMLMeta Property that provides the Office App Source of the pasted content
|
|
11
11
|
*/
|
|
12
|
-
PROG_ID_NAME
|
|
12
|
+
PROG_ID_NAME: string;
|
|
13
13
|
/**
|
|
14
14
|
* Name of the HTMLMeta Property that identifies pated content as from Excel Desktop
|
|
15
15
|
*/
|
|
16
|
-
EXCEL_DESKTOP_ATTRIBUTE_NAME
|
|
17
|
-
}
|
|
16
|
+
EXCEL_DESKTOP_ATTRIBUTE_NAME: string;
|
|
17
|
+
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
|
-
export var PastePropertyNames
|
|
5
|
-
(function (PastePropertyNames) {
|
|
4
|
+
export var PastePropertyNames = {
|
|
6
5
|
/**
|
|
7
6
|
* Node attribute used to identify if the content is from Google Sheets.
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
GOOGLE_SHEET_NODE_NAME: 'google-sheets-html-origin',
|
|
10
9
|
/**
|
|
11
10
|
* Name of the HTMLMeta Property that provides the Office App Source of the pasted content
|
|
12
11
|
*/
|
|
13
|
-
|
|
12
|
+
PROG_ID_NAME: 'ProgId',
|
|
14
13
|
/**
|
|
15
14
|
* Name of the HTMLMeta Property that identifies pated content as from Excel Desktop
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
EXCEL_DESKTOP_ATTRIBUTE_NAME: 'xmlns:x',
|
|
17
|
+
};
|
|
19
18
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAC9B;;OAEG;IACH,sBAAsB,EAAE,2BAA2B;IAEnD;;OAEG;IACH,YAAY,EAAE,QAAQ;IAEtB;;OAEG;IACH,4BAA4B,EAAE,SAAS;CAC1C,CAAC","sourcesContent":["/**\n * @internal\n */\nexport const PastePropertyNames = {\n /**\n * Node attribute used to identify if the content is from Google Sheets.\n */\n GOOGLE_SHEET_NODE_NAME: 'google-sheets-html-origin',\n\n /**\n * Name of the HTMLMeta Property that provides the Office App Source of the pasted content\n */\n PROG_ID_NAME: 'ProgId',\n\n /**\n * Name of the HTMLMeta Property that identifies pated content as from Excel Desktop\n */\n EXCEL_DESKTOP_ATTRIBUTE_NAME: 'xmlns:x',\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPasteSource.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getPasteSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"getPasteSource.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getPasteSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAgC1E,IAAM,kBAAkB,GAAG,IAAI,GAAG,CAA0C;IACxE,CAAC,aAAa,EAAE,qBAAqB,CAAC;IACtC,CAAC,cAAc,EAAE,sBAAsB,CAAC;IACxC,CAAC,aAAa,EAAE,qBAAqB,CAAC;IACtC,CAAC,mBAAmB,EAAE,2BAA2B,CAAC;IAClD,CAAC,eAAe,EAAE,0BAA0B,CAAC;IAC7C,CAAC,cAAc,EAAE,qBAAqB,CAAC;IACvC,CAAC,aAAa,EAAE,0BAA0B,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC1B,KAAuB,EACvB,wBAAiC;IAEzB,IAAA,cAAc,GAA8B,KAAK,eAAnC,EAAE,aAAa,GAAe,KAAK,cAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IAE1D,IAAI,MAAM,GAAgC,IAAI,CAAC;IAC/C,IAAM,KAAK,GAAyB;QAChC,cAAc,gBAAA;QACd,QAAQ,UAAA;QACR,wBAAwB,0BAAA;QACxB,aAAa,eAAA;KAChB,CAAC;IAEF,kBAAkB,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,GAAG;QACjC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,GAAG,GAAG,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;AAC/B,CAAC","sourcesContent":["import { documentContainWacElements } from './documentContainWacElements';\nimport { isExcelDesktopDocument } from './isExcelDesktopDocument';\nimport { isExcelOnlineDocument } from './isExcelOnlineDocument';\nimport { isGoogleSheetDocument } from './isGoogleSheetDocument';\nimport { isPowerPointDesktopDocument } from './isPowerPointDesktopDocument';\nimport { isWordDesktopDocument } from './isWordDesktopDocument';\nimport { shouldConvertToSingleImage } from './shouldConvertToSingleImage';\nimport type { BeforePasteEvent, ClipboardData } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport type GetSourceInputParams = {\n htmlAttributes: Record<string, string>;\n fragment: DocumentFragment;\n shouldConvertSingleImage: boolean;\n clipboardData: ClipboardData;\n};\n\n/**\n * @internal\n * Represent the types of sources to handle in the Paste Plugin\n */\nexport type KnownPasteSourceType =\n | 'wordDesktop'\n | 'excelDesktop'\n | 'excelOnline'\n | 'powerPointDesktop'\n | 'googleSheets'\n | 'wacComponents'\n | 'default'\n | 'singleImage';\n\n/**\n * @internal\n */\nexport type GetSourceFunction = (props: GetSourceInputParams) => boolean;\n\nconst getSourceFunctions = new Map<KnownPasteSourceType, GetSourceFunction>([\n ['wordDesktop', isWordDesktopDocument],\n ['excelDesktop', isExcelDesktopDocument],\n ['excelOnline', isExcelOnlineDocument],\n ['powerPointDesktop', isPowerPointDesktopDocument],\n ['wacComponents', documentContainWacElements],\n ['googleSheets', isGoogleSheetDocument],\n ['singleImage', shouldConvertToSingleImage],\n]);\n\n/**\n * @internal\n * This function tries to get the source of the Pasted content\n * @param event the before paste event\n * @param shouldConvertSingleImage Whether convert single image is enabled.\n * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}\n */\nexport function getPasteSource(\n event: BeforePasteEvent,\n shouldConvertSingleImage: boolean\n): KnownPasteSourceType {\n const { htmlAttributes, clipboardData, fragment } = event;\n\n let result: KnownPasteSourceType | null = null;\n const param: GetSourceInputParams = {\n htmlAttributes,\n fragment,\n shouldConvertSingleImage,\n clipboardData,\n };\n\n getSourceFunctions.forEach((func, key) => {\n if (!result && func(param)) {\n result = key;\n }\n });\n\n return result ?? 'default';\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PastePropertyNames } from './constants';
|
|
1
2
|
var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
@@ -8,6 +9,6 @@ var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
|
|
|
8
9
|
export var isExcelDesktopDocument = function (props) {
|
|
9
10
|
var htmlAttributes = props.htmlAttributes;
|
|
10
11
|
// The presence of this attribute confirms its origin from Excel Desktop
|
|
11
|
-
return htmlAttributes[
|
|
12
|
+
return htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == EXCEL_ATTRIBUTE_VALUE;
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=isExcelDesktopDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isExcelDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelDesktopDocument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isExcelDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelDesktopDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,IAAM,qBAAqB,GAAG,wCAAwC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,IAAM,sBAAsB,GAAsB,UAAA,KAAK;IAClD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,wEAAwE;IACxE,OAAO,cAAc,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,IAAI,qBAAqB,CAAC;AACpG,CAAC,CAAC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Excel Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isExcelDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of this attribute confirms its origin from Excel Desktop\n return htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == EXCEL_ATTRIBUTE_VALUE;\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PastePropertyNames } from './constants';
|
|
1
2
|
// Excel Desktop also has this attribute
|
|
2
3
|
var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
|
|
3
4
|
/**
|
|
@@ -9,7 +10,7 @@ var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
|
|
|
9
10
|
export var isExcelOnlineDocument = function (props) {
|
|
10
11
|
var htmlAttributes = props.htmlAttributes;
|
|
11
12
|
// The presence of Excel.Sheet confirms its origin from Excel, the absence of EXCEL_DESKTOP_ATTRIBUTE_NAME confirms it is from the Online version
|
|
12
|
-
return (htmlAttributes[
|
|
13
|
-
htmlAttributes[
|
|
13
|
+
return (htmlAttributes[PastePropertyNames.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE &&
|
|
14
|
+
htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == undefined);
|
|
14
15
|
};
|
|
15
16
|
//# sourceMappingURL=isExcelOnlineDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,wCAAwC;AACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,iJAAiJ;IACjJ,OAAO,CACH,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,4BAA4B;QAC/E,cAAc,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,IAAI,SAAS,CAC/E,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n// Excel Desktop also has this attribute\nconst EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Excel Online documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isExcelOnlineDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of Excel.Sheet confirms its origin from Excel, the absence of EXCEL_DESKTOP_ATTRIBUTE_NAME confirms it is from the Online version\n return (\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE &&\n htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == undefined\n );\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PastePropertyNames } from './constants';
|
|
1
2
|
/**
|
|
2
3
|
* @internal
|
|
3
4
|
* Checks whether the fragment provided contain elements from Google sheets
|
|
@@ -6,6 +7,6 @@
|
|
|
6
7
|
*/
|
|
7
8
|
export var isGoogleSheetDocument = function (props) {
|
|
8
9
|
var fragment = props.fragment;
|
|
9
|
-
return !!fragment.querySelector(
|
|
10
|
+
return !!fragment.querySelector(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=isGoogleSheetDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD;;;;;GAKG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Checks whether the fragment provided contain elements from Google sheets\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isGoogleSheetDocument: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PastePropertyNames } from './constants';
|
|
1
2
|
var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
@@ -6,6 +7,6 @@ var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
|
|
|
6
7
|
* @returns
|
|
7
8
|
*/
|
|
8
9
|
export var isPowerPointDesktopDocument = function (props) {
|
|
9
|
-
return props.htmlAttributes[
|
|
10
|
+
return props.htmlAttributes[PastePropertyNames.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=isPowerPointDesktopDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,IAAM,2BAA2B,GAAsB,UAAA,KAAK;IAC/D,OAAO,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,0BAA0B,CAAC;AAC/F,CAAC,CAAC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Power Point Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isPowerPointDesktopDocument: GetSourceFunction = props => {\n return props.htmlAttributes[PastePropertyNames.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PastePropertyNames } from './constants';
|
|
1
2
|
var WORD_ATTRIBUTE_NAME = 'xmlns:w';
|
|
2
3
|
var WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';
|
|
3
4
|
var WORD_PROG_ID = 'Word.Document';
|
|
@@ -10,6 +11,6 @@ var WORD_PROG_ID = 'Word.Document';
|
|
|
10
11
|
export var isWordDesktopDocument = function (props) {
|
|
11
12
|
var htmlAttributes = props.htmlAttributes;
|
|
12
13
|
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
13
|
-
htmlAttributes[
|
|
14
|
+
htmlAttributes[PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID);
|
|
14
15
|
};
|
|
15
16
|
//# sourceMappingURL=isWordDesktopDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,IAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;AACrE,IAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;QAC3D,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,YAAY,CAClE,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst WORD_ATTRIBUTE_NAME = 'xmlns:w';\nconst WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';\nconst WORD_PROG_ID = 'Word.Document';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Word Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isWordDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n return (\n htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID\n );\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentModelFormatMap, DomToModelOption, FormatParser,
|
|
1
|
+
import type { ContentModelFormatMap, DomToModelOption, FormatParser, ElementFormatParserPerCategory } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export default function addParser<TKey extends keyof
|
|
5
|
+
export default function addParser<TKey extends keyof ElementFormatParserPerCategory>(domToModelOption: DomToModelOption, entry: TKey, additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/addParser.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC7B,gBAAkC,EAClC,KAAW,EACX,uBAAkE;;IAElE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;QAC3C,gBAAgB,CAAC,uBAAuB,GAAG,EAAE,CAAC;KACjD;IACD,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAClD,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;KACxD;IAED,MAAA,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,0CAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import type {\n ContentModelFormatMap,\n DomToModelOption,\n FormatParser,\n
|
|
1
|
+
{"version":3,"file":"addParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/addParser.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC7B,gBAAkC,EAClC,KAAW,EACX,uBAAkE;;IAElE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;QAC3C,gBAAgB,CAAC,uBAAuB,GAAG,EAAE,CAAC;KACjD;IACD,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAClD,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;KACxD;IAED,MAAA,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,0CAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import type {\n ContentModelFormatMap,\n DomToModelOption,\n FormatParser,\n ElementFormatParserPerCategory,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport default function addParser<TKey extends keyof ElementFormatParserPerCategory>(\n domToModelOption: DomToModelOption,\n entry: TKey,\n additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>\n) {\n if (!domToModelOption.additionalFormatParsers) {\n domToModelOption.additionalFormatParsers = {};\n }\n if (!domToModelOption.additionalFormatParsers[entry]) {\n domToModelOption.additionalFormatParsers[entry] = [];\n }\n\n domToModelOption.additionalFormatParsers[entry]?.push(additionalFormatParsers);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
6
|
"roosterjs-editor-types": "^8.59.0",
|
|
7
7
|
"roosterjs-editor-dom": "^8.59.0",
|
|
8
|
-
"roosterjs-content-model-core": "^0.
|
|
9
|
-
"roosterjs-content-model-editor": "^0.
|
|
10
|
-
"roosterjs-content-model-dom": "^0.
|
|
11
|
-
"roosterjs-content-model-types": "^0.
|
|
8
|
+
"roosterjs-content-model-core": "^0.24.0",
|
|
9
|
+
"roosterjs-content-model-editor": "^0.24.0",
|
|
10
|
+
"roosterjs-content-model-dom": "^0.24.0",
|
|
11
|
+
"roosterjs-content-model-types": "^0.24.0"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.24.0",
|
|
14
14
|
"main": "./lib/index.js",
|
|
15
15
|
"typings": "./lib/index.d.ts",
|
|
16
16
|
"module": "./lib-mjs/index.js",
|