Skip to content

Commit

Permalink
Add expected output of font tests and add it to the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Oct 17, 2019
1 parent 82601ba commit 1956578
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
33 changes: 21 additions & 12 deletions plugins/pastefromlibreoffice/filter/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
[ /^strike$/i, 's' ]
],

attributes: {
'size': function( styles, element ) {
if ( element.name === 'font' ) {
return false;
}
}
},

elements: {
'!doctype': function( el ) {
el.replaceWithChildren();
Expand Down Expand Up @@ -95,10 +87,7 @@
}
}

if ( !CKEDITOR.tools.object.entries( el.attributes ).length ) {
el.replaceWithChildren();
}

replaceEmptyElementWithChildren( el );
},

'p': function( el ) {
Expand Down Expand Up @@ -131,12 +120,32 @@
if ( el.parent.name === 'a' && el.attributes.color === '#000080' ) {
el.replaceWithChildren();
}

if ( el.attributes.size ) {
delete el.attributes.size;
}

var styles = CKEDITOR.tools.parseCssText( el.attributes.style );

if ( styles[ 'font-size' ] ) {
el.name = 'span';
el.attributes.style = CKEDITOR.tools.writeCssText( styles );
return el;
}

replaceEmptyElementWithChildren( el );
}
}
};
}
};

function replaceEmptyElementWithChildren( element ) {
if ( !CKEDITOR.tools.object.entries( element.attributes ).length ) {
element.replaceWithChildren();
}
}

CKEDITOR.pasteFilters.pflibreoffice = pastetools.createFilter( {
rules: [
commonFilter.rules,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>Different font sizes: <span style="font-size:6pt">6</span>, <span style="font-size:8pt">8</span>, <span style="font-size:10pt">10</span>, 12, <span style="font-size:16pt">16</span>, <span style="font-size:24pt">24</span>, <span style="font-size:32pt">32</span>, <span style="font-size:48pt">48</span>, <span style="font-size:80pt">80</span></p>

<p>Different font face: <span style="font-family:Courier New,monospace">Courier New</span>, <span style="font-family:Verdana,sans-serif">Verdana</span>, <span style="font-family:Times New Roman,serif">Times New Roman</span>, <span style="font-family:Arial,sans-serif">Arial</span>.</p>
3 changes: 2 additions & 1 deletion tests/plugins/pastefromlibreoffice/generated/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
Simple_text: true,
Link: true,
Basic_styles: true,
Font_color: true
Font_color: true,
Font: true
},
ignoreAll: ( CKEDITOR.env.ie && CKEDITOR.env.version <= 11 ) || bender.tools.env.mobile
} ) );
Expand Down

0 comments on commit 1956578

Please sign in to comment.