import { MarkKeys, Element, ElementKeys, Editor } from 'slate'; import { NoEffectWrapTypes, TextAlign } from './constant.js'; import 'react'; interface CommandEditor { /** * @descriptionZH 标记类型是否处于激活状态 * @descriptionEN * @memberof CommandEditor */ isMarkActive: (name: MarkKeys) => boolean; /** * @descriptionZH 应用/取消标记类型 * @descriptionEN * @memberof CommandEditor */ toggleMark: (name: MarkKeys) => void; /** * @descriptionZH 某节点类型是否处于当前焦点 * @descriptionEN * @memberof CommandEditor */ isElementActive: (type: Element['type']) => boolean; /** * @descriptionZH 应用/取消某节点类型 * @descriptionEN * @memberof CommandEditor */ toggleElement: (type: NoEffectWrapTypes) => void; /** * @descriptionZH 应用/取消该文本对齐方式 * @descriptionEN * @memberof CommandEditor */ toggleAlign: (align: TextAlign) => void; /** * @descriptionZH 开启/关闭当前节点锁定状态 * @descriptionEN * @memberof CommandEditor */ toggleLock: (type: Element['type']) => void; /** * @descriptionZH 开启/关闭节点拖动。options.draggable:强制设置当前状态;options.unique: 状态唯一,即清除焦点外所有拖动状态,只应用焦点下的拖动状态 * @descriptionEN Turn on/off node draggable state * @memberof CommandEditor */ toggleDraggable: (type: Element['type'], options?: { unique?: boolean; draggable?: boolean; }) => void; /** * @descriptionZH * @descriptionEN * @memberof CommandEditor */ getElementFieldsValue: (fields?: ElementKeys | ElementKeys[], type?: Element['type']) => any; /** * @descriptionZH * @descriptionEN * @memberof CommandEditor */ setLink: (url: string) => void; /** * @descriptionZH * @descriptionEN * @memberof CommandEditor */ unsetLink: () => void; /** * @descriptionZH * @descriptionEN * @memberof CommandEditor */ getBoundingClientRect: () => DOMRect | null; /** * @descriptionZH 挂载在实例上的一些额外的属性 * @descriptionEN some extra attributes on the instance * @type {Record} * @memberof CommandEditor */ extraProperty?: Record; /** * @descriptionZH 添加额外属性 * @descriptionEN Add an extra attribute * @memberof CommandEditor */ addExtraProperty: (key: string, value: any) => void; /** * @descriptionZH 移除实例上指定的额外属性 * @descriptionEN Remove extra attributes specified on the instance * @memberof CommandEditor */ removeExtraProperty: (key: string) => void; /** * @descriptionZH 判断全文是否存在可拖动节点 * @descriptionEN Determine whether the editor has draggable nodes * @memberof CommandEditor */ hasDraggableNodes: () => boolean; } /** * @descriptionZH 命令方法: 在实例上新增一些常用的命令 * @descriptionEN Commands: Add some commonly used commands on the editor instance * @export * @template T * @param {T} editor * @return {*} */ declare function withCommand(editor: T): T & CommandEditor; export { CommandEditor, withCommand };