9.9.9-beta6 • Published 3 years ago

@bixi/label v9.9.9-beta6

Weekly downloads
306
License
MIT
Repository
-
Last release
3 years ago

快速开始

##1. 安装依赖

yarn add @bixi/label

2. 修改 angular.json

{
  "architect": {
    "build": {
      "options": {
        "assets": [
          {
            "glob": "**/*",
            "input": "node_modules/@bixi/label/engine",
            "output": "/bixi-label-engine"
          }
        ]
      }
    }    
  }
}

3. 模块注册

import { BixiLabelModule } from '@bixi/label';

@NgModule({
  imports: [
    BixiLabelModule,
  ]
})
export class SharedModule { }

4. 组件使用

示例代码

设计理念

Label Engine

标注引擎(通过 iframe 引入), 只负责单纯做两件的事:

  1. 标注图层的渲染
  2. 标注事件的监听

Label Hub

在使用标注器组件时候你需要先实例化一个标注控制器,然后将其传入标注组件,之后标注的所有事件都将会被它所接管,就像这样

import { LabelHub } from '@bixi/label';

@Component({
  template: `
  <bixi-label-core
    engine="./source/index.html"
    [hub]="hub">
  </bixi-label-core>`
})
export class LabelHubDemoComponent{
  hub = new LabelHub({
    dev: true,
  });
}

对于业务组件而言, LabelHub 就像是一个邮局,它可以告诉你有哪些事件发生,也允许你主动往它上面投递事件等待引擎处理,比如

export class LabelHubDemoComponent{
  hub = new LabelHub({
    dev: true,
  });

  ngOnInit() {
    this.hub.pagination$.subscribe(({ pageNumber }) => {
      console.warn('内部更改了页码', pageNumber);
    })
  }

  pageChange() {
    // 业务组件主动更改页码
    this.hub.setPagination({
      pageNumber: 2
    });
  }
}

LabelHub 对修改是封闭的,但是对扩展是完全开放的,我们将核心数据都实现了成员保护,只有当你需要完全定制 Hub 的时候,你可以继承它然后扩展它,就像下面这样可以实现 Hook 的功能

import { LabelHub } from '@bixi/label';

export class MyHub extends LabelHub {
  constructor(options) {
    super(options);
  }

  setZoom(zoom) {
    console.warn('set zoom1', zoom);
    this._api.setZoom(zoom);
    console.warn('set zoom2', zoom);
  }
}

但如果像上面这样仅仅是打印日志的话,那么你可以不必这么舍近求远,我们提供了开发模式,丰富的日志可以帮助你快速排查问题,而它仅需要一行配置

hub = new LabelHub({
  dev: true
});

<bixi-label-core />

这是标注引擎的 Angular 封装,同时支持文本和表格标注

标注控制器

构造参数

名称类型描述
devboolean开启开发模式,将会打印所有 hub 的核心方法执行过程,以及执行时间
logUnhandledEventsboolean打印未处理事件
logAllEventsboolean打印所有日志
logIgnoreEventsstring[]忽略的事件

成员属性

名称类型描述
ready$BehaviorSubject<boolean>在标注引擎准备好标注的准备工作后触发
searchResult$BehaviorSubject<ISearchResult>搜索结果
pagination$BehaviorSubject<IPagination>页码
zoom$BehaviorSubject<number>缩放比

成员方法

名称类型描述
init(options: IInitOptions) => void初始化标注器
setLabels(labels: ILabel[]) => void设置标注列表
setTables(labels: any) => void设置表格标注列表
setPagination(pagination: IPagination)=> void修改页码
setZoom(zoom: number) => void修改缩放比
setLabelMode(mode: LabelTextMode | LabelTableMode) => void修改标注模式
setPdfMode(mode: PdfMode) => void修改引擎模式
search(params: ISerarchParams) => void搜索
stopLabeling() => void停止标注
restore() => void丢掉临时标注重新渲染
scrollToLabelByUuid(params: ISearchLabelByUuidParams) => void通过uuid滚动到某个标注
scrollToLabelByIndex(params: ISearchLabelByIndexParams) => void通过索引跳转到某个标注
scrollToTableCell(params: ISearchTableCellParams) => void通过坐标跳转到某个单元格
getTableMatrix() => any获取表格标注数据
getViewport() => IViewPort[]获取页面的显示相关信息
resetLabelsStyle(params: ILabelStyle[]) => void重置已渲染标注填充色和边框
resetSelectedLabels(params: string[]) => void重置选中的标注
getSelectedLabels() => []ILabel获取所有被选中的标注数据
getDocContent() => string获取文档文本内容
enableMergeOrSplitTables(enable = false) => void是否启用跨页表格合并

