import { Mark, mergeAttributes } from '@tiptap/core';

export interface AIMarkOptions {
    HTMLAttributes: Record<string, unknown>;
}

export const AIMark = Mark.create<AIMarkOptions>({
    name: 'aiMark',

    addOptions() {
        return {
            HTMLAttributes: {
                class: 'ai-content',
            },
        };
    },

    parseHTML() {
        return [
            {
                tag: 'span.ai-content',
            },
        ];
    },

    renderHTML({ HTMLAttributes }) {
        return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
    },
});
