UNPKG

@atlaskit/editor-plugin-toolbar-lists-indentation

Version:

Toolbar lists and indentation plugin for @atlaskit/editor-core

44 lines 2.43 kB
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'; import { getIndentationButtonsState } from '../../pm-plugins/indentation-buttons'; export const useIndentationState = ({ api, allowHeadingAndParagraphIndentation, state }) => { const { isIndentationAllowed, indentDisabled, outdentDisabled } = useSharedPluginStateWithSelector(api, ['indentation'], states => { var _states$indentationSt, _states$indentationSt2, _states$indentationSt3; return { isIndentationAllowed: (_states$indentationSt = states.indentationState) === null || _states$indentationSt === void 0 ? void 0 : _states$indentationSt.isIndentationAllowed, outdentDisabled: (_states$indentationSt2 = states.indentationState) === null || _states$indentationSt2 === void 0 ? void 0 : _states$indentationSt2.outdentDisabled, indentDisabled: (_states$indentationSt3 = states.indentationState) === null || _states$indentationSt3 === void 0 ? void 0 : _states$indentationSt3.indentDisabled }; }); const { isInsideTask, indentDisabled: taskIndentDisabled, outdentDisabled: taskOutdentDisabled } = useSharedPluginStateWithSelector(api, ['taskDecision'], states => { var _states$taskDecisionS, _states$taskDecisionS2, _states$taskDecisionS3; return { isInsideTask: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask, outdentDisabled: (_states$taskDecisionS2 = states.taskDecisionState) === null || _states$taskDecisionS2 === void 0 ? void 0 : _states$taskDecisionS2.outdentDisabled, indentDisabled: (_states$taskDecisionS3 = states.taskDecisionState) === null || _states$taskDecisionS3 === void 0 ? void 0 : _states$taskDecisionS3.indentDisabled }; }); if (!state) { return undefined; } return getIndentationButtonsState(state, allowHeadingAndParagraphIndentation, { isInsideTask: isInsideTask !== null && isInsideTask !== void 0 ? isInsideTask : false, indentDisabled: taskIndentDisabled !== null && taskIndentDisabled !== void 0 ? taskIndentDisabled : false, outdentDisabled: taskOutdentDisabled !== null && taskOutdentDisabled !== void 0 ? taskOutdentDisabled : false }, { isIndentationAllowed, indentDisabled, outdentDisabled }, api === null || api === void 0 ? void 0 : api.list.actions.isInsideListItem); };