类型定义

你可以在构建产物中获取类型,以上所有类型均在 @bixi/label 根级目录有导出

import { ILabel } from '@bixi/label';

const labels = ILabel[];

或者直接在源码中查看类型定义

标注组件

这是标注引擎的 Angular 封装,同时支持文本和表格标注

bixi-label-core

成员说明类型默认值
[engine]标注引擎地址string./bixi-label/index.html
[hub]标注器控制器LabelHub-
[labelTooltipContent]Tooltip 内容TemplateRef-
[labelTooltipDisabled]是否禁用 Tooltipbooleanfalse
[labelModalTitle]标注框标题string-
[labelModalContent]标注框内容TemplateRef-
[labelModalDisabled]是否禁用标注框booleanfalse
(startLabeling)开始标注事件EventEmitter<ILabelingEvent>-
(deleteLabels)删除标注事件EventEmitter<IDeleteLabelsEvent>-
(clickLabels)点击标注事件EventEmitter<IClickLabelsEvent>-
(pdfLoadFailed)PDF 加载失败EventEmitter-
(mergeTables)合并跨页表格EventEmitter-
(splitTable)拆分跨页表格EventEmitter-

Type

interface IClickMetadata {
  altKey: boolean;
  ctrlKey: boolean;
  metaKey: boolean;
  shiftKey: boolean;
  which: number;
}

export interface IClickOutsideEvent {
  position: {
    top: number;
    left: number;
  };
  metadata: IClickMetadata;
}

interface ILabelsEvent {
  data: ILabel[];
  position: {
    top: number;
    left: number;
    width: number;
    height: number;
  };
}

export type ILabelingEvent = ILabelsEvent;
export type IDeleteLabelsEvent = ILabelsEvent;
export type IHoverInLabelsEvent = ILabelsEvent;
export interface IClickLabelsEvent extends ILabelsEvent {
  metadata: IClickMetadata;
}
9.9.9-beta6

3 years ago

9.9.9-beta3

3 years ago

9.9.9-beta5

3 years ago

9.9.9-beta2

3 years ago

9.9.9-beta1

3 years ago

9.9.9-alpha9

3 years ago

9.9.9-alpha8

3 years ago

9.9.9-alpha7

3 years ago

9.9.9-alpha6

3 years ago

9.9.9-alpha4

3 years ago

9.9.9-alpha5

3 years ago

9.9.4-alpha

3 years ago

9.9.9-alpha3

3 years ago

9.9.9-alpha2

3 years ago

9.9.9-alpha1

3 years ago

9.9.8-alpha10

3 years ago

9.9.8-alpha9

3 years ago

9.9.8-alpha8

3 years ago

9.9.8-alpha7

3 years ago

9.9.8-alpha6

3 years ago

9.9.8-alpha5

3 years ago

9.9.8-alpha4

3 years ago

9.9.8-alpha3

3 years ago

9.9.8-alpha2

3 years ago

9.9.8-alpha1

3 years ago

9.9.8

3 years ago

9.9.7

3 years ago

9.9.6

3 years ago

9.9.5

3 years ago

9.9.4-alpha1

3 years ago

9.9.4-alpha-IE10

3 years ago

10.0.0-alpha6

3 years ago

10.0.0-alpha1

3 years ago

10.0.1-alpha

3 years ago

10.0.0

3 years ago

9.9.4

3 years ago

9.9.3

4 years ago

10.0.0-alpha5

4 years ago

9.9.2

4 years ago

10.0.0-alpha4

4 years ago

10.0.0-alpha2

4 years ago

10.0.0-alpha3

4 years ago

9.9.1

4 years ago

9.9.0

4 years ago

9.8.5

4 years ago

9.8.4

4 years ago

9.8.3

4 years ago

9.8.2

4 years ago

9.0.0-rc3-patch2

4 years ago

9.9.0-alpha4

4 years ago

9.8.1

4 years ago

9.8.0

4 years ago

9.0.0-rc3-patch

4 years ago

9.7.8

4 years ago

9.7.7

4 years ago

9.7.6

4 years ago

9.7.5

4 years ago

9.7.4

4 years ago

9.7.3

4 years ago

