@atlaskit/editor-plugin-breakout
Version:
Breakout plugin for @atlaskit/editor-core
20 lines • 1.56 kB
JavaScript
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullPageNarrowBreakout, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
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 clampWidthToResizeBounds = (proposedWidth, containerWidth) => {
return Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth, WIDTHS.MAX));
};