@atlaskit/editor-plugin-text-formatting
Version:
Text-formatting plugin for @atlaskit/editor-core
47 lines • 1.47 kB
JavaScript
import React from 'react';
import { TEXT_FORMATTING_GROUP_INLINE, TEXT_FORMATTING_HERO_BUTTON, TEXT_SECTION, TEXT_SECTION_RANK, TEXT_FORMATTING_GROUP, TEXT_FORMAT_GROUP_RANK } from '@atlaskit/editor-common/toolbar';
import { ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
import { FormatOptions } from '../types';
import { FormatButton } from './Component';
import { formatOptions } from './utils';
export const textFormattingGroupForInlineToolbar = api => [{
type: TEXT_FORMATTING_GROUP_INLINE.type,
key: TEXT_FORMATTING_GROUP_INLINE.key,
parents: [{
type: TEXT_SECTION.type,
key: TEXT_SECTION.key,
rank: TEXT_SECTION_RANK[TEXT_FORMATTING_GROUP.key]
}],
component: ({
children
}) => {
return /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children);
}
}, {
type: TEXT_FORMATTING_HERO_BUTTON.type,
key: TEXT_FORMATTING_HERO_BUTTON.key,
parents: [{
type: TEXT_FORMATTING_GROUP_INLINE.type,
key: TEXT_FORMATTING_GROUP_INLINE.key,
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
}],
component: ({
parents
}) => {
const {
icon,
command,
shortcut,
title
} = formatOptions().strong;
return /*#__PURE__*/React.createElement(FormatButton, {
api: api,
parents: parents,
icon: icon,
title: title,
shortcut: shortcut,
optionType: FormatOptions.strong,
toggleMarkWithAnalyticsCallback: command
});
}
}];