@atlaskit/editor-plugin-toolbar-lists-indentation
Version:
Toolbar lists and indentation plugin for @atlaskit/editor-core
37 lines • 1.54 kB
JavaScript
import React from 'react';
import { useIntl } from 'react-intl';
import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
import TaskIcon from '@atlaskit/icon/core/task';
export const TaskListMenuItem = ({
api
}) => {
const {
formatMessage
} = useIntl();
const {
editorView
} = useEditorToolbar();
const taskListActive = useSharedPluginStateSelector(api, 'taskDecision.isInsideTask');
if (!(editorView !== null && editorView !== void 0 && editorView.state.schema.nodes.taskItem)) {
return null;
}
const handleClick = () => {
var _api$taskDecision;
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList());
};
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
elemBefore: /*#__PURE__*/React.createElement(TaskIcon, {
size: "small",
label: ""
}),
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
shortcut: "[]"
}),
isSelected: taskListActive,
isDisabled: false,
onClick: handleClick
}, formatMessage(tasksAndDecisionsMessages.taskList));
};