|
|
@@ -11,6 +11,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
|
|
import Model from '@ckeditor/ckeditor5-ui/src/model';
|
|
|
|
|
|
import { createDropdown, addListToDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
|
|
|
+import { getLocalizedOptions } from './utils';
|
|
|
|
|
|
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
|
|
|
|
@@ -28,7 +29,7 @@ export default class HeadingUI extends Plugin {
|
|
|
init() {
|
|
|
const editor = this.editor;
|
|
|
const t = editor.t;
|
|
|
- const options = this._getLocalizedOptions();
|
|
|
+ const options = getLocalizedOptions( editor );
|
|
|
const defaultTitle = t( 'Choose heading' );
|
|
|
const dropdownTooltip = t( 'Heading' );
|
|
|
|
|
|
@@ -102,37 +103,4 @@ export default class HeadingUI extends Plugin {
|
|
|
return dropdownView;
|
|
|
} );
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns heading options as defined in `config.heading.options` but processed to consider
|
|
|
- * editor localization, i.e. to display {@link module:heading/heading~HeadingOption}
|
|
|
- * in the correct language.
|
|
|
- *
|
|
|
- * Note: The reason behind this method is that there's no way to use {@link module:utils/locale~Locale#t}
|
|
|
- * when the user config is defined because the editor does not exist yet.
|
|
|
- *
|
|
|
- * @private
|
|
|
- * @returns {Array.<module:heading/heading~HeadingOption>}.
|
|
|
- */
|
|
|
- _getLocalizedOptions() {
|
|
|
- const editor = this.editor;
|
|
|
- const t = editor.t;
|
|
|
- const localizedTitles = {
|
|
|
- Paragraph: t( 'Paragraph' ),
|
|
|
- 'Heading 1': t( 'Heading 1' ),
|
|
|
- 'Heading 2': t( 'Heading 2' ),
|
|
|
- 'Heading 3': t( 'Heading 3' )
|
|
|
- };
|
|
|
-
|
|
|
- return editor.config.get( 'heading.options' ).map( option => {
|
|
|
- const title = localizedTitles[ option.title ];
|
|
|
-
|
|
|
- if ( title && title != option.title ) {
|
|
|
- // Clone the option to avoid altering the original `config.heading.options`.
|
|
|
- option = Object.assign( {}, option, { title } );
|
|
|
- }
|
|
|
-
|
|
|
- return option;
|
|
|
- } );
|
|
|
- }
|
|
|
}
|