import { SlateDescendant, SlateElement, SlateText } from '@wangeditor/editor';
import { QiniuUploadProps } from '../compose-form/interface';

declare module '@wangeditor/editor' {
  // 扩展 Text
  interface SlateText {
    text: string;
  }

  // 扩展 Element
  interface SlateElement {
    type: string;
    children: SlateDescendant[];
  }
}

export type ImageElement = SlateElement & {
  src: string;
  alt: string;
  url: string;
  href: string;
};
export type VideoElement = SlateElement & {
  src: string;
  poster?: string;
};
export type InsertFnType = (url: string, alt: string, href: string) => void;

interface UploadProps extends QiniuUploadProps {
  uploadUrlPrefix?: string;
}

export interface EditorProps {
  value: string | undefined;
  onChange: (value: string) => void;
  requestUrl?: string;
  exToolbar?: string[];
  setToolbar?: string[];
  getTokenUrl: string;
  maxSize?: number;
  maxVideoSize?: number;
  uploadProps?: UploadProps;
  [x: string]: any;
}
