UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

47 lines 2.22 kB
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import { TableDecorations } from '../../../types'; import { createResizeHandleDecoration, updateDecorations } from '../../utils/decoration'; import { composeDecorations } from './compose-decorations'; var emptyDecorations = [[], []]; var updateColumnResizeHandle = function updateColumnResizeHandle(columnResizesDecorations) { return function (_ref) { var decorationSet = _ref.decorationSet, tr = _ref.tr; return updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET); }; }; var updateLastCellElement = function updateLastCellElement(lastCellElementsDecorations) { return function (_ref2) { var decorationSet = _ref2.decorationSet, tr = _ref2.tr; return updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT); }; }; export var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex, includeTooltip, getIntl, nodeViewPortalProviderAPI) { return function (_ref3) { var tr = _ref3.tr, decorationSet = _ref3.decorationSet; var _ref4 = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, { right: columnEndIndex }, includeTooltip, getIntl, nodeViewPortalProviderAPI), _ref5 = _slicedToArray(_ref4, 2), columnResizesDecorations = _ref5[0], lastCellElementsDecorations = _ref5[1]; return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({ decorationSet: decorationSet, tr: tr }); }; }; export var clearColumnResizingDecorations = function clearColumnResizingDecorations() { return function (_ref6) { var tr = _ref6.tr, decorationSet = _ref6.decorationSet; var columnResizesDecorations = emptyDecorations[0], lastCellElementsDecorations = emptyDecorations[1]; return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({ decorationSet: decorationSet, tr: tr }); }; };