From e1f5df22992e383f3a9fce9de185db582e890085 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 28 May 2019 10:12:05 +0200 Subject: [PATCH] Mark fonts' attributes with 'copyOnEnter' property. --- src/fontbackgroundcolor/fontbackgroundcolorediting.js | 5 ++++- src/fontcolor/fontcolorediting.js | 5 ++++- src/fontfamily/fontfamilyediting.js | 5 ++++- src/fontsize/fontsizeediting.js | 5 ++++- tests/fontbackgroundcolor/fontbackgroundcoloreditng.js | 8 +++++++- tests/fontcolor/fontcolorediting.js | 8 +++++++- tests/fontfamily/fontfamilyediting.js | 8 +++++++- tests/fontsize/fontsizeediting.js | 8 +++++++- 8 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/fontbackgroundcolor/fontbackgroundcolorediting.js b/src/fontbackgroundcolor/fontbackgroundcolorediting.js index 366aa1f..6ab5148 100644 --- a/src/fontbackgroundcolor/fontbackgroundcolorediting.js +++ b/src/fontbackgroundcolor/fontbackgroundcolorediting.js @@ -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 + } ); } } diff --git a/src/fontcolor/fontcolorediting.js b/src/fontcolor/fontcolorediting.js index 1f26b4d..09ca309 100644 --- a/src/fontcolor/fontcolorediting.js +++ b/src/fontcolor/fontcolorediting.js @@ -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 + } ); } } diff --git a/src/fontfamily/fontfamilyediting.js b/src/fontfamily/fontfamilyediting.js index c63c31a..63567cd 100644 --- a/src/fontfamily/fontfamilyediting.js +++ b/src/fontfamily/fontfamilyediting.js @@ -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 ); diff --git a/src/fontsize/fontsizeediting.js b/src/fontsize/fontsizeediting.js index 72a81f0..4bcfe7d 100644 --- a/src/fontsize/fontsizeediting.js +++ b/src/fontsize/fontsizeediting.js @@ -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 + } ); } } diff --git a/tests/fontbackgroundcolor/fontbackgroundcoloreditng.js b/tests/fontbackgroundcolor/fontbackgroundcoloreditng.js index 777c07e..ac4b364 100644 --- a/tests/fontbackgroundcolor/fontbackgroundcoloreditng.js +++ b/tests/fontbackgroundcolor/fontbackgroundcoloreditng.js @@ -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', () => { diff --git a/tests/fontcolor/fontcolorediting.js b/tests/fontcolor/fontcolorediting.js index 8702f87..118a0b6 100644 --- a/tests/fontcolor/fontcolorediting.js +++ b/tests/fontcolor/fontcolorediting.js @@ -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', () => { diff --git a/tests/fontfamily/fontfamilyediting.js b/tests/fontfamily/fontfamilyediting.js index b6cd279..7364783 100644 --- a/tests/fontfamily/fontfamilyediting.js +++ b/tests/fontfamily/fontfamilyediting.js @@ -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', () => { diff --git a/tests/fontsize/fontsizeediting.js b/tests/fontsize/fontsizeediting.js index 1148007..0da039e 100644 --- a/tests/fontsize/fontsizeediting.js +++ b/tests/fontsize/fontsizeediting.js @@ -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', () => {