UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

18 lines (16 loc) 927 B
import { FULL_WIDTH_EDITOR_CONTENT_WIDTH } from '../table-resizing/utils/consts'; export var ALIGN_START = 'align-start'; export var 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') */ export var 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 */ export var shouldChangeAlignmentToCenterResized = function shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, updatedTableWidth) { return Boolean(isTableAlignmentEnabled && tableNode && tableNode.attrs.layout === ALIGN_START && lineLength && updatedTableWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH); };