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

Commit

Permalink
Mark basic-styles attributes with 'copyOnEnter' property.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed May 28, 2019
1 parent 2f7c0e6 commit d7485ed
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 d7485ed

Please sign in to comment.