|
@@ -39,7 +39,13 @@ describe( 'FontFamilyEditing', () => {
|
|
|
it( 'should be set', () => {
|
|
it( 'should be set', () => {
|
|
|
expect( editor.config.get( 'fontFamily.items' ) ).to.deep.equal( [
|
|
expect( editor.config.get( 'fontFamily.items' ) ).to.deep.equal( [
|
|
|
'Arial, Helvetica, sans-serif',
|
|
'Arial, Helvetica, sans-serif',
|
|
|
- 'Courier New, Courier, monospace'
|
|
|
|
|
|
|
+ 'Courier New, Courier, monospace',
|
|
|
|
|
+ 'Georgia, serif',
|
|
|
|
|
+ 'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
|
|
|
|
+ 'Tahoma, Geneva, sans-serif',
|
|
|
|
|
+ 'Times New Roman, Times, serif',
|
|
|
|
|
+ 'Trebuchet MS, Helvetica, sans-serif',
|
|
|
|
|
+ 'Verdana, Geneva, sans-serif'
|
|
|
] );
|
|
] );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
@@ -92,7 +98,8 @@ describe( 'FontFamilyEditing', () => {
|
|
|
label: 'Comic Sans',
|
|
label: 'Comic Sans',
|
|
|
model: 'comic',
|
|
model: 'comic',
|
|
|
view: {
|
|
view: {
|
|
|
- name: 'span', styles: {
|
|
|
|
|
|
|
+ name: 'span',
|
|
|
|
|
+ styles: {
|
|
|
'font-family': 'Comic Sans'
|
|
'font-family': 'Comic Sans'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -110,7 +117,7 @@ describe( 'FontFamilyEditing', () => {
|
|
|
items: [
|
|
items: [
|
|
|
'Arial',
|
|
'Arial',
|
|
|
'"Comic Sans MS", sans-serif',
|
|
'"Comic Sans MS", sans-serif',
|
|
|
- 'Lucida Console, Courier New, Courier, monospace'
|
|
|
|
|
|
|
+ 'Lucida Console, \'Courier New\', Courier, monospace'
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
} )
|
|
} )
|
|
@@ -128,7 +135,15 @@ describe( 'FontFamilyEditing', () => {
|
|
|
styles: {
|
|
styles: {
|
|
|
'font-family': 'Arial'
|
|
'font-family': 'Arial'
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ acceptsAlso: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'span',
|
|
|
|
|
+ styles: {
|
|
|
|
|
+ 'font-family': new RegExp( '("|\'|&qout;|\\W){0,2}Arial("|\'|&qout;|\\W){0,2}' )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: 'Comic Sans MS',
|
|
label: 'Comic Sans MS',
|
|
@@ -136,9 +151,20 @@ describe( 'FontFamilyEditing', () => {
|
|
|
view: {
|
|
view: {
|
|
|
name: 'span',
|
|
name: 'span',
|
|
|
styles: {
|
|
styles: {
|
|
|
- 'font-family': '"Comic Sans MS", sans-serif'
|
|
|
|
|
|
|
+ 'font-family': '\'Comic Sans MS\', sans-serif'
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ acceptsAlso: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'span',
|
|
|
|
|
+ styles: {
|
|
|
|
|
+ 'font-family': new RegExp(
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}Comic Sans MS("|\'|&qout;|\\W){0,2},' +
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}sans-serif("|\'|&qout;|\\W){0,2}'
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: 'Lucida Console',
|
|
label: 'Lucida Console',
|
|
@@ -146,9 +172,22 @@ describe( 'FontFamilyEditing', () => {
|
|
|
view: {
|
|
view: {
|
|
|
name: 'span',
|
|
name: 'span',
|
|
|
styles: {
|
|
styles: {
|
|
|
- 'font-family': '"Lucida Console", "Courier New", Courier, monospace'
|
|
|
|
|
|
|
+ 'font-family': '\'Lucida Console\', \'Courier New\', Courier, monospace'
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ acceptsAlso: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'span',
|
|
|
|
|
+ styles: {
|
|
|
|
|
+ 'font-family': new RegExp(
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}Lucida Console("|\'|&qout;|\\W){0,2},' +
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}Courier New("|\'|&qout;|\\W){0,2},' +
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}Courier("|\'|&qout;|\\W){0,2},' +
|
|
|
|
|
+ '("|\'|&qout;|\\W){0,2}monospace("|\'|&qout;|\\W){0,2}'
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
}
|
|
}
|
|
|
] );
|
|
] );
|
|
|
} );
|
|
} );
|
|
@@ -164,6 +203,7 @@ describe( 'FontFamilyEditing', () => {
|
|
|
fontFamily: {
|
|
fontFamily: {
|
|
|
items: [
|
|
items: [
|
|
|
'Arial',
|
|
'Arial',
|
|
|
|
|
+ 'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
|
|
{
|
|
{
|
|
|
label: 'My font',
|
|
label: 'My font',
|
|
|
model: 'my',
|
|
model: 'my',
|
|
@@ -188,12 +228,19 @@ describe( 'FontFamilyEditing', () => {
|
|
|
expect( editor.getData() ).to.equal( '<p>foo</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foo</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should convert fontFamily attribute to configured preset', () => {
|
|
|
|
|
|
|
+ it( 'should convert fontFamily attribute to configured simple preset', () => {
|
|
|
setModelData( doc, '<paragraph>f<$text fontFamily="Arial">o</$text>o</paragraph>' );
|
|
setModelData( doc, '<paragraph>f<$text fontFamily="Arial">o</$text>o</paragraph>' );
|
|
|
|
|
|
|
|
expect( editor.getData() ).to.equal( '<p>f<span style="font-family:Arial;">o</span>o</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>f<span style="font-family:Arial;">o</span>o</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should convert fontFamily attribute to configured complex preset', () => {
|
|
|
|
|
+ setModelData( doc, '<paragraph>f<$text fontFamily="Lucida Sans Unicode">o</$text>o</paragraph>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( editor.getData() )
|
|
|
|
|
+ .to.equal( '<p>f<span style="font-family:\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif;">o</span>o</p>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should convert fontFamily attribute from user defined settings', () => {
|
|
it( 'should convert fontFamily attribute from user defined settings', () => {
|
|
|
setModelData( doc, '<paragraph>f<$text fontFamily="my">o</$text>o</paragraph>' );
|
|
setModelData( doc, '<paragraph>f<$text fontFamily="my">o</$text>o</paragraph>' );
|
|
|
|
|
|
|
@@ -208,6 +255,7 @@ describe( 'FontFamilyEditing', () => {
|
|
|
plugins: [ FontFamilyEditing, Paragraph ],
|
|
plugins: [ FontFamilyEditing, Paragraph ],
|
|
|
fontFamily: {
|
|
fontFamily: {
|
|
|
items: [
|
|
items: [
|
|
|
|
|
+ 'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
|
|
{
|
|
{
|
|
|
label: 'My other setting',
|
|
label: 'My other setting',
|
|
|
model: 'my-other',
|
|
model: 'my-other',
|
|
@@ -290,5 +338,25 @@ describe( 'FontFamilyEditing', () => {
|
|
|
'<p>b<span class="text-complex">a</span>z</p>'
|
|
'<p>b<span class="text-complex">a</span>z</p>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert from various inline style definitions', () => {
|
|
|
|
|
+ editor.setData(
|
|
|
|
|
+ '<p>f<span style="font-family:\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif;">o</span>o</p>' +
|
|
|
|
|
+ '<p>f<span style="font-family:Lucida Sans Unicode, Lucida Grande, sans-serif;">o</span>o</p>' +
|
|
|
|
|
+ '<p>f<span style="font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;">o</span>o</p>'
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ expect( getModelData( doc ) ).to.equal(
|
|
|
|
|
+ '<paragraph>[]f<$text fontFamily="Lucida Sans Unicode">o</$text>o</paragraph>' +
|
|
|
|
|
+ '<paragraph>f<$text fontFamily="Lucida Sans Unicode">o</$text>o</paragraph>' +
|
|
|
|
|
+ '<paragraph>f<$text fontFamily="Lucida Sans Unicode">o</$text>o</paragraph>'
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ expect( editor.getData() ).to.equal(
|
|
|
|
|
+ '<p>f<span style="font-family:\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif;">o</span>o</p>' +
|
|
|
|
|
+ '<p>f<span style="font-family:\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif;">o</span>o</p>' +
|
|
|
|
|
+ '<p>f<span style="font-family:\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif;">o</span>o</p>'
|
|
|
|
|
+ );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|