UNPKG

3.63 kBTypeScriptView Raw
1/**
2 * @description 编辑器 class
3 * @author wangfupeng
4 */
5import $, { DomElement, DomElementSelector } from '../utils/dom-core';
6import { ConfigType } from '../config';
7import SelectionAndRangeAPI from './selection';
8import CommandAPI from './command';
9import Text from '../text/index';
10import Menus from '../menus/index';
11import ZIndex from './z-index';
12import Change from './change/index';
13import History from './history/index';
14import SelectionChange from './selection-change';
15import { RegisterOptions, pluginsListType } from '../plugins';
16import { MenuListType } from '../menus/menu-list';
17import BtnMenu from '../menus/menu-constructors/BtnMenu';
18import DropList from '../menus/menu-constructors/DropList';
19import DropListMenu from '../menus/menu-constructors/DropListMenu';
20import Panel from '../menus/menu-constructors/Panel';
21import PanelMenu from '../menus/menu-constructors/PanelMenu';
22import Tooltip from '../menus/menu-constructors/Tooltip';
23declare class Editor {
24 static $: typeof $;
25 static BtnMenu: typeof BtnMenu;
26 static DropList: typeof DropList;
27 static DropListMenu: typeof DropListMenu;
28 static Panel: typeof Panel;
29 static PanelMenu: typeof PanelMenu;
30 static Tooltip: typeof Tooltip;
31 static globalCustomMenuConstructorList: MenuListType;
32 static globalPluginsFunctionList: pluginsListType;
33 pluginsFunctionList: pluginsListType;
34 id: string;
35 toolbarSelector: DomElementSelector;
36 textSelector?: DomElementSelector;
37 config: ConfigType;
38 $toolbarElem: DomElement;
39 $textContainerElem: DomElement;
40 $textElem: DomElement;
41 toolbarElemId: string;
42 textElemId: string;
43 isFocus: boolean;
44 isComposing: boolean;
45 isCompatibleMode: boolean;
46 selection: SelectionAndRangeAPI;
47 cmd: CommandAPI;
48 txt: Text;
49 menus: Menus;
50 i18next: any;
51 highlight: any;
52 zIndex: ZIndex;
53 change: Change;
54 history: History;
55 isEnable: Boolean;
56 onSelectionChange: SelectionChange;
57 private beforeDestroyHooks;
58 /** 禁用api */
59 disable: Function;
60 /** 启用api */
61 enable: Function;
62 /**
63 * 构造函数
64 * @param toolbarSelector 工具栏 DOM selector
65 * @param textSelector 文本区域 DOM selector
66 */
67 constructor(toolbarSelector: DomElementSelector, textSelector?: DomElementSelector);
68 /**
69 * 初始化选区
70 * @param newLine 新建一行
71 */
72 initSelection(newLine?: boolean): void;
73 /**
74 * 创建编辑器实例
75 */
76 create(): void;
77 /**
78 * 提供给用户添加销毁前的钩子函数
79 * @param fn 钩子函数
80 */
81 beforeDestroy(fn: Function): Editor;
82 /**
83 * 销毁当前编辑器实例
84 */
85 destroy(): void;
86 /**
87 * 将编辑器设置为全屏
88 */
89 fullScreen(): void;
90 /**
91 * 将编辑器退出全屏
92 */
93 unFullScreen(): void;
94 /**
95 * 滚动到指定标题锚点
96 * @param id 标题锚点id
97 */
98 scrollToHead(id: string): void;
99 /**
100 * 自定义添加菜单
101 * @param key 菜单 key
102 * @param Menu 菜单构造函数
103 */
104 static registerMenu(key: string, Menu: any): void;
105 /**
106 * 自定义添加插件
107 * @param { string } name 插件的名称
108 * @param { RegisterOptions } options 插件的选项
109 */
110 registerPlugin(name: string, options: RegisterOptions): void;
111 /**
112 * 自定义添加插件
113 * @param { string } name 插件的名称
114 * @param { RegisterOptions } options 插件的选项
115 */
116 static registerPlugin(name: string, options: RegisterOptions): void;
117}
118export default Editor;