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

Commit

Permalink
Merge pull request #92 from ckeditor/t/ckeditor5-enter/40
Browse files Browse the repository at this point in the history
Other: Mark basic-styles attributes with 'copyOnEnter' property.
  • Loading branch information
jodator authored Jul 16, 2019
2 parents ad25260 + efa1313 commit 0afbc20
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/bold/boldediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default class BoldEditing extends Plugin {
const editor = this.editor;
// Allow bold attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: BOLD } );
editor.model.schema.setAttributeProperties( BOLD, { isFormatting: true } );
editor.model.schema.setAttributeProperties( BOLD, {
isFormatting: true,
copyOnEnter: true
} );

// Build converter from model to view for data and editing pipelines.

Expand Down
5 changes: 4 additions & 1 deletion src/code/codeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default class CodeEditing extends Plugin {

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

editor.conversion.attributeToElement( {
model: CODE,
Expand Down
5 changes: 4 additions & 1 deletion src/italic/italicediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default class ItalicEditing extends Plugin {

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

editor.conversion.attributeToElement( {
model: ITALIC,
Expand Down
5 changes: 4 additions & 1 deletion src/strikethrough/strikethroughediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default class StrikethroughEditing extends Plugin {

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

editor.conversion.attributeToElement( {
model: STRIKETHROUGH,
Expand Down
5 changes: 4 additions & 1 deletion src/subscript/subscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default class SubscriptEditing extends Plugin {
const editor = this.editor;
// Allow sub attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: SUBSCRIPT } );
editor.model.schema.setAttributeProperties( SUBSCRIPT, { isFormatting: true } );
editor.model.schema.setAttributeProperties( SUBSCRIPT, {
isFormatting: true,
copyOnEnter: true
} );

// Build converter from model to view for data and editing pipelines.

Expand Down
5 changes: 4 additions & 1 deletion src/superscript/superscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default class SuperscriptEditing extends Plugin {
const editor = this.editor;
// Allow super attribute on text nodes.
editor.model.schema.extend( '$text', { allowAttributes: SUPERSCRIPT } );
editor.model.schema.setAttributeProperties( SUPERSCRIPT, { isFormatting: true } );
editor.model.schema.setAttributeProperties( SUPERSCRIPT, {
isFormatting: true,
copyOnEnter: true
} );

// Build converter from model to view for data and editing pipelines.

Expand Down
5 changes: 4 additions & 1 deletion src/underline/underlineediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default class UnderlineEditing extends Plugin {

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

editor.conversion.attributeToElement( {
model: UNDERLINE,
Expand Down
8 changes: 7 additions & 1 deletion tests/bold/boldediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ describe( 'BoldEditing', () => {
} );

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

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

it( 'should set editor keystroke', () => {
const spy = sinon.spy( editor, 'execute' );
const keyEventData = {
Expand Down
8 changes: 7 additions & 1 deletion tests/code/codeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'CodeEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register code command', () => {
const command = editor.commands.get( 'code' );
Expand Down
8 changes: 7 additions & 1 deletion tests/italic/italicediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'ItalicEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register italic command', () => {
const command = editor.commands.get( 'italic' );
Expand Down
8 changes: 7 additions & 1 deletion tests/strikethrough/strikethroughediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'StrikethroughEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register strikethrough command', () => {
const command = editor.commands.get( 'strikethrough' );
Expand Down
8 changes: 7 additions & 1 deletion tests/subscript/subscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'SubEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register subscript command', () => {
const command = editor.commands.get( 'subscript' );
Expand Down
8 changes: 7 additions & 1 deletion tests/superscript/superscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'SuperEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register superscript command', () => {
const command = editor.commands.get( 'superscript' );
Expand Down
8 changes: 7 additions & 1 deletion tests/underline/underlineediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ describe( 'UnderlineEditing', () => {
} );

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

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

describe( 'command', () => {
it( 'should register underline command', () => {
const command = editor.commands.get( 'underline' );
Expand Down

0 comments on commit 0afbc20

Please sign in to comment.