index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /// <reference types="./types" />
  2. import "./assets/less/index.less";
  3. import VditorMethod from "./method";
  4. declare class Vditor extends VditorMethod {
  5. readonly version: string;
  6. vditor: IVditor;
  7. /**
  8. * @param id 要挂载 Vditor 的元素或者元素 ID。
  9. * @param options Vditor 参数
  10. */
  11. constructor(id: string | HTMLElement, options?: IOptions);
  12. /** 设置主题 */
  13. setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string): void;
  14. /** 获取 Markdown 内容 */
  15. getValue(): string;
  16. /** 获取编辑器当前编辑模式 */
  17. getCurrentMode(): "sv" | "wysiwyg" | "ir";
  18. /** 聚焦到编辑器 */
  19. focus(): void;
  20. /** 让编辑器失焦 */
  21. blur(): void;
  22. /** 禁用编辑器 */
  23. disabled(): void;
  24. /** 解除编辑器禁用 */
  25. enable(): void;
  26. /** 返回选中的字符串 */
  27. getSelection(): string;
  28. /** 设置预览区域内容 */
  29. renderPreview(value?: string): void;
  30. /** 获取焦点位置 */
  31. getCursorPosition(): {
  32. left: number;
  33. top: number;
  34. };
  35. /** 上传是否还在进行中 */
  36. isUploading(): boolean;
  37. /** 清除缓存 */
  38. clearCache(): void;
  39. /** 禁用缓存 */
  40. disabledCache(): void;
  41. /** 启用缓存 */
  42. enableCache(): void;
  43. /** HTML 转 md */
  44. html2md(value: string): string;
  45. /** markdown 转 JSON 输出 */
  46. exportJSON(value: string): string;
  47. /** 获取 HTML */
  48. getHTML(): string;
  49. /** 消息提示。time 为 0 将一直显示 */
  50. tip(text: string, time?: number): void;
  51. /** 设置预览模式 */
  52. setPreviewMode(mode: "both" | "editor"): void;
  53. /** 删除选中内容 */
  54. deleteValue(): void;
  55. /** 更新选中内容 */
  56. updateValue(value: string): void;
  57. /** 在焦点处插入内容,并默认进行 Markdown 渲染 */
  58. insertValue(value: string, render?: boolean): void;
  59. /** 设置编辑器内容 */
  60. setValue(markdown: string, clearStack?: boolean): void;
  61. /** 清空 undo & redo 栈 */
  62. clearStack(): void;
  63. /** 销毁编辑器 */
  64. destroy(): void;
  65. /** 获取评论 ID */
  66. getCommentIds(): ICommentsData[];
  67. /** 高亮评论 */
  68. hlCommentIds(ids: string[]): void;
  69. /** 取消评论高亮 */
  70. unHlCommentIds(ids: string[]): void;
  71. /** 删除评论 */
  72. removeCommentIds(removeIds: string[]): void;
  73. private init;
  74. }
  75. export default Vditor;