/* eslint-disable @typescript-eslint/consistent-type-definitions */
import { Extension } from '@tiptap/react';

declare module '@tiptap/core' {
  interface Commands<ReturnType> {
    video: {
      /**
       * Insert a video as a resizable-media node
       */
      setVideo: (src: string) => ReturnType;
    };
  }
}

const Video = Extension.create({
  name: 'video',

  addCommands() {
    return {
      setVideo:
        (src: string) =>
        ({ commands }) =>
          commands.insertContent([
            {
              type: 'resizable-media',
              attrs: {
                tag: 'video',
                src,
              },
            },
            { type: 'paragraph' },
          ]),
    };
  },
});

export default Video;
