/**
 * DropCursor Plugin Extension
 * 拖拽时显示光标位置
 */

import type { Schema, Plugin } from '../../core/types';
import { PluginExtension } from '../../core/Extension';
import { dropCursor } from 'prosemirror-dropcursor';

export interface DropCursorOptions {
  color?: string | false;
  width?: number;
  class?: string;
}

export class DropCursor extends PluginExtension<DropCursorOptions> {
  get name(): string {
    return 'dropCursor';
  }

  get defaultOptions(): DropCursorOptions {
    return {
      color: 'currentColor',
      width: 2,
      class: 'editor-drop-cursor',
    };
  }

  plugins(_schema: Schema): Plugin[] {
    return [
      dropCursor({
        color: this.options.color,
        width: this.options.width,
        class: this.options.class,
      }),
    ];
  }
}
