@hailin-zheng/editor-core 2.1.19 → 2.1.20

Sign up to get free protection for your applications and to get access to all the features.
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-cjs.js CHANGED
@@ -275,8 +275,6 @@ class RenderObject {
275
275
  this.margin = new MarginProps();
276
276
  this.padding = new PaddingProps();
277
277
  }
278
- pagePaintCompleted(e) {
279
- }
280
278
  destroy() {
281
279
  //this.parent = null;
282
280
  //this.margin = null;
@@ -2252,6 +2250,32 @@ class PictureProps extends INotifyPropertyChanged {
2252
2250
  return props;
2253
2251
  }
2254
2252
  }
2253
+ class SVGProps extends INotifyPropertyChanged {
2254
+ title;
2255
+ width = 5;
2256
+ height = 5;
2257
+ value;
2258
+ clone(dest) {
2259
+ const clone = dest ?? new SVGProps();
2260
+ super.cloneAttachedProperty(clone);
2261
+ clone.width = this.width;
2262
+ clone.height = this.height;
2263
+ clone.value = this.value;
2264
+ clone.title = this.title;
2265
+ return clone;
2266
+ }
2267
+ getSerializeProps(viewOptions) {
2268
+ const props = {
2269
+ width: this.width,
2270
+ height: this.height,
2271
+ value: this.value,
2272
+ };
2273
+ if (this.title) {
2274
+ props['title'] = this.title;
2275
+ }
2276
+ return props;
2277
+ }
2278
+ }
2255
2279
  class DataDecorateProps extends INotifyPropertyChanged {
2256
2280
  content;
2257
2281
  size;
@@ -2806,15 +2830,7 @@ class CommsContainerElement extends BlockContainerElement {
2806
2830
  class CommsContainerRenderObject extends BlockContainerRenderObject {
2807
2831
  //批注内容是否已经重组,只要重新绘制的时候组合一次即可
2808
2832
  isMeasureComm;
2809
- selectedSet;
2810
- commentRangeStatus = [];
2811
2833
  commsMarks = [];
2812
- render(e) {
2813
- if (this.rect.height === 0) {
2814
- return;
2815
- }
2816
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, 'black', 0.5);
2817
- }
2818
2834
  clone() {
2819
2835
  const clone = new CommsContainerRenderObject(this.element);
2820
2836
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -2895,9 +2911,6 @@ class DataDecorateElement extends LeafElement {
2895
2911
  }
2896
2912
  }
2897
2913
  class DataDecorateRenderObject extends LeafRenderObject {
2898
- render(e) {
2899
- this.renderDecorRect(e.render, e.position);
2900
- }
2901
2914
  renderDecorRect(ctx, position) {
2902
2915
  if (ctx.drawMode === 'print') {
2903
2916
  return;
@@ -3107,10 +3120,6 @@ class ParagraphElement extends BlockContentElement {
3107
3120
  }
3108
3121
  }
3109
3122
  class ParagraphRenderObject extends MuiltBlockLineRenderObject {
3110
- render(e) {
3111
- e.nextRender();
3112
- this.drawProjectNumber(e.render, e.docCtx.viewOptions, e);
3113
- }
3114
3123
  /**
3115
3124
  * 绘制项目符号
3116
3125
  */
@@ -3188,8 +3197,6 @@ class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {
3188
3197
  baseTopLine = 0;
3189
3198
  baseBottomLine = 0;
3190
3199
  startX = 0;
3191
- render(e) {
3192
- }
3193
3200
  clone() {
3194
3201
  const cloneRender = new ParagraphLineRectRenderObject(this.element);
3195
3202
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -3391,21 +3398,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3391
3398
  }
3392
3399
  headerLine;
3393
3400
  footerLine;
3394
- render(e) {
3395
- const { render, position, docCtx: { viewOptions } } = e;
3396
- const { width: docWidth, height: docHeight } = viewOptions.docPageSettings;
3397
- render.overlaysContext.fillRect(position.x, position.y, docWidth, this.rect.height, 'white', 5, 'black');
3398
- e.render.tran(() => {
3399
- e.render.contentContext.ctx.fillStyle = e.docCtx.viewOptions.defaultColor;
3400
- this.checkPrintMode(e);
3401
- e.nextRender();
3402
- this.drawCopyRight(viewOptions, render, position);
3403
- this.drawDocPageNum(render, viewOptions, position);
3404
- //绘制文档边距线
3405
- this.drawMarginLine(position, render, docWidth, docHeight);
3406
- this.drawWatermark(render, viewOptions, position);
3407
- });
3408
- }
3409
3401
  /**
3410
3402
  * 打印模式检查
3411
3403
  * 如果是续打模式,需要进行裁剪打印范围,页眉页脚都不需要打印
@@ -3841,45 +3833,6 @@ function getCurrOptions(ele) {
3841
3833
  return doc?.viewOptions;
3842
3834
  }
3843
3835
  class DataElementRenderObject extends InlineGroupRenderObject {
3844
- render(e) {
3845
- const { render, position, docCtx: { viewOptions } } = e;
3846
- this.paintPos = e.position;
3847
- //数据元不打印
3848
- if (!this.element.props.printable && render.drawMode === 'print') {
3849
- return;
3850
- }
3851
- render.contentContext.tran(() => {
3852
- //绘制数据元区域底色
3853
- let bgColor = '';
3854
- if (this.element.isMouseenter) {
3855
- bgColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3856
- }
3857
- if (this.element.isFocused) {
3858
- bgColor = e.docCtx.viewOptions.dataEleFocusedBgColor;
3859
- }
3860
- if (this.element.errorTip) {
3861
- bgColor = viewOptions.dataEleErrorBgColor;
3862
- }
3863
- if (bgColor) {
3864
- render.contentContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, bgColor);
3865
- }
3866
- if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
3867
- render.contentContext.ctx.filter = "blur(10px)";
3868
- }
3869
- if (this.element.props.underline) {
3870
- const y = position.y + 2 + this.rect.height;
3871
- render.contentContext.strokeLines([{ x: position.x, y }, {
3872
- x: position.x + this.rect.width,
3873
- y
3874
- }], 1, '#595959');
3875
- }
3876
- e.nextRender();
3877
- this.drawCaption(e);
3878
- });
3879
- e.render.onRenderCompleted.subscribe(() => {
3880
- drawDecorator(e, this);
3881
- });
3882
- }
3883
3836
  exportHTML(event) {
3884
3837
  const node = super.exportHTML(event);
3885
3838
  exportDecoratorHTML(event, this);
@@ -4165,15 +4118,6 @@ class DocumentBodyElement extends BlockContainerElement {
4165
4118
  }
4166
4119
  }
4167
4120
  class DocumentBodyRenderObject extends MuiltBlockLineRenderObject {
4168
- render(e) {
4169
- const { render, position } = e;
4170
- render.tran(() => {
4171
- if (this.element.disableClick && render.drawMode === 'view') {
4172
- render.contentContext.setGlobalAlpha(0.5);
4173
- }
4174
- e.nextRender();
4175
- });
4176
- }
4177
4121
  clone(cloneData = true) {
4178
4122
  const cloneRender = new DocumentBodyRenderObject(this.element);
4179
4123
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4243,22 +4187,6 @@ class DocumentFooterElement extends BlockContainerElement {
4243
4187
  }
4244
4188
  }
4245
4189
  class DocumentFooterRenderObject extends BlockContainerRenderObject {
4246
- render(e) {
4247
- const { render, position } = e;
4248
- render.tran(() => {
4249
- //判断页眉是否为输入内容
4250
- const isFooterEmpty = ElementUtil.checkEmptyRenderContent(this);
4251
- if (this.element.disableClick && render.drawMode === 'view') {
4252
- if (isFooterEmpty) {
4253
- render.contentContext.setGlobalAlpha(0);
4254
- }
4255
- else {
4256
- render.contentContext.setGlobalAlpha(0.5);
4257
- }
4258
- }
4259
- e.nextRender();
4260
- });
4261
- }
4262
4190
  clone() {
4263
4191
  const cloneRender = new DocumentFooterRenderObject(this.element);
4264
4192
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4339,27 +4267,6 @@ class DocumentHeaderElement extends BlockContainerElement {
4339
4267
  }
4340
4268
  }
4341
4269
  class DocumentHeaderRenderObject extends BlockContainerRenderObject {
4342
- render(e) {
4343
- const { render, position } = e;
4344
- render.tran(() => {
4345
- //判断页眉是否为输入内容
4346
- const isHeaderEmpty = ElementUtil.checkEmptyRenderContent(this);
4347
- //存在输入内容时,绘制页眉-页体分割线
4348
- if (!isHeaderEmpty || !this.element.disableClick) {
4349
- const headerLineY = this.rect.height;
4350
- render.contentContext.drawHoriLine(position.x, position.y + headerLineY, this.rect.width, 'black', 0.5);
4351
- }
4352
- if (this.element.disableClick && render.drawMode === 'view') {
4353
- if (isHeaderEmpty) {
4354
- render.contentContext.setGlobalAlpha(0);
4355
- }
4356
- else {
4357
- render.contentContext.setGlobalAlpha(0.5);
4358
- }
4359
- }
4360
- e.nextRender();
4361
- });
4362
- }
4363
4270
  clone() {
4364
4271
  const cloneRender = new DocumentHeaderRenderObject(this.element);
4365
4272
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4439,13 +4346,6 @@ class PSymbolElement extends LeafElement {
4439
4346
  }
4440
4347
  }
4441
4348
  class PSymbolRenderObject extends LeafRenderObject {
4442
- render(e) {
4443
- const { render, position } = e;
4444
- if (render.drawMode === 'print' || !e.docCtx.viewOptions.showParaSymbol) {
4445
- return;
4446
- }
4447
- render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
4448
- }
4449
4349
  exportHTML(event) {
4450
4350
  if (!event.options.showEnterSymbol || event.mode === 'print') {
4451
4351
  return null;
@@ -4558,22 +4458,6 @@ class TableCellElement extends BlockContainerElement {
4558
4458
  }
4559
4459
  }
4560
4460
  class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
4561
- render(e) {
4562
- const { render, position } = e;
4563
- render.tran(() => {
4564
- render.contentContext.clip(position.x, position.y, this.rect.width, this.rect.height);
4565
- const { hMerge, vMerge, backgroundColor, diagonal } = this.element.props;
4566
- if (hMerge === 'continue' || vMerge === 'continue') {
4567
- render.contentContext.setGlobalAlpha(0);
4568
- render.overlaysContext.setGlobalAlpha(0);
4569
- }
4570
- if (backgroundColor && this.rect.width && this.rect.height) {
4571
- render.contentContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, backgroundColor);
4572
- }
4573
- this.renderDiagonal(render, diagonal, position);
4574
- e.nextRender();
4575
- });
4576
- }
4577
4461
  /**
4578
4462
  * 绘制对角线
4579
4463
  * @private
@@ -4742,8 +4626,6 @@ class TableRowRenderObject extends MuiltBlockLineRenderObject {
4742
4626
  remeasureState = true;
4743
4627
  //当前行是否存在合并单元格
4744
4628
  hasMergeCells = undefined;
4745
- render(e) {
4746
- }
4747
4629
  clone() {
4748
4630
  const cloneRender = new TableRowRenderObject(this.element);
4749
4631
  cloneRender.remeasureState = this.remeasureState;
@@ -4772,17 +4654,6 @@ class DocumentContainerRender extends BlockContainerRenderObject {
4772
4654
  constructor() {
4773
4655
  super(null);
4774
4656
  }
4775
- render(e) {
4776
- const { render, nextRender, docCtx: { viewOptions } } = e;
4777
- const { viewSettings, docPageSettings, viewBackcolor, scale } = viewOptions;
4778
- render.clear();
4779
- //render.overlaysContext.fillRect(0, 0, viewSettings.width, viewSettings.height, viewBackcolor);
4780
- render.tran(() => {
4781
- render.overlaysContext.ctx.scale(scale, scale);
4782
- render.contentContext.ctx.scale(scale, scale);
4783
- nextRender();
4784
- });
4785
- }
4786
4657
  clone() {
4787
4658
  throw new Error("Method not implemented.");
4788
4659
  }
@@ -4899,17 +4770,6 @@ class TextGroupElement extends LeafElement {
4899
4770
  }
4900
4771
  class TextGroupRenderObject extends LeafRenderObject {
4901
4772
  textMeasures;
4902
- render(e) {
4903
- const { render, position } = e;
4904
- //null-text不打印
4905
- if (render.drawMode === 'print' && this.element.isDecorate) {
4906
- return;
4907
- }
4908
- if (this.element.props.border) {
4909
- render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
4910
- }
4911
- render.contentContext.drawTextUnits(this, position.x, position.y + (this.rect.height - this.element.props.fontSize) / 2);
4912
- }
4913
4773
  constructor(element) {
4914
4774
  super(element);
4915
4775
  }
@@ -6625,56 +6485,6 @@ class TableRenderObject extends MuiltBlockLineRenderObject {
6625
6485
  setRenderWidth(maxWidth) {
6626
6486
  super.setRenderWidth(maxWidth);
6627
6487
  }
6628
- render(e) {
6629
- const { render, position } = e;
6630
- //绘制表格线
6631
- const border = this.element.props.border;
6632
- if (border === 'none') {
6633
- return;
6634
- }
6635
- const lineDash = border === 'dashed' ? [2, 2] : [];
6636
- for (let i = 0; i < this.length; i++) {
6637
- const rowRender = this.getChild(i);
6638
- const rowPos = { x: rowRender.rect.x + position.x, y: rowRender.rect.y + position.y };
6639
- for (let j = 0; j < rowRender.length; j++) {
6640
- const cellRender = rowRender.getChild(j);
6641
- const cellPos = { x: cellRender.rect.x + rowPos.x, y: cellRender.rect.y + rowPos.y };
6642
- //绘制单元格上边框
6643
- if (i === 0) {
6644
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, cellRender.rect.width, 1);
6645
- render.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, {
6646
- x: cellPos.x + cellRender.rect.width,
6647
- y: cellPos.y
6648
- }], 1, '#000', lineDash);
6649
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y });
6650
- }
6651
- //绘制左边框
6652
- if (j === 0) {
6653
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, 1, cellRender.rect.height);
6654
- render.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, {
6655
- x: cellPos.x,
6656
- y: cellPos.y + cellRender.rect.height
6657
- }], 1, '#000', lineDash);
6658
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x, y: cellPos.y + cellRender.rect.height });
6659
- }
6660
- //绘制右边框
6661
- //ctx.contentContext.fillRect(cellPos.x + cellRender.rect.width, cellPos.y, 1, cellRender.rect.height);
6662
- render.contentContext.fillLines([{
6663
- x: cellPos.x + cellRender.rect.width,
6664
- y: cellPos.y
6665
- }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }], 1, '#000', lineDash);
6666
- //this.drawLine(ctx, { x: cellPos.x + cellRender.rect.width, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
6667
- //绘制下边框
6668
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y + cellRender.rect.height, cellRender.rect.width, 1);
6669
- render.contentContext.fillLines([{
6670
- x: cellPos.x,
6671
- y: cellPos.y + cellRender.rect.height
6672
- }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }], 1, '#000', lineDash);
6673
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y + cellRender.rect.height }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
6674
- //cellRender.beginRender(ctx, { x: position.x + cellRender.offsetX, y: position.y + cellRender.offsetY });
6675
- }
6676
- }
6677
- }
6678
6488
  exportTableBorder() {
6679
6489
  //绘制表格线
6680
6490
  const border = this.element.props.border;
@@ -6959,10 +6769,7 @@ class CheckBoxFactory extends ElementFactory {
6959
6769
  }
6960
6770
  }
6961
6771
  class CheckBoxRenderObject extends LeafRenderObject {
6962
- render(e) {
6963
- e.render.contentContext.drawCheckBox(e.position.x + 2, e.position.y, this.element.props.size, this.element.props.size, this.element.props.isChecked);
6964
- }
6965
- clone(cloneData = true) {
6772
+ clone() {
6966
6773
  const clone = new CheckBoxRenderObject(this.element);
6967
6774
  clone.rect = ElementUtil.cloneRect(this.rect);
6968
6775
  return clone;
@@ -7061,34 +6868,6 @@ class CommContentElement extends CommContentBaseElement {
7061
6868
  }
7062
6869
  }
7063
6870
  class CommContentRenderObject extends CommContentBaseRenderObject {
7064
- render(e) {
7065
- let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';
7066
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, borderColor);
7067
- e.render.contentContext.fillRect(e.position.x, e.position.y, 8, this.rect.height, '#871400');
7068
- const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject);
7069
- //获取审阅标记的绘制坐标
7070
- let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, {
7071
- x: 0,
7072
- y: -e.docCtx.viewOptions.pageOffset.y
7073
- });
7074
- const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
7075
- commMarkPos.y = commMarkLinePos.y + 2;
7076
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, {
7077
- x: 0,
7078
- y: -e.docCtx.viewOptions.pageOffset.y
7079
- });
7080
- const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
7081
- const marginRight = e.docCtx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
7082
- e.render.overlaysContext.drawDashLine([commMarkPos, {
7083
- x: commMarkPos.x + marginRight,
7084
- y: commMarkPos.y
7085
- }], [1, 1], 'red');
7086
- e.render.overlaysContext.drawDashLine([{
7087
- x: commMarkPos.x + marginRight,
7088
- y: commMarkPos.y
7089
- }, e.position], [1, 1], 'red');
7090
- this.renderTitle(e.render, e.position);
7091
- }
7092
6871
  exportHTML(event) {
7093
6872
  const t = super.exportHTML(event);
7094
6873
  t.children = [];
@@ -7359,16 +7138,6 @@ class CommentElement extends LeafElement {
7359
7138
  }
7360
7139
  }
7361
7140
  class CommentRenderObject extends LeafRenderObject {
7362
- //renderPos!: Position;
7363
- render(e) {
7364
- // if (!e.docCtx.viewOptions.showReviewWindow) {
7365
- // return;
7366
- // }
7367
- // this.renderPos = e.position;
7368
- // const paraLinePos = ElementUtil.getParaLinePos(this, {x: e.position.x, y: e.position.y});
7369
- // const color = '#ff4d4f';
7370
- // e.render.contentContext.fillRect(e.position.x - 1, paraLinePos.y, 2, paraLinePos.height, color)
7371
- }
7372
7141
  exportHTML(event) {
7373
7142
  const renderPos = { ...event.relativePagePos };
7374
7143
  const paraLinePos = ElementUtil.getParaLinePos(this, { x: renderPos.x, y: renderPos.y });
@@ -7534,31 +7303,6 @@ class ValidateElement extends CommContentBaseElement {
7534
7303
  }
7535
7304
  }
7536
7305
  class ValidateRenderObject extends CommContentBaseRenderObject {
7537
- render(e) {
7538
- let borderColor = this.element.focus ? '#fa8c16' : '#ffd591';
7539
- e.render.contentContext.strokeRect(e.position.x, e.position.y, this.rect.width, this.rect.height, borderColor);
7540
- e.render.contentContext.fillRect(e.position.x, e.position.y, 8, this.rect.height, '#871400');
7541
- const docRender = ElementUtil.getParentRender(this.commMarkRender.render, DocumentRenderObject);
7542
- //获取审阅标记的绘制坐标
7543
- let commMarkPos = ElementUtil.getRenderAbsolutePaintPos(this.commMarkRender.render, {
7544
- x: 0,
7545
- y: -e.docCtx.viewOptions.pageOffset.y
7546
- });
7547
- const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
7548
- commMarkPos.y = commMarkLinePos.y + 2;
7549
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, { x: 0, y: -e.docCtx.viewOptions.pageOffset.y });
7550
- const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
7551
- const marginRight = e.docCtx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
7552
- e.render.overlaysContext.drawDashLine([commMarkPos, {
7553
- x: commMarkPos.x + marginRight,
7554
- y: commMarkPos.y
7555
- }], [1, 1], 'red');
7556
- e.render.overlaysContext.drawDashLine([{
7557
- x: commMarkPos.x + marginRight,
7558
- y: commMarkPos.y
7559
- }, e.position], [1, 1], 'red');
7560
- this.renderTitle(e.render, e.position);
7561
- }
7562
7306
  renderTitle(ctx, position) {
7563
7307
  const topPadding = 24;
7564
7308
  const textProps = new TextProps();
@@ -8484,40 +8228,11 @@ class DataElementBarcode extends DataElementLeaf {
8484
8228
  }
8485
8229
  }
8486
8230
  class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
8487
- render(e) {
8488
- // const barcodeEle = this.element as DataElementBarcode;
8489
- // barcodeEle.drawBarcode(e.render, e.position);
8490
- }
8491
8231
  clone() {
8492
8232
  const clone = new DataElementBarcodeRenderObject(this.element);
8493
8233
  clone.rect = ElementUtil.cloneRect(this.rect);
8494
8234
  return clone;
8495
8235
  }
8496
- pagePaintCompleted(e) {
8497
- if (this.element.isFocused) {
8498
- const { render, position: pos } = e;
8499
- const { width, height } = this.rect;
8500
- render.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
8501
- this.drawResizeCircle(render, pos.x, pos.y);
8502
- this.drawResizeCircle(render, pos.x + width, pos.y);
8503
- this.drawResizeCircle(render, pos.x, pos.y + height);
8504
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
8505
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
8506
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
8507
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
8508
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
8509
- }
8510
- }
8511
- drawResizeCircle(ctx, x, y) {
8512
- const ctxNative = ctx.contentContext.ctx;
8513
- ctxNative.save();
8514
- ctxNative.fillStyle = '#69c0ff';
8515
- ctxNative.beginPath();
8516
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
8517
- ctxNative.closePath();
8518
- ctxNative.fill();
8519
- ctxNative.restore();
8520
- }
8521
8236
  exportHTML(event) {
8522
8237
  const t = super.exportHTML(event);
8523
8238
  if (this.element.props.type === 'qrcode') {
@@ -8682,27 +8397,6 @@ class DataElementCheckRenderObject extends LeafRenderObject {
8682
8397
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
8683
8398
  return cloneRender;
8684
8399
  }
8685
- render(e) {
8686
- const { render, position } = e;
8687
- const element = this.element;
8688
- if (element.props.drawStateChar) {
8689
- const font = `${element.props.size - 2}px 微软雅黑`;
8690
- const str = element.props.checked ? element.props.trueChar : element.props.falseChar;
8691
- const color = element.props.checked ? element.props.trueStateColor : element.props.falseStateColor;
8692
- e.render.contentContext.drawText2(str, font, color, position.x, position.y, element.props.size, element.props.size);
8693
- if (element.props.border) {
8694
- e.render.contentContext.strokeRect(position.x + 2, position.y, element.props.size, element.props.size);
8695
- }
8696
- }
8697
- else {
8698
- if (element.props.multiSelect) {
8699
- render.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8700
- }
8701
- else {
8702
- render.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8703
- }
8704
- }
8705
- }
8706
8400
  exportHTML(event) {
8707
8401
  const t = super.exportHTML(event);
8708
8402
  const props = this.element.props;
@@ -8993,12 +8687,6 @@ class DataElementGroupElement extends InlineGroupInputElement {
8993
8687
  }
8994
8688
  }
8995
8689
  class DataElementGroupRenderObject extends InlineGroupRenderObject {
8996
- render(e) {
8997
- this.paintPos = e.position;
8998
- e.render.onRenderCompleted.subscribe(() => {
8999
- drawDecorator(e, this);
9000
- });
9001
- }
9002
8690
  clone() {
9003
8691
  const cloneRender = new DataElementGroupRenderObject(this.element);
9004
8692
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -9066,38 +8754,11 @@ class DataElementImage extends DataElementLeaf {
9066
8754
  }
9067
8755
  }
9068
8756
  class DataImageRenderObject extends ResizeLeafRenderObject {
9069
- render(e) {
9070
- }
9071
8757
  clone() {
9072
8758
  const clone = new DataImageRenderObject(this.element);
9073
8759
  clone.rect = ElementUtil.cloneRect(this.rect);
9074
8760
  return clone;
9075
8761
  }
9076
- pagePaintCompleted(e) {
9077
- if (this.element.isFocused) {
9078
- const { render, position: pos } = e;
9079
- const { width, height } = this.rect;
9080
- render.contentContext.strokeRect(pos.x, pos.y, this.rect.width, this.rect.height, '#1890ff', 0.5);
9081
- this.drawResizeCircle(render, pos.x, pos.y);
9082
- this.drawResizeCircle(render, pos.x + width, pos.y);
9083
- this.drawResizeCircle(render, pos.x, pos.y + height);
9084
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
9085
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
9086
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
9087
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
9088
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
9089
- }
9090
- }
9091
- drawResizeCircle(ctx, x, y) {
9092
- const ctxNative = ctx.contentContext.ctx;
9093
- ctxNative.save();
9094
- ctxNative.fillStyle = '#69c0ff';
9095
- ctxNative.beginPath();
9096
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
9097
- ctxNative.closePath();
9098
- ctxNative.fill();
9099
- ctxNative.restore();
9100
- }
9101
8762
  exportHTML(event) {
9102
8763
  const t = super.exportHTML(event);
9103
8764
  t.children = [{
@@ -9333,13 +8994,6 @@ class BreakElement extends LeafElement {
9333
8994
  }
9334
8995
  }
9335
8996
  class BreakRenderObject extends LeafRenderObject {
9336
- render(e) {
9337
- const { render, position } = e;
9338
- if (render.drawMode === 'print') {
9339
- return;
9340
- }
9341
- render.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);
9342
- }
9343
8997
  exportHTML(event) {
9344
8998
  if (!event.options.showEnterSymbol || event.mode === 'print') {
9345
8999
  return null;
@@ -9505,8 +9159,6 @@ class FillNullSpaceRenderObject extends LeafRenderObject {
9505
9159
  super(null);
9506
9160
  this.disableClick = true;
9507
9161
  }
9508
- render(e) {
9509
- }
9510
9162
  clone() {
9511
9163
  const clone = new FillNullSpaceRenderObject();
9512
9164
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -9567,11 +9219,6 @@ class DocumentBodyPartElement extends BlockContainerElement {
9567
9219
  }
9568
9220
  }
9569
9221
  class DocumentBodyPartRenderObject extends MuiltBlockLineRenderObject {
9570
- render(e) {
9571
- const { render, position } = e;
9572
- const bgColor = (this.element.isFocused || this.element.isMouseenter) ? '#d9d9d9' : '#ffffff';
9573
- render.overlaysContext.fillRect(position.x - 2, position.y - 2, this.rect.width + 4, this.rect.height + 4, bgColor, 5, 'black');
9574
- }
9575
9222
  clone(cloneData = true) {
9576
9223
  const cloneRender = new DocumentBodyPartRenderObject(this.element);
9577
9224
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -9711,9 +9358,6 @@ function getMHItem(kind) {
9711
9358
  return mhLayoutItems[kindIndex];
9712
9359
  }
9713
9360
  class DataRenderMH extends LeafRenderObject {
9714
- render(e) {
9715
- renderMH(this.element, e.render, e.position, true);
9716
- }
9717
9361
  exportHTML(event) {
9718
9362
  const t = super.exportHTML(event);
9719
9363
  const children = [];
@@ -9948,36 +9592,11 @@ class PictureElement extends LeafElement {
9948
9592
  }
9949
9593
  }
9950
9594
  class PictureRenderObject extends ResizeLeafRenderObject {
9951
- render(e) {
9952
- }
9953
9595
  clone() {
9954
9596
  const clone = new PictureRenderObject(this.element);
9955
9597
  clone.rect = ElementUtil.cloneRect(this.rect);
9956
9598
  return clone;
9957
9599
  }
9958
- pagePaintCompleted(e) {
9959
- if (this.element.isFocused) {
9960
- const { render, position: pos } = e;
9961
- const { width, height } = this.rect;
9962
- render.contentContext.strokeRect(pos.x, pos.y, width, height, '#1890ff', 0.5);
9963
- this.drawResizeCircle(render, pos.x, pos.y);
9964
- this.drawResizeCircle(render, pos.x + width, pos.y);
9965
- this.drawResizeCircle(render, pos.x, pos.y + height);
9966
- this.drawResizeCircle(render, pos.x + width, pos.y + height);
9967
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y);
9968
- this.drawResizeCircle(render, pos.x + (Math.floor(width / 2)), pos.y + height);
9969
- this.drawResizeCircle(render, pos.x, pos.y + (Math.floor(height / 2)));
9970
- this.drawResizeCircle(render, pos.x + width, pos.y + (Math.floor(height / 2)));
9971
- }
9972
- }
9973
- drawResizeCircle(ctx, x, y) {
9974
- const ctxNative = ctx.contentContext.ctx;
9975
- ctxNative.fillStyle = '#69c0ff';
9976
- ctxNative.beginPath();
9977
- ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
9978
- ctxNative.closePath();
9979
- ctxNative.fill();
9980
- }
9981
9600
  exportHTML(event) {
9982
9601
  const picElement = this.element;
9983
9602
  const picProps = picElement.props;
@@ -10109,10 +9728,6 @@ class RadioBoxFactory extends ElementFactory {
10109
9728
  }
10110
9729
  }
10111
9730
  class RadioBoxRenderObject extends LeafRenderObject {
10112
- render(e) {
10113
- const { render, position } = e;
10114
- render.contentContext.drawRadioBox(position.x + 2, position.y, this.element.props.size, this.element.props.size, this.element.props.isChecked);
10115
- }
10116
9731
  clone(cloneData = true) {
10117
9732
  const clone = new RadioBoxRenderObject(this.element);
10118
9733
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -10151,13 +9766,6 @@ class PageBreakElement extends LeafElement {
10151
9766
  }
10152
9767
  }
10153
9768
  class PageBreakRenderObject extends LeafRenderObject {
10154
- render(e) {
10155
- const { render, position } = e;
10156
- if (render.drawMode === 'print') {
10157
- return;
10158
- }
10159
- render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
10160
- }
10161
9769
  clone() {
10162
9770
  const render = new PageBreakRenderObject(this.element);
10163
9771
  render.rect = ElementUtil.cloneRect(this.rect);
@@ -10194,13 +9802,6 @@ class TabElement extends LeafElement {
10194
9802
  }
10195
9803
  }
10196
9804
  class TabRenderObject extends LeafRenderObject {
10197
- render(e) {
10198
- const { render, position } = e;
10199
- if (render.drawMode === 'print') {
10200
- return;
10201
- }
10202
- //render.contentContext.fillRect(position.x,position.y,this.rect.width,this.rect.height,'red');
10203
- }
10204
9805
  clone() {
10205
9806
  const render = new TabRenderObject(this.element);
10206
9807
  render.rect = ElementUtil.cloneRect(this.rect);
@@ -10766,58 +10367,170 @@ class TableSplitCell {
10766
10367
  }
10767
10368
  }
10768
10369
 
10769
- class ElementSerialize {
10770
- /**
10771
- * 将当前文档对象构建并输出到标准的JSON对象
10772
- * @param element
10773
- * @param viewOptions
10774
- */
10775
- static serialize(element, viewOptions) {
10776
- const result = element.serialize(viewOptions);
10777
- if (!result) {
10778
- return null;
10779
- }
10780
- if (result.complete) {
10781
- return result;
10782
- }
10783
- if (element instanceof BranchElement) {
10784
- result.children = [];
10785
- let prevEle = null;
10786
- for (let i = 0; i < element.length; i++) {
10787
- const child = element.getChild(i);
10788
- const serializeChild = this.serialize(child, viewOptions);
10789
- if (child.type === 'text' && prevEle && prevEle.ele.type === 'text') {
10790
- if (child.props.equals(prevEle.ele.props)) {
10791
- prevEle.props.content += serializeChild.content;
10792
- continue;
10793
- }
10794
- }
10795
- if (serializeChild) {
10796
- delete serializeChild.complete;
10797
- serializeChild.props = serializeChild.props || {};
10798
- if (Object.keys(serializeChild.props).length === 0) {
10799
- delete serializeChild.props;
10800
- }
10801
- if (serializeChild.children && serializeChild.children.length === 0) {
10802
- delete serializeChild.children;
10803
- }
10804
- result.children.push(serializeChild);
10805
- prevEle = { ele: child, props: serializeChild };
10806
- }
10807
- }
10808
- }
10809
- if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
10810
- result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
10811
- }
10812
- return result;
10370
+ class SVGElement extends LeafElement {
10371
+ resizeable = true;
10372
+ constructor() {
10373
+ super('svg');
10374
+ this.props = new SVGProps();
10375
+ //this.addPropValueChangedSub(this.props);
10376
+ this.cursorType = 'move';
10377
+ this.focusable = true;
10813
10378
  }
10814
- static serializeString(element, options = { all: false }) {
10815
- if (!options.all && element instanceof TrackRunElement && element.type === exports.TrackRunTypeEnum.Deleted) {
10816
- return '';
10817
- }
10818
- if (element instanceof TextGroupElement && !element.isDecorate) {
10379
+ createRenderObject() {
10380
+ const render = new SVGRenderObject(this);
10381
+ render.rect.width = this.props.width;
10382
+ render.rect.height = this.props.height;
10383
+ return render;
10384
+ }
10385
+ serialize(options) {
10386
+ return {
10387
+ type: 'svg',
10388
+ props: {
10389
+ ...this.props.getSerializeProps(options)
10390
+ }
10391
+ };
10392
+ }
10393
+ clone(data) {
10394
+ const clone = new SVGElement();
10395
+ this.props.clone(clone.props);
10396
+ return clone;
10397
+ }
10398
+ destroy() {
10399
+ super.destroy();
10400
+ }
10401
+ }
10402
+ class SVGRenderObject extends ResizeLeafRenderObject {
10403
+ clone() {
10404
+ const clone = new SVGRenderObject(this.element);
10405
+ clone.rect = ElementUtil.cloneRect(this.rect);
10406
+ return clone;
10407
+ }
10408
+ drawResizeCircle(ctx, x, y) {
10409
+ const ctxNative = ctx.contentContext.ctx;
10410
+ ctxNative.fillStyle = '#69c0ff';
10411
+ ctxNative.beginPath();
10412
+ ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
10413
+ ctxNative.closePath();
10414
+ ctxNative.fill();
10415
+ }
10416
+ exportHTML(event) {
10417
+ const props = this.element.props;
10418
+ const t = super.exportHTML(event);
10419
+ t.children = [{
10420
+ sel: 'svg',
10421
+ data: {
10422
+ ns: "http://www.w3.org/2000/svg",
10423
+ attrs: {
10424
+ width: this.rect.width,
10425
+ height: this.rect.height
10426
+ }
10427
+ },
10428
+ children: [{
10429
+ sel: 'image',
10430
+ data: {
10431
+ ns: "http://www.w3.org/2000/svg",
10432
+ attrs: {
10433
+ "xlink:href": props.value,
10434
+ width: Math.min(this.rect.width, this.rect.height),
10435
+ height: Math.min(this.rect.width, this.rect.height)
10436
+ }
10437
+ }
10438
+ }]
10439
+ }];
10440
+ //绘制拖动圆圈
10441
+ if (this.element.isFocused) {
10442
+ const { width, height } = this.rect;
10443
+ 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) }];
10444
+ circlePoints.forEach((p) => {
10445
+ t.children.push({
10446
+ sel: 'circle',
10447
+ data: {
10448
+ ns: "http://www.w3.org/2000/svg",
10449
+ attrs: {
10450
+ cx: p.x,
10451
+ cy: p.y,
10452
+ r: Math.floor(4 / 5 * 4),
10453
+ fill: '#69c0ff'
10454
+ }
10455
+ }
10456
+ });
10457
+ });
10458
+ }
10459
+ return t;
10460
+ }
10461
+ }
10462
+ class SVGFactory extends ElementFactory {
10463
+ match(type) {
10464
+ return type === 'svg';
10465
+ }
10466
+ createElement(data) {
10467
+ const props = data.props;
10468
+ const pic = new SVGElement();
10469
+ const picProps = pic.props;
10470
+ picProps.width = props.width;
10471
+ picProps.height = props.height;
10472
+ picProps.value = props.value;
10473
+ picProps.title = props.title;
10474
+ pic.props = picProps;
10475
+ return pic;
10476
+ }
10477
+ }
10478
+
10479
+ class ElementSerialize {
10480
+ /**
10481
+ * 将当前文档对象构建并输出到标准的JSON对象
10482
+ * @param element
10483
+ * @param viewOptions
10484
+ */
10485
+ static serialize(element, viewOptions) {
10486
+ const result = element.serialize(viewOptions);
10487
+ if (!result) {
10488
+ return null;
10489
+ }
10490
+ if (result.complete) {
10491
+ return result;
10492
+ }
10493
+ if (element instanceof BranchElement) {
10494
+ result.children = [];
10495
+ let prevEle = null;
10496
+ for (let i = 0; i < element.length; i++) {
10497
+ const child = element.getChild(i);
10498
+ const serializeChild = this.serialize(child, viewOptions);
10499
+ if (child.type === 'text' && prevEle && prevEle.ele.type === 'text') {
10500
+ if (child.props.equals(prevEle.ele.props)) {
10501
+ prevEle.props.content += serializeChild.content;
10502
+ continue;
10503
+ }
10504
+ }
10505
+ if (serializeChild) {
10506
+ delete serializeChild.complete;
10507
+ serializeChild.props = serializeChild.props || {};
10508
+ if (Object.keys(serializeChild.props).length === 0) {
10509
+ delete serializeChild.props;
10510
+ }
10511
+ if (serializeChild.children && serializeChild.children.length === 0) {
10512
+ delete serializeChild.children;
10513
+ }
10514
+ result.children.push(serializeChild);
10515
+ prevEle = { ele: child, props: serializeChild };
10516
+ }
10517
+ }
10518
+ }
10519
+ if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
10520
+ result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
10521
+ }
10522
+ return result;
10523
+ }
10524
+ static serializeString(element, options = { all: false }) {
10525
+ if (!options.all && element instanceof TrackRunElement && element.type === exports.TrackRunTypeEnum.Deleted) {
10526
+ return '';
10527
+ }
10528
+ if (element instanceof TextGroupElement && !element.isDecorate) {
10819
10529
  return element.text;
10820
10530
  }
10531
+ if (element instanceof PSymbolElement) {
10532
+ return '\n';
10533
+ }
10821
10534
  if (element instanceof BranchElement) {
10822
10535
  const items = [];
10823
10536
  for (let i = 0; i < element.length; i++) {
@@ -10968,32 +10681,6 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10968
10681
  constructor(ele) {
10969
10682
  super(ele);
10970
10683
  }
10971
- render(e) {
10972
- const { render, position, docCtx: { viewOptions } } = e;
10973
- render.tran(() => {
10974
- let fillColor = viewOptions.showTrackChanges ? this.element.type === 'ins-run' ? viewOptions.trackInsColor : viewOptions.trackDelColor : '';
10975
- if (fillColor) {
10976
- render.contentContext.ctx.fillStyle = fillColor;
10977
- }
10978
- e.nextRender();
10979
- });
10980
- const { x, y } = position;
10981
- //不显示痕迹
10982
- if (!viewOptions.showTrackChanges) {
10983
- return;
10984
- }
10985
- const color = this.element.type === 'ins-run' ? 'green' : 'red';
10986
- for (let i = 0; i < this.length; i++) {
10987
- const childRender = this.getChild(i);
10988
- const { rect } = childRender;
10989
- if (childRender.element && childRender.element.type === 'del-run') {
10990
- continue;
10991
- }
10992
- let lineY = y + rect.y + rect.height;
10993
- lineY = this.element.type === 'ins-run' ? lineY : lineY - rect.height / 2;
10994
- render.contentContext.drawHoriLine(x + rect.x, lineY, rect.width, color, 1);
10995
- }
10996
- }
10997
10684
  exportHTML(event) {
10998
10685
  const { options } = event;
10999
10686
  const t = super.exportHTML(event);
@@ -12556,9 +12243,9 @@ class ElementUtil {
12556
12243
  return this.getTextRenderOffset(render, x);
12557
12244
  }
12558
12245
  else {
12559
- if (render.element && render.element.type === 'psym') {
12560
- return 0;
12561
- }
12246
+ // if (render.element && render.element.type === 'psym') {
12247
+ // return 0;
12248
+ // }
12562
12249
  return (render.rect.width / 2) >= x ? 0 : 1;
12563
12250
  }
12564
12251
  }
@@ -13288,12 +12975,12 @@ class ElementPaint {
13288
12975
  }
13289
12976
  }
13290
12977
  });
13291
- docContainer.render({
13292
- render: this.renderCtx,
13293
- position: { x: docContainer.rect.x, y: docContainer.rect.y },
13294
- nextRender: nextRenderFn,
13295
- docCtx: this.docCtx
13296
- });
12978
+ // docContainer.render({
12979
+ // render: this.renderCtx,
12980
+ // position: { x: docContainer.rect.x, y: docContainer.rect.y },
12981
+ // nextRender: nextRenderFn,
12982
+ // docCtx: this.docCtx
12983
+ // })
13297
12984
  nextRenderFn();
13298
12985
  const { scale, viewSettings: { width, height } } = this.viewOptions;
13299
12986
  while (this.renderCtx.onRenderCompleted.subs.length > 0) {
@@ -13322,25 +13009,25 @@ class ElementPaint {
13322
13009
  this.drawRenderObject(child, currPosition, inViewPort);
13323
13010
  }
13324
13011
  });
13325
- const renderData = {
13012
+ ({
13326
13013
  position: currPosition,
13327
13014
  nextRender: nextRenderFn,
13328
13015
  render: this.renderCtx,
13329
13016
  docCtx: this.docCtx
13330
- };
13331
- renderObject.render(renderData);
13017
+ });
13018
+ //renderObject.render(renderData);
13332
13019
  nextRenderFn();
13333
13020
  }
13334
13021
  }
13335
13022
  else if (renderObject instanceof LeafRenderObject) {
13336
13023
  if (inViewPort) {
13337
- const renderData = {
13024
+ ({
13338
13025
  position: currPosition,
13339
13026
  nextRender: () => { },
13340
13027
  render: this.renderCtx,
13341
13028
  docCtx: this.docCtx
13342
- };
13343
- renderObject.render(renderData);
13029
+ });
13030
+ //renderObject.render(renderData);
13344
13031
  }
13345
13032
  }
13346
13033
  //处理选中拖蓝
@@ -13393,14 +13080,14 @@ class ElementPaint {
13393
13080
  * 触发页面绘制结束事件
13394
13081
  */
13395
13082
  invokedPagePaintCompleted(renderObject, parent) {
13396
- const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
13397
- const currPosition = { x: rx + parent.x, y: ry + parent.y };
13398
- renderObject.pagePaintCompleted({ render: this.renderCtx, position: currPosition, docCtx: this.docCtx });
13399
- if (renderObject instanceof BranchRenderObject) {
13400
- for (let i = 0; i < renderObject.length; i++) {
13401
- this.invokedPagePaintCompleted(renderObject.getChild(i), currPosition);
13402
- }
13403
- }
13083
+ // const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
13084
+ // const currPosition = { x: rx + parent.x, y: ry + parent.y };
13085
+ // renderObject.pagePaintCompleted({ render: this.renderCtx, position: currPosition, docCtx: this.docCtx })
13086
+ // if (renderObject instanceof BranchRenderObject) {
13087
+ // for (let i = 0; i < renderObject.length; i++) {
13088
+ // this.invokedPagePaintCompleted(renderObject.getChild(i), currPosition);
13089
+ // }
13090
+ // }
13404
13091
  }
13405
13092
  static drawPage(renderCtx, docCtx, renderObject, parent) {
13406
13093
  const { x: rx, y: ry } = renderObject.rect;
@@ -13412,24 +13099,9 @@ class ElementPaint {
13412
13099
  this.drawPage(renderCtx, docCtx, child, currPosition);
13413
13100
  }
13414
13101
  });
13415
- const renderData = {
13416
- position: currPosition,
13417
- nextRender: nextRenderFn,
13418
- render: renderCtx,
13419
- docCtx
13420
- };
13421
- renderObject.render(renderData);
13102
+ //renderObject.render(renderData);
13422
13103
  nextRenderFn();
13423
13104
  }
13424
- else if (renderObject instanceof LeafRenderObject) {
13425
- const renderData = {
13426
- position: currPosition,
13427
- nextRender: () => { },
13428
- render: renderCtx,
13429
- docCtx: docCtx
13430
- };
13431
- renderObject.render(renderData);
13432
- }
13433
13105
  }
