UNPKG

@atlaskit/editor-plugin-breakout

Version:

Breakout plugin for @atlaskit/editor-core

20 lines • 1.57 kB
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullPageNarrowBreakout, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles/constants'; import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment'; var WIDTHS = { FULL: akEditorFullWidthLayoutWidth, MAX: akEditorMaxLayoutWidth, MIN: akEditorDefaultLayoutWidth, WIDE: akEditorCalculatedWideLayoutWidth }; export { WIDTHS }; export var getResizeContainerWidth = function getResizeContainerWidth(api) { var _api$width$sharedStat, _api$width$sharedStat2; var editorWidth = (_api$width$sharedStat = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState) === null || _api$width$sharedStat2 === void 0 || (_api$width$sharedStat2 = _api$width$sharedStat2.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0; var padding = editorWidth <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, { exposure: true }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic(); return editorWidth - 2 * padding - akEditorGutterPadding; }; export var clampWidthToResizeBounds = function clampWidthToResizeBounds(proposedWidth, containerWidth) { return Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth, WIDTHS.MAX)); };