@atlaskit/editor-plugin-text-formatting
Version:
Text-formatting plugin for @atlaskit/editor-core
59 lines • 1.71 kB
JavaScript
import React from 'react';
import { UNDERLINE_BUTTON_GROUP, UNDERLINE_BUTTON, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
import { FormatOptions } from '../types';
import { FormatButton } from './Component';
import { formatOptions } from './utils';
const UnderlineButtonGroup = ({
children
}) => {
const {
editorAppearance
} = useEditorToolbar();
if (editorAppearance === 'full-page') {
return /*#__PURE__*/React.createElement(Show, {
above: "xl"
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
}
};
export const underlineButtonGroup = api => [{
type: UNDERLINE_BUTTON_GROUP.type,
key: UNDERLINE_BUTTON_GROUP.key,
parents: [{
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[UNDERLINE_BUTTON_GROUP.key]
}],
component: ({
children
}) => {
return /*#__PURE__*/React.createElement(UnderlineButtonGroup, null, children);
}
}, {
type: UNDERLINE_BUTTON.type,
key: UNDERLINE_BUTTON.key,
parents: [{
type: UNDERLINE_BUTTON_GROUP.type,
key: UNDERLINE_BUTTON_GROUP.key,
rank: 100
}],
component: ({
parents
}) => {
const {
icon,
command,
shortcut,
title
} = formatOptions().underline;
return /*#__PURE__*/React.createElement(FormatButton, {
api: api,
parents: parents,
icon: icon,
title: title,
shortcut: shortcut,
optionType: FormatOptions.underline,
toggleMarkWithAnalyticsCallback: command
});
}
}];