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 #86 from ckeditor/t/ckeditor5/1664
Browse files Browse the repository at this point in the history
Feature: Marked basic style attributes as a formatting using the `AttributeProperties#isFormatting` property. Closes ckeditor/ckeditor5#1664.
  • Loading branch information
jodator authored Mar 29, 2019
2 parents bc3710e + 634e1cb commit fcfba54
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bold/boldediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ 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 } );

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

Expand Down
1 change: 1 addition & 0 deletions src/code/codeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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.conversion.attributeToElement( {
model: CODE,
Expand Down
1 change: 1 addition & 0 deletions src/italic/italicediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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.conversion.attributeToElement( {
model: ITALIC,
Expand Down
1 change: 1 addition & 0 deletions src/strikethrough/strikethroughediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ 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.conversion.attributeToElement( {
model: STRIKETHROUGH,
Expand Down
1 change: 1 addition & 0 deletions src/subscript/subscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ 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 } );

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

Expand Down
1 change: 1 addition & 0 deletions src/superscript/superscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ 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 } );

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

Expand Down
1 change: 1 addition & 0 deletions src/underline/underlineediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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.conversion.attributeToElement( {
model: UNDERLINE,
Expand Down
6 changes: 6 additions & 0 deletions tests/bold/boldediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ describe( 'BoldEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'bold' ) ).to.be.true;
} );

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

it( 'should set editor keystroke', () => {
const spy = sinon.spy( editor, 'execute' );
const keyEventData = {
Expand Down
6 changes: 6 additions & 0 deletions tests/code/codeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'CodeEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'code' ) ).to.be.true;
} );

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

describe( 'command', () => {
it( 'should register code command', () => {
const command = editor.commands.get( 'code' );
Expand Down
6 changes: 6 additions & 0 deletions tests/italic/italicediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'ItalicEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'italic' ) ).to.be.true;
} );

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

describe( 'command', () => {
it( 'should register italic command', () => {
const command = editor.commands.get( 'italic' );
Expand Down
6 changes: 6 additions & 0 deletions tests/strikethrough/strikethroughediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'StrikethroughEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'strikethrough' ) ).to.be.true;
} );

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

describe( 'command', () => {
it( 'should register strikethrough command', () => {
const command = editor.commands.get( 'strikethrough' );
Expand Down
6 changes: 6 additions & 0 deletions tests/subscript/subscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'SubEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'subscript' ) ).to.be.true;
} );

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

describe( 'command', () => {
it( 'should register subscript command', () => {
const command = editor.commands.get( 'subscript' );
Expand Down
6 changes: 6 additions & 0 deletions tests/superscript/superscriptediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'SuperEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'superscript' ) ).to.be.true;
} );

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

describe( 'command', () => {
it( 'should register superscript command', () => {
const command = editor.commands.get( 'superscript' );
Expand Down
6 changes: 6 additions & 0 deletions tests/underline/underlineediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe( 'UnderlineEditing', () => {
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'underline' ) ).to.be.true;
} );

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

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

0 comments on commit fcfba54

Please sign in to comment.