diff --git a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/utils/paste.ts b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/utils/paste.ts index 7d38b72cf63..2d4c257a4d4 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/utils/paste.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/utils/paste.ts @@ -67,9 +67,15 @@ export default function paste( ...event.domToModelOption, disableCacheElement: true, additionalFormatParsers: { - ...event.domToModelOption, - block: [...(applyCurrentFormat ? [blockElementParser] : [])], - listLevel: [...(applyCurrentFormat ? [blockElementParser] : [])], + ...event.domToModelOption.additionalFormatParsers, + block: [ + ...(event.domToModelOption.additionalFormatParsers?.block || []), + ...(applyCurrentFormat ? [blockElementParser] : []), + ], + listLevel: [ + ...(event.domToModelOption.additionalFormatParsers?.listLevel || []), + ...(applyCurrentFormat ? [blockElementParser] : []), + ], }, }); diff --git a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts index 69ef436b885..8cbd3a33ff3 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts @@ -96,7 +96,6 @@ describe('processPastedContentFromWordDesktopTest', () => { let source = 'TestTest'; runTest(source, 'TestTest', { blockGroupType: 'Document', - blocks: [ { blockType: 'Paragraph', @@ -944,6 +943,105 @@ describe('processPastedContentFromWordDesktopTest', () => { ); }); + it('Lists with margins', () => { + const source = + '
Test
Test
ยท \nTEST
'; + runTest(source, undefined, { + blockGroupType: 'Document', + blocks: [ + { + blockType: 'Paragraph', + segments: [ + { + segmentType: 'Text', + text: 'Test', + format: { + fontFamily: 'Calibri, sans-serif', + fontSize: '12pt', + }, + }, + ], + format: { + marginTop: '0in', + marginRight: '0in', + marginBottom: '0in', + marginLeft: '0in', + }, + segmentFormat: { + fontFamily: 'Calibri, sans-serif', + fontSize: '12pt', + }, + decorator: { tagName: 'p', format: {} }, + }, + { + blockType: 'Paragraph', + segments: [ + { + segmentType: 'Text', + text: 'Test', + format: { + fontFamily: 'Calibri, sans-serif', + fontSize: '12pt', + }, + }, + ], + format: { + marginTop: '0in', + marginRight: '0in', + marginBottom: '0in', + marginLeft: '0in', + }, + segmentFormat: { + fontFamily: 'Calibri, sans-serif', + fontSize: '12pt', + }, + decorator: { tagName: 'p', format: {} }, + }, + { + blockType: 'BlockGroup', + blockGroupType: 'ListItem', + blocks: [ + { + blockType: 'Paragraph', + segments: [ + { + segmentType: 'Text', + text: 'TEST', + format: { + fontFamily: 'Calibri, sans-serif', + fontSize: '12pt', + }, + }, + ], + format: {}, + isImplicit: true, + }, + ], + levels: [ + { + listType: 'UL', + marginTop: '0in', + marginRight: '0in', + marginBottom: undefined, + marginLeft: undefined, + }, + ], + formatHolder: { + segmentType: 'SelectionMarker', + isSelected: true, + format: {}, + }, + format: { + marginTop: '0in', + marginRight: undefined, + marginBottom: '0in', + marginLeft: undefined, + }, + }, + ], + }); + }); + /** * Test * 1. Test