13434
13106
  }
13435
13107
 
@@ -14993,10 +14665,11 @@ class DocumentArrange {
14993
14665
  let currRow = rows[j];
14994
14666
  const cutRows = [];
14995
14667
  while (currRow) {
14668
+ const minHeight = currRow.element.props.minHeight;
14996
14669
  const rowContentHeight = this.getBlockLineHeight(currRow);
14997
14670
  if (rowContentHeight + sumHeight > limitHeight) {
14998
- //行存在最小高度,且当前行跨页的情况下,不截断该行
14999
- if (currRow.element.props.minHeight) {
14671
+ //行存在最小高度,且当前行内容的高度小于最小高度,且当前行跨页的情况下,不截断该行
14672
+ if (minHeight > 0 && minHeight > rowContentHeight) {
15000
14673
  break;
15001
14674
  }
15002
14675
  //限制的外框尺寸
@@ -15871,539 +15544,52 @@ class ElementMeasure {
15871
15544
  }
15872
15545
  }
15873
15546
 
15874
- class ElementRenderCut {
15875
- options;
15547
+ class DocumentPaint {
15876
15548
  renderContext;
15877
- constructor(options, renderContext) {
15878
- this.options = options;
15549
+ docCtx;
15550
+ seo;
15551
+ elementMeasure;
15552
+ //elementRenderCut: ElementRenderCut;
15553
+ elementPaint;
15554
+ docPages;
15555
+ docContainer;
15556
+ //commsContainer!: CommsContainerRenderObject;
15557
+ viewOptions;
15558
+ constructor(renderContext, docCtx, seo) {
15879
15559
  this.renderContext = renderContext;
15560
+ this.docCtx = docCtx;
15561
+ this.seo = seo;
15562
+ this.viewOptions = this.docCtx.viewOptions;
15563
+ this.elementMeasure = new ElementMeasure(this.docCtx, this.renderContext);
15564
+ //this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
15565
+ this.elementPaint = new ElementPaint(this.renderContext, this.docCtx);
15880
15566
  }
15881
- cutPage(documentRender, documentElement) {
15882
- if (this.options.fullPageView) {
15883
- return this.getFullViewDocRender(documentRender, documentElement);
15884
- }
15885
- const headerRender = documentRender.getChild(0);
15886
- const bodyRender = documentRender.getChild(1).clone();
15887
- const footerRender = documentRender.getChild(2);
15888
- const commentsRender = documentRender.getChild(3);
15889
- const { headerLine, footerLine } = documentRender;
15890
- let bodyMarginTop = headerLine + headerRender.rect.height + 6;
15891
- let bodyMarginBottom = footerLine + footerRender.rect.height;
15892
- const { top: bodyTop, bottom: bodyBottom } = documentRender.padding;
15893
- bodyMarginTop = bodyMarginTop > bodyTop ? bodyMarginTop : bodyTop;
15894
- bodyMarginBottom = bodyMarginBottom > bodyBottom ? bodyMarginBottom : bodyBottom;
15895
- documentRender.padding.top = bodyMarginTop;
15896
- documentRender.padding.bottom = bodyMarginBottom;
15897
- const bodyLimitRect = this.getDocInnerRect(documentRender);
15898
- const bodyArray = [];
15899
- let { emptyBody: pageBodyRender, innerRect: bodyInnerLimitRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
15900
- bodyArray.push(pageBodyRender);
15901
- const createBodyHolder = () => {
15902
- const { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
15903
- pageBodyRender = emptyBody;
15904
- bodyInnerLimitRect = innerRect;
15905
- bodyArray.push(pageBodyRender);
15906
- };
15907
- const appendToBody = (item) => {
15908
- item.rect.y = bodyInnerLimitRect.height + item.margin.top;
15909
- pageBodyRender.addChild(item);
15910
- bodyInnerLimitRect.height += item.rect.height + item.margin.top + item.margin.bottom;
15911
- //上一个元素的bottom-margin
15912
- //bodyInnerLimitRect.prevMargin = item.margin.bottom;
15913
- ElementUtil.updateRenderHeightByInnerRect(pageBodyRender, bodyInnerLimitRect);
15914
- };
15915
- let i = 0;
15916
- let cloneBlockContentRender = bodyRender.getChild(i);
15917
- while (cloneBlockContentRender) {
15918
- if (bodyInnerLimitRect.maxHeight - bodyInnerLimitRect.height - cloneBlockContentRender.rect.height - cloneBlockContentRender.margin.bottom - cloneBlockContentRender.margin.top < 0) {
15919
- //限制的外框尺寸
15920
- const bodyAvailHeight = bodyInnerLimitRect.maxHeight - bodyInnerLimitRect.height - cloneBlockContentRender.margin.bottom - cloneBlockContentRender.margin.top;
15921
- //限制的内框尺寸
15922
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(cloneBlockContentRender, bodyAvailHeight);
15923
- const cutRenderObject = this.cutRenderItem(cloneBlockContentRender, limitRenderInnterHeight);
15924
- //至少有一个块级行元素被切割出来
15925
- if (cutRenderObject) {
15926
- appendToBody(cutRenderObject);
15927
- }
15928
- createBodyHolder();
15929
- }
15930
- else {
15931
- appendToBody(cloneBlockContentRender);
15932
- if (++i < bodyRender.length) {
15933
- cloneBlockContentRender = bodyRender.getChild(i);
15934
- }
15935
- else {
15936
- cloneBlockContentRender = null;
15937
- }
15938
- }
15939
- }
15940
- const docPages = [];
15941
- let pageY = this.options.docSpace;
15942
- for (let i = 0; i < bodyArray.length; i++) {
15943
- const body = bodyArray[i];
15944
- const documentRender = documentElement.createRenderObject();
15945
- docPages.push(documentRender);
15946
- documentRender.rect.y = pageY;
15947
- const limitRect = documentRender.getInnerRect();
15948
- const cloneHeaderRender = headerRender.clone();
15949
- cloneHeaderRender.rect.x = limitRect.x;
15950
- cloneHeaderRender.rect.y = headerLine;
15951
- documentRender.addChild(cloneHeaderRender);
15952
- body.rect.x = limitRect.x;
15953
- body.rect.y = bodyMarginTop;
15954
- body.rect.height = bodyInnerLimitRect.maxHeight;
15955
- documentRender.addChild(body);
15956
- pageY += documentRender.rect.height + this.options.docSpace;
15957
- const cloneFooterRender = footerRender.clone();
15958
- cloneFooterRender.rect.x = limitRect.x;
15959
- cloneFooterRender.rect.y = documentRender.rect.height - bodyMarginBottom;
15960
- documentRender.addChild(cloneFooterRender);
15961
- //审阅模式,添加审阅窗口
15962
- if (this.options.showReviewWindow && commentsRender) {
15963
- const commentsContainer = commentsRender.element.createRenderObject({
15964
- options: this.options,
15965
- renderCtx: this.renderContext
15966
- });
15967
- commentsContainer.padding.top = bodyMarginTop;
15968
- commentsContainer.rect.height = documentRender.rect.height;
15969
- documentRender.addChild(commentsContainer);
15970
- commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
15971
- documentRender.rect.width += this.options.reviewWindowWidth;
15972
- }
15567
+ rePages() {
15568
+ if (!this.docCtx.document.length) {
15569
+ return;
15973
15570
  }
15974
- return docPages;
15975
- }
15976
- getDocInnerRect(documentRender) {
15977
- const render = documentRender.element.createRenderObject({
15978
- options: this.options,
15979
- renderCtx: this.renderContext
15980
- });
15981
- render.padding = documentRender.padding;
15982
- return render.getInnerRect();
15983
- }
15984
- getFullViewDocRender(documentRender, documentElement) {
15985
- const commentsRender = documentRender.getChild(3);
15986
- const commentsContainer = commentsRender.element.createRenderObject({
15987
- options: this.options,
15988
- renderCtx: this.renderContext
15989
- });
15990
- documentRender.rect.height -= commentsContainer.rect.height;
15991
- const bodyRender = documentRender.getChild(1);
15992
- if (this.options.showReviewWindow) {
15993
- documentRender.removeChild(commentsRender);
15994
- documentRender.addChild(commentsContainer);
15995
- commentsContainer.padding.top = bodyRender.rect.y;
15996
- commentsContainer.rect.height = documentRender.rect.height;
15997
- commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
15998
- documentRender.rect.width += this.options.reviewWindowWidth;
15999
- }
16000
- return [documentRender];
16001
- }
16002
- createEmptyBodyRender(bodyRender, limitRect) {
16003
- const pageBodyRender = bodyRender.element.createRenderObject({
16004
- options: this.options,
16005
- renderCtx: this.renderContext
16006
- });
16007
- pageBodyRender.rect.width = limitRect.width;
16008
- const bodyInnerLimitRect = pageBodyRender.getInnerRect();
16009
- if (this.options.fullPageView) {
16010
- bodyInnerLimitRect.height = Number.MAX_VALUE;
16011
- }
16012
- return {
16013
- emptyBody: pageBodyRender,
16014
- innerRect: { ...bodyInnerLimitRect, prevMargin: 0, maxWidth: limitRect.width, maxHeight: limitRect.height }
16015
- };
16016
- }
16017
- /**
16018
- * 切割渲染元素
16019
- * @param render 被切割的对象
16020
- * @param limitHeight
16021
- * @returns
16022
- */
16023
- cutRenderItem(render, limitHeight) {
16024
- if (render instanceof TableRowRenderObject) {
16025
- return this.cutRowRenderItem(render, limitHeight);
16026
- }
16027
- if (render instanceof TableRenderObject) {
16028
- return this.cutTable(render, limitHeight);
16029
- }
16030
- const cloneRender = render.element.createRenderObject({
16031
- options: this.options,
16032
- renderCtx: this.renderContext
16033
- });
16034
- cloneRender.setRenderWidth(render.rect.width);
16035
- if (render instanceof MuiltBlockLineRenderObject) {
16036
- let sumHeight = 0;
16037
- const children = [...render.getItems()];
16038
- let j = 0;
16039
- let blockLine = children[j];
16040
- while (blockLine) {
16041
- //sumHeight = ElementUtil.remeasure(cloneRender);
16042
- const calcBlockLineHeight = this.getBlockLineHeight(blockLine);
16043
- if (calcBlockLineHeight + sumHeight > limitHeight) {
16044
- if (blockLine instanceof MuiltBlockLineRenderObject) {
16045
- //限制的外框尺寸
16046
- const availHeight = limitHeight - sumHeight;
16047
- //限制的内框尺寸
16048
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(render, availHeight);
16049
- const cutRenderObject = this.cutRenderItem(blockLine, limitRenderInnterHeight);
16050
- if (cutRenderObject) {
16051
- cloneRender.addChild(cutRenderObject);
16052
- sumHeight += cutRenderObject.rect.height;
16053
- blockLine = children[++j];
16054
- break;
16055
- }
16056
- else {
16057
- break;
16058
- }
16059
- }
16060
- else {
16061
- break;
16062
- }
16063
- }
16064
- else {
16065
- render.removeChild(blockLine);
16066
- cloneRender.addChild(blockLine);
16067
- sumHeight += blockLine.rect.height;
16068
- blockLine = children[++j];
16069
- }
16070
- }
16071
- ElementUtil.remeasure(cloneRender);
16072
- ElementUtil.remeasure(render);
16073
- if (cloneRender.length === 0) {
16074
- return null;
16075
- }
16076
- else {
16077
- return cloneRender;
16078
- }
16079
- }
16080
- else {
16081
- throw new Error('未实现');
16082
- }
16083
- }
16084
- /**
16085
- * 切割渲染元素
16086
- * @param tbRender 被切割的对象
16087
- * @param limitHeight
16088
- * @param addFunc
16089
- * @returns
16090
- */
16091
- cutTable(tbRender, limitHeight) {
16092
- const cloneTbRender = tbRender.element.createRenderObject();
16093
- cloneTbRender.setRenderWidth(tbRender.rect.width);
16094
- let sumHeight = 0;
16095
- const rows = [...tbRender.getItems()];
16096
- //获取跨页需要重复显示的行
16097
- const headerRows = this.getHeaderRows(tbRender);
16098
- //跨页头的高度
16099
- const headerHeight = headerRows.reduce((prev, curr) => prev + curr.rect.height, 0);
16100
- if (headerHeight > limitHeight) {
16101
- return null;
16102
- }
16103
- const copyHeaderRows = headerRows.map(item => item.clone());
16104
- //获取最后一个截断行,需要根据截断行判断最后一个截断的行位置
16105
- const cutOffRows = rows.filter(row => limitHeight >= row.rect.y && limitHeight <= row.rect.y + row.rect.height)
16106
- .map((row) => ({ rowIndex: row.element.getIndex(), row }))
16107
- .sort((first, second) => second.rowIndex - first.rowIndex);
16108
- if (cutOffRows.length === 0) {
16109
- throw new Error('无法获取截断行');
16110
- }
16111
- const joinRow = cutOffRows[0].row;
16112
- let j = 0;
16113
- let currRow = rows[j];
16114
- const cutRows = [];
16115
- while (currRow) {
16116
- const rowContentHeight = this.getBlockLineHeight(currRow);
16117
- if (rowContentHeight + sumHeight > limitHeight) {
16118
- if (currRow instanceof MuiltBlockLineRenderObject) {
16119
- //限制的外框尺寸
16120
- const availHeight = limitHeight - sumHeight;
16121
- //限制的内框尺寸
16122
- const limitRenderInnterHeight = ElementUtil.innerRectMaxHeight(tbRender, availHeight);
16123
- const cutRow = this.cutRowRenderItem(currRow, limitRenderInnterHeight);
16124
- if (cutRow) {
16125
- cloneTbRender.addChild(cutRow);
16126
- sumHeight += cutRow.rect.height;
16127
- cutRows.push(currRow);
16128
- if (currRow === joinRow) {
16129
- break;
16130
- }
16131
- currRow = rows[++j];
16132
- }
16133
- else {
16134
- break;
16135
- }
16136
- }
16137
- else {
16138
- break;
16139
- }
16140
- }
16141
- else {
16142
- tbRender.removeChild(currRow);
16143
- cloneTbRender.addChild(currRow);
16144
- sumHeight += currRow.rect.height;
16145
- currRow = rows[++j];
16146
- }
16147
- }
16148
- this.fixCutTable(tbRender, cutRows);
16149
- ElementUtil.remeasure(cloneTbRender);
16150
- //存在跨页需要重复显示的行头,则需要重新放置行头
16151
- if (copyHeaderRows.length) {
16152
- copyHeaderRows.forEach((r, i) => tbRender.insertChild(r, i));
16153
- }
16154
- ElementUtil.remeasure(tbRender);
16155
- if (cloneTbRender.length === 0) {
16156
- return null;
16157
- }
16158
- else {
16159
- return cloneTbRender;
16160
- }
16161
- }
16162
- cutRowRenderItem(render, limitHeight) {
16163
- if (render.element.props.minHeight > 0 && render.rect.height > limitHeight) {
16164
- return null;
16165
- }
16166
- const cloneRowRender = render.element.createRenderObject();
16167
- cloneRowRender.rect.width = render.rect.width;
16168
- render.remeasureState = true;
16169
- //cloneRowRender.rect.maxWidth = render.rect.height;
16170
- const cellRenders = [...render.getItems()];
16171
- const cutCellRenders = [];
16172
- for (let i = 0; i < cellRenders.length; i++) {
16173
- const cellRender = cellRenders[i];
16174
- this.markMergeRowRenderDirty(cellRender);
16175
- if (cellRender.rect.height > limitHeight) {
16176
- //限制的内框尺寸
16177
- const limitCellHeight = ElementUtil.innerRectMaxHeight(cellRender, limitHeight);
16178
- const cutCellRender = this.cutRenderItem(cellRender, limitCellHeight);
16179
- if (cutCellRender) {
16180
- cutCellRenders.push(cutCellRender);
16181
- }
16182
- else {
16183
- cutCellRenders.push(null);
16184
- }
16185
- }
16186
- else {
16187
- const cloneCellRender = cellRender;
16188
- render.removeChild(cellRender);
16189
- cutCellRenders.push(cloneCellRender);
16190
- }
16191
- }
16192
- ElementUtil.remeasure(render);
16193
- if (cutCellRenders.filter(item => item).length === 0) {
16194
- return null;
16195
- }
16196
- else {
16197
- //补齐单元格
16198
- for (let i = 0; i < cutCellRenders.length; i++) {
16199
- let cellRender = cutCellRenders[i];
16200
- if (!cellRender) {
16201
- cellRender = cellRenders[i].element.createRenderObject({
16202
- options: this.options,
16203
- renderCtx: this.renderContext
16204
- });
16205
- cellRender.rect = ElementUtil.cloneRect(cellRenders[i].rect);
16206
- ElementUtil.remeasure(cellRender);
16207
- }
16208
- cloneRowRender.addChild(cellRender);
16209
- }
16210
- ElementUtil.remeasure(cloneRowRender);
16211
- return cloneRowRender;
16212
- }
16213
- }
16214
- /**
16215
- * 标记合并单元格所在行需要重新计算
16216
- * @param cellRender
16217
- * @private
16218
- */
16219
- markMergeRowRenderDirty(cellRender) {
16220
- const cellEle = cellRender.element;
16221
- if (cellEle.props.vMerge !== 'restart') {
16222
- return;
16223
- }
16224
- const rowRender = cellRender.parent;
16225
- rowRender.element;
16226
- const tb = rowRender.parent;
16227
- const cellYPos = cellRender.rect.y;
16228
- for (let i = rowRender.getIndex() + 1; i < tb.length; i++) {
16229
- const nextRowRender = tb.getChild(i);
16230
- if (nextRowRender.rect.y <= cellYPos) {
16231
- nextRowRender.remeasureState = true;
16232
- nextRowRender.getItems().forEach(item => {
16233
- this.markMergeRowRenderDirty(item);
16234
- });
16235
- }
16236
- else {
16237
- break;
16238
- }
16239
- }
16240
- }
16241
- /**
16242
- * 修复->已经截断的合并单元格要向下移动到合适的位置
16243
- * @param tbRender
16244
- * @param cutRows
16245
- * @returns
16246
- */
16247
- fixCutTable(tbRender, cutRows) {
16248
- if (!cutRows.length) {
16249
- return;
16250
- }
16251
- const tbEle = tbRender.element;
16252
- const belowMergeRows = new Set();
16253
- for (let i = 0; i < tbRender.length; i++) {
16254
- const row = tbRender.getChild(i);
16255
- const nextRow = tbRender.getChild(i + 1);
16256
- if (!nextRow) {
16257
- break;
16258
- }
16259
- if (!cutRows.some(item => item === row)) {
16260
- break;
16261
- }
16262
- if (row.length === tbEle.getColsCount()) {
16263
- break;
16264
- }
16265
- if (this.checkFullRow(row)) {
16266
- break;
16267
- }
16268
- for (let j = 0; j < row.length; j++) {
16269
- const cell = row.getChild(j);
16270
- const cellEle = cell.element;
16271
- const colIndex = cellEle.getIndex();
16272
- if (!this.existsCellRender(nextRow, colIndex)) {
16273
- const insertColIndex = this.getRowInsertCellIndex(cell, nextRow);
16274
- if (insertColIndex === -1) {
16275
- this.getRowInsertCellIndex(cell, nextRow);
16276
- throw new Error('未在紧挨下方找到可以放置的位置');
16277
- }
16278
- //row.removeChild(cell);
16279
- nextRow.insertChild(cell, insertColIndex);
16280
- belowMergeRows.add(row);
16281
- ElementUtil.remeasure(nextRow);
16282
- }
16283
- }
16284
- }
16285
- if (belowMergeRows.size) {
16286
- for (const row of belowMergeRows) {
16287
- tbRender.removeChild(row);
16288
- row.clear();
16289
- }
16290
- ElementUtil.remeasure(tbRender);
16291
- }
16292
- }
16293
- /**
16294
- * 校验当前是否是一个完整的行,没有Null单元格,检查当前是否还需要向下合并
16295
- * @param row
16296
- */
16297
- checkFullRow(row) {
16298
- let x = 0;
16299
- for (let i = 0; i < row.length; i++) {
16300
- const cell = row.getChild(i);
16301
- if (cell.rect.x !== x) {
16302
- return false;
16303
- }
16304
- x += cell.rect.width;
16305
- }
16306
- return x === row.rect.width;
16307
- }
16308
- existsCellRender(rowRender, cellIndex) {
16309
- for (let i = 0; i < rowRender.length; i++) {
16310
- const cellRender = rowRender.getChild(i);
16311
- const cellEle = cellRender.element;
16312
- if (cellEle.getIndex() === cellIndex) {
16313
- return true;
16314
- }
16315
- }
16316
- return false;
16317
- }
16318
- getBlockLineHeight(render) {
16319
- if (render instanceof TableRowRenderObject) {
16320
- let maxCellHeight = 0;
16321
- for (let i = 0; i < render.length; i++) {
16322
- const itemHeight = render.getChild(i).rect.height;
16323
- if (itemHeight > maxCellHeight) {
16324
- maxCellHeight = itemHeight;
16325
- }
16326
- }
16327
- return maxCellHeight;
16328
- }
16329
- return render.rect.height;
16330
- }
16331
- getRowInsertCellIndex(sourceCell, destRow) {
16332
- for (let i = 0; i < destRow.length; i++) {
16333
- const cell = destRow.getChild(i);
16334
- const rect = cell.rect;
16335
- if (sourceCell.rect.x < rect.x) {
16336
- return i;
16337
- }
16338
- }
16339
- const lastCell = destRow.getChild(destRow.length - 1);
16340
- if (sourceCell.rect.x >= lastCell.rect.x + lastCell.rect.width) {
16341
- return destRow.length;
16342
- }
16343
- return -1;
16344
- }
16345
- getHeaderRows(tb) {
16346
- const rows = [];
16347
- for (let i = 0; i < tb.length; i++) {
16348
- const rowRender = tb.getChild(i);
16349
- const rowEle = rowRender.element;
16350
- if (rowEle.props.headerRow) {
16351
- rows.push(rowRender);
16352
- }
16353
- else {
16354
- break;
16355
- }
16356
- }
16357
- return rows;
16358
- }
16359
- }
16360
-
16361
- class DocumentPaint {
16362
- renderContext;
16363
- docCtx;
16364
- seo;
16365
- elementMeasure;
16366
- elementRenderCut;
16367
- elementPaint;
16368
- docPages;
16369
- docContainer;
16370
- //commsContainer!: CommsContainerRenderObject;
16371
- viewOptions;
16372
- constructor(renderContext, docCtx, seo) {
16373
- this.renderContext = renderContext;
16374
- this.docCtx = docCtx;
16375
- this.seo = seo;
16376
- this.viewOptions = this.docCtx.viewOptions;
16377
- this.elementMeasure = new ElementMeasure(this.docCtx, this.renderContext);
16378
- this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
16379
- this.elementPaint = new ElementPaint(this.renderContext, this.docCtx);
16380
- }
16381
- rePages() {
16382
- if (!this.docCtx.document.length) {
16383
- return;
16384
- }
16385
- this.docContainer = new DocumentContainerRender();
16386
- this.docCtx.selectionState.renderContainer = this.docContainer;
16387
- this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
16388
- // console.time('排版计时');
16389
- // const documentRender = this.elementMeasure.measureDocument(this.docCtx.document);
16390
- // this.commsContainer = documentRender.getChild(3) as CommsContainerRenderObject;
16391
- // if (this.commsContainer) {
16392
- // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
16393
- // }
16394
- // //console.timeEnd('排版计时');
16395
- // //console.time('断页计时');
16396
- // const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
16397
- const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
16398
- const docPages = newMeasure.measureDoc();
16399
- // this.commsContainer = newMeasure.commentsRender as CommsContainerRenderObject;
16400
- // if (this.commsContainer) {
16401
- // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
16402
- // }
16403
- //console.timeEnd('断页计时');
16404
- this.setCommRangeMark();
16405
- this.docPages = docPages;
16406
- this.layoutPages();
15571
+ this.docContainer = new DocumentContainerRender();
15572
+ this.docCtx.selectionState.renderContainer = this.docContainer;
15573
+ this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
15574
+ // console.time('排版计时');
15575
+ // const documentRender = this.elementMeasure.measureDocument(this.docCtx.document);
15576
+ // this.commsContainer = documentRender.getChild(3) as CommsContainerRenderObject;
15577
+ // if (this.commsContainer) {
15578
+ // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
15579
+ // }
15580
+ // //console.timeEnd('排版计时');
15581
+ // //console.time('断页计时');
15582
+ // const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
15583
+ const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
15584
+ const docPages = newMeasure.measureDoc();
15585
+ // this.commsContainer = newMeasure.commentsRender as CommsContainerRenderObject;
15586
+ // if (this.commsContainer) {
15587
+ // this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
15588
+ // }
15589
+ //console.timeEnd('断页计时');
15590
+ this.setCommRangeMark();
15591
+ this.docPages = docPages;
15592
+ this.layoutPages();
16407
15593
  }
16408
15594
  /**
16409
15595
  * 文档页面显示布局
@@ -16569,8 +15755,6 @@ class PermanentTeethElement extends LeafElement {
16569
15755
  }
16570
15756
  }
16571
15757
  class PermanentTeethRenderObject extends LeafRenderObject {
16572
- render(e) {
16573
- }
16574
15758
  clone() {
16575
15759
  const clone = new PermanentTeethRenderObject(this.element);
16576
15760
  clone.rect = ElementUtil.cloneRect(this.rect);
@@ -16702,6 +15886,7 @@ class ElementReader {
16702
15886
  this.addFactory(PageBreakFactory);
16703
15887
  this.addFactory(TabFactory);
16704
15888
  this.addFactory(PermanentTeethFactory);
15889
+ this.addFactory(SVGFactory);
16705
15890
  // this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
16706
15891
  // const props = new TrackRunProps(data.type);
16707
15892
  // props.userId = data.userId;
@@ -17842,7 +17027,10 @@ class DocumentEvent {
17842
17027
  if (renderObject instanceof LeafRenderObject) {
17843
17028
  if (CommonUtil.isInsideRectByPosition(renderObjectRect, hitPos)) {
17844
17029
  const x = hitPos.x - renderObjectRect.x;
17845
- const offset = ElementUtil.getHitRenderOffset(renderObject, x);
17030
+ let offset = ElementUtil.getHitRenderOffset(renderObject, x);
17031
+ if (!this.ismousedown && renderObject.element && renderObject.element.type === 'psym') {
17032
+ offset = 0;
17033
+ }
17846
17034
  return {
17847
17035
  render: renderObject,
17848
17036
  offset,
@@ -17934,7 +17122,10 @@ class DocumentEvent {
17934
17122
  else {
17935
17123
  x = position.x - adjacentRender.rect.x;
17936
17124
  }
17937
- const offset = ElementUtil.getHitRenderOffset(adjacentRender.render, x);
17125
+ let offset = ElementUtil.getHitRenderOffset(adjacentRender.render, x);
17126
+ if (!this.ismousedown && renderObject.element && renderObject.element.type === 'psym') {
17127
+ offset = 0;
17128
+ }
17938
17129
  return {
17939
17130
  render: adjacentRender.render,
17940
17131
  absoluteRenderRect: adjacentRender.rect,
@@ -18024,6 +17215,7 @@ class DocumentEvent {
18024
17215
  startHitInfo: this.startHitInfo,
18025
17216
  endHitInfo: this.endHitInfo
18026
17217
  });
17218
+ console.log(this.endHitInfo);
18027
17219
  }
18028
17220
  /**
18029
17221
  * 获取鼠标所在的渲染元素对象
@@ -28956,7 +28148,7 @@ class DocEditor {
28956
28148
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28957
28149
  }
28958
28150
  version() {
28959
- return "2.1.19";
28151
+ return "2.1.20";
28960
28152
  }
28961
28153
  switchPageHeaderEditor() {
28962
28154
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -28964,7 +28156,7 @@ class DocEditor {
28964
28156
  getTextContent() {
28965
28157
  const paras = this.docCtx.document.treeFilter(item => item instanceof ParagraphElement);
28966
28158
  const paraTexts = paras.map(item => ElementSerialize.serializeString(item, { all: false }));
28967
- return paraTexts.join('\n');
28159
+ return paraTexts.join('');
28968
28160
  }
28969
28161
  emit(event, args) {
28970
28162
  this.eventBus.emit(event, args);
@@ -29311,6 +28503,10 @@ exports.RenderContext = RenderContext;
29311
28503
  exports.RenderObject = RenderObject;
29312
28504
  exports.ResizeLeafRenderObject = ResizeLeafRenderObject;
29313
28505
  exports.RunElementFactory = RunElementFactory;
28506
+ exports.SVGElement = SVGElement;
28507
+ exports.SVGFactory = SVGFactory;
28508
+ exports.SVGProps = SVGProps;
28509
+ exports.SVGRenderObject = SVGRenderObject;
29314
28510
  exports.SelectionOverlays = SelectionOverlays;
29315
28511
  exports.SelectionRange = SelectionRange;
29316
28512
  exports.SelectionState = SelectionState;