@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
24 lines (21 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shouldChangeAlignmentToCenterResized = exports.normaliseAlignment = exports.ALIGN_START = exports.ALIGN_CENTER = void 0;
var _consts = require("../table-resizing/utils/consts");
var ALIGN_START = exports.ALIGN_START = 'align-start';
var ALIGN_CENTER = exports.ALIGN_CENTER = 'center';
/**
* Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
* center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
*/
var normaliseAlignment = exports.normaliseAlignment = function normaliseAlignment(layout) {
return layout === ALIGN_CENTER || layout === ALIGN_START ? layout : ALIGN_CENTER;
};
/**
* We don't want to switch alignment in Full-width editor
*/
var shouldChangeAlignmentToCenterResized = exports.shouldChangeAlignmentToCenterResized = function shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, updatedTableWidth) {
return Boolean(isTableAlignmentEnabled && tableNode && tableNode.attrs.layout === ALIGN_START && lineLength && updatedTableWidth > lineLength && lineLength < _consts.FULL_WIDTH_EDITOR_CONTENT_WIDTH);
};