import type { BlockDefinition } from '../../types';
import { ColumnLayout } from '../../extensions/MultiColumn/Columns';

const columns2: BlockDefinition = {
  label: '2カラムに分割',
  icon: 'view_column',
  description: '2カラムに分割',
  isTextMenu: false,
  aliases: ['cols2', 'columns2'],
  createActions: (cmd, ctx) => ({
    action: (editor) => {
      ctx.recordUsage(cmd);
      const { $from } = editor.state.selection;
      const pos = $from.before($from.depth);
      editor
        .chain()
        .focus()
        .setColumns(ColumnLayout.TwoColumn)
        .focus(editor.state.selection.head - 1)
        .setBlockAttrs(pos, { class: cmd.class })
        .run();
    },
    convert: () => {},
    isDisabled: () => true,
    isActive: (editor) => editor.isActive('columns2'),
  }),
};

export default columns2;
