roosterjs-content-model-dom 9.0.0 → 9.1.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/config/defaultContentModelFormatMap.js +1 -0
- package/lib/config/defaultContentModelFormatMap.js.map +1 -1
- package/lib/modelToText/contentModelToText.js +6 -1
- package/lib/modelToText/contentModelToText.js.map +1 -1
- package/lib-amd/config/defaultContentModelFormatMap.js +1 -0
- package/lib-amd/config/defaultContentModelFormatMap.js.map +1 -1
- package/lib-amd/modelToText/contentModelToText.js +6 -1
- package/lib-amd/modelToText/contentModelToText.js.map +1 -1
- package/lib-mjs/config/defaultContentModelFormatMap.js +1 -0
- package/lib-mjs/config/defaultContentModelFormatMap.js.map +1 -1
- package/lib-mjs/modelToText/contentModelToText.js +6 -1
- package/lib-mjs/modelToText/contentModelToText.js.map +1 -1
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ exports.defaultContentModelFormatMap = void 0;
|
|
|
8
8
|
exports.defaultContentModelFormatMap = {
|
|
9
9
|
a: {
|
|
10
10
|
underline: true,
|
|
11
|
+
textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one
|
|
11
12
|
},
|
|
12
13
|
blockquote: {
|
|
13
14
|
marginTop: '1em',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,4BAA4B,GAA6B;IAClE,CAAC,EAAE;QACC,SAAS,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,4BAA4B,GAA6B;IAClE,CAAC,EAAE;QACC,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,SAAS,EAAE,sLAAsL;KAC/M;IACD,UAAU,EAAE;QACR,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;KACtB;IACD,IAAI,EAAE;QACF,UAAU,EAAE,WAAW;KAC1B;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,KAAK;KAClB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,OAAO;KACpB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,KAAK,EAAE,wFAAwF;KAC5G;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,CAAC,EAAE;QACC,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;KACtB;IACD,GAAG,EAAE;QACD,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;KACtB;CACJ,CAAC","sourcesContent":["import type { DefaultImplicitFormatMap } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * A map from tag name to its default implicit formats\n */\nexport const defaultContentModelFormatMap: DefaultImplicitFormatMap = {\n a: {\n underline: true,\n textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one\n },\n blockquote: {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n code: {\n fontFamily: 'monospace',\n },\n h1: {\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n fontWeight: 'bold',\n fontSize: '1em', // Set this default value here to overwrite existing font size when change heading level\n },\n h5: {\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n p: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contentModelToText = void 0;
|
|
4
|
+
var TextForHR = '________________________________________';
|
|
4
5
|
/**
|
|
5
6
|
* Convert Content Model to plain text
|
|
6
7
|
* @param model The source Content Model
|
|
@@ -38,9 +39,13 @@ function contentModelToTextArray(group, textArray) {
|
|
|
38
39
|
break;
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
|
|
42
|
+
if (text_1) {
|
|
43
|
+
textArray.push(text_1);
|
|
44
|
+
}
|
|
42
45
|
break;
|
|
43
46
|
case 'Divider':
|
|
47
|
+
textArray.push(block.tagName == 'hr' ? TextForHR : '');
|
|
48
|
+
break;
|
|
44
49
|
case 'Entity':
|
|
45
50
|
textArray.push('');
|
|
46
51
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;IAA1B,0BAAA,EAAA,kBAA0B;IAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AATD,gDASC;AAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;IAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,WAAW;gBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;gBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;oBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;wBACzB,KAAK,IAAI;4BACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;4BACrB,MAAI,GAAG,EAAE,CAAC;4BACV,MAAM;wBAEV,KAAK,QAAQ;4BACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,SAAS;4BACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,MAAM;4BACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;4BACrB,MAAM;wBAEV,KAAK,OAAO;4BACR,MAAI,IAAI,GAAG,CAAC;4BACZ,MAAM;qBACb;gBACL,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":";;;AAEA,IAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;IAA1B,0BAAA,EAAA,kBAA0B;IAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AATD,gDASC;AAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;IAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,WAAW;gBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;gBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;oBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;wBACzB,KAAK,IAAI;4BACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;4BACrB,MAAI,GAAG,EAAE,CAAC;4BACV,MAAM;wBAEV,KAAK,QAAQ;4BACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,SAAS;4BACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,MAAM;4BACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;4BACrB,MAAM;wBAEV,KAAK,OAAO;4BACR,MAAI,IAAI,GAAG,CAAC;4BACZ,MAAM;qBACb;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAI,MAAI,EAAE;oBACN,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;iBACxB;gBAED,MAAM;YAEV,KAAK,SAAS;gBACV,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACvD,MAAM;YACV,KAAK,QAAQ;gBACT,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,MAAM;YAEV,KAAK,OAAO;gBACR,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;oBAC7C,CAAC,CAAC;gBAFF,CAEE,CACL,CAAC;gBACF,MAAM;YAEV,KAAK,YAAY;gBACb,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAC1C,MAAM;SACb;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { ContentModelBlockGroup, ContentModelDocument } from 'roosterjs-content-model-types';\n\nconst TextForHR = '________________________________________';\n\n/**\n * Convert Content Model to plain text\n * @param model The source Content Model\n * @param [separator='\\r\\n'] The separator string used for connect lines\n */\nexport function contentModelToText(\n model: ContentModelDocument,\n separator: string = '\\r\\n'\n): string {\n const textArray: string[] = [];\n\n contentModelToTextArray(model, textArray);\n\n return textArray.join(separator);\n}\n\nfunction contentModelToTextArray(group: ContentModelBlockGroup, textArray: string[]) {\n group.blocks.forEach(block => {\n switch (block.blockType) {\n case 'Paragraph':\n let text = '';\n\n block.segments.forEach(segment => {\n switch (segment.segmentType) {\n case 'Br':\n textArray.push(text);\n text = '';\n break;\n\n case 'Entity':\n text += segment.wrapper.textContent || '';\n break;\n\n case 'General':\n text += segment.element.textContent || '';\n break;\n\n case 'Text':\n text += segment.text;\n break;\n\n case 'Image':\n text += ' ';\n break;\n }\n });\n\n if (text) {\n textArray.push(text);\n }\n\n break;\n\n case 'Divider':\n textArray.push(block.tagName == 'hr' ? TextForHR : '');\n break;\n case 'Entity':\n textArray.push('');\n break;\n\n case 'Table':\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n contentModelToTextArray(cell, textArray);\n })\n );\n break;\n\n case 'BlockGroup':\n contentModelToTextArray(block, textArray);\n break;\n }\n });\n}\n"]}
|
|
@@ -9,6 +9,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
9
9
|
exports.defaultContentModelFormatMap = {
|
|
10
10
|
a: {
|
|
11
11
|
underline: true,
|
|
12
|
+
textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one
|
|
12
13
|
},
|
|
13
14
|
blockquote: {
|
|
14
15
|
marginTop: '1em',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACU,QAAA,4BAA4B,GAA6B;QAClE,CAAC,EAAE;YACC,SAAS,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACU,QAAA,4BAA4B,GAA6B;QAClE,CAAC,EAAE;YACC,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,SAAS,EAAE,sLAAsL;SAC/M;QACD,UAAU,EAAE;YACR,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,MAAM;SACtB;QACD,IAAI,EAAE;YACF,UAAU,EAAE,WAAW;SAC1B;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;SAClB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,OAAO;SACpB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK,EAAE,wFAAwF;SAC5G;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,CAAC,EAAE;YACC,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;QACD,GAAG,EAAE;YACD,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;KACJ,CAAC","sourcesContent":["import type { DefaultImplicitFormatMap } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * A map from tag name to its default implicit formats\n */\nexport const defaultContentModelFormatMap: DefaultImplicitFormatMap = {\n a: {\n underline: true,\n textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one\n },\n blockquote: {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n code: {\n fontFamily: 'monospace',\n },\n h1: {\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n fontWeight: 'bold',\n fontSize: '1em', // Set this default value here to overwrite existing font size when change heading level\n },\n h5: {\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n p: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n};\n"]}
|
|
@@ -2,6 +2,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.contentModelToText = void 0;
|
|
5
|
+
var TextForHR = '________________________________________';
|
|
5
6
|
/**
|
|
6
7
|
* Convert Content Model to plain text
|
|
7
8
|
* @param model The source Content Model
|
|
@@ -39,9 +40,13 @@ define(["require", "exports"], function (require, exports) {
|
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
+
if (text_1) {
|
|
44
|
+
textArray.push(text_1);
|
|
45
|
+
}
|
|
43
46
|
break;
|
|
44
47
|
case 'Divider':
|
|
48
|
+
textArray.push(block.tagName == 'hr' ? TextForHR : '');
|
|
49
|
+
break;
|
|
45
50
|
case 'Entity':
|
|
46
51
|
textArray.push('');
|
|
47
52
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":";;;;IAEA;;;;OAIG;IACH,SAAgB,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;QAA1B,0BAAA,EAAA,kBAA0B;QAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IATD,gDASC;IAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;QAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;YACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,WAAW;oBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;oBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;wBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;4BACzB,KAAK,IAAI;gCACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;gCACrB,MAAI,GAAG,EAAE,CAAC;gCACV,MAAM;4BAEV,KAAK,QAAQ;gCACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;gCAC1C,MAAM;4BAEV,KAAK,SAAS;gCACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;gCAC1C,MAAM;4BAEV,KAAK,MAAM;gCACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;gCACrB,MAAM;4BAEV,KAAK,OAAO;gCACR,MAAI,IAAI,GAAG,CAAC;gCACZ,MAAM;yBACb;oBACL,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":";;;;IAEA,IAAM,SAAS,GAAG,0CAA0C,CAAC;IAE7D;;;;OAIG;IACH,SAAgB,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;QAA1B,0BAAA,EAAA,kBAA0B;QAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IATD,gDASC;IAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;QAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;YACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,WAAW;oBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;oBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;wBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;4BACzB,KAAK,IAAI;gCACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;gCACrB,MAAI,GAAG,EAAE,CAAC;gCACV,MAAM;4BAEV,KAAK,QAAQ;gCACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;gCAC1C,MAAM;4BAEV,KAAK,SAAS;gCACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;gCAC1C,MAAM;4BAEV,KAAK,MAAM;gCACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;gCACrB,MAAM;4BAEV,KAAK,OAAO;gCACR,MAAI,IAAI,GAAG,CAAC;gCACZ,MAAM;yBACb;oBACL,CAAC,CAAC,CAAC;oBAEH,IAAI,MAAI,EAAE;wBACN,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;qBACxB;oBAED,MAAM;gBAEV,KAAK,SAAS;oBACV,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACvD,MAAM;gBACV,KAAK,QAAQ;oBACT,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACnB,MAAM;gBAEV,KAAK,OAAO;oBACR,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;wBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;4BAClB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;wBAC7C,CAAC,CAAC;oBAFF,CAEE,CACL,CAAC;oBACF,MAAM;gBAEV,KAAK,YAAY;oBACb,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;oBAC1C,MAAM;aACb;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import type { ContentModelBlockGroup, ContentModelDocument } from 'roosterjs-content-model-types';\n\nconst TextForHR = '________________________________________';\n\n/**\n * Convert Content Model to plain text\n * @param model The source Content Model\n * @param [separator='\\r\\n'] The separator string used for connect lines\n */\nexport function contentModelToText(\n model: ContentModelDocument,\n separator: string = '\\r\\n'\n): string {\n const textArray: string[] = [];\n\n contentModelToTextArray(model, textArray);\n\n return textArray.join(separator);\n}\n\nfunction contentModelToTextArray(group: ContentModelBlockGroup, textArray: string[]) {\n group.blocks.forEach(block => {\n switch (block.blockType) {\n case 'Paragraph':\n let text = '';\n\n block.segments.forEach(segment => {\n switch (segment.segmentType) {\n case 'Br':\n textArray.push(text);\n text = '';\n break;\n\n case 'Entity':\n text += segment.wrapper.textContent || '';\n break;\n\n case 'General':\n text += segment.element.textContent || '';\n break;\n\n case 'Text':\n text += segment.text;\n break;\n\n case 'Image':\n text += ' ';\n break;\n }\n });\n\n if (text) {\n textArray.push(text);\n }\n\n break;\n\n case 'Divider':\n textArray.push(block.tagName == 'hr' ? TextForHR : '');\n break;\n case 'Entity':\n textArray.push('');\n break;\n\n case 'Table':\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n contentModelToTextArray(cell, textArray);\n })\n );\n break;\n\n case 'BlockGroup':\n contentModelToTextArray(block, textArray);\n break;\n }\n });\n}\n"]}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export var defaultContentModelFormatMap = {
|
|
6
6
|
a: {
|
|
7
7
|
underline: true,
|
|
8
|
+
textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one
|
|
8
9
|
},
|
|
9
10
|
blockquote: {
|
|
10
11
|
marginTop: '1em',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,IAAM,4BAA4B,GAA6B;IAClE,CAAC,EAAE;QACC,SAAS,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"defaultContentModelFormatMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/config/defaultContentModelFormatMap.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,IAAM,4BAA4B,GAA6B;IAClE,CAAC,EAAE;QACC,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,SAAS,EAAE,sLAAsL;KAC/M;IACD,UAAU,EAAE;QACR,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;KACtB;IACD,IAAI,EAAE;QACF,UAAU,EAAE,WAAW;KAC1B;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,KAAK;KAClB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,OAAO;KACpB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,KAAK,EAAE,wFAAwF;KAC5G;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,EAAE,EAAE;QACA,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,CAAC,EAAE;QACC,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;KACtB;IACD,GAAG,EAAE;QACD,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;KACtB;CACJ,CAAC","sourcesContent":["import type { DefaultImplicitFormatMap } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * A map from tag name to its default implicit formats\n */\nexport const defaultContentModelFormatMap: DefaultImplicitFormatMap = {\n a: {\n underline: true,\n textColor: undefined, // Set to undefined to force override color from parent element so we can write correct link color if any, because browser will assign a default color for link if it doesn't have one\n },\n blockquote: {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n code: {\n fontFamily: 'monospace',\n },\n h1: {\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n fontWeight: 'bold',\n fontSize: '1em', // Set this default value here to overwrite existing font size when change heading level\n },\n h5: {\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n p: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var TextForHR = '________________________________________';
|
|
1
2
|
/**
|
|
2
3
|
* Convert Content Model to plain text
|
|
3
4
|
* @param model The source Content Model
|
|
@@ -34,9 +35,13 @@ function contentModelToTextArray(group, textArray) {
|
|
|
34
35
|
break;
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
|
-
|
|
38
|
+
if (text_1) {
|
|
39
|
+
textArray.push(text_1);
|
|
40
|
+
}
|
|
38
41
|
break;
|
|
39
42
|
case 'Divider':
|
|
43
|
+
textArray.push(block.tagName == 'hr' ? TextForHR : '');
|
|
44
|
+
break;
|
|
40
45
|
case 'Entity':
|
|
41
46
|
textArray.push('');
|
|
42
47
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;IAA1B,0BAAA,EAAA,kBAA0B;IAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;IAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,WAAW;gBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;gBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;oBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;wBACzB,KAAK,IAAI;4BACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;4BACrB,MAAI,GAAG,EAAE,CAAC;4BACV,MAAM;wBAEV,KAAK,QAAQ;4BACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,SAAS;4BACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,MAAM;4BACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;4BACrB,MAAM;wBAEV,KAAK,OAAO;4BACR,MAAI,IAAI,GAAG,CAAC;4BACZ,MAAM;qBACb;gBACL,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"contentModelToText.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/modelToText/contentModelToText.ts"],"names":[],"mappings":"AAEA,IAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAA2B,EAC3B,SAA0B;IAA1B,0BAAA,EAAA,kBAA0B;IAE1B,IAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,uBAAuB,CAAC,KAA6B,EAAE,SAAmB;IAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,WAAW;gBACZ,IAAI,MAAI,GAAG,EAAE,CAAC;gBAEd,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;oBAC1B,QAAQ,OAAO,CAAC,WAAW,EAAE;wBACzB,KAAK,IAAI;4BACL,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;4BACrB,MAAI,GAAG,EAAE,CAAC;4BACV,MAAM;wBAEV,KAAK,QAAQ;4BACT,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,SAAS;4BACV,MAAI,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;4BAC1C,MAAM;wBAEV,KAAK,MAAM;4BACP,MAAI,IAAI,OAAO,CAAC,IAAI,CAAC;4BACrB,MAAM;wBAEV,KAAK,OAAO;4BACR,MAAI,IAAI,GAAG,CAAC;4BACZ,MAAM;qBACb;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAI,MAAI,EAAE;oBACN,SAAS,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;iBACxB;gBAED,MAAM;YAEV,KAAK,SAAS;gBACV,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACvD,MAAM;YACV,KAAK,QAAQ;gBACT,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,MAAM;YAEV,KAAK,OAAO;gBACR,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;oBAC7C,CAAC,CAAC;gBAFF,CAEE,CACL,CAAC;gBACF,MAAM;YAEV,KAAK,YAAY;gBACb,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAC1C,MAAM;SACb;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { ContentModelBlockGroup, ContentModelDocument } from 'roosterjs-content-model-types';\n\nconst TextForHR = '________________________________________';\n\n/**\n * Convert Content Model to plain text\n * @param model The source Content Model\n * @param [separator='\\r\\n'] The separator string used for connect lines\n */\nexport function contentModelToText(\n model: ContentModelDocument,\n separator: string = '\\r\\n'\n): string {\n const textArray: string[] = [];\n\n contentModelToTextArray(model, textArray);\n\n return textArray.join(separator);\n}\n\nfunction contentModelToTextArray(group: ContentModelBlockGroup, textArray: string[]) {\n group.blocks.forEach(block => {\n switch (block.blockType) {\n case 'Paragraph':\n let text = '';\n\n block.segments.forEach(segment => {\n switch (segment.segmentType) {\n case 'Br':\n textArray.push(text);\n text = '';\n break;\n\n case 'Entity':\n text += segment.wrapper.textContent || '';\n break;\n\n case 'General':\n text += segment.element.textContent || '';\n break;\n\n case 'Text':\n text += segment.text;\n break;\n\n case 'Image':\n text += ' ';\n break;\n }\n });\n\n if (text) {\n textArray.push(text);\n }\n\n break;\n\n case 'Divider':\n textArray.push(block.tagName == 'hr' ? TextForHR : '');\n break;\n case 'Entity':\n textArray.push('');\n break;\n\n case 'Table':\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n contentModelToTextArray(cell, textArray);\n })\n );\n break;\n\n case 'BlockGroup':\n contentModelToTextArray(block, textArray);\n break;\n }\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"description": "Content Model for roosterjs",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
|
-
"roosterjs-content-model-types": "^9.
|
|
6
|
+
"roosterjs-content-model-types": "^9.1.0"
|
|
7
7
|
},
|
|
8
|
-
"version": "9.
|
|
8
|
+
"version": "9.1.0",
|
|
9
9
|
"main": "./lib/index.js",
|
|
10
10
|
"typings": "./lib/index.d.ts",
|
|
11
11
|
"module": "./lib-mjs/index.js",
|