9.7.2

4 years ago

9.7.1

4 years ago

9.7.0

4 years ago

9.6.0-alpha2

4 years ago

9.6.0-alpha3

4 years ago

9.6.4

4 years ago

9.6.0-alpha1

4 years ago

9.6.0-alpha

4 years ago

9.6.0

4 years ago

9.5.0-alpha1

4 years ago

9.5.1

4 years ago

9.5.0

4 years ago

9.4.0-alpha1

4 years ago

9.4.0

4 years ago

1.0.0-alpha1

4 years ago

9.2.0-alpha9

4 years ago

9.2.0-alpha8

4 years ago

9.2.0-alpha7

4 years ago

9.3.0-rc1

4 years ago

9.1.1-alpha

4 years ago

9.2.0-alpha6

4 years ago

9.2.0-alpha5

4 years ago

9.2.0-alpha2

4 years ago

9.2.0-alpha3

4 years ago

9.2.0-alpha4

4 years ago

9.2.0-alpha1

4 years ago

9.2.0-rc6

4 years ago

9.2.0-rc5

4 years ago

9.2.0-rc4

4 years ago

9.2.0-rc3

4 years ago

9.2.0-rc2

4 years ago

9.2.0-rc1

4 years ago

9.1.0-alpha45

4 years ago

9.1.0-alpha44

4 years ago

9.1.0-alpha43

4 years ago

9.1.0-rc8

4 years ago

9.1.0-rc7

4 years ago

9.1.0-alpha42

4 years ago

9.1.0-rc6

4 years ago

9.1.0-rc5

4 years ago

9.1.0-rc4

4 years ago

9.1.0-alphq39

4 years ago

9.1.0-alpha40

4 years ago

9.1.0-alpha41

4 years ago

9.1.0-rc2

4 years ago

9.1.0-rc3

4 years ago

9.1.0-rc1

4 years ago

9.1.0-alpha39

4 years ago

9.1.0-alpha38

4 years ago

9.1.0-alpha36

4 years ago

9.1.0-alpha37

4 years ago

9.1.0-alphq36

4 years ago

9.1.0-alpha34

4 years ago

9.1.0-alpha35

4 years ago

9.1.0-alpha32

4 years ago

9.1.0-alpha33

4 years ago

9.1.0-alpha31

4 years ago

9.1.0-alpha30

4 years ago

9.1.0-alpha29

4 years ago

9.1.0-alpha28

4 years ago

9.1.0-alpha26

4 years ago

9.1.0-alpha27

4 years ago

9.1.0-alpha25

4 years ago

9.1.0-alpha24

4 years ago

9.1.0-alpha18

4 years ago

9.1.0-alpha19

4 years ago

9.1.0-alpha21

4 years ago

9.1.0-alpha22

4 years ago

9.1.0-alpha20

4 years ago

9.1.0-alpha23

4 years ago

9.1.0-alpha15

4 years ago

9.1.0-alpha16

4 years ago

9.1.0-alpha17

4 years ago

9.1.0-alpha14

4 years ago

9.1.0-alpha13

4 years ago

9.1.0-alpha12

4 years ago

9.1.0-alpha11

4 years ago

9.1.0-alpha10

4 years ago

9.1.0-alpha9

4 years ago

9.1.0-alpha8

4 years ago

9.1.0-alpha7

4 years ago

9.1.0-alpha6

4 years ago

9.1.0-alpha5

4 years ago

9.1.0-alpha4

4 years ago

9.1.0-alpha2

4 years ago

9.1.0-alpha3

4 years ago

9.1.0-alpha1

4 years ago

9.0.0-rc3

4 years ago

9.0.0-rc1

4 years ago

9.0.0-rc2

4 years ago

8.1.0-rc1

4 years ago

8.0.0-rc4

4 years ago

8.0.0-rc3

4 years ago

8.0.0-rc2

4 years ago

8.0.0-rc1

4 years ago

0.2.0-beta11

4 years ago

0.2.0-beta12

4 years ago

0.2.0-beta10

4 years ago

0.2.0-alpha9

4 years ago

0.2.0-beta9

4 years ago

0.2.0-beta7

4 years ago

0.2.0-beta8

4 years ago

0.2.0-beta5

4 years ago

0.2.0-beta6

4 years ago

0.2.0-beta3

4 years ago

0.2.0-beta4

4 years ago

0.2.0-beta2

4 years ago

0.2.0-beta1

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago