1 | /**
|
2 | * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3 | * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4 | */
|
5 | /**
|
6 | * Returns heading options as defined in `config.heading.options` but processed to consider
|
7 | * the editor localization, i.e. to display {@link module:heading/headingconfig~HeadingOption}
|
8 | * in the correct language.
|
9 | *
|
10 | * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
11 | * when the user configuration is defined because the editor does not exist yet.
|
12 | */
|
13 | export function getLocalizedOptions(editor) {
|
14 | const t = editor.t;
|
15 | const localizedTitles = {
|
16 | 'Paragraph': t('Paragraph'),
|
17 | 'Heading 1': t('Heading 1'),
|
18 | 'Heading 2': t('Heading 2'),
|
19 | 'Heading 3': t('Heading 3'),
|
20 | 'Heading 4': t('Heading 4'),
|
21 | 'Heading 5': t('Heading 5'),
|
22 | 'Heading 6': t('Heading 6')
|
23 | };
|
24 | return editor.config.get('heading.options').map(option => {
|
25 | const title = localizedTitles[option.title];
|
26 | if (title && title != option.title) {
|
27 | option.title = title;
|
28 | }
|
29 | return option;
|
30 | });
|
31 | }
|