UNPKG

@textbus/platform-browser

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.96 kB
import { Selection, AbstractSelection, Scheduler, Textbus, SelectionPaths } from '@textbus/core'; import { SelectionBridge } from './selection-bridge'; import { Rect } from './_utils/uikit'; export interface SelectionRect extends Rect { color: string; username: string; } export interface RemoteSelectionCursor { cursor: HTMLElement; anchor: HTMLElement; userTip: HTMLElement; } /** * 远程光标绘制范围计算代理类,可用于定制特定场景下的远程选区绘制,如表格有选区,不会遵守常见的文档流形式 */ export declare abstract class CollaborateSelectionAwarenessDelegate { abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range, selectionCursor: UserSelectionCursor): false | Rect[]; } /** * 协作用户虚拟光标信息 */ export interface UserSelectionCursor { username: string; color: string; selection: SelectionPaths; data?: any; } /** * 协作光标绘制类 */ export declare class CollaborateCursor { private nativeSelection; private scheduler; private selection; private awarenessDelegate?; private host; private canvasContainer; private canvas; private context; private tooltips; private onRectsChange; private subscription; private selectionCursors; private container; private ratio; constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined); /** * 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制 */ refresh(): void; destroy(): void; /** * 根据远程用户光标位置,绘制协作光标 * @param paths */ draw(paths: UserSelectionCursor[]): void; protected drawUserCursor(rects: SelectionRect[]): void; private getUserCursor; }