@hailin-zheng/editor-core 2.1.19 → 2.1.20

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 (44) hide show
  1. package/index-cjs.js +273 -1077
  2. package/index-cjs.js.map +1 -1
  3. package/index.js +270 -1078
  4. package/index.js.map +1 -1
  5. package/med_editor/framework/document-paint.d.ts +0 -2
  6. package/med_editor/framework/element-define.d.ts +1 -1
  7. package/med_editor/framework/element-props.d.ts +8 -0
  8. package/med_editor/framework/impl/checkbox/checkbox-impl.d.ts +2 -3
  9. package/med_editor/framework/impl/comments/comment-content-impl.d.ts +1 -2
  10. package/med_editor/framework/impl/comments/comment-element-impl.d.ts +1 -2
  11. package/med_editor/framework/impl/comments/comments-container-impl.d.ts +2 -6
  12. package/med_editor/framework/impl/comments/validate-msg-impl.d.ts +1 -2
  13. package/med_editor/framework/impl/data-element/data-decorate-impl.d.ts +1 -2
  14. package/med_editor/framework/impl/data-element/data-element-barcode.d.ts +2 -5
  15. package/med_editor/framework/impl/data-element/data-element-base-impl.d.ts +0 -1
  16. package/med_editor/framework/impl/data-element/data-element-check-impl.d.ts +1 -2
  17. package/med_editor/framework/impl/data-element/data-element-group-impl.d.ts +1 -2
  18. package/med_editor/framework/impl/data-element/data-element-image-impl.d.ts +2 -5
  19. package/med_editor/framework/impl/decorate/fill-null-space-imple.d.ts +1 -2
  20. package/med_editor/framework/impl/document/doc-body-impl.d.ts +1 -2
  21. package/med_editor/framework/impl/document/doc-body-part-impl.d.ts +1 -2
  22. package/med_editor/framework/impl/document/doc-container-impl.d.ts +1 -2
  23. package/med_editor/framework/impl/document/doc-footer-impl.d.ts +1 -2
  24. package/med_editor/framework/impl/document/doc-header-impl.d.ts +1 -2
  25. package/med_editor/framework/impl/document/doc-impl.d.ts +1 -2
  26. package/med_editor/framework/impl/index.d.ts +1 -0
  27. package/med_editor/framework/impl/media-formula/menstrual-history.d.ts +1 -2
  28. package/med_editor/framework/impl/media-formula/permanent-teeth.d.ts +1 -2
  29. package/med_editor/framework/impl/paragraph/p-impl.d.ts +0 -2
  30. package/med_editor/framework/impl/picture/RectEle.d.ts +1 -6
  31. package/med_editor/framework/impl/picture/image-impl.d.ts +2 -5
  32. package/med_editor/framework/impl/radio/radio-impl.d.ts +1 -2
  33. package/med_editor/framework/impl/svg/svg-impl.d.ts +20 -0
  34. package/med_editor/framework/impl/symbol/br-symbol-impl.d.ts +1 -2
  35. package/med_editor/framework/impl/symbol/p-symbol-impl.d.ts +1 -2
  36. package/med_editor/framework/impl/symbol/page-br-symbol-impl.d.ts +1 -2
  37. package/med_editor/framework/impl/symbol/tab-symbol-impl.d.ts +1 -2
  38. package/med_editor/framework/impl/table/table-cell-impl.d.ts +1 -2
  39. package/med_editor/framework/impl/table/table-impl.d.ts +1 -2
  40. package/med_editor/framework/impl/table/table-row-impl.d.ts +1 -2
  41. package/med_editor/framework/impl/text/text-impl.d.ts +1 -2
  42. package/med_editor/framework/impl/text/track-run-impl.d.ts +1 -2
  43. package/med_editor/framework/render-define.d.ts +0 -2
  44. package/package.json +1 -1
package/index.js CHANGED
@@ -246,8 +246,6 @@ class RenderObject {
246
246
  this.margin = new MarginProps();
247
247
  this.padding = new PaddingProps();
248
248
  }
249
- pagePaintCompleted(e) {
250
- }
251
249
  destroy() {
252
250
  //this.parent = null;
253
251
  //this.margin = null;
@@ -2223,6 +2221,32 @@ class PictureProps extends INotifyPropertyChanged {
2223
2221
  return props;
2224
2222
  }
2225
2223
  }
