@hailin-zheng/editor-core 1.0.20 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1613 -0
- package/lib/doc-ruler.d.ts +0 -1
- package/lib/framework/common-util.d.ts +0 -1
- package/lib/framework/document-change.d.ts +0 -1
- package/lib/framework/document-combine.d.ts +0 -1
- package/lib/framework/document-comment.d.ts +0 -1
- package/lib/framework/document-context.d.ts +0 -1
- package/lib/framework/document-eval-func.d.ts +0 -1
- package/lib/framework/document-event.d.ts +0 -1
- package/lib/framework/document-history.d.ts +0 -1
- package/lib/framework/document-images-loader.d.ts +0 -1
- package/lib/framework/document-input-cursor.d.ts +0 -1
- package/lib/framework/document-paint.d.ts +0 -1
- package/lib/framework/document-print-offscreen.d.ts +0 -1
- package/lib/framework/document-print.d.ts +0 -1
- package/lib/framework/document-segmenter.d.ts +0 -1
- package/lib/framework/document-selection.d.ts +0 -1
- package/lib/framework/document-template.d.ts +0 -1
- package/lib/framework/document-textline-mode.d.ts +0 -1
- package/lib/framework/element-define.d.ts +0 -1
- package/lib/framework/element-event-define.d.ts +0 -1
- package/lib/framework/element-measure.d.ts +0 -1
- package/lib/framework/element-paint.d.ts +0 -1
- package/lib/framework/element-props.d.ts +1 -2
- package/lib/framework/element-reader.d.ts +0 -1
- package/lib/framework/element-render-cut.d.ts +0 -1
- package/lib/framework/element-serialize.d.ts +0 -1
- package/lib/framework/element-util.d.ts +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts +0 -1
- package/lib/framework/impl/comments/comment-content-impl.d.ts +0 -1
- package/lib/framework/impl/comments/comment-element-impl.d.ts +0 -1
- package/lib/framework/impl/comments/comments-container-impl.d.ts +0 -1
- package/lib/framework/impl/comments/comments-util.d.ts +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +0 -1
- package/lib/framework/impl/document/doc-body-impl.d.ts +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.d.ts +0 -1
- package/lib/framework/impl/document/doc-container-impl.d.ts +0 -1
- package/lib/framework/impl/document/doc-footer-impl.d.ts +0 -1
- package/lib/framework/impl/document/doc-header-impl.d.ts +0 -1
- package/lib/framework/impl/document/doc-impl.d.ts +0 -1
- package/lib/framework/impl/index.d.ts +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.d.ts +0 -1
- package/lib/framework/impl/paragraph/p-impl.d.ts +0 -1
- package/lib/framework/impl/picture/image-impl.d.ts +0 -1
- package/lib/framework/impl/radio/radio-impl.d.ts +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts +0 -1
- package/lib/framework/impl/table/table-cell-impl.d.ts +0 -1
- package/lib/framework/impl/table/table-impl.d.ts +0 -1
- package/lib/framework/impl/table/table-row-impl.d.ts +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.d.ts +0 -1
- package/lib/framework/impl/table/table-split-cell.d.ts +0 -1
- package/lib/framework/impl/table/table-util.d.ts +0 -1
- package/lib/framework/impl/text/text-impl.d.ts +0 -1
- package/lib/framework/impl/text/track-run-impl.d.ts +0 -1
- package/lib/framework/notify.d.ts +0 -1
- package/lib/framework/range-util.d.ts +0 -1
- package/lib/framework/render-context.d.ts +0 -1
- package/lib/framework/render-define.d.ts +0 -1
- package/lib/framework/selection-overlays.d.ts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -0
- package/lib/texteditor.d.ts +1 -2
- package/lib/util/subject.d.ts +0 -1
- package/lib/util/table-bind.d.ts +0 -1
- package/package.json +24 -31
- package/lib/doc-ruler.d.ts.map +0 -1
- package/lib/framework/common-util.d.ts.map +0 -1
- package/lib/framework/document-change.d.ts.map +0 -1
- package/lib/framework/document-combine.d.ts.map +0 -1
- package/lib/framework/document-comment.d.ts.map +0 -1
- package/lib/framework/document-context.d.ts.map +0 -1
- package/lib/framework/document-eval-func.d.ts.map +0 -1
- package/lib/framework/document-event.d.ts.map +0 -1
- package/lib/framework/document-history.d.ts.map +0 -1
- package/lib/framework/document-images-loader.d.ts.map +0 -1
- package/lib/framework/document-input-cursor.d.ts.map +0 -1
- package/lib/framework/document-paint.d.ts.map +0 -1
- package/lib/framework/document-print-offscreen.d.ts.map +0 -1
- package/lib/framework/document-print.d.ts.map +0 -1
- package/lib/framework/document-segmenter.d.ts.map +0 -1
- package/lib/framework/document-selection.d.ts.map +0 -1
- package/lib/framework/document-template.d.ts.map +0 -1
- package/lib/framework/document-textline-mode.d.ts.map +0 -1
- package/lib/framework/element-define.d.ts.map +0 -1
- package/lib/framework/element-event-define.d.ts.map +0 -1
- package/lib/framework/element-measure.d.ts.map +0 -1
- package/lib/framework/element-paint.d.ts.map +0 -1
- package/lib/framework/element-props.d.ts.map +0 -1
- package/lib/framework/element-reader.d.ts.map +0 -1
- package/lib/framework/element-render-cut.d.ts.map +0 -1
- package/lib/framework/element-serialize.d.ts.map +0 -1
- package/lib/framework/element-util.d.ts.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.d.ts.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.d.ts.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.d.ts.map +0 -1
- package/lib/framework/impl/comments/comments-util.d.ts.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-container-impl.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-footer-impl.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.d.ts.map +0 -1
- package/lib/framework/impl/document/doc-impl.d.ts.map +0 -1
- package/lib/framework/impl/index.d.ts.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.d.ts.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.d.ts.map +0 -1
- package/lib/framework/impl/picture/image-impl.d.ts.map +0 -1
- package/lib/framework/impl/radio/radio-impl.d.ts.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.d.ts.map +0 -1
- package/lib/framework/impl/table/table-impl.d.ts.map +0 -1
- package/lib/framework/impl/table/table-row-impl.d.ts.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.d.ts.map +0 -1
- package/lib/framework/impl/table/table-split-cell.d.ts.map +0 -1
- package/lib/framework/impl/table/table-util.d.ts.map +0 -1
- package/lib/framework/impl/text/text-impl.d.ts.map +0 -1
- package/lib/framework/impl/text/track-run-impl.d.ts.map +0 -1
- package/lib/framework/notify.d.ts.map +0 -1
- package/lib/framework/range-util.d.ts.map +0 -1
- package/lib/framework/render-context.d.ts.map +0 -1
- package/lib/framework/render-define.d.ts.map +0 -1
- package/lib/framework/selection-overlays.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/texteditor.d.ts.map +0 -1
- package/lib/util/subject.d.ts.map +0 -1
- package/lib/util/table-bind.d.ts.map +0 -1
package/README.md
ADDED
@@ -0,0 +1,1613 @@
|
|
1
|
+
## 开始
|
2
|
+
* <a href="#import">引入编辑器</a>
|
3
|
+
* <a href="#init">实例化上下文</a>
|
4
|
+
* <a href="#basicDataJson">数据元结构示例</a>
|
5
|
+
* <a href="#combineMedical">合并病程录</a>
|
6
|
+
* <a href="#jumpMedical">跳转病程录</a>
|
7
|
+
* <a href="#saveMedical">保存病程录</a>
|
8
|
+
* <a href="#getNowContext">获取当前编辑的内容</a>
|
9
|
+
* <a href="#getNowHtml">获取当前选中的元素</a>
|
10
|
+
* <a href="#getNowBasic">获取当前选中的数据元</a>
|
11
|
+
* <a href="#getNowPart">获取当前所在的段落</a>
|
12
|
+
* <a href="#getAllBasic">获取当前文档所有的数据元列表</a>
|
13
|
+
* <a href="#getSelectObj">获取选区内容的对象</a>
|
14
|
+
* <a href="#groupData">数据组</a>
|
15
|
+
* <a href="#part">段落</a>
|
16
|
+
* <a href="#noteSetting">批注设置</a>
|
17
|
+
* <a href="#trace">留痕</a>
|
18
|
+
* <a href="#offlinePrint">离线打印</a>
|
19
|
+
|
20
|
+
## 文档操作
|
21
|
+
* <a href="#createNewDoc">createNewDoc 新建文档</a>
|
22
|
+
* <a href="#printAllPages">printAllPages 打印文档</a>
|
23
|
+
* <a href="#exportPDF">exportPDF 导出PDF</a>
|
24
|
+
* <a href="#exportPhoto">exportAllPagesToBase64 导出为图片</a>
|
25
|
+
* <a href="#watermark">watermark 设置水印</a>
|
26
|
+
* <a href="#copyRightInfo">copyRightInfo 设置版权</a>
|
27
|
+
* <a href="#setPaperOrient">setPaperOrient 纸张方向</a>
|
28
|
+
* <a href="#setPaperSize">setPaperSize 纸张大小</a>
|
29
|
+
* <a href="#insertMH">insertMH 插入月经史公式</a>
|
30
|
+
* <a href="#insertImage">insertImage 插入图片</a>
|
31
|
+
* <a href="#appendString">appendString 对当前数据元追加内容</a>
|
32
|
+
* <a href="#setDataEleVal">setDataEleVal 设置当前数据元内容</a>
|
33
|
+
* <a href="#validate">validate 文档校验</a>
|
34
|
+
* <a href="#selectionChanged">selectionChanged 选区事件</a>
|
35
|
+
* <a href="#onClickEvent">onClickEvent 单击事件</a>
|
36
|
+
* <a href="#onContextMenuItemChanged">onContextMenuItemChanged 右击事件</a>
|
37
|
+
* <a href="#onDblClickEvent">onDblClickEvent 双击事件</a>
|
38
|
+
* <a href="#onScrollViewEvent">onScrollViewEvent 滚动事件</a>
|
39
|
+
* <a href="#onDocChangedEvent">onDocChangedEvent 文档变更事件</a>
|
40
|
+
* <a href="#fullPageView">fullPageView 全页实图模式</a>
|
41
|
+
|
42
|
+
|
43
|
+
## 文字
|
44
|
+
* <a href="#textBold">switchTextStyle 文字加粗</a>
|
45
|
+
* <a href="#textIncline">switchTextStyle 文字斜体</a>
|
46
|
+
* <a href="#setTextFontSize">setTextFontSize 设置字体大小</a>
|
47
|
+
* <a href="#setTextColor">setTextColor 设置字体颜色</a>
|
48
|
+
* <a href="#setTextFont">setTextFont 设置字体类型</a>
|
49
|
+
* <a href="#setTextBackColor">setTextBackColor 设置字体背景色</a>
|
50
|
+
* <a href="#switchParaAlign">switchParaAlign 文本行的对齐方式</a>
|
51
|
+
* <a href="#setParagraphNumberType">setParagraphNumberType 设置当前行的项目符号</a>
|
52
|
+
|
53
|
+
|
54
|
+
## 表格
|
55
|
+
* <a href="#tableConfig">表格操作的基本配置文件</a>
|
56
|
+
* <a href="#tableJson">表格的数据结构</a>
|
57
|
+
* <a href="#insertTable">insertTable 插入表格</a>
|
58
|
+
* <a href="#insertRowBelow">insertRowBelow 向下新增行</a>
|
59
|
+
* <a href="#insertRowAbove">insertRowAbove 向上新增行</a>
|
60
|
+
* <a href="#insertColToRight">insertColToRight 向右新增列</a>
|
61
|
+
* <a href="#insertColToLeft">insertColToLeft 向左新增列</a>
|
62
|
+
* <a href="#removeCurrRow">removeCurrRow 删除行</a>
|
63
|
+
* <a href="#removeCurrCol">removeCurrCol 删除列</a>
|
64
|
+
* <a href="#mergeCells">mergeCells 合并单元格</a>
|
65
|
+
* <a href="#splitCell">splitCell 拆分单元格</a>
|
66
|
+
* <a href="#restoreCell">restoreCell 合并单元格还原</a>
|
67
|
+
* <a href="#setRowHeight">setRowHeight 设置行高</a>
|
68
|
+
* <a href="#setColWidth"> 调整列宽度(拖动)</a>
|
69
|
+
* <a href="#setTableCellDiagonal">setTableCellDiagonal 对角线操作</a>
|
70
|
+
* <a href="#setTableBorderProps">setTableBorderProps 边框操作</a>
|
71
|
+
* <a href="#setCellValign">setCellValign 表格内容对齐方式</a>
|
72
|
+
* <a href="#setCellBackground">setCellBackground 表格背景颜色</a>
|
73
|
+
|
74
|
+
<!-- div -->
|
75
|
+
<h3 id="import"><code>引入编辑器</code></h3>
|
76
|
+
|
77
|
+
源码 `med_editor` 放入项目 `src` 文件夹下并在项目的容器文件中引入;
|
78
|
+
将 `emrComponents` 放在 `components` 文件夹下,在项目中添加代码如下;
|
79
|
+
|
80
|
+
```js
|
81
|
+
// 编辑器容器文件 .vue
|
82
|
+
<template>
|
83
|
+
...
|
84
|
+
<editor-body></editor-body>
|
85
|
+
</template>
|
86
|
+
<script lang="ts">
|
87
|
+
...
|
88
|
+
import EditorBody from '@/med_editor/view/editor-body.vue';
|
89
|
+
|
90
|
+
</script>
|
91
|
+
```
|
92
|
+
<!-- /div -->
|
93
|
+
|
94
|
+
<!-- div -->
|
95
|
+
<h3 id="init"><code>实例化上下文</code></h3>
|
96
|
+
|
97
|
+
实例化编辑器,声明编辑器上下文 `editorContext` ,并将上下文提供给子组件;
|
98
|
+
> 注意:这里需要引入类型 `editorContextType` (位于 emrComponents/code/types.ts 中)
|
99
|
+
```js
|
100
|
+
// 引入类型
|
101
|
+
import { editorContextType } from '../components/emrComponents/code/types';
|
102
|
+
|
103
|
+
// 初始化编辑器,声明编辑器上下文 editorContext;
|
104
|
+
const editorContext: editorContextType = reactive({
|
105
|
+
counter: 0,
|
106
|
+
editorData: { __v_skip: true, selectionState: null, editor: null, contextMenus: null }
|
107
|
+
});
|
108
|
+
// 将上下文依赖提供给子组件;
|
109
|
+
provide('editor-context', editorContext);
|
110
|
+
|
111
|
+
```
|
112
|
+
<!-- /div -->
|
113
|
+
|
114
|
+
<!-- div -->
|
115
|
+
<h3 id="basicDataJson"><code>数据元结构示例</code></h3>
|
116
|
+
|
117
|
+
- 文本类型 数据属性示例:
|
118
|
+
```js
|
119
|
+
class TextProps{
|
120
|
+
...
|
121
|
+
color!: string; // 颜色
|
122
|
+
fontName!: string; // 字体名称
|
123
|
+
fontSize!: number; // 字体大小
|
124
|
+
fontWeight: 'normal' | 'bold' = 'normal'; // 字体粗细
|
125
|
+
fontStyle: 'normal' | 'italic' = 'normal'; // 字体样式
|
126
|
+
underline: boolean = false; // 下划线
|
127
|
+
overline: boolean = false; // 上划线
|
128
|
+
linethrough: boolean = false; // 删除线
|
129
|
+
background!: string; // 字体背景色
|
130
|
+
letterSpace!: number; // 字体间距
|
131
|
+
vertAlign!: TextVertAlign; // 上标或者下标
|
132
|
+
border!: boolean; // 字体边框
|
133
|
+
...
|
134
|
+
}
|
135
|
+
```
|
136
|
+
- 复选框类型 数据属性示例:
|
137
|
+
```js
|
138
|
+
class CheckBoxProps{
|
139
|
+
...
|
140
|
+
size!: number;// 大小
|
141
|
+
isChecked!: boolean; // 当前选择的状态
|
142
|
+
groupName!: string | null; //用于复选框分组
|
143
|
+
...
|
144
|
+
}
|
145
|
+
```
|
146
|
+
- 单选框类型 数据属性示例:
|
147
|
+
```js
|
148
|
+
class RadioBoxProps{
|
149
|
+
...
|
150
|
+
size!: number;// 大小
|
151
|
+
isChecked!: boolean; // 当前选择的状态
|
152
|
+
...
|
153
|
+
}
|
154
|
+
```
|
155
|
+
- 图片类型 数据属性示例:
|
156
|
+
```js
|
157
|
+
class PictureProps{
|
158
|
+
...
|
159
|
+
title!: string; // 图片名称
|
160
|
+
width!: number; // 图片宽度
|
161
|
+
height!: number; // 图片高度
|
162
|
+
src!: string; // 图片地址
|
163
|
+
border!: 'all' | 'none'; //图片边框
|
164
|
+
...
|
165
|
+
}
|
166
|
+
```
|
167
|
+
- 日期类型 数据属性示例:
|
168
|
+
```js
|
169
|
+
class DataEleDateProps{
|
170
|
+
...
|
171
|
+
minValue?: Date; // 最大日期
|
172
|
+
maxValue?: Date; // 最小日期
|
173
|
+
format?: string; // 格式化
|
174
|
+
...
|
175
|
+
}
|
176
|
+
```
|
177
|
+
<!-- /div -->
|
178
|
+
- 下拉选择框类型 数据属性示例:
|
179
|
+
```js
|
180
|
+
class DataEleCheckProps{
|
181
|
+
...
|
182
|
+
size!: number; // 大小
|
183
|
+
checked!: boolean; // 选择状态
|
184
|
+
checkedValue: string = ''; // 选中的值
|
185
|
+
groupName!: string; // 下拉框的组合值
|
186
|
+
multiSelect: boolean = false; // 是否多选
|
187
|
+
...
|
188
|
+
}
|
189
|
+
```
|
190
|
+
<!-- /div -->
|
191
|
+
<h3 id="combineMedical"><code>合并病程录</code></h3>
|
192
|
+
|
193
|
+
病程录合并是将多个文档合并到一起。
|
194
|
+
1、实例化DocumentCombine 文档合并类,
|
195
|
+
2、选择一份文档作为模板,将格式 赋给 docCombineIns.mainTemplate。docCombineIns类会 将其header 和 footer作为合并后的header 和 footer,3、调用 docCombineIns.add 方法,将 多个文档的body合并到一起,调用 docCombineIns.load() 生成合并实例,
|
196
|
+
4、调用 ElementSerialize.serialize 生成序列化的对象,
|
197
|
+
5、 解析序列化的对象,解析渲染病程录
|
198
|
+
|
199
|
+
> 注意:docCombineIns.add() 第二个要添加唯一值,用来区分不同的文档。
|
200
|
+
```js
|
201
|
+
// 获取 mainTemplate docParts
|
202
|
+
const firstJson = JSON.parse(jsonS[0].recContent);
|
203
|
+
const docCombineIns = new DocumentCombine();
|
204
|
+
docCombineIns.mainTemplate = this.editorData.editor!.elementReader.readElement(firstJson) as DocumentElement;
|
205
|
+
jsonS.forEach((e) => {
|
206
|
+
const docBody: any = this.editorData.editor!.elementReader.readElement(
|
207
|
+
JSON.parse(e.recContent)
|
208
|
+
) as DocumentElement;
|
209
|
+
docCombineIns.add(docBody, e.docId);
|
210
|
+
});
|
211
|
+
const template = docCombineIns.load();
|
212
|
+
let partJson: any = ElementSerialize.serialize(template, this.editorData.editor!.viewOptions);
|
213
|
+
return partJson;
|
214
|
+
|
215
|
+
```
|
216
|
+
<!-- /div -->
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<!-- div -->
|
224
|
+
<h4 id="jumpMedical"><code>跳转病程录</code></h4>
|
225
|
+
病程录病历比较多的情况下,可以根据 bringToView 方法跳转到选择的某一份病历
|
226
|
+
|
227
|
+
> 注意:bringToView 参数 是 Element 类型,需要找到 DocumentBodyPartElement 类型的元素,根据partId找到DocumentBodyPartElement实例元素对象,传入DocumentBodyPartElement实例元素对象进行跳转。
|
228
|
+
```js
|
229
|
+
/** 跳转到点击病程录,通过id */
|
230
|
+
bringToViewByPartId(id: string) {
|
231
|
+
const ele = this.getBodyPartElementById(id);
|
232
|
+
if (ele) {
|
233
|
+
this.editorData.editor!.bringToView(ele);
|
234
|
+
}
|
235
|
+
}
|
236
|
+
getBodyPartElementById(id: string): DocumentBodyPartElement | null {
|
237
|
+
return this.editorData.editor?.docCtx.document.treeFind(
|
238
|
+
(item) => item instanceof DocumentBodyPartElement && item.props.partId === id
|
239
|
+
) as DocumentBodyPartElement | null;
|
240
|
+
}
|
241
|
+
|
242
|
+
```
|
243
|
+
<!-- /div -->
|
244
|
+
|
245
|
+
<!-- div -->
|
246
|
+
<h4 id="saveMedical"><code>保存病程录</code></h4>
|
247
|
+
保存病程录生成序列化1、JSON对象 2、 提取病历数据元内容集合
|
248
|
+
JSON对象 和 数据元内容集合 分别是提取header 和 body内容组合到一起
|
249
|
+
|
250
|
+
> 注意:根据partId匹配JSON对象 和 数据元内容集合。
|
251
|
+
```js
|
252
|
+
/** 合并文档类型 保存 */
|
253
|
+
combinedSave(): combinedSaveProps[] {
|
254
|
+
//DocumentElement 文档顶层对象 root
|
255
|
+
|
256
|
+
// header 部分 数据元集合
|
257
|
+
const headerEle: DocumentHeaderElement = this.editorData.editor?.docCtx.document.treeFind(
|
258
|
+
(item) => item instanceof DocumentHeaderElement
|
259
|
+
) as DocumentHeaderElement;
|
260
|
+
const headerDataEleList = this.editorData.editor!.docCtx.getCtx(headerEle).getDataElementValues() || []
|
261
|
+
|
262
|
+
const docJsons: jsonSProp[] = this.split();
|
263
|
+
const bodyPartS: DocumentBodyPartElement[] = this.editorData.editor?.docCtx.document.treeFilter(
|
264
|
+
(item) => item instanceof DocumentBodyPartElement
|
265
|
+
) as DocumentBodyPartElement[];
|
266
|
+
|
267
|
+
let list: any = bodyPartS?.map((e) => ({
|
268
|
+
docId: e.props.partId,
|
269
|
+
list: headerDataEleList.concat(this.getpartBodyCtxByPartId(e.props.partId).getDataElementValues())
|
270
|
+
}));
|
271
|
+
console.log('courseSavecourseSave', list, docJsons);
|
272
|
+
// list = list.map((ele) => ({ id: ele.id, name: ele.name }));
|
273
|
+
|
274
|
+
const retData: combinedSaveProps[] = docJsons.map((e) => {
|
275
|
+
const ret = list.find((item) => item.docId === e.docId);
|
276
|
+
if (ret) {
|
277
|
+
return {
|
278
|
+
docId: e.docId,
|
279
|
+
docJson: e.recContent,
|
280
|
+
list: ret.list
|
281
|
+
};
|
282
|
+
}
|
283
|
+
}) as combinedSaveProps[];
|
284
|
+
|
285
|
+
return retData;
|
286
|
+
}
|
287
|
+
|
288
|
+
/** 拆解partsBody 为单个JSON */
|
289
|
+
split(): jsonSProp[] {
|
290
|
+
// 获取整个文档对象
|
291
|
+
// 分别替换body,生成单个的JSON文档
|
292
|
+
|
293
|
+
// 获取整个文档对象
|
294
|
+
const fullDoc = this.editorData.editor?.getDocSchema();
|
295
|
+
const partsBody: any[] = this.getPartBodyDocSchema() as Array<any>;
|
296
|
+
console.log('拆解partsBody 为单个JSON', fullDoc, partsBody);
|
297
|
+
const docJsons: jsonSProp[] = [];
|
298
|
+
partsBody.forEach((ele) => {
|
299
|
+
const singleDoc = _.cloneDeep(fullDoc);
|
300
|
+
singleDoc.children.find((e) => {
|
301
|
+
if (e.type === 'body') {
|
302
|
+
e.children = ele.children[0].children;
|
303
|
+
docJsons.push({
|
304
|
+
docId: ele.props.partId,
|
305
|
+
recContent: JSON.stringify(singleDoc)
|
306
|
+
});
|
307
|
+
return true;
|
308
|
+
}
|
309
|
+
});
|
310
|
+
});
|
311
|
+
console.log('拆解partsBody 为单个JSON', docJsons);
|
312
|
+
return docJsons;
|
313
|
+
}
|
314
|
+
|
315
|
+
```
|
316
|
+
<!-- /div -->
|
317
|
+
|
318
|
+
|
319
|
+
<!-- div -->
|
320
|
+
<h3 id="getNowContext"><code>获取当前编辑的内容</code></h3>
|
321
|
+
说明:获取当前编辑的数据元的内容;
|
322
|
+
|
323
|
+
#### 例如:
|
324
|
+
```js
|
325
|
+
/** 获取当前编辑的内容 */
|
326
|
+
getEditorContent() {
|
327
|
+
const ele = emrExtraF.getDataEle(this.editorData.selectionState)
|
328
|
+
if (ele) {
|
329
|
+
return ele.getValue()
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
/** 获取数据元对象 */
|
334
|
+
getDataEle(selectionState) {
|
335
|
+
const { startControl } = selectionState;
|
336
|
+
const dataEle = ElementUtil.getParent(startControl, validateDataEle) as DataElementInlineGroup | DataElementLeaf;
|
337
|
+
return dataEle;
|
338
|
+
}
|
339
|
+
```
|
340
|
+
<!-- /div -->
|
341
|
+
|
342
|
+
<!-- div -->
|
343
|
+
<h3 id="getNowHtml"><code>获取当前选中的元素</code></h3>
|
344
|
+
说明:获取当前选中的元素,editor.selectionState.startControl 是当前选中的元素;
|
345
|
+
|
346
|
+
#### 例如:
|
347
|
+
```js
|
348
|
+
editor.selectionState.startControl
|
349
|
+
```
|
350
|
+
<!-- /div -->
|
351
|
+
|
352
|
+
<!-- div -->
|
353
|
+
<h3 id="getNowBasic"><code>获取当前选中的数据元</code></h3>
|
354
|
+
说明:获取当前编辑的数据元的内容;
|
355
|
+
|
356
|
+
#### 例如:
|
357
|
+
```js
|
358
|
+
/** 获取数据元对象 */
|
359
|
+
getDataEle(selectionState) {
|
360
|
+
const { startControl } = selectionState;
|
361
|
+
const dataEle = ElementUtil.getParent(startControl, validateDataEle) as DataElementInlineGroup | DataElementLeaf;
|
362
|
+
return dataEle;
|
363
|
+
}
|
364
|
+
```
|
365
|
+
<!-- /div -->
|
366
|
+
|
367
|
+
<!-- div -->
|
368
|
+
<h3 id="getNowPart"><code>获取当前所在的段落</code></h3>
|
369
|
+
说明:获取当前所在的段落元素;
|
370
|
+
|
371
|
+
#### 例如:
|
372
|
+
```js
|
373
|
+
/** 获取当前所在的段落 */
|
374
|
+
getParagraph() {
|
375
|
+
const { startControl } = this.editorData.selectionState!;
|
376
|
+
const currPara = ElementUtil.getParentByType(startControl, ParagraphElement) as ParagraphElement;
|
377
|
+
if (currPara) {
|
378
|
+
return currPara;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
```
|
382
|
+
<!-- /div -->
|
383
|
+
|
384
|
+
<!-- div -->
|
385
|
+
<h3 id="getAllBasic"><code>获取当前文档所有的数据元列表</code></h3>
|
386
|
+
说明:通过遍历文档树,获取当前文档所有的数据元列表;
|
387
|
+
|
388
|
+
#### 例如:
|
389
|
+
```js
|
390
|
+
/** 获取病历实例集合 */
|
391
|
+
const getControlInstanceList = () => editorContext.editorData.editor!.docCtx.defaultCtx.getControlInstanceList();
|
392
|
+
```
|
393
|
+
<!-- /div -->
|
394
|
+
|
395
|
+
<!-- div -->
|
396
|
+
<h3 id="getSelectObj"><code>获取选区内容的对象</code></h3>
|
397
|
+
说明:获取选区内容的对象 this.selectionState.selectedRange ;
|
398
|
+
|
399
|
+
#### 例如:
|
400
|
+
```js
|
401
|
+
this.selectionState.selectedRange
|
402
|
+
```
|
403
|
+
<!-- /div -->
|
404
|
+
|
405
|
+
<!-- div -->
|
406
|
+
<h3 id="groupData"><code>数据组</code></h3>
|
407
|
+
说明:数据组可以将不同的数据元和文字组合,获取其文本值;
|
408
|
+
|
409
|
+
> 注意:文本值在 表单编辑模式下,不能修改。
|
410
|
+
|
411
|
+
#### 例如:
|
412
|
+
```js
|
413
|
+
/** 插入数据组 */
|
414
|
+
insertDataEleInlineGroup(obj?: any) {
|
415
|
+
let { collapsed, startControl, startOffset } = this.editorData.selectionState!;
|
416
|
+
|
417
|
+
const instance = emrExtraF.createDataEleInlineGroupInstance(obj);
|
418
|
+
const lastEle: any = this.editorData.editor!.insertElement(startControl, startOffset, [instance]);
|
419
|
+
const focusEle = ElementUtil.getNextSiblingElement(lastEle);
|
420
|
+
if (focusEle) {
|
421
|
+
this.editorData.selectionState!.resetRange(focusEle, 0);
|
422
|
+
focusEle.refreshView();
|
423
|
+
}
|
424
|
+
}
|
425
|
+
```
|
426
|
+
<!-- /div -->
|
427
|
+
|
428
|
+
<!-- div -->
|
429
|
+
<h3 id="part"><code>段落</code></h3>
|
430
|
+
说明:段落作为容器组件,可以添加 其他元素。
|
431
|
+
textProps!: TextProps; // 设置字体样式
|
432
|
+
indent = 0; // 设置缩进
|
433
|
+
hanging = 0;
|
434
|
+
lineHeight = 1.3; // 设置行高
|
435
|
+
textAlign: TextAlign = 'left'; // 设置横向排版
|
436
|
+
numberType = -1;
|
437
|
+
pageBreak = false; // 是否换页
|
438
|
+
|
439
|
+
> 注意:
|
440
|
+
|
441
|
+
#### 例如:
|
442
|
+
```js
|
443
|
+
/** 设置段落属性 */
|
444
|
+
const setParagraph= ()=> {
|
445
|
+
const cont = emrUtilF.getParagraph()
|
446
|
+
if (cont) {
|
447
|
+
cont.props.indent = 10; // 设置字体样式
|
448
|
+
}
|
449
|
+
}
|
450
|
+
```
|
451
|
+
<!-- /div -->
|
452
|
+
|
453
|
+
<!-- div -->
|
454
|
+
<h3 id="noteSetting"><code>批注设置</code></h3>
|
455
|
+
批注设置,需要选择需要批注的内容,执行insertComment() 方法。会在侧边弹出批注框。
|
456
|
+
|
457
|
+
> 注意:
|
458
|
+
|
459
|
+
#### 例如:
|
460
|
+
```js
|
461
|
+
/** 插入批注 */
|
462
|
+
const insertComment = () => {
|
463
|
+
editorContext.editorData.editor!.insertComment();
|
464
|
+
};
|
465
|
+
```
|
466
|
+
<!-- /div -->
|
467
|
+
|
468
|
+
<!-- div -->
|
469
|
+
<h3 id="trace"><code>留痕</code></h3>
|
470
|
+
开启留痕模式,会将修改记录下来。
|
471
|
+
|
472
|
+
> 注意:需要开启留痕记录,设置显示痕迹记录,才会显示痕迹
|
473
|
+
|
474
|
+
#### 例如:
|
475
|
+
```js
|
476
|
+
/** 切换审阅痕迹 */
|
477
|
+
switchTrackChanges(editorContext: editorContextType, isAdd?: boolean) {
|
478
|
+
editorContext.editorData.editor!.selectionState.enableTrackChanges = isAdd ? true : false;
|
479
|
+
// editorContext.editorData.editor.switchTrackChanges();
|
480
|
+
},
|
481
|
+
/** 显示审阅痕迹 */
|
482
|
+
showTrackChange(editorContext: editorContextType, isShow?: boolean | undefined) {
|
483
|
+
if (isShow === undefined) {
|
484
|
+
editorContext.editorData.editor!.viewOptions.showTrackChanges =
|
485
|
+
!editorContext.editorData.editor!.viewOptions.showTrackChanges;
|
486
|
+
} else {
|
487
|
+
editorContext.editorData.editor!.viewOptions.showTrackChanges = isShow;
|
488
|
+
}
|
489
|
+
},
|
490
|
+
/** 获取留痕数据 */
|
491
|
+
getTracksData(editorContext: editorContextType) {
|
492
|
+
return editorContext.editorData.editor!.docCtx.defaultCtx.getTracksData();
|
493
|
+
},
|
494
|
+
/** 跳转到痕迹记录点 */
|
495
|
+
bringToView(id, editorContext: editorContextType) {
|
496
|
+
const ele = editorContext.editorData.editor!.docCtx.defaultCtx.getTrackElmeentById(id);
|
497
|
+
if (ele) {
|
498
|
+
editorContext.editorData.editor!.bringToView(ele);
|
499
|
+
}
|
500
|
+
},
|
501
|
+
```
|
502
|
+
<!-- /div -->
|
503
|
+
|
504
|
+
<!-- div -->
|
505
|
+
<h3 id="offlinePrint"><code>离线打印</code></h3>
|
506
|
+
不需要在浏览器端实例,也可以打印病历;
|
507
|
+
|
508
|
+
#### 例如:
|
509
|
+
```js
|
510
|
+
/** 离线打印 */
|
511
|
+
offscreenPrint() {
|
512
|
+
this.editorData.editor!.offscreenPrint()
|
513
|
+
}
|
514
|
+
```
|
515
|
+
<!-- /div -->
|
516
|
+
|
517
|
+
|
518
|
+
<!-- div -->
|
519
|
+
<h3 id="watermark"><code>设置水印 watermark</code></h3>
|
520
|
+
说明:设置编辑器内容水印;
|
521
|
+
|
522
|
+
#### 例如:
|
523
|
+
```js
|
524
|
+
editorContext.editorData.editor!.viewOptions.watermark='万达信息智慧医院';
|
525
|
+
```
|
526
|
+
<!-- /div -->
|
527
|
+
|
528
|
+
<!-- div -->
|
529
|
+
<h3 id="copyRightInfo"><code>设置版权 copyRightInfo</code></h3>
|
530
|
+
说明:设置编辑器设置版权;
|
531
|
+
|
532
|
+
#### 例如:
|
533
|
+
```js
|
534
|
+
editorContext.editorData.editor!.viewOptions.copyRightInfo='复高电子病历编辑器';
|
535
|
+
```
|
536
|
+
<!-- /div -->
|
537
|
+
|
538
|
+
|
539
|
+
<!-- div -->
|
540
|
+
<h3 id="setPaperOrient"><code>设置纸张方向 setPaperOrient(OrientType)</code></h3>
|
541
|
+
说明:设置纸张方向;
|
542
|
+
|
543
|
+
#### 参数
|
544
|
+
1. `OrientType` *("landscape" | "portrait")*: 必需。默认 `portrait`. `landscape` 横向;`portrait` 纵向;
|
545
|
+
|
546
|
+
#### 例如:
|
547
|
+
```js
|
548
|
+
const setPaperOrient = (OrientType) => {
|
549
|
+
editorContext.editorData.editor!.setPaperOrient(OrientType);
|
550
|
+
};
|
551
|
+
// setPaperOrient('landscape')
|
552
|
+
```
|
553
|
+
<!-- /div -->
|
554
|
+
|
555
|
+
<!-- div -->
|
556
|
+
<h3 id="setPaperSize"><code>设置纸张方向 setPaperSize({width,height})</code></h3>
|
557
|
+
说明:设置纸张大小;
|
558
|
+
|
559
|
+
#### 参数
|
560
|
+
1. `width` *(numer)*: 可选。单位为毫米(mm);
|
561
|
+
2. `height` *(numer)*: 可选。单位为毫米(mm);
|
562
|
+
|
563
|
+
#### 例如:
|
564
|
+
```js
|
565
|
+
const setPaperSize = ({width, height}) => {
|
566
|
+
editorContext.editorData.editor!.setPaperSize(width, height);
|
567
|
+
};
|
568
|
+
// setPaperSize()
|
569
|
+
```
|
570
|
+
<!-- /div -->
|
571
|
+
|
572
|
+
<!-- div -->
|
573
|
+
<h3 id="insertMH"><code>插入月经史公式 insertMH(SelectionState, editorData, obj)</code></h3>
|
574
|
+
说明:插入月经史公式;
|
575
|
+
|
576
|
+
#### 参数
|
577
|
+
1. `SelectionState` : 必需。当前选中状态,调用时手动传入;
|
578
|
+
2. `editorData` : 必需。当前编辑器,调用时手动传入;
|
579
|
+
2. `obj` *({age:string,cycles:string,days:string,lastDate:string})*: 可选。月经史公式参数;
|
580
|
+
|
581
|
+
> <span style="color:red">提示</span>:需要引入相关文件,并导入所需对象;
|
582
|
+
|
583
|
+
#### 例如:
|
584
|
+
```js
|
585
|
+
// 需要获取当前编辑器上下文所需引入文件;
|
586
|
+
...
|
587
|
+
import { CanvasTextEditor } from "@/med_editor/texteditor";
|
588
|
+
import { SelectionState } from "@/med_editor/framework/document-selection";
|
589
|
+
import { editorContextType } from '@/components/emrComponents/code/types';
|
590
|
+
import { emrExtraF } from '@/components/emrComponents/common/emrExtraF'
|
591
|
+
|
592
|
+
...
|
593
|
+
const editorContext: editorContextType = inject('editor-context') as editorContextType;
|
594
|
+
const getEditor = (): CanvasTextEditor => {
|
595
|
+
const editor = editorContext.editorData.editor as CanvasTextEditor;
|
596
|
+
return editor;
|
597
|
+
};
|
598
|
+
const getSelectionState = (): SelectionState => getEditor().selectionState;
|
599
|
+
|
600
|
+
const insertMH = (obj) => {
|
601
|
+
emrExtraF.insertMH(getSelectionState(), editorContext.editorData, obj);
|
602
|
+
};
|
603
|
+
// insertMH()
|
604
|
+
|
605
|
+
```
|
606
|
+
<!-- /div -->
|
607
|
+
|
608
|
+
<!-- div -->
|
609
|
+
<h3 id="insertImage"><code>插入图片 insertImage(SelectionState, editorData, src)</code></h3>
|
610
|
+
说明:对当前位置插入图片;
|
611
|
+
|
612
|
+
#### 参数
|
613
|
+
1. `SelectionState` : 必需。当前选中状态,调用时手动传入;
|
614
|
+
2. `editorData` : 必需。当前编辑器,调用时手动传入;
|
615
|
+
2. `src` *(string)*: 必需。插入图片地址支持 网络地址和当前项目内地址;
|
616
|
+
|
617
|
+
> <span style="color:red">提示</span>:需要引入相关文件,并导入所需对象;
|
618
|
+
|
619
|
+
#### 例如:
|
620
|
+
```js
|
621
|
+
// 需要获取当前编辑器上下文所需引入文件;
|
622
|
+
...
|
623
|
+
import { CanvasTextEditor } from "@/med_editor/texteditor";
|
624
|
+
import { SelectionState } from "@/med_editor/framework/document-selection";
|
625
|
+
import { editorContextType } from '@/components/emrComponents/code/types';
|
626
|
+
import { emrExtraF } from '@/components/emrComponents/common/emrExtraF'
|
627
|
+
|
628
|
+
...
|
629
|
+
const editorContext: editorContextType = inject('editor-context') as editorContextType;
|
630
|
+
const getEditor = (): CanvasTextEditor => {
|
631
|
+
const editor = editorContext.editorData.editor as CanvasTextEditor;
|
632
|
+
return editor;
|
633
|
+
};
|
634
|
+
const getSelectionState = (): SelectionState => getEditor().selectionState;
|
635
|
+
|
636
|
+
const insertImage = (src) => {
|
637
|
+
emrExtraF.insertImage(getSelectionState(), editorContext.editorData, src);
|
638
|
+
};
|
639
|
+
// insertImage()
|
640
|
+
|
641
|
+
```
|
642
|
+
<!-- /div -->
|
643
|
+
|
644
|
+
|
645
|
+
<!-- div -->
|
646
|
+
<h3 id="appendString"><code>对当前数据元追加内容 appendString(val, SelectionState)</code></h3>
|
647
|
+
说明:对当前数据元追加内容;
|
648
|
+
|
649
|
+
#### 参数
|
650
|
+
1. `val` *(string[] | string)*: 必需。需要追加的内容;
|
651
|
+
2. `SelectionState` : 必需。当前选中状态,调用时手动传入;
|
652
|
+
|
653
|
+
> <span style="color:red">提示</span>:需要引入相关文件,并导入所需对象;
|
654
|
+
|
655
|
+
#### 例如:
|
656
|
+
```js
|
657
|
+
// 需要获取当前编辑器上下文所需引入文件;
|
658
|
+
...
|
659
|
+
import { CanvasTextEditor } from "@/med_editor/texteditor";
|
660
|
+
import { SelectionState } from "@/med_editor/framework/document-selection";
|
661
|
+
import { editorContextType } from '@/components/emrComponents/code/types';
|
662
|
+
import { emrExtraF } from '@/components/emrComponents/common/emrExtraF'
|
663
|
+
|
664
|
+
...
|
665
|
+
const editorContext: editorContextType = inject('editor-context') as editorContextType;
|
666
|
+
const getEditor = (): CanvasTextEditor => {
|
667
|
+
const editor = editorContext.editorData.editor as CanvasTextEditor;
|
668
|
+
return editor;
|
669
|
+
};
|
670
|
+
const getSelectionState = (): SelectionState => getEditor().selectionState;
|
671
|
+
|
672
|
+
const appendString = (val) => {
|
673
|
+
emrExtraF.appendString(val, getSelectionState());
|
674
|
+
};
|
675
|
+
// appendString()
|
676
|
+
|
677
|
+
```
|
678
|
+
<!-- /div -->
|
679
|
+
|
680
|
+
<!-- div -->
|
681
|
+
<h3 id="setDataEleVal"><code>设置数据元的值 setDataEleVal(SelectionState, editorData, src)</code></h3>
|
682
|
+
说明:设置当前数据元的值;
|
683
|
+
|
684
|
+
#### 参数
|
685
|
+
1. `val` *(string)*: 必需。设置数据元的值;
|
686
|
+
2. `SelectionState` : 必需。当前选中状态,调用时手动传入;
|
687
|
+
|
688
|
+
> <span style="color:red">提示</span>:需要引入相关文件,并导入所需对象;
|
689
|
+
|
690
|
+
#### 例如:
|
691
|
+
```js
|
692
|
+
// 需要获取当前编辑器上下文所需引入文件;
|
693
|
+
...
|
694
|
+
import { CanvasTextEditor } from "@/med_editor/texteditor";
|
695
|
+
import { SelectionState } from "@/med_editor/framework/document-selection";
|
696
|
+
import { editorContextType } from '@/components/emrComponents/code/types';
|
697
|
+
import { emrExtraF } from '@/components/emrComponents/common/emrExtraF'
|
698
|
+
|
699
|
+
...
|
700
|
+
const editorContext: editorContextType = inject('editor-context') as editorContextType;
|
701
|
+
const getEditor = (): CanvasTextEditor => {
|
702
|
+
const editor = editorContext.editorData.editor as CanvasTextEditor;
|
703
|
+
return editor;
|
704
|
+
};
|
705
|
+
const getSelectionState = (): SelectionState => getEditor().selectionState;
|
706
|
+
|
707
|
+
const setDataEleVal = (val) => {
|
708
|
+
emrExtraF.setDataEleVal(val, getSelectionState());
|
709
|
+
};
|
710
|
+
// appendString()
|
711
|
+
|
712
|
+
```
|
713
|
+
<!-- /div -->
|
714
|
+
|
715
|
+
<!-- div -->
|
716
|
+
<h3 id="validate"><code>文档校验 validate()</code></h3>
|
717
|
+
说明:校验当前文档下所有数据元的有效性;
|
718
|
+
|
719
|
+
> 该校验是根据数据元属性的 `required` 属性值来判断是否做校验;数据元结构详见<a href="#basicDataJson">数据元结构示例</a>
|
720
|
+
|
721
|
+
#### 例如:
|
722
|
+
```js
|
723
|
+
const validate = (src) => {
|
724
|
+
editorContext.editorData.editor.validate();
|
725
|
+
|
726
|
+
};
|
727
|
+
// insertImage()
|
728
|
+
|
729
|
+
```
|
730
|
+
<!-- /div -->
|
731
|
+
|
732
|
+
<!-- div -->
|
733
|
+
<h3 id="selectionChanged"><code>选区事件 selectionChanged(callBack)</code></h3>
|
734
|
+
说明:获取当前光标的选中事件;
|
735
|
+
|
736
|
+
#### 参数
|
737
|
+
1. `callBack` *( function(selectionState?) )*: 必需。选区事件触发后的回调函数.
|
738
|
+
2. `selectionState` *(selectionState)*: 可选。当前选中对象.
|
739
|
+
|
740
|
+
#### 例如:
|
741
|
+
```js
|
742
|
+
editorContext.editorData.editor!.selectionChanged.subscribe(callBack)
|
743
|
+
```
|
744
|
+
<!-- /div -->
|
745
|
+
|
746
|
+
<!-- div -->
|
747
|
+
<h3 id="onClickEvent"><code>单击事件 onClickEvent(callBack)</code></h3>
|
748
|
+
说明:获取当前光标的单击事件;
|
749
|
+
|
750
|
+
#### 参数
|
751
|
+
1. `callBack` *( function(selectionState?) )*: 必需。单击事件触发后的回调函数.
|
752
|
+
2. `selectionState` *(selectionState)*: 可选。当前单击事件源.
|
753
|
+
|
754
|
+
#### 例如:
|
755
|
+
```js
|
756
|
+
editorContext.editorData.editor!.onClickEvent.subscribe(callBack)
|
757
|
+
```
|
758
|
+
<!-- /div -->
|
759
|
+
|
760
|
+
<!-- div -->
|
761
|
+
<h3 id="onContextMenuItemChanged"><code>右击事件 onContextMenuItemChanged(callBack)</code></h3>
|
762
|
+
说明:获取当前光标的右击事件;
|
763
|
+
|
764
|
+
#### 参数
|
765
|
+
1. `callBack` *( function(selectionState?) )*: 必需。右击事件触发后的回调函数.
|
766
|
+
2. `selectionState` *(selectionState)*: 可选。当前右击事件源.
|
767
|
+
|
768
|
+
#### 例如:
|
769
|
+
```js
|
770
|
+
editorContext.editorData.editor!.onContextMenuItemChanged.subscribe(callBack)
|
771
|
+
```
|
772
|
+
<!-- /div -->
|
773
|
+
|
774
|
+
<!-- div -->
|
775
|
+
<h3 id="onDblClickEvent"><code>双击事件 onDblClickEvent(callBack)</code></h3>
|
776
|
+
说明:获取当前光标的双击事件;
|
777
|
+
|
778
|
+
#### 参数
|
779
|
+
1. `callBack` *( function(selectionState?) )*: 必需。双击事件触发后的回调函数.
|
780
|
+
2. `selectionState` *(selectionState)*: 可选。当前双击事件源.
|
781
|
+
|
782
|
+
#### 例如:
|
783
|
+
```js
|
784
|
+
editorContext.editorData.editor!.onDblClickEvent.subscribe(callBack)
|
785
|
+
```
|
786
|
+
<!-- /div -->
|
787
|
+
|
788
|
+
<!-- div -->
|
789
|
+
<h3 id="onScrollViewEvent"><code>滚动事件 onScrollViewEvent(callBack)</code></h3>
|
790
|
+
说明:获取当前光标的滚动事件;
|
791
|
+
|
792
|
+
#### 参数
|
793
|
+
1. `callBack` *( function(selectionState?) )*: 必需。滚动事件触发后的回调函数.
|
794
|
+
2. `selectionState` *(selectionState)*: 可选。当前滚动事件源.
|
795
|
+
|
796
|
+
#### 例如:
|
797
|
+
```js
|
798
|
+
editorContext.editorData.editor!.onScrollViewEvent.subscribe(callBack)
|
799
|
+
```
|
800
|
+
<!-- /div -->
|
801
|
+
|
802
|
+
<!-- div -->
|
803
|
+
<h3 id="onDocChangedEvent"><code>文档变更事件 onDocChangedEvent(callBack)</code></h3>
|
804
|
+
说明:获取当前文档变更事件;
|
805
|
+
|
806
|
+
#### 参数
|
807
|
+
1. `callBack` *( function(selectionState?) )*: 必需。文档变更事件触发后的回调函数.
|
808
|
+
2. `selectionState` *(selectionState)*: 可选。当前文档变更事件源.
|
809
|
+
|
810
|
+
#### 例如:
|
811
|
+
```js
|
812
|
+
editorContext.editorData.editor!.onDocChangedEvent.subscribe(callBack)
|
813
|
+
```
|
814
|
+
<!-- /div -->
|
815
|
+
|
816
|
+
<!-- div -->
|
817
|
+
<h3 id="fullPageView"><code>全页面视图模式 fullPageView</code></h3>
|
818
|
+
|
819
|
+
说明:设置当前页面是否为全页面视图模式 默认是 `false` 分页模式 ;
|
820
|
+
|
821
|
+
#### 例如:
|
822
|
+
```js
|
823
|
+
editorContext.editorData.editor!.viewOptions.fullPageView = true;
|
824
|
+
```
|
825
|
+
<!-- /div -->
|
826
|
+
|
827
|
+
|
828
|
+
<!-- div -->
|
829
|
+
<h3 id="createNewDoc"><code>新建文档 createNewDoc()</code></h3>
|
830
|
+
说明:新建编辑器内容;
|
831
|
+
|
832
|
+
#### 例如:
|
833
|
+
```js
|
834
|
+
const createNewDoc = () => {
|
835
|
+
editorContext.editorData.editor!.createNewDoc();
|
836
|
+
};
|
837
|
+
// 调用 createNewDoc()
|
838
|
+
```
|
839
|
+
<!-- /div -->
|
840
|
+
|
841
|
+
<!-- div -->
|
842
|
+
<h3 id="printAllPages"><code>打印文档 printAllPages(printRanges)</code></h3>
|
843
|
+
说明:打印当前编辑器内容;
|
844
|
+
|
845
|
+
#### 参数
|
846
|
+
1. `printRanges` *(Array<number>)*: 可选。 要打印指定的页的下标,初始值 0,不传则全部打印.
|
847
|
+
|
848
|
+
#### 例如:
|
849
|
+
```js
|
850
|
+
const printAllPages = (printRanges) => {
|
851
|
+
editorContext.editorData.editor!.printAllPages(printRanges);
|
852
|
+
};
|
853
|
+
// 调用 printAllPages() // 打印全部;
|
854
|
+
// 调用 printAllPages([1]) // 只打印第二页;
|
855
|
+
```
|
856
|
+
<!-- /div -->
|
857
|
+
|
858
|
+
<!-- div -->
|
859
|
+
<h3 id="loadDoc"><code>导入文档 loadDoc(docJSON)</code></h3>
|
860
|
+
说明:将json文件转化为编辑器内容;
|
861
|
+
|
862
|
+
#### 参数
|
863
|
+
1. `docJSON` *(json)*: 必需。 导入文件的json 对象.
|
864
|
+
|
865
|
+
#### 例如:
|
866
|
+
```js
|
867
|
+
const loadDoc = (docJSON) => {
|
868
|
+
editorContext.editorData.editor?.loadDoc(docJSON);
|
869
|
+
};
|
870
|
+
// 调用 loadDoc()
|
871
|
+
```
|
872
|
+
> 如果是 json 文件需要将读取的文件内容转化为json对象. 参考:
|
873
|
+
|
874
|
+
```js
|
875
|
+
const reader = new FileReader(); //实例化一个FileReader对象
|
876
|
+
reader.readAsText(filedList.raw, 'utf8'); //借助 FileReader 的方法,按照文本格式读入文件,第二个参数是编码方式(可空)
|
877
|
+
reader.onload = function (ret: any) {
|
878
|
+
//然后在FileReader的onload方法里,然后在FileReader的onload方法里,刚刚读入的文件能以文本的形式得到了
|
879
|
+
//注意这个对象还是文本,不能拿来直接用,但首先你可以把它带出来。
|
880
|
+
const { target: { result } } = ret;
|
881
|
+
const docJSON = JSON.parse(result);
|
882
|
+
editorContext.editorData.editor?.loadDoc(docJSON);
|
883
|
+
};
|
884
|
+
```
|
885
|
+
<!-- /div -->
|
886
|
+
|
887
|
+
<!-- div -->
|
888
|
+
<h3 id="textBold"><code>文本加粗 switchTextStyle(style,matchValue,defaultValue)</code></h3>
|
889
|
+
说明:对当前选中的文本字体加粗;
|
890
|
+
|
891
|
+
#### 参数
|
892
|
+
1. `fontWeight` *(string)*: 必需。 字体操作的样式.
|
893
|
+
2. `bold` *(string)* 必需。 加粗.
|
894
|
+
3. `defaultValue`*(string)* 可选。 设置的默认值,默认为`undefined`;
|
895
|
+
|
896
|
+
#### 例如:
|
897
|
+
```js
|
898
|
+
// 判断设置属性是否在当前属性对象上面;
|
899
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
900
|
+
if (!textProps) {
|
901
|
+
return false;
|
902
|
+
}
|
903
|
+
return textProps[style] === matchValue;
|
904
|
+
};
|
905
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
906
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
907
|
+
if (!textProps) {
|
908
|
+
return;
|
909
|
+
}
|
910
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
911
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
912
|
+
}
|
913
|
+
// 调用 switchTextStyle('fontWeight', 'bold')
|
914
|
+
```
|
915
|
+
<!-- /div -->
|
916
|
+
|
917
|
+
<!-- div -->
|
918
|
+
<h3 id="textIncline"><code>文本斜体 switchTextStyle(style,matchValue,defaultValue)</code></h3>
|
919
|
+
说明:对当前选中的文本字体倾斜;
|
920
|
+
|
921
|
+
#### 参数
|
922
|
+
1. `fontStyle` *(string)*: 必需。 字体操作的样式.
|
923
|
+
2. `italic` *(string)* 必需。 斜体.
|
924
|
+
3. `defaultValue`*(string)* 可选。 设置的默认值,默认为`undefined`;
|
925
|
+
|
926
|
+
#### 例如:
|
927
|
+
```js
|
928
|
+
// 判断设置属性是否在当前属性对象上面;
|
929
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
930
|
+
if (!textProps) {
|
931
|
+
return false;
|
932
|
+
}
|
933
|
+
return textProps[style] === matchValue;
|
934
|
+
};
|
935
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
936
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
937
|
+
if (!textProps) {
|
938
|
+
return;
|
939
|
+
}
|
940
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
941
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
942
|
+
}
|
943
|
+
|
944
|
+
// 调用 switchTextStyle('fontStyle', 'italic')
|
945
|
+
```
|
946
|
+
<!-- /div -->
|
947
|
+
|
948
|
+
<!-- div -->
|
949
|
+
<h3 id="textIncline"><code>下划线 switchTextStyle(style,matchValue,defaultValue)</code></h3>
|
950
|
+
说明:对当前选中的文本加下划线;
|
951
|
+
|
952
|
+
#### 参数
|
953
|
+
1. `underline` *(string)*: 必需。 字体操作的样式.
|
954
|
+
2. `true` *(string)* 必需。 下划线.
|
955
|
+
3. `false`*(string)* 可选。 设置的默认值,默认为`undefined`;
|
956
|
+
|
957
|
+
#### 例如:
|
958
|
+
```js
|
959
|
+
// 判断设置属性是否在当前属性对象上面;
|
960
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
961
|
+
if (!textProps) {
|
962
|
+
return false;
|
963
|
+
}
|
964
|
+
return textProps[style] === matchValue;
|
965
|
+
};
|
966
|
+
|
967
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
968
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
969
|
+
if (!textProps) {
|
970
|
+
return;
|
971
|
+
}
|
972
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
973
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
974
|
+
}
|
975
|
+
|
976
|
+
// 调用 switchTextStyle('underline', true, false)
|
977
|
+
```
|
978
|
+
<!-- /div -->
|
979
|
+
|
980
|
+
<!-- div -->
|
981
|
+
<h3 id="textIncline"><code>删除线 switchTextStyle(style,matchValue,defaultValue)</code></h3>
|
982
|
+
说明:对当前选中的文本加删除线;
|
983
|
+
|
984
|
+
#### 参数
|
985
|
+
1. `linethrough` *(string)*: 必需。 字体操作的样式.
|
986
|
+
2. `true` *(string)* 必需。 下划线.
|
987
|
+
3. `false`*(string)* 可选。 设置的默认值,默认为`undefined`;
|
988
|
+
|
989
|
+
#### 例如:
|
990
|
+
```js
|
991
|
+
// 判断设置属性是否在当前属性对象上面;
|
992
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
993
|
+
if (!textProps) {
|
994
|
+
return false;
|
995
|
+
}
|
996
|
+
return textProps[style] === matchValue;
|
997
|
+
};
|
998
|
+
|
999
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
1000
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
1001
|
+
if (!textProps) {
|
1002
|
+
return;
|
1003
|
+
}
|
1004
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
1005
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
// 调用 switchTextStyle('linethrough', true, false)
|
1009
|
+
```
|
1010
|
+
<!-- /div -->
|
1011
|
+
|
1012
|
+
|
1013
|
+
<!-- div -->
|
1014
|
+
<h3 id="textIncline"><code>上标 switchTextStyle(style,matchValue)</code></h3>
|
1015
|
+
说明:对当前选中的文本上标;
|
1016
|
+
|
1017
|
+
#### 参数
|
1018
|
+
1. `style` *('vertAlign')*: 必需。 字体操作的样式.
|
1019
|
+
2. `matchValue` *('superscript')* 必需。 上标.
|
1020
|
+
|
1021
|
+
#### 例如:
|
1022
|
+
```js
|
1023
|
+
// 判断设置属性是否在当前属性对象上面;
|
1024
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
1025
|
+
if (!textProps) {
|
1026
|
+
return false;
|
1027
|
+
}
|
1028
|
+
return textProps[style] === matchValue;
|
1029
|
+
};
|
1030
|
+
|
1031
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
1032
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
1033
|
+
if (!textProps) {
|
1034
|
+
return;
|
1035
|
+
}
|
1036
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
1037
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
// 调用 switchTextStyle('vertAlign', 'superscript')
|
1041
|
+
```
|
1042
|
+
<!-- /div -->
|
1043
|
+
|
1044
|
+
<!-- div -->
|
1045
|
+
<h3 id="textIncline"><code>下标 switchTextStyle(style,matchValue)</code></h3>
|
1046
|
+
说明:对当前选中的文本下标;
|
1047
|
+
|
1048
|
+
#### 参数
|
1049
|
+
1. `style` *('vertAlign')*: 必需。 字体操作的样式.
|
1050
|
+
2. `matchValue` *('subscript')* 必需。 上标.
|
1051
|
+
|
1052
|
+
#### 例如:
|
1053
|
+
```js
|
1054
|
+
// 判断设置属性是否在当前属性对象上面;
|
1055
|
+
const getEffectiveTextGroupStyle = (textProps, style, matchValue) => {
|
1056
|
+
if (!textProps) {
|
1057
|
+
return false;
|
1058
|
+
}
|
1059
|
+
return textProps[style] === matchValue;
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
const switchTextStyle = (style,matchValue,defaultValue: any = undefined)=>{
|
1063
|
+
const textProps = editorContext.editorData.editor?.getSelectionTextGroupProps();
|
1064
|
+
if (!textProps) {
|
1065
|
+
return;
|
1066
|
+
}
|
1067
|
+
const isEffective = getEffectiveTextGroupStyle(textProps, style, matchValue);
|
1068
|
+
editorContext.editorData.editor!.switchTextStyle(isEffective, style, matchValue, defaultValue);
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
// 调用 switchTextStyle('vertAlign', 'subscript')
|
1072
|
+
```
|
1073
|
+
<!-- /div -->
|
1074
|
+
|
1075
|
+
<!-- div -->
|
1076
|
+
<h3 id="setTextFontSize"><code>设置字体大小 setTextFontSize(fontSize)</code></h3>
|
1077
|
+
说明:对当前选中的文本下标;
|
1078
|
+
|
1079
|
+
#### 参数
|
1080
|
+
1. `fontSize` *('number')*: 必需。 设置字体大小.
|
1081
|
+
|
1082
|
+
#### 例如:
|
1083
|
+
```js
|
1084
|
+
const setFontSize = (fontSize) => {
|
1085
|
+
editorContext.editorData.editor!.setTextFontSize(fontSize);
|
1086
|
+
};
|
1087
|
+
|
1088
|
+
// 调用 setFontSize(16)
|
1089
|
+
```
|
1090
|
+
<!-- /div -->
|
1091
|
+
|
1092
|
+
<!-- div -->
|
1093
|
+
<h3 id="setTextColor"><code>设置字体颜色 setTextFontSize(color)</code></h3>
|
1094
|
+
说明:对当前选中的文本设置颜色 ;
|
1095
|
+
|
1096
|
+
#### 参数
|
1097
|
+
1. `color` *('string')*: 必需。 设置字体颜色 目前是支持 `rgba` 和 十六进制 .
|
1098
|
+
|
1099
|
+
#### 例如:
|
1100
|
+
```js
|
1101
|
+
const setTextColor = (color) => {
|
1102
|
+
editorContext.editorData.editor!.setTextColor(color);
|
1103
|
+
};
|
1104
|
+
|
1105
|
+
// 调用 setTextColor('rgba(34, 34, 34, 1)')
|
1106
|
+
```
|
1107
|
+
<!-- /div -->
|
1108
|
+
|
1109
|
+
|
1110
|
+
<!-- div -->
|
1111
|
+
<h3 id="setTextFont"><code>设置字体 setTextFont(font)</code></h3>
|
1112
|
+
说明:设置当前选中文本的字体类型;
|
1113
|
+
|
1114
|
+
#### 参数
|
1115
|
+
1. `font` *('string')*: 必需。 设置字体 .
|
1116
|
+
|
1117
|
+
#### 例如:
|
1118
|
+
```js
|
1119
|
+
const setTextFont = (font) => {
|
1120
|
+
editorContext.editorData.editor!.setTextFont(font);
|
1121
|
+
};
|
1122
|
+
|
1123
|
+
// 调用 setTextFont('微软雅黑')
|
1124
|
+
```
|
1125
|
+
<!-- /div -->
|
1126
|
+
|
1127
|
+
<!-- div -->
|
1128
|
+
<h3 id="setTextBackColor"><code>设置文本的背景色 setTextBackColor(color)</code></h3>
|
1129
|
+
说明:设置当前选中文本的背景颜色;
|
1130
|
+
|
1131
|
+
#### 参数
|
1132
|
+
1. `color` *('string')*: 必需。 设置字体 目前是支持 `rgba` 和 十六进制 ..
|
1133
|
+
|
1134
|
+
#### 例如:
|
1135
|
+
```js
|
1136
|
+
const setTextBackColor = (color) => {
|
1137
|
+
editorContext.editorData.editor!.setTextBackColor(color);
|
1138
|
+
};
|
1139
|
+
|
1140
|
+
// 调用 setTextBackColor('#000000')
|
1141
|
+
```
|
1142
|
+
<!-- /div -->
|
1143
|
+
|
1144
|
+
<!-- div -->
|
1145
|
+
<h3 id="switchParaAlign"><code>文本对齐 switchParaAlign(align)</code></h3>
|
1146
|
+
说明:设置当前文本的对齐位置;
|
1147
|
+
|
1148
|
+
#### 参数
|
1149
|
+
1. `align` *('left','center','right','justify')*: 必需。 当前行对齐位置 文本默认左对齐.
|
1150
|
+
|
1151
|
+
#### 例如:
|
1152
|
+
```js
|
1153
|
+
const switchAlign = (align) => {
|
1154
|
+
editorContext.editorData.editor!.switchParaAlign(align);
|
1155
|
+
};
|
1156
|
+
|
1157
|
+
// 调用 switchAlign('left')
|
1158
|
+
```
|
1159
|
+
<!-- /div -->
|
1160
|
+
|
1161
|
+
|
1162
|
+
设计模式、只读模式、表单模式
|
1163
|
+
|
1164
|
+
格式刷
|
1165
|
+
|
1166
|
+
|
1167
|
+
|
1168
|
+
<!-- div -->
|
1169
|
+
<h3 id="exportPDF"><code>导出PDF exportPDF()</code></h3>
|
1170
|
+
说明:导出当前编辑器内容为PDF;
|
1171
|
+
|
1172
|
+
#### 例如:
|
1173
|
+
```js
|
1174
|
+
const exportPDF = () => {
|
1175
|
+
editorContext.editorData.editor!.exportPDF();
|
1176
|
+
};
|
1177
|
+
// 调用 exportPDF()
|
1178
|
+
```
|
1179
|
+
<!-- /div -->
|
1180
|
+
|
1181
|
+
<!-- div -->
|
1182
|
+
<h3 id="exportPhoto"><code>导出图片 exportAllPagesToBase64(pthotoName)</code></h3>
|
1183
|
+
说明:导出当前编辑器内容为图片;
|
1184
|
+
|
1185
|
+
#### 参数
|
1186
|
+
1. `pthotoName` *(string)*: 必需。 导出图片的名称.
|
1187
|
+
|
1188
|
+
#### 例如:
|
1189
|
+
```js
|
1190
|
+
const exportPhoto = (pthotoName)=>{
|
1191
|
+
editorContext.editorData.editor!.exportAllPagesToBase64(pthotoName);
|
1192
|
+
}
|
1193
|
+
// 调用 exportPhoto('test')
|
1194
|
+
```
|
1195
|
+
|
1196
|
+
<h3 id="setParagraphNumberType"><code>设置项目符号 setParagraphNumberType()</code></h3>
|
1197
|
+
说明:设置当前行的项目符号
|
1198
|
+
|
1199
|
+
#### 例如:
|
1200
|
+
```js
|
1201
|
+
const setParagraphNumberType = () => {
|
1202
|
+
editorContext.editorData.editor!.setParagraphNumberType();
|
1203
|
+
};
|
1204
|
+
// 调用 setParagraphNumberType();
|
1205
|
+
```
|
1206
|
+
<!-- div -->
|
1207
|
+
<h3 id="tableConfig"><code>表格操作的基础配置</code></h3>
|
1208
|
+
|
1209
|
+
> <span style="color:red">重要</span> 所有的表格操作,都要基于下面的引入文件
|
1210
|
+
|
1211
|
+
```js
|
1212
|
+
// 表格操作 所需要文件;
|
1213
|
+
import { CanvasTextEditor } from "@/med_editor/texteditor";
|
1214
|
+
import { SelectionState } from "@/med_editor/framework/document-selection";
|
1215
|
+
import { TableUtil } from "@/med_editor/framework/impl/table/table-util";
|
1216
|
+
import { TableSplitCell } from "@/med_editor/framework/impl/table/table-split-cell";
|
1217
|
+
import { editorContextType } from '@/components/emrComponents/code/types';
|
1218
|
+
import { emrExtraF, TableType } from '@/components/emrComponents/common/emrExtraF'
|
1219
|
+
|
1220
|
+
...
|
1221
|
+
// 获取操作表格的初始化;
|
1222
|
+
const editorContext: editorContextType = inject('editor-context') as editorContextType;
|
1223
|
+
|
1224
|
+
const getEditor = (): CanvasTextEditor => {
|
1225
|
+
const editor = editorContext.editorData.editor as CanvasTextEditor;
|
1226
|
+
return editor;
|
1227
|
+
};
|
1228
|
+
|
1229
|
+
const getSelectionState = (): SelectionState => getEditor().selectionState;
|
1230
|
+
...
|
1231
|
+
```
|
1232
|
+
|
1233
|
+
<!-- /div -->
|
1234
|
+
|
1235
|
+
<!-- div -->
|
1236
|
+
<h3 id="tableJson"><code>表格的数据结构</code></h3>
|
1237
|
+
|
1238
|
+
#### 表格的数据结构(JSON、table\row\cell)
|
1239
|
+
```json
|
1240
|
+
// 3*3 的表格数据结构 示例:
|
1241
|
+
{
|
1242
|
+
"type": "tb",
|
1243
|
+
"props": {
|
1244
|
+
"width": 649,
|
1245
|
+
"cols": [
|
1246
|
+
{
|
1247
|
+
"width": 216
|
1248
|
+
},
|
1249
|
+
{
|
1250
|
+
"width": 216
|
1251
|
+
},
|
1252
|
+
{
|
1253
|
+
"width": 217
|
1254
|
+
}
|
1255
|
+
],
|
1256
|
+
"border": "all"
|
1257
|
+
},
|
1258
|
+
"children": [
|
1259
|
+
{
|
1260
|
+
"type": "tr",
|
1261
|
+
"children": [
|
1262
|
+
{
|
1263
|
+
"type": "tbc",
|
1264
|
+
"children": [
|
1265
|
+
{
|
1266
|
+
"type": "p"
|
1267
|
+
}
|
1268
|
+
]
|
1269
|
+
},
|
1270
|
+
{
|
1271
|
+
"type": "tbc",
|
1272
|
+
"children": [
|
1273
|
+
{
|
1274
|
+
"type": "p"
|
1275
|
+
}
|
1276
|
+
]
|
1277
|
+
},
|
1278
|
+
{
|
1279
|
+
"type": "tbc",
|
1280
|
+
"children": [
|
1281
|
+
{
|
1282
|
+
"type": "p"
|
1283
|
+
}
|
1284
|
+
]
|
1285
|
+
}
|
1286
|
+
]
|
1287
|
+
},
|
1288
|
+
{
|
1289
|
+
"type": "tr",
|
1290
|
+
"children": [
|
1291
|
+
{
|
1292
|
+
"type": "tbc",
|
1293
|
+
"children": [
|
1294
|
+
{
|
1295
|
+
"type": "p"
|
1296
|
+
}
|
1297
|
+
]
|
1298
|
+
},
|
1299
|
+
{
|
1300
|
+
"type": "tbc",
|
1301
|
+
"children": [
|
1302
|
+
{
|
1303
|
+
"type": "p"
|
1304
|
+
}
|
1305
|
+
]
|
1306
|
+
},
|
1307
|
+
{
|
1308
|
+
"type": "tbc",
|
1309
|
+
"children": [
|
1310
|
+
{
|
1311
|
+
"type": "p"
|
1312
|
+
}
|
1313
|
+
]
|
1314
|
+
}
|
1315
|
+
]
|
1316
|
+
},
|
1317
|
+
{
|
1318
|
+
"type": "tr",
|
1319
|
+
"children": [
|
1320
|
+
{
|
1321
|
+
"type": "tbc",
|
1322
|
+
"children": [
|
1323
|
+
{
|
1324
|
+
"type": "p"
|
1325
|
+
}
|
1326
|
+
]
|
1327
|
+
},
|
1328
|
+
{
|
1329
|
+
"type": "tbc",
|
1330
|
+
"children": [
|
1331
|
+
{
|
1332
|
+
"type": "p"
|
1333
|
+
}
|
1334
|
+
]
|
1335
|
+
},
|
1336
|
+
{
|
1337
|
+
"type": "tbc",
|
1338
|
+
"children": [
|
1339
|
+
{
|
1340
|
+
"type": "p"
|
1341
|
+
}
|
1342
|
+
]
|
1343
|
+
}
|
1344
|
+
]
|
1345
|
+
}
|
1346
|
+
]
|
1347
|
+
}
|
1348
|
+
```
|
1349
|
+
<!-- /div -->
|
1350
|
+
|
1351
|
+
<!-- div -->
|
1352
|
+
<h3 id="insertTable"><code>插入表格 insertTable(row, col, editor, editorTableType)</code></h3>
|
1353
|
+
说明: 在当前光标处插入表格;
|
1354
|
+
|
1355
|
+
#### 参数
|
1356
|
+
1. 'row' *(number)*: 插入表格行数;
|
1357
|
+
2. 'col' *(number)*: 插入表格列数;
|
1358
|
+
2. 'editor' : 当前编辑器,该字段调用时手动传入;
|
1359
|
+
2. 'editorTableType' : 表格类型 该字段调用时手动传入 默认值‘tb’;
|
1360
|
+
|
1361
|
+
#### 例如:
|
1362
|
+
```js
|
1363
|
+
const insertTable = (row, col) => {
|
1364
|
+
emrExtraF.insertTable(row, col, editorContext.editorData.editor!, TableType.tb)
|
1365
|
+
};
|
1366
|
+
// insertTable()
|
1367
|
+
```
|
1368
|
+
<!-- /div -->
|
1369
|
+
|
1370
|
+
|
1371
|
+
<!-- div -->
|
1372
|
+
<h3 id="insertRowBelow"><code>向下新增行 insertRowBelow(getSelectionState)</code></h3>
|
1373
|
+
说明: 在当前行下面新增一行;
|
1374
|
+
|
1375
|
+
#### 参数
|
1376
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1377
|
+
|
1378
|
+
#### 例如:
|
1379
|
+
```js
|
1380
|
+
const insertRowBelow = () => {
|
1381
|
+
emrExtraF.insertRowBelow(getSelectionState())
|
1382
|
+
};
|
1383
|
+
// insertRowBelow()
|
1384
|
+
```
|
1385
|
+
<!-- /div -->
|
1386
|
+
|
1387
|
+
<!-- div -->
|
1388
|
+
<h3 id="insertRowAbove"><code>向上新增行 insertRowAbove(getSelectionState)</code></h3>
|
1389
|
+
说明: 在当前行上面新增一行;
|
1390
|
+
|
1391
|
+
#### 参数
|
1392
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1393
|
+
|
1394
|
+
#### 例如:
|
1395
|
+
```js
|
1396
|
+
const insertRowAbove = () => {
|
1397
|
+
emrExtraF.insertRowAbove(getSelectionState())
|
1398
|
+
};
|
1399
|
+
// insertRowAbove()
|
1400
|
+
```
|
1401
|
+
<!-- /div -->
|
1402
|
+
|
1403
|
+
<!-- div -->
|
1404
|
+
<h3 id="insertColToRight"><code>向右新增列 insertColToRight(getSelectionState)</code></h3>
|
1405
|
+
说明:在当前单元格右面新增一列;
|
1406
|
+
|
1407
|
+
#### 参数
|
1408
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1409
|
+
|
1410
|
+
#### 例如:
|
1411
|
+
```js
|
1412
|
+
const insertColToRight = () => {
|
1413
|
+
emrExtraF.insertColToRight(getSelectionState())
|
1414
|
+
};
|
1415
|
+
// insertColToRight()
|
1416
|
+
```
|
1417
|
+
<!-- /div -->
|
1418
|
+
|
1419
|
+
<!-- div -->
|
1420
|
+
<h3 id="insertColToLeft"><code>向左新增列 insertColToLeft(getSelectionState)</code></h3>
|
1421
|
+
说明:在当前单元格左面新增一列;
|
1422
|
+
|
1423
|
+
#### 参数
|
1424
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1425
|
+
|
1426
|
+
#### 例如:
|
1427
|
+
```js
|
1428
|
+
const insertColToLeft = () => {
|
1429
|
+
emrExtraF.insertColToLeft(getSelectionState())
|
1430
|
+
};
|
1431
|
+
// insertColToLeft()
|
1432
|
+
```
|
1433
|
+
<!-- /div -->
|
1434
|
+
|
1435
|
+
<!-- div -->
|
1436
|
+
<h3 id="removeCurrRow"><code>删除行 removeCurrRow(getSelectionState)</code></h3>
|
1437
|
+
说明:在当前光标所在的行;
|
1438
|
+
|
1439
|
+
#### 参数
|
1440
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1441
|
+
|
1442
|
+
#### 例如:
|
1443
|
+
```js
|
1444
|
+
const removeCurrRow = () => {
|
1445
|
+
TableUtil.removeCurrRow(getSelectionState());
|
1446
|
+
};
|
1447
|
+
// removeCurrRow()
|
1448
|
+
```
|
1449
|
+
<!-- /div -->
|
1450
|
+
|
1451
|
+
<!-- div -->
|
1452
|
+
<h3 id="removeCurrCol"><code>删除列 removeCurrCol(getSelectionState)</code></h3>
|
1453
|
+
说明:在当前光标所在的列;
|
1454
|
+
|
1455
|
+
#### 参数
|
1456
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1457
|
+
|
1458
|
+
#### 例如:
|
1459
|
+
```js
|
1460
|
+
const removeCurrCol = () => {
|
1461
|
+
TableUtil.removeCurrCol(getSelectionState());
|
1462
|
+
};
|
1463
|
+
// removeCurrCol()
|
1464
|
+
```
|
1465
|
+
<!-- /div -->
|
1466
|
+
|
1467
|
+
<!-- div -->
|
1468
|
+
<h3 id="mergeCells"><code>合并单元格 mergeCells(getSelectionState)</code></h3>
|
1469
|
+
说明:合并当前选中单元格;
|
1470
|
+
|
1471
|
+
#### 参数
|
1472
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1473
|
+
|
1474
|
+
#### 例如:
|
1475
|
+
```js
|
1476
|
+
const mergeCells = () => {
|
1477
|
+
TableUtil.mergeCells(getSelectionState());
|
1478
|
+
};
|
1479
|
+
// mergeCells()
|
1480
|
+
```
|
1481
|
+
<!-- /div -->
|
1482
|
+
|
1483
|
+
<!-- div -->
|
1484
|
+
<h3 id="splitCell"><code>拆分单元格 splitCell(getSelectionState)</code></h3>
|
1485
|
+
说明:拆分当前选中单元格;
|
1486
|
+
|
1487
|
+
#### 参数
|
1488
|
+
1. 'getSelectionState' 当前光标的状态;
|
1489
|
+
|
1490
|
+
#### 例如:
|
1491
|
+
```js
|
1492
|
+
const splitCell = () => {
|
1493
|
+
TableSplitCell.splitCell(selectionState(), 0, 2)
|
1494
|
+
};
|
1495
|
+
// splitCell()
|
1496
|
+
```
|
1497
|
+
<!-- /div -->
|
1498
|
+
|
1499
|
+
<!-- div -->
|
1500
|
+
<h3 id="restoreCell"><code>合并单元格还原 restoreCell(getSelectionState)</code></h3>
|
1501
|
+
说明:还原当前合并单元格;
|
1502
|
+
|
1503
|
+
#### 参数
|
1504
|
+
1. 'getSelectionState' 当前光标的状态;
|
1505
|
+
|
1506
|
+
#### 例如:
|
1507
|
+
```js
|
1508
|
+
const restoreCell = () => {
|
1509
|
+
TableSplitCell.restoreCell(selectionState())
|
1510
|
+
};
|
1511
|
+
// restoreCell()
|
1512
|
+
```
|
1513
|
+
<!-- /div -->
|
1514
|
+
|
1515
|
+
<!-- div -->
|
1516
|
+
<h3 id="setRowHeight"><code>设置行高 setRowHeight(getSelectionState, rowHeight=20)</code></h3>
|
1517
|
+
说明:设置当前光标所在行的行高;
|
1518
|
+
|
1519
|
+
#### 参数
|
1520
|
+
1. 'getSelectionState' 当前光标选中的状态;
|
1521
|
+
2. 'rowHeight' *(number)*: 行高值 默认值为20;
|
1522
|
+
|
1523
|
+
#### 例如:
|
1524
|
+
```js
|
1525
|
+
const setRowHeight = () => {
|
1526
|
+
TableUtil.setRowHeight(getSelectionState(), rowHeight=20);
|
1527
|
+
};
|
1528
|
+
// setRowHeight()
|
1529
|
+
```
|
1530
|
+
<!-- /div -->
|
1531
|
+
|
1532
|
+
<!-- div -->
|
1533
|
+
<h3 id="setColWidth"><code>设置列宽 目前支持拖动</code></h3>
|
1534
|
+
说明:拖动设置当前列宽(后续配置文档待完善);
|
1535
|
+
<!-- /div -->
|
1536
|
+
|
1537
|
+
<!-- div -->
|
1538
|
+
<h3 id="setTableCellDiagonal"><code>表格对角线操作 setTableCellDiagonal(getSelectionState, diagonal)</code></h3>
|
1539
|
+
说明:设置当前单元格的对角线和删除对角线;
|
1540
|
+
|
1541
|
+
#### 参数
|
1542
|
+
1. 'getSelectionState' 当前光标选中的状态 该字段调用时手动传入;
|
1543
|
+
2. 'diagonal' *("main" | "sub" | '')*: `main` 主对角线 `sub` 副对角线 `''` 删除对角线;
|
1544
|
+
|
1545
|
+
#### 例如:
|
1546
|
+
```js
|
1547
|
+
const setTableCellDiagonal = (diagonal) => {
|
1548
|
+
TableUtil.setTableCellDiagonal(getSelectionState(), diagonal);
|
1549
|
+
};
|
1550
|
+
// setTableCellDiagonal()
|
1551
|
+
```
|
1552
|
+
<!-- /div -->
|
1553
|
+
|
1554
|
+
<!-- div -->
|
1555
|
+
<h3 id="setTableBorderProps"><code>设置边框线 setTableBorderProps(getSelectionState, diagonal)</code></h3>
|
1556
|
+
说明:设置当前表格边框线;
|
1557
|
+
|
1558
|
+
#### 参数
|
1559
|
+
1. 'getSelectionState' 当前光标选中的状态 该字段调用时手动传入;
|
1560
|
+
2. 'diagonal' *("all" | "none")*: `all` 有边框; `none` 无边框;
|
1561
|
+
|
1562
|
+
#### 例如:
|
1563
|
+
```js
|
1564
|
+
const setTableBorderProps = (diagonal) => {
|
1565
|
+
TableUtil.setTableBorderProps(getSelectionState(), diagonal);
|
1566
|
+
};
|
1567
|
+
// setTableBorderProps()
|
1568
|
+
```
|
1569
|
+
<!-- /div -->
|
1570
|
+
|
1571
|
+
<!-- div -->
|
1572
|
+
<h3 id="setCellValign"><code>设置表格内容对齐方式 setCellValign(getSelectionState, diagonal)</code></h3>
|
1573
|
+
说明:设置表格内容对齐方式;
|
1574
|
+
|
1575
|
+
#### 参数
|
1576
|
+
1. 'getSelectionState' 当前光标选中的状态 该字段调用时手动传入;
|
1577
|
+
2. 'diagonal' *("top" | "middle" |"bottom")*: `top` 顶部对齐; `middle` 居中对齐; `bottom` 底部对齐;
|
1578
|
+
|
1579
|
+
#### 例如:
|
1580
|
+
```js
|
1581
|
+
const setCellValign = (diagonal) => {
|
1582
|
+
TableUtil.setCellValign(getSelectionState(), diagonal);
|
1583
|
+
};
|
1584
|
+
// setCellValign()
|
1585
|
+
```
|
1586
|
+
<!-- /div -->
|
1587
|
+
|
1588
|
+
<!-- div -->
|
1589
|
+
<h3 id="setCellBackground"><code>设置表格内容对齐方式 setCellBackground(getSelectionState, diagonal)</code></h3>
|
1590
|
+
说明:设置当前选中的单元格背景色;
|
1591
|
+
|
1592
|
+
#### 参数
|
1593
|
+
1. 'getSelectionState' 当前光标选中的状态 该字段调用时手动传入;
|
1594
|
+
2. 'diagonal' *(string)*: 背景颜色 支持`rgba` 和十六进制;
|
1595
|
+
|
1596
|
+
#### 例如:
|
1597
|
+
```js
|
1598
|
+
const setCellBackground = (color) => {
|
1599
|
+
TableUtil.setCellBackground(getSelectionState(), color);
|
1600
|
+
};
|
1601
|
+
// setCellBackground()
|
1602
|
+
```
|
1603
|
+
<!-- /div -->
|
1604
|
+
|
1605
|
+
|
1606
|
+
<!--
|
1607
|
+
编辑页脚页眉
|
1608
|
+
双击页眉,body,页脚 开启是否可编辑,默认body 是可编辑;
|
1609
|
+
default 设置viewoption;
|
1610
|
+
删除数据元、删除段落、删除数据组
|
1611
|
+
条形码、二维码
|
1612
|
+
排版:标尺处理,悬挂
|
1613
|
+
-->
|