@textbus/core
Version:
Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.
60 lines (59 loc) • 1.62 kB
TypeScript
import { ComponentConstructor, RawKeyAgent, Shortcut } from '../model/_api';
import { Commander } from './commander';
import { Selection } from './selection';
import { Textbus } from '../textbus';
import { Scheduler } from './scheduler';
/**
* 快捷键配置
*/
export interface KeymapState {
modKey: boolean;
altKey: boolean;
shiftKey: boolean;
key: string;
agent: RawKeyAgent;
}
export interface ZenCodingInterceptor {
/** 匹配字符 */
match(content: string): boolean;
/** 触发键 */
try(key: string, agent: RawKeyAgent): boolean;
/** 触发执行的方法 */
action(content: string): boolean;
}
/**
* Textbus 键盘管理
*/
export declare class Keyboard {
private components;
private zenCoding;
private commander;
private textbus;
private scheduler;
private selection;
private shortcutList;
private zenCodingInterceptors;
constructor(components: ComponentConstructor[], zenCoding: boolean, commander: Commander, textbus: Textbus, scheduler: Scheduler, selection: Selection);
/**
* 注册输入语法糖
* @param interceptor
*/
addZenCodingInterceptor(interceptor: ZenCodingInterceptor): {
remove: () => void;
};
/**
* 调用快捷键
* @param keymapState 快捷键配置
*/
execShortcut(keymapState: KeymapState): boolean;
/**
* 注册快捷键
* @param shortcut 快捷键配置
*/
addShortcut(shortcut: Shortcut): {
remove: () => void;
};
private handleShortcut;
private createZenCodingEx;
private createShortcutEx;
}