import { defineCellType } from '../../types';
import { MultiDocumentView } from './View';
import { MultiDocumentEdit } from './Edit';

export { MultiDocumentView, MultiDocumentEdit };

export const multiDocumentCellType = defineCellType<string[] | null>({
  type: 'multiDocument',
  ViewComponent: MultiDocumentView,
  EditComponent: MultiDocumentEdit,
  serialize: (value) => (value ?? []).join(', '),
  clearable: true,
  showEditWhenFocused: true,
  growable: true,
  // Returning undefined blocks all key presses from starting type-to-edit, but
  // the presence of the function sets the :typeToEdit CSS modifier which keeps
  // the selection borders visible while the cell is in edit mode (double border).
  onTypeToEdit: () => undefined,
});
