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

Commit

Permalink
Docs: Fixed the fancy-heading sample and added integration test for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Mar 11, 2018
1 parent 511a9d8 commit bbf7d60
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
7 changes: 4 additions & 3 deletions docs/_snippets/features/custom-heading-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ ClassicEditor
model: 'headingFancy',
view: {
name: 'h2',
class: 'fancy',
priority: 'high'
class: 'fancy'
},
title: 'Heading 2 (fancy)', class: 'ck-heading_heading2_fancy'
title: 'Heading 2 (fancy)',
class: 'ck-heading_heading2_fancy',
priority: 'high'
}
]
},
Expand Down
10 changes: 5 additions & 5 deletions docs/features/headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ ClassicEditor
model: 'headingFancy',
view: {
name: 'h2',
class: 'fancy',

// It needs to be converted before the standard 'heading2'.
priority: 'high'
class: 'fancy'
},
title: 'Heading 2 (fancy)',
class: 'ck-heading_heading2_fancy'
class: 'ck-heading_heading2_fancy',

// It needs to be converted before the standard 'heading2'.
priority: 'high'
}
]
}
Expand Down
39 changes: 39 additions & 0 deletions tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,43 @@ describe( 'Heading integration', () => {
expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
} );
} );

// Remember to sync docs/_snippets/features/custom-heading-elements.js and docs/features/headings.md
// with this test when changing it.
describe( 'fancy heading sample in the docs', () => {
it( 'upcasts the <h2> and <h2 class=fancy> elements when configured to do so', () => {
const element = document.createElement( 'div' );
document.body.appendChild( element );

return ClassicTestEditor
.create( element, {
plugins: [ Paragraph, Heading ],
heading: {
options: [
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
{
model: 'headingFancy',
view: {
name: 'h2',
class: 'fancy'
},
title: 'Heading 2 (fancy)',
class: 'ck-heading_heading2_fancy',
priority: 'high'
}
]
}
} )
.then( editor => {
editor.setData( '<h2>Heading 2</h2><h2 class="fancy">Fancy Heading 2</h2>' );

expect( editor.getData() )
.to.equal( '<h2>Heading 2</h2><h2 class="fancy">Fancy Heading 2</h2>' );

editor.destroy();
element.remove();
} );
} );
} );
} );

0 comments on commit bbf7d60

Please sign in to comment.