UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

14 lines (12 loc) 839 B
import { FULL_WIDTH_EDITOR_CONTENT_WIDTH } from '../table-resizing/utils/consts'; export const ALIGN_START = 'align-start'; export const 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 const normaliseAlignment = layout => layout === ALIGN_CENTER || layout === ALIGN_START ? layout : ALIGN_CENTER; /** * We don't want to switch alignment in Full-width editor */ export const shouldChangeAlignmentToCenterResized = (isTableAlignmentEnabled, tableNode, lineLength, updatedTableWidth) => Boolean(isTableAlignmentEnabled && tableNode && tableNode.attrs.layout === ALIGN_START && lineLength && updatedTableWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH);