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

Commit 17bea3d

Browse files
authored
Merge pull request #124 from ckeditor/t/121
Feature: Provided translations and enabled the default icons to make `heading4`, `heading5`, and `heading6` button components usable (as provided by `HeadingButtonUI`). Closes #121.
2 parents 55fd7ee + 5175878 commit 17bea3d

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

lang/contexts.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"Choose heading": "Default label for the heading dropdown.",
55
"Heading 1": "Dropdown option label for the heading level 1 format.",
66
"Heading 2": "Dropdown option label for the heading level 2 format.",
7-
"Heading 3": "Dropdown option label for the heading level 3 format."
7+
"Heading 3": "Dropdown option label for the heading level 3 format.",
8+
"Heading 4": "Dropdown option label for the heading level 4 format.",
9+
"Heading 5": "Dropdown option label for the heading level 5 format.",
10+
"Heading 6": "Dropdown option label for the heading level 6 format."
811
}

src/headingbuttonsui.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ import { getLocalizedOptions } from './utils';
1414
import iconHeading1 from '../theme/icons/heading1.svg';
1515
import iconHeading2 from '../theme/icons/heading2.svg';
1616
import iconHeading3 from '../theme/icons/heading3.svg';
17+
import iconHeading4 from '../theme/icons/heading4.svg';
18+
import iconHeading5 from '../theme/icons/heading5.svg';
19+
import iconHeading6 from '../theme/icons/heading6.svg';
1720

1821
const defaultIcons = {
1922
heading1: iconHeading1,
2023
heading2: iconHeading2,
21-
heading3: iconHeading3
24+
heading3: iconHeading3,
25+
heading4: iconHeading4,
26+
heading5: iconHeading5,
27+
heading6: iconHeading6
2228
};
2329

2430
/**

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export function getLocalizedOptions( editor ) {
1515
Paragraph: t( 'Paragraph' ),
1616
'Heading 1': t( 'Heading 1' ),
1717
'Heading 2': t( 'Heading 2' ),
18-
'Heading 3': t( 'Heading 3' )
18+
'Heading 3': t( 'Heading 3' ),
19+
'Heading 4': t( 'Heading 4' ),
20+
'Heading 5': t( 'Heading 5' ),
21+
'Heading 6': t( 'Heading 6' )
1922
};
2023

2124
return editor.config.get( 'heading.options' ).map( option => {

tests/headingbuttonsui.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@ describe( 'HeadingButtonUI', () => {
2424
return ClassicTestEditor
2525
.create( editorElement, {
2626
plugins: [ HeadingButtonsUI, HeadingEditing ],
27-
toolbar: [ 'heading1', 'heading2', 'heading3' ]
27+
toolbar: [ 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6' ],
28+
heading: {
29+
options: [
30+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
31+
{ model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
32+
{ model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
33+
{ model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' },
34+
{ model: 'heading4', view: 'h5', title: 'Heading 4', class: 'ck-heading_heading4' },
35+
{ model: 'heading5', view: 'h6', title: 'Heading 5', class: 'ck-heading_heading5' },
36+
{ model: 'heading6', view: 'p', title: 'Heading 6', class: 'ck-heading_heading6' }
37+
]
38+
}
2839
} )
2940
.then( newEditor => {
3041
editor = newEditor;
@@ -46,6 +57,9 @@ describe( 'HeadingButtonUI', () => {
4657
expect( factory.create( 'heading1' ) ).to.be.instanceOf( ButtonView );
4758
expect( factory.create( 'heading2' ) ).to.be.instanceOf( ButtonView );
4859
expect( factory.create( 'heading3' ) ).to.be.instanceOf( ButtonView );
60+
expect( factory.create( 'heading4' ) ).to.be.instanceOf( ButtonView );
61+
expect( factory.create( 'heading5' ) ).to.be.instanceOf( ButtonView );
62+
expect( factory.create( 'heading6' ) ).to.be.instanceOf( ButtonView );
4963
} );
5064

5165
it( 'should initialize buttons with correct localized data', () => {

tests/manual/heading-buttons.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ import Undo from '@ckeditor/ckeditor5-undo/src/undo';
1717
ClassicEditor
1818
.create( document.querySelector( '#editor' ), {
1919
plugins: [ Enter, Typing, Undo, Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ],
20-
toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3', '|', 'undo', 'redo' ]
20+
toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', '|', 'undo', 'redo' ],
21+
heading: {
22+
options: [
23+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
24+
{ model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
25+
{ model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
26+
{ model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' },
27+
{ model: 'heading4', view: 'h5', title: 'Heading 4', class: 'ck-heading_heading4' },
28+
{ model: 'heading5', view: 'h6', title: 'Heading 5', class: 'ck-heading_heading5' },
29+
{ model: 'heading6', view: 'p', title: 'Heading 6', class: 'ck-heading_heading6' }
30+
]
31+
}
2132
} )
2233
.then( editor => {
2334
window.editor = editor;

0 commit comments

Comments
 (0)