@hailin-zheng/editor-core 1.0.7 → 1.0.10
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/package.json +3 -4
- package/{lib/doc-ruler.js → src/med_editor/doc-ruler.ts} +101 -74
- package/src/med_editor/framework/common-util.ts +200 -0
- package/{lib/framework/document-change.js → src/med_editor/framework/document-change.ts} +308 -259
- package/{lib/framework/document-combine.js → src/med_editor/framework/document-combine.ts} +15 -11
- package/{lib/framework/document-comment.js → src/med_editor/framework/document-comment.ts} +52 -37
- package/{lib/framework/document-context.js → src/med_editor/framework/document-context.ts} +181 -101
- package/{lib/framework/document-eval-func.js → src/med_editor/framework/document-eval-func.ts} +16 -11
- package/{lib/framework/document-event.js → src/med_editor/framework/document-event.ts} +244 -216
- package/{lib/framework/document-history.js → src/med_editor/framework/document-history.ts} +25 -14
- package/{lib/framework/document-images-loader.js → src/med_editor/framework/document-images-loader.ts} +25 -17
- package/{lib/framework/document-input-cursor.js → src/med_editor/framework/document-input-cursor.ts} +76 -71
- package/{lib/framework/document-paint.js → src/med_editor/framework/document-paint.ts} +35 -28
- package/{lib/framework/document-print-offscreen.js → src/med_editor/framework/document-print-offscreen.ts} +25 -19
- package/{lib/framework/document-print.js → src/med_editor/framework/document-print.ts} +57 -41
- package/src/med_editor/framework/document-segmenter.ts +211 -0
- package/{lib/framework/document-selection.js → src/med_editor/framework/document-selection.ts} +116 -85
- package/{lib/framework/document-template.js → src/med_editor/framework/document-template.ts} +3 -3
- package/src/med_editor/framework/document-textline-mode.ts +34 -0
- package/{lib/framework/element-define.js → src/med_editor/framework/element-define.ts} +301 -206
- package/src/med_editor/framework/element-event-define.ts +141 -0
- package/{lib/framework/element-measure.js → src/med_editor/framework/element-measure.ts} +143 -121
- package/{lib/framework/element-paint.js → src/med_editor/framework/element-paint.ts} +44 -38
- package/{lib/framework/element-props.js → src/med_editor/framework/element-props.ts} +331 -202
- package/{lib/framework/element-reader.js → src/med_editor/framework/element-reader.ts} +39 -31
- package/{lib/framework/element-render-cut.js → src/med_editor/framework/element-render-cut.ts} +113 -106
- package/{lib/framework/element-serialize.js → src/med_editor/framework/element-serialize.ts} +37 -24
- package/{lib/framework/element-util.js → src/med_editor/framework/element-util.ts} +317 -216
- package/{lib/framework/impl/checkbox/checkbox-impl.js → src/med_editor/framework/impl/checkbox/checkbox-impl.ts} +27 -20
- package/{lib/framework/impl/comments/comment-content-impl.js → src/med_editor/framework/impl/comments/comment-content-impl.ts} +45 -31
- package/{lib/framework/impl/comments/comment-element-impl.js → src/med_editor/framework/impl/comments/comment-element-impl.ts} +23 -20
- package/{lib/framework/impl/comments/comments-container-impl.js → src/med_editor/framework/impl/comments/comments-container-impl.ts} +22 -16
- package/{lib/framework/impl/comments/comments-util.js → src/med_editor/framework/impl/comments/comments-util.ts} +34 -17
- package/{lib/framework/impl/comments/validate-msg-impl.js → src/med_editor/framework/impl/comments/validate-msg-impl.ts} +28 -17
- package/{lib/framework/impl/data-element/data-decorate-impl.js → src/med_editor/framework/impl/data-element/data-decorate-impl.ts} +26 -22
- package/{lib/framework/impl/data-element/data-element-barcode.js → src/med_editor/framework/impl/data-element/data-element-barcode.ts} +41 -29
- package/{lib/framework/impl/data-element/data-element-base-impl.js → src/med_editor/framework/impl/data-element/data-element-base-impl.ts} +73 -44
- package/{lib/framework/impl/data-element/data-element-check-impl.js → src/med_editor/framework/impl/data-element/data-element-check-impl.ts} +48 -35
- package/{lib/framework/impl/data-element/data-element-date-impl.js → src/med_editor/framework/impl/data-element/data-element-date-impl.ts} +41 -24
- package/{lib/framework/impl/data-element/data-element-group-impl.js → src/med_editor/framework/impl/data-element/data-element-group-impl.ts} +52 -32
- package/{lib/framework/impl/data-element/data-element-image-impl.js → src/med_editor/framework/impl/data-element/data-element-image-impl.ts} +38 -28
- package/{lib/framework/impl/data-element/data-element-list-impl.js → src/med_editor/framework/impl/data-element/data-element-list-impl.ts} +42 -31
- package/{lib/framework/impl/data-element/data-element-text-impl.js → src/med_editor/framework/impl/data-element/data-element-text-impl.ts} +36 -22
- package/{lib/framework/impl/decorate/fill-null-space-imple.js → src/med_editor/framework/impl/decorate/fill-null-space-imple.ts} +15 -10
- package/{lib/framework/impl/document/doc-body-impl.js → src/med_editor/framework/impl/document/doc-body-impl.ts} +32 -16
- package/{lib/framework/impl/document/doc-body-part-impl.js → src/med_editor/framework/impl/document/doc-body-part-impl.ts} +27 -17
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +24 -0
- package/{lib/framework/impl/document/doc-footer-impl.js → src/med_editor/framework/impl/document/doc-footer-impl.ts} +30 -19
- package/{lib/framework/impl/document/doc-header-impl.js → src/med_editor/framework/impl/document/doc-header-impl.ts} +34 -17
- package/{lib/framework/impl/document/doc-impl.js → src/med_editor/framework/impl/document/doc-impl.ts} +62 -45
- package/{lib/framework/impl/media-formula/menstrual-history.js → src/med_editor/framework/impl/media-formula/menstrual-history.ts} +58 -36
- package/{lib/framework/impl/paragraph/p-impl.js → src/med_editor/framework/impl/paragraph/p-impl.ts} +64 -30
- package/{lib/framework/impl/picture/image-impl.js → src/med_editor/framework/impl/picture/image-impl.ts} +37 -25
- package/{lib/framework/impl/radio/radio-impl.js → src/med_editor/framework/impl/radio/radio-impl.ts} +28 -21
- package/{lib/framework/impl/symbol/br-symbol-impl.js → src/med_editor/framework/impl/symbol/br-symbol-impl.ts} +21 -15
- package/{lib/framework/impl/symbol/p-symbol-impl.js → src/med_editor/framework/impl/symbol/p-symbol-impl.ts} +15 -12
- package/{lib/framework/impl/table/table-cell-impl.js → src/med_editor/framework/impl/table/table-cell-impl.ts} +41 -30
- package/{lib/framework/impl/table/table-impl.js → src/med_editor/framework/impl/table/table-impl.ts} +122 -84
- package/{lib/framework/impl/table/table-row-impl.js → src/med_editor/framework/impl/table/table-row-impl.ts} +26 -18
- package/{lib/framework/impl/table/table-split-cell-patch.js → src/med_editor/framework/impl/table/table-split-cell-patch.ts} +31 -22
- package/{lib/framework/impl/table/table-split-cell.js → src/med_editor/framework/impl/table/table-split-cell.ts} +105 -94
- package/{lib/framework/impl/table/table-util.js → src/med_editor/framework/impl/table/table-util.ts} +197 -159
- package/{lib/framework/impl/text/text-impl.js → src/med_editor/framework/impl/text/text-impl.ts} +49 -35
- package/{lib/framework/impl/text/track-run-impl.js → src/med_editor/framework/impl/text/track-run-impl.ts} +53 -30
- package/{lib/framework/notify.js → src/med_editor/framework/notify.ts} +50 -36
- package/{lib/framework/range-util.js → src/med_editor/framework/range-util.ts} +80 -71
- package/{lib/framework/render-context.js → src/med_editor/framework/render-context.ts} +111 -64
- package/{lib/framework/render-define.js → src/med_editor/framework/render-define.ts} +90 -61
- package/{lib/framework/selection-overlays.js → src/med_editor/framework/selection-overlays.ts} +25 -16
- package/{lib/texteditor.js → src/med_editor/texteditor.ts} +288 -191
- package/src/med_editor/util/subject.ts +118 -0
- package/{lib/util/table-bind.js → src/med_editor/util/table-bind.ts} +2 -2
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +315 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/211/271/346/263/250.json +122 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/226/207/346/241/243/351/252/214/350/257/201.json +3599 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/351/225/277/346/226/207/346/234/254.json +24586 -0
- package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +2874 -0
- package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +341 -0
- package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +2201 -0
- package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +1069 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/206/205/351/225/234/344/270/213/346/262/273/347/226/227/350/256/260/345/275/225.json +125 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225/346/250/241/346/235/277.json +86 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/227/245/345/270/270/347/227/205/347/250/213/350/256/260/345/275/225.json +115 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/237/245/346/210/277/350/256/260/345/275/2251.json +108 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//351/246/226/346/254/241/344/270/212/347/272/247/345/214/273/345/270/210/346/237/245/346/210/277/350/256/260/345/275/225.json +272 -0
- package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +1070 -0
- package/lib/doc-ruler.d.ts +0 -51
- package/lib/doc-ruler.js.map +0 -1
- package/lib/framework/common-util.d.ts +0 -63
- package/lib/framework/common-util.js +0 -178
- package/lib/framework/common-util.js.map +0 -1
- package/lib/framework/document-change.d.ts +0 -265
- package/lib/framework/document-change.js.map +0 -1
- package/lib/framework/document-combine.d.ts +0 -24
- package/lib/framework/document-combine.js.map +0 -1
- package/lib/framework/document-comment.d.ts +0 -46
- package/lib/framework/document-comment.js.map +0 -1
- package/lib/framework/document-context.d.ts +0 -149
- package/lib/framework/document-context.js.map +0 -1
- package/lib/framework/document-eval-func.d.ts +0 -18
- package/lib/framework/document-eval-func.js.map +0 -1
- package/lib/framework/document-event.d.ts +0 -213
- package/lib/framework/document-event.js.map +0 -1
- package/lib/framework/document-history.d.ts +0 -26
- package/lib/framework/document-history.js.map +0 -1
- package/lib/framework/document-images-loader.d.ts +0 -16
- package/lib/framework/document-images-loader.js.map +0 -1
- package/lib/framework/document-input-cursor.d.ts +0 -78
- package/lib/framework/document-input-cursor.js.map +0 -1
- package/lib/framework/document-paint.d.ts +0 -34
- package/lib/framework/document-paint.js.map +0 -1
- package/lib/framework/document-print-offscreen.d.ts +0 -38
- package/lib/framework/document-print-offscreen.js.map +0 -1
- package/lib/framework/document-print.d.ts +0 -60
- package/lib/framework/document-print.js.map +0 -1
- package/lib/framework/document-segmenter.d.ts +0 -2
- package/lib/framework/document-segmenter.js +0 -106
- package/lib/framework/document-segmenter.js.map +0 -1
- package/lib/framework/document-selection.d.ts +0 -89
- package/lib/framework/document-selection.js.map +0 -1
- package/lib/framework/document-template.d.ts +0 -4
- package/lib/framework/document-template.js.map +0 -1
- package/lib/framework/document-textline-mode.d.ts +0 -7
- package/lib/framework/document-textline-mode.js +0 -30
- package/lib/framework/document-textline-mode.js.map +0 -1
- package/lib/framework/element-define.d.ts +0 -319
- package/lib/framework/element-define.js.map +0 -1
- package/lib/framework/element-event-define.d.ts +0 -99
- package/lib/framework/element-event-define.js +0 -108
- package/lib/framework/element-event-define.js.map +0 -1
- package/lib/framework/element-measure.d.ts +0 -97
- package/lib/framework/element-measure.js.map +0 -1
- package/lib/framework/element-paint.d.ts +0 -42
- package/lib/framework/element-paint.js.map +0 -1
- package/lib/framework/element-props.d.ts +0 -301
- package/lib/framework/element-props.js.map +0 -1
- package/lib/framework/element-reader.d.ts +0 -19
- package/lib/framework/element-reader.js.map +0 -1
- package/lib/framework/element-render-cut.d.ts +0 -55
- package/lib/framework/element-render-cut.js.map +0 -1
- package/lib/framework/element-serialize.d.ts +0 -30
- package/lib/framework/element-serialize.js.map +0 -1
- package/lib/framework/element-util.d.ts +0 -369
- package/lib/framework/element-util.js.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts +0 -24
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.d.ts +0 -40
- package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.d.ts +0 -21
- package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.d.ts +0 -22
- package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-util.d.ts +0 -12
- package/lib/framework/impl/comments/comments-util.js.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.d.ts +0 -21
- package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.d.ts +0 -31
- package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts +0 -68
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts +0 -35
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts +0 -22
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +0 -21
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.d.ts +0 -27
- package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.d.ts +0 -30
- package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-container-impl.d.ts +0 -16
- package/lib/framework/impl/document/doc-container-impl.js +0 -21
- package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-footer-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-impl.d.ts +0 -61
- package/lib/framework/impl/document/doc-impl.js.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.d.ts +0 -35
- package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.d.ts +0 -45
- package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
- package/lib/framework/impl/picture/image-impl.d.ts +0 -31
- package/lib/framework/impl/picture/image-impl.js.map +0 -1
- package/lib/framework/impl/radio/radio-impl.d.ts +0 -22
- package/lib/framework/impl/radio/radio-impl.js.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts +0 -22
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts +0 -19
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.d.ts +0 -37
- package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
- package/lib/framework/impl/table/table-impl.d.ts +0 -55
- package/lib/framework/impl/table/table-impl.js.map +0 -1
- package/lib/framework/impl/table/table-row-impl.d.ts +0 -26
- package/lib/framework/impl/table/table-row-impl.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.d.ts +0 -20
- package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell.d.ts +0 -90
- package/lib/framework/impl/table/table-split-cell.js.map +0 -1
- package/lib/framework/impl/table/table-util.d.ts +0 -150
- package/lib/framework/impl/table/table-util.js.map +0 -1
- package/lib/framework/impl/text/text-impl.d.ts +0 -32
- package/lib/framework/impl/text/text-impl.js.map +0 -1
- package/lib/framework/impl/text/track-run-impl.d.ts +0 -27
- package/lib/framework/impl/text/track-run-impl.js.map +0 -1
- package/lib/framework/notify.d.ts +0 -13
- package/lib/framework/notify.js.map +0 -1
- package/lib/framework/range-util.d.ts +0 -40
- package/lib/framework/range-util.js.map +0 -1
- package/lib/framework/render-context.d.ts +0 -91
- package/lib/framework/render-context.js.map +0 -1
- package/lib/framework/render-define.d.ts +0 -109
- package/lib/framework/render-define.js.map +0 -1
- package/lib/framework/selection-overlays.d.ts +0 -30
- package/lib/framework/selection-overlays.js.map +0 -1
- package/lib/texteditor.d.ts +0 -318
- package/lib/texteditor.js.map +0 -1
- package/lib/util/subject.d.ts +0 -34
- package/lib/util/subject.js +0 -88
- package/lib/util/subject.js.map +0 -1
- package/lib/util/table-bind.d.ts +0 -5
- package/lib/util/table-bind.js.map +0 -1
- package/tsconfig.json +0 -25
@@ -1,43 +1,51 @@
|
|
1
1
|
import { DocumentEvalFunc } from "./document-eval-func";
|
2
2
|
import { DocumentImagesLoader } from "./document-images-loader";
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { SelectionState } from "./document-selection";
|
4
|
+
import { BranchElement, Element, ImgLoadStatus, ModifyFlag, Rect, RefreshType, ViewOptions } from "./element-define";
|
5
|
+
import { ElementEvent, EventTypes } from "./element-event-define";
|
6
|
+
import { DataElementValueStruct, ElementSerialize } from "./element-serialize";
|
5
7
|
import { DataElementInlineGroup, DataElementLeaf, validateDataEle } from "./impl/data-element/data-element-base-impl";
|
6
8
|
import { DataElementCheck } from "./impl/data-element/data-element-check-impl";
|
7
9
|
import { DocumentElement } from "./impl/document/doc-impl";
|
8
|
-
import { TrackRunElement } from "
|
10
|
+
import { TrackRunElement, TrackRunTypeEnum } from "./impl/text/track-run-impl";
|
9
11
|
import { ElementUtil } from "./element-util";
|
10
12
|
import { DocumentBodyPartElement } from "./impl/document/doc-body-part-impl";
|
13
|
+
import { DocumentChange } from "./document-change";
|
11
14
|
import { CommonUtil } from "./common-util";
|
15
|
+
|
16
|
+
interface RegisterTypeHandlerProps<T extends Element> {
|
17
|
+
elementType: { new(...args: any): T },
|
18
|
+
eventName: EventTypes,
|
19
|
+
handler: <E extends ElementEvent>(e: E) => void,
|
20
|
+
useCapture: boolean
|
21
|
+
}
|
12
22
|
/**
|
13
23
|
* 当前打开的文档的上下文信息,当前文档所有的属性设置都暴露在上下文中
|
14
24
|
*/
|
15
25
|
export class EditorContext {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
cursorRect;
|
20
|
-
_document;
|
26
|
+
isDirty: boolean = false;
|
27
|
+
cursorRect!: Rect | null;
|
28
|
+
private _document!: DocumentElement;
|
21
29
|
//文档刷新的订阅事件
|
22
30
|
//refSub!: Subscription;
|
23
|
-
syncRefresh;
|
24
|
-
imageLoader;
|
25
|
-
dynamicFunc;
|
26
|
-
docChange;
|
27
|
-
clearPrevDocCb;
|
28
|
-
constructor(selectionState, viewOptions) {
|
29
|
-
this.selectionState = selectionState;
|
30
|
-
this.viewOptions = viewOptions;
|
31
|
+
syncRefresh!: () => void;
|
32
|
+
imageLoader: IImageLoader;
|
33
|
+
dynamicFunc: DocumentEvalFunc;
|
34
|
+
docChange!: DocumentChange;
|
35
|
+
clearPrevDocCb!: (() => void) | null;
|
36
|
+
constructor(public readonly selectionState: SelectionState, public readonly viewOptions: ViewOptions) {
|
31
37
|
this.dynamicFunc = new DocumentEvalFunc(this);
|
32
38
|
this.imageLoader = new DocumentImagesLoader();
|
33
39
|
this.selectionState.onChangedEvent.subscribe(() => {
|
34
40
|
this.syncRefresh?.();
|
35
41
|
});
|
36
42
|
}
|
37
|
-
|
43
|
+
|
44
|
+
public get document(): DocumentElement {
|
38
45
|
return this._document;
|
39
46
|
}
|
40
|
-
|
47
|
+
|
48
|
+
public set document(value: DocumentElement) {
|
41
49
|
this.clearPrevDocCb?.();
|
42
50
|
this._document = value;
|
43
51
|
this.initScripts();
|
@@ -62,77 +70,88 @@ export class EditorContext {
|
|
62
70
|
this._document.destroy();
|
63
71
|
}
|
64
72
|
this.clearPrevDocCb = null;
|
65
|
-
}
|
73
|
+
}
|
66
74
|
}
|
67
|
-
|
75
|
+
|
76
|
+
clear(): void {
|
68
77
|
this.selectionState.clear();
|
69
|
-
this.imageLoader.clear()
|
70
|
-
;
|
78
|
+
this.imageLoader.clear();;
|
71
79
|
this.dynamicFunc.destroyScripts();
|
72
80
|
this.isDirty = false;
|
73
81
|
}
|
74
|
-
|
82
|
+
|
83
|
+
get defaultCtx(): DocumentContext {
|
75
84
|
return new DocumentContext(this._document, this.selectionState);
|
76
85
|
}
|
77
|
-
|
78
|
-
|
86
|
+
|
87
|
+
getCurrentCtx(ele: Element): DocumentContext {
|
88
|
+
const parentCtx = ElementUtil.getParent(ele, (item) => item instanceof DocumentElement || item instanceof DocumentBodyPartElement) as BranchElement;
|
79
89
|
return new DocumentContext(parentCtx, this.selectionState);
|
80
90
|
}
|
91
|
+
|
81
92
|
/**
|
82
93
|
* 根据当前选区,返回所在的上下文元素,返回类型为DocumentElement|DocumentBodyPartElement
|
83
94
|
*/
|
84
|
-
getCurrentEleCtx() {
|
95
|
+
getCurrentEleCtx(): BranchElement | null {
|
85
96
|
const { startControl } = this.selectionState;
|
86
97
|
if (!startControl) {
|
87
98
|
return null;
|
88
99
|
}
|
89
|
-
const parentCtx = ElementUtil.getParent(startControl, (item) => item instanceof DocumentElement || item instanceof DocumentBodyPartElement);
|
100
|
+
const parentCtx = ElementUtil.getParent(startControl, (item) => item instanceof DocumentElement || item instanceof DocumentBodyPartElement) as BranchElement;
|
90
101
|
return parentCtx;
|
91
102
|
}
|
92
|
-
|
103
|
+
|
104
|
+
getCtx(ele: BranchElement): DocumentContext {
|
93
105
|
return new DocumentContext(ele, this.selectionState);
|
94
106
|
}
|
95
|
-
|
96
|
-
|
107
|
+
|
108
|
+
|
109
|
+
private ele_types_handlers: Array<RegisterTypeHandlerProps<Element>> = [];
|
110
|
+
registerTypeHandlers<T extends Element>(elementType: { new(...args: any): T }, eventName: EventTypes, handler: (e: ElementEvent) => void, useCapture: boolean = false): void {
|
97
111
|
this.ele_types_handlers.push({
|
98
112
|
elementType,
|
99
113
|
eventName,
|
100
114
|
handler,
|
101
115
|
useCapture
|
102
|
-
})
|
116
|
+
})
|
103
117
|
}
|
104
|
-
|
118
|
+
|
119
|
+
invokeTypeHandler(ele: Element, eventName: EventTypes, e: ElementEvent, useCapture: boolean = false): void {
|
105
120
|
for (const th of this.ele_types_handlers) {
|
106
121
|
if (ele instanceof th.elementType && th.eventName === eventName && th.useCapture === useCapture) {
|
107
122
|
th.handler(e);
|
108
123
|
}
|
109
124
|
}
|
110
125
|
}
|
111
|
-
|
126
|
+
|
127
|
+
destroy(): void {
|
112
128
|
this.clear();
|
113
129
|
this.document.destroy();
|
114
130
|
this.clearPrevDocCb?.();
|
115
131
|
this.ele_types_handlers.length = 0;
|
116
|
-
this.imageLoader.clear()
|
117
|
-
;
|
132
|
+
this.imageLoader.clear();;
|
118
133
|
}
|
134
|
+
|
119
135
|
/**
|
120
136
|
* 切换到行打印模式
|
121
137
|
*/
|
122
|
-
switchTextlineMode() {
|
138
|
+
switchTextlineMode(): void {
|
123
139
|
this.document.viewOptions.textRowLineMode = !this.document.viewOptions.textRowLineMode;
|
124
140
|
this.syncRefresh();
|
125
141
|
}
|
142
|
+
|
126
143
|
/**
|
127
144
|
* 实例化动态脚本
|
128
145
|
*/
|
129
|
-
initScripts() {
|
146
|
+
private initScripts(): void {
|
130
147
|
this.dynamicFunc.initScripts(this.document.props.scripts);
|
131
148
|
}
|
149
|
+
|
150
|
+
|
132
151
|
/**
|
133
152
|
* 替换数据元
|
134
153
|
*/
|
135
|
-
replaceDataElement(oldDataElement, newElement, ss) {
|
154
|
+
replaceDataElement(oldDataElement: DataElementLeaf | DataElementInlineGroup, newElement: DataElementLeaf | DataElementInlineGroup, ss: SelectionState): void {
|
136
155
|
//清除光标
|
137
156
|
ss.clear();
|
138
157
|
//执行刷新
|
@@ -141,72 +160,96 @@ export class EditorContext {
|
|
141
160
|
//删除旧节点
|
142
161
|
oldDataElement.remove();
|
143
162
|
}
|
144
|
-
|
145
|
-
|
163
|
+
|
164
|
+
get refreshType(): RefreshType {
|
165
|
+
return this._document?.modifyFlag === ModifyFlag.None ? 'appearance' : 'content'
|
146
166
|
}
|
147
167
|
}
|
168
|
+
|
169
|
+
export interface ImageSourceItem {
|
170
|
+
src: string,
|
171
|
+
task: Promise<void>;
|
172
|
+
cbs: Array<(status: ImgLoadStatus) => void>;
|
173
|
+
ele: HTMLImageElement,
|
174
|
+
loadStatus: ImgLoadStatus
|
175
|
+
}
|
176
|
+
|
177
|
+
export interface IImageLoader {
|
178
|
+
clear(): void;
|
179
|
+
loadImage(src: string, onCallback: (status: ImgLoadStatus) => void): void;
|
180
|
+
getImage(src: string): HTMLImageElement | undefined;
|
181
|
+
imagesLoadCompleted(): boolean;
|
182
|
+
getLoadTasks(): Array<Promise<void>>;
|
183
|
+
}
|
184
|
+
|
148
185
|
/**
|
149
186
|
* 文档上下文
|
150
187
|
*/
|
151
188
|
export class DocumentContext {
|
152
|
-
ctx
|
153
|
-
|
154
|
-
|
155
|
-
this.ctx
|
156
|
-
this.ss = ss;
|
157
|
-
}
|
158
|
-
getControlIDList() {
|
159
|
-
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item));
|
189
|
+
constructor(private ctx: BranchElement, private ss: SelectionState) { }
|
190
|
+
|
191
|
+
getControlIDList(): Array<string> {
|
192
|
+
const dataEleList = <unknown>this.ctx.treeFilter(item => validateDataEle(item)) as Array<{ props: { id: string } }>;
|
160
193
|
return dataEleList.map(item => item.props.id);
|
161
194
|
}
|
162
|
-
|
163
|
-
|
195
|
+
|
196
|
+
getControlInstanceList(): Array<DataElementInlineGroup | DataElementLeaf> {
|
197
|
+
return this.ctx.treeFilter(item => validateDataEle(item)) as Array<DataElementInlineGroup | DataElementLeaf>;
|
164
198
|
}
|
165
|
-
|
166
|
-
|
199
|
+
|
200
|
+
getControlById(id: string): DataElementInlineGroup | DataElementLeaf {
|
201
|
+
return this.ctx.treeFind(item => validateDataEle(item) && (<any>item)['props']['id'] === id) as DataElementInlineGroup | DataElementLeaf;
|
167
202
|
}
|
168
|
-
|
169
|
-
|
203
|
+
|
204
|
+
getControlByName(name: string): DataElementInlineGroup | DataElementLeaf {
|
205
|
+
return this.ctx.treeFind(item => validateDataEle(item) && (<any>item)['props']['name'] === name) as DataElementInlineGroup | DataElementLeaf;
|
170
206
|
}
|
207
|
+
|
171
208
|
/**
|
172
209
|
* 获取数据元值集合
|
173
210
|
*/
|
174
|
-
getDataElementValues() {
|
211
|
+
getDataElementValues(): Array<DataElementValueStruct> {
|
175
212
|
const structList = this.getDataElementModelList();
|
176
|
-
return structList.map(item => ({
|
213
|
+
return structList.map<DataElementValueStruct>(item => ({
|
177
214
|
id: item.id,
|
178
215
|
name: item.name,
|
179
216
|
value: item.getValue()
|
180
217
|
}));
|
181
218
|
}
|
219
|
+
|
182
220
|
/**
|
183
221
|
* 获取数据元结构以及get\set闭包调用函数
|
184
|
-
* @returns
|
222
|
+
* @returns
|
185
223
|
*/
|
186
|
-
getDataElementModelList() {
|
187
|
-
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item))
|
188
|
-
|
189
|
-
const
|
224
|
+
getDataElementModelList(): Array<DataCheckEleModel | DataInputEleModel | DataLeafEleModel> {
|
225
|
+
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item)) as Array<DataElementInlineGroup | DataElementLeaf>;
|
226
|
+
|
227
|
+
const dataInlineGroups = dataEleList.filter(item => item instanceof DataElementInlineGroup) as Array<DataElementInlineGroup>;
|
228
|
+
const dataLeafs = dataEleList.filter(item => item instanceof DataElementLeaf) as Array<DataElementLeaf>;
|
229
|
+
|
190
230
|
//复选框数据元
|
191
|
-
const dataCheckList = dataLeafs.filter(item => item instanceof DataElementCheck)
|
231
|
+
const dataCheckList = dataLeafs.filter(item => item instanceof DataElementCheck) as Array<DataElementCheck>;
|
192
232
|
//除复选框之外的LeafDataElement
|
193
|
-
const dataOtherLeafValues = CommonUtil.removeUnionSet(dataLeafs, dataCheckList).map(item => (
|
194
|
-
|
233
|
+
const dataOtherLeafValues = CommonUtil.removeUnionSet(dataLeafs, dataCheckList).map<DataLeafEleModel>(item => (
|
234
|
+
{ id: item.props.id as string, name: item.props.name as string, fieldName: item.props.field as string, item, getValue: () => { return item.getValue() }, setValue: (val) => { item.setValue(val) } }));
|
235
|
+
const dataInlineStructList = dataInlineGroups.map<DataInputEleModel>(item => (
|
236
|
+
{ id: item.props.id, name: item.props.name, fieldName: item.props.fieldName, item, getValue: () => { return item.getValue() }, setValue: (val) => { item.setValue(val) } }));
|
195
237
|
//复选框列表
|
196
238
|
const dataCheckStructList = this.getDataCheckModelList(dataCheckList);
|
197
239
|
return [...dataInlineStructList, ...dataCheckStructList, ...dataOtherLeafValues];
|
198
240
|
}
|
241
|
+
|
199
242
|
/**
|
200
243
|
* 获取复选框数据元结构列表
|
201
|
-
* @param dataCheckList
|
202
|
-
* @returns
|
244
|
+
* @param dataCheckList
|
245
|
+
* @returns
|
203
246
|
*/
|
204
|
-
getDataCheckModelList(dataCheckList) {
|
247
|
+
private getDataCheckModelList(dataCheckList: Array<DataElementCheck>): Array<DataCheckEleModel | DataLeafEleModel> {
|
205
248
|
//不存在groupName的复选框
|
206
249
|
const singleCheckList = dataCheckList.filter(item => !item.props.groupName);
|
207
250
|
//存在groupName的复选框
|
208
251
|
const groupNames = Array.from(new Set(dataCheckList.filter(item => item.props.groupName).map(item => item.props.groupName)));
|
209
|
-
const groupCheckListValues = groupNames.map((groupName) => {
|
252
|
+
const groupCheckListValues = groupNames.map<DataCheckEleModel>((groupName) => {
|
210
253
|
const groupCheckItems = dataCheckList.filter(item => item.props.groupName === groupName);
|
211
254
|
return {
|
212
255
|
id: groupName,
|
@@ -218,17 +261,15 @@ export class DocumentContext {
|
|
218
261
|
let checkedValue = '';
|
219
262
|
if (groupCheckItems[0].props.multiSelect) {
|
220
263
|
checkedValue = groupCheckItems.filter(item => item.props.checked).map(item => item.getValue() + '').join(';');
|
221
|
-
}
|
222
|
-
|
223
|
-
const checkedSingleItem = groupCheckItems.find(item => item.props.checked);
|
264
|
+
} else {
|
265
|
+
const checkedSingleItem = groupCheckItems.find(item => item.props.checked)
|
224
266
|
if (checkedSingleItem) {
|
225
267
|
checkedValue = checkedSingleItem.props.checkedValue;
|
226
268
|
}
|
227
|
-
}
|
228
|
-
;
|
269
|
+
};
|
229
270
|
return checkedValue;
|
230
271
|
},
|
231
|
-
setValue: (val) => {
|
272
|
+
setValue: (val: string | Array<string>) => {
|
232
273
|
//为null时
|
233
274
|
if (val === null || val === undefined) {
|
234
275
|
groupCheckItems.forEach(item => item.props.checked = false);
|
@@ -236,38 +277,40 @@ export class DocumentContext {
|
|
236
277
|
}
|
237
278
|
if (groupCheckItems[0].props.multiSelect) {
|
238
279
|
const valItems = typeof val === 'string' ? val.split(';') : val;
|
280
|
+
|
239
281
|
groupCheckItems.forEach(item => {
|
240
282
|
item.props.checked = valItems.indexOf(item.props.checkedValue + '') >= 0;
|
241
283
|
});
|
242
|
-
}
|
243
|
-
else {
|
284
|
+
} else {
|
244
285
|
groupCheckItems.forEach(item => {
|
245
286
|
item.props.checked = item.props.checkedValue === val;
|
246
287
|
});
|
247
|
-
}
|
248
|
-
;
|
288
|
+
};
|
249
289
|
}
|
250
|
-
}
|
251
|
-
})
|
252
|
-
const singleCheckListValues = singleCheckList.map(item => ({ id: item.props.id, name: item.props.name, fieldName: item.props.fieldName, item, getValue: () => { return item.getValue()
|
290
|
+
}
|
291
|
+
})
|
292
|
+
const singleCheckListValues = singleCheckList.map<DataLeafEleModel>(item => ({ id: item.props.id, name: item.props.name, fieldName: item.props.fieldName, item, getValue: () => { return item.getValue() }, setValue: (val) => { item.setValue(val) } }));
|
253
293
|
return [...singleCheckListValues, ...groupCheckListValues];
|
254
294
|
}
|
295
|
+
|
255
296
|
/**
|
256
297
|
* 获取留痕块元素列表
|
257
298
|
*/
|
258
|
-
getTrackElements() {
|
259
|
-
return this.ctx.treeFilter(item => item instanceof TrackRunElement)
|
299
|
+
getTrackElements(): Array<TrackRunElement> {
|
300
|
+
return this.ctx.treeFilter(item => item instanceof TrackRunElement) as Array<TrackRunElement>;
|
260
301
|
}
|
261
|
-
|
262
|
-
|
302
|
+
|
303
|
+
getTrackElmeentById(id: string): TrackRunElement | null {
|
304
|
+
return this.ctx.treeFind(item => item instanceof TrackRunElement && item.props.id === id) as TrackRunElement | null;
|
263
305
|
}
|
306
|
+
|
264
307
|
/**
|
265
308
|
* 获取留痕块内数据
|
266
309
|
*/
|
267
|
-
getTracksData() {
|
310
|
+
getTracksData(): Array<TrackBlockData> {
|
268
311
|
const trackElements = this.getTrackElements();
|
269
312
|
return trackElements.map(item => {
|
270
|
-
const trackRun = item;
|
313
|
+
const trackRun = item as TrackRunElement;
|
271
314
|
const content = ElementSerialize.serializeString(trackRun, { all: true });
|
272
315
|
return {
|
273
316
|
//用户id
|
@@ -277,45 +320,50 @@ export class DocumentContext {
|
|
277
320
|
//日期
|
278
321
|
date: trackRun.props.date,
|
279
322
|
//类型,ins-run:插入,del-run:删除
|
280
|
-
type: trackRun.type,
|
323
|
+
type: trackRun.type as TrackRunTypeEnum,
|
281
324
|
//留痕块id
|
282
325
|
id: trackRun.props.id,
|
283
326
|
//内容
|
284
327
|
content
|
285
|
-
}
|
328
|
+
}
|
286
329
|
});
|
287
330
|
}
|
288
|
-
|
331
|
+
|
332
|
+
setControlValue(id: string, value: string): void {
|
289
333
|
const dataEle = this.getControlById(id);
|
290
334
|
if (dataEle) {
|
291
335
|
dataEle.setValue(value);
|
292
336
|
}
|
293
337
|
this.ss.clear();
|
294
338
|
}
|
295
|
-
|
296
|
-
|
297
|
-
dataEle.
|
339
|
+
|
340
|
+
setControlValueByName(name: string, val: any): void {
|
341
|
+
const dataEle = this.getControlByName(name)
|
342
|
+
dataEle.setValue(val)
|
298
343
|
}
|
344
|
+
|
299
345
|
/**
|
300
346
|
* 获取复选框选中的值
|
301
347
|
*/
|
302
|
-
getCheckBoxValues(groupName) {
|
348
|
+
getCheckBoxValues(groupName: string): Array<string> {
|
303
349
|
const ckbs = this.getCheckBoxList(groupName);
|
304
350
|
return ckbs.filter(item => item.props.checked).map(item => item.props.checkedValue);
|
305
351
|
}
|
306
|
-
|
307
|
-
|
352
|
+
|
353
|
+
getCheckBoxList(groupName: string): Array<DataElementCheck> {
|
354
|
+
return this.getControlInstanceList().filter(item => item instanceof DataElementCheck && item.props.groupName === groupName) as Array<DataElementCheck>;
|
308
355
|
}
|
356
|
+
|
309
357
|
/**
|
310
358
|
* 当前上下文执行默认绑定
|
311
|
-
* @param data
|
359
|
+
* @param data
|
312
360
|
*/
|
313
|
-
bindDataValues(data, predicateKey = 'fieldName') {
|
361
|
+
bindDataValues(data: string | Object | Array<{ key: string, value: any }>, predicateKey: 'id' | 'name' | 'fieldName' = 'fieldName'): void {
|
314
362
|
this.ss.clear();
|
315
|
-
let bindData = typeof data === 'string' ? JSON.parse(data) : data;
|
363
|
+
let bindData = typeof data === 'string' ? JSON.parse(data) as Object : data;
|
316
364
|
if (Array.isArray(bindData)) {
|
317
365
|
const obj = {};
|
318
|
-
bindData.forEach(item => { obj[item.key] = item.value
|
366
|
+
bindData.forEach(item => { obj[item.key] = item.value });
|
319
367
|
bindData = obj;
|
320
368
|
}
|
321
369
|
const dataList = this.getDataElementModelList();
|
@@ -327,4 +375,36 @@ export class DocumentContext {
|
|
327
375
|
});
|
328
376
|
}
|
329
377
|
}
|
330
|
-
|
378
|
+
|
379
|
+
|
380
|
+
interface DataEleBaseModel {
|
381
|
+
id: string;
|
382
|
+
name: string;
|
383
|
+
fieldName: string;
|
384
|
+
getValue: () => any;
|
385
|
+
setValue: (val: any) => void;
|
386
|
+
}
|
387
|
+
interface DataCheckEleModel extends DataEleBaseModel {
|
388
|
+
item: Array<DataElementCheck>;
|
389
|
+
multiSelect: boolean;
|
390
|
+
}
|
391
|
+
|
392
|
+
interface DataInputEleModel extends DataEleBaseModel {
|
393
|
+
item: DataElementInlineGroup
|
394
|
+
}
|
395
|
+
|
396
|
+
interface DataLeafEleModel extends DataEleBaseModel {
|
397
|
+
item: DataElementLeaf;
|
398
|
+
}
|
399
|
+
|
400
|
+
/**
|
401
|
+
* 留痕块结构化数据
|
402
|
+
*/
|
403
|
+
interface TrackBlockData {
|
404
|
+
userId: string;
|
405
|
+
userName: string;
|
406
|
+
date: string;
|
407
|
+
type: TrackRunTypeEnum,
|
408
|
+
content: string,
|
409
|
+
id: string;
|
410
|
+
}
|
package/{lib/framework/document-eval-func.js → src/med_editor/framework/document-eval-func.ts}
RENAMED
@@ -1,22 +1,24 @@
|
|
1
|
+
import { EditorContext } from "./document-context";
|
2
|
+
|
1
3
|
export class DocumentEvalFunc {
|
2
|
-
docCtx
|
3
|
-
|
4
|
-
this.docCtx = docCtx;
|
4
|
+
constructor(public docCtx: EditorContext) {
|
5
|
+
|
5
6
|
}
|
6
|
-
scriptsFunc;
|
7
|
+
scriptsFunc!: (() => void) | null;
|
8
|
+
|
7
9
|
/**
|
8
10
|
* 实例化动态脚本
|
9
11
|
*/
|
10
|
-
initScripts(scripts) {
|
12
|
+
initScripts(scripts: string): void {
|
11
13
|
this.destroyScripts();
|
12
14
|
if (scripts) {
|
13
15
|
try {
|
14
|
-
const func = new Function("docCtx", scripts)
|
16
|
+
const func = new Function("docCtx", scripts)
|
15
17
|
this.scriptsFunc = func(this.docCtx);
|
16
|
-
}
|
17
|
-
catch (e) {
|
18
|
+
} catch (e) {
|
18
19
|
console.error("自定义标本解析错误", e);
|
19
20
|
}
|
21
|
+
|
20
22
|
}
|
21
23
|
// const func = (docCtx: DocumentContext) => {
|
22
24
|
// const sexELe = docCtx.getControlById('NqoYI')
|
@@ -30,19 +32,22 @@ export class DocumentEvalFunc {
|
|
30
32
|
// };
|
31
33
|
// };
|
32
34
|
}
|
35
|
+
|
33
36
|
/**
|
34
37
|
* 销毁动态脚本实例
|
35
38
|
*/
|
36
|
-
destroyScripts() {
|
39
|
+
destroyScripts(): void {
|
37
40
|
if (this.scriptsFunc) {
|
38
41
|
this.scriptsFunc = null;
|
39
42
|
}
|
40
43
|
}
|
44
|
+
|
41
45
|
/**
|
42
46
|
* 触发动态脚本
|
43
47
|
*/
|
44
|
-
invokedScripts() {
|
48
|
+
invokedScripts(): void {
|
45
49
|
this.scriptsFunc?.();
|
46
50
|
}
|
51
|
+
|
52
|
+
|
47
53
|
}
|
48
|
-
//# sourceMappingURL=document-eval-func.js.map
|