@hailin-zheng/editor-core 2.1.28 → 2.2.0

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 (74) hide show
  1. package/editor.css +17 -3
  2. package/index-cjs.d.ts +12 -12
  3. package/index-cjs.js +574 -1074
  4. package/index-cjs.js.map +1 -1
  5. package/index.d.ts +12 -12
  6. package/index.js +594 -1093
  7. package/index.js.map +1 -1
  8. package/med_editor/doc-editor.d.ts +10 -6
  9. package/med_editor/doc-rule.d.ts +1 -1
  10. package/med_editor/editor-core.d.ts +1 -1
  11. package/med_editor/framework/{document-eval-func.d.ts → code-interpreter/document-eval-func.d.ts} +1 -1
  12. package/med_editor/framework/{dynamic-execute.d.ts → code-interpreter/dynamic-execute.d.ts} +3 -3
  13. package/med_editor/framework/{document-arrange.d.ts → doc-layout/document-arrange.d.ts} +7 -12
  14. package/med_editor/framework/{paragraph-arrange.d.ts → doc-layout/paragraph-arrange.d.ts} +5 -5
  15. package/med_editor/framework/document-change.d.ts +1 -1
  16. package/med_editor/framework/document-context.d.ts +5 -12
  17. package/med_editor/framework/document-event.d.ts +3 -14
  18. package/med_editor/framework/document-input-cursor.d.ts +1 -1
  19. package/med_editor/framework/document-paginator.d.ts +1 -7
  20. package/med_editor/framework/document-svg.d.ts +12 -8
  21. package/med_editor/framework/element-define.d.ts +3 -9
  22. package/med_editor/framework/element-event-define.d.ts +2 -2
  23. package/med_editor/framework/element-props.d.ts +1 -1
  24. package/med_editor/framework/element-serialize.d.ts +1 -1
  25. package/med_editor/framework/{element-trace-manage.d.ts → history/element-trace-manage.d.ts} +3 -2
  26. package/med_editor/framework/{element-trace-tracking.d.ts → history/element-trace-tracking.d.ts} +2 -2
  27. package/med_editor/framework/impl/document/doc-impl.d.ts +1 -11
  28. package/med_editor/framework/impl/index.d.ts +0 -1
  29. package/med_editor/framework/impl/table/table-split-cell.d.ts +1 -1
  30. package/med_editor/framework/impl/table/table-util.d.ts +1 -1
  31. package/med_editor/framework/impl/text/track-run-impl.d.ts +2 -2
  32. package/med_editor/framework/{document-print-offscreen.d.ts → print/document-print-offscreen.d.ts} +8 -8
  33. package/med_editor/framework/{document-print.d.ts → print/document-print.d.ts} +1 -1
  34. package/med_editor/framework/{document-selection.d.ts → selection/document-selection.d.ts} +5 -5
  35. package/med_editor/framework/{range-util.d.ts → selection/range-util.d.ts} +2 -2
  36. package/med_editor/framework/{selection-overlays.d.ts → selection/selection-overlays.d.ts} +1 -1
  37. package/med_editor/framework/util/adjust-viewport-elements.d.ts +12 -0
  38. package/med_editor/framework/{common-util.d.ts → util/common-util.d.ts} +2 -2
  39. package/med_editor/framework/{document-segmenter.d.ts → util/document-segmenter.d.ts} +1 -1
  40. package/med_editor/framework/{element-util.d.ts → util/element-util.d.ts} +13 -12
  41. package/med_editor/framework/{editor-calendar-vnode.d.ts → vnode/editor-calendar-vnode.d.ts} +4 -4
  42. package/package.json +2 -2
  43. package/controls/ButtonBase.d.ts +0 -10
  44. package/controls/Canvas.d.ts +0 -7
  45. package/controls/Config.d.ts +0 -12
  46. package/controls/FlexBox.d.ts +0 -81
  47. package/controls/Input.d.ts +0 -33
  48. package/controls/MedTimeLine/TimeAxis.d.ts +0 -21
  49. package/controls/MedTimeLine/TimeSlider.d.ts +0 -19
  50. package/controls/Menu.d.ts +0 -31
  51. package/controls/Node.d.ts +0 -232
  52. package/controls/NodeEvent.d.ts +0 -138
  53. package/controls/Rect.d.ts +0 -4
  54. package/controls/ScrollView.d.ts +0 -57
  55. package/controls/StackPanel.d.ts +0 -27
  56. package/controls/SurfaceView.d.ts +0 -44
  57. package/controls/Text.d.ts +0 -46
  58. package/controls/TextBase.d.ts +0 -19
  59. package/controls/ViewPaint.d.ts +0 -64
  60. package/controls/Window.d.ts +0 -27
  61. package/controls/WrapPanel.d.ts +0 -10
  62. package/controls/event-subject.d.ts +0 -42
  63. package/med_editor/framework/impl/comments/comments-util.d.ts +0 -5
  64. package/med_editor/rule-control.d.ts +0 -66
  65. package/timeline/TimeLineControl.d.ts +0 -47
  66. package/timeline/TimeValueGridControl.d.ts +0 -106
  67. package/timeline/TimelineConfig.d.ts +0 -68
  68. package/timeline/TimelineScrollbar.d.ts +0 -25
  69. package/timeline/TimelineStatus.d.ts +0 -61
  70. package/timeline/TimelineTick.d.ts +0 -63
  71. package/timeline/example.d.ts +0 -2
  72. /package/med_editor/framework/{ast-parser.d.ts → code-interpreter/ast-parser.d.ts} +0 -0
  73. /package/med_editor/framework/{event-subject.d.ts → infrastructure/event-subject.d.ts} +0 -0
  74. /package/med_editor/framework/{notify.d.ts → infrastructure/notify.d.ts} +0 -0
package/index-cjs.js CHANGED
@@ -980,7 +980,7 @@ function getExactDiffProps(oldProps, newProps) {
980
980
  });
981
981
  return obj;
982
982
  }
983
- function generatePatch(doc) {
983
+ function generatePatch(doc, clear = true) {
984
984
  const insertOpsMap = new Map();
985
985
  const formatOpsMap = new Map();
986
986
  const patches = [];
@@ -1006,6 +1006,9 @@ function generatePatch(doc) {
1006
1006
  }
1007
1007
  formatOpsMap.set(ele, op);
1008
1008
  }
1009
+ if ('insert' in op.ops) {
1010
+ insertOpsMap.set(ele, op);
1011
+ }
1009
1012
  // if ('insert' in op.ops) {
1010
1013
  // op.ops.insert = ele.clone(true);
1011
1014
  // const log = getOpsLog(ele, op.ops);
@@ -1013,17 +1016,17 @@ function generatePatch(doc) {
1013
1016
  // op.prevIndex = log.prevIndex;
1014
1017
  // op.parentIndex = log.parentIndex;
1015
1018
  // }
1016
- if ('insert' in op.ops) {
1017
- const prevEle = ElementUtil.getPrevSiblingElement(ele);
1018
- op.ops.insert = ele.clone(true);
1019
- op.index = ElementUtil.getControlIndex(ele, true);
1020
- op.parentIndex = ElementUtil.getControlIndex(ele.parent, true);
1021
- op.prevIndex = prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1;
1022
- }
1019
+ // if ('insert' in op.ops) {
1020
+ // const prevEle = ElementUtil.getPrevSiblingElement(ele);
1021
+ // op.ops.insert = ele.clone(true);
1022
+ // op.index = ElementUtil.getControlIndex(ele, true);
1023
+ // op.parentIndex = ElementUtil.getControlIndex(ele.parent, true);
1024
+ // op.prevIndex = prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1;
1025
+ // }
1023
1026
  patches.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
1024
1027
  }
1025
1028
  //清空
1026
- ops.length = 0;
1029
+ clear && (ops.length = 0);
1027
1030
  return patches;
1028
1031
  }
1029
1032
  /**
@@ -1054,11 +1057,11 @@ function mergeDiffProps(prevFormat, currFormat) {
1054
1057
  /**
1055
1058
  * 订阅者
1056
1059
  */
