@hailin-zheng/editor-core 1.0.15 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1613 -0
- package/lib/framework/element-props.d.ts +2 -2
- package/lib/framework/impl/index.d.ts +36 -0
- package/lib/index.d.ts +34 -0
- package/lib/index.js +15672 -0
- package/lib/texteditor.d.ts +3 -3
- package/package.json +27 -26
- package/lib/doc-ruler.js +0 -313
- package/lib/doc-ruler.js.map +0 -1
- package/lib/framework/common-util.js +0 -178
- package/lib/framework/common-util.js.map +0 -1
- package/lib/framework/document-change.js +0 -1342
- package/lib/framework/document-change.js.map +0 -1
- package/lib/framework/document-combine.js +0 -40
- package/lib/framework/document-combine.js.map +0 -1
- package/lib/framework/document-comment.js +0 -148
- package/lib/framework/document-comment.js.map +0 -1
- package/lib/framework/document-context.js +0 -330
- package/lib/framework/document-context.js.map +0 -1
- package/lib/framework/document-eval-func.js +0 -48
- package/lib/framework/document-eval-func.js.map +0 -1
- package/lib/framework/document-event.js +0 -1054
- package/lib/framework/document-event.js.map +0 -1
- package/lib/framework/document-history.js +0 -65
- package/lib/framework/document-history.js.map +0 -1
- package/lib/framework/document-images-loader.js +0 -66
- package/lib/framework/document-images-loader.js.map +0 -1
- package/lib/framework/document-input-cursor.js +0 -239
- package/lib/framework/document-input-cursor.js.map +0 -1
- package/lib/framework/document-paint.js +0 -103
- package/lib/framework/document-paint.js.map +0 -1
- package/lib/framework/document-print-offscreen.js +0 -128
- package/lib/framework/document-print-offscreen.js.map +0 -1
- package/lib/framework/document-print.js +0 -203
- package/lib/framework/document-print.js.map +0 -1
- package/lib/framework/document-segmenter.js +0 -106
- package/lib/framework/document-segmenter.js.map +0 -1
- package/lib/framework/document-selection.js +0 -358
- package/lib/framework/document-selection.js.map +0 -1
- package/lib/framework/document-template.js +0 -20
- package/lib/framework/document-template.js.map +0 -1
- package/lib/framework/document-textline-mode.js +0 -30
- package/lib/framework/document-textline-mode.js.map +0 -1
- package/lib/framework/element-define.js +0 -579
- package/lib/framework/element-define.js.map +0 -1
- package/lib/framework/element-event-define.js +0 -108
- package/lib/framework/element-event-define.js.map +0 -1
- package/lib/framework/element-measure.js +0 -551
- package/lib/framework/element-measure.js.map +0 -1
- package/lib/framework/element-paint.js +0 -170
- package/lib/framework/element-paint.js.map +0 -1
- package/lib/framework/element-props.js +0 -809
- package/lib/framework/element-props.js.map +0 -1
- package/lib/framework/element-reader.js +0 -151
- package/lib/framework/element-reader.js.map +0 -1
- package/lib/framework/element-render-cut.js +0 -449
- package/lib/framework/element-render-cut.js.map +0 -1
- package/lib/framework/element-serialize.js +0 -113
- package/lib/framework/element-serialize.js.map +0 -1
- package/lib/framework/element-util.js +0 -1463
- package/lib/framework/element-util.js.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.js +0 -64
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.js +0 -105
- package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.js +0 -62
- package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.js +0 -62
- package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-util.js +0 -67
- package/lib/framework/impl/comments/comments-util.js.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.js +0 -83
- package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.js +0 -91
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.js +0 -115
- package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.js +0 -205
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.js +0 -133
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.js +0 -111
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.js +0 -130
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.js +0 -137
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.js +0 -131
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.js +0 -103
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.js +0 -43
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.js +0 -79
- package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.js +0 -94
- package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
- 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.js +0 -77
- package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.js +0 -83
- package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-impl.js +0 -209
- package/lib/framework/impl/document/doc-impl.js.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.js +0 -153
- package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.js +0 -156
- package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
- package/lib/framework/impl/picture/image-impl.js +0 -124
- package/lib/framework/impl/picture/image-impl.js.map +0 -1
- package/lib/framework/impl/radio/radio-impl.js +0 -72
- package/lib/framework/impl/radio/radio-impl.js.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.js +0 -54
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.js +0 -54
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.js +0 -145
- package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
- package/lib/framework/impl/table/table-impl.js +0 -363
- package/lib/framework/impl/table/table-impl.js.map +0 -1
- package/lib/framework/impl/table/table-row-impl.js +0 -75
- package/lib/framework/impl/table/table-row-impl.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.js +0 -89
- package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell.js +0 -464
- package/lib/framework/impl/table/table-split-cell.js.map +0 -1
- package/lib/framework/impl/table/table-util.js +0 -678
- package/lib/framework/impl/table/table-util.js.map +0 -1
- package/lib/framework/impl/text/text-impl.js +0 -149
- package/lib/framework/impl/text/text-impl.js.map +0 -1
- package/lib/framework/impl/text/track-run-impl.js +0 -112
- package/lib/framework/impl/text/track-run-impl.js.map +0 -1
- package/lib/framework/notify.js +0 -116
- package/lib/framework/notify.js.map +0 -1
- package/lib/framework/range-util.js +0 -312
- package/lib/framework/range-util.js.map +0 -1
- package/lib/framework/render-context.js +0 -384
- package/lib/framework/render-context.js.map +0 -1
- package/lib/framework/render-define.js +0 -195
- package/lib/framework/render-define.js.map +0 -1
- package/lib/framework/selection-overlays.js +0 -124
- package/lib/framework/selection-overlays.js.map +0 -1
- package/lib/texteditor.js +0 -913
- package/lib/texteditor.js.map +0 -1
- package/lib/util/subject.js +0 -88
- package/lib/util/subject.js.map +0 -1
- package/lib/util/table-bind.js +0 -6
- package/lib/util/table-bind.js.map +0 -1
@@ -1,83 +0,0 @@
|
|
1
|
-
import { BlockContainerElement, ElementFactory } from "../../element-define";
|
2
|
-
import { ElementUtil } from "../../element-util";
|
3
|
-
import { BlockContainerRenderObject } from "../../render-define";
|
4
|
-
export class DocumentHeaderElement extends BlockContainerElement {
|
5
|
-
constructor() {
|
6
|
-
super('header');
|
7
|
-
this.addEvent('ElementDblClick', (evt) => {
|
8
|
-
this.switchEditMode(evt);
|
9
|
-
}, true);
|
10
|
-
//this.editMode = EditMode.Disabled;
|
11
|
-
this.disableClick = true;
|
12
|
-
}
|
13
|
-
clone(data) {
|
14
|
-
const clone = new DocumentHeaderElement();
|
15
|
-
if (data) {
|
16
|
-
for (let i = 0; i < this.length; i++) {
|
17
|
-
clone.addChild(this.getChild(i).clone(true));
|
18
|
-
}
|
19
|
-
}
|
20
|
-
return clone;
|
21
|
-
}
|
22
|
-
switchEditMode(evt) {
|
23
|
-
const docElement = this.parent;
|
24
|
-
docElement.switchPageHeaderEditor(evt.selectionState, this);
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
createRenderObject() {
|
28
|
-
const renderObject = new DocumentHeaderRenderObject(this);
|
29
|
-
return renderObject;
|
30
|
-
}
|
31
|
-
serialize() {
|
32
|
-
return {
|
33
|
-
type: 'header',
|
34
|
-
props: {}
|
35
|
-
};
|
36
|
-
}
|
37
|
-
}
|
38
|
-
export class DocumentHeaderRenderObject extends BlockContainerRenderObject {
|
39
|
-
beginRender(ctx, position) {
|
40
|
-
//判断页眉是否为输入内容
|
41
|
-
const isHeaderEmpty = ElementUtil.checkEmptyContent(this);
|
42
|
-
//存在输入内容时,绘制页眉-页体分割线
|
43
|
-
if (!isHeaderEmpty || !this.element.disableClick) {
|
44
|
-
const headerLineY = this.rect.height;
|
45
|
-
ctx.contentContext.drawLine(position.x, position.y + headerLineY, this.rect.width, 'black', 0.5);
|
46
|
-
}
|
47
|
-
if (this.element.disableClick && ctx.drawMode === 'view') {
|
48
|
-
if (isHeaderEmpty) {
|
49
|
-
ctx.contentContext.setGlobalAlpha(0);
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
ctx.contentContext.setGlobalAlpha(0.7);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
endRender(ctx, position) {
|
56
|
-
//console.log('绘制页头-end');
|
57
|
-
if (this.element.disableClick && ctx.drawMode === 'view') {
|
58
|
-
ctx.contentContext.setGlobalAlpha(1);
|
59
|
-
}
|
60
|
-
if (ctx.viewOptions.showDebug) {
|
61
|
-
ctx.overlaysContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, 'rgb(122,122,122,0.4)');
|
62
|
-
}
|
63
|
-
}
|
64
|
-
clone() {
|
65
|
-
const cloneRender = new DocumentHeaderRenderObject(this.element);
|
66
|
-
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
67
|
-
for (let i = 0; i < this.length; i++) {
|
68
|
-
cloneRender.addChild(this.getChild(i).clone());
|
69
|
-
}
|
70
|
-
return cloneRender;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
export class DocumentHeaderFactory extends ElementFactory {
|
74
|
-
match(type) {
|
75
|
-
return type === 'header';
|
76
|
-
}
|
77
|
-
createElement(data, renderCtx) {
|
78
|
-
const element = new DocumentHeaderElement();
|
79
|
-
//element.renderCtx = renderCtx;
|
80
|
-
return element;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
//# sourceMappingURL=doc-header-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"doc-header-impl.js","sourceRoot":"lib/","sources":["framework/impl/document/doc-header-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAW,cAAc,EAAkB,MAAM,sBAAsB,CAAC;AAEtG,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,0BAA0B,EAAgB,MAAM,qBAAqB,CAAC;AAG/E,MAAM,OAAO,qBAAsB,SAAQ,qBAAqB;IAC5D;QACI,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE;YACrC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC,EA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AAsB,SAAQ,cAAoB;IAC3D,KAAK,CAAC,IAAY;QACd,OAAO,IAAI,KAAK,QAAQ,CAAC;IAC7B,CAAC;IAED,aAAa,CAAC,IAAS,EAAE,SAA6B;QAClD,MAAM,OAAO,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC5C,gCAAgC;QAChC,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ","sourcesContent":["import { BlockContainerElement, Element, ElementFactory, SerializeProps } from \"../../element-define\";\nimport { MouseElementEvent } from \"../../element-event-define\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { BlockContainerRenderObject, RenderObject } from \"../../render-define\";\nimport { DocumentElement } from \"./doc-impl\";\n\nexport class DocumentHeaderElement extends BlockContainerElement {\n constructor() {\n super('header');\n this.addEvent('ElementDblClick', (evt) => {\n this.switchEditMode(evt);\n }, true);\n //this.editMode = EditMode.Disabled;\n this.disableClick = true;\n }\n\n clone(data: boolean): Element {\n const clone = new DocumentHeaderElement();\n if (data) {\n for (let i = 0; i < this.length; i++) {\n clone.addChild(this.getChild(i).clone(true));\n }\n }\n return clone;\n }\n\n switchEditMode(evt: MouseElementEvent): void {\n const docElement = this.parent as DocumentElement;\n docElement.switchPageHeaderEditor(evt.selectionState, this);\n return;\n }\n\n\n createRenderObject(): DocumentHeaderRenderObject {\n const renderObject = new DocumentHeaderRenderObject(this);\n return renderObject;\n }\n\n serialize(): SerializeProps {\n return {\n type: 'header',\n props: {}\n }\n }\n\n}\n\n\nexport class DocumentHeaderRenderObject extends BlockContainerRenderObject {\n beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n //判断页眉是否为输入内容\n const isHeaderEmpty = ElementUtil.checkEmptyContent(this);\n //存在输入内容时,绘制页眉-页体分割线\n if (!isHeaderEmpty || !this.element.disableClick) {\n const headerLineY = this.rect.height;\n ctx.contentContext.drawLine(position.x, position.y + headerLineY, this.rect.width, 'black', 0.5);\n }\n if (this.element.disableClick && ctx.drawMode === 'view') {\n if (isHeaderEmpty) {\n ctx.contentContext.setGlobalAlpha(0);\n return;\n }\n ctx.contentContext.setGlobalAlpha(0.7);\n }\n }\n\n\n endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n //console.log('绘制页头-end');\n if (this.element.disableClick && ctx.drawMode === 'view') {\n ctx.contentContext.setGlobalAlpha(1);\n }\n if (ctx.viewOptions.showDebug) {\n ctx.overlaysContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, 'rgb(122,122,122,0.4)')\n }\n }\n\n clone(): RenderObject {\n const cloneRender = new DocumentHeaderRenderObject(this.element);\n cloneRender.rect = ElementUtil.cloneRect(this.rect);\n for (let i = 0; i < this.length; i++) {\n cloneRender.addChild(this.getChild(i).clone());\n }\n return cloneRender;\n }\n}\n\n\nexport class DocumentHeaderFactory extends ElementFactory<null> {\n match(type: string): boolean {\n return type === 'header';\n }\n\n createElement(data: any, renderCtx: RenderContenxtType): Element {\n const element = new DocumentHeaderElement();\n //element.renderCtx = renderCtx;\n return element;\n }\n}\n"]}
|
@@ -1,209 +0,0 @@
|
|
1
|
-
import { BlockContainerElement, DocMode, ElementFactory, PaddingProps } from "../../element-define";
|
2
|
-
import { DocumentProps, TextProps } from '../../element-props';
|
3
|
-
import { BlockContainerRenderObject } from "../../render-define";
|
4
|
-
import { ElementUtil } from "../../element-util";
|
5
|
-
import { documentPrint } from "../../document-print";
|
6
|
-
import { CommonUtil } from "../../common-util";
|
7
|
-
export class DocumentElement extends BlockContainerElement {
|
8
|
-
//props: DocumentProps;
|
9
|
-
viewOptions;
|
10
|
-
bodyElement;
|
11
|
-
headerElement;
|
12
|
-
footerElement;
|
13
|
-
commentsContainerElement;
|
14
|
-
headerEditState = false;
|
15
|
-
constructor() {
|
16
|
-
super('doc');
|
17
|
-
this.props = new DocumentProps();
|
18
|
-
this.addEvent('ElementContextMenu', (cevt) => {
|
19
|
-
cevt.menus.push({ icon: 'Print', caption: '打印所有页', eventObj: { onClick: (evt) => { documentPrint.print(cevt.selectionState, this.viewOptions, cevt.ctx); } } });
|
20
|
-
cevt.menus.push({ icon: 'Print', caption: '打印当前页', eventObj: { onClick: (evt) => { documentPrint.printCurrPage(cevt.selectionState, this.viewOptions, cevt.ctx); } } });
|
21
|
-
}, true);
|
22
|
-
}
|
23
|
-
createRenderObject(options) {
|
24
|
-
const { width: docPixelsWidth, height: docPixelsHeight } = this.viewOptions.docPageSettings;
|
25
|
-
const docRenderObject = new DocumentRenderObject(this);
|
26
|
-
docRenderObject.rect.width = docPixelsWidth;
|
27
|
-
docRenderObject.rect.maxWidth = docPixelsWidth;
|
28
|
-
docRenderObject.rect.maxHeight = docPixelsHeight;
|
29
|
-
docRenderObject.rect.height = docPixelsHeight;
|
30
|
-
docRenderObject.element = this;
|
31
|
-
const { top, bottom, left, right } = this.props.padding;
|
32
|
-
let { headerLine: headLine, footerLine: footLine } = this.props;
|
33
|
-
const { mmToPixelsRatio } = this.viewOptions;
|
34
|
-
headLine = headLine * mmToPixelsRatio;
|
35
|
-
footLine = footLine * mmToPixelsRatio;
|
36
|
-
docRenderObject.padding.top = Math.floor(top * mmToPixelsRatio);
|
37
|
-
docRenderObject.padding.bottom = Math.floor(bottom * mmToPixelsRatio);
|
38
|
-
docRenderObject.padding.left = Math.floor(left * mmToPixelsRatio);
|
39
|
-
docRenderObject.padding.right = Math.floor(right * mmToPixelsRatio);
|
40
|
-
docRenderObject.headerLine = headLine;
|
41
|
-
docRenderObject.footerLine = footLine;
|
42
|
-
docRenderObject.margin.top = options.docSpace;
|
43
|
-
return docRenderObject;
|
44
|
-
}
|
45
|
-
serialize() {
|
46
|
-
return {
|
47
|
-
type: 'doc',
|
48
|
-
props: {
|
49
|
-
...this.props.getSerializeProps()
|
50
|
-
}
|
51
|
-
};
|
52
|
-
}
|
53
|
-
clone() {
|
54
|
-
const clone = new DocumentElement();
|
55
|
-
this.props.clone(clone.props);
|
56
|
-
for (let i = 0; i < this.length; i++) {
|
57
|
-
clone.addChild(this.getChild(i).clone(true));
|
58
|
-
}
|
59
|
-
return clone;
|
60
|
-
}
|
61
|
-
/**
|
62
|
-
* 更新页边距
|
63
|
-
* @param marginProps
|
64
|
-
*/
|
65
|
-
updateMargin(marginProps, unit = 'cm') {
|
66
|
-
const { top, bottom, left, right } = marginProps;
|
67
|
-
const paddig = this.props.padding;
|
68
|
-
const ratio = unit === 'cm' ? 10 : 1;
|
69
|
-
paddig.top = top * ratio;
|
70
|
-
paddig.bottom = bottom * ratio;
|
71
|
-
paddig.left = left * ratio;
|
72
|
-
paddig.right = right * ratio;
|
73
|
-
}
|
74
|
-
/**
|
75
|
-
* 切换开启页眉页脚编辑功能
|
76
|
-
*/
|
77
|
-
switchPageHeaderEditor(ss, ele) {
|
78
|
-
if (this.viewOptions.docMode !== DocMode.Design) {
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
if (!this.headerEditState && (!ele || (ele === this.headerElement || ele === this.footerElement))) {
|
82
|
-
this.headerElement.disableClick = false;
|
83
|
-
this.footerElement.disableClick = false;
|
84
|
-
this.bodyElement.disableClick = true;
|
85
|
-
this.headerEditState = true;
|
86
|
-
}
|
87
|
-
else if (this.headerEditState && (!ele || ele === this.bodyElement)) {
|
88
|
-
this.headerElement.disableClick = true;
|
89
|
-
this.footerElement.disableClick = true;
|
90
|
-
this.bodyElement.disableClick = false;
|
91
|
-
this.headerEditState = false;
|
92
|
-
}
|
93
|
-
ss.clear();
|
94
|
-
this.refreshView();
|
95
|
-
}
|
96
|
-
}
|
97
|
-
export class DocumentRenderObject extends BlockContainerRenderObject {
|
98
|
-
constructor(ele) {
|
99
|
-
super(ele);
|
100
|
-
}
|
101
|
-
headerLine;
|
102
|
-
footerLine;
|
103
|
-
beginRender(ctx, position) {
|
104
|
-
const { width: docWidth, height: docHeight } = ctx.viewOptions.docPageSettings;
|
105
|
-
ctx.overlaysContext.fillRect(position.x, position.y, docWidth, this.rect.height, 'white', 5, 'black');
|
106
|
-
// if (ctx.drawMode === 'view') {
|
107
|
-
// ctx.contentContext.strokeRect(position.x, position.y, docWidth, this.rect.height, 'black', 0.5);
|
108
|
-
// }
|
109
|
-
}
|
110
|
-
endRender(ctx, position) {
|
111
|
-
const textP = new TextProps();
|
112
|
-
textP.color = "rgb(0,0,0)";
|
113
|
-
textP.fontName = '楷体';
|
114
|
-
textP.fontSize = 12;
|
115
|
-
if (ctx.viewOptions.copyRightInfo) {
|
116
|
-
ctx.contentContext.drawText(ctx.viewOptions.copyRightInfo, textP, position.x + 5, position.y + 5, 100, 12);
|
117
|
-
}
|
118
|
-
this.drawDocPageNum(ctx, position);
|
119
|
-
const padding = this.padding;
|
120
|
-
let paddingPos = { x: padding.left + position.x, y: padding.top + position.y };
|
121
|
-
const drawLineWidth = 0.5;
|
122
|
-
const lineWidth = 20;
|
123
|
-
const { width: docWidth } = ctx.viewOptions.docPageSettings;
|
124
|
-
const docHeight = this.rect.height;
|
125
|
-
ctx.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y - lineWidth }], drawLineWidth);
|
126
|
-
paddingPos = { x: docWidth - padding.right + position.x, y: padding.top + position.y };
|
127
|
-
ctx.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y - lineWidth }], drawLineWidth);
|
128
|
-
paddingPos = { x: padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
|
129
|
-
ctx.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y + lineWidth }], drawLineWidth);
|
130
|
-
paddingPos = { x: docWidth - padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
|
131
|
-
ctx.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y + lineWidth }], drawLineWidth);
|
132
|
-
this.drawWatermark(ctx, position);
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* 绘制水印
|
136
|
-
* @param ctx
|
137
|
-
* @param position
|
138
|
-
*/
|
139
|
-
drawWatermark(ctx, position) {
|
140
|
-
if (ctx.viewOptions.watermark) {
|
141
|
-
const watermark = ctx.viewOptions.watermark;
|
142
|
-
ctx.contentContext.ctx.save();
|
143
|
-
ctx.contentContext.ctx.translate(position.x, position.y);
|
144
|
-
const { width, height } = this.rect;
|
145
|
-
const degrees = Math.atan(height / width) * 180 / Math.PI;
|
146
|
-
ctx.contentContext.ctx.rotate(degrees * Math.PI / 180);
|
147
|
-
ctx.contentContext.ctx.globalAlpha = 0.3;
|
148
|
-
const d = Math.sqrt(width * width + height * height);
|
149
|
-
const textProps = new TextProps();
|
150
|
-
textProps.color = "rgb(0,0,0)";
|
151
|
-
textProps.fontName = '楷体';
|
152
|
-
textProps.fontSize = 60;
|
153
|
-
const textWidth = ctx.contentContext.measureText(watermark, textProps).width;
|
154
|
-
const x = d / 2 - textWidth / 2;
|
155
|
-
ctx.contentContext.ctx.font = textProps.getFont();
|
156
|
-
ctx.contentContext.ctx.fillText(watermark, x, 30);
|
157
|
-
ctx.contentContext.ctx.restore();
|
158
|
-
}
|
159
|
-
}
|
160
|
-
/**
|
161
|
-
* 绘制文档页码
|
162
|
-
*/
|
163
|
-
drawDocPageNum(ctx, position) {
|
164
|
-
const pageWidth = ctx.viewOptions.docPageSettings.width;
|
165
|
-
const pageIndex = this.getIndex() + 1;
|
166
|
-
const str = CommonUtil.parseText(ctx.viewOptions.pageNumFormat, { index: pageIndex, count: this.parent.length });
|
167
|
-
const textProps = new TextProps();
|
168
|
-
textProps.color = "rgb(0,0,0)";
|
169
|
-
textProps.fontName = '仿宋';
|
170
|
-
textProps.fontSize = 14;
|
171
|
-
textProps.fontStyle = 'italic';
|
172
|
-
const size = ctx.contentContext.measureText(str, textProps);
|
173
|
-
const alignCenterX = position.x + Math.ceil(pageWidth / 2) - Math.ceil(size.width / 2);
|
174
|
-
const paintY = position.y + this.rect.height - size.height - 5;
|
175
|
-
ctx.contentContext.drawText(str, textProps, alignCenterX, paintY, size.width, size.height);
|
176
|
-
}
|
177
|
-
clone() {
|
178
|
-
const cloneRender = new DocumentRenderObject(this.element);
|
179
|
-
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
180
|
-
cloneRender.headerLine = this.headerLine;
|
181
|
-
cloneRender.footerLine = this.footerLine;
|
182
|
-
for (let i = 0; i < this.length; i++) {
|
183
|
-
cloneRender.addChild(this.getChild(i).clone());
|
184
|
-
}
|
185
|
-
return cloneRender;
|
186
|
-
}
|
187
|
-
}
|
188
|
-
export class DocumentFactory extends ElementFactory {
|
189
|
-
match(type) {
|
190
|
-
return type === 'doc';
|
191
|
-
}
|
192
|
-
createElement(data, renderCtx) {
|
193
|
-
const documentElement = new DocumentElement();
|
194
|
-
const props = data.props;
|
195
|
-
const docProps = documentElement.props;
|
196
|
-
docProps.width = props.width;
|
197
|
-
docProps.height = props.height;
|
198
|
-
docProps.padding = new PaddingProps(props.padding.top, props.padding.bottom, props.padding.left, props.padding.right);
|
199
|
-
docProps.headerLine = props.headerLine ?? 12;
|
200
|
-
docProps.footerLine = props.footerLine ?? 12;
|
201
|
-
docProps.scripts = props.scripts;
|
202
|
-
docProps.createUserId = props.createUserId;
|
203
|
-
docProps.createUserName = props.createUserName;
|
204
|
-
docProps.createDate = props.createDate;
|
205
|
-
docProps.orient = props.orient ?? 'portrait';
|
206
|
-
return documentElement;
|
207
|
-
}
|
208
|
-
}
|
209
|
-
//# sourceMappingURL=doc-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"doc-impl.js","sourceRoot":"lib/","sources":["framework/impl/document/doc-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAW,cAAc,EAAe,YAAY,EAAuD,MAAM,sBAAsB,CAAC;AAC/K,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAI/D,O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AG,eAAe,CAAC,KAAK,CAAC;QACvC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7B,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC/B,QAAQ,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtH,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAC7C,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAC7C,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QACjC,QAAQ,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAC3C,QAAQ,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QAC/C,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACvC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,CAAC;QAC7C,OAAO,eAAe,CAAC;IAC3B,CAAC;CAEJ","sourcesContent":["import { BlockContainerElement, DocMode, Element, ElementFactory, MarginProps, PaddingProps, readElementProps, Rect, SerializeProps, ViewOptions } from \"../../element-define\";\nimport { DocumentProps, TextProps } from '../../element-props';\nimport { RenderContenxtType } from \"../../render-context\";\nimport { DocumentBodyElement } from \"./doc-body-impl\";\nimport { DocumentHeaderElement } from \"./doc-header-impl\";\nimport { BlockContainerRenderObject, RenderObject } from \"../../render-define\";\nimport { ElementUtil } from \"../../element-util\";\nimport { DocumentFooterElement } from \"./doc-footer-impl\";\nimport { ContextMenuElementEvent } from \"../../element-event-define\";\nimport { documentPrint } from \"../../document-print\";\nimport { CommsContainerElement } from \"../comments/comments-container-impl\";\nimport { CommonUtil } from \"../../common-util\";\nimport { SelectionState } from \"../../document-selection\";\n\nexport class DocumentElement extends BlockContainerElement<DocumentProps> {\n //props: DocumentProps;\n viewOptions!: ViewOptions;\n bodyElement!: DocumentBodyElement;\n headerElement!: DocumentHeaderElement;\n footerElement!: DocumentFooterElement;\n commentsContainerElement!: CommsContainerElement;\n headerEditState: boolean = false;\n constructor() {\n super('doc');\n this.props = new DocumentProps();\n this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (cevt) => {\n cevt.menus.push({ icon: 'Print', caption: '打印所有页', eventObj: { onClick: (evt) => { documentPrint.print(cevt.selectionState, this.viewOptions, cevt.ctx) } } });\n cevt.menus.push({ icon: 'Print', caption: '打印当前页', eventObj: { onClick: (evt) => { documentPrint.printCurrPage(cevt.selectionState, this.viewOptions, cevt.ctx) } } });\n }, true);\n }\n createRenderObject(options: ViewOptions): DocumentRenderObject {\n const { width: docPixelsWidth, height: docPixelsHeight } = this.viewOptions.docPageSettings;\n const docRenderObject = new DocumentRenderObject(this);\n docRenderObject.rect.width = docPixelsWidth;\n docRenderObject.rect.maxWidth = docPixelsWidth;\n docRenderObject.rect.maxHeight = docPixelsHeight;\n docRenderObject.rect.height = docPixelsHeight;\n docRenderObject.element = this;\n const { top, bottom, left, right } = this.props.padding;\n let { headerLine: headLine, footerLine: footLine } = this.props;\n const { mmToPixelsRatio } = this.viewOptions;\n headLine = headLine * mmToPixelsRatio;\n footLine = footLine * mmToPixelsRatio;\n docRenderObject.padding.top = Math.floor(top * mmToPixelsRatio);\n docRenderObject.padding.bottom = Math.floor(bottom * mmToPixelsRatio);\n docRenderObject.padding.left = Math.floor(left * mmToPixelsRatio);\n docRenderObject.padding.right = Math.floor(right * mmToPixelsRatio);\n docRenderObject.headerLine = headLine;\n docRenderObject.footerLine = footLine;\n docRenderObject.margin.top = options.docSpace;\n return docRenderObject;\n }\n\n serialize(): SerializeProps {\n return {\n type: 'doc',\n props: {\n ...this.props.getSerializeProps()\n }\n }\n }\n\n clone(): DocumentElement {\n const clone = new DocumentElement();\n this.props.clone(clone.props)\n for (let i = 0; i < this.length; i++) {\n clone.addChild(this.getChild(i).clone(true));\n }\n return clone;\n }\n\n /**\n * 更新页边距\n * @param marginProps \n */\n updateMargin(marginProps: Partial<MarginProps>, unit: 'mm' | 'cm' = 'cm'): void {\n const { top, bottom, left, right } = marginProps as MarginProps;\n const paddig = this.props.padding;\n const ratio = unit === 'cm' ? 10 : 1;\n paddig.top = top * ratio;\n paddig.bottom = bottom * ratio;\n paddig.left = left * ratio;\n paddig.right = right * ratio;\n }\n\n /**\n * 切换开启页眉页脚编辑功能\n */\n switchPageHeaderEditor(ss: SelectionState, ele: Element | null): void {\n if (this.viewOptions.docMode !== DocMode.Design) {\n return;\n }\n if (!this.headerEditState && (!ele || (ele === this.headerElement || ele === this.footerElement))) {\n this.headerElement.disableClick = false;\n this.footerElement.disableClick = false;\n this.bodyElement.disableClick = true;\n this.headerEditState = true;\n } else if (this.headerEditState && (!ele || ele === this.bodyElement)) {\n this.headerElement.disableClick = true;\n this.footerElement.disableClick = true;\n this.bodyElement.disableClick = false;\n this.headerEditState = false;\n }\n ss.clear();\n this.refreshView();\n }\n}\n\n\nexport class DocumentRenderObject extends BlockContainerRenderObject {\n constructor(ele: Element) {\n super(ele);\n }\n headerLine!: number;\n footerLine!: number;\n beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const { width: docWidth, height: docHeight } = ctx.viewOptions.docPageSettings;\n ctx.overlaysContext.fillRect(position.x, position.y, docWidth, this.rect.height, 'white', 5, 'black');\n // if (ctx.drawMode === 'view') {\n // ctx.contentContext.strokeRect(position.x, position.y, docWidth, this.rect.height, 'black', 0.5);\n // }\n }\n endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const textP = new TextProps();\n textP.color = \"rgb(0,0,0)\";\n textP.fontName = '楷体';\n textP.fontSize = 12;\n if (ctx.viewOptions.copyRightInfo) {\n ctx.contentContext.drawText(ctx.viewOptions.copyRightInfo, textP, position.x + 5, position.y + 5, 100, 12);\n }\n this.drawDocPageNum(ctx, position);\n const padding = this.padding;\n let paddingPos = { x: padding.left + position.x, y: padding.top + position.y };\n const drawLineWidth = 0.5;\n const lineWidth = 20;\n const { width: docWidth } = ctx.viewOptions.docPageSettings;\n const docHeight = this.rect.height;\n ctx.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y - lineWidth }], drawLineWidth);\n paddingPos = { x: docWidth - padding.right + position.x, y: padding.top + position.y };\n ctx.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y - lineWidth }], drawLineWidth);\n paddingPos = { x: padding.left + position.x, y: docHeight - this.padding.bottom + position.y };\n ctx.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y + lineWidth }], drawLineWidth);\n paddingPos = { x: docWidth - padding.left + position.x, y: docHeight - this.padding.bottom + position.y };\n ctx.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, { x: paddingPos.x, y: paddingPos.y + lineWidth }], drawLineWidth);\n this.drawWatermark(ctx, position);\n }\n\n /**\n * 绘制水印\n * @param ctx \n * @param position \n */\n private drawWatermark(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n if (ctx.viewOptions.watermark) {\n const watermark = ctx.viewOptions.watermark;\n ctx.contentContext.ctx.save();\n ctx.contentContext.ctx.translate(position.x, position.y);\n const { width, height } = this.rect;\n const degrees = Math.atan(height / width) * 180 / Math.PI\n ctx.contentContext.ctx.rotate(degrees * Math.PI / 180);\n ctx.contentContext.ctx.globalAlpha = 0.3;\n const d = Math.sqrt(width * width + height * height);\n const textProps = new TextProps();\n textProps.color = \"rgb(0,0,0)\";\n textProps.fontName = '楷体';\n textProps.fontSize = 60;\n const textWidth = ctx.contentContext.measureText(watermark, textProps).width\n const x = d / 2 - textWidth / 2;\n ctx.contentContext.ctx.font = textProps.getFont()\n ctx.contentContext.ctx.fillText(watermark, x, 30);\n ctx.contentContext.ctx.restore();\n }\n }\n\n /**\n * 绘制文档页码\n */\n drawDocPageNum(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const pageWidth = ctx.viewOptions.docPageSettings.width;\n const pageIndex = this.getIndex() + 1;\n const str = CommonUtil.parseText(ctx.viewOptions.pageNumFormat, { index: pageIndex, count: this.parent.length });\n const textProps = new TextProps();\n textProps.color = \"rgb(0,0,0)\";\n textProps.fontName = '仿宋';\n textProps.fontSize = 14;\n textProps.fontStyle = 'italic';\n const size = ctx.contentContext.measureText(str, textProps);\n const alignCenterX = position.x + Math.ceil(pageWidth / 2) - Math.ceil(size.width / 2)\n const paintY = position.y + this.rect.height - size.height - 5;\n ctx.contentContext.drawText(str, textProps, alignCenterX, paintY, size.width, size.height);\n }\n\n clone(): RenderObject {\n const cloneRender = new DocumentRenderObject(this.element);\n cloneRender.rect = ElementUtil.cloneRect(this.rect);\n cloneRender.headerLine = this.headerLine;\n cloneRender.footerLine = this.footerLine;\n for (let i = 0; i < this.length; i++) {\n cloneRender.addChild(this.getChild(i).clone());\n }\n return cloneRender;\n }\n}\n\nexport class DocumentFactory extends ElementFactory<DocumentProps> {\n match(type: string): boolean {\n return type === 'doc';\n }\n createElement(data: readElementProps<DocumentProps>, renderCtx: RenderContenxtType): Element {\n const documentElement = new DocumentElement();\n const props = data.props as DocumentProps;\n const docProps = documentElement.props;\n docProps.width = props.width;\n docProps.height = props.height;\n docProps.padding = new PaddingProps(props.padding.top, props.padding.bottom, props.padding.left, props.padding.right);\n docProps.headerLine = props.headerLine ?? 12;\n docProps.footerLine = props.footerLine ?? 12;\n docProps.scripts = props.scripts;\n docProps.createUserId = props.createUserId;\n docProps.createUserName = props.createUserName;\n docProps.createDate = props.createDate;\n docProps.orient = props.orient ?? 'portrait';\n return documentElement;\n }\n\n}\n"]}
|
@@ -1,153 +0,0 @@
|
|
1
|
-
import { CommonUtil } from "../../common-util";
|
2
|
-
import { ElementFactory } from "../../element-define";
|
3
|
-
import { DataEleMHProps, TextProps } from "../../element-props";
|
4
|
-
import { ElementUtil } from "../../element-util";
|
5
|
-
import { LeafRenderObject } from "../../render-define";
|
6
|
-
import { DataElementLeaf } from "../data-element/data-element-base-impl";
|
7
|
-
/**
|
8
|
-
* 月经史
|
9
|
-
*/
|
10
|
-
export class DataElementMH extends DataElementLeaf {
|
11
|
-
//props!: DataEleMHProps;
|
12
|
-
constructor() {
|
13
|
-
super('data-ele-mh');
|
14
|
-
this.props = new DataEleMHProps();
|
15
|
-
//this.addPropValueChangedSub(this.props);
|
16
|
-
}
|
17
|
-
setValue(val) {
|
18
|
-
if (typeof val === 'string' && val) {
|
19
|
-
const items = val.split(';');
|
20
|
-
if (items.length >= 4) {
|
21
|
-
const mhLayoutItem = getMHItem(this.props.kind);
|
22
|
-
this.props[mhLayoutItem.left.prop] = items[0];
|
23
|
-
this.props[mhLayoutItem.top.prop] = items[1];
|
24
|
-
this.props[mhLayoutItem.bottom.prop] = items[2];
|
25
|
-
this.props[mhLayoutItem.right.prop] = items[3];
|
26
|
-
}
|
27
|
-
}
|
28
|
-
else if (typeof val === 'object') {
|
29
|
-
this.props.age = val?.age ?? '';
|
30
|
-
this.props.days = val?.days ?? '';
|
31
|
-
this.props.cycles = val?.cycles ?? '';
|
32
|
-
this.props.lastDate = val?.lastDate ?? '';
|
33
|
-
this.props.closeAge = val?.closeAge ?? '';
|
34
|
-
}
|
35
|
-
}
|
36
|
-
getValue() {
|
37
|
-
const layoutItem = getMHItem(this.props.kind);
|
38
|
-
return `${this.props[layoutItem.left.prop]};${this.props[layoutItem.top.prop]};${this.props[layoutItem.bottom.prop]};${this.props[layoutItem.right.prop]}`;
|
39
|
-
}
|
40
|
-
createRenderObject(options, renderCtx) {
|
41
|
-
const render = new DataRenderMH(this);
|
42
|
-
const measure = renderMH(this, renderCtx, { x: 0, y: 0 }, false);
|
43
|
-
if (measure) {
|
44
|
-
render.rect.width = measure.width;
|
45
|
-
render.rect.height = measure.height;
|
46
|
-
}
|
47
|
-
return render;
|
48
|
-
}
|
49
|
-
serialize(viewOptions) {
|
50
|
-
return {
|
51
|
-
type: this.type,
|
52
|
-
props: this.props.getSerializeProps(viewOptions)
|
53
|
-
};
|
54
|
-
}
|
55
|
-
clone(data) {
|
56
|
-
const element = new DataElementMH();
|
57
|
-
this.props.clone(element.props);
|
58
|
-
return element;
|
59
|
-
}
|
60
|
-
getCurrentLayoutItem() {
|
61
|
-
return getMHItem(this.props.kind);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
const mhLayoutItems = [
|
65
|
-
{ left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '行经期天数', prop: 'days' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } },
|
66
|
-
{ left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '闭经年龄', prop: 'closeAge' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '行经期天数', prop: 'days' } },
|
67
|
-
{ left: { tip: '闭经年龄', prop: 'closeAge' }, top: { tip: '行经期天数', prop: 'days' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } },
|
68
|
-
{ left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '月经周期天数', prop: 'cycles' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '行经期天数', prop: 'days' } },
|
69
|
-
{ left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '闭经年龄', prop: 'closeAge' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } }
|
70
|
-
];
|
71
|
-
function getMHItem(kind) {
|
72
|
-
kind = kind ?? 'A';
|
73
|
-
kind = kind.toUpperCase();
|
74
|
-
let kindIndex = ['A', 'B', 'C', 'D', 'E'].indexOf(kind);
|
75
|
-
kindIndex = kindIndex < 0 ? 0 : kindIndex;
|
76
|
-
return mhLayoutItems[kindIndex];
|
77
|
-
}
|
78
|
-
export class DataRenderMH extends LeafRenderObject {
|
79
|
-
render(ctx, position) {
|
80
|
-
renderMH(this.element, ctx, position, true);
|
81
|
-
}
|
82
|
-
clone() {
|
83
|
-
const clone = new DataRenderMH(this.element);
|
84
|
-
clone.rect = ElementUtil.cloneRect(this.rect);
|
85
|
-
return clone;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
export class DataElementMHFactory extends ElementFactory {
|
89
|
-
match(type) {
|
90
|
-
return type === 'data-ele-mh';
|
91
|
-
}
|
92
|
-
createElement(data, renderCtx) {
|
93
|
-
const ele = new DataElementMH();
|
94
|
-
ElementUtil.readEleBaseProps(ele.props, data.props);
|
95
|
-
ele.props.age = data.props?.age ?? '';
|
96
|
-
ele.props.cycles = data.props?.cycles ?? '';
|
97
|
-
ele.props.days = data.props?.days ?? '';
|
98
|
-
ele.props.lastDate = data.props?.lastDate ?? '';
|
99
|
-
ele.props.closeAge = data.props?.closeAge ?? '';
|
100
|
-
ele.props.kind = data.props?.kind ?? 'A';
|
101
|
-
return ele;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
function renderMH(element, ctx, position, isPaint) {
|
105
|
-
let { x, y } = position;
|
106
|
-
const defaultTextProps = new TextProps();
|
107
|
-
const paddingVer = 2;
|
108
|
-
const paddingHor = 5;
|
109
|
-
defaultTextProps.fontSize = 12;
|
110
|
-
defaultTextProps.fontName = '仿宋';
|
111
|
-
defaultTextProps.color = "rgb(0,0,0)";
|
112
|
-
const currentLayout = getMHItem(element.props.kind);
|
113
|
-
const left = CommonUtil.getEmptyValue(element.props[currentLayout.left.prop], currentLayout.left.tip);
|
114
|
-
const top = CommonUtil.getEmptyValue(element.props[currentLayout.top.prop], currentLayout.top.tip);
|
115
|
-
const bottom = CommonUtil.getEmptyValue(element.props[currentLayout.bottom.prop], currentLayout.bottom.tip);
|
116
|
-
const right = CommonUtil.getEmptyValue(element.props[currentLayout.right.prop], currentLayout.right.tip);
|
117
|
-
const leftRect = ctx.contentContext.measureText(left, defaultTextProps);
|
118
|
-
const topRect = ctx.contentContext.measureText(top, defaultTextProps);
|
119
|
-
const bottomRect = ctx.contentContext.measureText(bottom, defaultTextProps);
|
120
|
-
const rightRect = ctx.contentContext.measureText(right, defaultTextProps);
|
121
|
-
let height = topRect.height + bottomRect.height;
|
122
|
-
const middleWidth = Math.max(topRect.width, bottomRect.width);
|
123
|
-
let width = leftRect.width + middleWidth + rightRect.width;
|
124
|
-
if (!isPaint) {
|
125
|
-
return { width: width + paddingHor * 2, height: height + paddingVer * 2 };
|
126
|
-
}
|
127
|
-
x += paddingHor;
|
128
|
-
y += paddingVer;
|
129
|
-
//年龄
|
130
|
-
ctx.contentContext.drawText(left, defaultTextProps, x, y + (height - leftRect.height) / 2, leftRect.width, leftRect.height);
|
131
|
-
x += leftRect.width;
|
132
|
-
//天数
|
133
|
-
ctx.contentContext.drawText(top, defaultTextProps, x + (middleWidth - topRect.width) / 2, y - 2, topRect.width, topRect.height);
|
134
|
-
//分割线
|
135
|
-
ctx.contentContext.drawLine(x, y + topRect.height, middleWidth);
|
136
|
-
//周期
|
137
|
-
ctx.contentContext.drawText(bottom, defaultTextProps, x + (middleWidth - bottomRect.width) / 2, y + topRect.height + 2, bottomRect.width, bottomRect.height);
|
138
|
-
//末次时间
|
139
|
-
x += middleWidth;
|
140
|
-
ctx.contentContext.drawText(right, defaultTextProps, x, y + (height - leftRect.height) / 2, rightRect.width, rightRect.height);
|
141
|
-
if (ctx.drawMode === 'view') {
|
142
|
-
let { x, y } = position;
|
143
|
-
width = width + paddingHor * 2;
|
144
|
-
height = height + paddingVer * 2;
|
145
|
-
//const { width, height } = this.rect;
|
146
|
-
const lineWidth = 3;
|
147
|
-
const paintColor = '#0050b3';
|
148
|
-
ctx.contentContext.strokeLines([{ x: x + lineWidth, y }, { x, y }, { x, y: y + height }, { x: x + lineWidth, y: y + height }], 1, paintColor);
|
149
|
-
x = x + width;
|
150
|
-
ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x, y }, { x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);
|
151
|
-
}
|
152
|
-
}
|
153
|
-
//# sourceMappingURL=menstrual-history.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"menstrual-history.js","sourceRoot":"lib/","sources":["framework/impl/media-formula/menstrual-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAwC,cAAc,EAA0B,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,eAA+B;IAC9D,yBAAyB;IACzB;QACI,KAAK,CAAC,aAAa,CAAC,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,EAAE,CAAC;QAClC,0CAA0C;IAC9C,CAAC;IACD,QAAQ,CAAC,GAAmC;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,EAAE;YAChC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;gBACnB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAChD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,KA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AC;QAC7B,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QAC9I,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACd,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;KACjJ;AACL,CAAC","sourcesContent":["import { CommonUtil } from \"../../common-util\";\nimport { ViewOptions, Element, SerializeProps, ElementFactory, readElementProps, Rect } from \"../../element-define\";\nimport { DataEleMHProps, TextProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\nimport { DataElementLeaf } from \"../data-element/data-element-base-impl\";\n\n/**\n * 月经史\n */\nexport class DataElementMH extends DataElementLeaf<DataEleMHProps> {\n //props!: DataEleMHProps;\n constructor() {\n super('data-ele-mh')\n this.props = new DataEleMHProps();\n //this.addPropValueChangedSub(this.props);\n }\n setValue(val: DataEleMHProps | string | null): void {\n if (typeof val === 'string' && val) {\n const items = val.split(';');\n if (items.length >= 4) {\n const mhLayoutItem = getMHItem(this.props.kind);\n this.props[mhLayoutItem.left.prop] = items[0];\n this.props[mhLayoutItem.top.prop] = items[1];\n this.props[mhLayoutItem.bottom.prop] = items[2];\n this.props[mhLayoutItem.right.prop] = items[3];\n }\n } else if (typeof val === 'object') {\n this.props.age = val?.age ?? '';\n this.props.days = val?.days ?? '';\n this.props.cycles = val?.cycles ?? '';\n this.props.lastDate = val?.lastDate ?? '';\n this.props.closeAge = val?.closeAge ?? '';\n }\n }\n\n getValue() {\n const layoutItem = getMHItem(this.props.kind);\n return `${this.props[layoutItem.left.prop]};${this.props[layoutItem.top.prop]};${this.props[layoutItem.bottom.prop]};${this.props[layoutItem.right.prop]}`;\n }\n\n createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject<Element> | null {\n const render = new DataRenderMH(this);\n const measure = renderMH(this, renderCtx, { x: 0, y: 0 }, false);\n if (measure) {\n render.rect.width = measure.width;\n render.rect.height = measure.height;\n }\n return render;\n }\n serialize(viewOptions: ViewOptions): SerializeProps | null {\n return {\n type: this.type,\n props: this.props.getSerializeProps(viewOptions)\n }\n }\n clone(data: boolean): Element {\n const element = new DataElementMH();\n this.props.clone(element.props);\n return element;\n }\n\n getCurrentLayoutItem(): MHLayoutType {\n return getMHItem(this.props.kind);\n }\n\n}\n\ntype MHLayoutType = {\n [key in 'left' | 'top' | 'right' | 'bottom']: {\n tip: '初潮年龄' | '行经期天数' | '末次月经时间' | '月经周期天数' | '闭经年龄',\n prop: 'age' | 'days' | 'cycles' | 'lastDate' | 'closeAge'\n }\n}\n\nconst mhLayoutItems: Array<MHLayoutType> = [\n { left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '行经期天数', prop: 'days' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } },\n { left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '闭经年龄', prop: 'closeAge' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '行经期天数', prop: 'days' } },\n { left: { tip: '闭经年龄', prop: 'closeAge' }, top: { tip: '行经期天数', prop: 'days' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } },\n { left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '月经周期天数', prop: 'cycles' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '行经期天数', prop: 'days' } },\n { left: { tip: '初潮年龄', prop: 'age' }, top: { tip: '闭经年龄', prop: 'closeAge' }, right: { tip: '末次月经时间', prop: 'lastDate' }, bottom: { tip: '月经周期天数', prop: 'cycles' } }\n]\n\n\nfunction getMHItem(kind: string): MHLayoutType {\n kind = kind ?? 'A';\n kind = kind.toUpperCase();\n let kindIndex = ['A', 'B', 'C', 'D', 'E'].indexOf(kind);\n kindIndex = kindIndex < 0 ? 0 : kindIndex;\n return mhLayoutItems[kindIndex];\n}\n\nexport class DataRenderMH extends LeafRenderObject<DataElementMH> {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n renderMH(this.element, ctx, position, true);\n }\n\n clone(): RenderObject<Element> {\n const clone = new DataRenderMH(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n return clone;\n }\n}\n\nexport class DataElementMHFactory extends ElementFactory<DataEleMHProps> {\n match(type: string): boolean {\n return type === 'data-ele-mh'\n }\n createElement(data: readElementProps<DataEleMHProps>, renderCtx: RenderContenxtType): Element {\n const ele = new DataElementMH();\n ElementUtil.readEleBaseProps(ele.props, data.props as DataEleMHProps);\n ele.props.age = data.props?.age ?? '';\n ele.props.cycles = data.props?.cycles ?? '';\n ele.props.days = data.props?.days ?? '';\n ele.props.lastDate = data.props?.lastDate ?? '';\n ele.props.closeAge = data.props?.closeAge ?? '';\n ele.props.kind = data.props?.kind ?? 'A';\n return ele;\n }\n\n}\n\nfunction renderMH(element: DataElementMH, ctx: RenderContenxtType, position: { x: number; y: number; }, isPaint: boolean): { width: number, height: number } | void {\n let { x, y } = position;\n const defaultTextProps = new TextProps()\n const paddingVer = 2;\n const paddingHor = 5;\n defaultTextProps.fontSize = 12;\n defaultTextProps.fontName = '仿宋';\n defaultTextProps.color = \"rgb(0,0,0)\";\n const currentLayout = getMHItem(element.props.kind);\n const left = CommonUtil.getEmptyValue(element.props[currentLayout.left.prop], currentLayout.left.tip);\n const top = CommonUtil.getEmptyValue(element.props[currentLayout.top.prop], currentLayout.top.tip);\n const bottom = CommonUtil.getEmptyValue(element.props[currentLayout.bottom.prop], currentLayout.bottom.tip);\n const right = CommonUtil.getEmptyValue(element.props[currentLayout.right.prop], currentLayout.right.tip);\n const leftRect = ctx.contentContext.measureText(left, defaultTextProps)\n const topRect = ctx.contentContext.measureText(top, defaultTextProps)\n const bottomRect = ctx.contentContext.measureText(bottom, defaultTextProps)\n const rightRect = ctx.contentContext.measureText(right, defaultTextProps)\n let height = topRect.height + bottomRect.height;\n const middleWidth = Math.max(topRect.width, bottomRect.width)\n let width = leftRect.width + middleWidth + rightRect.width;\n if (!isPaint) {\n return { width: width + paddingHor * 2, height: height + paddingVer * 2 }\n }\n x += paddingHor;\n y += paddingVer;\n //年龄\n ctx.contentContext.drawText(left, defaultTextProps, x, y + (height - leftRect.height) / 2, leftRect.width, leftRect.height)\n x += leftRect.width;\n //天数\n ctx.contentContext.drawText(top, defaultTextProps, x + (middleWidth - topRect.width) / 2, y - 2, topRect.width, topRect.height);\n //分割线\n ctx.contentContext.drawLine(x, y + topRect.height, middleWidth)\n //周期\n ctx.contentContext.drawText(bottom, defaultTextProps, x + (middleWidth - bottomRect.width) / 2, y + topRect.height + 2, bottomRect.width, bottomRect.height);\n //末次时间\n x += middleWidth;\n ctx.contentContext.drawText(right, defaultTextProps, x, y + (height - leftRect.height) / 2, rightRect.width, rightRect.height)\n\n if (ctx.drawMode === 'view') {\n let { x, y } = position;\n width = width + paddingHor * 2;\n height = height + paddingVer * 2;\n //const { width, height } = this.rect;\n const lineWidth = 3;\n const paintColor = '#0050b3';\n ctx.contentContext.strokeLines([{ x: x + lineWidth, y }, { x, y }, { x, y: y + height }, { x: x + lineWidth, y: y + height }], 1, paintColor);\n x = x + width;\n ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x, y }, { x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);\n }\n}\n\n\n"]}
|