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