1057
- class Subscription$1 {
1060
+ class Subscription {
1058
1061
  closed = false;
1059
1062
  once = false;
1060
1063
  }
1061
- class EventSourceCore$1 {
1064
+ class EventSourceCore {
1062
1065
  closed = false;
1063
1066
  subs = [];
1064
1067
  next(data) {
@@ -1087,7 +1090,7 @@ class EventSourceCore$1 {
1087
1090
  /**
1088
1091
  * DOM事件处理
1089
1092
  */
1090
- class DOMEventSource extends EventSourceCore$1 {
1093
+ class DOMEventSource extends EventSourceCore {
1091
1094
  dom;
1092
1095
  type;
1093
1096
  constructor(dom, type) {
@@ -1107,7 +1110,7 @@ class DOMEventSource extends EventSourceCore$1 {
1107
1110
  return sub;
1108
1111
  }
1109
1112
  }
1110
- class DOMSubscription extends Subscription$1 {
1113
+ class DOMSubscription extends Subscription {
1111
1114
  listener;
1112
1115
  cancel;
1113
1116
  constructor(listener, cancel) {
@@ -1126,23 +1129,23 @@ class DOMSubscription extends Subscription$1 {
1126
1129
  this.cancel();
1127
1130
  }
1128
1131
  }
1129
- class Subject$1 extends EventSourceCore$1 {
1132
+ class Subject extends EventSourceCore {
1130
1133
  subscribe(listener) {
1131
- const sub = new SubjectSubscription$1(listener, () => {
1134
+ const sub = new SubjectSubscription(listener, () => {
1132
1135
  this.removeSub(sub);
1133
1136
  });
1134
1137
  this.addSub(sub);
1135
1138
  return sub;
1136
1139
  }
1137
1140
  }
1138
- class OnceSubject extends Subject$1 {
1141
+ class OnceSubject extends Subject {
1139
1142
  subscribe(listener) {
1140
1143
  const sub = super.subscribe(listener);
1141
1144
  sub.once = true;
1142
1145
  return sub;
1143
1146
  }
1144
1147
  }
1145
- class SubjectSubscription$1 extends Subscription$1 {
1148
+ class SubjectSubscription extends Subscription {
1146
1149
  listener;
1147
1150
  cancel;
1148
1151
  constructor(listener, cancel) {
@@ -1172,7 +1175,7 @@ class EventBus {
1172
1175
  handlers = [];
1173
1176
  this.subs.set(event, handlers);
1174
1177
  }
1175
- const sub = new Subject$1();
1178
+ const sub = new Subject();
1176
1179
  sub.subscribe(handler);
1177
1180
  handlers.push(sub);
1178
1181
  }
@@ -1247,8 +1250,8 @@ class Element {
1247
1250
  modifyFlag = exports.ModifyFlag.Modify;
1248
1251
  isMouseenter;
1249
1252
  _eventMap;
1250
- _refreshEvent = new Subject$1();
1251
- _onChangeEvent = new Subject$1();
1253
+ _refreshEvent = new Subject();
1254
+ _onChangeEvent = new Subject();
1252
1255
  observers = new WeakMap();
1253
1256
  paintRenders = [];
1254
1257
  cacheRender;
@@ -1519,15 +1522,22 @@ class BranchElement extends Element {
1519
1522
  }, 0);
1520
1523
  }
1521
1524
  getSelfLength(pure) {
1522
- return 1 + this.chilren.reduce((prev, curr) => {
1525
+ const len = 1 + this.chilren.reduce((prev, curr) => {
1523
1526
  return prev + curr.getSelfLength(pure);
1524
1527
  }, 0);
1528
+ //fixed:block-container类型的元素,比如表格单元格,再插入元素的时候,内部没有
1529
+ //段落,但是在文档排版时,会补充段落元素;因此在插入时,统计的index和len是有问题的
1530
+ //因此在统计的时候,手动将数量修复
1531
+ if (len === 1 && this instanceof BlockContainerElement) {
1532
+ return 2;
1533
+ }
1534
+ return len;
1525
1535
  }
1526
1536
  treeFilter(predicate) {
1527
1537
  const items = [];
1528
1538
  for (let i = 0; i < this.length; i++) {
1529
1539
  const item = this.getChild(i);
1530
- if (predicate(item, i)) {
1540
+ if (predicate(item)) {
1531
1541
  items.push(item);
1532
1542
  }
1533
1543
  if (item instanceof BranchElement) {
@@ -1539,7 +1549,7 @@ class BranchElement extends Element {
1539
1549
  treeFind(predicate) {
1540
1550
  for (let i = 0; i < this.length; i++) {
1541
1551
  const item = this.getChild(i);
1542
- if (predicate(item, i)) {
1552
+ if (predicate(item)) {
1543
1553
  return item;
1544
1554
  }
1545
1555
  if (item instanceof BranchElement) {
@@ -1786,28 +1796,12 @@ class ViewOptions {
1786
1796
  defaultIndent = 20;
1787
1797
  //内容区宽度,受审阅窗口宽度影响
1788
1798
  get contentWidth() {
1789
- if (this.showReviewWindow) {
1790
- return this.docPageSettings.width + this.reviewWindowWidth;
1791
- }
1792
- return this.docPageSettings.width;
1793
- }
1794
- /**
1795
- * 内容区域的高度
1796
- * 同时限定canvas的最小宽度
1797
- */
1798
- get ContentWidth() {
1799
- let width = this.docPageSettings.width;
1800
- if (this.showReviewWindow) {
1801
- width = width + this.reviewWindowWidth;
1802
- }
1803
- return width;
1799
+ return this.docPageSettings.width + this.reviewWindowWidth;
1804
1800
  }
1805
1801
  //两个页的间距
1806
1802
  docSpace = 0;
1807
- //是否显示审阅窗口
1808
- showReviewWindow = false;
1809
1803
  //审阅窗口宽度
1810
- reviewWindowWidth = 200;
1804
+ reviewWindowWidth = 0;
1811
1805
  //缩放
1812
1806
  _scale = 1;
1813
1807
  get scale() {
@@ -1846,7 +1840,7 @@ class ViewOptions {
1846
1840
  editUser = { id: '', name: '' };
1847
1841
  //留痕区域的生效时间段,同一用户的留痕块在此时间外需要生成新的留痕块
1848
1842
  trackChangePeriod = 10;
1849
- onChange = new Subject$1();
1843
+ onChange = new Subject();
1850
1844
  //打印模式,普通模式,续打模式
1851
1845
  printMode = 'normal';
1852
1846
  constructor() {
@@ -2915,65 +2909,6 @@ class BodyPartProps extends INotifyPropertyChanged {
2915
2909
  }
2916
2910
  }
2917
2911
 
2918
- class CommsContainerElement extends BlockContainerElement {
2919
- constructor() {
2920
- super('comm-list');
2921
- }
2922
- createRenderObject(data) {
2923
- const render = new CommsContainerRenderObject(this);
2924
- render.rect.width = data.options.reviewWindowWidth;
2925
- return render;
2926
- }
2927
- serialize(viewOptions) {
2928
- return {
2929
- type: this.type,
2930
- props: {}
2931
- };
2932
- }
2933
- clone(data) {
2934
- const clone = new CommsContainerElement();
2935
- cloneElementBase(this, clone);
2936
- cloneChildren(this, clone, data);
2937
- return clone;
2938
- }
2939
- }
2940
- class CommsContainerRenderObject extends BlockContainerRenderObject {
2941
- //批注内容是否已经重组,只要重新绘制的时候组合一次即可
2942
- isMeasureComm;
2943
- commsMarks = [];
2944
- clone() {
2945
- const clone = new CommsContainerRenderObject(this.element);
2946
- clone.rect = ElementUtil.cloneRect(this.rect);
2947
- for (let i = 0; i < this.length; i++) {
2948
- clone.addChild(this.getChild(i).clone());
2949
- }
2950
- return clone;
2951
- }
2952
- exportSVG(event) {
2953
- const t = super.exportSVG(event);
2954
- t.children = [ElementUtil.createSvgEle('rect', {
2955
- x: 0,
2956
- y: 0,
2957
- width: this.rect.width,
2958
- height: this.rect.height,
2959
- fill: '#fafafa',
2960
- stroke: 'black',
2961
- 'paint-order': 'stroke fill markers',
2962
- 'stroke-width': 0.5,
2963
- })];
2964
- return t;
2965
- }
2966
- }
2967
- class CommentsFactory extends ElementFactory {
2968
- match(type) {
2969
- return type === "comm-list";
2970
- }
2971
- createElement(data) {
2972
- const commentsEle = new CommsContainerElement();
2973
- return commentsEle;
2974
- }
2975
- }
2976
-
2977
2912
  class DataDecorateElement extends LeafElement {
2978
2913
  dataEle;
2979
2914
  isPrefix;
@@ -3140,7 +3075,7 @@ class ParagraphElement extends BlockContentElement {
3140
3075
  super('p');
3141
3076
  this.props = new ParagraphProps();
3142
3077
  this.addEvent('BackspaceKey', (evt) => {
3143
- if (evt.selectionState.collapsed) {
3078
+ if (evt.selectionState.editable && evt.selectionState.collapsed) {
3144
3079
  const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
3145
3080
  if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
3146
3081
  if (this.props.numberType >= 0) {
@@ -3156,7 +3091,7 @@ class ParagraphElement extends BlockContentElement {
3156
3091
  }, true);
3157
3092
  this.addEvent('ElementKeyDown', evt => {
3158
3093
  //当前存在缩进,点击tab
3159
- if (evt.sourceEvent.keyCode === 9) {
3094
+ if (evt.selectionState.editable && evt.sourceEvent.keyCode === 9) {
3160
3095
  const { startControl, startOffset } = evt.selectionState;
3161
3096
  if (startOffset === 0 && startControl === this.getChild(0)) {
3162
3097
  const defaultIndent = evt.ctx.viewOptions.defaultIndent;
@@ -3672,60 +3607,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3672
3607
  render.contentContext.drawText(viewOptions.copyRightInfo, textP, position.x + 5, position.y + 5, 100, 12);
3673
3608
  }
3674
3609
  }
3675
- /**
3676
- * 绘制文档边距线
3677
- */
3678
- drawMarginLine(position, render, docWidth, docHeight) {
3679
- const padding = this.padding;
3680
- let paddingPos = { x: padding.left + position.x, y: padding.top + position.y };
3681
- const drawLineWidth = 0.5;
3682
- const lineWidth = 20;
3683
- render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
3684
- x: paddingPos.x,
3685
- y: paddingPos.y - lineWidth
3686
- }], drawLineWidth);
3687
- paddingPos = { x: docWidth - padding.right + position.x, y: padding.top + position.y };
3688
- render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
3689
- x: paddingPos.x,
3690
- y: paddingPos.y - lineWidth
3691
- }], drawLineWidth);
3692
- paddingPos = { x: padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
3693
- render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
3694
- x: paddingPos.x,
3695
- y: paddingPos.y + lineWidth
3696
- }], drawLineWidth);
3697
- paddingPos = { x: docWidth - padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
3698
- render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
3699
- x: paddingPos.x,
3700
- y: paddingPos.y + lineWidth
3701
- }], drawLineWidth);
3702
- }
3703
- /**
3704
- * 绘制水印
3705
- * @param ctx
3706
- * @param position
3707
- */
3708
- drawWatermark(ctx, viewOptions, position) {
3709
- if (viewOptions.watermark) {
3710
- const watermark = viewOptions.watermark;
3711
- ctx.contentContext.ctx.save();
3712
- ctx.contentContext.ctx.translate(position.x, position.y);
3713
- const { width, height } = this.rect;
3714
- const degrees = Math.atan(height / width) * 180 / Math.PI;
3715
- ctx.contentContext.ctx.rotate(degrees * Math.PI / 180);
3716
- ctx.contentContext.ctx.globalAlpha = 0.3;
3717
- const d = Math.sqrt(width * width + height * height);
3718
- const textProps = new TextProps();
3719
- textProps.color = "#000000";
3720
- textProps.fontName = '楷体';
3721
- textProps.fontSize = 60;
3722
- const textWidth = ctx.contentContext.measureText(watermark, textProps).width;
3723
- const x = d / 2 - textWidth / 2;
3724
- ctx.contentContext.ctx.font = textProps.getFont();
3725
- ctx.contentContext.ctx.fillText(watermark, x, 30);
3726
- ctx.contentContext.ctx.restore();
3727
- }
3728
- }
3729
3610
  clone() {
3730
3611
  throw new Error('未实现');
3731
3612
  }
@@ -3770,9 +3651,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3770
3651
  return pageNumNode;
3771
3652
  }
3772
3653
  exportSVG(event) {
3773
- const padding = this.padding;
3774
- event.options.docPageSettings;
3775
- ({ x: padding.left, y: padding.top });
3776
3654
  const selection = {
3777
3655
  sel: "g",
3778
3656
  data: {
@@ -5470,7 +5348,8 @@ class TableUtil {
5470
5348
  currCell.props.hMerge = null;
5471
5349
  }
5472
5350
  if (currCell !== startCell) {
5473
- if (currCell.getChildLength() !== 2) {
5351
+ //单元格存在有效内容
5352
+ if (currCell.getChildLength() > 2) {
5474
5353
  cellContents.push(...ElementUtil.getChildrenElements(currCell.clone(true)));
5475
5354
  currCell.clearItems();
5476
5355
  }
@@ -5535,6 +5414,9 @@ class TableUtil {
5535
5414
  this.restoreCellMerge(cell);
5536
5415
  }
5537
5416
  }
5417
+ else {
5418
+ break;
5419
+ }
5538
5420
  }
5539
5421
  }
5540
5422
  if (hMerge === 'restart') {
@@ -5546,6 +5428,9 @@ class TableUtil {
5546
5428
  this.restoreCellMerge(cell);
5547
5429
  }
5548
5430
  }
5431
+ else {
5432
+ break;
5433
+ }
5549
5434
  }
5550
5435
  }
5551
5436
  cell.props.hMerge = null;
@@ -6525,94 +6410,6 @@ class CommentContentFactory extends ElementFactory {
6525
6410
  }
6526
6411
  }
6527
6412
 
6528
- class CommentsUtil {
6529
- static createCommentsImage(commWindow) {
6530
- const commContainer = commWindow.element.cacheRender;
6531
- commWindow.clear();
6532
- for (let i = 0; i < commContainer.length; i++) {
6533
- const commRender = commContainer.getChild(i);
6534
- const commEle = commRender.element;
6535
- const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
6536
- if (mapComm) {
6537
- const commContentRender = commRender.clone();
6538
- commContentRender.rect.x = 0;
6539
- commContentRender.rect.y = 0;
6540
- commWindow.addChild(commContentRender);
6541
- }
6542
- }
6543
- }
6544
- static arrangeComments(commWindow) {
6545
- if (commWindow.isMeasureComm) {
6546
- return;
6547
- }
6548
- const commContainer = commWindow.element.cacheRender;
6549
- const commMap = [];
6550
- const docRender = ElementUtil.getParentRender(commWindow, DocumentRenderObject);
6551
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender);
6552
- for (let i = 0; i < commContainer.length; i++) {
6553
- const commRender = commContainer.getChild(i);
6554
- const commEle = commRender.element;
6555
- const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
6556
- if (mapComm) {
6557
- const commRenderPos = ElementUtil.getRenderAbsolutePaintPos(mapComm);
6558
- const commPos = { x: commRenderPos.x - docRenderPos.x, y: commRenderPos.y - docRenderPos.y };
6559
- const commMarkLinePos = ElementUtil.getParaLinePos(mapComm, commPos);
6560
- commPos.y = commMarkLinePos.y + 2;
6561
- const commContentRender = commWindow.getItems().find(item => item.element === commRender.element);
6562
- //const commContentRender = commRender.clone() as CommContentBaseRenderObject<any>;
6563
- commContentRender.rect.x = 0;
6564
- commContentRender.rect.y = commPos.y;
6565
- //commWindow.addChild(commContentRender);
6566
- commMap.push({
6567
- commMarkRender: mapComm,
6568
- commMarkPos: commPos,
6569
- commContentRender: commContentRender
6570
- });
6571
- }
6572
- }
6573
- let sumCommentHeight = 0;
6574
- for (let i = 0; i < commMap.length; i++) {
6575
- const map = commMap[i];
6576
- const prevRender = commMap[i - 1]?.commContentRender;
6577
- const { commContentRender } = map;
6578
- sumCommentHeight += commContentRender.rect.height + 5;
6579
- if (prevRender) {
6580
- const { y: prevY, height: prevHeight } = prevRender.rect;
6581
- if (commContentRender.rect.y < prevY + prevHeight) {
6582
- commContentRender.rect.y = prevY + prevHeight + 5;
6583
- }
6584
- }
6585
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
6586
- }
6587
- if (!commMap.length) {
6588
- return;
6589
- }
6590
- const lastCommentMap = commMap[commMap.length - 1];
6591
- const { commContentRender: lastCommContentRender } = lastCommentMap;
6592
- const { rect: lastRect } = lastCommContentRender;
6593
- //批注内容超出文档,需要重新排序
6594
- if (lastRect.y + lastRect.height > docRender.rect.height) {
6595
- //总内容小于容器高度,则进行倒排
6596
- //否则进行正排
6597
- if (sumCommentHeight < docRender.rect.height) {
6598
- lastRect.y = docRender.rect.height - lastRect.height;
6599
- for (let i = commMap.length - 1; i >= 0; i--) {
6600
- const map = commMap[i];
6601
- const prevRender = commMap[i + 1]?.commContentRender;
6602
- const { commContentRender } = map;
6603
- if (prevRender) {
6604
- const { y: prevY } = prevRender.rect;
6605
- if (commContentRender.rect.y + commContentRender.rect.height > prevY) {
6606
- commContentRender.rect.y = prevY - commContentRender.rect.height - 5;
6607
- }
6608
- }
6609
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
6610
- }
6611
- }
6612
- }
6613
- }
6614
- }
6615
-
6616
6413
  let activeEditorContext = null;
6617
6414
  function setActiveEditorContext(ctx) {
6618
6415
  activeEditorContext = ctx;
@@ -6825,7 +6622,7 @@ class SelectionState {
6825
6622
  set endControl(value) {
6826
6623
  this._endControl = value;
6827
6624
  }
6828
- onChangedEvent = new Subject$1();
6625
+ onChangedEvent = new Subject();
6829
6626
  startControlIndex;
6830
6627
  startOffset;
6831
6628
  endControlIndex;
@@ -7032,7 +6829,7 @@ class CommentElement extends LeafElement {
7032
6829
  color;
7033
6830
  constructor() {
7034
6831
  super('comm');
7035
- this.isDecorate = true;
6832
+ //this.isDecorate = true;
7036
6833
  this.disableClick = true;
7037
6834
  this.props = new CommProps();
7038
6835
  this.color = CommonUtil.randomRgbColor(0.5);
@@ -7088,10 +6885,14 @@ class CommentRenderObject extends LeafRenderObject {
7088
6885
  if (this.element.paintRenders.indexOf(this) !== 0) {
7089
6886
  return;
7090
6887
  }
6888
+ const { x, y } = event.globalPos;
6889
+ const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
7091
6890
  const appCtx = getActiveEditorContext();
7092
6891
  const opType = '批注:';
7093
6892
  const content = this.element.props.text;
7094
- const left = 5;
6893
+ let left = 5;
6894
+ //显示在文档的右测
6895
+ left += docRender.rect.x + docRender.rect.width + 20;
7095
6896
  let sel = 'div.tg-container';
7096
6897
  const node = {
7097
6898
  sel,
@@ -7099,7 +6900,10 @@ class CommentRenderObject extends LeafRenderObject {
7099
6900
  data: {
7100
6901
  style: {
7101
6902
  left: `${left}px`,
7102
- top: `${event.globalPos.y}px`
6903
+ top: `${y}px`
6904
+ },
6905
+ dataset: {
6906
+ key: this.element.key
7103
6907
  },
7104
6908
  on: {
7105
6909
  click: (e) => {
@@ -7142,6 +6946,43 @@ class CommentRenderObject extends LeafRenderObject {
7142
6946
  }]
7143
6947
  };
7144
6948
  event.addChangeTips(node);
6949
+ const triangleTipX = x + this.rect.width / 2;
6950
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
6951
+ const tipLineA = {
6952
+ sel: 'div.doc-triangle-line',
6953
+ data: {
6954
+ style: {
6955
+ left: `${triangleTipX}px`,
6956
+ top: `${y + this.rect.height}px`,
6957
+ width: tipLineAWidth + 'px'
6958
+ }
6959
+ }
6960
+ };
6961
+ const tipLineB = {
6962
+ sel: 'div.doc-triangle-line',
6963
+ data: {
6964
+ style: {
6965
+ left: `${triangleTipX + tipLineAWidth}px`,
6966
+ top: `${y + this.rect.height}px`,
6967
+ width: 20 + 'px'
6968
+ },
6969
+ dataset: {
6970
+ key: this.element.key
6971
+ }
6972
+ }
6973
+ };
6974
+ const triangleTip = {
6975
+ sel: `div.doc-triangle`,
6976
+ data: {
6977
+ style: {
6978
+ left: `${triangleTipX}px`,
6979
+ top: `${y + this.rect.height * 2 / 3}px`
6980
+ }
6981
+ }
6982
+ };
6983
+ event.addChangeTips(triangleTip);
6984
+ event.addChangeTips(tipLineA);
6985
+ event.addChangeTips(tipLineB);
7145
6986
  // <div class="container">
7146
6987
  // <div class="header">
7147
6988
  // <span class="header-user">张三</span>
@@ -7175,10 +7016,72 @@ class CommentFactory extends ElementFactory {
7175
7016
  ele.props.id = props.id;
7176
7017
  ele.props.markType = props.markType;
7177
7018
  ele.props.text = props.text;
7019
+ ele.props.userId = props.userId;
7020
+ ele.props.userName = props.userName;
7021
+ ele.props.date = props.date;
7178
7022
  return ele;
7179
7023
  }
7180
7024
  }
7181
7025
 
7026
+ class CommsContainerElement extends BlockContainerElement {
7027
+ constructor() {
7028
+ super('comm-list');
7029
+ }
7030
+ createRenderObject(data) {
7031
+ const render = new CommsContainerRenderObject(this);
7032
+ render.rect.width = data.options.reviewWindowWidth;
7033
+ return render;
7034
+ }
7035
+ serialize(viewOptions) {
7036
+ return {
7037
+ type: this.type,
7038
+ props: {}
7039
+ };
7040
+ }
7041
+ clone(data) {
7042
+ const clone = new CommsContainerElement();
7043
+ cloneElementBase(this, clone);
7044
+ cloneChildren(this, clone, data);
7045
+ return clone;
7046
+ }
7047
+ }
7048
+ class CommsContainerRenderObject extends BlockContainerRenderObject {
7049
+ //批注内容是否已经重组,只要重新绘制的时候组合一次即可
7050
+ isMeasureComm;
7051
+ commsMarks = [];
7052
+ clone() {
7053
+ const clone = new CommsContainerRenderObject(this.element);
7054
+ clone.rect = ElementUtil.cloneRect(this.rect);
7055
+ for (let i = 0; i < this.length; i++) {
7056
+ clone.addChild(this.getChild(i).clone());
7057
+ }
7058
+ return clone;
7059
+ }
7060
+ exportSVG(event) {
7061
+ const t = super.exportSVG(event);
7062
+ t.children = [ElementUtil.createSvgEle('rect', {
7063
+ x: 0,
7064
+ y: 0,
7065
+ width: this.rect.width,
7066
+ height: this.rect.height,
7067
+ fill: '#fafafa',
7068
+ stroke: 'black',
7069
+ 'paint-order': 'stroke fill markers',
7070
+ 'stroke-width': 0.5,
7071
+ })];
7072
+ return t;
7073
+ }
7074
+ }
7075
+ class CommentsFactory extends ElementFactory {
7076
+ match(type) {
7077
+ return type === "comm-list";
7078
+ }
7079
+ createElement(data) {
7080
+ const commentsEle = new CommsContainerElement();
7081
+ return commentsEle;
7082
+ }
7083
+ }
7084
+
7182
7085
  /**
7183
7086
  * 数据元验证提示
7184
7087
  */
@@ -10626,7 +10529,7 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10626
10529
  if (fillColor) {
10627
10530
  t.data.attrs['fill'] = fillColor;
10628
10531
  }
10629
- this.createChangeTips(event);
10532
+ this.createModifyTips(event);
10630
10533
  const { x, y } = event.relativePagePos;
10631
10534
  const color = this.element.type === 'ins-run' ? 'green' : 'red';
10632
10535
  if (this.element.type === 'del-run') {
@@ -10634,35 +10537,39 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10634
10537
  event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY} H${x + this.rect.width}`, 'red', 1));
10635
10538
  event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY + 4} H${x + this.rect.width}`, 'red', 1));
10636
10539
  }
10637
- if (this.element.gotFocus && event.options.showTrackChanges) {
10540
+ if (this.element.gotFocus) {
10638
10541
  //起始位置
10639
10542
  if (this.element.paintRenders.indexOf(this) === 0) {
10640
10543
  const pathPoints = [];
10641
10544
  pathPoints.push({ x: x, y: y + this.rect.height / 3 });
10642
10545
  pathPoints.push({ x, y });
10643
10546
  pathPoints.push({ x: x + this.rect.width, y: y });
10644
- event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 2));
10547
+ event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
10645
10548
  }
10646
10549
  if (this.element.paintRenders.indexOf(this) === this.element.paintRenders.length - 1) {
10647
10550
  const pathPoints = [];
10648
10551
  pathPoints.push({ x: x, y: y + this.rect.height });
10649
10552
  pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height });
10650
10553
  pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height * 2 / 3 });
10651
- event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 2));
10554
+ event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
10652
10555
  }
10653
10556
  }
10654
10557
  return t;
10655
10558
  }
10656
- createChangeTips(event) {
10559
+ createModifyTips(event) {
10657
10560
  if (this.element.paintRenders.indexOf(this) !== 0) {
10658
10561
  return;
10659
10562
  }
10660
10563
  if (!event.options.showTrackChangesTip) {
10661
10564
  return;
10662
10565
  }
10566
+ const { x, y } = event.globalPos;
10567
+ const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
10663
10568
  const opType = this.element.type === 'ins-run' ? '插入:' : '删除:';
10664
10569
  const content = ElementSerialize.serializeString(this.element, { all: true });
10665
- const left = this.element.gotFocus ? -10 : 5;
10570
+ let left = this.element.gotFocus ? -10 : 5;
10571
+ //显示在文档的右测
10572
+ left += docRender.rect.x + docRender.rect.width + 20;
10666
10573
  let sel = 'div.tg-container';
10667
10574
  if (this.element.gotFocus) {
10668
10575
  sel += '.tg-container--selected';
@@ -10673,7 +10580,10 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10673
10580
  data: {
10674
10581
  style: {
10675
10582
  left: `${left}px`,
10676
- top: `${event.globalPos.y}px`
10583
+ top: `${y}px`
10584
+ },
10585
+ dataset: {
10586
+ key: this.element.key
10677
10587
  }
10678
10588
  },
10679
10589
  children: [{
@@ -10695,6 +10605,43 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10695
10605
  }]
10696
10606
  };
10697
10607
  event.addChangeTips(node);
10608
+ const triangleTipX = x + this.rect.width / 2;
10609
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
10610
+ const tipLineA = {
10611
+ sel: 'div.doc-triangle-line',
10612
+ data: {
10613
+ style: {
10614
+ left: `${triangleTipX}px`,
10615
+ top: `${y + this.rect.height}px`,
10616
+ width: tipLineAWidth + 'px'
10617
+ }
10618
+ }
10619
+ };
10620
+ const tipLineB = {
10621
+ sel: 'div.doc-triangle-line',
10622
+ data: {
10623
+ style: {
10624
+ left: `${triangleTipX + tipLineAWidth}px`,
10625
+ top: `${y + this.rect.height}px`,
10626
+ width: 20 + 'px'
10627
+ },
10628
+ dataset: {
10629
+ key: this.element.key
10630
+ }
10631
+ }
10632
+ };
10633
+ const triangleTip = {
10634
+ sel: `div.doc-triangle`,
10635
+ data: {
10636
+ style: {
10637
+ left: `${triangleTipX}px`,
10638
+ top: `${y + this.rect.height * 2 / 3}px`
10639
+ }
10640
+ }
10641
+ };
10642
+ event.addChangeTips(triangleTip);
10643
+ event.addChangeTips(tipLineA);
10644
+ event.addChangeTips(tipLineB);
10698
10645
  }
10699
10646
  clone() {
10700
10647
  const cloneRender = new TrackRunRenderObject(this.element);
@@ -12075,9 +12022,6 @@ class ElementUtil {
12075
12022
  if (element instanceof DocumentHeaderElement) {
12076
12023
  return { type: 'header', target: element };
12077
12024
  }
12078
- if (element instanceof CommsContainerElement) {
12079
- return { type: 'review', target: element };
12080
- }
12081
12025
  return this.getElementRegionTarget(element.parent);
12082
12026
  }
12083
12027
  /**
@@ -12446,6 +12390,22 @@ class ElementUtil {
12446
12390
  delete ele.attribute[attr];
12447
12391
  }
12448
12392
  }
12393
+ static getMatchItems(item, predicate) {
12394
+ const items = [];
12395
+ if (predicate(item)) {
12396
+ items.push(item);
12397
+ }
12398
+ if (item instanceof BranchElement) {
12399
+ for (let i = 0; i < item.length; i++) {
12400
+ const child = item.getChild(i);
12401
+ const matchItems = this.getMatchItems(child, predicate);
12402
+ if (matchItems) {
12403
+ items.push(...matchItems);
12404
+ }
12405
+ }
12406
+ }
12407
+ return items;
12408
+ }
12449
12409
  }
12450
12410
 
12451
12411
  exports.TextUnitsHolder = void 0;
@@ -12942,7 +12902,7 @@ class EditorContext {
12942
12902
  docChange;
12943
12903
  clearPrevDocCb;
12944
12904
  //绘制结束之后回调函数
12945
- paintedCallback;
12905
+ nextViewFn;
12946
12906
  constructor(selectionState, viewOptions) {
12947
12907
  this.selectionState = selectionState;
12948
12908
  this.viewOptions = viewOptions;
@@ -12952,8 +12912,8 @@ class EditorContext {
12952
12912
  this.syncRefresh?.();
12953
12913
  });
12954
12914
  }
12955
- setPaintedCallback(cb) {
12956
- this.paintedCallback = cb;
12915
+ onNextView(cb) {
12916
+ this.nextViewFn = cb;
12957
12917
  }
12958
12918
  get document() {
12959
12919
  return this._document;
@@ -12981,6 +12941,7 @@ class EditorContext {
12981
12941
  this.selectionState?.renderContainer?.destroy();
12982
12942
  this.clear();
12983
12943
  this._document.destroy();
12944
+ clearTraces(this._document);
12984
12945
  }
12985
12946
  this.clearPrevDocCb = null;
12986
12947
  this.selectionState.startHitInfo = null;
@@ -14817,9 +14778,6 @@ class DocumentArrange {
14817
14778
  }
14818
14779
  for (let i = 0; i < renderTree.length; i++) {
14819
14780
  const currRender = renderTree.getChild(i);
14820
- if (currRender.element) {
14821
- this.cacheCommsRender(currRender);
14822
- }
14823
14781
  if (currRender instanceof BranchRenderObject) {
14824
14782
  this.cacheRenders(currRender);
14825
14783
  }
@@ -14828,26 +14786,6 @@ class DocumentArrange {
14828
14786
  }
14829
14787
  }
14830
14788
  }
14831
- /**
14832
- * 缓存批注标志
14833
- * @private
14834
- */
14835
- cacheCommsRender(render) {
14836
- if (render.element && render.element.type === 'comm') {
14837
- const commElement = render.element;
14838
- if (commElement.props.markType === 'start') {
14839
- const currDocRender = this.cacheDoc;
14840
- const docCommContainer = currDocRender.getItems().find(item => item instanceof CommsContainerRenderObject);
14841
- if (docCommContainer) {
14842
- docCommContainer.commsMarks.push(render);
14843
- }
14844
- }
14845
- }
14846
- if (render.element && render.element.type === 'comm-list') {
14847
- const commContainer = render;
14848
- CommentsUtil.createCommentsImage(commContainer);
14849
- }
14850
- }
14851
14789
  endMeasures(ele) {
14852
14790
  ele.endMeasure();
14853
14791
  if (ele instanceof BranchElement) {
@@ -14888,14 +14826,11 @@ class DocumentPaginator {
14888
14826
  this.docCtx.selectionState.renderContainer = this.docContainer;
14889
14827
  this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
14890
14828
  const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
14891
- const docPages = newMeasure.measureDoc();
14892
- this.setCommRangeMark();
14893
- this.docPages = docPages;
14829
+ this.docPages = newMeasure.measureDoc();
14894
14830
  this.layoutPages();
14895
14831
  }
14896
14832
  /**
14897
14833
  * 文档页面显示布局
14898
- * @param pages
14899
14834
  */
14900
14835
  layoutPages() {
14901
14836
  if (!this.docContainer || !this.docPages) {
@@ -14978,39 +14913,6 @@ class DocumentPaginator {
14978
14913
  getDocContainer() {
14979
14914
  return this.docContainer;
14980
14915
  }
14981
- /***
14982
- * 设置审阅区间样式痕迹
14983
- */
14984
- setCommRangeMark() {
14985
- if (!this.viewOptions.showReviewWindow) {
14986
- return;
14987
- }
14988
- // const cce = this.docCtx.document.commentsContainerElement;
14989
- // const set = new Map<Element, SelectionContentRange>();
14990
- // const commentRangeStatus: Array<CommentRangeStatus> = [];
14991
- // for (let i = 0; i < cce.length; i++) {
14992
- // const commContent = cce.getChild(i) as CommContentElement;
14993
- // const commMarkPair = cce.markPairs.find(item => item.id === commContent.props.id);
14994
- // if (commMarkPair) {
14995
- // if (commMarkPair.start) {
14996
- // commContent.startMark = commMarkPair.start;
14997
- // }
14998
- // if (commMarkPair.end) {
14999
- // commContent.endMark = commMarkPair.end;
15000
- // }
15001
- // }
15002
- // const {startMark, endMark, props: {id}, focus} = commContent;
15003
- // const ancestorCommonControl = DocumentSelection.getAncestorCommonControl(startMark, endMark);
15004
- // const commonRange = RangeUtil.getSectionRange(startMark, 0, endMark, 1, ancestorCommonControl);
15005
- // SelectionOverlays.addToCommentSets(commonRange, set);
15006
- // commentRangeStatus.push({
15007
- // commContent,
15008
- // range: commonRange
15009
- // })
15010
- // }
15011
- // (<CommsContainerRenderObject>cce.cacheRender).selectedSet = set;
15012
- // (<CommsContainerRenderObject>cce.cacheRender).commentRangeStatus = commentRangeStatus;
15013
- }
15014
14916
  }
15015
14917
 
15016
14918
  class ElementReader {
@@ -15146,491 +15048,6 @@ class ElementReader {
15146
15048
  }
15147
15049
  }
15148
15050
 
15149
- class Subscription {
15150
- closed = false;
15151
- once = false;
15152
- }
15153
- class EventSourceCore {
15154
- closed = false;
15155
- subs = [];
15156
- next(data) {
15157
- const subs = [...this.subs];
15158
- subs.forEach((sub) => {
15159
- sub.invoke(data);
15160
- if (sub.once) {
15161
- sub.unsubscribe();
15162
- }
15163
- });
15164
- }
15165
- addSub(sub) {
15166
- this.subs.push(sub);
15167
- }
15168
- removeSub(sub) {
15169
- const index = this.subs.indexOf(sub);
15170
- if (index >= 0) {
15171
- this.subs.splice(index, 1);
15172
- }
15173
- }
15174
- unsubscribe() {
15175
- this.subs.length = 0;
15176
- this.closed = true;
15177
- }
15178
- }
15179
- class Subject extends EventSourceCore {
15180
- subscribe(listener) {
15181
- const sub = new SubjectSubscription(listener, () => {
15182
- this.removeSub(sub);
15183
- });
15184
- this.addSub(sub);
15185
- return sub;
15186
- }
15187
- onceSubscribe(listener) {
15188
- const sub = this.subscribe(listener);
15189
- sub.once = true;
15190
- return sub;
15191
- }
15192
- }
15193
- class SubjectSubscription extends Subscription {
15194
- listener;
15195
- cancel;
15196
- constructor(listener, cancel) {
15197
- super();
15198
- this.listener = listener;
15199
- this.cancel = cancel;
15200
- }
15201
- invoke(data) {
15202
- if (this.closed) {
15203
- return;
15204
- }
15205
- this.listener(data);
15206
- }
15207
- unsubscribe() {
15208
- this.closed = true;
15209
- this.cancel();
15210
- }
15211
- }
15212
-
15213
- var ModifyFlag;
15214
- (function (ModifyFlag) {
15215
- ModifyFlag[ModifyFlag["None"] = 0] = "None";
15216
- ModifyFlag[ModifyFlag["Modify"] = 1] = "Modify";
15217
- ModifyFlag[ModifyFlag["Track"] = 2] = "Track";
15218
- })(ModifyFlag || (ModifyFlag = {}));
15219
- class NodeCore {
15220
- enableClip = true;
15221
- pointEvent = true;
15222
- allowHitTest = false;
15223
- hitTest(hitPos, currPos) {
15224
- return false;
15225
- }
15226
- get enable() {
15227
- return this._enable;
15228
- }
15229
- set enable(value) {
15230
- this.propertyChanged('enable', this._enable, value);
15231
- }
15232
- _enable = true;
15233
- enableFocus = false;
15234
- isFocused = false;
15235
- get cursor() {
15236
- return this._cursor;
15237
- }
15238
- set cursor(value) {
15239
- this.propertyChanged('cursor', this._cursor, value);
15240
- this._cursor = value;
15241
- }
15242
- _cursor = 'default';
15243
- get visible() {
15244
- return this._visible;
15245
- }
15246
- set visible(value) {
15247
- this.propertyChanged('visible', this._visible, value);
15248
- this._visible = value;
15249
- }
15250
- _visible = true;
15251
- get borderRadius() {
15252
- return this._borderRadius;
15253
- }
15254
- set borderRadius(value) {
15255
- this.propertyChanged('borderRadius', this._borderRadius, value);
15256
- this._borderRadius = value;
15257
- }
15258
- get width() {
15259
- return this._width;
15260
- }
15261
- set width(value) {
15262
- this.propertyChanged('width', this._width, value);
15263
- this._width = value;
15264
- }
15265
- get height() {
15266
- return this._height;
15267
- }
15268
- set height(value) {
15269
- this.propertyChanged('height', this._height, value);
15270
- this._height = value;
15271
- }
15272
- get x() {
15273
- return this._x;
15274
- }
15275
- set x(value) {
15276
- this.propertyChanged('x', this._x, value);
15277
- this._x = value;
15278
- }
15279
- get y() {
15280
- return this._y;
15281
- }
15282
- set y(value) {
15283
- this.propertyChanged('y', this._y, value);
15284
- this._y = value;
15285
- }
15286
- _minWidth = Number.NaN;
15287
- _minHeight = Number.NaN;
15288
- get minWidth() {
15289
- return this._minWidth;
15290
- }
15291
- set minWidth(value) {
15292
- this.propertyChanged('minWidth', this._minWidth, value);
15293
- this._minWidth = value;
15294
- }
15295
- get minHeight() {
15296
- return this._minHeight;
15297
- }
15298
- set minHeight(value) {
15299
- this.propertyChanged('minHeight', this._minHeight, value);
15300
- this._minHeight = value;
15301
- }
15302
- get bgColor() {
15303
- return this._bgColor;
15304
- }
15305
- set bgColor(value) {
15306
- this.propertyChanged('bgColor', this._bgColor, value);
15307
- this._bgColor = value;
15308
- }
15309
- _border = 0;
15310
- get border() {
15311
- return this._border;
15312
- }
15313
- set border(value) {
15314
- this.propertyChanged('border', this._border, Math.abs(value));
15315
- this._border = value;
15316
- }
15317
- _padding = 0;
15318
- get padding() {
15319
- return this._padding;
15320
- }
15321
- set padding(value) {
15322
- this.propertyChanged('padding', this._padding, Math.abs(value));
15323
- this._padding = value;
15324
- }
15325
- _borderRadius = 0;
15326
- _borderColor;
15327
- get borderColor() {
15328
- return this._borderColor;
15329
- }
15330
- set borderColor(value) {
15331
- this.propertyChanged('borderColor', this._borderColor, value);
15332
- this._borderColor = value;
15333
- }
15334
- _shadowBlur = 0;
15335
- _shadowColor;
15336
- get shadowBlur() {
15337
- return this._shadowBlur;
15338
- }
15339
- set shadowBlur(value) {
15340
- this.propertyChanged('shadowBlur', this._shadowBlur, value);
15341
- this._shadowBlur = value;
15342
- }
15343
- get shadowColor() {
15344
- return this._shadowColor;
15345
- }
15346
- set shadowColor(value) {
15347
- this.propertyChanged('shadowColor', this._shadowColor, value);
15348
- this._shadowColor = value;
15349
- }
15350
- _isMouseenter = false;
15351
- get isMouseenter() {
15352
- return this._isMouseenter;
15353
- }
15354
- set isMouseenter(value) {
15355
- this.propertyChanged('isMouseenter', this._isMouseenter, value);
15356
- this._isMouseenter = value;
15357
- }
15358
- _overflowHidden = true;
15359
- get overflowHidden() {
15360
- return this._overflowHidden;
15361
- }
15362
- set overflowHidden(value) {
15363
- this.propertyChanged('overflowHidden', this._overflowHidden, value);
15364
- this._overflowHidden = value;
15365
- }
15366
- outlineColor = '';
15367
- outlineStyle = 'none';
15368
- outlineWidth = 0;
15369
- _width = Number.NaN;
15370
- _height = Number.NaN;
15371
- _x = 0;
15372
- _y = 0;
15373
- //测量需要的大小
15374
- desiredSize;
15375
- //绘制的大小
15376
- renderSize;
15377
- //最终分配的大小
15378
- finalRect;
15379
- _bgColor;
15380
- _modifyFlag = ModifyFlag.Modify;
15381
- get modifyFlag() {
15382
- return this._modifyFlag;
15383
- }
15384
- set modifyFlag(value) {
15385
- this._modifyFlag = value;
15386
- }
15387
- onChangedEvent = new Subject();
15388
- listenerEvents = [];
15389
- parent;
15390
- propertyChanged(prop, old, newV) {
15391
- if (this._modifyFlag == ModifyFlag.Modify) {
15392
- return;
15393
- }
15394
- if (old === newV) {
15395
- return;
15396
- }
15397
- this.onChanged();
15398
- }
15399
- onChanged() {
15400
- if (this._modifyFlag == ModifyFlag.Modify) {
15401
- return;
15402
- }
15403
- this._modifyFlag = ModifyFlag.Modify;
15404
- // if (this.parent) {
15405
- // this.parent.onChildChanged();
15406
- // }
15407
- this.onChangedEvent.next();
15408
- }
15409
- addEventListener(name, listener, useCapture = false) {
15410
- this.listenerEvents.push({
15411
- name,
15412
- listener: listener,
15413
- useCapture
15414
- });
15415
- }
15416
- removeEventListener(name, listener, useCapture = false) {
15417
- const index = this.listenerEvents.findIndex(item => item.name === name && item.listener === listener && item.useCapture === useCapture);
15418
- if (index >= 0) {
15419
- this.listenerEvents.splice(index, 1);
15420
- }
15421
- }
15422
- /**
15423
- * 父容器传入参数,子容器设置坐标位置
15424
- * @param e
15425
- * @param finalRect
15426
- */
15427
- arrange(e, finalRect) {
15428
- if (!this._visible) {
15429
- this.finalRect = { x: finalRect.x, y: finalRect.y, width: 0, height: 0 };
15430
- return;
15431
- }
15432
- const contentSize = this.getContentSize(finalRect.width, finalRect.height);
15433
- const finalSize = this.arrangeOverride(e, contentSize);
15434
- this.renderSize = this.getOuterSize({
15435
- width: Math.min(contentSize.width, finalSize.width),
15436
- height: Math.min(contentSize.height, finalSize.height)
15437
- });
15438
- this.finalRect = { x: finalRect.x, y: finalRect.y, width: this.renderSize.width, height: this.renderSize.height };
15439
- }
15440
- arrangeOverride(e, finalSize) {
15441
- return finalSize;
15442
- }
15443
- /**
15444
- * 测量阶段
15445
- * @param e
15446
- * @param availableSize
15447
- */
15448
- measure(e, availableSize) {
15449
- if (!this._visible) {
15450
- this.desiredSize = { width: 0, height: 0 };
15451
- return;
15452
- }
15453
- let width = 0, height = 0;
15454
- if (Number.isNaN(this._width)) {
15455
- width = availableSize.width;
15456
- }
15457
- else {
15458
- width = this.getPercentWidth(availableSize.width);
15459
- }
15460
- if (Number.isNaN(this._height)) {
15461
- height = availableSize.height;
15462
- }
15463
- else {
15464
- height = this.getPercentHeight(availableSize.height);
15465
- }
15466
- const measureSize = this.getOuterSize(this.measureOverride(e, this.getContentSize(width, height)));
15467
- if (Number.isNaN(this._width)) {
15468
- width = measureSize.width;
15469
- }
15470
- if (Number.isNaN(this._height)) {
15471
- height = measureSize.height;
15472
- }
15473
- this.desiredSize = { width, height };
15474
- }
15475
- getPercentWidth(val) {
15476
- if (typeof this._width === 'object') {
15477
- return val * this._width.value / 100;
15478
- }
15479
- else {
15480
- return this._width;
15481
- }
15482
- }
15483
- getPercentHeight(val) {
15484
- if (typeof this._height === 'object') {
15485
- return val * this._height.value / 100;
15486
- }
15487
- else {
15488
- return this._height;
15489
- }
15490
- }
15491
- /**
15492
- * 获取内容尺寸
15493
- * 元素模型为边框模型,元素的大小为默认包含边框大小,内容大小需要减去边框大小
15494
- * @private
15495
- * @param width
15496
- * @param height
15497
- */
15498
- getContentSize(width, height) {
15499
- return {
15500
- width: width - this._border * 2 - this._padding * 2,
15501
- height: height - this._border * 2 - this.padding * 2
15502
- };
15503
- }
15504
- /**
15505
- * 获取外部尺寸
15506
- * @param availableSize
15507
- * @private
15508
- */
15509
- getOuterSize(availableSize) {
15510
- return {
15511
- width: availableSize.width + this._border * 2 + this._padding * 2,
15512
- height: availableSize.height + this._border * 2 + this._padding * 2
15513
- };
15514
- }
15515
- /**
15516
- * 子元素需重写该方法
15517
- * @param e
15518
- * @param availableSize
15519
- */
15520
- measureOverride(e, availableSize) {
15521
- return availableSize;
15522
- }
15523
- preRender(e) {
15524
- return true;
15525
- }
15526
- attachedProp = {};
15527
- setAttachedProp(name, val) {
15528
- const key = name;
15529
- this.propertyChanged(key, this.attachedProp[key], val);
15530
- this.attachedProp[key] = val;
15531
- }
15532
- getAttachedPropValue(name) {
15533
- return this.attachedProp[name];
15534
- }
15535
- removeAttachedProp(name) {
15536
- this.propertyChanged(name, this.attachedProp[name], undefined);
15537
- delete this.attachedProp[name];
15538
- }
15539
- /**
15540
- * 绘制轮廓
15541
- */
15542
- renderOutline(renderCtx) {
15543
- drawOutline(this, renderCtx);
15544
- clipContent(this, renderCtx);
15545
- drawBorderline(this, renderCtx);
15546
- translate(renderCtx, this.finalRect.x, this.finalRect.y);
15547
- translate(renderCtx, this.border + this.padding, this.border + this.padding);
15548
- }
15549
- }
15550
- /**
15551
- * 绘制边框
15552
- * @param node
15553
- * @param renderCtx
15554
- */
15555
- function drawBorderline(node, renderCtx) {
15556
- //renderCtx.contentContext.fillRect(node.x, node.y, node.finalRect.width, node.finalRect.height, node.bgColor);
15557
- if (!node.border) {
15558
- return;
15559
- }
15560
- let { finalRect: { x, y, width, height } } = node;
15561
- const ctx = renderCtx.ctx;
15562
- ctx.save();
15563
- ctx.fillStyle = node.borderColor;
15564
- ctx.beginPath();
15565
- ctx.moveTo(x, y);
15566
- ctx.lineTo(x + width, y);
15567
- ctx.lineTo(x + width, y + height);
15568
- ctx.lineTo(x, y + height);
15569
- ctx.lineTo(x, y);
15570
- ctx.closePath();
15571
- ctx.fill();
15572
- if (node.border) {
15573
- ctx.globalCompositeOperation = 'source-atop';
15574
- x += node.border;
15575
- y += node.border;
15576
- width -= node.border * 2;
15577
- height -= node.border * 2;
15578
- const bgColor = node.bgColor ? node.bgColor : 'white';
15579
- ctx.fillStyle = bgColor;
15580
- renderCtx.roundRect(x, y, width, height, node.borderRadius);
15581
- }
15582
- ctx.fill();
15583
- ctx.restore();
15584
- //裁剪子内容区域范围
15585
- node.enableClip && renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
15586
- }
15587
- /**
15588
- * 绘制外轮廓
15589
- */
15590
- function drawOutline(node, renderCtx) {
15591
- if (node.outlineWidth <= 0 || node.outlineStyle === 'none' || !node.outlineColor) {
15592
- return;
15593
- }
15594
- let { x, y, finalRect: { width, height } } = node;
15595
- x -= node.outlineWidth / 2;
15596
- y -= node.outlineWidth / 2;
15597
- width += node.outlineWidth;
15598
- height += node.outlineWidth;
15599
- renderCtx.strokeRect(x, y, width, height, node.outlineColor, node.outlineWidth, node.borderRadius);
15600
- }
15601
- function clipContent(node, renderCtx) {
15602
- const x = node.finalRect.x;
15603
- const y = node.finalRect.y;
15604
- const width = node.finalRect.width;
15605
- const height = node.finalRect.height;
15606
- renderCtx.ctx.lineWidth = 0;
15607
- //绘制背景
15608
- if (node.bgColor) {
15609
- renderCtx.fillRect(x, y, width, height, node.bgColor, node.shadowBlur, node.shadowColor, node.borderRadius);
15610
- }
15611
- //确定绘制裁剪范围
15612
- renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
15613
- }
15614
- function translate(renderCtx, x, y) {
15615
- renderCtx.ctx.translate(x, y);
15616
- }
15617
-
15618
- class RectNode extends NodeCore {
15619
- render(e) {
15620
- // const {render}=e;
15621
- // const ctx=render.contentContext.ctx;
15622
- //
15623
- // var gradient = ctx.createLinearGradient(0,0, this.finalRect.width,0);
15624
- //
15625
- // gradient.addColorStop(0, 'green');
15626
- // gradient.addColorStop(.5, 'cyan');
15627
- // gradient.addColorStop(1, 'blue');
15628
- //
15629
- // ctx.fillStyle=gradient;
15630
- // ctx.fill();
15631
- }
15632
- }
15633
-
15634
15051
  /**
15635
15052
  * 事件系统
15636
15053
  */
@@ -15648,13 +15065,13 @@ class DocumentEvent {
15648
15065
  focusedRect;
15649
15066
  //当前光标所在的元素
15650
15067
  currentMouseoverRender;
15651
- hitInfoChanged = new Subject$1();
15652
- clickEvent = new Subject$1();
15653
- dblClickEvent = new Subject$1();
15654
- tripleClickEvent = new Subject$1();
15655
- changeCursor = new Subject$1();
15656
- contextMenu = new Subject$1();
15657
- trackTipsChanged = new Subject$1();
15068
+ hitInfoChanged = new Subject();
15069
+ clickEvent = new Subject();
15070
+ dblClickEvent = new Subject();
15071
+ tripleClickEvent = new Subject();
15072
+ changeCursor = new Subject();
15073
+ contextMenu = new Subject();
15074
+ trackTipsChanged = new Subject();
15658
15075
  //光标处于边框的绘制元素
15659
15076
  edgeRenderInfo;
15660
15077
  //当前鼠标所在的page-position
@@ -16874,119 +16291,6 @@ class DocumentEvent {
16874
16291
  // }
16875
16292
  // }
16876
16293
  }
16877
- /**
16878
- * 开启打印区域
16879
- */
16880
- startPrintArea(editor) {
16881
- const cancelToken = {};
16882
- const startRect = new RectNode();
16883
- startRect.x = 0;
16884
- startRect.y = 0;
16885
- startRect.width = editor.width;
16886
- startRect.height = 0;
16887
- //设置半透明颜色
16888
- startRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
16889
- startRect.pointEvent = false;
16890
- const endRect = new RectNode();
16891
- endRect.x = 0;
16892
- endRect.y = editor.finalRect.height;
16893
- endRect.width = editor.width;
16894
- endRect.height = 0;
16895
- //设置半透明颜色
16896
- endRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
16897
- endRect.pointEvent = false;
16898
- let state = 'start';
16899
- editor.parent?.addChild(startRect);
16900
- editor.parent?.addChild(endRect);
16901
- let startY = 0, startDocIndex = 0, endY = 0, endDocIndex = 0;
16902
- const onMousemoveHandler = (evt) => {
16903
- const pos = evt.sourceHitPos;
16904
- if (state === 'start') {
16905
- startRect.height = pos.y;
16906
- }
16907
- else {
16908
- if (startRect.height + 5 > pos.y) {
16909
- return;
16910
- }
16911
- endRect.y = pos.y;
16912
- endRect.height = editor.finalRect.height - pos.y;
16913
- }
16914
- };
16915
- const onKeydownHandler = (evt) => {
16916
- if (evt.sourceEvt.keyCode === 27) {
16917
- cancelToken.cancel?.();
16918
- }
16919
- };
16920
- const onClickHandler = (evt) => {
16921
- const pos = evt.sourceHitPos;
16922
- const hitDoc = this.getHitDocPage({ globalX: pos.x, globalY: pos.y });
16923
- if (!hitDoc) {
16924
- return;
16925
- }
16926
- const { docIndex, hitPagePos } = hitDoc;
16927
- if (state === 'start') {
16928
- startY = hitPagePos.y;
16929
- startDocIndex = docIndex;
16930
- state = 'end';
16931
- }
16932
- else {
16933
- if (startRect.height + 5 > pos.y) {
16934
- return;
16935
- }
16936
- endY = hitPagePos.y;
16937
- endDocIndex = docIndex;
16938
- cancelToken.onFinish?.({
16939
- startY,
16940
- startDocIndex,
16941
- endY,
16942
- endDocIndex
16943
- });
16944
- }
16945
- };
16946
- editor.addEventListener('mousemove', onMousemoveHandler);
16947
- editor.addEventListener('keydown', onKeydownHandler);
16948
- editor.addEventListener('click', onClickHandler);
16949
- cancelToken.cancel = () => {
16950
- if (!startRect.parent) {
16951
- return;
16952
- }
16953
- startRect.parent?.removeChild(startRect);
16954
- endRect.parent?.removeChild(endRect);
16955
- editor.removeEventListener('mousemove', onMousemoveHandler);
16956
- editor.removeEventListener('keydown', onKeydownHandler);
16957
- editor.removeEventListener('click', onClickHandler);
16958
- };
16959
- return cancelToken;
16960
- }
16961
- clicks = 0;
16962
- timeout;
16963
- /**
16964
- * 处理三击事件
16965
- */
16966
- handleTripleClick() {
16967
- this.clicks++;
16968
- let curr = this;
16969
- if (this.clicks === 1) {
16970
- // 设置延时,等待第二次点击
16971
- this.timeout = setTimeout(function () {
16972
- curr.clicks = 0;
16973
- }, 300);
16974
- }
16975
- else if (this.clicks === 2) {
16976
- // 第二次点击后,清除延时
16977
- clearTimeout(curr.timeout);
16978
- // 设置延时,等待第三次点击
16979
- curr.timeout = setTimeout(function () {
16980
- curr.clicks = 0;
16981
- }, 300);
16982
- }
16983
- else if (curr.clicks === 3) {
16984
- // 第三次点击后,处理三击事件并清除延时
16985
- clearTimeout(curr.timeout);
16986
- this.tripleClickEvent.next();
16987
- this.clicks = 0;
16988
- }
16989
- }
16990
16294
  /**
16991
16295
  * 获取当前光标所在的数据元
16992
16296
  * @returns
@@ -17019,34 +16323,34 @@ class DocumentEvent {
17019
16323
  class DocumentInput {
17020
16324
  docCtx;
17021
16325
  //输入内容事件
17022
- onInputEvent = new Subject$1();
16326
+ onInputEvent = new Subject();
17023
16327
  //backspace 键盘事件
17024
- onBackspaceEvent = new Subject$1();
16328
+ onBackspaceEvent = new Subject();
17025
16329
  //delete 键盘事件
17026
- onDeleteEvent = new Subject$1();
16330
+ onDeleteEvent = new Subject();
17027
16331
  //enter 键盘事件
17028
- onEnterEvent = new Subject$1();
16332
+ onEnterEvent = new Subject();
17029
16333
  //左键
17030
- onLeftEvent = new Subject$1();
16334
+ onLeftEvent = new Subject();
17031
16335
  //右键
17032
- onRightEvent = new Subject$1();
16336
+ onRightEvent = new Subject();
17033
16337
  //复制
17034
- onCopyEvent = new Subject$1();
16338
+ onCopyEvent = new Subject();
17035
16339
  //剪切
17036
- onCutEvent = new Subject$1();
16340
+ onCutEvent = new Subject();
17037
16341
  //粘贴
17038
- onPasteEvent = new Subject$1();
16342
+ onPasteEvent = new Subject();
17039
16343
  //插入换行符
17040
- onInsertBr = new Subject$1();
16344
+ onInsertBr = new Subject();
17041
16345
  //ctrl+A 全选事件
17042
- onSelectAllEvent = new Subject$1();
16346
+ onSelectAllEvent = new Subject();
17043
16347
  //home 事件
17044
- onHomeEvent = new Subject$1();
16348
+ onHomeEvent = new Subject();
17045
16349
  //end 事件
17046
- onEndEvent = new Subject$1();
17047
- onUpEvent = new Subject$1();
17048
- onDownEvent = new Subject$1();
17049
- onTabKeyEvent = new Subject$1();
16350
+ onEndEvent = new Subject();
16351
+ onUpEvent = new Subject();
16352
+ onDownEvent = new Subject();
16353
+ onTabKeyEvent = new Subject();
17050
16354
  constructor(docCtx) {
17051
16355
  this.docCtx = docCtx;
17052
16356
  }
@@ -17234,7 +16538,7 @@ class DocumentChange {
17234
16538
  });
17235
16539
  }
17236
16540
  newInput(data) {
17237
- if (data.composition && data.data === '') {
16541
+ if (data.composition && data.data === '') {
17238
16542
  debugger;
17239
16543
  }
17240
16544
  const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
@@ -17259,6 +16563,9 @@ class DocumentChange {
17259
16563
  const comp = data.compositionStartInfo;
17260
16564
  comp.element = newInput;
17261
16565
  comp.offset = 0;
16566
+ //修正数据
16567
+ if (data.composition)
16568
+ this.documentInput.correctInputEle(newInput, newInput.text, 0);
17262
16569
  this.inputTextGroup(newInput, data);
17263
16570
  return;
17264
16571
  }
@@ -17310,7 +16617,7 @@ class DocumentChange {
17310
16617
  return true;
17311
16618
  };
17312
16619
  //利用回调完成后续的输入处理
17313
- this.docCtx.setPaintedCallback(cb);
16620
+ this.docCtx.onNextView(cb);
17314
16621
  }
17315
16622
  /**
17316
16623
  * 当前元素是否在正确的留痕区域(ins-run、del-run),情况分为以下情况
@@ -18439,7 +17746,7 @@ class DocumentChange {
18439
17746
  const cb = () => {
18440
17747
  this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
18441
17748
  };
18442
- this.docCtx.setPaintedCallback(cb);
17749
+ this.docCtx.onNextView(cb);
18443
17750
  return;
18444
17751
  }
18445
17752
  this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
@@ -19373,7 +18680,7 @@ class ElementTrackManage {
19373
18680
  if (!ssLog) {
19374
18681
  return;
19375
18682
  }
19376
- this.docCtx.setPaintedCallback(() => {
18683
+ this.docCtx.onNextView(() => {
19377
18684
  const { startIndex, startOffset, endIndex, endOffset, editable } = ssLog;
19378
18685
  const range = new SelectionRange();
19379
18686
  const sc = this.getControl(startIndex, false);
@@ -19479,6 +18786,9 @@ class ElementTrackManage {
19479
18786
  getControl(index, pure = true) {
19480
18787
  return ElementUtil.getControlByIndex(this.docCtx.document, { currIndex: -1, index: index }, pure);
19481
18788
  }
18789
+ getControlIndex(control) {
18790
+ return ElementUtil.getControlIndex(control, true);
18791
+ }
19482
18792
  }
19483
18793
 
19484
18794
  class DocumentSvg {
@@ -19494,7 +18804,7 @@ class DocumentSvg {
19494
18804
  this.sso = sso;
19495
18805
  this.renderCtx = renderCtx;
19496
18806
  }
19497
- getVNode(render, selectionRects, parentPos) {
18807
+ getVNode(render, parentMaskRect, parentPos) {
19498
18808
  const currPos = {
19499
18809
  x: parentPos.x + render.rect.x,
19500
18810
  y: parentPos.y + render.rect.y,
@@ -19502,17 +18812,13 @@ class DocumentSvg {
19502
18812
  height: render.rect.height
19503
18813
  };
19504
18814
  //处理选区遮罩
19505
- this.createSelectionRect(render, selectionRects, currPos);
19506
- //审阅窗口重新计算位置
19507
- if (this.viewOptions.showReviewWindow && render instanceof CommsContainerRenderObject) {
19508
- CommentsUtil.arrangeComments(render);
19509
- }
19510
- const getChildNodes = (node, selectionRects) => {
18815
+ this.createSelectionRect(render, parentMaskRect, currPos);
18816
+ const getChildNodes = (node, selectionMask) => {
19511
18817
  if (node instanceof BranchRenderObject) {
19512
18818
  const children = [];
19513
18819
  for (let i = 0; i < node.length; i++) {
19514
18820
  const child = node.getChild(i);
19515
- const vNode = this.getVNode(child, selectionRects, currPos);
18821
+ const vNode = this.getVNode(child, selectionMask, currPos);
19516
18822
  if (Array.isArray(vNode)) {
19517
18823
  children.push(...vNode);
19518
18824
  }
@@ -19522,14 +18828,12 @@ class DocumentSvg {
19522
18828
  }
19523
18829
  return children;
19524
18830
  }
19525
- else {
19526
- return null;
19527
- }
18831
+ return null;
19528
18832
  };
19529
- let selectionRectsTemp = [];
18833
+ let currMaskGroup = { selection: [], mask: [] };
19530
18834
  const vNodeOptions = {
19531
18835
  getChildNodes: (node) => {
19532
- return getChildNodes(node, selectionRectsTemp);
18836
+ return getChildNodes(node, currMaskGroup);
19533
18837
  },
19534
18838
  options: this.viewOptions,
19535
18839
  highlights: [],
@@ -19549,7 +18853,7 @@ class DocumentSvg {
19549
18853
  this.highlights.push(...vNodeOptions.highlights);
19550
18854
  }
19551
18855
  if (currVNode && !currVNode.isCompleted) {
19552
- const childNodes = getChildNodes(render, selectionRectsTemp);
18856
+ const childNodes = getChildNodes(render, currMaskGroup);
19553
18857
  if (childNodes) {
19554
18858
  if (!currVNode.children) {
19555
18859
  currVNode.children = [];
@@ -19563,26 +18867,22 @@ class DocumentSvg {
19563
18867
  }
19564
18868
  }
19565
18869
  if (render instanceof ParagraphLineRectRenderObject) {
19566
- if (selectionRectsTemp.length > 0) {
19567
- const startX = selectionRectsTemp[0].x;
19568
- const endX = selectionRectsTemp[selectionRectsTemp.length - 1].x + selectionRectsTemp[selectionRectsTemp.length - 1].width;
19569
- selectionRects.push({
19570
- x: startX,
19571
- y: currPos.y,
19572
- width: endX - startX,
19573
- height: currPos.height,
19574
- color: selectionRectsTemp[0].color
19575
- });
19576
- selectionRectsTemp.length = 0;
18870
+ if (currMaskGroup.selection.length > 0) {
18871
+ this.combineParaLineSelection(parentMaskRect.selection, currMaskGroup.selection, currPos);
19577
18872
  }
19578
18873
  }
19579
18874
  else if (render instanceof TableCellRenderObject) {
19580
18875
  if (this.sso.selectionEleSets.has(render.element) && this.sso.selectionEleSets.get(render.element)?.isFullSelected) {
19581
- selectionRects.push(currPos);
19582
- selectionRectsTemp.length = 0;
18876
+ parentMaskRect.selection.push(currPos);
18877
+ currMaskGroup.selection.length = 0;
18878
+ }
18879
+ if (this.sso.commRangeSets.has(render.element) && this.sso.commRangeSets.get(render.element)?.isFullSelected) {
18880
+ parentMaskRect.mask.push(currPos);
18881
+ currMaskGroup.mask.length = 0;
19583
18882
  }
19584
18883
  }
19585
- selectionRects.push(...selectionRectsTemp);
18884
+ parentMaskRect.selection.push(...currMaskGroup.selection);
18885
+ parentMaskRect.mask.push(...currMaskGroup.mask);
19586
18886
  // if (currVNode && currVNode.data?.attrs?.transform) {
19587
18887
  // currVNode.data.attrs.transform = `translate(${currVNode.data?.attrs?.transform.x},${currVNode.data?.attrs?.transform.y})`
19588
18888
  // }
@@ -19602,13 +18902,6 @@ class DocumentSvg {
19602
18902
  if (line && !item.data.attrs.transform) {
19603
18903
  item.data.attrs.transform = `translate(${translateX},${translateY})`;
19604
18904
  }
19605
- // if (item && item.data?.attrs?.transform && typeof item.data?.attrs?.transform === 'object') {
19606
- // item.data.attrs.transform = `translate(${item.data.attrs.transform.x + translateX},${item.data.attrs.transform.y + translateY})`
19607
- // } else {
19608
- // if (line && !item.data.attrs.transform) {
19609
- // item.data.attrs.transform = `translate(${translateX},${translateY})`;
19610
- // }
19611
- // }
19612
18905
  });
19613
18906
  if (line) {
19614
18907
  return currVNode.children;
@@ -19619,32 +18912,35 @@ class DocumentSvg {
19619
18912
  }
19620
18913
  return currVNode;
19621
18914
  }
19622
- createSelectionRect(render, selectionRects, currPos) {
19623
- const items = [this.sso.selectionEleSets, this.sso.commRangeSets];
19624
- for (const item of items) {
19625
- if (item.has(render.element)) {
19626
- const range = item.get(render.element);
19627
- if (render.element && render instanceof LeafRenderObject) {
19628
- if (range.isFullSelected) {
19629
- selectionRects.push({ ...currPos, color: range['rangeColor'] });
19630
- }
19631
- else {
19632
- if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
19633
- const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
19634
- const width = endX - startX;
19635
- const x = currPos.x + startX;
19636
- // @ts-ignore
19637
- selectionRects.push({
19638
- x,
19639
- y: currPos.y,
19640
- width,
19641
- height: currPos.height,
19642
- color: range['rangeColor']
19643
- });
19644
- }
18915
+ createSelectionRect(render, selectionMask, currPos) {
18916
+ const createMaskVNode = (range, selectionRects) => {
18917
+ if (render.element && render instanceof LeafRenderObject) {
18918
+ if (range.isFullSelected) {
18919
+ selectionRects.push({ ...currPos, color: range['rangeColor'] });
18920
+ }
18921
+ else {
18922
+ if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
18923
+ const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
18924
+ const width = endX - startX;
18925
+ const x = currPos.x + startX;
18926
+ selectionRects.push({
18927
+ x,
18928
+ y: currPos.y,
18929
+ width,
18930
+ height: currPos.height,
18931
+ color: range['rangeColor']
18932
+ });
19645
18933
  }
19646
18934
  }
19647
18935
  }
18936
+ };
18937
+ if (this.sso.selectionEleSets.has(render.element)) {
18938
+ const range = this.sso.selectionEleSets.get(render.element);
18939
+ createMaskVNode(range, selectionMask.selection);
18940
+ }
18941
+ if (this.sso.commRangeSets.has(render.element)) {
18942
+ const range = this.sso.commRangeSets.get(render.element);
18943
+ createMaskVNode(range, selectionMask.mask);
19648
18944
  }
19649
18945
  }
19650
18946
  getHTMLVNode(docRenders) {
@@ -19693,12 +18989,13 @@ class DocumentSvg {
19693
18989
  }
19694
18990
  getPageSvgVNode(item) {
19695
18991
  this.highlights = [];
19696
- const rects = [];
18992
+ const rects = { selection: [], mask: [] };
19697
18993
  this.pagePos = { x: item.rect.x, y: item.rect.y };
19698
18994
  const pageSvg = this.getVNode(item, rects, { x: -item.rect.x, y: -item.rect.y });
19699
18995
  const selectionNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'selection');
19700
- const hightlightNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'highlight');
19701
- selectionNode.children = rects.map(item => ({
18996
+ const highlightNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'highlight');
18997
+ rects.selection = rects.selection.concat(rects.mask);
18998
+ selectionNode.children = rects.selection.map(item => ({
19702
18999
  sel: 'path',
19703
19000
  data: {
19704
19001
  ns: 'http://www.w3.org/2000/svg',
@@ -19711,7 +19008,7 @@ class DocumentSvg {
19711
19008
  }
19712
19009
  }
19713
19010
  }));
19714
- hightlightNode.children = this.highlights;
19011
+ highlightNode.children = this.highlights;
19715
19012
  return pageSvg;
19716
19013
  }
19717
19014
  counterMap = {};
@@ -19731,6 +19028,25 @@ class DocumentSvg {
19731
19028
  addChangeTips(tipVNode) {
19732
19029
  this.changeTips.push(tipVNode);
19733
19030
  }
19031
+ /**
19032
+ * 合并段落行选区
19033
+ * @param parentMaskRect
19034
+ * @param currMaskRect
19035
+ * @param currPos
19036
+ * @private
19037
+ */
19038
+ combineParaLineSelection(parentMaskRect, currMaskRect, currPos) {
19039
+ const startX = currMaskRect[0].x;
19040
+ const endX = currMaskRect[currMaskRect.length - 1].x + currMaskRect[currMaskRect.length - 1].width;
19041
+ parentMaskRect.push({
19042
+ x: startX,
19043
+ y: currPos.y,
19044
+ width: endX - startX,
19045
+ height: currPos.height,
19046
+ color: currMaskRect[0].color
19047
+ });
19048
+ currMaskRect.length = 0;
19049
+ }
19734
19050
  }
19735
19051
 
19736
19052
  /**
@@ -19743,7 +19059,7 @@ class EditorCalendarVNode {
19743
19059
  currCalendarMode;
19744
19060
  selectedDate;
19745
19061
  currentDate = '';
19746
- onSetValue = new Subject$1();
19062
+ onSetValue = new Subject();
19747
19063
  currTime;
19748
19064
  selectedTime;
19749
19065
  constructor(viewOptions) {
@@ -20564,6 +19880,154 @@ class DocRule {
20564
19880
  }
20565
19881
  }
20566
19882
 
19883
+ function calculateOverflow(rect, viewport) {
19884
+ const overflow = rect.y + rect.height - (viewport.y + viewport.height);
19885
+ return overflow > 0 ? overflow : 0;
19886
+ }
19887
+ function adjustRectangles(rectangles, startIndex, endIndex, overflow) {
19888
+ for (let i = startIndex; i < endIndex; i++) {
19889
+ const currentRect = rectangles[i];
19890
+ currentRect.y -= overflow;
19891
+ }
19892
+ }
19893
+ function placeRectangles(rectangles, viewport) {
19894
+ // Step 1: 过滤视窗内的矩形并按y值排序
19895
+ const sortedRectangles = rectangles
19896
+ .filter(rect => rect.y + rect.height >= viewport.y &&
19897
+ rect.y <= viewport.y + viewport.height)
19898
+ .sort((a, b) => a.y - b.y);
19899
+ // Step 2: 遍历并调整矩形位置
19900
+ for (let i = 1; i < sortedRectangles.length; i++) {
19901
+ const currentRect = sortedRectangles[i];
19902
+ const prevRect = sortedRectangles[i - 1];
19903
+ // Step 3: 调整重叠矩形的位置
19904
+ if (currentRect.y < prevRect.y + prevRect.height) {
19905
+ currentRect.y = prevRect.y + prevRect.height;
19906
+ }
19907
+ // Step 4: 处理超出视窗的情况
19908
+ let overflow = calculateOverflow(currentRect, viewport);
19909
+ if (overflow <= 0) {
19910
+ continue;
19911
+ }
19912
+ //紧挨着的上级兄弟元素之间存在足够空间
19913
+ const remainingSpace = currentRect.y - prevRect.y - prevRect.height;
19914
+ if (remainingSpace > 0) {
19915
+ if (remainingSpace >= overflow) {
19916
+ currentRect.y -= overflow;
19917
+ continue;
19918
+ }
19919
+ else {
19920
+ overflow -= remainingSpace;
19921
+ adjustRectangles(sortedRectangles, i - 1, i, remainingSpace);
19922
+ currentRect.y -= remainingSpace;
19923
+ }
19924
+ }
19925
+ const space = findSpace(sortedRectangles, viewport, i - 1, i, overflow);
19926
+ //完全没有可用空间,后续元素按照顺序排列即可
19927
+ if (space === overflow) {
19928
+ const prevRect = sortedRectangles[i - 1];
19929
+ sortedRectangles.filter((item, index) => index >= i).reduce((prev, curr) => { curr.y = prev.y + prev.height; return curr; }, prevRect);
19930
+ break;
19931
+ }
19932
+ currentRect.y -= (overflow - space);
19933
+ }
19934
+ return sortedRectangles;
19935
+ }
19936
+ function findSpace(sortedRectangles, viewport, i, overflowIndex, overflow) {
19937
+ for (let j = i; j >= 0; j--) {
19938
+ let currentRect = sortedRectangles[j];
19939
+ let aboveRect = sortedRectangles[j - 1];
19940
+ if (aboveRect === undefined) {
19941
+ aboveRect = { y: viewport.y, height: 0, width: 0, x: 0 };
19942
+ }
19943
+ const remainingSpace = currentRect.y - aboveRect.y - aboveRect.height;
19944
+ //存在可用空间
19945
+ if (remainingSpace > 0) {
19946
+ if (remainingSpace >= overflow) {
19947
+ adjustRectangles(sortedRectangles, j, overflowIndex, overflow);
19948
+ return 0;
19949
+ }
19950
+ else {
19951
+ overflow -= remainingSpace;
19952
+ // 调整当前元素到溢出元素之间的元素的y值
19953
+ adjustRectangles(sortedRectangles, j, overflowIndex, remainingSpace);
19954
+ return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
19955
+ }
19956
+ }
19957
+ else {
19958
+ return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
19959
+ }
19960
+ }
19961
+ return overflow;
19962
+ }
19963
+ /**
19964
+ * 调整页面提示框位置,使其在视窗内的位置合理
19965
+ */
19966
+ function adjustViewportElements(tipContainer, viewPort) {
19967
+ viewPort.y /= viewPort.scale;
19968
+ viewPort.height /= viewPort.scale;
19969
+ const tipContainerEle = tipContainer.elm;
19970
+ const tipContainerRect = tipContainerEle.getBoundingClientRect();
19971
+ const children = tipContainer.children;
19972
+ if (!children || children.length === 0) {
19973
+ return;
19974
+ }
19975
+ const nativeEle = [];
19976
+ for (let i = 0; i < children.length; i++) {
19977
+ const item = children[i];
19978
+ const elm = item.elm;
19979
+ if (!elm.classList.contains("tg-container")) {
19980
+ continue;
19981
+ }
19982
+ const runKey = elm.dataset['key'];
19983
+ const lineElm = tipContainerEle.querySelector(`.doc-triangle-line[data-key='${runKey}']`);
19984
+ const linePos = getEleAbsolutePos(lineElm);
19985
+ const eleRect = { elm, lineElm, x: 0, y: 0, width: 0, height: 0, linePos };
19986
+ nativeEle.push(eleRect);
19987
+ const rect = elm.getBoundingClientRect();
19988
+ eleRect.y = linePos.y;
19989
+ eleRect.x = (rect.x - tipContainerRect.x) / viewPort.scale;
19990
+ eleRect.width = rect.width / viewPort.scale;
19991
+ eleRect.height = rect.height / viewPort.scale;
19992
+ }
19993
+ if (nativeEle.length) {
19994
+ const sortedRectangles = placeRectangles(nativeEle, viewPort);
19995
+ for (let i = 0; i < sortedRectangles.length; i++) {
19996
+ const item = sortedRectangles[i];
19997
+ item.elm.style.top = item.y + 'px';
19998
+ const rotationAngle = calculateRotationAngle(item.linePos, item);
19999
+ const distance = calculateDistance(item.linePos, item);
20000
+ rotateDiv(item.lineElm, rotationAngle, distance);
20001
+ }
20002
+ }
20003
+ }
20004
+ function getEleAbsolutePos(elm) {
20005
+ const topStr = elm.style.top;
20006
+ const leftStr = elm.style.left;
20007
+ return {
20008
+ x: parseInt(leftStr.substring(0, leftStr.length - 2)),
20009
+ y: parseInt(topStr.substring(0, topStr.length - 2))
20010
+ };
20011
+ }
20012
+ function calculateRotationAngle(a, b) {
20013
+ const deltaX = b.x - a.x;
20014
+ const deltaY = b.y - a.y;
20015
+ // 使用反正切函数计算旋转角度
20016
+ const angleInRadians = Math.atan2(deltaY, deltaX);
20017
+ // 将弧度转换为度数
20018
+ const angleInDegrees = angleInRadians * (180 / Math.PI);
20019
+ return angleInDegrees;
20020
+ }
20021
+ function rotateDiv(c, angle, distance) {
20022
+ c.style.transform = `rotate(${angle}deg)`;
20023
+ c.style.width = `${distance}px`;
20024
+ }
20025
+ function calculateDistance(a, b) {
20026
+ const deltaX = b.x - a.x;
20027
+ const deltaY = b.y - a.y;
20028
+ return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
20029
+ }
20030
+
20567
20031
  class DocEditor {
20568
20032
  svgContainer;
20569
20033
  //private docContent!: HTMLElement;
@@ -20581,28 +20045,25 @@ class DocEditor {
20581
20045
  selectionOverlays;
20582
20046
  //private docRule: DocRule;
20583
20047
  historyMange;
20584
- selectionChanged = new Subject$1();
20585
- beforeRenderSubject = new Subject$1();
20586
- afterRenderSubject = new Subject$1();
20587
- onBeforeSetCursorSubject = new Subject$1();
20588
- contentChanged = new Subject$1();
20589
- onPatchVNodeSubject = new Subject$1();
20048
+ selectionChanged = new Subject();
20049
+ beforeRenderSubject = new Subject();
20050
+ afterRenderSubject = new Subject();
20051
+ onBeforeSetCursorSubject = new Subject();
20052
+ contentChanged = new Subject();
20053
+ onPatchVNodeSubject = new Subject();
20590
20054
  selectionState;
20591
- //显示右键菜单
20592
- onContextMenuItemChanged = new Subject$1();
20593
- onDblClickEvent = new Subject$1();
20594
- onClickEvent = new Subject$1();
20595
- onScrollViewEvent = new Subject$1();
20055
+ onDblClickEvent = new Subject();
20056
+ onClickEvent = new Subject();
20596
20057
  //文档改变事件:内容及样式,业务模块需要根据此事件,来追踪当前文档是否改变的状态
20597
- onDocChangedEvent = new Subject$1();
20058
+ onDocChangedEvent = new Subject();
20598
20059
  //执行flushTask,refreshDoc之前,此时可以在文档计算排版之前改变内容
20599
- onBeforeRefreshDocument = new Subject$1();
20060
+ onBeforeRefreshDocument = new Subject();
20600
20061
  //文档视图尺寸改变事件
20601
- onDocViewSizeChanged = new Subject$1();
20062
+ onDocViewSizeChanged = new Subject();
20602
20063
  //编辑器销毁事件
20603
- onDestroy = new Subject$1();
20604
- beforeNodePatch = new Subject$1();
20605
- afterNodePatch = new Subject$1();
20064
+ onDestroy = new Subject();
20065
+ beforeNodePatch = new Subject();
20066
+ afterNodePatch = new Subject();
20606
20067
  //自定义事件传递消息
20607
20068
  eventBus;
20608
20069
  editInput;
@@ -20617,7 +20078,6 @@ class DocEditor {
20617
20078
  this.viewOptions.drawCharRectColor = 'green';
20618
20079
  this.viewOptions.showLineRect = true;
20619
20080
  this.viewOptions.docSpace = 20;
20620
- this.viewOptions.reviewWindowWidth = 200;
20621
20081
  this.viewOptions.defaultFontName = '宋体';
20622
20082
  this.viewOptions.editorVersion = this.version();
20623
20083
  //this.viewOptions.scale = 2;
@@ -20803,11 +20263,13 @@ class DocEditor {
20803
20263
  return null;
20804
20264
  }
20805
20265
  this.flushTask = () => {
20266
+ //读取变更记录,可能会同步影响文档内容
20267
+ this.readDocChangeLog();
20806
20268
  this.refreshDocument();
20807
20269
  this.flushTask = null;
20808
- let cb = this.docCtx.paintedCallback;
20270
+ let cb = this.docCtx.nextViewFn;
20809
20271
  if (cb) {
20810
- this.docCtx.setPaintedCallback(null);
20272
+ this.docCtx.onNextView(null);
20811
20273
  cb();
20812
20274
  return;
20813
20275
  }
@@ -21238,7 +20700,7 @@ class DocEditor {
21238
20700
  this.onDocViewSizeChanged.unsubscribe();
21239
20701
  this.flushTask = null;
21240
20702
  Object.keys(this).forEach(key => {
21241
- if (this[key] instanceof Subject$1) {
20703
+ if (this[key] instanceof Subject) {
21242
20704
  this[key].unsubscribe();
21243
20705
  }
21244
20706
  });
@@ -21344,7 +20806,7 @@ class DocEditor {
21344
20806
  }
21345
20807
  /**
21346
20808
  * 设置段落样式
21347
- * @param newProps
20809
+ * @param setterFunc
21348
20810
  */
21349
20811
  setParaStyleByFn(setterFunc) {
21350
20812
  DocumentChange.setParaStyle(this.selectionState, setterFunc);
@@ -21705,7 +21167,8 @@ class DocEditor {
21705
21167
  snabbdom.styleModule,
21706
21168
  snabbdom.classModule,
21707
21169
  snabbdom.attributesModule,
21708
- snabbdom.eventListenersModule
21170
+ snabbdom.eventListenersModule,
21171
+ snabbdom.datasetModule
21709
21172
  ]);
21710
21173
  setActiveEditorContext(this);
21711
21174
  const vNodeFunc = this.renderRoot();
@@ -21770,6 +21233,7 @@ class DocEditor {
21770
21233
  children.push(tipsContainer);
21771
21234
  children.push(...vNode);
21772
21235
  tipsContainer.children?.push(...svgGenerator.changeTips);
21236
+ this.updateTipLayoutWidth();
21773
21237
  const sub = this.afterNodePatch.subscribe(() => {
21774
21238
  this.updateTipLayoutAfterPatch();
21775
21239
  sub.unsubscribe();
@@ -21779,42 +21243,50 @@ class DocEditor {
21779
21243
  };
21780
21244
  }
21781
21245
  /**
21782
- * 更新留痕提示框位置在文档渲染后
21246
+ * 更新提示区域布局宽度,根据渲染的节点,判断是否需要设置提示区域宽度
21783
21247
  * @private
21784
21248
  */
21785
- updateTipLayoutAfterPatch() {
21786
- const children = this.tipContainer.children;
21787
- if (!children || children.length === 0) {
21788
- return;
21789
- }
21790
- let prevPos = { x: 0, y: -999999 };
21791
- const gap = 12;
21792
- for (let i = 0; i < children.length; i++) {
21793
- const item = children[i];
21794
- const elm = item.elm;
21795
- const topStr = elm.style.top;
21796
- let topPixs = Number.parseInt(topStr.substring(0, topStr.length - 2));
21797
- const rect = elm.getBoundingClientRect();
21798
- if (topPixs + gap < prevPos.y) {
21799
- topPixs = (prevPos.y + gap);
21800
- elm.style.top = topPixs + 'px';
21249
+ updateTipLayoutWidth() {
21250
+ const tipChildren = this.tipContainer?.children;
21251
+ if (!tipChildren || !tipChildren.length) {
21252
+ if (this.viewOptions.reviewWindowWidth > 0) {
21253
+ this.viewOptions.reviewWindowWidth = 0;
21254
+ //刷新页面
21255
+ this.adjustPageLayout();
21801
21256
  }
21802
- if (topPixs - prevPos.y < gap) {
21803
- elm.style.top = (prevPos.y + gap) + 'px';
21257
+ }
21258
+ else {
21259
+ if (this.viewOptions.reviewWindowWidth === 0) {
21260
+ this.viewOptions.reviewWindowWidth = 250;
21261
+ //刷新页面
21262
+ this.adjustPageLayout();
21804
21263
  }
21805
- prevPos.y = topPixs + rect.height;
21806
21264
  }
21807
21265
  }
21266
+ /**
21267
+ * 更新留痕提示框位置在文档渲染后
21268
+ * @private
21269
+ */
21270
+ updateTipLayoutAfterPatch() {
21271
+ const viewBoxRect = {
21272
+ x: this.viewOptions.pageOffset.x,
21273
+ y: this.viewOptions.pageOffset.y,
21274
+ width: this.viewOptions.viewSettings.width,
21275
+ height: this.viewOptions.viewSettings.height,
21276
+ scale: this.viewOptions.scale
21277
+ };
21278
+ adjustViewportElements(this.tipContainer, viewBoxRect);
21279
+ }
21808
21280
  createChangeTipContainer() {
21809
21281
  const docRect = this.documentPaginator.docContainer.getItems()[0].rect;
21810
- const x = docRect.x + docRect.width + 20;
21282
+ docRect.x + docRect.width + 20;
21811
21283
  return {
21812
- sel: 'div.tip-container',
21284
+ sel: 'div.decorate-container',
21813
21285
  data: {
21814
- style: {
21815
- left: x + 'px',
21816
- top: '0px',
21817
- }
21286
+ /* style: {
21287
+ left: x + 'px',
21288
+ top: '0px',
21289
+ }*/
21818
21290
  },
21819
21291
  children: []
21820
21292
  };
@@ -21895,7 +21367,6 @@ class DocEditor {
21895
21367
  },
21896
21368
  on: {
21897
21369
  click: (evt) => {
21898
- console.log('dd');
21899
21370
  onChangeHandler(item.code);
21900
21371
  }
21901
21372
  }
@@ -22063,7 +21534,7 @@ class DocEditor {
22063
21534
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
22064
21535
  }
22065
21536
  version() {
22066
- return "2.1.28";
21537
+ return "2.2.0";
22067
21538
  }
22068
21539
  switchPageHeaderEditor() {
22069
21540
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -22143,6 +21614,36 @@ class DocEditor {
22143
21614
  ])
22144
21615
  ]);
22145
21616
  }
21617
+ readDocChangeLog() {
21618
+ //获取文档的变更日志
21619
+ const ops = generatePatch(this.docCtx.document, false);
21620
+ for (let i = 0; i < ops.length; i++) {
21621
+ const op = ops[i];
21622
+ if ('delete' in op.ops) {
21623
+ const delItem = op.ops.delete;
21624
+ //获取删除的批注元素
21625
+ const getDelCommItems = ElementUtil.getMatchItems(delItem, (item) => item instanceof CommentElement);
21626
+ const maps = {};
21627
+ getDelCommItems.forEach(item => {
21628
+ let num = maps[item.props.id];
21629
+ if (num === undefined) {
21630
+ maps[item.props.id] = 1;
21631
+ }
21632
+ else {
21633
+ maps[item.props.id] = num + 1;
21634
+ }
21635
+ });
21636
+ //获取需要删除的批注元素
21637
+ const keys = Object.keys(maps).filter(key => maps[key] === 1);
21638
+ if (keys.length) {
21639
+ const commItems = this.docCtx.document.treeFilter(item => item instanceof CommentElement);
21640
+ const delCommItems = commItems.filter(item => keys.includes(item.props.id));
21641
+ delCommItems.forEach(item => item.remove());
21642
+ return true;
21643
+ }
21644
+ }
21645
+ }
21646
+ }
22146
21647
  }
22147
21648
 
22148
21649
  /**
@@ -27240,10 +26741,10 @@ class DocumentPrintOffscreenBase {
27240
26741
  docCtx;
27241
26742
  renderCtx;
27242
26743
  elementReader;
27243
- beforeRenderEvent = new Subject$1();
27244
- afterRenderEvent = new Subject$1();
27245
- beforePrint = new Subject$1();
27246
- afterPrint = new Subject$1();
26744
+ beforeRenderEvent = new Subject();
26745
+ afterRenderEvent = new Subject();
26746
+ beforePrint = new Subject();
26747
+ afterPrint = new Subject();
27247
26748
  constructor() {
27248
26749
  this.viewOptions = new ViewOptions();
27249
26750
  this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
@@ -27557,7 +27058,6 @@ exports.CommentElement = CommentElement;
27557
27058
  exports.CommentFactory = CommentFactory;
27558
27059
  exports.CommentRenderObject = CommentRenderObject;
27559
27060
  exports.CommentsFactory = CommentsFactory;
27560
- exports.CommentsUtil = CommentsUtil;
27561
27061
  exports.CommonUtil = CommonUtil;
27562
27062
  exports.CommsContainerElement = CommsContainerElement;
27563
27063
  exports.CommsContainerRenderObject = CommsContainerRenderObject;
@@ -27647,7 +27147,7 @@ exports.ElementSerialize = ElementSerialize;
27647
27147
  exports.ElementUtil = ElementUtil;
27648
27148
  exports.EventBus = EventBus;
27649
27149
  exports.EventMap = EventMap;
27650
- exports.EventSourceCore = EventSourceCore$1;
27150
+ exports.EventSourceCore = EventSourceCore;
27651
27151
  exports.FillNullSpaceElement = FillNullSpaceElement;
27652
27152
  exports.FillNullSpaceRenderObject = FillNullSpaceRenderObject;
27653
27153
  exports.GetTrackTipsEvent = GetTrackTipsEvent;
@@ -27711,9 +27211,9 @@ exports.SVGRenderObject = SVGRenderObject;
27711
27211
  exports.SelectionOverlays = SelectionOverlays;
27712
27212
  exports.SelectionRange = SelectionRange;
27713
27213
  exports.SelectionState = SelectionState;
27714
- exports.Subject = Subject$1;
27715
- exports.SubjectSubscription = SubjectSubscription$1;
27716
- exports.Subscription = Subscription$1;
27214
+ exports.Subject = Subject;
27215
+ exports.SubjectSubscription = SubjectSubscription;
27216
+ exports.Subscription = Subscription;
27717
27217
  exports.TabElement = TabElement;
27718
27218
  exports.TabFactory = TabFactory;
27719
27219
  exports.TabRenderObject = TabRenderObject;