@hailin-zheng/editor-core 1.0.6 → 1.0.9
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 +2 -2
- 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
@@ -1,19 +1,17 @@
|
|
1
|
-
import { LeafElement } from "
|
2
|
-
import { ElementUtil } from "
|
3
|
-
import {
|
1
|
+
import { LeafElement, SerializeProps } from "../../element-define";
|
2
|
+
import { ElementUtil } from "../../element-util";
|
3
|
+
import { RenderContenxtType } from "../../render-context";
|
4
|
+
import { LeafRenderObject, RenderObject } from "../../render-define";
|
4
5
|
import { InlineGroupInputElement, validateInlineInputRenderObj } from "./data-element-base-impl";
|
5
|
-
|
6
|
-
|
7
|
-
isPrefix;
|
6
|
+
|
7
|
+
export class DataDecorateElement extends LeafElement<any> {
|
8
8
|
//props: DataDecorateProps;
|
9
|
-
constructor(dataEle, isPrefix) {
|
9
|
+
constructor(public dataEle: InlineGroupInputElement, public isPrefix: boolean) {
|
10
10
|
super('data-dec');
|
11
|
-
this.dataEle = dataEle;
|
12
|
-
this.isPrefix = isPrefix;
|
13
11
|
this.addEvent('GotCursor', (evt) => {
|
14
12
|
const { selectionState } = evt.ctx;
|
15
13
|
if (selectionState.collapsed && this.parent instanceof InlineGroupInputElement) {
|
16
|
-
const group = this.parent;
|
14
|
+
const group = this.parent as InlineGroupInputElement;
|
17
15
|
if (this === group.endDecorate && selectionState.startOffset === 0) {
|
18
16
|
if (group.length === 2) {
|
19
17
|
selectionState.resetRange(group.startDecorate, 1);
|
@@ -24,36 +22,41 @@ export class DataDecorateElement extends LeafElement {
|
|
24
22
|
});
|
25
23
|
this.isDecorate = true;
|
26
24
|
}
|
27
|
-
createRenderObject() {
|
25
|
+
createRenderObject(): DataDecorateRenderObject {
|
28
26
|
const render = new DataDecorateRenderObject(this);
|
29
27
|
//render.rect.width = this.dProps.size / 2;
|
30
28
|
render.rect.width = 6;
|
31
29
|
render.rect.height = 14;
|
32
30
|
return render;
|
33
31
|
}
|
34
|
-
|
32
|
+
|
33
|
+
serialize(): SerializeProps | null {
|
35
34
|
return null;
|
36
35
|
}
|
37
|
-
clone() {
|
36
|
+
clone(): DataDecorateElement {
|
38
37
|
const clone = new DataDecorateElement(this.dataEle, this.isPrefix);
|
39
38
|
this.props.clone(clone.props);
|
40
39
|
//clone.renderCtx = this.renderCtx;
|
41
40
|
return clone;
|
42
41
|
}
|
43
42
|
}
|
43
|
+
|
44
44
|
export class DataDecorateArrowRenderObject extends LeafRenderObject {
|
45
|
-
render(ctx, position) {
|
45
|
+
render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
46
46
|
throw new Error("Method not implemented.");
|
47
47
|
}
|
48
|
-
clone() {
|
48
|
+
clone(): RenderObject {
|
49
49
|
throw new Error("Method not implemented.");
|
50
50
|
}
|
51
|
+
|
51
52
|
}
|
53
|
+
|
52
54
|
export class DataDecorateRenderObject extends LeafRenderObject {
|
53
|
-
render(ctx, position) {
|
55
|
+
render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
54
56
|
this.renderDecorRect(ctx, position);
|
55
57
|
}
|
56
|
-
|
58
|
+
|
59
|
+
renderDecorRect(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
57
60
|
if (ctx.drawMode === 'print') {
|
58
61
|
return;
|
59
62
|
}
|
@@ -62,7 +65,7 @@ export class DataDecorateRenderObject extends LeafRenderObject {
|
|
62
65
|
return;
|
63
66
|
}
|
64
67
|
const dataEleRenderPos = ElementUtil.getParentRenderPos(dataEleRender, this, position);
|
65
|
-
const element = this.element;
|
68
|
+
const element = this.element as DataDecorateElement;
|
66
69
|
let { x, y, height, width } = dataEleRenderPos;
|
67
70
|
const lineWidth = 2;
|
68
71
|
const paintColor = '#0050b3';
|
@@ -74,18 +77,19 @@ export class DataDecorateRenderObject extends LeafRenderObject {
|
|
74
77
|
if (element.isPrefix) {
|
75
78
|
x += 2;
|
76
79
|
ctx.contentContext.strokeLines([{ x: x + lineWidth, y }, { x: x, y }, { x: x, y: y + height }, { x: x + lineWidth, y: y + height }], 1, paintColor);
|
77
|
-
}
|
78
|
-
else {
|
80
|
+
} else {
|
79
81
|
x = x + width - 2;
|
80
82
|
ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x: x, y }, { x: x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);
|
81
83
|
}
|
82
84
|
ctx.contentContext.ctx.restore();
|
83
85
|
return;
|
86
|
+
|
84
87
|
}
|
85
|
-
|
88
|
+
|
89
|
+
clone(cloneData = true): RenderObject {
|
86
90
|
const clone = new DataDecorateRenderObject(this.element);
|
87
91
|
clone.rect = ElementUtil.cloneRect(this.rect);
|
88
92
|
return clone;
|
89
93
|
}
|
94
|
+
|
90
95
|
}
|
91
|
-
//# sourceMappingURL=data-decorate-impl.js.map
|
@@ -1,13 +1,17 @@
|
|
1
|
-
import { ElementFactory, ResizeLeafRenderObject } from "
|
2
|
-
import { DataElementBarcodeProps } from "
|
3
|
-
import { ElementUtil } from "
|
1
|
+
import { Element, ElementFactory, Position, readElementProps, ResizeLeafRenderObject, SerializeProps, ViewOptions } from "../../element-define";
|
2
|
+
import { DataElementBarcodeProps } from "../../element-props";
|
3
|
+
import { ElementUtil } from "../../element-util";
|
4
|
+
import { RenderContenxtType } from "../../render-context";
|
5
|
+
import { LeafRenderObject, RenderObject } from "../../render-define";
|
4
6
|
import { DataElementLeaf } from "./data-element-base-impl";
|
5
7
|
import bwipjs from "bwip-js";
|
6
8
|
import { watchChanged } from "../../notify";
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
|
11
|
+
export class DataElementBarcode extends DataElementLeaf<DataElementBarcodeProps> {
|
12
|
+
resizeable: boolean = true;
|
13
|
+
private barCodeCanvas!: HTMLCanvasElement | null;
|
14
|
+
private cache = false;
|
11
15
|
constructor() {
|
12
16
|
super('data-ele-barcode');
|
13
17
|
this.props = new DataElementBarcodeProps();
|
@@ -18,36 +22,40 @@ export class DataElementBarcode extends DataElementLeaf {
|
|
18
22
|
this.cache = false;
|
19
23
|
});
|
20
24
|
}
|
21
|
-
createRenderObject() {
|
25
|
+
createRenderObject(): LeafRenderObject {
|
22
26
|
const render = new DataElementBarcodeRenderObject(this);
|
23
27
|
render.rect.width = this.props.width + 2;
|
24
28
|
render.rect.height = this.props.height + 2;
|
25
29
|
return render;
|
26
30
|
}
|
27
|
-
serialize(options) {
|
31
|
+
serialize(options: ViewOptions): SerializeProps {
|
28
32
|
return {
|
29
33
|
type: this.type,
|
30
34
|
props: {
|
31
35
|
...this.props.getSerializeProps()
|
32
36
|
}
|
33
|
-
}
|
37
|
+
}
|
34
38
|
}
|
35
|
-
clone(data) {
|
39
|
+
clone(data: boolean): Element {
|
36
40
|
const clone = new DataElementBarcode();
|
37
41
|
this.props.clone(clone.props);
|
38
42
|
return clone;
|
39
43
|
}
|
40
|
-
|
44
|
+
|
45
|
+
setValue(val: string): void {
|
41
46
|
this.props.text = val;
|
42
47
|
}
|
43
|
-
|
48
|
+
|
49
|
+
getValue(): string {
|
44
50
|
return this.props.text;
|
45
51
|
}
|
46
|
-
|
52
|
+
|
53
|
+
drawBarcode(renderCtx: RenderContenxtType, pos: Position): void {
|
47
54
|
this.createBarcodeCache();
|
48
|
-
renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas, pos.x, pos.y, this.props.width, this.props.height);
|
55
|
+
renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas as HTMLCanvasElement, pos.x, pos.y, this.props.width, this.props.height);
|
49
56
|
}
|
50
|
-
|
57
|
+
|
58
|
+
createBarcodeCache(): void {
|
51
59
|
if (this.cache) {
|
52
60
|
return;
|
53
61
|
}
|
@@ -56,25 +64,27 @@ export class DataElementBarcode extends DataElementLeaf {
|
|
56
64
|
this.barCodeCanvas = document.createElement('canvas');
|
57
65
|
}
|
58
66
|
this.barCodeCanvas = bwipjs.toCanvas(this.barCodeCanvas, {
|
59
|
-
bcid: this.props.type,
|
60
|
-
text: this.props.text || "0123456789",
|
61
|
-
height: 10,
|
62
|
-
includetext: true,
|
67
|
+
bcid: this.props.type, // Barcode type
|
68
|
+
text: this.props.text || "0123456789", // Text to encode
|
69
|
+
height: 10, // Bar height, in millimeters
|
70
|
+
includetext: true, // Show human-readable text
|
63
71
|
textxalign: "center", // Always good to set this
|
64
72
|
});
|
65
73
|
}
|
66
74
|
}
|
75
|
+
|
67
76
|
export class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
|
68
|
-
render(ctx, position) {
|
69
|
-
const barcodeEle = this.element;
|
77
|
+
render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
78
|
+
const barcodeEle = this.element as DataElementBarcode;
|
70
79
|
barcodeEle.drawBarcode(ctx, position);
|
71
80
|
}
|
72
|
-
clone() {
|
81
|
+
clone(): RenderObject {
|
73
82
|
const clone = new DataElementBarcodeRenderObject(this.element);
|
74
83
|
clone.rect = ElementUtil.cloneRect(this.rect);
|
75
84
|
return clone;
|
76
85
|
}
|
77
|
-
|
86
|
+
|
87
|
+
pagePaintCompleted(ctx: RenderContenxtType, pos: Position): void {
|
78
88
|
if (this.element.isFocused) {
|
79
89
|
const { width, height } = this.rect;
|
80
90
|
ctx.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
|
@@ -88,7 +98,8 @@ export class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
|
|
88
98
|
this.drawResizeCircle(ctx, pos.x + width, pos.y + (Math.floor(height / 2)));
|
89
99
|
}
|
90
100
|
}
|
91
|
-
|
101
|
+
|
102
|
+
private drawResizeCircle(ctx: RenderContenxtType, x: number, y: number): void {
|
92
103
|
const ctxNative = ctx.contentContext.ctx;
|
93
104
|
ctxNative.save();
|
94
105
|
ctxNative.fillStyle = '#69c0ff';
|
@@ -99,11 +110,13 @@ export class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
|
|
99
110
|
ctxNative.restore();
|
100
111
|
}
|
101
112
|
}
|
102
|
-
|
103
|
-
|
113
|
+
|
114
|
+
|
115
|
+
export class DataElementBarcodeFactory extends ElementFactory<DataElementBarcodeProps> {
|
116
|
+
match(type: string): boolean {
|
104
117
|
return type === 'data-ele-barcode';
|
105
118
|
}
|
106
|
-
createElement(data
|
119
|
+
createElement(data: readElementProps<DataElementBarcodeProps>, renderCtx: RenderContenxtType): Element {
|
107
120
|
const ele = new DataElementBarcode();
|
108
121
|
ele.props.width = data.props?.width || 100;
|
109
122
|
ele.props.height = data.props?.height || 30;
|
@@ -112,4 +125,3 @@ export class DataElementBarcodeFactory extends ElementFactory {
|
|
112
125
|
return ele;
|
113
126
|
}
|
114
127
|
}
|
115
|
-
//# sourceMappingURL=data-element-barcode.js.map
|
@@ -1,34 +1,41 @@
|
|
1
|
-
import { DocMode, InlineGroupElement, LeafElement } from "
|
2
|
-
import { InlineGroupRenderObject } from "
|
1
|
+
import { DocMode, Element, InlineGroupElement, LeafElement } from "../../element-define";
|
2
|
+
import { InlineGroupRenderObject, RenderObject } from "../../render-define";
|
3
|
+
import { ContextMenuElementEvent, GotCursorEvent, KeyboradElementEvent } from "../../element-event-define";
|
4
|
+
import { DataEleBaseProps, TextProps } from "../../element-props";
|
3
5
|
import { DataDecorateElement } from "./data-decorate-impl";
|
6
|
+
import { RenderContenxtType } from "../../render-context";
|
4
7
|
import { ElementUtil } from "../../element-util";
|
8
|
+
|
5
9
|
/**
|
6
10
|
* 所有的数据元继承上述两个抽象类
|
7
11
|
*/
|
8
|
-
export class DataElementLeaf extends LeafElement {
|
12
|
+
export abstract class DataElementLeaf<P extends object = any> extends LeafElement<P> {
|
13
|
+
abstract setValue(val: any): void;
|
14
|
+
abstract getValue(): any;
|
9
15
|
}
|
16
|
+
|
10
17
|
/**
|
11
18
|
* 可供输入的内联块
|
12
19
|
* 使用场景:数据元,数据组
|
13
20
|
*/
|
14
|
-
export class InlineGroupInputElement extends InlineGroupElement
|
15
|
-
startDecorate;
|
16
|
-
endDecorate;
|
17
|
-
constructor(type) {
|
21
|
+
export abstract class InlineGroupInputElement<P extends object = any> extends InlineGroupElement<P>{
|
22
|
+
startDecorate!: DataDecorateElement;
|
23
|
+
endDecorate!: DataDecorateElement;
|
24
|
+
constructor(type: string) {
|
18
25
|
super(type);
|
19
26
|
//行内块不允许换行
|
20
|
-
this.addEvent('ElementKeyDown', (evt) => {
|
27
|
+
this.addEvent<KeyboradElementEvent>('ElementKeyDown', (evt) => {
|
21
28
|
const { selectionState, sourceEvent, source } = evt;
|
22
29
|
const { startControl, startOffset } = selectionState;
|
23
|
-
if (IsInSideDataElement(startControl, startOffset)) {
|
30
|
+
if (IsInSideDataElement(startControl as LeafElement, startOffset)) {
|
24
31
|
if (sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
|
25
32
|
//this.removeNullText();
|
26
|
-
}
|
27
|
-
else if (!sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
|
33
|
+
} else if (!sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
|
28
34
|
evt.isCancel = true;
|
29
35
|
}
|
30
36
|
}
|
31
37
|
}, true);
|
38
|
+
|
32
39
|
this.addEvent('GotCursor', (evt) => {
|
33
40
|
const { startControl, startOffset } = evt.selectionState;
|
34
41
|
if (IsInSideDataElement(startControl, startOffset)) {
|
@@ -37,7 +44,8 @@ export class InlineGroupInputElement extends InlineGroupElement {
|
|
37
44
|
});
|
38
45
|
this.addEvent('LostCursor', (evt) => { this.isFocused = false; });
|
39
46
|
}
|
40
|
-
|
47
|
+
|
48
|
+
fillDecorate(): void {
|
41
49
|
if (!this.startDecorate) {
|
42
50
|
const { startDecorate, endDecorate } = this.createDataDecorate();
|
43
51
|
this.addChild(startDecorate, 0);
|
@@ -46,19 +54,22 @@ export class InlineGroupInputElement extends InlineGroupElement {
|
|
46
54
|
this.endDecorate = endDecorate;
|
47
55
|
}
|
48
56
|
}
|
49
|
-
|
57
|
+
|
58
|
+
createDataDecorate(): { startDecorate: DataDecorateElement, endDecorate: DataDecorateElement } {
|
50
59
|
const startDecorate = new DataDecorateElement(this, true);
|
51
60
|
const endDecorate = new DataDecorateElement(this, false);
|
52
61
|
return {
|
53
62
|
startDecorate,
|
54
63
|
endDecorate
|
55
|
-
}
|
64
|
+
}
|
56
65
|
}
|
57
|
-
|
66
|
+
|
67
|
+
beginMeasure(): void {
|
58
68
|
this.fillDecorate();
|
59
69
|
super.beginMeasure();
|
60
70
|
}
|
61
|
-
|
71
|
+
|
72
|
+
addChild(child: Element<any>, index: number = -1): void {
|
62
73
|
index = index === -1 ? this.length : index;
|
63
74
|
index = index > this.length ? this.length : index;
|
64
75
|
if (index === 0 && this.startDecorate) {
|
@@ -71,8 +82,9 @@ export class InlineGroupInputElement extends InlineGroupElement {
|
|
71
82
|
}
|
72
83
|
super.addChild(child, index);
|
73
84
|
}
|
74
|
-
|
75
|
-
|
85
|
+
|
86
|
+
clearInnerItems(): void {
|
87
|
+
const removeItems: Array<Element> = [];
|
76
88
|
for (let i = this.length - 1; i >= 0; i--) {
|
77
89
|
const child = this.getChild(i);
|
78
90
|
if (child !== this.startDecorate && child !== this.endDecorate) {
|
@@ -82,8 +94,9 @@ export class InlineGroupInputElement extends InlineGroupElement {
|
|
82
94
|
removeItems.forEach(item => this.removeChild(item));
|
83
95
|
}
|
84
96
|
}
|
85
|
-
|
86
|
-
|
97
|
+
|
98
|
+
export abstract class DataElementInlineGroup<P extends DataEleBaseProps = DataEleBaseProps & { valueTextProps: TextProps }> extends InlineGroupInputElement<P> {
|
99
|
+
constructor(type: string) {
|
87
100
|
super(type);
|
88
101
|
this.addEvent('ElementMousemove', (evt) => {
|
89
102
|
this.isMouseenter = true;
|
@@ -91,16 +104,17 @@ export class DataElementInlineGroup extends InlineGroupInputElement {
|
|
91
104
|
});
|
92
105
|
this.addEvent('ElementMouseLeave', (evt) => {
|
93
106
|
this.isMouseenter = false;
|
94
|
-
this.refreshView()
|
107
|
+
this.refreshView()
|
95
108
|
});
|
96
|
-
this.addEvent('GotCursor', (evt) => { this.onGotCursorEvent(evt)
|
97
|
-
this.addEvent('ElementContextMenu', (evt) => {
|
109
|
+
this.addEvent<GotCursorEvent>('GotCursor', (evt) => { this.onGotCursorEvent(evt) });
|
110
|
+
this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
|
98
111
|
evt.menus.push({
|
99
112
|
icon: 'Settings', caption: '内容控制设置', eventObj: {}
|
100
113
|
});
|
101
114
|
}, true);
|
102
115
|
}
|
103
|
-
|
116
|
+
|
117
|
+
onGotCursorEvent(evt: GotCursorEvent): void {
|
104
118
|
const { source, selectionState } = evt;
|
105
119
|
if (evt.ctx.viewOptions.docMode === DocMode.FormEdit) {
|
106
120
|
//当前数据元不可编辑
|
@@ -115,27 +129,34 @@ export class DataElementInlineGroup extends InlineGroupInputElement {
|
|
115
129
|
range.editable = false;
|
116
130
|
selectionState.addRange(range);
|
117
131
|
}
|
118
|
-
return
|
132
|
+
return
|
119
133
|
}
|
120
134
|
}
|
135
|
+
|
121
136
|
if (source === this.endDecorate && selectionState.startOffset === 0 && this.length === 2) {
|
122
137
|
evt.isCancel = true;
|
123
138
|
selectionState.resetRange(this.startDecorate, 1);
|
124
139
|
}
|
125
140
|
}
|
141
|
+
|
142
|
+
abstract setValue(val: any): void;
|
143
|
+
abstract getValue(): string;
|
144
|
+
|
126
145
|
/**
|
127
146
|
* 验证数据元的值是否合法
|
128
|
-
* @returns
|
147
|
+
* @returns
|
129
148
|
*/
|
130
|
-
validate() {
|
149
|
+
validate(): string {
|
131
150
|
if (this.props.required && this.props.editable && !this.getValue()) {
|
132
151
|
return '该字段不能为空';
|
133
152
|
}
|
134
153
|
return '';
|
135
154
|
}
|
155
|
+
|
136
156
|
}
|
137
|
-
|
138
|
-
|
157
|
+
|
158
|
+
export abstract class DataElementRenderObject<T extends DataElementInlineGroup = DataElementInlineGroup> extends InlineGroupRenderObject<T> {
|
159
|
+
beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
139
160
|
ctx.contentContext.save();
|
140
161
|
//绘制数据元区域底色
|
141
162
|
if (this.element.isMouseenter) {
|
@@ -143,42 +164,48 @@ export class DataElementRenderObject extends InlineGroupRenderObject {
|
|
143
164
|
ctx.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, overlayColor);
|
144
165
|
}
|
145
166
|
if (this.element.props.secretBrowse && ctx.viewOptions.secretBrowse) {
|
146
|
-
ctx.contentContext.ctx.filter = "blur(10px)"
|
167
|
+
ctx.contentContext.ctx.filter = "blur(10px)"
|
147
168
|
}
|
148
169
|
if (this.element.props.underline) {
|
149
170
|
const y = position.y + 2 + this.rect.height;
|
150
|
-
ctx.contentContext.strokeLines([{ x: position.x, y }, { x: position.x + this.rect.width, y }], 1, '#595959')
|
171
|
+
ctx.contentContext.strokeLines([{ x: position.x, y }, { x: position.x + this.rect.width, y }], 1, '#595959')
|
151
172
|
}
|
152
173
|
}
|
153
|
-
|
174
|
+
|
175
|
+
endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
154
176
|
ctx.contentContext.restore();
|
155
177
|
if (!this.element.props.printable && ctx.drawMode === 'print') {
|
156
178
|
ctx.contentContext.clearRect(position.x, position.y, this.rect.width, this.rect.height);
|
157
179
|
}
|
158
180
|
}
|
159
181
|
}
|
160
|
-
|
182
|
+
|
183
|
+
|
184
|
+
export const validateDataEle = (ele: Element) => {
|
161
185
|
return ele instanceof DataElementLeaf || ele instanceof DataElementInlineGroup;
|
162
186
|
};
|
163
|
-
|
187
|
+
|
188
|
+
export const validateDataEleRenderObj = (renderObj: RenderObject) => {
|
164
189
|
if (renderObj.element) {
|
165
190
|
return validateDataEle(renderObj.element);
|
166
191
|
}
|
167
192
|
return false;
|
168
193
|
};
|
169
|
-
|
194
|
+
|
195
|
+
export const validateInlineInputRenderObj = (renderObj: RenderObject) => {
|
170
196
|
if (renderObj.element) {
|
171
197
|
return renderObj.element instanceof InlineGroupInputElement;
|
172
198
|
}
|
173
199
|
return false;
|
174
200
|
};
|
201
|
+
|
175
202
|
/**
|
176
203
|
* 是否在数据元内部
|
177
|
-
* @param control
|
178
|
-
* @param offset
|
204
|
+
* @param control
|
205
|
+
* @param offset
|
179
206
|
*/
|
180
|
-
export function IsInSideDataElement(control, offset) {
|
181
|
-
const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementInlineGroup);
|
207
|
+
export function IsInSideDataElement(control: LeafElement, offset: number): boolean {
|
208
|
+
const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementInlineGroup) as DataElementInlineGroup;
|
182
209
|
if (mathEle) {
|
183
210
|
if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
|
184
211
|
return false;
|
@@ -187,13 +214,15 @@ export function IsInSideDataElement(control, offset) {
|
|
187
214
|
}
|
188
215
|
return false;
|
189
216
|
}
|
217
|
+
|
218
|
+
|
190
219
|
/**
|
191
220
|
* 是否在内联块内部
|
192
|
-
* @param control
|
193
|
-
* @param offset
|
221
|
+
* @param control
|
222
|
+
* @param offset
|
194
223
|
*/
|
195
|
-
export function IsInSideInlineGroupInputElement(control, offset) {
|
196
|
-
const mathEle = ElementUtil.getParent(control, (item) => item instanceof InlineGroupInputElement);
|
224
|
+
export function IsInSideInlineGroupInputElement(control: LeafElement, offset: number): boolean {
|
225
|
+
const mathEle = ElementUtil.getParent(control, (item) => item instanceof InlineGroupInputElement) as InlineGroupInputElement;
|
197
226
|
if (mathEle) {
|
198
227
|
if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
|
199
228
|
return false;
|
@@ -202,4 +231,4 @@ export function IsInSideInlineGroupInputElement(control, offset) {
|
|
202
231
|
}
|
203
232
|
return false;
|
204
233
|
}
|
205
|
-
|
234
|
+
|
@@ -1,28 +1,33 @@
|
|
1
|
-
import { DocMode, ElementFactory } from "
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
1
|
+
import { DocMode, Element, ElementFactory, LeafElement, readElementProps, SerializeProps, ViewOptions } from "../../element-define";
|
2
|
+
import { ContextMenuElementEvent, ElementEvent } from "../../element-event-define";
|
3
|
+
import { DataEleCheckProps } from "../../element-props";
|
4
|
+
import { ElementUtil } from "../../element-util";
|
5
|
+
import { RenderContenxtType } from "../../render-context";
|
6
|
+
import { LeafRenderObject, RenderObject } from "../../render-define";
|
5
7
|
import { DataElementLeaf } from "./data-element-base-impl";
|
6
|
-
|
8
|
+
|
9
|
+
export class DataElementCheck extends DataElementLeaf<DataEleCheckProps> {
|
7
10
|
//props: DataEleCheckProps;
|
8
11
|
constructor() {
|
9
12
|
super('data-ele-check');
|
10
|
-
this.cursorType = 'default'
|
13
|
+
this.cursorType = 'default'
|
11
14
|
this.props = new DataEleCheckProps();
|
12
|
-
this.addEvent('ElementContextMenu', (evt) => {
|
15
|
+
this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
|
13
16
|
evt.menus.push({
|
14
17
|
icon: 'Settings', caption: '内容控制设置', eventObj: {}
|
15
18
|
});
|
16
19
|
});
|
17
|
-
this.addEvent('ElementClick', (evt) => { this.onClickHandler(evt)
|
20
|
+
this.addEvent('ElementClick', (evt) => { this.onClickHandler(evt) });
|
18
21
|
}
|
19
|
-
|
22
|
+
|
23
|
+
createRenderObject(): RenderObject {
|
20
24
|
const render = new DataElementCheckRenderObject(this);
|
21
25
|
render.rect.width = this.props.size + 4;
|
22
26
|
render.rect.height = this.props.size;
|
23
27
|
return render;
|
24
28
|
}
|
25
|
-
|
29
|
+
|
30
|
+
onClickHandler(evt: ElementEvent): void {
|
26
31
|
if (!this.props.editable && evt.ctx.viewOptions.docMode === DocMode.FormEdit) {
|
27
32
|
return;
|
28
33
|
}
|
@@ -35,53 +40,57 @@ export class DataElementCheck extends DataElementLeaf {
|
|
35
40
|
//复选框存在组时,并且为单选模式时
|
36
41
|
if (this.props.groupName && !this.props.multiSelect) {
|
37
42
|
const ckbs = docCtx.getCurrentCtx(this).getCheckBoxList(this.props.groupName);
|
38
|
-
ckbs.forEach(item => { if (item !== this) {
|
39
|
-
item.setValue(!this.props.checked);
|
40
|
-
} });
|
43
|
+
ckbs.forEach(item => { if (item !== this) { item.setValue(!this.props.checked) } });
|
41
44
|
}
|
42
45
|
}
|
43
|
-
|
46
|
+
|
47
|
+
serialize(viewOptions: ViewOptions): SerializeProps {
|
44
48
|
return {
|
45
49
|
type: this.type,
|
46
50
|
props: {
|
47
51
|
...this.props.getSerializeProps(viewOptions)
|
48
52
|
}
|
49
|
-
}
|
53
|
+
}
|
50
54
|
}
|
51
|
-
|
55
|
+
|
56
|
+
clone(data: boolean): DataElementCheck {
|
52
57
|
const clone = new DataElementCheck();
|
53
58
|
this.props.clone(clone.props);
|
54
59
|
return clone;
|
55
60
|
}
|
56
|
-
|
61
|
+
|
62
|
+
setValue(val: any): void {
|
57
63
|
if (typeof val === 'boolean') {
|
58
64
|
this.props.checked = val;
|
59
|
-
}
|
60
|
-
else {
|
65
|
+
} else {
|
61
66
|
const trueValue = val === 'true';
|
62
67
|
this.props.checked = trueValue;
|
63
68
|
}
|
64
69
|
}
|
65
|
-
|
70
|
+
|
71
|
+
getValue(): any {
|
66
72
|
if (this.props.checked) {
|
67
73
|
return this.props.checkedValue;
|
68
|
-
}
|
69
|
-
else {
|
74
|
+
} else {
|
70
75
|
return '';
|
71
76
|
}
|
72
77
|
}
|
73
78
|
}
|
79
|
+
|
80
|
+
|
74
81
|
export class DataElementCheckRenderObject extends LeafRenderObject {
|
75
|
-
constructor(element) {
|
82
|
+
constructor(element: Element) {
|
76
83
|
super(element);
|
77
84
|
}
|
78
|
-
|
85
|
+
|
86
|
+
clone(): RenderObject {
|
79
87
|
const cloneRender = new DataElementCheckRenderObject(this.element);
|
80
88
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
81
89
|
return cloneRender;
|
82
90
|
}
|
83
|
-
|
84
|
-
|
91
|
+
|
92
|
+
render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
93
|
+
const element = this.element as DataElementCheck;
|
85
94
|
if (this.element.props.multiSelect) {
|
86
95
|
ctx.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
|
87
96
|
}
|
@@ -92,10 +101,11 @@ export class DataElementCheckRenderObject extends LeafRenderObject {
|
|
92
101
|
//this.renderCkbDecoreate(ctx, position);
|
93
102
|
}
|
94
103
|
}
|
104
|
+
|
95
105
|
/**
|
96
106
|
* 绘制复选框装饰符号
|
97
107
|
*/
|
98
|
-
renderCkbDecoreate(ctx, position) {
|
108
|
+
renderCkbDecoreate(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
99
109
|
let { x, y } = position;
|
100
110
|
const { width, height } = this.rect;
|
101
111
|
const lineWidth = 5;
|
@@ -104,19 +114,22 @@ export class DataElementCheckRenderObject extends LeafRenderObject {
|
|
104
114
|
x += width;
|
105
115
|
ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x, y }, { x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);
|
106
116
|
}
|
117
|
+
|
107
118
|
}
|
108
|
-
|
109
|
-
|
110
|
-
|
119
|
+
|
120
|
+
export class DataElementCheckFactory extends ElementFactory<DataEleCheckProps> {
|
121
|
+
match(type: string): boolean {
|
122
|
+
return type === "data-ele-check"
|
111
123
|
}
|
112
|
-
createElement(data
|
113
|
-
const props = data.props;
|
124
|
+
createElement(data: readElementProps<DataEleCheckProps>, renderCtx: RenderContenxtType): Element {
|
125
|
+
const props = data.props as DataEleCheckProps;
|
114
126
|
const ele = new DataElementCheck();
|
115
127
|
this.createDataEleProps(ele.props, props);
|
116
128
|
return ele;
|
117
129
|
}
|
118
|
-
|
119
|
-
|
130
|
+
|
131
|
+
createDataEleProps(dest: DataEleCheckProps, props: DataEleCheckProps): DataEleCheckProps {
|
132
|
+
const dataEleProps: DataEleCheckProps = dest;
|
120
133
|
ElementUtil.readEleBaseProps(dataEleProps, props);
|
121
134
|
//dataEleProps.id = props.id ?? nanoid(5);
|
122
135
|
//dataEleProps.name = props.name;
|
@@ -129,5 +142,5 @@ export class DataElementCheckFactory extends ElementFactory {
|
|
129
142
|
dataEleProps.checkedValue = props.checkedValue;
|
130
143
|
return dataEleProps;
|
131
144
|
}
|
145
|
+
|
132
146
|
}
|
133
|
-
//# sourceMappingURL=data-element-check-impl.js.map
|