Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Mark fonts' attributes with 'copyOnEnter' property.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Jul 11, 2019
1 parent 77cc2f8 commit e1f5df2
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/fontbackgroundcolor/fontbackgroundcolorediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export default class FontBackgroundColorEditing extends Plugin {
// Allow the font backgroundColor attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: FONT_BACKGROUND_COLOR } );

editor.model.schema.setAttributeProperties( FONT_BACKGROUND_COLOR, { isFormatting: true } );
editor.model.schema.setAttributeProperties( FONT_BACKGROUND_COLOR, {
isFormatting: true,
copyOnEnter: true
} );
}
}
5 changes: 4 additions & 1 deletion src/fontcolor/fontcolorediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export default class FontColorEditing extends Plugin {
// Allow the font color attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: FONT_COLOR } );

editor.model.schema.setAttributeProperties( FONT_COLOR, { isFormatting: true } );
editor.model.schema.setAttributeProperties( FONT_COLOR, {
isFormatting: true,
copyOnEnter: true
} );
}
}
5 changes: 4 additions & 1 deletion src/fontfamily/fontfamilyediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export default class FontFamilyEditing extends Plugin {

// Allow fontFamily attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: FONT_FAMILY } );
editor.model.schema.setAttributeProperties( FONT_FAMILY, { isFormatting: true } );
editor.model.schema.setAttributeProperties( FONT_FAMILY, {
isFormatting: true,
copyOnEnter: true
} );

// Get configured font family options without "default" option.
const options = normalizeOptions( editor.config.get( 'fontFamily.options' ) ).filter( item => item.model );
Expand Down
5 changes: 4 additions & 1 deletion src/fontsize/fontsizeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export default class FontSizeEditing extends Plugin {

// Allow fontSize attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: FONT_SIZE } );
editor.model.schema.setAttributeProperties( FONT_SIZE, { isFormatting: true } );
editor.model.schema.setAttributeProperties( FONT_SIZE, {
isFormatting: true,
copyOnEnter: true
} );
}
}
8 changes: 7 additions & 1 deletion tests/fontbackgroundcolor/fontbackgroundcoloreditng.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ describe( 'FontBackgroundColorEditing', () => {
} );

it( 'has the attribute marked with the isFormatting property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontBackgroundColor' ) ).to.deep.equal( {
expect( editor.model.schema.getAttributeProperties( 'fontBackgroundColor' ) ).to.include( {
isFormatting: true
} );
} );

it( 'its attribute is marked with a copOnEnter property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontBackgroundColor' ) ).to.include( {
copyOnEnter: true
} );
} );

describe( 'config', () => {
describe( 'default value', () => {
it( 'should be set', () => {
Expand Down
8 changes: 7 additions & 1 deletion tests/fontcolor/fontcolorediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ describe( 'FontColorEditing', () => {
} );

it( 'has the attribute marked with the isFormatting property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontColor' ) ).to.deep.equal( {
expect( editor.model.schema.getAttributeProperties( 'fontColor' ) ).to.include( {
isFormatting: true
} );
} );

it( 'its attribute is marked with a copOnEnter property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontColor' ) ).to.include( {
copyOnEnter: true
} );
} );

describe( 'config', () => {
describe( 'default value', () => {
it( 'should be set', () => {
Expand Down
8 changes: 7 additions & 1 deletion tests/fontfamily/fontfamilyediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ describe( 'FontFamilyEditing', () => {
} );

it( 'should be marked with a formatting property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontFamily' ) ).to.deep.equal( {
expect( editor.model.schema.getAttributeProperties( 'fontFamily' ) ).to.include( {
isFormatting: true
} );
} );

it( 'its attribute is marked with a copOnEnter property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontFamily' ) ).to.include( {
copyOnEnter: true
} );
} );

describe( 'config', () => {
describe( 'default value', () => {
it( 'should be set', () => {
Expand Down
8 changes: 7 additions & 1 deletion tests/fontsize/fontsizeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ describe( 'FontSizeEditing', () => {
} );

it( 'should be marked with a formatting property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontSize' ) ).to.deep.equal( {
expect( editor.model.schema.getAttributeProperties( 'fontSize' ) ).to.include( {
isFormatting: true
} );
} );

it( 'its attribute is marked with a copOnEnter property', () => {
expect( editor.model.schema.getAttributeProperties( 'fontSize' ) ).to.include( {
copyOnEnter: true
} );
} );

describe( 'config', () => {
describe( 'default value', () => {
it( 'should be set', () => {
Expand Down

0 comments on commit e1f5df2

Please sign in to comment.