@atlaskit/editor-plugin-code-block-advanced
Version:
CodeBlockAdvanced plugin for @atlaskit/editor-core
24 lines (22 loc) • 825 B
JavaScript
import { SUPPORTED_LANGUAGES } from '@atlaskit/code/constants';
import { fg } from '@atlaskit/platform-feature-flags/fg';
// We expect alias[0] to be used for the ADF attribute, see ED-2813
export const DEFAULT_LANGUAGES = [{
name: '(None)',
alias: ['none'],
value: 'none'
}, ...SUPPORTED_LANGUAGES];
const getLanguageName = languageValue => {
if (!languageValue) {
return undefined;
}
// mermaid is gated out of the shared SUPPORTED_LANGUAGES list, so resolve it here
if (languageValue === 'mermaid' && fg('platform_editor_code_block_mermaid_language')) {
return 'Mermaid';
}
const language = SUPPORTED_LANGUAGES.find(l => {
return l.value === languageValue || l.alias && l.alias.includes(languageValue);
});
return language ? language.name : undefined;
};
export default getLanguageName;