@bixi/label
Version:
1,983 lines (1,978 loc) • 72.8 kB
JavaScript
import { DragDropModule } from '@angular/cdk/drag-drop';
import { OverlayModule } from '@angular/cdk/overlay';
import { CommonModule } from '@angular/common';
import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, Input, ViewChild, ViewContainerRef, Output, NgModule } from '@angular/core';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzPopoverModule } from 'ng-zorro-antd/popover';
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
import { DomSanitizer } from '@angular/platform-browser';
import { BehaviorSubject, Subject, Subscription } from 'rxjs';
import { filter, delayWhen } from 'rxjs/operators';
import { __spread, __assign, __decorate, __metadata } from 'tslib';
import { POSITION_MAP, DEFAULT_TOOLTIP_POSITIONS } from 'ng-zorro-antd/core/overlay';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var PREFIX = 'BIXI';
/** @type {?} */
var EVENTS = {
ready: PREFIX + "_READY",
startLabeling: PREFIX + "_START_LABELING",
deleteLabels: PREFIX + "_DELETE_LABELS",
paginationChange: PREFIX + "_PAGINATION_CHANGE",
zoomChange: PREFIX + "_ZOOM_CHANGE",
searchResult: PREFIX + "_SEARCH_RESULT",
clickLabels: PREFIX + "_CLICK_LABELS",
hoverInLabel: PREFIX + "_HOVER_IN_LABEL",
hoverOutLabel: PREFIX + "_HOVER_OUT_LABEL",
pdfScrolling: PREFIX + "_PDF_SCROLLING",
pdfLoadFailed: PREFIX + "_PDF_LOAD_FAILED",
resize: PREFIX + "_resize",
log: PREFIX + "_LOG",
mergeTables: PREFIX + "_MERGE_TABLES",
splitTable: PREFIX + "_SPLIT_TABLE",
tblOperationRecords: PREFIX + "_TABLE_OPERATION_RECORDS"
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function ILabel() { }
if (false) {
/** @type {?|undefined} */
ILabel.prototype.uuid;
/** @type {?|undefined} */
ILabel.prototype.tagId;
/** @type {?|undefined} */
ILabel.prototype.stroke;
/** @type {?|undefined} */
ILabel.prototype.fill;
/** @type {?} */
ILabel.prototype.index;
/** @type {?} */
ILabel.prototype.word;
/** @type {?|undefined} */
ILabel.prototype.selected;
/** @type {?|undefined} */
ILabel.prototype.direction;
}
/**
* @record
*/
function ILabelStyle() { }
if (false) {
/** @type {?} */
ILabelStyle.prototype.uuid;
/** @type {?|undefined} */
ILabelStyle.prototype.fill;
/** @type {?|undefined} */
ILabelStyle.prototype.stroke;
}
/**
* @record
*/
function ISerarchParams() { }
if (false) {
/** @type {?} */
ISerarchParams.prototype.keyword;
/** @type {?} */
ISerarchParams.prototype.caseSensitive;
}
/**
* @record
*/
function ISearchResult() { }
if (false) {
/** @type {?|undefined} */
ISearchResult.prototype.result;
}
/**
* @record
*/
function IClickMetadata() { }
if (false) {
/** @type {?} */
IClickMetadata.prototype.altKey;
/** @type {?} */
IClickMetadata.prototype.ctrlKey;
/** @type {?} */
IClickMetadata.prototype.metaKey;
/** @type {?} */
IClickMetadata.prototype.shiftKey;
/** @type {?} */
IClickMetadata.prototype.which;
}
/**
* @record
*/
function ILabelsEvent() { }
if (false) {
/** @type {?} */
ILabelsEvent.prototype.data;
/** @type {?} */
ILabelsEvent.prototype.position;
}
/**
* @record
*/
function IClickLabelsEvent() { }
if (false) {
/** @type {?} */
IClickLabelsEvent.prototype.metadata;
}
/**
* @record
*/
function IPagination() { }
if (false) {
/** @type {?} */
IPagination.prototype.pageNumber;
/** @type {?} */
IPagination.prototype.pageCount;
}
/**
* @record
*/
function IInitOptions() { }
if (false) {
/** @type {?} */
IInitOptions.prototype.id;
/** @type {?} */
IInitOptions.prototype.pdfUrl;
/** @type {?} */
IInitOptions.prototype.pdfInfoUrl;
/** @type {?} */
IInitOptions.prototype.pdfCharsUrl;
/** @type {?} */
IInitOptions.prototype.pdfMode;
/** @type {?} */
IInitOptions.prototype.labelMode;
/** @type {?|undefined} */
IInitOptions.prototype.pdfSize;
/** @type {?|undefined} */
IInitOptions.prototype.labels;
/** @type {?|undefined} */
IInitOptions.prototype.tables;
}
/**
* @record
*/
function ISearchLabelByUuidParams() { }
if (false) {
/** @type {?} */
ISearchLabelByUuidParams.prototype.uuid;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.pageNumber;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.isHighlight;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.level;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.offsetTop;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.stroke;
/** @type {?|undefined} */
ISearchLabelByUuidParams.prototype.fill;
}
/**
* @record
*/
function ISearchLabelByIndexParams() { }
if (false) {
/** @type {?} */
ISearchLabelByIndexParams.prototype.index;
/** @type {?|undefined} */
ISearchLabelByIndexParams.prototype.word;
/** @type {?|undefined} */
ISearchLabelByIndexParams.prototype.isHighlight;
/** @type {?|undefined} */
ISearchLabelByIndexParams.prototype.level;
/** @type {?|undefined} */
ISearchLabelByIndexParams.prototype.offsetTop;
}
/**
* @record
*/
function ISearchTableCellParams() { }
if (false) {
/** @type {?} */
ISearchTableCellParams.prototype.pageNumber;
/** @type {?} */
ISearchTableCellParams.prototype.tableId;
/** @type {?} */
ISearchTableCellParams.prototype.x;
/** @type {?} */
ISearchTableCellParams.prototype.y;
/** @type {?|undefined} */
ISearchTableCellParams.prototype.word;
/** @type {?|undefined} */
ISearchTableCellParams.prototype.fontSize;
/** @type {?|undefined} */
ISearchTableCellParams.prototype.scale;
/** @type {?|undefined} */
ISearchTableCellParams.prototype.fill;
}
/**
* @record
*/
function IViewPort() { }
if (false) {
/** @type {?} */
IViewPort.prototype.height;
/** @type {?} */
IViewPort.prototype.left;
/** @type {?} */
IViewPort.prototype.scale;
/** @type {?} */
IViewPort.prototype.top;
/** @type {?} */
IViewPort.prototype.width;
/** @type {?} */
IViewPort.prototype.zoom;
}
/**
* @record
*/
function ITableMatrix() { }
if (false) {
/** @type {?} */
ITableMatrix.prototype.tableId;
/** @type {?} */
ITableMatrix.prototype.type;
/** @type {?} */
ITableMatrix.prototype.pageNumber;
/** @type {?} */
ITableMatrix.prototype.area;
/** @type {?} */
ITableMatrix.prototype.lines;
/** @type {?} */
ITableMatrix.prototype.detail;
}
/** @enum {string} */
var LabelTextMode = {
/**
* 禁止标注
*/
non: 'non',
/**
* 划选
*/
textSlip: 'textSlip',
/**
* 框选
*/
textFrame: 'textFrame',
/**
* 组合
*/
textGroup: 'textGroup',
};
/** @enum {string} */
var LabelTableMode = {
/**
* 新增表格
*/
tableAddTbl: 'tableAddTbl',
/**
* 调整表格
*/
tableResizeTbl: 'tableResizeTbl',
/**
* 删除表格
*/
tableDelTbl: 'tableDelTbl',
/**
* 横向拆分表格
*/
tableHSplitTbl: 'tableHSplitTbl',
/**
* 纵向拆分表格
*/
tableVSplitTbl: 'tableVSplitTbl',
/**
* 增加横线
*/
tableAddHLine: 'tableAddHLine',
/**
* 增加竖线
*/
tableAddVLine: 'tableAddVLine',
/**
* 增加表格线 (任意长度)
*/
tableAddLine: 'tableAddLine',
/**
* 调整线条
*/
tableResizeCell: 'tableResizeCell',
/**
* 删除线
*/
tableDelLine: 'tableDelLine',
/**
* 删除单元格线
*/
tableDelCellLine: 'tableDelCellLine',
/**
* 合并单元格
*/
tableMergeCell: 'tableMergeCell',
/**
* 拆分单元格
*/
tableSplitCell: 'tableSplitCell',
/**
* 选择单元格
*/
tableSelectCells: 'tableSelectCells',
/**
* 隐藏框线
*/
tableHideTable: 'tableHideTable',
/**
* 显示框线
*/
tableShowTable: 'tableShowTable',
/**
* 选择表格
*/
selectTables: 'tableSelectTables',
/**
* 合并表格
*/
mergeTables: 'tableMergeTables',
/**
* 拆分表格
*/
splitTables: 'tableSplitTables',
/**
* 禁止表格操作
*/
tableNon: 'tableNon',
};
/** @enum {string} */
var PdfMode = {
/**
* 全部功能
*/
full: 'full',
/**
* 只读
*/
readonly: 'readonly',
/**
* 只删
*/
deleteonly: 'deleteonly',
/**
* 预览(只能查看pdf文档)
*/
preview: 'preview',
};
/**
* @record
*/
function ISearchRectParams() { }
if (false) {
/** @type {?} */
ISearchRectParams.prototype.x1;
/** @type {?} */
ISearchRectParams.prototype.y1;
/** @type {?} */
ISearchRectParams.prototype.x2;
/** @type {?} */
ISearchRectParams.prototype.y2;
/** @type {?} */
ISearchRectParams.prototype.pageNumber;
/** @type {?|undefined} */
ISearchRectParams.prototype.stroke;
/** @type {?|undefined} */
ISearchRectParams.prototype.fill;
}
/**
* @record
*/
function ITableSplit() { }
if (false) {
/** @type {?} */
ITableSplit.prototype.page_number;
/** @type {?} */
ITableSplit.prototype.table_id;
/** @type {?} */
ITableSplit.prototype.split_lines;
}
/**
* @record
*/
function ITableOperationRecord() { }
if (false) {
/** @type {?} */
ITableOperationRecord.prototype.id;
/** @type {?} */
ITableOperationRecord.prototype.type;
}
/**
* @record
*/
function IModifiedTableLineMatrix() { }
if (false) {
/** @type {?} */
IModifiedTableLineMatrix.prototype.table_id;
/** @type {?} */
IModifiedTableLineMatrix.prototype.page_number;
/** @type {?} */
IModifiedTableLineMatrix.prototype.lines;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} origin
* @return {?}
*/
function functionProxy(origin) {
/** @type {?} */
var obj = [
'init',
'setPage',
'setZoom',
'setLabelMode',
'setPdfMode',
'setLabels',
'restore',
'search',
'scrollToLabel',
'scrollToLabelByIdx',
'scrollToTableCell',
'setTables',
'getTableMatrix',
'getViewport',
'getSelectedLabels',
'resetLabelsStyle',
'resetSelectedLabels',
'getDocContent',
'enableMergeOrSplitTables',
'scrollToRect',
'getTableSplitLines',
'redirectToRecord',
'deleteTblRecords',
'ignoreTblOperations',
'getModifiedTableLinesMatrix',
'focusTableCells'
].reduce((/**
* @param {?} pre
* @param {?} key
* @return {?}
*/
function (pre, key) {
((/** @type {?} */ (pre)))[key] = (/**
* @return {?}
*/
function proxy() {
/** @type {?} */
var timeTag = "Execution Time";
console.group("[@bixi/label] Proxy " + key);
console.log.apply(console, __spread(arguments));
// tslint:disable-next-line: no-console
console.time(timeTag);
/** @type {?} */
var result;
try {
result = origin[key].apply(origin, __spread(arguments));
}
catch (error) {
console.error("[@bixi/label] excute proxy." + key + " failed");
console.error(error);
}
// tslint:disable-next-line: no-console
console.timeEnd(timeTag);
console.groupEnd();
return result;
});
return pre;
}), {});
return obj;
}
/**
* @return {?}
*/
function Log() {
return (/**
* @param {?} _target
* @param {?} _propKey
* @param {?} desc
* @return {?}
*/
function (_target, _propKey, desc) {
return __assign(__assign({}, desc), { value: /**
* @return {?}
*/
function () {
if (((/** @type {?} */ (this))).dev === true) {
console.group("[@bixi/label] hub " + _propKey);
console.log.apply(console, __spread(arguments));
/** @type {?} */
var result = void 0;
// tslint:disable-next-line: no-console
console.time(_propKey);
result = desc.value.bind(this).apply(void 0, __spread(arguments));
// tslint:disable-next-line: no-console
console.timeEnd(_propKey);
console.groupEnd();
return result;
}
return desc.value.bind(this).apply(void 0, __spread(arguments));
} });
});
}
/**
* @return {?}
*/
function Safe() {
return (/**
* @param {?} _target
* @param {?} _propKey
* @param {?} desc
* @return {?}
*/
function (_target, _propKey, desc) {
return __assign(__assign({}, desc), { value: /**
* @return {?}
*/
function () {
if (((/** @type {?} */ (this))).ready === false) {
console.error('[@bixi/label] DANGEROUS!!! Call method before initialization:', _propKey);
return void 0;
}
return desc.value.bind(this).apply(void 0, __spread(arguments));
} });
});
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function IOptions() { }
if (false) {
/** @type {?|undefined} */
IOptions.prototype.dev;
/** @type {?|undefined} */
IOptions.prototype.logUnhandledEvents;
/** @type {?|undefined} */
IOptions.prototype.logAllEvents;
/** @type {?|undefined} */
IOptions.prototype.logIgnoreEvents;
}
var LabelHub = /** @class */ (function () {
function LabelHub(options) {
this._hoverInLabelsEvent = null;
this._labelingEvent = null;
this._dev = false;
this._logUnhandledEvents = false;
this._logAllEvents = false;
this._logIgnoreEvents = [];
this._ready = false;
this._loaded = false;
this._zoom = 1;
this._pagination = {
pageCount: 1,
pageNumber: 1
};
/**
* 标注器是否加载完成
*/
this.loaded$ = new BehaviorSubject(this._loaded);
/**
* 标注器是否准备完毕
*/
this.ready$ = new BehaviorSubject(this._ready);
/**
* 初始化数据流
*/
this.init$ = new BehaviorSubject(null);
/**
* 搜索结果
*/
this.searchResult$ = new BehaviorSubject({
keyword: '',
caseSensitive: false,
result: []
});
/**
* Tooltip 信息
*/
this.hoverInLabelsEvent$ = new Subject();
/**
* 分页信息
* 默认
* {
* page: 1,
* total: 1
* }
*/
this.pagination$ = new BehaviorSubject(this._pagination);
/**
* 缩放
*/
this.zoom$ = new BehaviorSubject(this._zoom);
/**
* 标注列表
*/
this.labels$ = new BehaviorSubject(null);
/**
* 表格列表
*/
this.tables$ = new BehaviorSubject(null);
/**
* 删除标注
*/
this.deleteLabelsEvent$ = new Subject();
/**
* 当前正在标注的标注
*/
this.labelingEvent$ = new Subject();
/**
* 尺寸变化
*/
this.resize$ = new Subject();
/**
* 日志流
*/
this.log$ = new Subject();
this._dev = (options === null || options === void 0 ? void 0 : options.dev) || false;
this._logUnhandledEvents = (options === null || options === void 0 ? void 0 : options.logUnhandledEvents) || false;
this._logAllEvents = (options === null || options === void 0 ? void 0 : options.logAllEvents) || false;
this._logIgnoreEvents = (options === null || options === void 0 ? void 0 : options.logIgnoreEvents) || [];
}
Object.defineProperty(LabelHub.prototype, "ready", {
get: /**
* @return {?}
*/
function () {
return this._ready;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "dev", {
get: /**
* @return {?}
*/
function () {
return this._dev;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "api", {
get: /**
* @return {?}
*/
function () {
return this._api;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "loaded", {
get: /**
* @return {?}
*/
function () {
return this._loaded;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "logUnhandledEvents", {
get: /**
* @return {?}
*/
function () {
return this._logUnhandledEvents;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "logAllEvents", {
get: /**
* @return {?}
*/
function () {
return this._logAllEvents;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "logIgnoreEvents", {
get: /**
* @return {?}
*/
function () {
return this._logIgnoreEvents;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "hoverInLabelsEvent", {
get: /**
* @return {?}
*/
function () {
return this._hoverInLabelsEvent;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "labelingEvent", {
get: /**
* @return {?}
*/
function () {
return this._labelingEvent;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LabelHub.prototype, "labeling", {
get: /**
* @return {?}
*/
function () {
return !!this._labelingEvent;
},
enumerable: true,
configurable: true
});
/**
* 设置标注器是否准备完毕
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 设置标注器是否准备完毕
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} ready
* @return {?}
*/
LabelHub.prototype.setReady = /**
* 设置标注器是否准备完毕
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} ready
* @return {?}
*/
function (ready) {
this._ready = ready;
this.ready$.next(this._ready);
};
/**
* 设置标注器是否加载完成
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 设置标注器是否加载完成
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} loaded
* @return {?}
*/
LabelHub.prototype.setLoaded = /**
* 设置标注器是否加载完成
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} loaded
* @return {?}
*/
function (loaded) {
this._loaded = loaded;
this.loaded$.next(this._loaded);
};
/**
* 初始化标注器
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 初始化标注器
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} options
* @return {?}
*/
LabelHub.prototype.init = /**
* 初始化标注器
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} options
* @return {?}
*/
function (options) {
this.id = options.id;
// if ([LabelTextMode.textSlip, LabelTextMode.textFrame].includes(options.labelMode as LabelTextMode)) {
if (options.labelMode in LabelTextMode) {
if (options.labels) {
this.setLabels(options.labels);
}
}
else {
if (options.tables) {
this.setTables(options.tables);
}
}
this.init$.next(options);
};
/**
* 设置标注
*/
/**
* 设置标注
* @param {?} labels
* @return {?}
*/
LabelHub.prototype.setLabels = /**
* 设置标注
* @param {?} labels
* @return {?}
*/
function (labels) {
this.labels$.next(labels);
};
/**
* 设置表格
*/
/**
* 设置表格
* @param {?} tables
* @return {?}
*/
LabelHub.prototype.setTables = /**
* 设置表格
* @param {?} tables
* @return {?}
*/
function (tables) {
this.tables$.next(tables);
};
/**
* 获取表格标注数据
*/
/**
* 获取表格标注数据
* @return {?}
*/
LabelHub.prototype.getTableMatrix = /**
* 获取表格标注数据
* @return {?}
*/
function () {
return this._api.getTableMatrix();
};
/**
* 设置 Tooltip
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 设置 Tooltip
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} event
* @return {?}
*/
LabelHub.prototype.hoverInLabels = /**
* 设置 Tooltip
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} event
* @return {?}
*/
function (event) {
this._hoverInLabelsEvent = event;
this.hoverInLabelsEvent$.next(event);
};
/**
* 设置分页
*/
/**
* 设置分页
* @param {?} pagination
* @return {?}
*/
LabelHub.prototype.setPagination = /**
* 设置分页
* @param {?} pagination
* @return {?}
*/
function (pagination) {
/** @type {?} */
var p = __assign(__assign({}, this._pagination), pagination);
if (p.pageCount < p.pageNumber || p.pageNumber < 1)
return;
this.pagination$.next(p);
if (this._pagination.pageNumber !== pagination.pageNumber) {
this._api.setPage(pagination.pageNumber);
}
this._pagination = p;
};
/**
* 获取分页信息
*/
/**
* 获取分页信息
* @return {?}
*/
LabelHub.prototype.getPagination = /**
* 获取分页信息
* @return {?}
*/
function () {
return this._pagination;
};
/**
* 设置分页(内部调用)
* @description 同外部调用区别是,它不需要通知标注器更新,最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 设置分页(内部调用)
* \@description 同外部调用区别是,它不需要通知标注器更新,最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} pagination
* @return {?}
*/
LabelHub.prototype.innerSetPagination = /**
* 设置分页(内部调用)
* \@description 同外部调用区别是,它不需要通知标注器更新,最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} pagination
* @return {?}
*/
function (pagination) {
this._pagination = __assign(__assign({}, this._pagination), pagination);
this.pagination$.next(this._pagination);
};
/**
* 设置缩放
*/
/**
* 设置缩放
* @param {?} zoom
* @return {?}
*/
LabelHub.prototype.setZoom = /**
* 设置缩放
* @param {?} zoom
* @return {?}
*/
function (zoom) {
if (this._zoom !== zoom) {
this._zoom = zoom;
this.zoom$.next(zoom);
this._api.setZoom(zoom);
}
};
/**
* 获取缩放
*/
/**
* 获取缩放
* @return {?}
*/
LabelHub.prototype.getZoom = /**
* 获取缩放
* @return {?}
*/
function () {
return this._zoom;
};
/**
* 设置标注模式
*/
/**
* 设置标注模式
* @param {?} mode
* @return {?}
*/
LabelHub.prototype.setLabelMode = /**
* 设置标注模式
* @param {?} mode
* @return {?}
*/
function (mode) {
this._api.setLabelMode(mode);
};
/**
* 设置PDF模式
*/
/**
* 设置PDF模式
* @param {?} mode
* @return {?}
*/
LabelHub.prototype.setPdfMode = /**
* 设置PDF模式
* @param {?} mode
* @return {?}
*/
function (mode) {
this._api.setPdfMode(mode);
};
/**
* 打印日志
*/
/**
* 打印日志
* @param {?} log
* @return {?}
*/
LabelHub.prototype.setLog = /**
* 打印日志
* @param {?} log
* @return {?}
*/
function (log) {
var level = log.level, content = log.content;
// tslint:disable-next-line: no-any
/** @type {?} */
var logger = ((/** @type {?} */ (console)))[level];
if (logger) {
logger(content);
}
else {
console.error('[@bixi/label] 没有找到对应的日志等级', level, content);
}
this.log$.next({
level: level,
content: content
});
};
/**
* 开始标注
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 开始标注
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} labeling
* @return {?}
*/
LabelHub.prototype.startLabeling = /**
* 开始标注
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} labeling
* @return {?}
*/
function (labeling) {
this._labelingEvent = labeling;
this.labelingEvent$.next(labeling);
};
/**
* 清除当前标注
*/
/**
* 清除当前标注
* @return {?}
*/
LabelHub.prototype.stopLabeling = /**
* 清除当前标注
* @return {?}
*/
function () {
if (!this._labelingEvent)
return;
this._labelingEvent = null;
this.labelingEvent$.next(null);
};
/**
* 删除标注
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 删除标注
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} event
* @return {?}
*/
LabelHub.prototype.deleteLabels = /**
* 删除标注
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @param {?} event
* @return {?}
*/
function (event) {
this.deleteLabelsEvent$.next(event);
};
/**
* 搜索
*/
/**
* 搜索
* @param {?} params
* @return {?}
*/
LabelHub.prototype.search = /**
* 搜索
* @param {?} params
* @return {?}
*/
function (params) {
this._api.search(params);
};
/**
* 设置搜索结果
*/
/**
* 设置搜索结果
* @param {?} result
* @return {?}
*/
LabelHub.prototype.setSearchResult = /**
* 设置搜索结果
* @param {?} result
* @return {?}
*/
function (result) {
this.searchResult$.next(result);
};
/**
* 强制标注器重新渲染
*/
/**
* 强制标注器重新渲染
* @return {?}
*/
LabelHub.prototype.restore = /**
* 强制标注器重新渲染
* @return {?}
*/
function () {
this._api.restore();
};
/**
* 跳转到某个标签
*/
/**
* 跳转到某个标签
* @param {?} params
* @return {?}
*/
LabelHub.prototype.scrollToLabelByUuid = /**
* 跳转到某个标签
* @param {?} params
* @return {?}
*/
function (params) {
this._api.scrollToLabel(params);
};
/**
* 通过索引跳转到某个标签
*/
/**
* 通过索引跳转到某个标签
* @param {?} params
* @return {?}
*/
LabelHub.prototype.scrollToLabelByIndex = /**
* 通过索引跳转到某个标签
* @param {?} params
* @return {?}
*/
function (params) {
this._api.scrollToLabelByIdx(params);
};
/**
* 通过坐标跳转到表格单元格
*/
/**
* 通过坐标跳转到表格单元格
* @param {?=} params
* @return {?}
*/
LabelHub.prototype.scrollToTableCell = /**
* 通过坐标跳转到表格单元格
* @param {?=} params
* @return {?}
*/
function (params) {
this._api.scrollToTableCell(params);
};
/**
* 聚焦已高亮的单元格
*/
/**
* 聚焦已高亮的单元格
* @param {?} params
* @return {?}
*/
LabelHub.prototype.focusTableCells = /**
* 聚焦已高亮的单元格
* @param {?} params
* @return {?}
*/
function (params) {
this._api.focusTableCells(params);
};
/**
* 获取页面的显示相关信息
*/
/**
* 获取页面的显示相关信息
* @return {?}
*/
LabelHub.prototype.getViewport = /**
* 获取页面的显示相关信息
* @return {?}
*/
function () {
return this._api.getViewport();
};
/**
* 获取所有被选中的 Labels
*/
/**
* 获取所有被选中的 Labels
* @return {?}
*/
LabelHub.prototype.getSelectedLabels = /**
* 获取所有被选中的 Labels
* @return {?}
*/
function () {
return this._api.getSelectedLabels();
};
/**
* @param {?} api
* @return {?}
*/
LabelHub.prototype.setApi = /**
* @param {?} api
* @return {?}
*/
function (api) {
this._api = api;
};
/**
* 重置已渲染标注填充色和边框
*/
/**
* 重置已渲染标注填充色和边框
* @param {?} params
* @return {?}
*/
LabelHub.prototype.resetLabelsStyle = /**
* 重置已渲染标注填充色和边框
* @param {?} params
* @return {?}
*/
function (params) {
this._api.resetLabelsStyle(params);
};
/**
* 重置选中的标注
*/
/**
* 重置选中的标注
* @param {?} params
* @return {?}
*/
LabelHub.prototype.resetSelectedLabels = /**
* 重置选中的标注
* @param {?} params
* @return {?}
*/
function (params) {
this._api.resetSelectedLabels(params);
};
/**
* 获取文档文本内容
*/
/**
* 获取文档文本内容
* @return {?}
*/
LabelHub.prototype.getDocContent = /**
* 获取文档文本内容
* @return {?}
*/
function () {
return this._api.getDocContent();
};
/**
* enable merge|split cross page tables
*/
/**
* enable merge|split cross page tables
* @param {?=} enable
* @return {?}
*/
LabelHub.prototype.enableMergeOrSplitTables = /**
* enable merge|split cross page tables
* @param {?=} enable
* @return {?}
*/
function (enable) {
if (enable === void 0) { enable = false; }
this._api.enableMergeOrSplitTables(enable);
};
/**
* scroll to rect
*/
/**
* scroll to rect
* @param {?} params
* @return {?}
*/
LabelHub.prototype.scrollToRect = /**
* scroll to rect
* @param {?} params
* @return {?}
*/
function (params) {
this._api.scrollToRect(params);
};
/**
* get split line info
*/
/**
* get split line info
* @return {?}
*/
LabelHub.prototype.getTableSplitLines = /**
* get split line info
* @return {?}
*/
function () {
return this._api.getTableSplitLines();
};
/**
* redirect to specific table status ( will reset table operation records )
*/
/**
* redirect to specific table status ( will reset table operation records )
* @param {?} recordId
* @return {?}
*/
LabelHub.prototype.redirectToRecord = /**
* redirect to specific table status ( will reset table operation records )
* @param {?} recordId
* @return {?}
*/
function (recordId) {
this._api.redirectToRecord(recordId);
};
/**
* delete table operation records
*/
/**
* delete table operation records
* @param {?} recordIds
* @return {?}
*/
LabelHub.prototype.deleteTblRecords = /**
* delete table operation records
* @param {?} recordIds
* @return {?}
*/
function (recordIds) {
this._api.deleteTblRecords(recordIds);
};
/**
* ignore table operations
*/
/**
* ignore table operations
* @param {?} params
* @return {?}
*/
LabelHub.prototype.ignoreTblOperations = /**
* ignore table operations
* @param {?} params
* @return {?}
*/
function (params) {
this._api.setIgnoreTblOperations(params);
};
/**
* get modified table line matrix
*/
/**
* get modified table line matrix
* @return {?}
*/
LabelHub.prototype.getModifiedTableLinesMatrix = /**
* get modified table line matrix
* @return {?}
*/
function () {
return this._api.getModifiedTableLinesMatrix();
};
/**
* 销毁 Hub
* @description 最好不要在外部调用,这可能会产生不可预期的效果
*/
/**
* 销毁 Hub
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @return {?}
*/
LabelHub.prototype.destory = /**
* 销毁 Hub
* \@description 最好不要在外部调用,这可能会产生不可预期的效果
* @return {?}
*/
function () {
this.loaded$.complete();
this.ready$.complete();
this.init$.complete();
this.searchResult$.complete();
this.hoverInLabelsEvent$.complete();
this.pagination$.complete();
this.zoom$.complete();
this.labels$.complete();
this.tables$.complete();
this.deleteLabelsEvent$.complete();
this.labelingEvent$.complete();
this.log$.complete();
};
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Boolean]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setReady", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Boolean]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setLoaded", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "init", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setLabels", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setTables", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "getTableMatrix", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "hoverInLabels", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setPagination", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Object)
], LabelHub.prototype, "getPagination", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "innerSetPagination", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setZoom", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Number)
], LabelHub.prototype, "getZoom", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setLabelMode", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setPdfMode", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setLog", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "startLabeling", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "stopLabeling", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "deleteLabels", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "search", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "setSearchResult", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "restore", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "scrollToLabelByUuid", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "scrollToLabelByIndex", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "scrollToTableCell", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "focusTableCells", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Array)
], LabelHub.prototype, "getViewport", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Array)
], LabelHub.prototype, "getSelectedLabels", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "resetLabelsStyle", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "resetSelectedLabels", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", String)
], LabelHub.prototype, "getDocContent", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "enableMergeOrSplitTables", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "scrollToRect", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Array)
], LabelHub.prototype, "getTableSplitLines", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "redirectToRecord", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "deleteTblRecords", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "ignoreTblOperations", null);
__decorate([
Log(),
Safe(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Array)
], LabelHub.prototype, "getModifiedTableLinesMatrix", null);
__decorate([
Log(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LabelHub.prototype, "destory", null);
return LabelHub;
}());
if (false) {
/** @type {?} */
LabelHub.prototype.id;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._hoverInLabelsEvent;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._labelingEvent;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._dev;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._logUnhandledEvents;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._logAllEvents;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._logIgnoreEvents;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._api;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._ready;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._loaded;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._zoom;
/**
* @type {?}
* @protected
*/
LabelHub.prototype._pagination;
/**
* 标注器是否加载完成
* @type {?}
*/
LabelHub.prototype.loaded$;
/**
* 标注器是否准备完毕
* @type {?}
*/
LabelHub.prototype.ready$;
/**
* 初始化数据流
* @type {?}
*/
LabelHub.prototype.init$;
/**
* 搜索结果
* @type {?}
*/
LabelHub.prototype.searchResult$;
/**
* Tooltip 信息
* @type {?}
*/
LabelHub.prototype.hoverInLabelsEvent$;
/**
* 分页信息
* 默认
* {
* page: 1,
* total: 1
* }
* @type {?}
*/
LabelHub.prototype.pagination$;
/**
* 缩放
* @type {?}
*/
LabelHub.prototype.zoom$;
/**
* 标注列表
* @type {?}
*/
LabelHub.prototype.labels$;
/**
* 表格列表
* @type {?}
*/
LabelHub.prototype.tables$;
/**
* 删除标注
* @type {?}
*/
LabelHub.prototype.deleteLabelsEvent$;
/**
* 当前正在标注的标注
* @type {?}
*/
LabelHub.prototype.labelingEvent$;
/**
* 尺寸变化
* @type {?}
*/
LabelHub.prototype.resize$;
/**
* 日志流
* @type {?}
*/
LabelHub.prototype.log$;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var BixiLabelCoreComponent = /** @class */ (function () {
function BixiLabelCoreComponent(sanitizer, cdr) {
var _this = this;
this.sanitizer = sanitizer;
this.cdr = cdr;
this.subscription = new Subscription();
this.hoverInLabelsEvent = null;
this.labelingEvent = null;
this.labelTooltipDisabled = false;
this.labelModalDisabled = false;
this.startLabeling = new EventEmitter();
this.deleteLabels = new EventEmitter();
this.clickLabels = new EventEmitter();
this.pdfLoadFailed = new EventEmitter();
this.pdfScrolling = new EventEmitter();
this.mergeTables = new EventEmitter();
this.splitTable = new EventEmitter();
this.tblOperationRecords = new EventEmitter();
this.messageHandler = (/**
* @param {?} e
* @return {?}
*/
function (e) {
var _a = e.data, id = _a.id, event = _a.event, data = _a.data;
if (_this.hub.id !== id)
return;
if (_this.hub.logAllEvents) {
if (!_this.hub.logIgnoreEvents.includes(event)) {
console.log("[@bixi/label] Event(" + _this.hub.id + ")", e.data);
}
}
switch (event) {
case EVENTS.ready: {
// 初始化标注器
_this.hub.setReady(true);
_this.hub.innerSetPagination({
pageCount: data.pageCount
});
break;
}
case EVENTS.zoomChange: {
_this.hub.setZoom(data.zoom);
break;
}
case EVENTS.startLabeling: {
_this.hub.startLabeling(data);
_this.startLabeling.emit(data);
break;
}
case EVENTS.deleteLabels: {
_this.hub.deleteLabels(data);
_this.deleteLabels.emit(data);
break;
}
case EVENTS.paginationChange: {
_this.hub.innerSetPagination({
pageNumber: data.pageNumber
});
break;
}
case EVENTS.searchResult: {
_this.hub.setSearchResult(data);
break;
}
case EVENTS.clickLabels: {
_this.clickLabels.emit(data);
break;
}
case EVENTS.hoverInLabel: {
_this.hub.hoverInLabels(data);
break;
}
case EVENTS.hoverOutLabel: {
_this.hub.hoverInLabels(null);
break;
}
case EVENTS.pdfScrolling: {
if (_this.hub.hoverInLabelsEvent) {
_this.hub.hoverInLabels(null);
}
_this.pdfScrolling.emit(true);
break;
}
case EVENTS.pdfLoadFailed: {
_this.pdfLoadFailed.emit();
break;
}
case EVENTS.log: {
_this.hub.setLog(data);
break;
}
case EVENTS.resize: {
_this.hub.resize$.next();
break;
}
case EVENTS.mergeTables: {
_this.mergeTables.emit(data);
break;
}
case EVENTS.splitTable: {
_this.splitTable.emit(data);
break;
}
case EVENTS.tblOperationRecords: {
_this.tblOperationRecords.emit(data);
break;
}
default: {
if (_this.hub.logUnhandledEvents) {
if (!_this.hub.logIgnoreEvents.includes(event)) {
console.warn("[@bixi/label] Unhandled Event(" + _this.hub.id + ") ", event, data);
}
}
break;
}
}
});
}
Object.defineProperty(BixiLabelCoreComponent.prototype, "engine", {
get: /**
* @return {?}
*/
function () {
return this._engine;
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
this.url = this.sanitizer.bypassSecurityTrustResourceUrl("" + (val || './bixi-label/index.html'));
this._engine = val;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
BixiLabelCoreComponent.prototype.onLoad = /**
* @return {?}
*/
function () {
if (!this.hub)
return;
/** @type {?} */
var api = this.api;
this.hub.setApi(api);
this.hub.setLoaded(!!api);
};
Object.defineProperty(BixiLabelCoreComponent.prototype, "api", {
get: /**
* @return {?}
*/
function () {
if (!this.iframe)
return;
/** @type {?} */
var service = this.iframe.element.nativeElement.contentWindow.ProxyApiService2;
if