Skip to content

Commit

Permalink
Fix Parsers when pasting (#1949)
Browse files Browse the repository at this point in the history
* Remove Margins

* fix
  • Loading branch information
BryanValverdeU authored Jul 13, 2023
1 parent f77648f commit daea105
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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] : []),
],
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe('processPastedContentFromWordDesktopTest', () => {
let source = '<span>Test<span style="mso-comment-continuation:3">Test</span></span>';
runTest(source, 'TestTest', {
blockGroupType: 'Document',

blocks: [
{
blockType: 'Paragraph',
Expand Down Expand Up @@ -944,6 +943,105 @@ describe('processPastedContentFromWordDesktopTest', () => {
);
});

it('Lists with margins', () => {
const source =
'<p style="margin:0in;font-size:12pt;font-family:Calibri, sans-serif">Test</p><p style="margin:0in;font-size:12pt;font-family:Calibri, sans-serif">Test</p><p style="margin:0in 0in 0in 0.5in;font-size:12pt;font-family:Calibri, sans-serif;text-indent:-.25in;mso-list:l0 level1 lfo1"><span style="font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span>TEST</p>';
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
Expand Down

0 comments on commit daea105

Please sign in to comment.