@bixi/label
Version:
256 lines (255 loc) • 7.13 kB
TypeScript
import { BehaviorSubject, Subject } from 'rxjs';
import { IDeleteLabelsEvent, IHoverInLabelsEvent, IInitOptions, ILabel, ILabelingEvent, ILabelStyle, IModifiedTableLineMatrix, IPagination, ISafeAny, ISearchLabelByIndexParams, ISearchLabelByUuidParams, ISearchRectParams, ISearchResult, ISearchTableCellParams, ISerarchParams, ITableSplit, IViewPort, LabelTableMode, LabelTextMode, PdfMode } from './label.type';
interface IOptions {
dev?: boolean;
logUnhandledEvents?: boolean;
logAllEvents?: boolean;
logIgnoreEvents?: string[];
}
export declare class LabelHub {
id: string;
protected _hoverInLabelsEvent: IHoverInLabelsEvent | null;
protected _labelingEvent: ILabelingEvent | null;
protected _dev: boolean;
protected _logUnhandledEvents: boolean;
protected _logAllEvents: boolean;
protected _logIgnoreEvents: string[];
protected _api: ISafeAny;
protected _ready: boolean;
protected _loaded: boolean;
protected _zoom: number;
protected _pagination: IPagination;
/**
* 标注器是否加载完成
*/
readonly loaded$: BehaviorSubject<boolean>;
/**
* 标注器是否准备完毕
*/
readonly ready$: BehaviorSubject<boolean>;
/**
* 初始化数据流
*/
readonly init$: BehaviorSubject<IInitOptions | null>;
/**
* 搜索结果
*/
readonly searchResult$: BehaviorSubject<ISearchResult>;
/**
* Tooltip 信息
*/
readonly hoverInLabelsEvent$: Subject<IHoverInLabelsEvent | null>;
/**
* 分页信息
* 默认
* {
* page: 1,
* total: 1
* }
*/
readonly pagination$: BehaviorSubject<IPagination>;
/**
* 缩放
*/
readonly zoom$: BehaviorSubject<number>;
/**
* 标注列表
*/
readonly labels$: BehaviorSubject<ILabel[] | null>;
/**
* 表格列表
*/
readonly tables$: BehaviorSubject<any>;
/**
* 删除标注
*/
readonly deleteLabelsEvent$: Subject<IDeleteLabelsEvent | null>;
/**
* 当前正在标注的标注
*/
readonly labelingEvent$: Subject<ILabelingEvent | null>;
/**
* 尺寸变化
*/
readonly resize$: Subject<void>;
/**
* 日志流
*/
readonly log$: Subject<unknown>;
constructor(options?: IOptions);
get ready(): boolean;
get dev(): boolean;
get api(): any;
get loaded(): boolean;
get logUnhandledEvents(): boolean;
get logAllEvents(): boolean;
get logIgnoreEvents(): string[];
get hoverInLabelsEvent(): ILabelingEvent | null;
get labelingEvent(): ILabelingEvent | null;
get labeling(): boolean;
/**
* 设置标注器是否准备完毕
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
setReady(ready: boolean): void;
/**
* 设置标注器是否加载完成
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
setLoaded(loaded: boolean): void;
/**
* 初始化标注器
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
init(options: IInitOptions): void;
/**
* 设置标注
*/
setLabels(labels: ILabel[]): void;
/**
* 设置表格
*/
setTables(tables: ISafeAny): void;
/**
* 获取表格标注数据
*/
getTableMatrix(): any;
/**
* 设置 Tooltip
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
hoverInLabels(event: IHoverInLabelsEvent | null): void;
/**
* 设置分页
*/
setPagination(pagination: Partial<IPagination>): void;
/**
* 获取分页信息
*/
getPagination(): IPagination;
/**
* 设置分页(内部调用)
* @description 同外部调用区别是,它不需要通知标注器更新,最好不要在外部调用,这可能会产生不可预期的效果
*/
innerSetPagination(pagination: Partial<IPagination>): void;
/**
* 设置缩放
*/
setZoom(zoom: number): void;
/**
* 获取缩放
*/
getZoom(): number;
/**
* 设置标注模式
*/
setLabelMode(mode: LabelTextMode | LabelTableMode): void;
/**
* 设置PDF模式
*/
setPdfMode(mode: PdfMode): void;
/**
* 打印日志
*/
setLog(log: {
level: string;
content: string;
}): void;
/**
* 开始标注
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
startLabeling(labeling: ILabelingEvent): void;
/**
* 清除当前标注
*/
stopLabeling(): void;
/**
* 删除标注
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
deleteLabels(event: IDeleteLabelsEvent | null): void;
/**
* 搜索
*/
search(params: ISerarchParams): void;
/**
* 设置搜索结果
*/
setSearchResult(result: ISearchResult): void;
/**
* 强制标注器重新渲染
*/
restore(): void;
/**
* 跳转到某个标签
*/
scrollToLabelByUuid(params: ISearchLabelByUuidParams): void;
/**
* 通过索引跳转到某个标签
*/
scrollToLabelByIndex(params: ISearchLabelByIndexParams): void;
/**
* 通过坐标跳转到表格单元格
*/
scrollToTableCell(params?: ISearchTableCellParams | ISearchTableCellParams[]): void;
/**
* 聚焦已高亮的单元格
*/
focusTableCells(params: ISearchTableCellParams | ISearchTableCellParams[]): void;
/**
* 获取页面的显示相关信息
*/
getViewport(): IViewPort[];
/**
* 获取所有被选中的 Labels
*/
getSelectedLabels(): ILabel[];
setApi(api: ISafeAny): void;
/**
* 重置已渲染标注填充色和边框
*/
resetLabelsStyle(params: ILabelStyle[]): void;
/**
* 重置选中的标注
*/
resetSelectedLabels(params: Required<ILabelStyle>[]): void;
/**
* 获取文档文本内容
*/
getDocContent(): string;
/**
* enable merge|split cross page tables
*/
enableMergeOrSplitTables(enable?: boolean): void;
/**
* scroll to rect
*/
scrollToRect(params: ISearchRectParams | ISearchRectParams[]): void;
/**
* get split line info
*/
getTableSplitLines(): ITableSplit[];
/**
* redirect to specific table status ( will reset table operation records )
*/
redirectToRecord(recordId: string): void;
/**
* delete table operation records
*/
deleteTblRecords(recordIds: string | string[]): void;
/**
* ignore table operations
*/
ignoreTblOperations(params: LabelTableMode[]): void;
/**
* get modified table line matrix
*/
getModifiedTableLinesMatrix(): IModifiedTableLineMatrix[];
/**
* 销毁 Hub
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
destory(): void;
}
export {};