UNPKG

@atlaskit/editor-plugin-breakout

Version:

Breakout plugin for @atlaskit/editor-core

24 lines 1.96 kB
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullPageNarrowBreakout, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles/constants'; import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals'; import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'; 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 getResizeHardMax = function getResizeHardMax(containerWidth) { return expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL); }; export var clampWidthToResizeBounds = function clampWidthToResizeBounds(proposedWidth, containerWidth) { return Math.max(WIDTHS.MIN, Math.min(proposedWidth, getResizeHardMax(containerWidth))); };