@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.
Files changed (149) hide show
  1. package/README.md +1613 -0
  2. package/lib/framework/element-props.d.ts +2 -2
  3. package/lib/framework/impl/index.d.ts +36 -0
  4. package/lib/index.d.ts +34 -0
  5. package/lib/index.js +15672 -0
  6. package/lib/texteditor.d.ts +3 -3
  7. package/package.json +27 -26
  8. package/lib/doc-ruler.js +0 -313
  9. package/lib/doc-ruler.js.map +0 -1
  10. package/lib/framework/common-util.js +0 -178
  11. package/lib/framework/common-util.js.map +0 -1
  12. package/lib/framework/document-change.js +0 -1342
  13. package/lib/framework/document-change.js.map +0 -1
  14. package/lib/framework/document-combine.js +0 -40
  15. package/lib/framework/document-combine.js.map +0 -1
  16. package/lib/framework/document-comment.js +0 -148
  17. package/lib/framework/document-comment.js.map +0 -1
  18. package/lib/framework/document-context.js +0 -330
  19. package/lib/framework/document-context.js.map +0 -1
  20. package/lib/framework/document-eval-func.js +0 -48
  21. package/lib/framework/document-eval-func.js.map +0 -1
  22. package/lib/framework/document-event.js +0 -1054
  23. package/lib/framework/document-event.js.map +0 -1
  24. package/lib/framework/document-history.js +0 -65
  25. package/lib/framework/document-history.js.map +0 -1
  26. package/lib/framework/document-images-loader.js +0 -66
  27. package/lib/framework/document-images-loader.js.map +0 -1
  28. package/lib/framework/document-input-cursor.js +0 -239
  29. package/lib/framework/document-input-cursor.js.map +0 -1
  30. package/lib/framework/document-paint.js +0 -103
  31. package/lib/framework/document-paint.js.map +0 -1
  32. package/lib/framework/document-print-offscreen.js +0 -128
  33. package/lib/framework/document-print-offscreen.js.map +0 -1
  34. package/lib/framework/document-print.js +0 -203
  35. package/lib/framework/document-print.js.map +0 -1
  36. package/lib/framework/document-segmenter.js +0 -106
  37. package/lib/framework/document-segmenter.js.map +0 -1
  38. package/lib/framework/document-selection.js +0 -358
  39. package/lib/framework/document-selection.js.map +0 -1
  40. package/lib/framework/document-template.js +0 -20
  41. package/lib/framework/document-template.js.map +0 -1
  42. package/lib/framework/document-textline-mode.js +0 -30
  43. package/lib/framework/document-textline-mode.js.map +0 -1
  44. package/lib/framework/element-define.js +0 -579
  45. package/lib/framework/element-define.js.map +0 -1
  46. package/lib/framework/element-event-define.js +0 -108
  47. package/lib/framework/element-event-define.js.map +0 -1
  48. package/lib/framework/element-measure.js +0 -551
  49. package/lib/framework/element-measure.js.map +0 -1
  50. package/lib/framework/element-paint.js +0 -170
  51. package/lib/framework/element-paint.js.map +0 -1
  52. package/lib/framework/element-props.js +0 -809
  53. package/lib/framework/element-props.js.map +0 -1
  54. package/lib/framework/element-reader.js +0 -151
  55. package/lib/framework/element-reader.js.map +0 -1
  56. package/lib/framework/element-render-cut.js +0 -449
  57. package/lib/framework/element-render-cut.js.map +0 -1
  58. package/lib/framework/element-serialize.js +0 -113
  59. package/lib/framework/element-serialize.js.map +0 -1
  60. package/lib/framework/element-util.js +0 -1463
  61. package/lib/framework/element-util.js.map +0 -1
  62. package/lib/framework/impl/checkbox/checkbox-impl.js +0 -64
  63. package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
  64. package/lib/framework/impl/comments/comment-content-impl.js +0 -105
  65. package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
  66. package/lib/framework/impl/comments/comment-element-impl.js +0 -62
  67. package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
  68. package/lib/framework/impl/comments/comments-container-impl.js +0 -62
  69. package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
  70. package/lib/framework/impl/comments/comments-util.js +0 -67
  71. package/lib/framework/impl/comments/comments-util.js.map +0 -1
  72. package/lib/framework/impl/comments/validate-msg-impl.js +0 -83
  73. package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
  74. package/lib/framework/impl/data-element/data-decorate-impl.js +0 -91
  75. package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
  76. package/lib/framework/impl/data-element/data-element-barcode.js +0 -115
  77. package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
  78. package/lib/framework/impl/data-element/data-element-base-impl.js +0 -205
  79. package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
  80. package/lib/framework/impl/data-element/data-element-check-impl.js +0 -133
  81. package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
  82. package/lib/framework/impl/data-element/data-element-date-impl.js +0 -111
  83. package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
  84. package/lib/framework/impl/data-element/data-element-group-impl.js +0 -130
  85. package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
  86. package/lib/framework/impl/data-element/data-element-image-impl.js +0 -137
  87. package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
  88. package/lib/framework/impl/data-element/data-element-list-impl.js +0 -131
  89. package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
  90. package/lib/framework/impl/data-element/data-element-text-impl.js +0 -103
  91. package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
  92. package/lib/framework/impl/decorate/fill-null-space-imple.js +0 -43
  93. package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
  94. package/lib/framework/impl/document/doc-body-impl.js +0 -79
  95. package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
  96. package/lib/framework/impl/document/doc-body-part-impl.js +0 -94
  97. package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
  98. package/lib/framework/impl/document/doc-container-impl.js +0 -21
  99. package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
  100. package/lib/framework/impl/document/doc-footer-impl.js +0 -77
  101. package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
  102. package/lib/framework/impl/document/doc-header-impl.js +0 -83
  103. package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
  104. package/lib/framework/impl/document/doc-impl.js +0 -209
  105. package/lib/framework/impl/document/doc-impl.js.map +0 -1
  106. package/lib/framework/impl/media-formula/menstrual-history.js +0 -153
  107. package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
  108. package/lib/framework/impl/paragraph/p-impl.js +0 -156
  109. package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
  110. package/lib/framework/impl/picture/image-impl.js +0 -124
  111. package/lib/framework/impl/picture/image-impl.js.map +0 -1
  112. package/lib/framework/impl/radio/radio-impl.js +0 -72
  113. package/lib/framework/impl/radio/radio-impl.js.map +0 -1
  114. package/lib/framework/impl/symbol/br-symbol-impl.js +0 -54
  115. package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
  116. package/lib/framework/impl/symbol/p-symbol-impl.js +0 -54
  117. package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
  118. package/lib/framework/impl/table/table-cell-impl.js +0 -145
  119. package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
  120. package/lib/framework/impl/table/table-impl.js +0 -363
  121. package/lib/framework/impl/table/table-impl.js.map +0 -1
  122. package/lib/framework/impl/table/table-row-impl.js +0 -75
  123. package/lib/framework/impl/table/table-row-impl.js.map +0 -1
  124. package/lib/framework/impl/table/table-split-cell-patch.js +0 -89
  125. package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
  126. package/lib/framework/impl/table/table-split-cell.js +0 -464
  127. package/lib/framework/impl/table/table-split-cell.js.map +0 -1
  128. package/lib/framework/impl/table/table-util.js +0 -678
  129. package/lib/framework/impl/table/table-util.js.map +0 -1
  130. package/lib/framework/impl/text/text-impl.js +0 -149
  131. package/lib/framework/impl/text/text-impl.js.map +0 -1
  132. package/lib/framework/impl/text/track-run-impl.js +0 -112
  133. package/lib/framework/impl/text/track-run-impl.js.map +0 -1
  134. package/lib/framework/notify.js +0 -116
  135. package/lib/framework/notify.js.map +0 -1
  136. package/lib/framework/range-util.js +0 -312
  137. package/lib/framework/range-util.js.map +0 -1
  138. package/lib/framework/render-context.js +0 -384
  139. package/lib/framework/render-context.js.map +0 -1
  140. package/lib/framework/render-define.js +0 -195
  141. package/lib/framework/render-define.js.map +0 -1
  142. package/lib/framework/selection-overlays.js +0 -124
  143. package/lib/framework/selection-overlays.js.map +0 -1
  144. package/lib/texteditor.js +0 -913
  145. package/lib/texteditor.js.map +0 -1
  146. package/lib/util/subject.js +0 -88
  147. package/lib/util/subject.js.map +0 -1
  148. package/lib/util/table-bind.js +0 -6
  149. package/lib/util/table-bind.js.map +0 -1
