@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
34 lines • 1.55 kB
JavaScript
import { TableDecorations } from '../../../types';
import { createResizeHandleDecoration, updateDecorations } from '../../utils/decoration';
import { composeDecorations } from './compose-decorations';
const emptyDecorations = [[], []];
const updateColumnResizeHandle = columnResizesDecorations => ({
decorationSet,
tr
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
const updateLastCellElement = lastCellElementsDecorations => ({
decorationSet,
tr
}) => updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex, includeTooltip, getIntl, nodeViewPortalProviderAPI) => ({
tr,
decorationSet
}) => {
const [columnResizesDecorations, lastCellElementsDecorations] = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, {
right: columnEndIndex
}, includeTooltip, getIntl, nodeViewPortalProviderAPI);
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
decorationSet,
tr
});
};
export const clearColumnResizingDecorations = () => ({
tr,
decorationSet
}) => {
const [columnResizesDecorations, lastCellElementsDecorations] = emptyDecorations;
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
decorationSet,
tr
});
};