UNPKG

@atlaskit/editor-plugin-breakout

Version:

Breakout plugin for @atlaskit/editor-core

24 lines 1.92 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'; const WIDTHS = { FULL: akEditorFullWidthLayoutWidth, MAX: akEditorMaxLayoutWidth, MIN: akEditorDefaultLayoutWidth, WIDE: akEditorCalculatedWideLayoutWidth }; export { WIDTHS }; export const getResizeContainerWidth = api => { var _api$width$sharedStat, _api$width$sharedStat2, _api$width$sharedStat3; const editorWidth = (_api$width$sharedStat = api === null || api === void 0 ? void 0 : (_api$width$sharedStat2 = api.width.sharedState) === null || _api$width$sharedStat2 === void 0 ? void 0 : (_api$width$sharedStat3 = _api$width$sharedStat2.currentState()) === null || _api$width$sharedStat3 === void 0 ? void 0 : _api$width$sharedStat3.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0; const padding = editorWidth <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, { exposure: true }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic(); return editorWidth - 2 * padding - akEditorGutterPadding; }; export const 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 const clampWidthToResizeBounds = (proposedWidth, containerWidth) => { return Math.max(WIDTHS.MIN, Math.min(proposedWidth, getResizeHardMax(containerWidth))); };