@@ -1,67 +0,0 @@
1
- import { ElementUtil } from "../../element-util";
2
- import { DocumentRenderObject } from "../document/doc-impl";
3
- export class CommentsUtil {
4
- static remeasureComments(ctx, commWindow, commContainer, map) {
5
- const commMap = [];
6
- const docRender = ElementUtil.getParentRender(commWindow, DocumentRenderObject);
7
- for (let i = 0; i < commContainer.length; i++) {
8
- const commRender = commContainer.getChild(i);
9
- const commEle = commRender.element;
10
- const mapComm = map.find(item => item.ele.props.id === commEle.props.id);
11
- if (mapComm) {
12
- const commMarkLinePos = ElementUtil.getParaLinePos(mapComm.render, mapComm.pos);
13
- mapComm.pos.y = commMarkLinePos.y + 2;
14
- const commContentRender = commRender.clone();
15
- commContentRender.rect.x = 0;
16
- commContentRender.rect.y = mapComm.pos.y;
17
- commWindow.addChild(commContentRender);
18
- commMap.push({
19
- commMarkRender: mapComm.render,
20
- commMarkPos: mapComm.pos,
21
- commContentRender: commContentRender
22
- });
23
- }
24
- }
25
- let sumCommentHeight = 0;
26
- for (let i = 0; i < commMap.length; i++) {
27
- const map = commMap[i];
28
- const prevRender = commMap[i - 1]?.commContentRender;
29
- const { commContentRender } = map;
30
- sumCommentHeight += commContentRender.rect.height + 5;
31
- if (prevRender) {
32
- const { y: prevY, height: prevHeight } = prevRender.rect;
33
- if (commContentRender.rect.y < prevY + prevHeight) {
34
- commContentRender.rect.y = prevY + prevHeight + 5;
35
- }
36
- }
37
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
38
- }
39
- if (!commMap.length) {
40
- return;
41
- }
42
- const lastCommentMap = commMap[commMap.length - 1];
43
- const { commContentRender: lastCommContentRender } = lastCommentMap;
44
- const { rect: lastRect } = lastCommContentRender;
45
- //批注内容超出文档,需要重新排序
46
- if (lastRect.y + lastRect.height > docRender.rect.height) {
47
- //总内容小于容器高度,则进行倒排
48
- //否则进行正排
49
- if (sumCommentHeight < docRender.rect.height) {
50
- lastRect.y = docRender.rect.height - lastRect.height;
51
- for (let i = commMap.length - 1; i >= 0; i--) {
52
- const map = commMap[i];
53
- const prevRender = commMap[i + 1]?.commContentRender;
54
- const { commContentRender } = map;
55
- if (prevRender) {
56
- const { y: prevY } = prevRender.rect;
57
- if (commContentRender.rect.y + commContentRender.rect.height > prevY) {
58
- commContentRender.rect.y = prevY - commContentRender.rect.height - 5;
59
- }
60
- }
61
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
62
- }
63
- }
64
- }
65
- }
66
- }
67
- //# sourceMappingURL=comments-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"comments-util.js","sourceRoot":"lib/","sources":["framework/impl/comments/comments-util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAY1D,MAAM,OAAO,YAAY;IACrB,MAAM,CAAC,iBAAiB,CAAC,GAAuB,EAAE,UAAsC,EAAE,aAAyC,EAAE,GAAwE;QACzM,MAAM,OAAO,GAAwB,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC,UAAU,EAAE,oBAAoB,CAAyB,CAAC;QACxG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,OAAiC,CAAC;YAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,I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AC,EAAE,KAAK,EAAC,GAAG,UAAU,CAAC,IAAI,CAAC;wBACnC,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE;4BAClE,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;yBACxE;qBACJ;oBACD,iBAAiB,CAAC,cAAc,GAAG,EAAC,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,CAAC,WAAW,EAAC,CAAC;iBACzF;aACJ;SACJ;IAEL,CAAC;CAEJ","sourcesContent":["import {Position} from \"../../element-define\";\nimport {RenderContenxtType} from \"../../render-context\";\nimport {RenderObject} from \"../../render-define\";\nimport {ElementUtil} from \"../../element-util\";\nimport {DocumentRenderObject} from \"../document/doc-impl\";\nimport {CommContentBaseElement, CommContentBaseRenderObject,} from \"./comment-content-impl\";\nimport {CommentElement, CommentRenderObject} from \"./comment-element-impl\";\nimport {CommsContainerRenderObject} from \"./comments-container-impl\";\n\ninterface CommMapProps {\n commMarkRender: CommentRenderObject,\n commMarkPos: Position,\n commContentRender: CommContentBaseRenderObject<any>,\n commContentPos?: Position\n}\n\nexport class CommentsUtil {\n static remeasureComments(ctx: RenderContenxtType, commWindow: CommsContainerRenderObject, commContainer: CommsContainerRenderObject, map: Array<{ ele: CommentElement, render: RenderObject, pos: Position }>): void {\n const commMap: Array<CommMapProps> = [];\n const docRender = ElementUtil.getParentRender(commWindow, DocumentRenderObject) as DocumentRenderObject;\n for (let i = 0; i < commContainer.length; i++) {\n const commRender = commContainer.getChild(i);\n const commEle = commRender.element as CommContentBaseElement;\n const mapComm = map.find(item => item.ele.props.id === commEle.props.id);\n if (mapComm) {\n const commMarkLinePos = ElementUtil.getParaLinePos(mapComm.render, mapComm.pos);\n mapComm.pos.y = commMarkLinePos.y + 2;\n\n const commContentRender = commRender.clone() as CommContentBaseRenderObject<any>;\n commContentRender.rect.x = 0;\n commContentRender.rect.y = mapComm.pos.y;\n commWindow.addChild(commContentRender);\n commMap.push({\n commMarkRender: <CommentRenderObject>mapComm.render,\n commMarkPos: mapComm.pos,\n commContentRender: commContentRender\n });\n }\n }\n let sumCommentHeight = 0;\n for (let i = 0; i < commMap.length; i++) {\n const map = commMap[i];\n const prevRender = commMap[i - 1]?.commContentRender;\n const {commContentRender} = map;\n sumCommentHeight += commContentRender.rect.height + 5;\n if (prevRender) {\n const {y: prevY, height: prevHeight} = prevRender.rect;\n if (commContentRender.rect.y < prevY + prevHeight) {\n commContentRender.rect.y = prevY + prevHeight + 5;\n }\n }\n commContentRender.commMarkRender = {render: map.commMarkRender, pos: map.commMarkPos};\n }\n if (!commMap.length) {\n return;\n }\n const lastCommentMap = commMap[commMap.length - 1];\n const {commContentRender: lastCommContentRender} = lastCommentMap;\n const {rect: lastRect} = lastCommContentRender;\n\n //批注内容超出文档,需要重新排序\n if (lastRect.y + lastRect.height > docRender.rect.height) {\n //总内容小于容器高度,则进行倒排\n //否则进行正排\n if (sumCommentHeight < docRender.rect.height) {\n lastRect.y = docRender.rect.height - lastRect.height;\n for (let i = commMap.length - 1; i >= 0; i--) {\n const map = commMap[i];\n const prevRender = commMap[i + 1]?.commContentRender;\n const {commContentRender} = map;\n if (prevRender) {\n const {y: prevY} = prevRender.rect;\n if (commContentRender.rect.y + commContentRender.rect.height > prevY) {\n commContentRender.rect.y = prevY - commContentRender.rect.height - 5;\n }\n }\n commContentRender.commMarkRender = {render: map.commMarkRender, pos: map.commMarkPos};\n }\n }\n }\n\n }\n\n}\n"]}
@@ -1,83 +0,0 @@
1
- import { TextProps, ValidateProps } from "../../element-props";
2
- import { ElementUtil } from "../../element-util";
3
- import { CommContentBaseElement, CommContentBaseRenderObject } from "./comment-content-impl";
4
- import { ParagraphElement } from "../paragraph/p-impl";
5
- import { TextGroupElement } from "../text/text-impl";
6
- import { DocumentRenderObject } from "../document/doc-impl";
7
- /**
8
- * 数据元验证提示
9
- */
10
- export class ValidateElement extends CommContentBaseElement {
11
- constructor() {
12
- super('validate');
13
- this.props = new ValidateProps();
14
- this.isDecorate = true;
15
- }
16
- createRenderObject(options, renderCtx) {
17
- const render = new ValidateRenderObject(this);
18
- render.padding.left = 14;
19
- render.padding.top = 24;
20
- return render;
21
- }
22
- serialize(viewOptions) {
23
- return null;
24
- }
25
- clone(data) {
26
- throw new Error("Method not implemented.");
27
- }
28
- setContent(content) {
29
- this.clearItems();
30
- const para = new ParagraphElement();
31
- const text = new TextGroupElement();
32
- text.props.fontSize = 14;
33
- text.props.fontName = '等线';
34
- text.props.color = '#000000';
35
- text.text = content;
36
- para.addChild(text);
37
- this.addChild(para);
38
- }
39
- }
40
- export class ValidateRenderObject extends CommContentBaseRenderObject {
41
- beginRender(ctx, position) {
42
- let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';
43
- ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, borderColor);
44
- ctx.contentContext.fillRect(position.x, position.y, 8, this.rect.height, '#871400');
45
- const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject);
46
- //获取审阅标记的绘制坐标
47
- let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, { x: 0, y: -ctx.viewOptions.translateY });
48
- const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
49
- commMarkPos.y = commMarkLinePos.y + 2;
50
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, { x: 0, y: -ctx.viewOptions.translateY });
51
- const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
52
- const marginRight = ctx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
53
- ctx.overlaysContext.drawDashLine([commMarkPos, { x: commMarkPos.x + marginRight, y: commMarkPos.y }], [1, 1], 'red');
54
- ctx.overlaysContext.drawDashLine([{ x: commMarkPos.x + marginRight, y: commMarkPos.y }, position], [1, 1], 'red');
55
- this.renderTitle(ctx, position);
56
- }
57
- renderTitle(ctx, position) {
58
- const topPadding = 24;
59
- const { props } = this.element;
60
- const textProps = new TextProps();
61
- textProps.fontSize = 12;
62
- textProps.fontName = '楷体';
63
- textProps.color = "rgb(0,0,0)";
64
- const title = this.element.props.title;
65
- const { width, height } = ctx.contentContext.measureText(title, textProps);
66
- const rect = { x: position.x + this.padding.left, y: position.y, width, height, maxHeight: 0, maxWidth: 0 };
67
- rect.y += (topPadding - rect.height) / 2;
68
- ctx.contentContext.drawText(title, textProps, rect.x, rect.y, rect.width, rect.height);
69
- }
70
- endRender(ctx, position) {
71
- //throw new Error("Method not implemented.");
72
- }
73
- clone() {
74
- const clone = new ValidateRenderObject(this.element);
75
- clone.rect = ElementUtil.cloneRect(this.rect);
76
- clone.padding = this.padding.clone();
77
- for (let i = 0; i < this.length; i++) {
78
- clone.addChild(this.getChild(i).clone());
79
- }
80
- return clone;
81
- }
82
- }
83
- //# sourceMappingURL=validate-msg-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-msg-impl.js","sourceRoot":"lib/","sources":["framework/impl/comments/validate-msg-impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,sBAAqC;IACtE;QACI,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,EAAE,CA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AQ,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3F,CAAC;IACD,SAAS,CAAC,GAAuB,EAAE,QAAkB;QACjD,6CAA6C;IACjD,CAAC;IACD,KAAK;QACD,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;SAC5C;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { ViewOptions, Element, SerializeProps, Position, Rect } from \"../../element-define\";\nimport { TextProps, ValidateProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { RenderObject } from \"../../render-define\";\nimport { CommContentBaseElement, CommContentBaseRenderObject } from \"./comment-content-impl\";\nimport { ParagraphElement } from \"../paragraph/p-impl\";\nimport { TextGroupElement } from \"../text/text-impl\";\nimport { DocumentRenderObject } from \"../document/doc-impl\";\n\n/**\n * 数据元验证提示\n */\nexport class ValidateElement extends CommContentBaseElement<ValidateProps> {\n constructor() {\n super('validate');\n this.props = new ValidateProps();\n this.isDecorate = true;\n }\n\n createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject | null {\n const render = new ValidateRenderObject(this);\n render.padding.left = 14;\n render.padding.top = 24;\n return render;\n }\n\n serialize(viewOptions: ViewOptions): SerializeProps | null {\n return null;\n }\n\n clone(data: boolean): Element {\n throw new Error(\"Method not implemented.\");\n }\n\n setContent(content: string): void {\n this.clearItems();\n const para = new ParagraphElement();\n const text = new TextGroupElement();\n text.props.fontSize = 14;\n text.props.fontName = '等线';\n text.props.color = '#000000'\n text.text = content;\n para.addChild(text);\n this.addChild(para);\n }\n}\n\nexport class ValidateRenderObject extends CommContentBaseRenderObject<ValidateElement> {\n beginRender(ctx: RenderContenxtType, position: Position): void {\n let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';\n ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, borderColor);\n ctx.contentContext.fillRect(position.x, position.y, 8, this.rect.height, '#871400')\n const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject) as DocumentRenderObject;\n //获取审阅标记的绘制坐标\n let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, { x: 0, y: -ctx.viewOptions.translateY });\n const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);\n commMarkPos.y = commMarkLinePos.y + 2;\n\n const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, { x: 0, y: -ctx.viewOptions.translateY });\n const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;\n const marginRight = ctx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;\n ctx.overlaysContext.drawDashLine([commMarkPos, { x: commMarkPos.x + marginRight, y: commMarkPos.y }], [1, 1], 'red');\n ctx.overlaysContext.drawDashLine([{ x: commMarkPos.x + marginRight, y: commMarkPos.y }, position], [1, 1], 'red');\n\n this.renderTitle(ctx, position);\n }\n\n renderTitle(ctx: RenderContenxtType, position: Position): void {\n const topPadding = 24;\n const { props } = this.element;\n const textProps = new TextProps();\n textProps.fontSize = 12;\n textProps.fontName = '楷体';\n textProps.color = \"rgb(0,0,0)\";\n const title = this.element.props.title;\n const { width, height } = ctx.contentContext.measureText(title, textProps);\n const rect: Rect = { x: position.x + this.padding.left, y: position.y, width, height, maxHeight: 0, maxWidth: 0 }\n rect.y += (topPadding - rect.height) / 2;\n ctx.contentContext.drawText(title, textProps, rect.x, rect.y, rect.width, rect.height);\n }\n endRender(ctx: RenderContenxtType, position: Position): void {\n //throw new Error(\"Method not implemented.\");\n }\n clone(): RenderObject {\n const clone = new ValidateRenderObject(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n clone.padding = this.padding.clone();\n for (let i = 0; i < this.length; i++) {\n clone.addChild(this.getChild(i).clone());\n }\n return clone;\n }\n}\n"]}
@@ -1,91 +0,0 @@
1
- import { LeafElement } from "../../element-define";
2
- import { ElementUtil } from "../../element-util";
3
- import { LeafRenderObject } from "../../render-define";
4
- import { InlineGroupInputElement, validateInlineInputRenderObj } from "./data-element-base-impl";
5
- export class DataDecorateElement extends LeafElement {
6
- dataEle;
7
- isPrefix;
8
- //props: DataDecorateProps;
9
- constructor(dataEle, isPrefix) {
10
- super('data-dec');
11
- this.dataEle = dataEle;
12
- this.isPrefix = isPrefix;
13
- this.addEvent('GotCursor', (evt) => {
14
- const { selectionState } = evt.ctx;
15
- if (selectionState.collapsed && this.parent instanceof InlineGroupInputElement) {
16
- const group = this.parent;
17
- if (this === group.endDecorate && selectionState.startOffset === 0) {
18
- if (group.length === 2) {
19
- selectionState.resetRange(group.startDecorate, 1);
20
- evt.isCancel = true;
21
- }
22
- }
23
- }
24
- });
25
- this.isDecorate = true;
26
- }
27
- createRenderObject() {
28
- const render = new DataDecorateRenderObject(this);
29
- //render.rect.width = this.dProps.size / 2;
30
- render.rect.width = 6;
31
- render.rect.height = 14;
32
- return render;
33
- }
34
- serialize() {
35
- return null;
36
- }
37
- clone() {
38
- const clone = new DataDecorateElement(this.dataEle, this.isPrefix);
39
- this.props.clone(clone.props);
40
- //clone.renderCtx = this.renderCtx;
41
- return clone;
42
- }
43
- }
44
- export class DataDecorateArrowRenderObject extends LeafRenderObject {
45
- render(ctx, position) {
46
- throw new Error("Method not implemented.");
47
- }
48
- clone() {
49
- throw new Error("Method not implemented.");
50
- }
51
- }
52
- export class DataDecorateRenderObject extends LeafRenderObject {
53
- render(ctx, position) {
54
- this.renderDecorRect(ctx, position);
55
- }
56
- renderDecorRect(ctx, position) {
57
- if (ctx.drawMode === 'print') {
58
- return;
59
- }
60
- const dataEleRender = ElementUtil.getParentRenderByPredicate(this, item => validateInlineInputRenderObj(item));
61
- if (!dataEleRender) {
62
- return;
63
- }
64
- const dataEleRenderPos = ElementUtil.getParentRenderPos(dataEleRender, this, position);
65
- const element = this.element;
66
- let { x, y, height, width } = dataEleRenderPos;
67
- const lineWidth = 2;
68
- const paintColor = '#0050b3';
69
- ctx.contentContext.ctx.save();
70
- if (this.element.parent.type === 'data-group') {
71
- ctx.contentContext.ctx.shadowBlur = 5;
72
- ctx.contentContext.ctx.shadowColor = 'black';
73
- }
74
- if (element.isPrefix) {
75
- x += 2;
76
- 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 {
79
- x = x + width - 2;
80
- ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x: x, y }, { x: x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);
81
- }
82
- ctx.contentContext.ctx.restore();
83
- return;
84
- }
85
- clone(cloneData = true) {
86
- const clone = new DataDecorateRenderObject(this.element);
87
- clone.rect = ElementUtil.cloneRect(this.rect);
88
- return clone;
89
- }
90
- }
91
- //# sourceMappingURL=data-decorate-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-decorate-impl.js","sourceRoot":"lib/","sources":["framework/impl/data-element/data-decorate-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,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,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ","sourcesContent":["import { LeafElement, SerializeProps } from \"../../element-define\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\nimport { InlineGroupInputElement, validateInlineInputRenderObj } from \"./data-element-base-impl\";\n\nexport class DataDecorateElement extends LeafElement<any> {\n //props: DataDecorateProps;\n constructor(public dataEle: InlineGroupInputElement, public isPrefix: boolean) {\n super('data-dec');\n this.addEvent('GotCursor', (evt) => {\n const { selectionState } = evt.ctx;\n if (selectionState.collapsed && this.parent instanceof InlineGroupInputElement) {\n const group = this.parent as InlineGroupInputElement;\n if (this === group.endDecorate && selectionState.startOffset === 0) {\n if (group.length === 2) {\n selectionState.resetRange(group.startDecorate, 1);\n evt.isCancel = true;\n }\n }\n }\n });\n this.isDecorate = true;\n }\n createRenderObject(): DataDecorateRenderObject {\n const render = new DataDecorateRenderObject(this);\n //render.rect.width = this.dProps.size / 2;\n render.rect.width = 6;\n render.rect.height = 14;\n return render;\n }\n\n serialize(): SerializeProps | null {\n return null;\n }\n clone(): DataDecorateElement {\n const clone = new DataDecorateElement(this.dataEle, this.isPrefix);\n this.props.clone(clone.props);\n //clone.renderCtx = this.renderCtx;\n return clone;\n }\n}\n\nexport class DataDecorateArrowRenderObject extends LeafRenderObject {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n throw new Error(\"Method not implemented.\");\n }\n clone(): RenderObject {\n throw new Error(\"Method not implemented.\");\n }\n\n}\n\nexport class DataDecorateRenderObject extends LeafRenderObject {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n this.renderDecorRect(ctx, position);\n }\n\n renderDecorRect(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n if (ctx.drawMode === 'print') {\n return;\n }\n const dataEleRender = ElementUtil.getParentRenderByPredicate(this, item => validateInlineInputRenderObj(item));\n if (!dataEleRender) {\n return;\n }\n const dataEleRenderPos = ElementUtil.getParentRenderPos(dataEleRender, this, position);\n const element = this.element as DataDecorateElement;\n let { x, y, height, width } = dataEleRenderPos;\n const lineWidth = 2;\n const paintColor = '#0050b3';\n ctx.contentContext.ctx.save();\n if (this.element.parent.type === 'data-group') {\n ctx.contentContext.ctx.shadowBlur = 5;\n ctx.contentContext.ctx.shadowColor = 'black';\n }\n if (element.isPrefix) {\n x += 2;\n ctx.contentContext.strokeLines([{ x: x + lineWidth, y }, { x: x, y }, { x: x, y: y + height }, { x: x + lineWidth, y: y + height }], 1, paintColor);\n } else {\n x = x + width - 2;\n ctx.contentContext.strokeLines([{ x: x - lineWidth, y }, { x: x, y }, { x: x, y: y + height }, { x: x - lineWidth, y: y + height }], 1, paintColor);\n }\n ctx.contentContext.ctx.restore();\n return;\n\n }\n\n clone(cloneData = true): RenderObject {\n const clone = new DataDecorateRenderObject(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n return clone;\n }\n\n}\n"]}
@@ -1,115 +0,0 @@
1
- import { ElementFactory, ResizeLeafRenderObject } from "../../element-define";
2
- import { DataElementBarcodeProps } from "../../element-props";
3
- import { ElementUtil } from "../../element-util";
4
- import { DataElementLeaf } from "./data-element-base-impl";
5
- import bwipjs from "bwip-js";
6
- import { watchChanged } from "../../notify";
7
- export class DataElementBarcode extends DataElementLeaf {
8
- resizeable = true;
9
- barCodeCanvas;
10
- cache = false;
11
- constructor() {
12
- super('data-ele-barcode');
13
- this.props = new DataElementBarcodeProps();
14
- this.props.width = 100;
15
- this.props.height = 30;
16
- this.focusable = true;
17
- watchChanged(this.props, () => {
18
- this.cache = false;
19
- });
20
- }
21
- createRenderObject() {
22
- const render = new DataElementBarcodeRenderObject(this);
23
- render.rect.width = this.props.width + 2;
24
- render.rect.height = this.props.height + 2;
25
- return render;
26
- }
27
- serialize(options) {
28
- return {
29
- type: this.type,
30
- props: {
31
- ...this.props.getSerializeProps()
32
- }
33
- };
34
- }
35
- clone(data) {
36
- const clone = new DataElementBarcode();
37
- this.props.clone(clone.props);
38
- return clone;
39
- }
40
- setValue(val) {
41
- this.props.text = val;
42
- }
43
- getValue() {
44
- return this.props.text;
45
- }
46
- drawBarcode(renderCtx, pos) {
47
- this.createBarcodeCache();
48
- renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas, pos.x, pos.y, this.props.width, this.props.height);
49
- }
50
- createBarcodeCache() {
51
- if (this.cache) {
52
- return;
53
- }
54
- this.cache = true;
55
- if (!this.barCodeCanvas) {
56
- this.barCodeCanvas = document.createElement('canvas');
57
- }
58
- this.barCodeCanvas = bwipjs.toCanvas(this.barCodeCanvas, {
59
- bcid: this.props.type,
60
- text: this.props.text || "0123456789",
61
- height: 10,
62
- includetext: true,
63
- textxalign: "center", // Always good to set this
64
- });
65
- }
66
- }
67
- export class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
68
- render(ctx, position) {
69
- const barcodeEle = this.element;
70
- barcodeEle.drawBarcode(ctx, position);
71
- }
72
- clone() {
73
- const clone = new DataElementBarcodeRenderObject(this.element);
74
- clone.rect = ElementUtil.cloneRect(this.rect);
75
- return clone;
76
- }
77
- pagePaintCompleted(ctx, pos) {
78
- if (this.element.isFocused) {
79
- const { width, height } = this.rect;
80
- ctx.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
81
- this.drawResizeCircle(ctx, pos.x, pos.y);
82
- this.drawResizeCircle(ctx, pos.x + width, pos.y);
83
- this.drawResizeCircle(ctx, pos.x, pos.y + height);
84
- this.drawResizeCircle(ctx, pos.x + width, pos.y + height);
85
- this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y);
86
- this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y + height);
87
- this.drawResizeCircle(ctx, pos.x, pos.y + (Math.floor(height / 2)));
88
- this.drawResizeCircle(ctx, pos.x + width, pos.y + (Math.floor(height / 2)));
89
- }
90
- }
91
- drawResizeCircle(ctx, x, y) {
92
- const ctxNative = ctx.contentContext.ctx;
93
- ctxNative.save();
94
- ctxNative.fillStyle = '#69c0ff';
95
- ctxNative.beginPath();
96
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
97
- ctxNative.closePath();
98
- ctxNative.fill();
99
- ctxNative.restore();
100
- }
101
- }
102
- export class DataElementBarcodeFactory extends ElementFactory {
103
- match(type) {
104
- return type === 'data-ele-barcode';
105
- }
106
- createElement(data, renderCtx) {
107
- const ele = new DataElementBarcode();
108
- ele.props.width = data.props?.width || 100;
109
- ele.props.height = data.props?.height || 30;
110
- ele.props.type = data.props?.type || 'code128';
111
- ele.props.text = data.props?.text || '';
112
- return ele;
113
- }
114
- }
115
- //# sourceMappingURL=data-element-barcode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-element-barcode.js","sourceRoot":"lib/","sources":["framework/impl/data-element/data-element-barcode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAA8B,sBAAsB,EAA+B,MAAM,sBAAsB,CAAC;AAChJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,OAAO,kBAAmB,SAAQ,eAAwC;IAC5E,UAAU,GAAY,IAAI,CAAC;IACnB,aAAa,CAA4B;IACzC,KAAK,GAAG,KAAK,CAAC;IACtB;QACI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CA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Element, ElementFactory, Position, readElementProps, ResizeLeafRenderObject, SerializeProps, ViewOptions } from \"../../element-define\";\nimport { DataElementBarcodeProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\nimport { DataElementLeaf } from \"./data-element-base-impl\";\nimport bwipjs from \"bwip-js\";\nimport { watchChanged } from \"../../notify\";\n\n\nexport class DataElementBarcode extends DataElementLeaf<DataElementBarcodeProps> {\n resizeable: boolean = true;\n private barCodeCanvas!: HTMLCanvasElement | null;\n private cache = false;\n constructor() {\n super('data-ele-barcode');\n this.props = new DataElementBarcodeProps();\n this.props.width = 100;\n this.props.height = 30;\n this.focusable = true;\n watchChanged(this.props, () => {\n this.cache = false;\n });\n }\n createRenderObject(): LeafRenderObject {\n const render = new DataElementBarcodeRenderObject(this);\n render.rect.width = this.props.width + 2;\n render.rect.height = this.props.height + 2;\n return render;\n }\n serialize(options: ViewOptions): SerializeProps {\n return {\n type: this.type,\n props: {\n ...this.props.getSerializeProps()\n }\n }\n }\n clone(data: boolean): Element {\n const clone = new DataElementBarcode();\n this.props.clone(clone.props);\n return clone;\n }\n\n setValue(val: string): void {\n this.props.text = val;\n }\n\n getValue(): string {\n return this.props.text;\n }\n\n drawBarcode(renderCtx: RenderContenxtType, pos: Position): void {\n this.createBarcodeCache();\n renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas as HTMLCanvasElement, pos.x, pos.y, this.props.width, this.props.height);\n }\n\n createBarcodeCache(): void {\n if (this.cache) {\n return;\n }\n this.cache = true;\n if (!this.barCodeCanvas) {\n this.barCodeCanvas = document.createElement('canvas');\n }\n this.barCodeCanvas = bwipjs.toCanvas(this.barCodeCanvas, {\n bcid: this.props.type, // Barcode type\n text: this.props.text || \"0123456789\", // Text to encode\n height: 10, // Bar height, in millimeters\n includetext: true, // Show human-readable text\n textxalign: \"center\", // Always good to set this\n });\n }\n}\n\nexport class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const barcodeEle = this.element as DataElementBarcode;\n barcodeEle.drawBarcode(ctx, position);\n }\n clone(): RenderObject {\n const clone = new DataElementBarcodeRenderObject(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n return clone;\n }\n\n pagePaintCompleted(ctx: RenderContenxtType, pos: Position): void {\n if (this.element.isFocused) {\n const { width, height } = this.rect;\n ctx.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);\n this.drawResizeCircle(ctx, pos.x, pos.y);\n this.drawResizeCircle(ctx, pos.x + width, pos.y);\n this.drawResizeCircle(ctx, pos.x, pos.y + height);\n this.drawResizeCircle(ctx, pos.x + width, pos.y + height);\n this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y);\n this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y + height);\n this.drawResizeCircle(ctx, pos.x, pos.y + (Math.floor(height / 2)));\n this.drawResizeCircle(ctx, pos.x + width, pos.y + (Math.floor(height / 2)));\n }\n }\n\n private drawResizeCircle(ctx: RenderContenxtType, x: number, y: number): void {\n const ctxNative = ctx.contentContext.ctx;\n ctxNative.save();\n ctxNative.fillStyle = '#69c0ff';\n ctxNative.beginPath();\n ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);\n ctxNative.closePath();\n ctxNative.fill();\n ctxNative.restore();\n }\n}\n\n\nexport class DataElementBarcodeFactory extends ElementFactory<DataElementBarcodeProps> {\n match(type: string): boolean {\n return type === 'data-ele-barcode';\n }\n createElement(data: readElementProps<DataElementBarcodeProps>, renderCtx: RenderContenxtType): Element {\n const ele = new DataElementBarcode();\n ele.props.width = data.props?.width || 100;\n ele.props.height = data.props?.height || 30;\n ele.props.type = data.props?.type || 'code128';\n ele.props.text = data.props?.text || '';\n return ele;\n }\n}\n"]}
@@ -1,205 +0,0 @@
1
- import { DocMode, InlineGroupElement, LeafElement } from "../../element-define";
2
- import { InlineGroupRenderObject } from "../../render-define";
3
- import { DataDecorateElement } from "./data-decorate-impl";
4
- import { ElementUtil } from "../../element-util";
5
- /**
6
- * 所有的数据元继承上述两个抽象类
7
- */
8
- export class DataElementLeaf extends LeafElement {
9
- }
10
- /**
11
- * 可供输入的内联块
12
- * 使用场景:数据元,数据组
13
- */
14
- export class InlineGroupInputElement extends InlineGroupElement {
15
- startDecorate;
16
- endDecorate;
17
- constructor(type) {
18
- super(type);
19
- //行内块不允许换行
20
- this.addEvent('ElementKeyDown', (evt) => {
21
- const { selectionState, sourceEvent, source } = evt;
22
- const { startControl, startOffset } = selectionState;
23
- if (IsInSideDataElement(startControl, startOffset)) {
24
- if (sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
25
- //this.removeNullText();
26
- }
27
- else if (!sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
28
- evt.isCancel = true;
29
- }
30
- }
31
- }, true);
32
- this.addEvent('GotCursor', (evt) => {
33
- const { startControl, startOffset } = evt.selectionState;
34
- if (IsInSideDataElement(startControl, startOffset)) {
35
- this.isFocused = true;
36
- }
37
- });
38
- this.addEvent('LostCursor', (evt) => { this.isFocused = false; });
39
- }
40
- fillDecorate() {
41
- if (!this.startDecorate) {
42
- const { startDecorate, endDecorate } = this.createDataDecorate();
43
- this.addChild(startDecorate, 0);
44
- this.addChild(endDecorate);
45
- this.startDecorate = startDecorate;
46
- this.endDecorate = endDecorate;
47
- }
48
- }
49
- createDataDecorate() {
50
- const startDecorate = new DataDecorateElement(this, true);
51
- const endDecorate = new DataDecorateElement(this, false);
52
- return {
53
- startDecorate,
54
- endDecorate
55
- };
56
- }
57
- beginMeasure() {
58
- this.fillDecorate();
59
- super.beginMeasure();
60
- }
61
- addChild(child, index = -1) {
62
- index = index === -1 ? this.length : index;
63
- index = index > this.length ? this.length : index;
64
- if (index === 0 && this.startDecorate) {
65
- this.parent?.addChild(child, this.getIndex());
66
- return;
67
- }
68
- if (index === this.length && this.endDecorate) {
69
- this.parent?.addChild(child, this.getIndex() + 1);
70
- return;
71
- }
72
- super.addChild(child, index);
73
- }
74
- clearInnerItems() {
75
- const removeItems = [];
76
- for (let i = this.length - 1; i >= 0; i--) {
77
- const child = this.getChild(i);
78
- if (child !== this.startDecorate && child !== this.endDecorate) {
79
- removeItems.push(child);
80
- }
81
- }
82
- removeItems.forEach(item => this.removeChild(item));
83
- }
84
- }
85
- export class DataElementInlineGroup extends InlineGroupInputElement {
86
- constructor(type) {
87
- super(type);
88
- this.addEvent('ElementMousemove', (evt) => {
89
- this.isMouseenter = true;
90
- this.refreshView();
91
- });
92
- this.addEvent('ElementMouseLeave', (evt) => {
93
- this.isMouseenter = false;
94
- this.refreshView();
95
- });
96
- this.addEvent('GotCursor', (evt) => { this.onGotCursorEvent(evt); });
97
- this.addEvent('ElementContextMenu', (evt) => {
98
- evt.menus.push({
99
- icon: 'Settings', caption: '内容控制设置', eventObj: {}
100
- });
101
- }, true);
102
- }
103
- onGotCursorEvent(evt) {
104
- const { source, selectionState } = evt;
105
- if (evt.ctx.viewOptions.docMode === DocMode.FormEdit) {
106
- //当前数据元不可编辑
107
- if (selectionState.editable && !this.props.editable) {
108
- const { startControl, startOffset } = selectionState;
109
- if (startControl === this.startDecorate && startOffset === 0 || startControl === this.endDecorate && startOffset === 1) {
110
- return;
111
- }
112
- selectionState.editable = false;
113
- const range = selectionState.range?.clone();
114
- if (range) {
115
- range.editable = false;
116
- selectionState.addRange(range);
117
- }
118
- return;
119
- }
120
- }
121
- if (source === this.endDecorate && selectionState.startOffset === 0 && this.length === 2) {
122
- evt.isCancel = true;
123
- selectionState.resetRange(this.startDecorate, 1);
124
- }
125
- }
126
- /**
127
- * 验证数据元的值是否合法
128
- * @returns
129
- */
130
- validate() {
131
- if (this.props.required && this.props.editable && !this.getValue()) {
132
- return '该字段不能为空';
133
- }
134
- return '';
135
- }
136
- }
137
- export class DataElementRenderObject extends InlineGroupRenderObject {
138
- beginRender(ctx, position) {
139
- ctx.contentContext.save();
140
- //绘制数据元区域底色
141
- if (this.element.isMouseenter) {
142
- const overlayColor = this.element.props.editable ? ctx.viewOptions.dataEleOverlaysColor : ctx.viewOptions.dataEleReadOnlyOverlayColor;
143
- ctx.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, overlayColor);
144
- }
145
- if (this.element.props.secretBrowse && ctx.viewOptions.secretBrowse) {
146
- ctx.contentContext.ctx.filter = "blur(10px)";
147
- }
148
- if (this.element.props.underline) {
149
- 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');
151
- }
152
- }
153
- endRender(ctx, position) {
154
- ctx.contentContext.restore();
155
- if (!this.element.props.printable && ctx.drawMode === 'print') {
156
- ctx.contentContext.clearRect(position.x, position.y, this.rect.width, this.rect.height);
157
- }
158
- }
159
- }
160
- export const validateDataEle = (ele) => {
161
- return ele instanceof DataElementLeaf || ele instanceof DataElementInlineGroup;
162
- };
163
- export const validateDataEleRenderObj = (renderObj) => {
164
- if (renderObj.element) {
165
- return validateDataEle(renderObj.element);
166
- }
167
- return false;
168
- };
169
- export const validateInlineInputRenderObj = (renderObj) => {
170
- if (renderObj.element) {
171
- return renderObj.element instanceof InlineGroupInputElement;
172
- }
173
- return false;
174
- };
175
- /**
176
- * 是否在数据元内部
177
- * @param control
178
- * @param offset
179
- */
180
- export function IsInSideDataElement(control, offset) {
181
- const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementInlineGroup);
182
- if (mathEle) {
183
- if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
184
- return false;
185
- }
186
- return true;
187
- }
188
- return false;
189
- }
190
- /**
191
- * 是否在内联块内部
192
- * @param control
193
- * @param offset
194
- */
195
- export function IsInSideInlineGroupInputElement(control, offset) {
196
- const mathEle = ElementUtil.getParent(control, (item) => item instanceof InlineGroupInputElement);
197
- if (mathEle) {
198
- if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
199
- return false;
200
- }
201
- return true;
202
- }
203
- return false;
204
- }
205
- //# sourceMappingURL=data-element-base-impl.js.map