UNPKG

@textbus/core

Version:

Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.

109 lines (108 loc) 2.71 kB
import { Observable } from '@tanbo/stream'; import { Operation } from '../model/_api'; import { Selection } from './selection'; import { Registry } from './registry'; import { RootComponentRef } from './_injection-tokens'; import { Scheduler } from './scheduler'; import { Paths } from '../observable/change-marker'; interface SelectionPaths { anchor: Paths; focus: Paths; } /** * 每一次变更所产生的记录 */ export interface HistoryItem { /** 变更之前的光标位置 */ beforePaths: SelectionPaths; /** 变更之后的光标位置 */ afterPaths: SelectionPaths; /** 变更操作记录集合 */ operations: Operation[]; } /** * 历史记录抽象类,实现以下接口即可完成 Textbus 历史记录 */ export declare abstract class History { abstract onChange: Observable<void>; abstract onBack: Observable<void>; abstract onForward: Observable<void>; abstract onPush: Observable<void>; abstract canBack: boolean; abstract canForward: boolean; abstract listen(): void; abstract back(): void; abstract forward(): void; abstract clear(): void; abstract destroy(): void; } /** * Textbus 历史记录管理类 */ export declare class LocalHistory extends History { private stackSize; private scheduler; private rootComponentRef; private selection; private registry; /** * 当历史记录变化时触发 */ onChange: Observable<void>; /** * 当历史记录回退时触发 */ onBack: Observable<void>; /** * 当历史记录重做时触发 */ onForward: Observable<void>; /** * 当历史记录增加时触发 */ onPush: Observable<void>; /** * 历史记录是否可回退 */ get canBack(): boolean; /** * 历史记录是否可重做 */ get canForward(): boolean; private index; private historySequence; private changeEvent; private backEvent; private forwardEvent; private pushEvent; private subscription; private forceChangeSubscription; constructor(stackSize: number, scheduler: Scheduler, rootComponentRef: RootComponentRef, selection: Selection, registry: Registry); /** * 监听数据变化,并记录操作历史 */ listen(): void; /** * 重做历史记录 */ forward(): void; /** * 撤消操作 */ back(): void; /** * 清除历史记录 */ clear(): void; /** * 销毁历史记录实例 */ destroy(): void; private record; private apply; private valueToModel; private getPaths; private usePaths; private findModelByPaths; } export {};