2224
+ class SVGProps extends INotifyPropertyChanged {
2225
+ title;
2226
+ width = 5;
2227
+ height = 5;
2228
+ value;
2229
+ clone(dest) {
2230
+ const clone = dest ?? new SVGProps();
2231
+ super.cloneAttachedProperty(clone);
2232
+ clone.width = this.width;
2233
+ clone.height = this.height;
2234
+ clone.value = this.value;
2235
+ clone.title = this.title;
2236
+ return clone;
2237
+ }
2238
+ getSerializeProps(viewOptions) {
2239
+ const props = {
2240
+ width: this.width,
2241
+ height: this.height,
2242
+ value: this.value,
2243
+ };
2244
+ if (this.title) {
2245
+ props['title'] = this.title;
2246
+ }
2247
+ return props;
2248
+ }
2249
+ }
2226
2250
  class DataDecorateProps extends INotifyPropertyChanged {
2227
2251
  content;
2228
2252
  size;
@@ -2777,15 +2801,7 @@ class CommsContainerElement extends BlockContainerElement {
2777
2801
  class CommsContainerRenderObject extends BlockContainerRenderObject {
2778
2802
  //批注内容是否已经重组,只要重新绘制的时候组合一次即可
2779
2803
  isMeasureComm;
2780
- selectedSet;
2781
- commentRangeStatus = [];
2782
2804
  commsMarks = [];
2783
- render(e) {
2784
- if (this.rect.height === 0) {
2785
- return;
2786
- }
2787
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, 'black', 0.5);
2788
- }
2789
2805
  clone() {
2790
2806
  const clone = new CommsContainerRenderObject(this.element);
2791
2807
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -2866,9 +2882,6 @@ class DataDecorateElement extends LeafElement {
2866
2882
  }
2867
2883
  }
2868
2884
  class DataDecorateRenderObject extends LeafRenderObject {
2869
- render(e) {
2870
- this.renderDecorRect(e.render, e.position);
2871
- }
2872
2885
  renderDecorRect(ctx, position) {
2873
2886
  if (ctx.drawMode === 'print') {
2874
2887
  return;
@@ -3078,10 +3091,6 @@ class ParagraphElement extends BlockContentElement {
3078
3091
  }
3079
3092
  }
3080
3093
  class ParagraphRenderObject extends MuiltBlockLineRenderObject {
3081
- render(e) {
3082
- e.nextRender();
3083
- this.drawProjectNumber(e.render, e.docCtx.viewOptions, e);
3084
- }
3085
3094
  /**
3086
3095
  * 绘制项目符号
3087
3096
  */
@@ -3159,8 +3168,6 @@ class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {
3159
3168
  baseTopLine = 0;
3160
3169
  baseBottomLine = 0;
3161
3170
  startX = 0;
3162
- render(e) {
3163
- }
3164
3171
  clone() {
3165
3172
  const cloneRender = new ParagraphLineRectRenderObject(this.element);
3166
3173
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -3362,21 +3369,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3362
3369
  }
3363
3370
  headerLine;
3364
3371
  footerLine;
3365
- render(e) {
3366
- const { render, position, docCtx: { viewOptions } } = e;
3367
- const { width: docWidth, height: docHeight } = viewOptions.docPageSettings;
3368
- render.overlaysContext.fillRect(position.x, position.y, docWidth, this.rect.height, 'white', 5, 'black');
3369
- e.render.tran(() => {
3370
- e.render.contentContext.ctx.fillStyle = e.docCtx.viewOptions.defaultColor;
3371
- this.checkPrintMode(e);
3372
- e.nextRender();
3373
- this.drawCopyRight(viewOptions, render, position);
3374
- this.drawDocPageNum(render, viewOptions, position);
3375
- //绘制文档边距线
3376
- this.drawMarginLine(position, render, docWidth, docHeight);
3377
- this.drawWatermark(render, viewOptions, position);
3378
- });
3379
- }
3380
3372
  /**
3381
3373
  * 打印模式检查
3382
3374
  * 如果是续打模式,需要进行裁剪打印范围,页眉页脚都不需要打印
@@ -3812,45 +3804,6 @@ function getCurrOptions(ele) {
3812
3804
  return doc?.viewOptions;
3813
3805
  }
3814
3806
  class DataElementRenderObject extends InlineGroupRenderObject {
3815
- render(e) {
3816
- const { render, position, docCtx: { viewOptions } } = e;
3817
- this.paintPos = e.position;
3818
- //数据元不打印
3819
- if (!this.element.props.printable && render.drawMode === 'print') {
3820
- return;
3821
- }
3822
- render.contentContext.tran(() => {
3823
- //绘制数据元区域底色
3824
- let bgColor = '';
3825
- if (this.element.isMouseenter) {
3826
- bgColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3827
- }
3828
- if (this.element.isFocused) {
3829
- bgColor = e.docCtx.viewOptions.dataEleFocusedBgColor;
3830
- }
3831
- if (this.element.errorTip) {
3832
- bgColor = viewOptions.dataEleErrorBgColor;
3833
- }
3834
- if (bgColor) {
3835
- render.contentContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, bgColor);
3836
- }
3837
- if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
3838
- render.contentContext.ctx.filter = "blur(10px)";
3839
- }
3840
- if (this.element.props.underline) {
3841
- const y = position.y + 2 + this.rect.height;
3842
- render.contentContext.strokeLines([{ x: position.x, y }, {
3843
- x: position.x + this.rect.width,
3844
- y
3845
- }], 1, '#595959');
3846
- }
3847
- e.nextRender();
3848
- this.drawCaption(e);
3849
- });
3850
- e.render.onRenderCompleted.subscribe(() => {
3851
- drawDecorator(e, this);
3852
- });
3853
- }
3854
3807
  exportHTML(event) {
3855
3808
  const node = super.exportHTML(event);
3856
3809
  exportDecoratorHTML(event, this);
@@ -4136,15 +4089,6 @@ class DocumentBodyElement extends BlockContainerElement {
4136
4089
  }
4137
4090
  }
4138
4091
  class DocumentBodyRenderObject extends MuiltBlockLineRenderObject {
4139
- render(e) {
4140
- const { render, position } = e;
4141
- render.tran(() => {
4142
- if (this.element.disableClick && render.drawMode === 'view') {
4143
- render.contentContext.setGlobalAlpha(0.5);
4144
- }
4145
- e.nextRender();
4146
- });
4147
- }
4148
4092
  clone(cloneData = true) {
4149
4093
  const cloneRender = new DocumentBodyRenderObject(this.element);
4150
4094
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4214,22 +4158,6 @@ class DocumentFooterElement extends BlockContainerElement {
4214
4158
  }
4215
4159
  }
4216
4160
  class DocumentFooterRenderObject extends BlockContainerRenderObject {
4217
- render(e) {
4218
- const { render, position } = e;
4219
- render.tran(() => {
4220
- //判断页眉是否为输入内容
4221
- const isFooterEmpty = ElementUtil.checkEmptyRenderContent(this);
4222
- if (this.element.disableClick && render.drawMode === 'view') {
4223
- if (isFooterEmpty) {
4224
- render.contentContext.setGlobalAlpha(0);
4225
- }
4226
- else {
4227
- render.contentContext.setGlobalAlpha(0.5);
4228
- }
4229
- }
4230
- e.nextRender();
4231
- });
4232
- }
4233
4161
  clone() {
4234
4162
  const cloneRender = new DocumentFooterRenderObject(this.element);
4235
4163
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4310,27 +4238,6 @@ class DocumentHeaderElement extends BlockContainerElement {
4310
4238
  }
4311
4239
  }
4312
4240
  class DocumentHeaderRenderObject extends BlockContainerRenderObject {
4313
- render(e) {
4314
- const { render, position } = e;
4315
- render.tran(() => {
4316
- //判断页眉是否为输入内容
4317
- const isHeaderEmpty = ElementUtil.checkEmptyRenderContent(this);
4318
- //存在输入内容时,绘制页眉-页体分割线
4319
- if (!isHeaderEmpty || !this.element.disableClick) {
4320
- const headerLineY = this.rect.height;
4321
- render.contentContext.drawHoriLine(position.x, position.y + headerLineY, this.rect.width, 'black', 0.5);
4322
- }
4323
- if (this.element.disableClick && render.drawMode === 'view') {
4324
- if (isHeaderEmpty) {
4325
- render.contentContext.setGlobalAlpha(0);
4326
- }
4327
- else {
4328
- render.contentContext.setGlobalAlpha(0.5);
4329
- }
4330
- }
4331
- e.nextRender();
4332
- });
4333
- }
4334
4241
  clone() {
4335
4242
  const cloneRender = new DocumentHeaderRenderObject(this.element);
4336
4243
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4410,13 +4317,6 @@ class PSymbolElement extends LeafElement {
4410
4317
  }
4411
4318
  }
4412
4319
  class PSymbolRenderObject extends LeafRenderObject {
4413
- render(e) {
4414
- const { render, position } = e;
4415
- if (render.drawMode === 'print' || !e.docCtx.viewOptions.showParaSymbol) {
4416
- return;
4417
- }
4418
- render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
4419
- }
4420
4320
  exportHTML(event) {
4421
4321
  if (!event.options.showEnterSymbol || event.mode === 'print') {
4422
4322
  return null;
@@ -4529,22 +4429,6 @@ class TableCellElement extends BlockContainerElement {
4529
4429
  }
4530
4430
  }
4531
4431
  class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
4532
- render(e) {
4533
- const { render, position } = e;
4534
- render.tran(() => {
4535
- render.contentContext.clip(position.x, position.y, this.rect.width, this.rect.height);
4536
- const { hMerge, vMerge, backgroundColor, diagonal } = this.element.props;
4537
- if (hMerge === 'continue' || vMerge === 'continue') {
4538
- render.contentContext.setGlobalAlpha(0);
4539
- render.overlaysContext.setGlobalAlpha(0);
4540
- }
4541
- if (backgroundColor && this.rect.width && this.rect.height) {
4542
- render.contentContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, backgroundColor);
4543
- }
4544
- this.renderDiagonal(render, diagonal, position);
4545
- e.nextRender();
4546
- });
4547
- }
4548
4432
  /**
4549
4433
  * 绘制对角线
4550
4434
  * @private
@@ -4713,8 +4597,6 @@ class TableRowRenderObject extends MuiltBlockLineRenderObject {
4713
4597
  remeasureState = true;
4714
4598
  //当前行是否存在合并单元格
4715
4599
  hasMergeCells = undefined;
4716
- render(e) {
4717
- }
4718
4600
  clone() {
4719
4601
  const cloneRender = new TableRowRenderObject(this.element);
4720
4602
  cloneRender.remeasureState = this.remeasureState;
@@ -4743,17 +4625,6 @@ class DocumentContainerRender extends BlockContainerRenderObject {
4743
4625
  constructor() {
4744
4626
  super(null);
4745
4627
  }
4746
- render(e) {
4747
- const { render, nextRender, docCtx: { viewOptions } } = e;
4748
- const { viewSettings, docPageSettings, viewBackcolor, scale } = viewOptions;
4749
- render.clear();
4750
- //render.overlaysContext.fillRect(0, 0, viewSettings.width, viewSettings.height, viewBackcolor);
4751
- render.tran(() => {
4752
- render.overlaysContext.ctx.scale(scale, scale);
4753
- render.contentContext.ctx.scale(scale, scale);
4754
- nextRender();
4755
- });
4756
- }
4757
4628
  clone() {
4758
4629
  throw new Error("Method not implemented.");
4759
4630
  }
@@ -4870,17 +4741,6 @@ class TextGroupElement extends LeafElement {
4870
4741
  }
4871
4742
  class TextGroupRenderObject extends LeafRenderObject {
4872
4743
  textMeasures;
4873
- render(e) {
4874
- const { render, position } = e;
4875
- //null-text不打印
4876
- if (render.drawMode === 'print' && this.element.isDecorate) {
4877
- return;
4878
- }
4879
- if (this.element.props.border) {
4880
- render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
4881
- }
4882
- render.contentContext.drawTextUnits(this, position.x, position.y + (this.rect.height - this.element.props.fontSize) / 2);
4883
- }
4884
4744
  constructor(element) {
4885
4745
  super(element);
4886
4746
  }
@@ -6596,56 +6456,6 @@ class TableRenderObject extends MuiltBlockLineRenderObject {
6596
6456
  setRenderWidth(maxWidth) {
6597
6457
  super.setRenderWidth(maxWidth);
6598
6458
  }
6599
- render(e) {
6600
- const { render, position } = e;
6601
- //绘制表格线
6602
- const border = this.element.props.border;
6603
- if (border === 'none') {
6604
- return;
6605
- }
6606
- const lineDash = border === 'dashed' ? [2, 2] : [];
6607
- for (let i = 0; i < this.length; i++) {
6608
- const rowRender = this.getChild(i);
6609
- const rowPos = { x: rowRender.rect.x + position.x, y: rowRender.rect.y + position.y };
6610
- for (let j = 0; j < rowRender.length; j++) {
6611
- const cellRender = rowRender.getChild(j);
6612
- const cellPos = { x: cellRender.rect.x + rowPos.x, y: cellRender.rect.y + rowPos.y };
6613
- //绘制单元格上边框
6614
- if (i === 0) {
6615
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, cellRender.rect.width, 1);
6616
- render.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, {
6617
- x: cellPos.x + cellRender.rect.width,
6618
- y: cellPos.y
6619
- }], 1, '#000', lineDash);
6620
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y });
6621
- }
6622
- //绘制左边框
6623
- if (j === 0) {
6624
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, 1, cellRender.rect.height);
6625
- render.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, {
6626
- x: cellPos.x,
6627
- y: cellPos.y + cellRender.rect.height
6628
- }], 1, '#000', lineDash);
6629
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x, y: cellPos.y + cellRender.rect.height });
6630
- }
6631
- //绘制右边框
6632
- //ctx.contentContext.fillRect(cellPos.x + cellRender.rect.width, cellPos.y, 1, cellRender.rect.height);
6633
- render.contentContext.fillLines([{
6634
- x: cellPos.x + cellRender.rect.width,
6635
- y: cellPos.y
6636
- }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }], 1, '#000', lineDash);
6637
- //this.drawLine(ctx, { x: cellPos.x + cellRender.rect.width, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
6638
- //绘制下边框
6639
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y + cellRender.rect.height, cellRender.rect.width, 1);
6640
- render.contentContext.fillLines([{
6641
- x: cellPos.x,
6642
- y: cellPos.y + cellRender.rect.height
6643
- }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }], 1, '#000', lineDash);
6644
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y + cellRender.rect.height }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
6645
- //cellRender.beginRender(ctx, { x: position.x + cellRender.offsetX, y: position.y + cellRender.offsetY });
6646
- }
6647
- }
6648
- }
6649
6459
  exportTableBorder() {
6650
6460
  //绘制表格线
6651
6461
  const border = this.element.props.border;
@@ -6930,10 +6740,7 @@ class CheckBoxFactory extends ElementFactory {
6930
6740
  }
6931
6741
  }
6932
6742
  class CheckBoxRenderObject extends LeafRenderObject {
6933
- render(e) {
6934
- e.render.contentContext.drawCheckBox(e.position.x + 2, e.position.y, this.element.props.size, this.element.props.size, this.element.props.isChecked);
6935
- }
6936
- clone(cloneData = true) {
6743
+ clone() {
6937
6744
  const clone = new CheckBoxRenderObject(this.element);
6938
6745
  clone.rect = ElementUtil.cloneRect(this.rect);
6939
6746
  return clone;
@@ -7032,34 +6839,6 @@ class CommContentElement extends CommContentBaseElement {
7032
6839
  }
7033
6840
  }
7034
6841
  class CommContentRenderObject extends CommContentBaseRenderObject {
7035
- render(e) {
7036
- let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';
7037
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, borderColor);
7038
- e.render.contentContext.fillRect(e.position.x, e.position.y, 8, this.rect.height, '#871400');
7039
- const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject);
7040
- //获取审阅标记的绘制坐标
7041
- let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, {
7042
- x: 0,
7043
- y: -e.docCtx.viewOptions.pageOffset.y
7044
- });
7045
- const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
7046
- commMarkPos.y = commMarkLinePos.y + 2;
7047
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, {
7048
- x: 0,
7049
- y: -e.docCtx.viewOptions.pageOffset.y
7050
- });
7051
- const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
7052
- const marginRight = e.docCtx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
7053
- e.render.overlaysContext.drawDashLine([commMarkPos, {
7054
- x: commMarkPos.x + marginRight,
7055
- y: commMarkPos.y
7056
- }], [1, 1], 'red');
7057
- e.render.overlaysContext.drawDashLine([{
7058
- x: commMarkPos.x + marginRight,
7059
- y: commMarkPos.y
7060
- }, e.position], [1, 1], 'red');
7061
- this.renderTitle(e.render, e.position);
7062
- }
7063
6842
  exportHTML(event) {
7064
6843
  const t = super.exportHTML(event);
7065
6844
  t.children = [];
@@ -7330,16 +7109,6 @@ class CommentElement extends LeafElement {
7330
7109
  }
7331
7110
  }
7332
7111
  class CommentRenderObject extends LeafRenderObject {
7333
- //renderPos!: Position;
7334
- render(e) {
7335
- // if (!e.docCtx.viewOptions.showReviewWindow) {
7336
- // return;
7337
- // }
7338
- // this.renderPos = e.position;
7339
- // const paraLinePos = ElementUtil.getParaLinePos(this, {x: e.position.x, y: e.position.y});
7340
- // const color = '#ff4d4f';
7341
- // e.render.contentContext.fillRect(e.position.x - 1, paraLinePos.y, 2, paraLinePos.height, color)
7342
- }
7343
7112
  exportHTML(event) {
7344
7113
  const renderPos = { ...event.relativePagePos };
7345
7114
  const paraLinePos = ElementUtil.getParaLinePos(this, { x: renderPos.x, y: renderPos.y });
@@ -7505,31 +7274,6 @@ class ValidateElement extends CommContentBaseElement {
7505
7274
  }
7506
7275
  }
7507
7276
  class ValidateRenderObject extends CommContentBaseRenderObject {
7508
- render(e) {
7509
- let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';
7510
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, borderColor);
7511
- e.render.contentContext.fillRect(e.position.x, e.position.y, 8, this.rect.height, '#871400');
7512
- const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject);
7513
- //获取审阅标记的绘制坐标
7514
- let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, {
7515
- x: 0,
7516
- y: -e.docCtx.viewOptions.pageOffset.y
7517
- });
7518
- const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
7519
- commMarkPos.y = commMarkLinePos.y + 2;
7520
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, { x: 0, y: -e.docCtx.viewOptions.pageOffset.y });
7521
- const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
7522
- const marginRight = e.docCtx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
7523
- e.render.overlaysContext.drawDashLine([commMarkPos, {
7524
- x: commMarkPos.x + marginRight,
7525
- y: commMarkPos.y
7526
- }], [1, 1], 'red');
7527
- e.render.overlaysContext.drawDashLine([{
7528
- x: commMarkPos.x + marginRight,
7529
- y: commMarkPos.y
7530
- }, e.position], [1, 1], 'red');
7531
- this.renderTitle(e.render, e.position);
7532
- }
7533
7277
  renderTitle(ctx, position) {
7534
7278
  const topPadding = 24;
7535
7279
  const textProps = new TextProps();
@@ -8455,40 +8199,11 @@ class DataElementBarcode extends DataElementLeaf {
8455
8199
  }
8456
8200
  }
8457
8201
  class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
8458
- render(e) {
8459
- // const barcodeEle = this.element as DataElementBarcode;
8460
- // barcodeEle.drawBarcode(e.render, e.position);
8461
- }
8462
8202
  clone() {
8463
8203
  const clone = new DataElementBarcodeRenderObject(this.element);
8464
8204
  clone.rect = ElementUtil.cloneRect(this.rect);
8465
8205
  return clone;
8466
8206
  }
8467
- pagePaintCompleted(e) {
8468
- if (this.element.isFocused) {
8469
- const { render, position: pos } = e;
8470
- const { width, height } = this.rect;
8471
- render.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
8472
- this.drawResizeCircle(render, pos.x, pos.y);
8473
- this.drawResizeCircle(render, pos.x + width, pos.y);
8474
- this.drawResizeCircle(render, pos.x, pos.y + height);
8475
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
8476
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
8477
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
8478
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
8479
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
8480
- }
8481
- }
8482
- drawResizeCircle(ctx, x, y) {
8483
- const ctxNative = ctx.contentContext.ctx;
8484
- ctxNative.save();
8485
- ctxNative.fillStyle = '#69c0ff';
8486
- ctxNative.beginPath();
8487
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
8488
- ctxNative.closePath();
8489
- ctxNative.fill();
8490
- ctxNative.restore();
8491
- }
8492
8207
  exportHTML(event) {
8493
8208
  const t = super.exportHTML(event);
8494
8209
  if (this.element.props.type === 'qrcode') {
@@ -8653,27 +8368,6 @@ class DataElementCheckRenderObject extends LeafRenderObject {
8653
8368
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
8654
8369
  return cloneRender;
8655
8370
  }
8656
- render(e) {
8657
- const { render, position } = e;
8658
- const element = this.element;
8659
- if (element.props.drawStateChar) {
8660
- const font = `${element.props.size - 2}px 微软雅黑`;
8661
- const str = element.props.checked ? element.props.trueChar : element.props.falseChar;
8662
- const color = element.props.checked ? element.props.trueStateColor : element.props.falseStateColor;
8663
- e.render.contentContext.drawText2(str, font, color, position.x, position.y, element.props.size, element.props.size);
8664
- if (element.props.border) {
8665
- e.render.contentContext.strokeRect(position.x + 2, position.y, element.props.size, element.props.size);
8666
- }
8667
- }
8668
- else {
8669
- if (element.props.multiSelect) {
8670
- render.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8671
- }
8672
- else {
8673
- render.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8674
- }
8675
- }
8676
- }
8677
8371
  exportHTML(event) {
8678
8372
  const t = super.exportHTML(event);
8679
8373
  const props = this.element.props;
@@ -8964,12 +8658,6 @@ class DataElementGroupElement extends InlineGroupInputElement {
8964
8658
  }
8965
8659
  }
8966
8660
  class DataElementGroupRenderObject extends InlineGroupRenderObject {
8967
- render(e) {
8968
- this.paintPos = e.position;
8969
- e.render.onRenderCompleted.subscribe(() => {
8970
- drawDecorator(e, this);
8971
- });
8972
- }
8973
8661
  clone() {
8974
8662
  const cloneRender = new DataElementGroupRenderObject(this.element);
8975
8663
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -9037,38 +8725,11 @@ class DataElementImage extends DataElementLeaf {
9037
8725
  }
9038
8726
  }
9039
8727
  class DataImageRenderObject extends ResizeLeafRenderObject {
9040
- render(e) {
9041
- }
9042
8728
  clone() {
9043
8729
  const clone = new DataImageRenderObject(this.element);
9044
8730
  clone.rect = ElementUtil.cloneRect(this.rect);
9045
8731
  return clone;
9046
8732
  }
9047
- pagePaintCompleted(e) {
9048
- if (this.element.isFocused) {
9049
- const { render, position: pos } = e;
9050
- const { width, height } = this.rect;
9051
- render.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
9052
- this.drawResizeCircle(render, pos.x, pos.y);
9053
- this.drawResizeCircle(render, pos.x + width, pos.y);
9054
- this.drawResizeCircle(render, pos.x, pos.y + height);
9055
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
9056
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
9057
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
9058
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
9059
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
9060
- }
9061
- }
9062
- drawResizeCircle(ctx, x, y) {
9063
- const ctxNative = ctx.contentContext.ctx;
9064
- ctxNative.save();
9065
- ctxNative.fillStyle = '#69c0ff';
9066
- ctxNative.beginPath();
9067
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
9068
- ctxNative.closePath();
9069
- ctxNative.fill();
9070
- ctxNative.restore();
9071
- }
9072
8733
  exportHTML(event) {
9073
8734
  const t = super.exportHTML(event);
9074
8735
  t.children = [{
@@ -9304,13 +8965,6 @@ class BreakElement extends LeafElement {
9304
8965
  }
9305
8966
  }
9306
8967
  class BreakRenderObject extends LeafRenderObject {
9307
- render(e) {
9308
- const { render, position } = e;
9309
- if (render.drawMode === 'print') {
9310
- return;
9311
- }
9312
- render.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);
9313
- }
9314
8968
  exportHTML(event) {
9315
8969
  if (!event.options.showEnterSymbol || event.mode === 'print') {
9316
8970
  return null;
@@ -9476,8 +9130,6 @@ class FillNullSpaceRenderObject extends LeafRenderObject {
9476
9130
  super(null);
9477
9131
  this.disableClick = true;
9478
9132
  }
9479
- render(e) {
9480
- }
9481
9133
  clone() {
9482
9134
  const clone = new FillNullSpaceRenderObject();
9483
9135
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -9538,11 +9190,6 @@ class DocumentBodyPartElement extends BlockContainerElement {
9538
9190
  }
9539
9191
  }
9540
9192
  class DocumentBodyPartRenderObject extends MuiltBlockLineRenderObject {
9541
- render(e) {
9542
- const { render, position } = e;
9543
- const bgColor = (this.element.isFocused || this.element.isMouseenter) ? '#d9d9d9' : '#ffffff';
9544
- render.overlaysContext.fillRect(position.x - 2, position.y - 2, this.rect.width + 4, this.rect.height + 4, bgColor, 5, 'black');
9545
- }
9546
9193
  clone(cloneData = true) {
9547
9194
  const cloneRender = new DocumentBodyPartRenderObject(this.element);
9548
9195
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -9682,9 +9329,6 @@ function getMHItem(kind) {
9682
9329
  return mhLayoutItems[kindIndex];
9683
9330
  }
9684
9331
  class DataRenderMH extends LeafRenderObject {
9685
- render(e) {
9686
- renderMH(this.element, e.render, e.position, true);
9687
- }
9688
9332
  exportHTML(event) {
9689
9333
  const t = super.exportHTML(event);
9690
9334
  const children = [];
@@ -9919,36 +9563,11 @@ class PictureElement extends LeafElement {
9919
9563
  }
9920
9564
  }
9921
9565
  class PictureRenderObject extends ResizeLeafRenderObject {
9922
- render(e) {
9923
- }
9924
9566
  clone() {
9925
9567
  const clone = new PictureRenderObject(this.element);
9926
9568
  clone.rect = ElementUtil.cloneRect(this.rect);
9927
9569
  return clone;
9928
9570
  }
9929
- pagePaintCompleted(e) {
9930
- if (this.element.isFocused) {
9931
- const { render, position: pos } = e;
9932
- const { width, height } = this.rect;
9933
- render.contentContext.strokeRect(pos.x, pos.y, width, height, '#1890ff', 0.5);
9934
- this.drawResizeCircle(render, pos.x, pos.y);
9935
- this.drawResizeCircle(render, pos.x + width, pos.y);
9936
- this.drawResizeCircle(render, pos.x, pos.y + height);
9937
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
9938
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
9939
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
9940
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
9941
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
9942
- }
9943
- }
9944
- drawResizeCircle(ctx, x, y) {
9945
- const ctxNative = ctx.contentContext.ctx;
9946
- ctxNative.fillStyle = '#69c0ff';
9947
- ctxNative.beginPath();
9948
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
9949
- ctxNative.closePath();
9950
- ctxNative.fill();
9951
- }
9952
9571
  exportHTML(event) {
9953
9572
  const picElement = this.element;
9954
9573
  const picProps = picElement.props;
@@ -10080,10 +9699,6 @@ class RadioBoxFactory extends ElementFactory {
10080
9699
  }
10081
9700
  }
10082
9701
  class RadioBoxRenderObject extends LeafRenderObject {
10083
- render(e) {
10084
- const { render, position } = e;
10085
- render.contentContext.drawRadioBox(position.x + 2, position.y, this.element.props.size, this.element.props.size, this.element.props.isChecked);
10086
- }
10087
9702
  clone(cloneData = true) {
10088
9703
  const clone = new RadioBoxRenderObject(this.element);
10089
9704
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -10122,13 +9737,6 @@ class PageBreakElement extends LeafElement {
10122
9737
  }
10123
9738
  }
10124
9739
  class PageBreakRenderObject extends LeafRenderObject {
10125
- render(e) {
10126
- const { render, position } = e;
10127
- if (render.drawMode === 'print') {
10128
- return;
10129
- }
10130
- render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
10131
- }
10132
9740
  clone() {
10133
9741
  const render = new PageBreakRenderObject(this.element);
10134
9742
  render.rect = ElementUtil.cloneRect(this.rect);
@@ -10165,13 +9773,6 @@ class TabElement extends LeafElement {
10165
9773
  }
10166
9774
  }
10167
9775
  class TabRenderObject extends LeafRenderObject {
10168
- render(e) {
10169
- const { render, position } = e;
10170
- if (render.drawMode === 'print') {
10171
- return;
10172
- }
10173
- //render.contentContext.fillRect(position.x,position.y,this.rect.width,this.rect.height,'red');
10174
- }
10175
9776
  clone() {
10176
9777
  const render = new TabRenderObject(this.element);
10177
9778
  render.rect = ElementUtil.cloneRect(this.rect);
@@ -10737,58 +10338,170 @@ class TableSplitCell {
10737
10338
  }
10738
10339
  }
10739
10340
 
10740
- class ElementSerialize {
10741
- /**
10742
- * 将当前文档对象构建并输出到标准的JSON对象
10743
- * @param element
10744
- * @param viewOptions
10745
- */
10746
- static serialize(element, viewOptions) {
10747
- const result = element.serialize(viewOptions);
10748
- if (!result) {
10749
- return null;
10750
- }
10751
- if (result.complete) {
10752
- return result;
10753
- }
10754
- if (element instanceof BranchElement) {
10755
- result.children = [];
10756
- let prevEle = null;
10757
- for (let i = 0; i < element.length; i++) {
10758
- const child = element.getChild(i);
10759
- const serializeChild = this.serialize(child, viewOptions);
10760
- if (child.type === 'text' && prevEle && prevEle.ele.type === 'text') {
10761
- if (child.props.equals(prevEle.ele.props)) {
10762
- prevEle.props.content += serializeChild.content;
10763
- continue;
10764
- }
10765
- }
10766
- if (serializeChild) {
10767
- delete serializeChild.complete;
10768
- serializeChild.props = serializeChild.props || {};
10769
- if (Object.keys(serializeChild.props).length === 0) {
10770
- delete serializeChild.props;
10771
- }
10772
- if (serializeChild.children && serializeChild.children.length === 0) {
10773
- delete serializeChild.children;
10774
- }
10775
- result.children.push(serializeChild);
10776
- prevEle = { ele: child, props: serializeChild };
10777
- }
10778
- }
10779
- }
10780
- if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
10781
- result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
10782
- }
10783
- return result;
10341
+ class SVGElement extends LeafElement {
10342
+ resizeable = true;
10343
+ constructor() {
10344
+ super('svg');
10345
+ this.props = new SVGProps();
10346
+ //this.addPropValueChangedSub(this.props);
10347
+ this.cursorType = 'move';
10348
+ this.focusable = true;
10784
10349
  }
10785
- static serializeString(element, options = { all: false }) {
10786
- if (!options.all && element instanceof TrackRunElement && element.type === TrackRunTypeEnum.Deleted) {
10787
- return '';
10788
- }
10789
- if (element instanceof TextGroupElement && !element.isDecorate) {
10350
+ createRenderObject() {
10351
+ const render = new SVGRenderObject(this);
10352
+ render.rect.width = this.props.width;
10353
+ render.rect.height = this.props.height;
10354
+ return render;
10355
+ }
10356
+ serialize(options) {
10357
+ return {
10358
+ type: 'svg',
10359
+ props: {
10360
+ ...this.props.getSerializeProps(options)
10361
+ }
10362
+ };
10363
+ }
10364
+ clone(data) {
10365
+ const clone = new SVGElement();
10366
+ this.props.clone(clone.props);
10367
+ return clone;
10368
+ }
10369
+ destroy() {
10370
+ super.destroy();
10371
+ }
10372
+ }
10373
+ class SVGRenderObject extends ResizeLeafRenderObject {
10374
+ clone() {
10375
+ const clone = new SVGRenderObject(this.element);
10376
+ clone.rect = ElementUtil.cloneRect(this.rect);
10377
+ return clone;
10378
+ }
10379
+ drawResizeCircle(ctx, x, y) {
10380
+ const ctxNative = ctx.contentContext.ctx;
10381
+ ctxNative.fillStyle = '#69c0ff';
10382
+ ctxNative.beginPath();
10383
+ ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
10384
+ ctxNative.closePath();
10385
+ ctxNative.fill();
10386
+ }
10387
+ exportHTML(event) {
10388
+ const props = this.element.props;
10389
+ const t = super.exportHTML(event);
10390
+ t.children = [{
10391
+ sel: 'svg',
10392
+ data: {
10393
+ ns: "http://www.w3.org/2000/svg",
10394
+ attrs: {
10395
+ width: this.rect.width,
10396
+ height: this.rect.height
10397
+ }
10398
+ },
10399
+ children: [{
10400
+ sel: 'image',
10401
+ data: {
10402
+ ns: "http://www.w3.org/2000/svg",
10403
+ attrs: {
10404
+ "xlink:href": props.value,
10405
+ width: Math.min(this.rect.width, this.rect.height),
10406
+ height: Math.min(this.rect.width, this.rect.height)
10407
+ }
10408
+ }
10409
+ }]
10410
+ }];
10411
+ //绘制拖动圆圈
10412
+ if (this.element.isFocused) {
10413
+ const { width, height } = this.rect;
10414
+ const circlePoints = [{ x: 0, y: 0 }, { x: width, y: 0 }, { x: 0, y: height }, { x: width, y: height }, { x: Math.floor(width / 2), y: 0 }, { x: Math.floor(width / 2), y: height }, { x: 0, y: Math.floor(height / 2) }, { x: width, y: Math.floor(height / 2) }];
10415
+ circlePoints.forEach((p) => {
10416
+ t.children.push({
10417
+ sel: 'circle',
10418
+ data: {
10419
+ ns: "http://www.w3.org/2000/svg",
10420
+ attrs: {
10421
+ cx: p.x,
10422
+ cy: p.y,
10423
+ r: Math.floor(4 / 5 * 4),
10424
+ fill: '#69c0ff'
10425
+ }
10426
+ }
10427
+ });
10428
+ });
10429
+ }
10430
+ return t;
10431
+ }
10432
+ }
10433
+ class SVGFactory extends ElementFactory {
10434
+ match(type) {
10435
+ return type === 'svg';
10436
+ }
10437
+ createElement(data) {
10438
+ const props = data.props;
10439
+ const pic = new SVGElement();
10440
+ const picProps = pic.props;
10441
+ picProps.width = props.width;
10442
+ picProps.height = props.height;
10443
+ picProps.value = props.value;
10444
+ picProps.title = props.title;
10445
+ pic.props = picProps;
10446
+ return pic;
10447
+ }
10448
+ }
10449
+
10450
+ class ElementSerialize {
10451
+ /**
10452
+ * 将当前文档对象构建并输出到标准的JSON对象
10453
+ * @param element
10454
+ * @param viewOptions
10455
+ */
10456
+ static serialize(element, viewOptions) {
10457
+ const result = element.serialize(viewOptions);
10458
+ if (!result) {
10459
+ return null;
10460
+ }
10461
+ if (result.complete) {
10462
+ return result;
10463
+ }
10464
+ if (element instanceof BranchElement) {
10465
+ result.children = [];
10466
+ let prevEle = null;
10467
+ for (let i = 0; i < element.length; i++) {
10468
+ const child = element.getChild(i);
10469
+ const serializeChild = this.serialize(child, viewOptions);
10470
+ if (child.type === 'text' && prevEle && prevEle.ele.type === 'text') {
10471
+ if (child.props.equals(prevEle.ele.props)) {
10472
+ prevEle.props.content += serializeChild.content;
10473
+ continue;
10474
+ }
10475
+ }
10476
+ if (serializeChild) {
10477
+ delete serializeChild.complete;
10478
+ serializeChild.props = serializeChild.props || {};
10479
+ if (Object.keys(serializeChild.props).length === 0) {
10480
+ delete serializeChild.props;
10481
+ }
10482
+ if (serializeChild.children && serializeChild.children.length === 0) {
10483
+ delete serializeChild.children;
10484
+ }
10485
+ result.children.push(serializeChild);
10486
+ prevEle = { ele: child, props: serializeChild };
10487
+ }
10488
+ }
10489
+ }
10490
+ if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
10491
+ result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
10492
+ }
10493
+ return result;
10494
+ }
10495
+ static serializeString(element, options = { all: false }) {
10496
+ if (!options.all && element instanceof TrackRunElement && element.type === TrackRunTypeEnum.Deleted) {
10497
+ return '';
10498
+ }
10499
+ if (element instanceof TextGroupElement && !element.isDecorate) {
10790
10500
  return element.text;
10791
10501
  }
10502
+ if (element instanceof PSymbolElement) {
10503
+ return '\n';
10504
+ }
10792
10505
  if (element instanceof BranchElement) {
10793
10506
  const items = [];
10794
10507
  for (let i = 0; i < element.length; i++) {
@@ -10939,32 +10652,6 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10939
10652
  constructor(ele) {
10940
10653
  super(ele);
10941
10654
  }
10942
- render(e) {
10943
- const { render, position, docCtx: { viewOptions } } = e;
10944
- render.tran(() => {
10945
- let fillColor = viewOptions.showTrackChanges ? this.element.type === 'ins-run' ? viewOptions.trackInsColor : viewOptions.trackDelColor : '';
10946
- if (fillColor) {
10947
- render.contentContext.ctx.fillStyle = fillColor;
10948
- }
10949
- e.nextRender();
10950
- });
10951
- const { x, y } = position;
10952
- //不显示痕迹
10953
- if (!viewOptions.showTrackChanges) {
10954
- return;
10955
- }
10956
- const color = this.element.type === 'ins-run' ? 'green' : 'red';
10957
- for (let i = 0; i < this.length; i++) {
10958
- const childRender = this.getChild(i);
10959
- const { rect } = childRender;
10960
- if (childRender.element && childRender.element.type === 'del-run') {
10961
- continue;
10962
- }
10963
- let lineY = y + rect.y + rect.height;
10964
- lineY = this.element.type === 'ins-run' ? lineY : lineY - rect.height / 2;
10965
- render.contentContext.drawHoriLine(x + rect.x, lineY, rect.width, color, 1);
10966
- }
10967
- }
10968
10655
  exportHTML(event) {
10969
10656
  const { options } = event;
10970
10657
  const t = super.exportHTML(event);
@@ -12527,9 +12214,9 @@ class ElementUtil {
12527
12214
  return this.getTextRenderOffset(render, x);
12528
12215
  }
12529
12216
  else {
12530
- if (render.element && render.element.type === 'psym') {
12531
- return 0;
12532
- }
12217
+ // if (render.element && render.element.type === 'psym') {
12218
+ // return 0;
12219
+ // }
12533
12220
  return (render.rect.width / 2) >= x ? 0 : 1;
12534
12221
  }
12535
12222
  }
@@ -13259,12 +12946,12 @@ class ElementPaint {
13259
12946
  }
13260
12947
  }
13261
12948
  });
13262
- docContainer.render({
13263
- render: this.renderCtx,
13264
- position: { x: docContainer.rect.x, y: docContainer.rect.y },
13265
- nextRender: nextRenderFn,
13266
- docCtx: this.docCtx
13267
- });
12949
+ // docContainer.render({
12950
+ // render: this.renderCtx,
12951
+ // position: { x: docContainer.rect.x, y: docContainer.rect.y },
12952
+ // nextRender: nextRenderFn,
12953
+ // docCtx: this.docCtx
12954
+ // })
13268
12955
  nextRenderFn();
13269
12956
  const { scale, viewSettings: { width, height } } = this.viewOptions;
13270
12957
  while (this.renderCtx.onRenderCompleted.subs.length > 0) {
@@ -13293,25 +12980,25 @@ class ElementPaint {
13293
12980
  this.drawRenderObject(child, currPosition, inViewPort);
13294
12981
  }
13295
12982
  });
13296
- const renderData = {
12983
+ ({
13297
12984
  position: currPosition,
13298
12985
  nextRender: nextRenderFn,
13299
12986
  render: this.renderCtx,
13300
12987
  docCtx: this.docCtx
13301
- };
13302
- renderObject.render(renderData);
12988
+ });
12989
+ //renderObject.render(renderData);
13303
12990
  nextRenderFn();
13304
12991
  }
13305
12992
  }
13306
12993
  else if (renderObject instanceof LeafRenderObject) {
13307
12994
  if (inViewPort) {
13308
- const renderData = {
12995
+ ({
13309
12996
  position: currPosition,
13310
12997
  nextRender: () => { },
13311
12998
  render: this.renderCtx,
13312
12999
  docCtx: this.docCtx
13313
- };
13314
- renderObject.render(renderData);
13000
+ });
13001
+ //renderObject.render(renderData);
13315
13002
  }
13316
13003
  }
13317
13004
  //处理选中拖蓝
@@ -13364,14 +13051,14 @@ class ElementPaint {
13364
13051
  * 触发页面绘制结束事件
13365
13052
  */
13366
13053
  invokedPagePaintCompleted(renderObject, parent) {
13367
- const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
13368
- const currPosition = { x: rx + parent.x, y: ry + parent.y };
13369
- renderObject.pagePaintCompleted({ render: this.renderCtx, position: currPosition, docCtx: this.docCtx });
13370
- if (renderObject instanceof BranchRenderObject) {
13371
- for (let i = 0; i < renderObject.length; i++) {
13372
- this.invokedPagePaintCompleted(renderObject.getChild(i), currPosition);
13373
- }
13374
- }
13054
+ // const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
13055
+ // const currPosition = { x: rx + parent.x, y: ry + parent.y };
13056
+ // renderObject.pagePaintCompleted({ render: this.renderCtx, position: currPosition, docCtx: this.docCtx })
13057
+ // if (renderObject instanceof BranchRenderObject) {
13058
+ // for (let i = 0; i < renderObject.length; i++) {
13059
+ // this.invokedPagePaintCompleted(renderObject.getChild(i), currPosition);
13060
+ // }
13061
+ // }
13375
13062
  }
13376
13063
  static drawPage(renderCtx, docCtx, renderObject, parent) {
13377
13064
  const { x: rx, y: ry } = renderObject.rect;
@@ -13383,24 +13070,9 @@ class ElementPaint {
13383
13070
  this.drawPage(renderCtx, docCtx, child, currPosition);
13384
13071
  }
13385
13072
  });
13386
- const renderData = {
13387
- position: currPosition,
13388
- nextRender: nextRenderFn,
13389
- render: renderCtx,
13390
- docCtx
13391
- };
13392
- renderObject.render(renderData);
13073
+ //renderObject.render(renderData);
13393
13074
  nextRenderFn();
13394
13075
  }
13395
- else if (renderObject instanceof LeafRenderObject) {
13396
- const renderData = {
13397
- position: currPosition,
13398
- nextRender: () => { },
13399
- render: renderCtx,
13400
- docCtx: docCtx
13401
- };
13402
- renderObject.render(renderData);
13403
- }
13404
13076
  }
13405
13077
  }
13406
13078
 
@@ -14964,10 +14636,11 @@ class DocumentArrange {
14964
14636
  let currRow = rows[j];
14965
14637
  const cutRows = [];
14966
14638
  while (currRow) {
14639
+ const minHeight = currRow.element.props.minHeight;
14967
14640
  const rowContentHeight = this.getBlockLineHeight(currRow);
14968
14641
  if (rowContentHeight + sumHeight > limitHeight) {
14969
- //行存在最小高度,且当前行跨页的情况下,不截断该行
14970
- if (currRow.element.props.minHeight) {
14642
+ //行存在最小高度,且当前行内容的高度小于最小高度,且当前行跨页的情况下,不截断该行
14643
+ if (minHeight > 0 && minHeight > rowContentHeight) {
14971
14644
  break;
14972
14645
  }
14973
14646
  //限制的外框尺寸
@@ -15842,539 +15515,52 @@ class ElementMeasure {
15842
15515
  }
15843
15516
  }
15844
15517
 
15845
- class ElementRenderCut {
15846
- options;
15518
+ class DocumentPaint {
15847
15519
  renderContext;
15848
- constructor(options, renderContext) {
15849
- this.options = options;
15520
+ docCtx;
15521
+ seo;
15522
+ elementMeasure;
15523
+ //elementRenderCut: ElementRenderCut;
15524
+ elementPaint;
15525
+ docPages;
15526
+ docContainer;
15527
+ //commsContainer!: CommsContainerRenderObject;
15528
+ viewOptions;
15529
+ constructor(renderContext, docCtx, seo) {
15850
15530
  this.renderContext = renderContext;
15531
+ this.docCtx = docCtx;
15532
+ this.seo = seo;
15533
+ this.viewOptions = this.docCtx.viewOptions;
15534
+ this.elementMeasure = new ElementMeasure(this.docCtx, this.renderContext);
15535
+ //this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
15536
+ this.elementPaint = new ElementPaint(this.renderContext, this.docCtx);
15851
15537
  }
15852
- cutPage(documentRender, documentElement) {
15853
- if (this.options.fullPageView) {
15854
- return this.getFullViewDocRender(documentRender, documentElement);
15855
- }
15856
- const headerRender = documentRender.getChild(0);
15857
- const bodyRender = documentRender.getChild(1).clone();
15858
- const footerRender = documentRender.getChild(2);
15859
- const commentsRender = documentRender.getChild(3);
15860
- const { headerLine, footerLine } = documentRender;
15861
- let bodyMarginTop = headerLine + headerRender.rect.height + 6;
15862
- let bodyMarginBottom = footerLine + footerRender.rect.height;
15863
- const { top: bodyTop, bottom: bodyBottom } = documentRender.padding;
15864
- bodyMarginTop = bodyMarginTop > bodyTop ? bodyMarginTop : bodyTop;
15865
- bodyMarginBottom = bodyMarginBottom > bodyBottom ? bodyMarginBottom : bodyBottom;
15866
- documentRender.padding.top = bodyMarginTop;
15867
- documentRender.padding.bottom = bodyMarginBottom;
15868
- const bodyLimitRect = this.getDocInnerRect(documentRender);
15869
- const bodyArray = [];
15870
- let { emptyBody: pageBodyRender, innerRect: bodyInnerLimitRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
15871
- bodyArray.push(pageBodyRender);
15872
- const createBodyHolder = () => {
15873
- const { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
15874
- pageBodyRender = emptyBody;
15875
- bodyInnerLimitRect = innerRect;
15876
- bodyArray.push(pageBodyRender);
15877
- };
15878
- const appendToBody = (item) => {
15879
- item.rect.y = bodyInnerLimitRect.height + item.margin.top;
15880
- pageBodyRender.addChild(item);
15881
- bodyInnerLimitRect.height += item.rect.height + item.margin.top + item.margin.bottom;
15882
- //上一个元素的bottom-margin
15883
- //bodyInnerLimitRect.prevMargin = item.margin.bottom;
15884
- ElementUtil.updateRenderHeightByInnerRect(pageBodyRender, bodyInnerLimitRect);
15885
- };
15886
- let i = 0;
15887
- let cloneBlockContentRender = bodyRender.getChild(i);
15888
- while (cloneBlockContentRender) {
15889
- if (bodyInnerLimitRect.maxHeight - bodyInnerLimitRect.height - cloneBlockContentRender.rect.height - cloneBlockContentRender.margin.bottom - cloneBlockContentRender.margin.top < 0) {
15890
- //限制的外框尺寸
15891
- const bodyAvailHeight = bodyInnerLimitRect.maxHeight - bodyInnerLimitRect.height - cloneBlockContentRender.margin.bottom - cloneBlockContentRender.margin.top;
15892
- //限制的内框尺寸
15893
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(cloneBlockContentRender, bodyAvailHeight);
15894
- const cutRenderObject = this.cutRenderItem(cloneBlockContentRender, limitRenderInnterHeight);
15895
- //至少有一个块级行元素被切割出来
15896
- if (cutRenderObject) {
15897
- appendToBody(cutRenderObject);
15898
- }
15899
- createBodyHolder();
15900
- }
15901
- else {
15902
- appendToBody(cloneBlockContentRender);
15903
- if (++i < bodyRender.length) {
15904
- cloneBlockContentRender = bodyRender.getChild(i);
15905
- }
15906
- else {
15907
- cloneBlockContentRender = null;
15908
- }
15909
- }
15910
- }
15911
- const docPages = [];
15912
- let pageY = this.options.docSpace;
15913
- for (let i = 0; i < bodyArray.length; i++) {
15914
- const body = bodyArray[i];
15915
- const documentRender = documentElement.createRenderObject();
15916
- docPages.push(documentRender);
15917
- documentRender.rect.y = pageY;
15918
- const limitRect = documentRender.getInnerRect();
15919
- const cloneHeaderRender = headerRender.clone();
15920
- cloneHeaderRender.rect.x = limitRect.x;
15921
- cloneHeaderRender.rect.y = headerLine;
15922
- documentRender.addChild(cloneHeaderRender);
15923
- body.rect.x = limitRect.x;
15924
- body.rect.y = bodyMarginTop;
15925
- body.rect.height = bodyInnerLimitRect.maxHeight;
15926
- documentRender.addChild(body);
15927
- pageY += documentRender.rect.height + this.options.docSpace;
15928
- const cloneFooterRender = footerRender.clone();
15929
- cloneFooterRender.rect.x = limitRect.x;
15930
- cloneFooterRender.rect.y = documentRender.rect.height - bodyMarginBottom;
15931
- documentRender.addChild(cloneFooterRender);
15932
- //审阅模式,添加审阅窗口
15933
- if (this.options.showReviewWindow && commentsRender) {
15934
- const commentsContainer = commentsRender.element.createRenderObject({
15935
- options: this.options,
15936
- renderCtx: this.renderContext
15937
- });
15938
- commentsContainer.padding.top = bodyMarginTop;
15939
- commentsContainer.rect.height = documentRender.rect.height;
15940
- documentRender.addChild(commentsContainer);
15941
- commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
15942
- documentRender.rect.width += this.options.reviewWindowWidth;
15943
- }
15538
+ rePages() {
15539
+ if (!this.docCtx.document.length) {
15540
+ return;
15944
15541
  }
15945
- return docPages;
15946
- }
15947
- getDocInnerRect(documentRender) {
15948
- const render = documentRender.element.createRenderObject({
15949
- options: this.options,
15950
- renderCtx: this.renderContext
15951
- });
15952
- render.padding = documentRender.padding;
15953
- return render.getInnerRect();
15954
- }
15955
- getFullViewDocRender(documentRender, documentElement) {
15956
- const commentsRender = documentRender.getChild(3);
15957
- const commentsContainer = commentsRender.element.createRenderObject({
15958
- options: this.options,
15959
- renderCtx: this.renderContext
15960
- });
15961
- documentRender.rect.height -= commentsContainer.rect.height;
15962
- const bodyRender = documentRender.getChild(1);
15963
- if (this.options.showReviewWindow) {
15964
- documentRender.removeChild(commentsRender);
15965
- documentRender.addChild(commentsContainer);
15966
- commentsContainer.padding.top = bodyRender.rect.y;
15967
- commentsContainer.rect.height = documentRender.rect.height;
15968
- commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
15969
- documentRender.rect.width += this.options.reviewWindowWidth;
15970
- }
15971
- return [documentRender];
15972
- }
15973
- createEmptyBodyRender(bodyRender, limitRect) {
15974
- const pageBodyRender = bodyRender.element.createRenderObject({
15975
- options: this.options,
15976
- renderCtx: this.renderContext
15977
- });
15978
- pageBodyRender.rect.width = limitRect.width;
15979
- const bodyInnerLimitRect = pageBodyRender.getInnerRect();
15980
- if (this.options.fullPageView) {
15981
- bodyInnerLimitRect.height = Number.MAX_VALUE;
15982
- }
15983
- return {
15984
- emptyBody: pageBodyRender,
15985
- innerRect: { ...bodyInnerLimitRect, prevMargin: 0, maxWidth: limitRect.width, maxHeight: limitRect.height }
15986
- };
15987
- }
15988
- /**
15989
- * 切割渲染元素
15990
- * @param render 被切割的对象
15991
- * @param limitHeight
15992
- * @returns
15993
- */
15994
- cutRenderItem(render, limitHeight) {
15995
- if (render instanceof TableRowRenderObject) {
15996
- return this.cutRowRenderItem(render, limitHeight);
15997
- }
15998
- if (render instanceof TableRenderObject) {
15999
- return this.cutTable(render, limitHeight);
16000
- }
16001
- const cloneRender = render.element.createRenderObject({
16002
- options: this.options,
16003
- renderCtx: this.renderContext
16004
- });
16005
- cloneRender.setRenderWidth(render.rect.width);
16006
- if (render instanceof MuiltBlockLineRenderObject) {
16007
- let sumHeight = 0;
16008
- const children = [...render.getItems()];
16009
- let j = 0;
16010
- let blockLine = children[j];
16011
- while (blockLine) {
16012
- //sumHeight = ElementUtil.remeasure(cloneRender);
16013
- const calcBlockLineHeight = this.getBlockLineHeight(blockLine);
16014
- if (calcBlockLineHeight + sumHeight > limitHeight) {
16015
- if (blockLine instanceof MuiltBlockLineRenderObject) {
16016
- //限制的外框尺寸
16017
- const availHeight = limitHeight - sumHeight;
16018
- //限制的内框尺寸
16019
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(render, availHeight);
16020
- const cutRenderObject = this.cutRenderItem(blockLine, limitRenderInnterHeight);
16021
- if (cutRenderObject) {
16022
- cloneRender.addChild(cutRenderObject);
16023
- sumHeight += cutRenderObject.rect.height;
16024
- blockLine = children[++j];
16025
- break;
16026
- }
16027
- else {
16028
- break;
16029
- }
16030
- }
16031
- else {
16032
- break;
16033
- }
16034
- }
16035
- else {
16036
- render.removeChild(blockLine);
16037
- cloneRender.addChild(blockLine);
16038
- sumHeight += blockLine.rect.height;
16039
- blockLine = children[++j];
16040
- }
16041
- }
16042
- ElementUtil.remeasure(cloneRender);
16043
- ElementUtil.remeasure(render);
16044
- if (cloneRender.length === 0) {
16045
- return null;
16046
- }
16047
- else {
16048
- return cloneRender;
16049
- }
16050
- }
16051
- else {
16052
- throw new Error('未实现');
16053
- }
16054
- }
16055
- /**
16056
- * 切割渲染元素
16057
- * @param tbRender 被切割的对象
16058
- * @param limitHeight
16059
- * @param addFunc
16060
- * @returns
16061
- */
16062
- cutTable(tbRender, limitHeight) {
16063
- const cloneTbRender = tbRender.element.createRenderObject();
16064
- cloneTbRender.setRenderWidth(tbRender.rect.width);
16065
- let sumHeight = 0;
16066
- const rows = [...tbRender.getItems()];
16067
- //获取跨页需要重复显示的行
16068
- const headerRows = this.getHeaderRows(tbRender);
16069
- //跨页头的高度
16070
- const headerHeight = headerRows.reduce((prev, curr) => prev + curr.rect.height, 0);
16071
- if (headerHeight > limitHeight) {
16072
- return null;
16073
- }
16074
- const copyHeaderRows = headerRows.map(item => item.clone());
16075
- //获取最后一个截断行,需要根据截断行判断最后一个截断的行位置
16076
- const cutOffRows = rows.filter(row => limitHeight >= row.rect.y && limitHeight <= row.rect.y + row.rect.height)
16077
- .map((row) => ({ rowIndex: row.element.getIndex(), row }))
16078
- .sort((first, second) => second.rowIndex - first.rowIndex);
16079
- if (cutOffRows.length === 0) {
16080
- throw new Error('无法获取截断行');
16081
- }
16082
- const joinRow = cutOffRows[0].row;
16083
- let j = 0;
16084
- let currRow = rows[j];
16085
- const cutRows = [];
16086
- while (currRow) {
16087
- const rowContentHeight = this.getBlockLineHeight(currRow);
16088
- if (rowContentHeight + sumHeight > limitHeight) {
16089
- if (currRow instanceof MuiltBlockLineRenderObject) {
16090
- //限制的外框尺寸
16091
- const availHeight = limitHeight - sumHeight;
16092
- //限制的内框尺寸
16093
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(tbRender, availHeight);
16094
- const cutRow = this.cutRowRenderItem(currRow, limitRenderInnterHeight);
16095
- if (cutRow) {
16096
- cloneTbRender.addChild(cutRow);
16097
- sumHeight += cutRow.rect.height;
16098
- cutRows.push(currRow);
16099
- if (currRow === joinRow) {
16100
- break;
16101
- }
16102
- currRow = rows[++j];
16103
- }
16104
- else {
16105
- break;
16106
- }
16107
- }
16108
- else {
16109
- break;
16110
- }
16111
- }
16112
- else {
16113
- tbRender.removeChild(currRow);
16114
- cloneTbRender.addChild(currRow);
16115
- sumHeight += currRow.rect.height;
16116
- currRow = rows[++j];
16117
- }
16118
- }
16119
- this.fixCutTable(tbRender, cutRows);
16120
- ElementUtil.remeasure(cloneTbRender);
16121
- //存在跨页需要重复显示的行头,则需要重新放置行头
16122
- if (copyHeaderRows.length) {
16123
- copyHeaderRows.forEach((r, i) => tbRender.insertChild(r, i));
16124
- }
16125
- ElementUtil.remeasure(tbRender);
16126
- if (cloneTbRender.length === 0) {
16127
- return null;
16128
- }
16129
- else {
16130
- return cloneTbRender;
16131
- }
16132
- }
16133
- cutRowRenderItem(render, limitHeight) {
16134
- if (render.element.props.minHeight > 0 && render.rect.height > limitHeight) {
16135
- return null;
16136
- }
16137
- const cloneRowRender = render.element.createRenderObject();
16138
- cloneRowRender.rect.width = render.rect.width;
16139
- render.remeasureState = true;
16140
- //cloneRowRender.rect.maxWidth = render.rect.height;
16141
- const cellRenders = [...render.getItems()];
16142
- const cutCellRenders = [];
16143
- for (let i = 0; i < cellRenders.length; i++) {
16144
- const cellRender = cellRenders[i];
16145
- this.markMergeRowRenderDirty(cellRender);
16146
- if (cellRender.rect.height > limitHeight) {
16147
- //限制的内框尺寸
16148
- const limitCellHeight = ElementUtil.innerRectMaxHeight(cellRender, limitHeight);
16149
- const cutCellRender = this.cutRenderItem(cellRender, limitCellHeight);
16150
- if (cutCellRender) {
16151
- cutCellRenders.push(cutCellRender);
16152
- }
16153
- else {
16154
- cutCellRenders.push(null);
16155
- }
16156
- }
16157
- else {
16158
- const cloneCellRender = cellRender;
16159
- render.removeChild(cellRender);
16160
- cutCellRenders.push(cloneCellRender);
16161
- }
16162
- }
16163
- ElementUtil.remeasure(render);
16164
- if (cutCellRenders.filter(item => item).length === 0) {
16165
- return null;
16166
- }
16167
- else {
16168
- //补齐单元格
16169
- for (let i = 0; i < cutCellRenders.length; i++) {
16170
- let cellRender = cutCellRenders[i];
16171
- if (!cellRender) {
16172
- cellRender = cellRenders[i].element.createRenderObject({
16173
- options: this.options,
16174
- renderCtx: this.renderContext
16175
- });
16176
- cellRender.rect = ElementUtil.cloneRect(cellRenders[i].rect);
16177
- ElementUtil.remeasure(cellRender);
16178
- }
16179
- cloneRowRender.addChild(cellRender);
16180
- }
16181
- ElementUtil.remeasure(cloneRowRender);
16182
- return cloneRowRender;
16183
- }
16184
- }
16185
- /**
16186
- * 标记合并单元格所在行需要重新计算
16187
- * @param cellRender
16188
- * @private
16189
- */
16190
- markMergeRowRenderDirty(cellRender) {
16191
- const cellEle = cellRender.element;
16192
- if (cellEle.props.vMerge !== 'restart') {
16193
- return;
16194
- }
16195
- const rowRender = cellRender.parent;
16196
- rowRender.element;
16197
- const tb = rowRender.parent;
16198
- const cellYPos = cellRender.rect.y;
16199
- for (let i = rowRender.getIndex() + 1; i < tb.length; i++) {
16200
- const nextRowRender = tb.getChild(i);
16201
- if (nextRowRender.rect.y <= cellYPos) {
16202
- nextRowRender.remeasureState = true;
16203
- nextRowRender.getItems().forEach(item => {
16204
- this.markMergeRowRenderDirty(item);
16205
- });
16206
- }
16207
- else {
16208
- break;
16209
- }
16210
- }
16211
- }
16212
- /**
16213
- * 修复->已经截断的合并单元格要向下移动到合适的位置
16214
- * @param tbRender
16215
- * @param cutRows
16216
- * @returns
16217
- */
16218
- fixCutTable(tbRender, cutRows) {
16219
- if (!cutRows.length) {
16220
- return;
16221
- }
16222
- const tbEle = tbRender.element;
16223
- const belowMergeRows = new Set();
16224
- for (let i = 0; i < tbRender.length; i++) {
16225
- const row = tbRender.getChild(i);
16226
- const nextRow = tbRender.getChild(i + 1);
16227
- if (!nextRow) {
16228
- break;
16229
- }
16230
- if (!cutRows.some(item => item === row)) {
16231
- break;
16232
- }
16233
- if (row.length === tbEle.getColsCount()) {
16234
- break;
16235
- }
16236
- if (this.checkFullRow(row)) {
16237
- break;
16238
- }
16239
- for (let j = 0; j < row.length; j++) {
16240
- const cell = row.getChild(j);
16241
- const cellEle = cell.element;
16242
- const colIndex = cellEle.getIndex();
16243
- if (!this.existsCellRender(nextRow, colIndex)) {
16244
- const insertColIndex = this.getRowInsertCellIndex(cell, nextRow);
16245
- if (insertColIndex === -1) {
16246
- this.getRowInsertCellIndex(cell, nextRow);
16247
- throw new Error('未在紧挨下方找到可以放置的位置');
16248
- }
16249
- //row.removeChild(cell);
16250
- nextRow.insertChild(cell, insertColIndex);
16251
- belowMergeRows.add(row);
16252
- ElementUtil.remeasure(nextRow);
16253
- }
16254
- }
16255
- }
16256
- if (belowMergeRows.size) {
16257
- for (const row of belowMergeRows) {
16258
- tbRender.removeChild(row);
16259
- row.clear();
16260
- }
16261
- ElementUtil.remeasure(tbRender);
16262
- }
16263
- }
16264
- /**
16265
- * 校验当前是否是一个完整的行,没有Null单元格,检查当前是否还需要向下合并
16266
- * @param row
16267
- */
16268
- checkFullRow(row) {
16269
- let x = 0;
16270
- for (let i = 0; i < row.length; i++) {
16271
- const cell = row.getChild(i);
16272
- if (cell.rect.x !== x) {
16273
- return false;
16274
- }
16275
- x += cell.rect.width;
16276
- }
16277
- return x === row.rect.width;
16278
- }
16279
- existsCellRender(rowRender, cellIndex) {
16280
- for (let i = 0; i < rowRender.length; i++) {
16281
- const cellRender = rowRender.getChild(i);
16282
- const cellEle = cellRender.element;
16283
- if (cellEle.getIndex() === cellIndex) {
16284
- return true;
16285
- }
16286
- }
16287
- return false;
16288
- }
16289
- getBlockLineHeight(render) {
16290
- if (render instanceof TableRowRenderObject) {
16291
- let maxCellHeight = 0;
16292
- for (let i = 0; i < render.length; i++) {
16293
- const itemHeight = render.getChild(i).rect.height;
16294
- if (itemHeight > maxCellHeight) {
16295
- maxCellHeight = itemHeight;
16296
- }
16297
- }
16298
- return maxCellHeight;
16299
- }
16300
- return render.rect.height;
16301
- }
16302
- getRowInsertCellIndex(sourceCell, destRow) {
16303
- for (let i = 0; i < destRow.length; i++) {
16304
- const cell = destRow.getChild(i);
16305
- const rect = cell.rect;
16306
- if (sourceCell.rect.x < rect.x) {
16307
- return i;
16308
- }
16309
- }
16310
- const lastCell = destRow.getChild(destRow.length - 1);
16311
- if (sourceCell.rect.x >= lastCell.rect.x + lastCell.rect.width) {
16312
- return destRow.length;
16313
- }
16314
- return -1;
16315
- }
16316
- getHeaderRows(tb) {
16317
- const rows = [];
16318
- for (let i = 0; i < tb.length; i++) {
16319
- const rowRender = tb.getChild(i);
16320
- const rowEle = rowRender.element;
16321
- if (rowEle.props.headerRow) {
16322
- rows.push(rowRender);
16323
- }
16324
- else {
16325
- break;
16326
- }
16327
- }
16328
- return rows;
16329
- }
16330
- }
16331
-
16332
- class DocumentPaint {
16333
- renderContext;
16334
- docCtx;
16335
- seo;
16336
- elementMeasure;
16337
- elementRenderCut;
16338
- elementPaint;
16339
- docPages;
16340
- docContainer;
16341
- //commsContainer!: CommsContainerRenderObject;
16342
- viewOptions;
16343
- constructor(renderContext, docCtx, seo) {
16344
- this.renderContext = renderContext;
16345
- this.docCtx = docCtx;
16346
- this.seo = seo;
16347
- this.viewOptions = this.docCtx.viewOptions;
16348
- this.elementMeasure = new ElementMeasure(this.docCtx, this.renderContext);
16349
- this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
16350
- this.elementPaint = new ElementPaint(this.renderContext, this.docCtx);
16351
- }
16352
- rePages() {
16353
- if (!this.docCtx.document.length) {
16354
- return;
16355
- }
16356
- this.docContainer = new DocumentContainerRender();
16357
- this.docCtx.selectionState.renderContainer = this.docContainer;
16358
- this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
16359
- // console.time('排版计时');
16360
- // const documentRender = this.elementMeasure.measureDocument(this.docCtx.document);
16361
- // this.commsContainer = documentRender.getChild(3) as CommsContainerRenderObject;
16362
- // if (this.commsContainer) {
16363
- // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
16364
- // }
16365
- // //console.timeEnd('排版计时');
16366
- // //console.time('断页计时');
16367
- // const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
16368
- const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
16369
- const docPages = newMeasure.measureDoc();
16370
- // this.commsContainer = newMeasure.commentsRender as CommsContainerRenderObject;
16371
- // if (this.commsContainer) {
16372
- // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
16373
- // }
16374
- //console.timeEnd('断页计时');
16375
- this.setCommRangeMark();
16376
- this.docPages = docPages;
16377
- this.layoutPages();
15542
+ this.docContainer = new DocumentContainerRender();
15543
+ this.docCtx.selectionState.renderContainer = this.docContainer;
15544
+ this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
15545
+ // console.time('排版计时');
15546
+ // const documentRender = this.elementMeasure.measureDocument(this.docCtx.document);
15547
+ // this.commsContainer = documentRender.getChild(3) as CommsContainerRenderObject;
15548
+ // if (this.commsContainer) {
15549
+ // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
15550
+ // }
15551
+ // //console.timeEnd('排版计时');
15552
+ // //console.time('断页计时');
15553
+ // const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
15554
+ const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
15555
+ const docPages = newMeasure.measureDoc();
15556
+ // this.commsContainer = newMeasure.commentsRender as CommsContainerRenderObject;
15557
+ // if (this.commsContainer) {
15558
+ // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
15559
+ // }
15560
+ //console.timeEnd('断页计时');
15561
+ this.setCommRangeMark();
15562
+ this.docPages = docPages;
15563
+ this.layoutPages();
16378
15564
  }
16379
15565
  /**
16380
15566
  * 文档页面显示布局
@@ -16540,8 +15726,6 @@ class PermanentTeethElement extends LeafElement {
16540
15726
  }
16541
15727
  }
16542
15728
  class PermanentTeethRenderObject extends LeafRenderObject {
16543
- render(e) {
16544
- }
16545
15729
  clone() {
16546
15730
  const clone = new PermanentTeethRenderObject(this.element);
16547
15731
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -16673,6 +15857,7 @@ class ElementReader {
16673
15857
  this.addFactory(PageBreakFactory);
16674
15858
  this.addFactory(TabFactory);
16675
15859
  this.addFactory(PermanentTeethFactory);
15860
+ this.addFactory(SVGFactory);
16676
15861
  // this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
16677
15862
  // const props = new TrackRunProps(data.type);
16678
15863
  // props.userId = data.userId;
@@ -17813,7 +16998,10 @@ class DocumentEvent {
17813
16998
  if (renderObject instanceof LeafRenderObject) {
17814
16999
  if (CommonUtil.isInsideRectByPosition(renderObjectRect, hitPos)) {
17815
17000
  const x = hitPos.x - renderObjectRect.x;
17816
- const offset = ElementUtil.getHitRenderOffset(renderObject, x);
17001
+ let offset = ElementUtil.getHitRenderOffset(renderObject, x);
17002
+ if (!this.ismousedown && renderObject.element && renderObject.element.type === 'psym') {
17003
+ offset = 0;
17004
+ }
17817
17005
  return {
17818
17006
  render: renderObject,
17819
17007
  offset,
@@ -17905,7 +17093,10 @@ class DocumentEvent {
17905
17093
  else {
17906
17094
  x = position.x - adjacentRender.rect.x;
17907
17095
  }
17908
- const offset = ElementUtil.getHitRenderOffset(adjacentRender.render, x);
17096
+ let offset = ElementUtil.getHitRenderOffset(adjacentRender.render, x);
17097
+ if (!this.ismousedown && renderObject.element && renderObject.element.type === 'psym') {
17098
+ offset = 0;
17099
+ }
17909
17100
  return {
17910
17101
  render: adjacentRender.render,
17911
17102
  absoluteRenderRect: adjacentRender.rect,
@@ -17995,6 +17186,7 @@ class DocumentEvent {
17995
17186
  startHitInfo: this.startHitInfo,
17996
17187
  endHitInfo: this.endHitInfo
17997
17188
  });
17189
+ console.log(this.endHitInfo);
17998
17190
  }
17999
17191
  /**
18000
17192
  * 获取鼠标所在的渲染元素对象
@@ -28927,7 +28119,7 @@ class DocEditor {
28927
28119
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28928
28120
  }
28929
28121
  version() {
28930
- return "2.1.19";
28122
+ return "2.1.20";
28931
28123
  }
28932
28124
  switchPageHeaderEditor() {
28933
28125
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -28935,7 +28127,7 @@ class DocEditor {
28935
28127
  getTextContent() {
28936
28128
  const paras = this.docCtx.document.treeFilter(item => item instanceof ParagraphElement);
28937
28129
  const paraTexts = paras.map(item => ElementSerialize.serializeString(item, { all: false }));
28938
- return paraTexts.join('\n');
28130
+ return paraTexts.join('');
28939
28131
  }
28940
28132
  emit(event, args) {
28941
28133
  this.eventBus.emit(event, args);
@@ -29111,5 +28303,5 @@ function removeDuplicatesEvent(events) {
29111
28303
  return arr;
29112
28304
  }
29113
28305
 
29114
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, clearChildrenRenderCache, clearTraces, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, docOpsMap, documentPrint, drawDecorator, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, printNodes, reactiveMap, removeEle, removeText, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
28306
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, clearChildrenRenderCache, clearTraces, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, docOpsMap, documentPrint, drawDecorator, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, printNodes, reactiveMap, removeEle, removeText, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
29115
28307
  //# sourceMappingURL=index.js.map