UNPKG

@atlaskit/editor-plugin-breakout

Version:

Breakout plugin for @atlaskit/editor-core

25 lines (24 loc) • 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getResizeContainerWidth = exports.clampWidthToResizeBounds = exports.WIDTHS = void 0; var _constants = require("@atlaskit/editor-shared-styles/constants"); var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment"); var WIDTHS = exports.WIDTHS = { FULL: _constants.akEditorFullWidthLayoutWidth, MAX: _constants.akEditorMaxLayoutWidth, MIN: _constants.akEditorDefaultLayoutWidth, WIDE: _constants.akEditorCalculatedWideLayoutWidth }; var getResizeContainerWidth = exports.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 <= _constants.akEditorFullPageNarrowBreakout && (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, { exposure: true }) ? _constants.akEditorGutterPaddingReduced : (0, _constants.akEditorGutterPaddingDynamic)(); return editorWidth - 2 * padding - _constants.akEditorGutterPadding; }; var clampWidthToResizeBounds = exports.clampWidthToResizeBounds = function clampWidthToResizeBounds(proposedWidth, containerWidth) { return Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth, WIDTHS.MAX)); };