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

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

export default columns1;
