UNPKG

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

Version:

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

41 lines 2.87 kB
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'; import { getIndentationButtonsState } from '../../pm-plugins/indentation-buttons'; export var useIndentationState = function useIndentationState(_ref) { var api = _ref.api, allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation, state = _ref.state; var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['indentation'], function (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 }; }), isIndentationAllowed = _useSharedPluginState.isIndentationAllowed, indentDisabled = _useSharedPluginState.indentDisabled, outdentDisabled = _useSharedPluginState.outdentDisabled; var _useSharedPluginState2 = useSharedPluginStateWithSelector(api, ['taskDecision'], function (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 }; }), isInsideTask = _useSharedPluginState2.isInsideTask, taskIndentDisabled = _useSharedPluginState2.indentDisabled, taskOutdentDisabled = _useSharedPluginState2.outdentDisabled; 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: isIndentationAllowed, indentDisabled: indentDisabled, outdentDisabled: outdentDisabled }, api === null || api === void 0 ? void 0 : api.list.actions.isInsideListItem); };