@hailin-zheng/editor-core 2.1.28 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/editor.css +19 -4
  2. package/index-cjs.d.ts +12 -12
  3. package/index-cjs.js +728 -1119
  4. package/index-cjs.js.map +1 -1
  5. package/index.d.ts +12 -12
  6. package/index.js +745 -1137
  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 -2
  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/data-element/data-element-base-impl.d.ts +13 -0
  28. package/med_editor/framework/impl/document/doc-impl.d.ts +1 -11
  29. package/med_editor/framework/impl/index.d.ts +0 -1
  30. package/med_editor/framework/impl/table/table-split-cell.d.ts +1 -1
  31. package/med_editor/framework/impl/table/table-util.d.ts +1 -1
  32. package/med_editor/framework/impl/text/track-run-impl.d.ts +2 -2
  33. package/med_editor/framework/{document-print-offscreen.d.ts → print/document-print-offscreen.d.ts} +8 -8
  34. package/med_editor/framework/{document-print.d.ts → print/document-print.d.ts} +1 -1
  35. package/med_editor/framework/{document-selection.d.ts → selection/document-selection.d.ts} +5 -5
  36. package/med_editor/framework/{range-util.d.ts → selection/range-util.d.ts} +2 -2
  37. package/med_editor/framework/{selection-overlays.d.ts → selection/selection-overlays.d.ts} +1 -1
  38. package/med_editor/framework/util/adjust-viewport-elements.d.ts +12 -0
  39. package/med_editor/framework/{common-util.d.ts → util/common-util.d.ts} +2 -2
  40. package/med_editor/framework/{document-segmenter.d.ts → util/document-segmenter.d.ts} +1 -1
  41. package/med_editor/framework/{element-util.d.ts → util/element-util.d.ts} +13 -12
  42. package/med_editor/framework/{editor-calendar-vnode.d.ts → vnode/editor-calendar-vnode.d.ts} +4 -4
  43. package/package.json +2 -2
  44. package/controls/ButtonBase.d.ts +0 -10
  45. package/controls/Canvas.d.ts +0 -7
  46. package/controls/Config.d.ts +0 -12
  47. package/controls/FlexBox.d.ts +0 -81
  48. package/controls/Input.d.ts +0 -33
  49. package/controls/MedTimeLine/TimeAxis.d.ts +0 -21
  50. package/controls/MedTimeLine/TimeSlider.d.ts +0 -19
  51. package/controls/Menu.d.ts +0 -31
  52. package/controls/Node.d.ts +0 -232
  53. package/controls/NodeEvent.d.ts +0 -138
  54. package/controls/Rect.d.ts +0 -4
  55. package/controls/ScrollView.d.ts +0 -57
  56. package/controls/StackPanel.d.ts +0 -27
  57. package/controls/SurfaceView.d.ts +0 -44
  58. package/controls/Text.d.ts +0 -46
  59. package/controls/TextBase.d.ts +0 -19
  60. package/controls/ViewPaint.d.ts +0 -64
  61. package/controls/Window.d.ts +0 -27
  62. package/controls/WrapPanel.d.ts +0 -10
  63. package/controls/event-subject.d.ts +0 -42
  64. package/med_editor/framework/impl/comments/comments-util.d.ts +0 -5
  65. package/med_editor/rule-control.d.ts +0 -66
  66. package/timeline/TimeLineControl.d.ts +0 -47
  67. package/timeline/TimeValueGridControl.d.ts +0 -106
  68. package/timeline/TimelineConfig.d.ts +0 -68
  69. package/timeline/TimelineScrollbar.d.ts +0 -25
  70. package/timeline/TimelineStatus.d.ts +0 -61
  71. package/timeline/TimelineTick.d.ts +0 -63
  72. package/timeline/example.d.ts +0 -2
  73. /package/med_editor/framework/{ast-parser.d.ts → code-interpreter/ast-parser.d.ts} +0 -0
  74. /package/med_editor/framework/{event-subject.d.ts → infrastructure/event-subject.d.ts} +0 -0
  75. /package/med_editor/framework/{notify.d.ts → infrastructure/notify.d.ts} +0 -0
package/index.js CHANGED
@@ -4,7 +4,7 @@ import * as acor from 'acorn';
4
4
  import { generate } from 'astring';
5
5
  import estraverse from 'estraverse';
6
6
  import JsBarcode from 'jsbarcode';
7
- import { toVNode, init as init$1, styleModule, classModule, attributesModule, eventListenersModule, h } from 'snabbdom';
7
+ import { toVNode, init as init$1, styleModule, classModule, attributesModule, eventListenersModule, datasetModule, h } from 'snabbdom';
8
8
 
9
9
  /**
10
10
  * 元素事件
@@ -804,28 +804,21 @@ function getDocCtx(ele) {
804
804
  if (!doc) {
805
805
  return null;
806
806
  }
807
- const options = doc['viewOptions'];
808
- if (!options || !options.enableTrackHistory) {
809
- return null;
810
- }
811
- return {
812
- doc,
813
- options: doc['viewOptions']
814
- };
807
+ return doc;
815
808
  }
816
809
  function insertEle(ele) {
817
810
  if (ele.type === 'psym') {
818
811
  return;
819
812
  }
820
- const options = getDocCtx(ele);
821
- if (!options) {
813
+ const docCtx = getDocCtx(ele);
814
+ if (!docCtx) {
822
815
  return;
823
816
  }
824
817
  // const serializeObj = getEleSerializeFunc(ele, options);
825
818
  // if (!serializeObj) {
826
819
  // return;
827
820
  // }
828
- appendToOps(options.doc, ele, {
821
+ appendToOps(docCtx, ele, {
829
822
  //如果当前插入的为单元格,由于新插入的单元格,内部的内容没有补足,导致后续计算索引会出现问题
830
823
  //之前为ele.clone(true);
831
824
  insert: ele
@@ -835,11 +828,11 @@ function removeEle(ele) {
835
828
  if (ele.type === 'psym') {
836
829
  return;
837
830
  }
838
- const options = getDocCtx(ele);
839
- if (!options) {
831
+ const docCtx = getDocCtx(ele);
832
+ if (!docCtx) {
840
833
  return;
841
834
  }
842
- appendToOps(options.doc, ele, {
835
+ appendToOps(docCtx, ele, {
843
836
  delete: ele.clone(true),
844
837
  });
845
838
  }
@@ -862,15 +855,15 @@ function getOpsLog(ele, ops) {
862
855
  };
863
856
  }
864
857
  function inputText(ele, startIndex, input) {
865
- const options = getDocCtx(ele);
866
- if (!options) {
858
+ const docCtx = getDocCtx(ele);
859
+ if (!docCtx) {
867
860
  return;
868
861
  }
869
862
  if (!input) {
870
863
  return;
871
864
  }
872
865
  //处理修复:如果当前的文字刚插入,这时候输入的文字内容已经被序列化到操作日志中了,就不需要生成操作日志
873
- let array = docOpsMap.get(options.doc);
866
+ let array = docOpsMap.get(docCtx);
874
867
  if (array) {
875
868
  const lastLog = array[array.length - 1];
876
869
  if (lastLog && 'insert' in lastLog.ops) {
@@ -879,7 +872,7 @@ function inputText(ele, startIndex, input) {
879
872
  }
880
873
  }
881
874
  }
882
- appendToOps(options.doc, ele, {
875
+ appendToOps(docCtx, ele, {
883
876
  insText: {
884
877
  index: startIndex,
885
878
  length: input.length
@@ -888,14 +881,14 @@ function inputText(ele, startIndex, input) {
888
881
  });
889
882
  }
890
883
  function removeText(ele, index, length, content) {
891
- const options = getDocCtx(ele);
892
- if (!options) {
884
+ const docCtx = getDocCtx(ele);
885
+ if (!docCtx) {
893
886
  return;
894
887
  }
895
888
  if (!length) {
896
889
  return;
897
890
  }
898
- appendToOps(options.doc, ele, {
891
+ appendToOps(docCtx, ele, {
899
892
  delText: {
900
893
  index,
901
894
  length
@@ -910,15 +903,15 @@ function removeText(ele, index, length, content) {
910
903
  * @returns
911
904
  */
912
905
  function formatEle(ele, props) {
913
- const options = getDocCtx(ele);
914
- if (!options) {
906
+ const docCtx = getDocCtx(ele);
907
+ if (!docCtx) {
915
908
  return;
916
909
  }
917
910
  const updateKeys = Object.keys(props);
918
911
  if (!updateKeys.length) {
919
912
  return;
920
913
  }
921
- appendToOps(options.doc, ele, {
914
+ appendToOps(docCtx, ele, {
922
915
  format: getExactDiffProps(ele.props, props)
923
916
  });
924
917
  }
@@ -930,11 +923,11 @@ function formatEle(ele, props) {
930
923
  * @param newValue
931
924
  */
932
925
  function logUpdateEleProps(ele, p, oldValue, newValue) {
933
- const options = getDocCtx(ele);
934
- if (!options) {
926
+ const docCtx = getDocCtx(ele);
927
+ if (!docCtx) {
935
928
  return;
936
929
  }
937
- appendToOps(options.doc, ele, {
930
+ appendToOps(docCtx, ele, {
938
931
  format: {
939
932
  [p]: {
940
933
  oldValue,
@@ -951,7 +944,7 @@ function getExactDiffProps(oldProps, newProps) {
951
944
  });
952
945
  return obj;
953
946
  }
954
- function generatePatch(doc) {
947
+ function generatePatch(doc, clear = true) {
955
948
  const insertOpsMap = new Map();
956
949
  const formatOpsMap = new Map();
957
950
  const patches = [];
@@ -977,6 +970,9 @@ function generatePatch(doc) {
977
970
  }
978
971
  formatOpsMap.set(ele, op);
979
972
  }
973
+ if ('insert' in op.ops) {
974
+ insertOpsMap.set(ele, op);
975
+ }
980
976
  // if ('insert' in op.ops) {
981
977
  // op.ops.insert = ele.clone(true);
982
978
  // const log = getOpsLog(ele, op.ops);
@@ -984,17 +980,17 @@ function generatePatch(doc) {
984
980
  // op.prevIndex = log.prevIndex;
985
981
  // op.parentIndex = log.parentIndex;
986
982
  // }
987
- if ('insert' in op.ops) {
988
- const prevEle = ElementUtil.getPrevSiblingElement(ele);
989
- op.ops.insert = ele.clone(true);
990
- op.index = ElementUtil.getControlIndex(ele, true);
991
- op.parentIndex = ElementUtil.getControlIndex(ele.parent, true);
992
- op.prevIndex = prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1;
993
- }
983
+ // if ('insert' in op.ops) {
984
+ // const prevEle = ElementUtil.getPrevSiblingElement(ele);
985
+ // op.ops.insert = ele.clone(true);
986
+ // op.index = ElementUtil.getControlIndex(ele, true);
987
+ // op.parentIndex = ElementUtil.getControlIndex(ele.parent, true);
988
+ // op.prevIndex = prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1;
989
+ // }
994
990
  patches.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
995
991
  }
996
992
  //清空
997
- ops.length = 0;
993
+ clear && (ops.length = 0);
998
994
  return patches;
999
995
  }
1000
996
  /**
@@ -1025,11 +1021,11 @@ function mergeDiffProps(prevFormat, currFormat) {
1025
1021
  /**
1026
1022
  * 订阅者
1027
1023
  */
1028
- class Subscription$1 {
1024
+ class Subscription {
1029
1025
  closed = false;
1030
1026
  once = false;
1031
1027
  }
1032
- class EventSourceCore$1 {
1028
+ class EventSourceCore {
1033
1029
  closed = false;
1034
1030
  subs = [];
1035
1031
  next(data) {
@@ -1058,7 +1054,7 @@ class EventSourceCore$1 {
1058
1054
  /**
1059
1055
  * DOM事件处理
1060
1056
  */
1061
- class DOMEventSource extends EventSourceCore$1 {
1057
+ class DOMEventSource extends EventSourceCore {
1062
1058
  dom;
1063
1059
  type;
1064
1060
  constructor(dom, type) {
@@ -1078,7 +1074,7 @@ class DOMEventSource extends EventSourceCore$1 {
1078
1074
  return sub;
1079
1075
  }
1080
1076
  }
1081
- class DOMSubscription extends Subscription$1 {
1077
+ class DOMSubscription extends Subscription {
1082
1078
  listener;
1083
1079
  cancel;
1084
1080
  constructor(listener, cancel) {
@@ -1097,23 +1093,23 @@ class DOMSubscription extends Subscription$1 {
1097
1093
  this.cancel();
1098
1094
  }
1099
1095
  }
1100
- class Subject$1 extends EventSourceCore$1 {
1096
+ class Subject extends EventSourceCore {
1101
1097
  subscribe(listener) {
1102
- const sub = new SubjectSubscription$1(listener, () => {
1098
+ const sub = new SubjectSubscription(listener, () => {
1103
1099
  this.removeSub(sub);
1104
1100
  });
1105
1101
  this.addSub(sub);
1106
1102
  return sub;
1107
1103
  }
1108
1104
  }
1109
- class OnceSubject extends Subject$1 {
1105
+ class OnceSubject extends Subject {
1110
1106
  subscribe(listener) {
1111
1107
  const sub = super.subscribe(listener);
1112
1108
  sub.once = true;
1113
1109
  return sub;
1114
1110
  }
1115
1111
  }
1116
- class SubjectSubscription$1 extends Subscription$1 {
1112
+ class SubjectSubscription extends Subscription {
1117
1113
  listener;
1118
1114
  cancel;
1119
1115
  constructor(listener, cancel) {
@@ -1143,7 +1139,7 @@ class EventBus {
1143
1139
  handlers = [];
1144
1140
  this.subs.set(event, handlers);
1145
1141
  }
1146
- const sub = new Subject$1();
1142
+ const sub = new Subject();
1147
1143
  sub.subscribe(handler);
1148
1144
  handlers.push(sub);
1149
1145
  }
@@ -1179,7 +1175,7 @@ class Rect {
1179
1175
  /**
1180
1176
  * 修改标志
1181
1177
  */
1182
- var ModifyFlag$1;
1178
+ var ModifyFlag;
1183
1179
  (function (ModifyFlag) {
1184
1180
  //被修改
1185
1181
  ModifyFlag[ModifyFlag["Modify"] = 0] = "Modify";
@@ -1187,7 +1183,7 @@ var ModifyFlag$1;
1187
1183
  ModifyFlag[ModifyFlag["None"] = 1] = "None";
1188
1184
  //子项被修改
1189
1185
  ModifyFlag[ModifyFlag["Track"] = 2] = "Track";
1190
- })(ModifyFlag$1 || (ModifyFlag$1 = {}));
1186
+ })(ModifyFlag || (ModifyFlag = {}));
1191
1187
  /**
1192
1188
  * 类型事件处理
1193
1189
  */
@@ -1215,11 +1211,11 @@ function invokeTypeHandler(ele, eventName, e, useCapture = false) {
1215
1211
  */
1216
1212
  class Element {
1217
1213
  type;
1218
- modifyFlag = ModifyFlag$1.Modify;
1214
+ modifyFlag = ModifyFlag.Modify;
1219
1215
  isMouseenter;
1220
1216
  _eventMap;
1221
- _refreshEvent = new Subject$1();
1222
- _onChangeEvent = new Subject$1();
1217
+ _refreshEvent = new Subject();
1218
+ _onChangeEvent = new Subject();
1223
1219
  observers = new WeakMap();
1224
1220
  paintRenders = [];
1225
1221
  cacheRender;
@@ -1373,22 +1369,22 @@ class LeafElement extends Element {
1373
1369
  return 1;
1374
1370
  }
1375
1371
  pubOnChange(selfChange) {
1376
- if (this.modifyFlag === ModifyFlag$1.None) {
1372
+ if (this.modifyFlag === ModifyFlag.None) {
1377
1373
  this.refreshView();
1378
1374
  }
1379
- if (this.modifyFlag === ModifyFlag$1.Track && selfChange === 'tracker') {
1375
+ if (this.modifyFlag === ModifyFlag.Track && selfChange === 'tracker') {
1380
1376
  return;
1381
1377
  }
1382
- if (this.modifyFlag === ModifyFlag$1.Modify) {
1378
+ if (this.modifyFlag === ModifyFlag.Modify) {
1383
1379
  return;
1384
1380
  }
1385
1381
  if (selfChange === 'tracker') {
1386
- if (this.modifyFlag === ModifyFlag$1.None) {
1387
- this.modifyFlag = ModifyFlag$1.Track;
1382
+ if (this.modifyFlag === ModifyFlag.None) {
1383
+ this.modifyFlag = ModifyFlag.Track;
1388
1384
  }
1389
1385
  }
1390
1386
  else {
1391
- this.modifyFlag = ModifyFlag$1.Modify;
1387
+ this.modifyFlag = ModifyFlag.Modify;
1392
1388
  }
1393
1389
  this._onChangeEvent.next();
1394
1390
  }
@@ -1490,15 +1486,22 @@ class BranchElement extends Element {
1490
1486
  }, 0);
1491
1487
  }
1492
1488
  getSelfLength(pure) {
1493
- return 1 + this.chilren.reduce((prev, curr) => {
1489
+ const len = 1 + this.chilren.reduce((prev, curr) => {
1494
1490
  return prev + curr.getSelfLength(pure);
1495
1491
  }, 0);
1492
+ //fixed:block-container类型的元素,比如表格单元格,再插入元素的时候,内部没有
1493
+ //段落,但是在文档排版时,会补充段落元素;因此在插入时,统计的index和len是有问题的
1494
+ //因此在统计的时候,手动将数量修复
1495
+ if (len === 1 && this instanceof BlockContainerElement) {
1496
+ return 2;
1497
+ }
1498
+ return len;
1496
1499
  }
1497
1500
  treeFilter(predicate) {
1498
1501
  const items = [];
1499
1502
  for (let i = 0; i < this.length; i++) {
1500
1503
  const item = this.getChild(i);
1501
- if (predicate(item, i)) {
1504
+ if (predicate(item)) {
1502
1505
  items.push(item);
1503
1506
  }
1504
1507
  if (item instanceof BranchElement) {
@@ -1510,7 +1513,7 @@ class BranchElement extends Element {
1510
1513
  treeFind(predicate) {
1511
1514
  for (let i = 0; i < this.length; i++) {
1512
1515
  const item = this.getChild(i);
1513
- if (predicate(item, i)) {
1516
+ if (predicate(item)) {
1514
1517
  return item;
1515
1518
  }
1516
1519
  if (item instanceof BranchElement) {
@@ -1523,19 +1526,19 @@ class BranchElement extends Element {
1523
1526
  return null;
1524
1527
  }
1525
1528
  pubOnChange(selfChange) {
1526
- if (this.modifyFlag === ModifyFlag$1.Track && selfChange === 'tracker') {
1529
+ if (this.modifyFlag === ModifyFlag.Track && selfChange === 'tracker') {
1527
1530
  return;
1528
1531
  }
1529
- if (this.modifyFlag === ModifyFlag$1.Modify) {
1532
+ if (this.modifyFlag === ModifyFlag.Modify) {
1530
1533
  return;
1531
1534
  }
1532
1535
  if (selfChange === 'tracker') {
1533
- if (this.modifyFlag === ModifyFlag$1.None) {
1534
- this.modifyFlag = ModifyFlag$1.Track;
1536
+ if (this.modifyFlag === ModifyFlag.None) {
1537
+ this.modifyFlag = ModifyFlag.Track;
1535
1538
  }
1536
1539
  }
1537
1540
  else {
1538
- this.modifyFlag = ModifyFlag$1.Modify;
1541
+ this.modifyFlag = ModifyFlag.Modify;
1539
1542
  //clearChildrenRenderCache(this);
1540
1543
  for (let i = 0; i < this.length; i++) {
1541
1544
  this.getChild(i).pubOnChange('to-child');
@@ -1757,28 +1760,12 @@ class ViewOptions {
1757
1760
  defaultIndent = 20;
1758
1761
  //内容区宽度,受审阅窗口宽度影响
1759
1762
  get contentWidth() {
1760
- if (this.showReviewWindow) {
1761
- return this.docPageSettings.width + this.reviewWindowWidth;
1762
- }
1763
- return this.docPageSettings.width;
1764
- }
1765
- /**
1766
- * 内容区域的高度
1767
- * 同时限定canvas的最小宽度
1768
- */
1769
- get ContentWidth() {
1770
- let width = this.docPageSettings.width;
1771
- if (this.showReviewWindow) {
1772
- width = width + this.reviewWindowWidth;
1773
- }
1774
- return width;
1763
+ return this.docPageSettings.width + this.reviewWindowWidth;
1775
1764
  }
1776
1765
  //两个页的间距
1777
1766
  docSpace = 0;
1778
- //是否显示审阅窗口
1779
- showReviewWindow = false;
1780
1767
  //审阅窗口宽度
1781
- reviewWindowWidth = 200;
1768
+ reviewWindowWidth = 0;
1782
1769
  //缩放
1783
1770
  _scale = 1;
1784
1771
  get scale() {
@@ -1817,7 +1804,7 @@ class ViewOptions {
1817
1804
  editUser = { id: '', name: '' };
1818
1805
  //留痕区域的生效时间段,同一用户的留痕块在此时间外需要生成新的留痕块
1819
1806
  trackChangePeriod = 10;
1820
- onChange = new Subject$1();
1807
+ onChange = new Subject();
1821
1808
  //打印模式,普通模式,续打模式
1822
1809
  printMode = 'normal';
1823
1810
  constructor() {
@@ -2386,7 +2373,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2386
2373
  printable;
2387
2374
  secretBrowse;
2388
2375
  editable = true;
2389
- deleteable;
2390
2376
  minLength;
2391
2377
  underline;
2392
2378
  expression;
@@ -2402,7 +2388,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2402
2388
  target.fieldName = source.fieldName;
2403
2389
  target.required = source.required;
2404
2390
  target.editable = source.editable;
2405
- target.deleteable = source.deleteable;
2406
2391
  target.secretBrowse = source.secretBrowse;
2407
2392
  target.printable = source.printable;
2408
2393
  target.minLength = source.minLength;
@@ -2432,9 +2417,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2432
2417
  if (!this.editable) {
2433
2418
  props['editable'] = this.editable;
2434
2419
  }
2435
- if (this.deleteable) {
2436
- props["deleteable"] = this.deleteable;
2437
- }
2438
2420
  if (this.minLength) {
2439
2421
  props["minLength"] = this.minLength;
2440
2422
  }
@@ -2886,65 +2868,6 @@ class BodyPartProps extends INotifyPropertyChanged {
2886
2868
  }
2887
2869
  }
2888
2870
 
2889
- class CommsContainerElement extends BlockContainerElement {
2890
- constructor() {
2891
- super('comm-list');
2892
- }
2893
- createRenderObject(data) {
2894
- const render = new CommsContainerRenderObject(this);
2895
- render.rect.width = data.options.reviewWindowWidth;
2896
- return render;
2897
- }
2898
- serialize(viewOptions) {
2899
- return {
2900
- type: this.type,
2901
- props: {}
2902
- };
2903
- }
2904
- clone(data) {
2905
- const clone = new CommsContainerElement();
2906
- cloneElementBase(this, clone);
2907
- cloneChildren(this, clone, data);
2908
- return clone;
2909
- }
2910
- }
2911
- class CommsContainerRenderObject extends BlockContainerRenderObject {
2912
- //批注内容是否已经重组,只要重新绘制的时候组合一次即可
2913
- isMeasureComm;
2914
- commsMarks = [];
2915
- clone() {
2916
- const clone = new CommsContainerRenderObject(this.element);
2917
- clone.rect = ElementUtil.cloneRect(this.rect);
2918
- for (let i = 0; i < this.length; i++) {
2919
- clone.addChild(this.getChild(i).clone());
2920
- }
2921
- return clone;
2922
- }
2923
- exportSVG(event) {
2924
- const t = super.exportSVG(event);
2925
- t.children = [ElementUtil.createSvgEle('rect', {
2926
- x: 0,
2927
- y: 0,
2928
- width: this.rect.width,
2929
- height: this.rect.height,
2930
- fill: '#fafafa',
2931
- stroke: 'black',
2932
- 'paint-order': 'stroke fill markers',
2933
- 'stroke-width': 0.5,
2934
- })];
2935
- return t;
2936
- }
2937
- }
2938
- class CommentsFactory extends ElementFactory {
2939
- match(type) {
2940
- return type === "comm-list";
2941
- }
2942
- createElement(data) {
2943
- const commentsEle = new CommsContainerElement();
2944
- return commentsEle;
2945
- }
2946
- }
2947
-
2948
2871
  class DataDecorateElement extends LeafElement {
2949
2872
  dataEle;
2950
2873
  isPrefix;
@@ -3111,7 +3034,7 @@ class ParagraphElement extends BlockContentElement {
3111
3034
  super('p');
3112
3035
  this.props = new ParagraphProps();
3113
3036
  this.addEvent('BackspaceKey', (evt) => {
3114
- if (evt.selectionState.collapsed) {
3037
+ if (evt.selectionState.editable && evt.selectionState.collapsed) {
3115
3038
  const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
3116
3039
  if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
3117
3040
  if (this.props.numberType >= 0) {
@@ -3127,7 +3050,7 @@ class ParagraphElement extends BlockContentElement {
3127
3050
  }, true);
3128
3051
  this.addEvent('ElementKeyDown', evt => {
3129
3052
  //当前存在缩进,点击tab
3130
- if (evt.sourceEvent.keyCode === 9) {
3053
+ if (evt.selectionState.editable && evt.sourceEvent.keyCode === 9) {
3131
3054
  const { startControl, startOffset } = evt.selectionState;
3132
3055
  if (startOffset === 0 && startControl === this.getChild(0)) {
3133
3056
  const defaultIndent = evt.ctx.viewOptions.defaultIndent;
@@ -3643,60 +3566,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3643
3566
  render.contentContext.drawText(viewOptions.copyRightInfo, textP, position.x + 5, position.y + 5, 100, 12);
3644
3567
  }
3645
3568
  }
3646
- /**
3647
- * 绘制文档边距线
3648
- */
3649
- drawMarginLine(position, render, docWidth, docHeight) {
3650
- const padding = this.padding;
3651
- let paddingPos = { x: padding.left + position.x, y: padding.top + position.y };
3652
- const drawLineWidth = 0.5;
3653
- const lineWidth = 20;
3654
- render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
3655
- x: paddingPos.x,
3656
- y: paddingPos.y - lineWidth
3657
- }], drawLineWidth);
3658
- paddingPos = { x: docWidth - padding.right + position.x, y: padding.top + position.y };
3659
- render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
3660
- x: paddingPos.x,
3661
- y: paddingPos.y - lineWidth
3662
- }], drawLineWidth);
3663
- paddingPos = { x: padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
3664
- render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
3665
- x: paddingPos.x,
3666
- y: paddingPos.y + lineWidth
3667
- }], drawLineWidth);
3668
- paddingPos = { x: docWidth - padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
3669
- render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
3670
- x: paddingPos.x,
3671
- y: paddingPos.y + lineWidth
3672
- }], drawLineWidth);
3673
- }
3674
- /**
3675
- * 绘制水印
3676
- * @param ctx
3677
- * @param position
3678
- */
3679
- drawWatermark(ctx, viewOptions, position) {
3680
- if (viewOptions.watermark) {
3681
- const watermark = viewOptions.watermark;
3682
- ctx.contentContext.ctx.save();
3683
- ctx.contentContext.ctx.translate(position.x, position.y);
3684
- const { width, height } = this.rect;
3685
- const degrees = Math.atan(height / width) * 180 / Math.PI;
3686
- ctx.contentContext.ctx.rotate(degrees * Math.PI / 180);
3687
- ctx.contentContext.ctx.globalAlpha = 0.3;
3688
- const d = Math.sqrt(width * width + height * height);
3689
- const textProps = new TextProps();
3690
- textProps.color = "#000000";
3691
- textProps.fontName = '楷体';
3692
- textProps.fontSize = 60;
3693
- const textWidth = ctx.contentContext.measureText(watermark, textProps).width;
3694
- const x = d / 2 - textWidth / 2;
3695
- ctx.contentContext.ctx.font = textProps.getFont();
3696
- ctx.contentContext.ctx.fillText(watermark, x, 30);
3697
- ctx.contentContext.ctx.restore();
3698
- }
3699
- }
3700
3569
  clone() {
3701
3570
  throw new Error('未实现');
3702
3571
  }
@@ -3741,9 +3610,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3741
3610
  return pageNumNode;
3742
3611
  }
3743
3612
  exportSVG(event) {
3744
- const padding = this.padding;
3745
- event.options.docPageSettings;
3746
- ({ x: padding.left, y: padding.top });
3747
3613
  const selection = {
3748
3614
  sel: "g",
3749
3615
  data: {
@@ -3774,7 +3640,8 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3774
3640
  width: this.rect.width,
3775
3641
  height: this.rect.height - 1,
3776
3642
  viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
3777
- overflow: "hidden"
3643
+ overflow: "hidden",
3644
+ "shape-rendering": "optimizeSpeed"
3778
3645
  },
3779
3646
  },
3780
3647
  children: [
@@ -4066,6 +3933,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
4066
3933
  }
4067
3934
  });
4068
3935
  }
3936
+ renderErrorTip(event, this);
4069
3937
  return node;
4070
3938
  }
4071
3939
  }
@@ -4121,6 +3989,11 @@ class DataElementBaseFactory extends ElementFactory {
4121
3989
  }
4122
3990
  }
4123
3991
  }
3992
+ /**
3993
+ * 渲染数据元背景修饰
3994
+ * @param event
3995
+ * @param r
3996
+ */
4124
3997
  function exportDecoratorHTML(event, r) {
4125
3998
  const canPaint = r.element.isMouseenter || r.element.isFocused;
4126
3999
  if (!canPaint) {
@@ -4165,10 +4038,12 @@ function exportDecoratorHTML(event, r) {
4165
4038
  const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
4166
4039
  const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
4167
4040
  const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
4168
- event.highlights.push(ElementUtil.createSvgPath({ d: path,
4041
+ event.highlights.push(ElementUtil.createSvgPath({
4042
+ d: path,
4169
4043
  stroke: color,
4170
4044
  fill: 'none',
4171
- 'stroke-width': 1 }));
4045
+ 'stroke-width': 1
4046
+ }));
4172
4047
  return;
4173
4048
  }
4174
4049
  }
@@ -4183,6 +4058,110 @@ function exportDecoratorHTML(event, r) {
4183
4058
  }
4184
4059
  }
4185
4060
  }
4061
+ /**
4062
+ * 渲染数据源验证错误提示框
4063
+ */
4064
+ function renderErrorTip(event, r) {
4065
+ if (!event.options.enableDataEleInputValidate || event.mode === 'print') {
4066
+ return;
4067
+ }
4068
+ const ele = r.element;
4069
+ //元素调用内部验证
4070
+ ele.onChangedValidate();
4071
+ if (!ele.errorTip) {
4072
+ return;
4073
+ }
4074
+ //渲染底部波浪线
4075
+ renderUnderWavyLine(event, r, 'red');
4076
+ if (ele.paintRenders.indexOf(r) !== 0) {
4077
+ return;
4078
+ }
4079
+ const { x, y } = event.globalPos;
4080
+ const docRender = ElementUtil.getParentRender(r, DocumentRenderObject);
4081
+ const content = ele.errorTip;
4082
+ let left = ele.isFocused ? -10 : 5;
4083
+ //显示在文档的右测
4084
+ left += docRender.rect.x + docRender.rect.width + 20;
4085
+ let sel = 'div.tg-container';
4086
+ if (ele.isFocused) {
4087
+ sel += '.tg-container--selected';
4088
+ }
4089
+ const node = {
4090
+ sel,
4091
+ key: ele.props.id,
4092
+ data: {
4093
+ style: {
4094
+ left: `${left}px`,
4095
+ top: `${y}px`
4096
+ },
4097
+ dataset: {
4098
+ key: ele.key
4099
+ }
4100
+ },
4101
+ children: [{
4102
+ sel: 'div.header',
4103
+ data: {},
4104
+ children: [{
4105
+ sel: 'span.header-user',
4106
+ data: {},
4107
+ text: ele.props.caption,
4108
+ }]
4109
+ }, {
4110
+ sel: 'div.content',
4111
+ data: {},
4112
+ text: content
4113
+ }]
4114
+ };
4115
+ event.addChangeTips(node);
4116
+ const triangleTipX = x + r.rect.width / 2;
4117
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
4118
+ const tipLineA = {
4119
+ sel: 'div.doc-triangle-line',
4120
+ data: {
4121
+ style: {
4122
+ left: `${triangleTipX}px`,
4123
+ top: `${y + r.rect.height}px`,
4124
+ width: tipLineAWidth + 'px'
4125
+ }
4126
+ }
4127
+ };
4128
+ const tipLineB = {
4129
+ sel: 'div.doc-triangle-line',
4130
+ data: {
4131
+ style: {
4132
+ left: `${triangleTipX + tipLineAWidth}px`,
4133
+ top: `${y + r.rect.height}px`,
4134
+ width: 20 + 'px'
4135
+ },
4136
+ dataset: {
4137
+ key: ele.key
4138
+ }
4139
+ }
4140
+ };
4141
+ const triangleTip = {
4142
+ sel: `div.doc-triangle`,
4143
+ data: {
4144
+ style: {
4145
+ left: `${triangleTipX}px`,
4146
+ top: `${y + r.rect.height * 2 / 3}px`
4147
+ }
4148
+ }
4149
+ };
4150
+ event.addChangeTips(triangleTip);
4151
+ event.addChangeTips(tipLineA);
4152
+ event.addChangeTips(tipLineB);
4153
+ }
4154
+ /**
4155
+ * 渲染底部波浪线
4156
+ */
4157
+ function renderUnderWavyLine(event, r, color) {
4158
+ const { x, y } = event.relativePagePos;
4159
+ let d = `M ${x} ${y + r.rect.height - 2} q 1.5,2, `;
4160
+ const width = r.rect.width;
4161
+ d += Array(Math.ceil(width / 3)).fill("3,0").join(' t ');
4162
+ const path = ElementUtil.createSvgPath({ d, fill: 'none', stroke: color });
4163
+ event.highlights.push(path);
4164
+ }
4186
4165
  /**
4187
4166
  * 获取渲染元素相对稳当的位置
4188
4167
  * @param render
@@ -4485,7 +4464,7 @@ class TableRowElement extends BlockContainerElement {
4485
4464
  beginMeasure(data) {
4486
4465
  super.beginMeasure(data);
4487
4466
  //在差异更新中,由于行内单元格存在合并行的情况,需要将当前行内存在合并的单元格,将其修改标志改为修改
4488
- if (this.modifyFlag === ModifyFlag$1.Track) {
4467
+ if (this.modifyFlag === ModifyFlag.Track) {
4489
4468
  this.checkRowModifyState();
4490
4469
  }
4491
4470
  }
@@ -4505,17 +4484,17 @@ class TableRowElement extends BlockContainerElement {
4505
4484
  const endRowIndex = TableUtil.getVMergeEndIndex(tb, currRowIndex, i);
4506
4485
  const startRowIndex = TableUtil.getVMergeStartIndex(tb, currRowIndex, i);
4507
4486
  for (let j = startRowIndex; j <= endRowIndex; j++) {
4508
- setChildrenModifyFlag(ModifyFlag$1.Modify, tb.getChild(j));
4487
+ setChildrenModifyFlag(ModifyFlag.Modify, tb.getChild(j));
4509
4488
  }
4510
4489
  }
4511
4490
  else if (cell.props.vMerge === 'restart') {
4512
4491
  const endRowIndex = TableUtil.getVMergeEndIndex(tb, currRowIndex, i);
4513
4492
  for (let j = currRowIndex; j <= endRowIndex; j++) {
4514
- setChildrenModifyFlag(ModifyFlag$1.Modify, tb.getChild(j));
4493
+ setChildrenModifyFlag(ModifyFlag.Modify, tb.getChild(j));
4515
4494
  }
4516
4495
  break;
4517
4496
  }
4518
- cell.modifyFlag = ModifyFlag$1.Modify;
4497
+ cell.modifyFlag = ModifyFlag.Modify;
4519
4498
  }
4520
4499
  }
4521
4500
  createRenderObject() {
@@ -4620,7 +4599,7 @@ class TextGroupElement extends LeafElement {
4620
4599
  return this.textMeasures.map(item => item.char).join('');
4621
4600
  }
4622
4601
  createRenderObject(data) {
4623
- if (!this.isMeasure || this.modifyFlag !== ModifyFlag$1.None || !this.cacheRender) {
4602
+ if (!this.isMeasure || this.modifyFlag !== ModifyFlag.None || !this.cacheRender) {
4624
4603
  data.renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
4625
4604
  //data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
4626
4605
  this.isMeasure = true;
@@ -5441,7 +5420,8 @@ class TableUtil {
5441
5420
  currCell.props.hMerge = null;
5442
5421
  }
5443
5422
  if (currCell !== startCell) {
5444
- if (currCell.getChildLength() !== 2) {
5423
+ //单元格存在有效内容
5424
+ if (currCell.getChildLength() > 2) {
5445
5425
  cellContents.push(...ElementUtil.getChildrenElements(currCell.clone(true)));
5446
5426
  currCell.clearItems();
5447
5427
  }
@@ -5506,6 +5486,9 @@ class TableUtil {
5506
5486
  this.restoreCellMerge(cell);
5507
5487
  }
5508
5488
  }
5489
+ else {
5490
+ break;
5491
+ }
5509
5492
  }
5510
5493
  }
5511
5494
  if (hMerge === 'restart') {
@@ -5517,6 +5500,9 @@ class TableUtil {
5517
5500
  this.restoreCellMerge(cell);
5518
5501
  }
5519
5502
  }
5503
+ else {
5504
+ break;
5505
+ }
5520
5506
  }
5521
5507
  }
5522
5508
  cell.props.hMerge = null;
@@ -6496,94 +6482,6 @@ class CommentContentFactory extends ElementFactory {
6496
6482
  }
6497
6483
  }
6498
6484
 
6499
- class CommentsUtil {
6500
- static createCommentsImage(commWindow) {
6501
- const commContainer = commWindow.element.cacheRender;
6502
- commWindow.clear();
6503
- for (let i = 0; i < commContainer.length; i++) {
6504
- const commRender = commContainer.getChild(i);
6505
- const commEle = commRender.element;
6506
- const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
6507
- if (mapComm) {
6508
- const commContentRender = commRender.clone();
6509
- commContentRender.rect.x = 0;
6510
- commContentRender.rect.y = 0;
6511
- commWindow.addChild(commContentRender);
6512
- }
6513
- }
6514
- }
6515
- static arrangeComments(commWindow) {
6516
- if (commWindow.isMeasureComm) {
6517
- return;
6518
- }
6519
- const commContainer = commWindow.element.cacheRender;
6520
- const commMap = [];
6521
- const docRender = ElementUtil.getParentRender(commWindow, DocumentRenderObject);
6522
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender);
6523
- for (let i = 0; i < commContainer.length; i++) {
6524
- const commRender = commContainer.getChild(i);
6525
- const commEle = commRender.element;
6526
- const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
6527
- if (mapComm) {
6528
- const commRenderPos = ElementUtil.getRenderAbsolutePaintPos(mapComm);
6529
- const commPos = { x: commRenderPos.x - docRenderPos.x, y: commRenderPos.y - docRenderPos.y };
6530
- const commMarkLinePos = ElementUtil.getParaLinePos(mapComm, commPos);
6531
- commPos.y = commMarkLinePos.y + 2;
6532
- const commContentRender = commWindow.getItems().find(item => item.element === commRender.element);
6533
- //const commContentRender = commRender.clone() as CommContentBaseRenderObject<any>;
6534
- commContentRender.rect.x = 0;
6535
- commContentRender.rect.y = commPos.y;
6536
- //commWindow.addChild(commContentRender);
6537
- commMap.push({
6538
- commMarkRender: mapComm,
6539
- commMarkPos: commPos,
6540
- commContentRender: commContentRender
6541
- });
6542
- }
6543
- }
6544
- let sumCommentHeight = 0;
6545
- for (let i = 0; i < commMap.length; i++) {
6546
- const map = commMap[i];
6547
- const prevRender = commMap[i - 1]?.commContentRender;
6548
- const { commContentRender } = map;
6549
- sumCommentHeight += commContentRender.rect.height + 5;
6550
- if (prevRender) {
6551
- const { y: prevY, height: prevHeight } = prevRender.rect;
6552
- if (commContentRender.rect.y < prevY + prevHeight) {
6553
- commContentRender.rect.y = prevY + prevHeight + 5;
6554
- }
6555
- }
6556
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
6557
- }
6558
- if (!commMap.length) {
6559
- return;
6560
- }
6561
- const lastCommentMap = commMap[commMap.length - 1];
6562
- const { commContentRender: lastCommContentRender } = lastCommentMap;
6563
- const { rect: lastRect } = lastCommContentRender;
6564
- //批注内容超出文档,需要重新排序
6565
- if (lastRect.y + lastRect.height > docRender.rect.height) {
6566
- //总内容小于容器高度,则进行倒排
6567
- //否则进行正排
6568
- if (sumCommentHeight < docRender.rect.height) {
6569
- lastRect.y = docRender.rect.height - lastRect.height;
6570
- for (let i = commMap.length - 1; i >= 0; i--) {
6571
- const map = commMap[i];
6572
- const prevRender = commMap[i + 1]?.commContentRender;
6573
- const { commContentRender } = map;
6574
- if (prevRender) {
6575
- const { y: prevY } = prevRender.rect;
6576
- if (commContentRender.rect.y + commContentRender.rect.height > prevY) {
6577
- commContentRender.rect.y = prevY - commContentRender.rect.height - 5;
6578
- }
6579
- }
6580
- commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
6581
- }
6582
- }
6583
- }
6584
- }
6585
- }
6586
-
6587
6485
  let activeEditorContext = null;
6588
6486
  function setActiveEditorContext(ctx) {
6589
6487
  activeEditorContext = ctx;
@@ -6796,7 +6694,7 @@ class SelectionState {
6796
6694
  set endControl(value) {
6797
6695
  this._endControl = value;
6798
6696
  }
6799
- onChangedEvent = new Subject$1();
6697
+ onChangedEvent = new Subject();
6800
6698
  startControlIndex;
6801
6699
  startOffset;
6802
6700
  endControlIndex;
@@ -7003,7 +6901,7 @@ class CommentElement extends LeafElement {
7003
6901
  color;
7004
6902
  constructor() {
7005
6903
  super('comm');
7006
- this.isDecorate = true;
6904
+ //this.isDecorate = true;
7007
6905
  this.disableClick = true;
7008
6906
  this.props = new CommProps();
7009
6907
  this.color = CommonUtil.randomRgbColor(0.5);
@@ -7034,6 +6932,9 @@ class CommentElement extends LeafElement {
7034
6932
  }
7035
6933
  class CommentRenderObject extends LeafRenderObject {
7036
6934
  exportSVG(event) {
6935
+ if (event.mode === 'print') {
6936
+ return;
6937
+ }
7037
6938
  const renderPos = { ...event.relativePagePos };
7038
6939
  const paraLinePos = ElementUtil.getParaLinePos(this, { x: renderPos.x, y: renderPos.y });
7039
6940
  const color = '#ff4d4f';
@@ -7059,10 +6960,14 @@ class CommentRenderObject extends LeafRenderObject {
7059
6960
  if (this.element.paintRenders.indexOf(this) !== 0) {
7060
6961
  return;
7061
6962
  }
6963
+ const { x, y } = event.globalPos;
6964
+ const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
7062
6965
  const appCtx = getActiveEditorContext();
7063
6966
  const opType = '批注:';
7064
6967
  const content = this.element.props.text;
7065
- const left = 5;
6968
+ let left = 5;
6969
+ //显示在文档的右测
6970
+ left += docRender.rect.x + docRender.rect.width + 20;
7066
6971
  let sel = 'div.tg-container';
7067
6972
  const node = {
7068
6973
  sel,
@@ -7070,7 +6975,10 @@ class CommentRenderObject extends LeafRenderObject {
7070
6975
  data: {
7071
6976
  style: {
7072
6977
  left: `${left}px`,
7073
- top: `${event.globalPos.y}px`
6978
+ top: `${y}px`
6979
+ },
6980
+ dataset: {
6981
+ key: this.element.key
7074
6982
  },
7075
6983
  on: {
7076
6984
  click: (e) => {
@@ -7113,6 +7021,43 @@ class CommentRenderObject extends LeafRenderObject {
7113
7021
  }]
7114
7022
  };
7115
7023
  event.addChangeTips(node);
7024
+ const triangleTipX = x + this.rect.width / 2;
7025
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
7026
+ const tipLineA = {
7027
+ sel: 'div.doc-triangle-line',
7028
+ data: {
7029
+ style: {
7030
+ left: `${triangleTipX}px`,
7031
+ top: `${y + this.rect.height}px`,
7032
+ width: tipLineAWidth + 'px'
7033
+ }
7034
+ }
7035
+ };
7036
+ const tipLineB = {
7037
+ sel: 'div.doc-triangle-line',
7038
+ data: {
7039
+ style: {
7040
+ left: `${triangleTipX + tipLineAWidth}px`,
7041
+ top: `${y + this.rect.height}px`,
7042
+ width: 20 + 'px'
7043
+ },
7044
+ dataset: {
7045
+ key: this.element.key
7046
+ }
7047
+ }
7048
+ };
7049
+ const triangleTip = {
7050
+ sel: `div.doc-triangle`,
7051
+ data: {
7052
+ style: {
7053
+ left: `${triangleTipX}px`,
7054
+ top: `${y + this.rect.height * 2 / 3}px`
7055
+ }
7056
+ }
7057
+ };
7058
+ event.addChangeTips(triangleTip);
7059
+ event.addChangeTips(tipLineA);
7060
+ event.addChangeTips(tipLineB);
7116
7061
  // <div class="container">
7117
7062
  // <div class="header">
7118
7063
  // <span class="header-user">张三</span>
@@ -7146,10 +7091,72 @@ class CommentFactory extends ElementFactory {
7146
7091
  ele.props.id = props.id;
7147
7092
  ele.props.markType = props.markType;
7148
7093
  ele.props.text = props.text;
7094
+ ele.props.userId = props.userId;
7095
+ ele.props.userName = props.userName;
7096
+ ele.props.date = props.date;
7149
7097
  return ele;
7150
7098
  }
7151
7099
  }
7152
7100
 
7101
+ class CommsContainerElement extends BlockContainerElement {
7102
+ constructor() {
7103
+ super('comm-list');
7104
+ }
7105
+ createRenderObject(data) {
7106
+ const render = new CommsContainerRenderObject(this);
7107
+ render.rect.width = data.options.reviewWindowWidth;
7108
+ return render;
7109
+ }
7110
+ serialize(viewOptions) {
7111
+ return {
7112
+ type: this.type,
7113
+ props: {}
7114
+ };
7115
+ }
7116
+ clone(data) {
7117
+ const clone = new CommsContainerElement();
7118
+ cloneElementBase(this, clone);
7119
+ cloneChildren(this, clone, data);
7120
+ return clone;
7121
+ }
7122
+ }
7123
+ class CommsContainerRenderObject extends BlockContainerRenderObject {
7124
+ //批注内容是否已经重组,只要重新绘制的时候组合一次即可
7125
+ isMeasureComm;
7126
+ commsMarks = [];
7127
+ clone() {
7128
+ const clone = new CommsContainerRenderObject(this.element);
7129
+ clone.rect = ElementUtil.cloneRect(this.rect);
7130
+ for (let i = 0; i < this.length; i++) {
7131
+ clone.addChild(this.getChild(i).clone());
7132
+ }
7133
+ return clone;
7134
+ }
7135
+ exportSVG(event) {
7136
+ const t = super.exportSVG(event);
7137
+ t.children = [ElementUtil.createSvgEle('rect', {
7138
+ x: 0,
7139
+ y: 0,
7140
+ width: this.rect.width,
7141
+ height: this.rect.height,
7142
+ fill: '#fafafa',
7143
+ stroke: 'black',
7144
+ 'paint-order': 'stroke fill markers',
7145
+ 'stroke-width': 0.5,
7146
+ })];
7147
+ return t;
7148
+ }
7149
+ }
7150
+ class CommentsFactory extends ElementFactory {
7151
+ match(type) {
7152
+ return type === "comm-list";
7153
+ }
7154
+ createElement(data) {
7155
+ const commentsEle = new CommsContainerElement();
7156
+ return commentsEle;
7157
+ }
7158
+ }
7159
+
7153
7160
  /**
7154
7161
  * 数据元验证提示
7155
7162
  */
@@ -8434,9 +8441,6 @@ class DataElementDate extends DataElementInlineGroup {
8434
8441
  this.onChangedValidate();
8435
8442
  }
8436
8443
  isValid(val, format) {
8437
- if (!format) {
8438
- format = this.props.format ?? 'YYYY-MM-DD';
8439
- }
8440
8444
  const date = moment(val, format);
8441
8445
  return date.isValid();
8442
8446
  }
@@ -8451,8 +8455,7 @@ class DataElementDate extends DataElementInlineGroup {
8451
8455
  if (res) {
8452
8456
  return res;
8453
8457
  }
8454
- const format = this.props.format ?? 'YYYY-MM-DD';
8455
- const date = moment(this.getValue(), format, true);
8458
+ const date = moment(this.getValue(), true);
8456
8459
  if (!date.isValid()) {
8457
8460
  return '日期格式不正确';
8458
8461
  }
@@ -10597,7 +10600,7 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10597
10600
  if (fillColor) {
10598
10601
  t.data.attrs['fill'] = fillColor;
10599
10602
  }
10600
- this.createChangeTips(event);
10603
+ this.createModifyTips(event);
10601
10604
  const { x, y } = event.relativePagePos;
10602
10605
  const color = this.element.type === 'ins-run' ? 'green' : 'red';
10603
10606
  if (this.element.type === 'del-run') {
@@ -10605,35 +10608,39 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10605
10608
  event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY} H${x + this.rect.width}`, 'red', 1));
10606
10609
  event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY + 4} H${x + this.rect.width}`, 'red', 1));
10607
10610
  }
10608
- if (this.element.gotFocus && event.options.showTrackChanges) {
10611
+ if (this.element.gotFocus) {
10609
10612
  //起始位置
10610
10613
  if (this.element.paintRenders.indexOf(this) === 0) {
10611
10614
  const pathPoints = [];
10612
10615
  pathPoints.push({ x: x, y: y + this.rect.height / 3 });
10613
10616
  pathPoints.push({ x, y });
10614
10617
  pathPoints.push({ x: x + this.rect.width, y: y });
10615
- event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 2));
10618
+ event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
10616
10619
  }
10617
10620
  if (this.element.paintRenders.indexOf(this) === this.element.paintRenders.length - 1) {
10618
10621
  const pathPoints = [];
10619
10622
  pathPoints.push({ x: x, y: y + this.rect.height });
10620
10623
  pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height });
10621
10624
  pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height * 2 / 3 });
10622
- event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 2));
10625
+ event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
10623
10626
  }
10624
10627
  }
10625
10628
  return t;
10626
10629
  }
10627
- createChangeTips(event) {
10630
+ createModifyTips(event) {
10628
10631
  if (this.element.paintRenders.indexOf(this) !== 0) {
10629
10632
  return;
10630
10633
  }
10631
10634
  if (!event.options.showTrackChangesTip) {
10632
10635
  return;
10633
10636
  }
10637
+ const { x, y } = event.globalPos;
10638
+ const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
10634
10639
  const opType = this.element.type === 'ins-run' ? '插入:' : '删除:';
10635
10640
  const content = ElementSerialize.serializeString(this.element, { all: true });
10636
- const left = this.element.gotFocus ? -10 : 5;
10641
+ let left = this.element.gotFocus ? -10 : 5;
10642
+ //显示在文档的右测
10643
+ left += docRender.rect.x + docRender.rect.width + 20;
10637
10644
  let sel = 'div.tg-container';
10638
10645
  if (this.element.gotFocus) {
10639
10646
  sel += '.tg-container--selected';
@@ -10644,7 +10651,10 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10644
10651
  data: {
10645
10652
  style: {
10646
10653
  left: `${left}px`,
10647
- top: `${event.globalPos.y}px`
10654
+ top: `${y}px`
10655
+ },
10656
+ dataset: {
10657
+ key: this.element.key
10648
10658
  }
10649
10659
  },
10650
10660
  children: [{
@@ -10666,6 +10676,43 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
10666
10676
  }]
10667
10677
  };
10668
10678
  event.addChangeTips(node);
10679
+ const triangleTipX = x + this.rect.width / 2;
10680
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
10681
+ const tipLineA = {
10682
+ sel: 'div.doc-triangle-line',
10683
+ data: {
10684
+ style: {
10685
+ left: `${triangleTipX}px`,
10686
+ top: `${y + this.rect.height}px`,
10687
+ width: tipLineAWidth + 'px'
10688
+ }
10689
+ }
10690
+ };
10691
+ const tipLineB = {
10692
+ sel: 'div.doc-triangle-line',
10693
+ data: {
10694
+ style: {
10695
+ left: `${triangleTipX + tipLineAWidth}px`,
10696
+ top: `${y + this.rect.height}px`,
10697
+ width: 20 + 'px'
10698
+ },
10699
+ dataset: {
10700
+ key: this.element.key
10701
+ }
10702
+ }
10703
+ };
10704
+ const triangleTip = {
10705
+ sel: `div.doc-triangle`,
10706
+ data: {
10707
+ style: {
10708
+ left: `${triangleTipX}px`,
10709
+ top: `${y + this.rect.height * 2 / 3}px`
10710
+ }
10711
+ }
10712
+ };
10713
+ event.addChangeTips(triangleTip);
10714
+ event.addChangeTips(tipLineA);
10715
+ event.addChangeTips(tipLineB);
10669
10716
  }
10670
10717
  clone() {
10671
10718
  const cloneRender = new TrackRunRenderObject(this.element);
@@ -10778,7 +10825,6 @@ class ElementUtil {
10778
10825
  dest.printable = props.printable ?? true;
10779
10826
  dest.required = props.required;
10780
10827
  dest.secretBrowse = props.secretBrowse;
10781
- dest.deleteable = props.deleteable;
10782
10828
  dest.underline = props.underline;
10783
10829
  dest.expression = props.expression;
10784
10830
  dest.hidden = props.hidden;
@@ -12046,9 +12092,6 @@ class ElementUtil {
12046
12092
  if (element instanceof DocumentHeaderElement) {
12047
12093
  return { type: 'header', target: element };
12048
12094
  }
12049
- if (element instanceof CommsContainerElement) {
12050
- return { type: 'review', target: element };
12051
- }
12052
12095
  return this.getElementRegionTarget(element.parent);
12053
12096
  }
12054
12097
  /**
@@ -12417,6 +12460,22 @@ class ElementUtil {
12417
12460
  delete ele.attribute[attr];
12418
12461
  }
12419
12462
  }
12463
+ static getMatchItems(item, predicate) {
12464
+ const items = [];
12465
+ if (predicate(item)) {
12466
+ items.push(item);
12467
+ }
12468
+ if (item instanceof BranchElement) {
12469
+ for (let i = 0; i < item.length; i++) {
12470
+ const child = item.getChild(i);
12471
+ const matchItems = this.getMatchItems(child, predicate);
12472
+ if (matchItems) {
12473
+ items.push(...matchItems);
12474
+ }
12475
+ }
12476
+ }
12477
+ return items;
12478
+ }
12420
12479
  }
12421
12480
 
12422
12481
  var TextUnitsHolder;
@@ -12913,7 +12972,8 @@ class EditorContext {
12913
12972
  docChange;
12914
12973
  clearPrevDocCb;
12915
12974
  //绘制结束之后回调函数
12916
- paintedCallback;
12975
+ //nextViewFn!: (() => void) | null;
12976
+ nextViewFns = [];
12917
12977
  constructor(selectionState, viewOptions) {
12918
12978
  this.selectionState = selectionState;
12919
12979
  this.viewOptions = viewOptions;
@@ -12923,8 +12983,13 @@ class EditorContext {
12923
12983
  this.syncRefresh?.();
12924
12984
  });
12925
12985
  }
12926
- setPaintedCallback(cb) {
12927
- this.paintedCallback = cb;
12986
+ onNextView(cb) {
12987
+ if (!cb) {
12988
+ this.nextViewFns.length = 0;
12989
+ return;
12990
+ }
12991
+ //this.nextViewFn = cb;
12992
+ this.nextViewFns.push(cb);
12928
12993
  }
12929
12994
  get document() {
12930
12995
  return this._document;
@@ -12952,6 +13017,7 @@ class EditorContext {
12952
13017
  this.selectionState?.renderContainer?.destroy();
12953
13018
  this.clear();
12954
13019
  this._document.destroy();
13020
+ clearTraces(this._document);
12955
13021
  }
12956
13022
  this.clearPrevDocCb = null;
12957
13023
  this.selectionState.startHitInfo = null;
@@ -13034,7 +13100,7 @@ class EditorContext {
13034
13100
  if (!this._document) {
13035
13101
  return null;
13036
13102
  }
13037
- return this._document.modifyFlag === ModifyFlag$1.None ? 'appearance' : 'content';
13103
+ return this._document.modifyFlag === ModifyFlag.None ? 'appearance' : 'content';
13038
13104
  }
13039
13105
  }
13040
13106
  /**
@@ -14336,7 +14402,7 @@ class DocumentArrange {
14336
14402
  };
14337
14403
  }
14338
14404
  measureControl(element, maxWidth) {
14339
- if (element.modifyFlag === ModifyFlag$1.None && element.cacheRender) {
14405
+ if (element.modifyFlag === ModifyFlag.None && element.cacheRender) {
14340
14406
  return element.cacheRender;
14341
14407
  }
14342
14408
  if (element instanceof BlockContentElement) {
@@ -14738,7 +14804,7 @@ class DocumentArrange {
14738
14804
  this.setMeasureCompletedModifyFlag(ele.getChild(i));
14739
14805
  }
14740
14806
  }
14741
- ele.modifyFlag = ModifyFlag$1.None;
14807
+ ele.modifyFlag = ModifyFlag.None;
14742
14808
  if (!ele.loaded) {
14743
14809
  ele.loaded = true;
14744
14810
  }
@@ -14788,9 +14854,6 @@ class DocumentArrange {
14788
14854
  }
14789
14855
  for (let i = 0; i < renderTree.length; i++) {
14790
14856
  const currRender = renderTree.getChild(i);
14791
- if (currRender.element) {
14792
- this.cacheCommsRender(currRender);
14793
- }
14794
14857
  if (currRender instanceof BranchRenderObject) {
14795
14858
  this.cacheRenders(currRender);
14796
14859
  }
@@ -14799,26 +14862,6 @@ class DocumentArrange {
14799
14862
  }
14800
14863
  }
14801
14864
  }
14802
- /**
14803
- * 缓存批注标志
14804
- * @private
14805
- */
14806
- cacheCommsRender(render) {
14807
- if (render.element && render.element.type === 'comm') {
14808
- const commElement = render.element;
14809
- if (commElement.props.markType === 'start') {
14810
- const currDocRender = this.cacheDoc;
14811
- const docCommContainer = currDocRender.getItems().find(item => item instanceof CommsContainerRenderObject);
14812
- if (docCommContainer) {
14813
- docCommContainer.commsMarks.push(render);
14814
- }
14815
- }
14816
- }
14817
- if (render.element && render.element.type === 'comm-list') {
14818
- const commContainer = render;
14819
- CommentsUtil.createCommentsImage(commContainer);
14820
- }
14821
- }
14822
14865
  endMeasures(ele) {
14823
14866
  ele.endMeasure();
14824
14867
  if (ele instanceof BranchElement) {
@@ -14859,14 +14902,11 @@ class DocumentPaginator {
14859
14902
  this.docCtx.selectionState.renderContainer = this.docContainer;
14860
14903
  this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
14861
14904
  const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
14862
- const docPages = newMeasure.measureDoc();
14863
- this.setCommRangeMark();
14864
- this.docPages = docPages;
14905
+ this.docPages = newMeasure.measureDoc();
14865
14906
  this.layoutPages();
14866
14907
  }
14867
14908
  /**
14868
14909
  * 文档页面显示布局
14869
- * @param pages
14870
14910
  */
14871
14911
  layoutPages() {
14872
14912
  if (!this.docContainer || !this.docPages) {
@@ -14949,39 +14989,6 @@ class DocumentPaginator {
14949
14989
  getDocContainer() {
14950
14990
  return this.docContainer;
14951
14991
  }
14952
- /***
14953
- * 设置审阅区间样式痕迹
14954
- */
14955
- setCommRangeMark() {
14956
- if (!this.viewOptions.showReviewWindow) {
14957
- return;
14958
- }
14959
- // const cce = this.docCtx.document.commentsContainerElement;
14960
- // const set = new Map<Element, SelectionContentRange>();
14961
- // const commentRangeStatus: Array<CommentRangeStatus> = [];
14962
- // for (let i = 0; i < cce.length; i++) {
14963
- // const commContent = cce.getChild(i) as CommContentElement;
14964
- // const commMarkPair = cce.markPairs.find(item => item.id === commContent.props.id);
14965
- // if (commMarkPair) {
14966
- // if (commMarkPair.start) {
14967
- // commContent.startMark = commMarkPair.start;
14968
- // }
14969
- // if (commMarkPair.end) {
14970
- // commContent.endMark = commMarkPair.end;
14971
- // }
14972
- // }
14973
- // const {startMark, endMark, props: {id}, focus} = commContent;
14974
- // const ancestorCommonControl = DocumentSelection.getAncestorCommonControl(startMark, endMark);
14975
- // const commonRange = RangeUtil.getSectionRange(startMark, 0, endMark, 1, ancestorCommonControl);
14976
- // SelectionOverlays.addToCommentSets(commonRange, set);
14977
- // commentRangeStatus.push({
14978
- // commContent,
14979
- // range: commonRange
14980
- // })
14981
- // }
14982
- // (<CommsContainerRenderObject>cce.cacheRender).selectedSet = set;
14983
- // (<CommsContainerRenderObject>cce.cacheRender).commentRangeStatus = commentRangeStatus;
14984
- }
14985
14992
  }
14986
14993
 
14987
14994
  class ElementReader {
@@ -15117,491 +15124,6 @@ class ElementReader {
15117
15124
  }
15118
15125
  }
15119
15126
 
15120
- class Subscription {
15121
- closed = false;
15122
- once = false;
15123
- }
15124
- class EventSourceCore {
15125
- closed = false;
15126
- subs = [];
15127
- next(data) {
15128
- const subs = [...this.subs];
15129
- subs.forEach((sub) => {
15130
- sub.invoke(data);
15131
- if (sub.once) {
15132
- sub.unsubscribe();
15133
- }
15134
- });
15135
- }
15136
- addSub(sub) {
15137
- this.subs.push(sub);
15138
- }
15139
- removeSub(sub) {
15140
- const index = this.subs.indexOf(sub);
15141
- if (index >= 0) {
15142
- this.subs.splice(index, 1);
15143
- }
15144
- }
15145
- unsubscribe() {
15146
- this.subs.length = 0;
15147
- this.closed = true;
15148
- }
15149
- }
15150
- class Subject extends EventSourceCore {
15151
- subscribe(listener) {
15152
- const sub = new SubjectSubscription(listener, () => {
15153
- this.removeSub(sub);
15154
- });
15155
- this.addSub(sub);
15156
- return sub;
15157
- }
15158
- onceSubscribe(listener) {
15159
- const sub = this.subscribe(listener);
15160
- sub.once = true;
15161
- return sub;
15162
- }
15163
- }
15164
- class SubjectSubscription extends Subscription {
15165
- listener;
15166
- cancel;
15167
- constructor(listener, cancel) {
15168
- super();
15169
- this.listener = listener;
15170
- this.cancel = cancel;
15171
- }
15172
- invoke(data) {
15173
- if (this.closed) {
15174
- return;
15175
- }
15176
- this.listener(data);
15177
- }
15178
- unsubscribe() {
15179
- this.closed = true;
15180
- this.cancel();
15181
- }
15182
- }
15183
-
15184
- var ModifyFlag;
15185
- (function (ModifyFlag) {
15186
- ModifyFlag[ModifyFlag["None"] = 0] = "None";
15187
- ModifyFlag[ModifyFlag["Modify"] = 1] = "Modify";
15188
- ModifyFlag[ModifyFlag["Track"] = 2] = "Track";
15189
- })(ModifyFlag || (ModifyFlag = {}));
15190
- class NodeCore {
15191
- enableClip = true;
15192
- pointEvent = true;
15193
- allowHitTest = false;
15194
- hitTest(hitPos, currPos) {
15195
- return false;
15196
- }
15197
- get enable() {
15198
- return this._enable;
15199
- }
15200
- set enable(value) {
15201
- this.propertyChanged('enable', this._enable, value);
15202
- }
15203
- _enable = true;
15204
- enableFocus = false;
15205
- isFocused = false;
15206
- get cursor() {
15207
- return this._cursor;
15208
- }
15209
- set cursor(value) {
15210
- this.propertyChanged('cursor', this._cursor, value);
15211
- this._cursor = value;
15212
- }
15213
- _cursor = 'default';
15214
- get visible() {
15215
- return this._visible;
15216
- }
15217
- set visible(value) {
15218
- this.propertyChanged('visible', this._visible, value);
15219
- this._visible = value;
15220
- }
15221
- _visible = true;
15222
- get borderRadius() {
15223
- return this._borderRadius;
15224
- }
15225
- set borderRadius(value) {
15226
- this.propertyChanged('borderRadius', this._borderRadius, value);
15227
- this._borderRadius = value;
15228
- }
15229
- get width() {
15230
- return this._width;
15231
- }
15232
- set width(value) {
15233
- this.propertyChanged('width', this._width, value);
15234
- this._width = value;
15235
- }
15236
- get height() {
15237
- return this._height;
15238
- }
15239
- set height(value) {
15240
- this.propertyChanged('height', this._height, value);
15241
- this._height = value;
15242
- }
15243
- get x() {
15244
- return this._x;
15245
- }
15246
- set x(value) {
15247
- this.propertyChanged('x', this._x, value);
15248
- this._x = value;
15249
- }
15250
- get y() {
15251
- return this._y;
15252
- }
15253
- set y(value) {
15254
- this.propertyChanged('y', this._y, value);
15255
- this._y = value;
15256
- }
15257
- _minWidth = Number.NaN;
15258
- _minHeight = Number.NaN;
15259
- get minWidth() {
15260
- return this._minWidth;
15261
- }
15262
- set minWidth(value) {
15263
- this.propertyChanged('minWidth', this._minWidth, value);
15264
- this._minWidth = value;
15265
- }
15266
- get minHeight() {
15267
- return this._minHeight;
15268
- }
15269
- set minHeight(value) {
15270
- this.propertyChanged('minHeight', this._minHeight, value);
15271
- this._minHeight = value;
15272
- }
15273
- get bgColor() {
15274
- return this._bgColor;
15275
- }
15276
- set bgColor(value) {
15277
- this.propertyChanged('bgColor', this._bgColor, value);
15278
- this._bgColor = value;
15279
- }
15280
- _border = 0;
15281
- get border() {
15282
- return this._border;
15283
- }
15284
- set border(value) {
15285
- this.propertyChanged('border', this._border, Math.abs(value));
15286
- this._border = value;
15287
- }
15288
- _padding = 0;
15289
- get padding() {
15290
- return this._padding;
15291
- }
15292
- set padding(value) {
15293
- this.propertyChanged('padding', this._padding, Math.abs(value));
15294
- this._padding = value;
15295
- }
15296
- _borderRadius = 0;
15297
- _borderColor;
15298
- get borderColor() {
15299
- return this._borderColor;
15300
- }
15301
- set borderColor(value) {
15302
- this.propertyChanged('borderColor', this._borderColor, value);
15303
- this._borderColor = value;
15304
- }
15305
- _shadowBlur = 0;
15306
- _shadowColor;
15307
- get shadowBlur() {
15308
- return this._shadowBlur;
15309
- }
15310
- set shadowBlur(value) {
15311
- this.propertyChanged('shadowBlur', this._shadowBlur, value);
15312
- this._shadowBlur = value;
15313
- }
15314
- get shadowColor() {
15315
- return this._shadowColor;
15316
- }
15317
- set shadowColor(value) {
15318
- this.propertyChanged('shadowColor', this._shadowColor, value);
15319
- this._shadowColor = value;
15320
- }
15321
- _isMouseenter = false;
15322
- get isMouseenter() {
15323
- return this._isMouseenter;
15324
- }
15325
- set isMouseenter(value) {
15326
- this.propertyChanged('isMouseenter', this._isMouseenter, value);
15327
- this._isMouseenter = value;
15328
- }
15329
- _overflowHidden = true;
15330
- get overflowHidden() {
15331
- return this._overflowHidden;
15332
- }
15333
- set overflowHidden(value) {
15334
- this.propertyChanged('overflowHidden', this._overflowHidden, value);
15335
- this._overflowHidden = value;
15336
- }
15337
- outlineColor = '';
15338
- outlineStyle = 'none';
15339
- outlineWidth = 0;
15340
- _width = Number.NaN;
15341
- _height = Number.NaN;
15342
- _x = 0;
15343
- _y = 0;
15344
- //测量需要的大小
15345
- desiredSize;
15346
- //绘制的大小
15347
- renderSize;
15348
- //最终分配的大小
15349
- finalRect;
15350
- _bgColor;
15351
- _modifyFlag = ModifyFlag.Modify;
15352
- get modifyFlag() {
15353
- return this._modifyFlag;
15354
- }
15355
- set modifyFlag(value) {
15356
- this._modifyFlag = value;
15357
- }
15358
- onChangedEvent = new Subject();
15359
- listenerEvents = [];
15360
- parent;
15361
- propertyChanged(prop, old, newV) {
15362
- if (this._modifyFlag == ModifyFlag.Modify) {
15363
- return;
15364
- }
15365
- if (old === newV) {
15366
- return;
15367
- }
15368
- this.onChanged();
15369
- }
15370
- onChanged() {
15371
- if (this._modifyFlag == ModifyFlag.Modify) {
15372
- return;
15373
- }
15374
- this._modifyFlag = ModifyFlag.Modify;
15375
- // if (this.parent) {
15376
- // this.parent.onChildChanged();
15377
- // }
15378
- this.onChangedEvent.next();
15379
- }
15380
- addEventListener(name, listener, useCapture = false) {
15381
- this.listenerEvents.push({
15382
- name,
15383
- listener: listener,
15384
- useCapture
15385
- });
15386
- }
15387
- removeEventListener(name, listener, useCapture = false) {
15388
- const index = this.listenerEvents.findIndex(item => item.name === name && item.listener === listener && item.useCapture === useCapture);
15389
- if (index >= 0) {
15390
- this.listenerEvents.splice(index, 1);
15391
- }
15392
- }
15393
- /**
15394
- * 父容器传入参数,子容器设置坐标位置
15395
- * @param e
15396
- * @param finalRect
15397
- */
15398
- arrange(e, finalRect) {
15399
- if (!this._visible) {
15400
- this.finalRect = { x: finalRect.x, y: finalRect.y, width: 0, height: 0 };
15401
- return;
15402
- }
15403
- const contentSize = this.getContentSize(finalRect.width, finalRect.height);
15404
- const finalSize = this.arrangeOverride(e, contentSize);
15405
- this.renderSize = this.getOuterSize({
15406
- width: Math.min(contentSize.width, finalSize.width),
15407
- height: Math.min(contentSize.height, finalSize.height)
15408
- });
15409
- this.finalRect = { x: finalRect.x, y: finalRect.y, width: this.renderSize.width, height: this.renderSize.height };
15410
- }
15411
- arrangeOverride(e, finalSize) {
15412
- return finalSize;
15413
- }
15414
- /**
15415
- * 测量阶段
15416
- * @param e
15417
- * @param availableSize
15418
- */
15419
- measure(e, availableSize) {
15420
- if (!this._visible) {
15421
- this.desiredSize = { width: 0, height: 0 };
15422
- return;
15423
- }
15424
- let width = 0, height = 0;
15425
- if (Number.isNaN(this._width)) {
15426
- width = availableSize.width;
15427
- }
15428
- else {
15429
- width = this.getPercentWidth(availableSize.width);
15430
- }
15431
- if (Number.isNaN(this._height)) {
15432
- height = availableSize.height;
15433
- }
15434
- else {
15435
- height = this.getPercentHeight(availableSize.height);
15436
- }
15437
- const measureSize = this.getOuterSize(this.measureOverride(e, this.getContentSize(width, height)));
15438
- if (Number.isNaN(this._width)) {
15439
- width = measureSize.width;
15440
- }
15441
- if (Number.isNaN(this._height)) {
15442
- height = measureSize.height;
15443
- }
15444
- this.desiredSize = { width, height };
15445
- }
15446
- getPercentWidth(val) {
15447
- if (typeof this._width === 'object') {
15448
- return val * this._width.value / 100;
15449
- }
15450
- else {
15451
- return this._width;
15452
- }
15453
- }
15454
- getPercentHeight(val) {
15455
- if (typeof this._height === 'object') {
15456
- return val * this._height.value / 100;
15457
- }
15458
- else {
15459
- return this._height;
15460
- }
15461
- }
15462
- /**
15463
- * 获取内容尺寸
15464
- * 元素模型为边框模型,元素的大小为默认包含边框大小,内容大小需要减去边框大小
15465
- * @private
15466
- * @param width
15467
- * @param height
15468
- */
15469
- getContentSize(width, height) {
15470
- return {
15471
- width: width - this._border * 2 - this._padding * 2,
15472
- height: height - this._border * 2 - this.padding * 2
15473
- };
15474
- }
15475
- /**
15476
- * 获取外部尺寸
15477
- * @param availableSize
15478
- * @private
15479
- */
15480
- getOuterSize(availableSize) {
15481
- return {
15482
- width: availableSize.width + this._border * 2 + this._padding * 2,
15483
- height: availableSize.height + this._border * 2 + this._padding * 2
15484
- };
15485
- }
15486
- /**
15487
- * 子元素需重写该方法
15488
- * @param e
15489
- * @param availableSize
15490
- */
15491
- measureOverride(e, availableSize) {
15492
- return availableSize;
15493
- }
15494
- preRender(e) {
15495
- return true;
15496
- }
15497
- attachedProp = {};
15498
- setAttachedProp(name, val) {
15499
- const key = name;
15500
- this.propertyChanged(key, this.attachedProp[key], val);
15501
- this.attachedProp[key] = val;
15502
- }
15503
- getAttachedPropValue(name) {
15504
- return this.attachedProp[name];
15505
- }
15506
- removeAttachedProp(name) {
15507
- this.propertyChanged(name, this.attachedProp[name], undefined);
15508
- delete this.attachedProp[name];
15509
- }
15510
- /**
15511
- * 绘制轮廓
15512
- */
15513
- renderOutline(renderCtx) {
15514
- drawOutline(this, renderCtx);
15515
- clipContent(this, renderCtx);
15516
- drawBorderline(this, renderCtx);
15517
- translate(renderCtx, this.finalRect.x, this.finalRect.y);
15518
- translate(renderCtx, this.border + this.padding, this.border + this.padding);
15519
- }
15520
- }
15521
- /**
15522
- * 绘制边框
15523
- * @param node
15524
- * @param renderCtx
15525
- */
15526
- function drawBorderline(node, renderCtx) {
15527
- //renderCtx.contentContext.fillRect(node.x, node.y, node.finalRect.width, node.finalRect.height, node.bgColor);
15528
- if (!node.border) {
15529
- return;
15530
- }
15531
- let { finalRect: { x, y, width, height } } = node;
15532
- const ctx = renderCtx.ctx;
15533
- ctx.save();
15534
- ctx.fillStyle = node.borderColor;
15535
- ctx.beginPath();
15536
- ctx.moveTo(x, y);
15537
- ctx.lineTo(x + width, y);
15538
- ctx.lineTo(x + width, y + height);
15539
- ctx.lineTo(x, y + height);
15540
- ctx.lineTo(x, y);
15541
- ctx.closePath();
15542
- ctx.fill();
15543
- if (node.border) {
15544
- ctx.globalCompositeOperation = 'source-atop';
15545
- x += node.border;
15546
- y += node.border;
15547
- width -= node.border * 2;
15548
- height -= node.border * 2;
15549
- const bgColor = node.bgColor ? node.bgColor : 'white';
15550
- ctx.fillStyle = bgColor;
15551
- renderCtx.roundRect(x, y, width, height, node.borderRadius);
15552
- }
15553
- ctx.fill();
15554
- ctx.restore();
15555
- //裁剪子内容区域范围
15556
- node.enableClip && renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
15557
- }
15558
- /**
15559
- * 绘制外轮廓
15560
- */
15561
- function drawOutline(node, renderCtx) {
15562
- if (node.outlineWidth <= 0 || node.outlineStyle === 'none' || !node.outlineColor) {
15563
- return;
15564
- }
15565
- let { x, y, finalRect: { width, height } } = node;
15566
- x -= node.outlineWidth / 2;
15567
- y -= node.outlineWidth / 2;
15568
- width += node.outlineWidth;
15569
- height += node.outlineWidth;
15570
- renderCtx.strokeRect(x, y, width, height, node.outlineColor, node.outlineWidth, node.borderRadius);
15571
- }
15572
- function clipContent(node, renderCtx) {
15573
- const x = node.finalRect.x;
15574
- const y = node.finalRect.y;
15575
- const width = node.finalRect.width;
15576
- const height = node.finalRect.height;
15577
- renderCtx.ctx.lineWidth = 0;
15578
- //绘制背景
15579
- if (node.bgColor) {
15580
- renderCtx.fillRect(x, y, width, height, node.bgColor, node.shadowBlur, node.shadowColor, node.borderRadius);
15581
- }
15582
- //确定绘制裁剪范围
15583
- renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
15584
- }
15585
- function translate(renderCtx, x, y) {
15586
- renderCtx.ctx.translate(x, y);
15587
- }
15588
-
15589
- class RectNode extends NodeCore {
15590
- render(e) {
15591
- // const {render}=e;
15592
- // const ctx=render.contentContext.ctx;
15593
- //
15594
- // var gradient = ctx.createLinearGradient(0,0, this.finalRect.width,0);
15595
- //
15596
- // gradient.addColorStop(0, 'green');
15597
- // gradient.addColorStop(.5, 'cyan');
15598
- // gradient.addColorStop(1, 'blue');
15599
- //
15600
- // ctx.fillStyle=gradient;
15601
- // ctx.fill();
15602
- }
15603
- }
15604
-
15605
15127
  /**
15606
15128
  * 事件系统
15607
15129
  */
@@ -15619,13 +15141,13 @@ class DocumentEvent {
15619
15141
  focusedRect;
15620
15142
  //当前光标所在的元素
15621
15143
  currentMouseoverRender;
15622
- hitInfoChanged = new Subject$1();
15623
- clickEvent = new Subject$1();
15624
- dblClickEvent = new Subject$1();
15625
- tripleClickEvent = new Subject$1();
15626
- changeCursor = new Subject$1();
15627
- contextMenu = new Subject$1();
15628
- trackTipsChanged = new Subject$1();
15144
+ hitInfoChanged = new Subject();
15145
+ clickEvent = new Subject();
15146
+ dblClickEvent = new Subject();
15147
+ tripleClickEvent = new Subject();
15148
+ changeCursor = new Subject();
15149
+ contextMenu = new Subject();
15150
+ trackTipsChanged = new Subject();
15629
15151
  //光标处于边框的绘制元素
15630
15152
  edgeRenderInfo;
15631
15153
  //当前鼠标所在的page-position
@@ -16845,119 +16367,6 @@ class DocumentEvent {
16845
16367
  // }
16846
16368
  // }
16847
16369
  }
16848
- /**
16849
- * 开启打印区域
16850
- */
16851
- startPrintArea(editor) {
16852
- const cancelToken = {};
16853
- const startRect = new RectNode();
16854
- startRect.x = 0;
16855
- startRect.y = 0;
16856
- startRect.width = editor.width;
16857
- startRect.height = 0;
16858
- //设置半透明颜色
16859
- startRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
16860
- startRect.pointEvent = false;
16861
- const endRect = new RectNode();
16862
- endRect.x = 0;
16863
- endRect.y = editor.finalRect.height;
16864
- endRect.width = editor.width;
16865
- endRect.height = 0;
16866
- //设置半透明颜色
16867
- endRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
16868
- endRect.pointEvent = false;
16869
- let state = 'start';
16870
- editor.parent?.addChild(startRect);
16871
- editor.parent?.addChild(endRect);
16872
- let startY = 0, startDocIndex = 0, endY = 0, endDocIndex = 0;
16873
- const onMousemoveHandler = (evt) => {
16874
- const pos = evt.sourceHitPos;
16875
- if (state === 'start') {
16876
- startRect.height = pos.y;
16877
- }
16878
- else {
16879
- if (startRect.height + 5 > pos.y) {
16880
- return;
16881
- }
16882
- endRect.y = pos.y;
16883
- endRect.height = editor.finalRect.height - pos.y;
16884
- }
16885
- };
16886
- const onKeydownHandler = (evt) => {
16887
- if (evt.sourceEvt.keyCode === 27) {
16888
- cancelToken.cancel?.();
16889
- }
16890
- };
16891
- const onClickHandler = (evt) => {
16892
- const pos = evt.sourceHitPos;
16893
- const hitDoc = this.getHitDocPage({ globalX: pos.x, globalY: pos.y });
16894
- if (!hitDoc) {
16895
- return;
16896
- }
16897
- const { docIndex, hitPagePos } = hitDoc;
16898
- if (state === 'start') {
16899
- startY = hitPagePos.y;
16900
- startDocIndex = docIndex;
16901
- state = 'end';
16902
- }
16903
- else {
16904
- if (startRect.height + 5 > pos.y) {
16905
- return;
16906
- }
16907
- endY = hitPagePos.y;
16908
- endDocIndex = docIndex;
16909
- cancelToken.onFinish?.({
16910
- startY,
16911
- startDocIndex,
16912
- endY,
16913
- endDocIndex
16914
- });
16915
- }
16916
- };
16917
- editor.addEventListener('mousemove', onMousemoveHandler);
16918
- editor.addEventListener('keydown', onKeydownHandler);
16919
- editor.addEventListener('click', onClickHandler);
16920
- cancelToken.cancel = () => {
16921
- if (!startRect.parent) {
16922
- return;
16923
- }
16924
- startRect.parent?.removeChild(startRect);
16925
- endRect.parent?.removeChild(endRect);
16926
- editor.removeEventListener('mousemove', onMousemoveHandler);
16927
- editor.removeEventListener('keydown', onKeydownHandler);
16928
- editor.removeEventListener('click', onClickHandler);
16929
- };
16930
- return cancelToken;
16931
- }
16932
- clicks = 0;
16933
- timeout;
16934
- /**
16935
- * 处理三击事件
16936
- */
16937
- handleTripleClick() {
16938
- this.clicks++;
16939
- let curr = this;
16940
- if (this.clicks === 1) {
16941
- // 设置延时,等待第二次点击
16942
- this.timeout = setTimeout(function () {
16943
- curr.clicks = 0;
16944
- }, 300);
16945
- }
16946
- else if (this.clicks === 2) {
16947
- // 第二次点击后,清除延时
16948
- clearTimeout(curr.timeout);
16949
- // 设置延时,等待第三次点击
16950
- curr.timeout = setTimeout(function () {
16951
- curr.clicks = 0;
16952
- }, 300);
16953
- }
16954
- else if (curr.clicks === 3) {
16955
- // 第三次点击后,处理三击事件并清除延时
16956
- clearTimeout(curr.timeout);
16957
- this.tripleClickEvent.next();
16958
- this.clicks = 0;
16959
- }
16960
- }
16961
16370
  /**
16962
16371
  * 获取当前光标所在的数据元
16963
16372
  * @returns
@@ -16990,34 +16399,34 @@ class DocumentEvent {
16990
16399
  class DocumentInput {
16991
16400
  docCtx;
16992
16401
  //输入内容事件
16993
- onInputEvent = new Subject$1();
16402
+ onInputEvent = new Subject();
16994
16403
  //backspace 键盘事件
16995
- onBackspaceEvent = new Subject$1();
16404
+ onBackspaceEvent = new Subject();
16996
16405
  //delete 键盘事件
16997
- onDeleteEvent = new Subject$1();
16406
+ onDeleteEvent = new Subject();
16998
16407
  //enter 键盘事件
16999
- onEnterEvent = new Subject$1();
16408
+ onEnterEvent = new Subject();
17000
16409
  //左键
17001
- onLeftEvent = new Subject$1();
16410
+ onLeftEvent = new Subject();
17002
16411
  //右键
17003
- onRightEvent = new Subject$1();
16412
+ onRightEvent = new Subject();
17004
16413
  //复制
17005
- onCopyEvent = new Subject$1();
16414
+ onCopyEvent = new Subject();
17006
16415
  //剪切
17007
- onCutEvent = new Subject$1();
16416
+ onCutEvent = new Subject();
17008
16417
  //粘贴
17009
- onPasteEvent = new Subject$1();
16418
+ onPasteEvent = new Subject();
17010
16419
  //插入换行符
17011
- onInsertBr = new Subject$1();
16420
+ onInsertBr = new Subject();
17012
16421
  //ctrl+A 全选事件
17013
- onSelectAllEvent = new Subject$1();
16422
+ onSelectAllEvent = new Subject();
17014
16423
  //home 事件
17015
- onHomeEvent = new Subject$1();
16424
+ onHomeEvent = new Subject();
17016
16425
  //end 事件
17017
- onEndEvent = new Subject$1();
17018
- onUpEvent = new Subject$1();
17019
- onDownEvent = new Subject$1();
17020
- onTabKeyEvent = new Subject$1();
16426
+ onEndEvent = new Subject();
16427
+ onUpEvent = new Subject();
16428
+ onDownEvent = new Subject();
16429
+ onTabKeyEvent = new Subject();
17021
16430
  constructor(docCtx) {
17022
16431
  this.docCtx = docCtx;
17023
16432
  }
@@ -17205,7 +16614,7 @@ class DocumentChange {
17205
16614
  });
17206
16615
  }
17207
16616
  newInput(data) {
17208
- if (data.composition && data.data === '') {
16617
+ if (data.composition && data.data === '') {
17209
16618
  debugger;
17210
16619
  }
17211
16620
  const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
@@ -17230,6 +16639,9 @@ class DocumentChange {
17230
16639
  const comp = data.compositionStartInfo;
17231
16640
  comp.element = newInput;
17232
16641
  comp.offset = 0;
16642
+ //修正数据
16643
+ if (data.composition)
16644
+ this.documentInput.correctInputEle(newInput, newInput.text, 0);
17233
16645
  this.inputTextGroup(newInput, data);
17234
16646
  return;
17235
16647
  }
@@ -17281,7 +16693,7 @@ class DocumentChange {
17281
16693
  return true;
17282
16694
  };
17283
16695
  //利用回调完成后续的输入处理
17284
- this.docCtx.setPaintedCallback(cb);
16696
+ this.docCtx.onNextView(cb);
17285
16697
  }
17286
16698
  /**
17287
16699
  * 当前元素是否在正确的留痕区域(ins-run、del-run),情况分为以下情况
@@ -18410,7 +17822,7 @@ class DocumentChange {
18410
17822
  const cb = () => {
18411
17823
  this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
18412
17824
  };
18413
- this.docCtx.setPaintedCallback(cb);
17825
+ this.docCtx.onNextView(cb);
18414
17826
  return;
18415
17827
  }
18416
17828
  this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
@@ -19142,6 +18554,7 @@ class ElementTrackManage {
19142
18554
  */
19143
18555
  generateTrack() {
19144
18556
  if (!this.docCtx.viewOptions.enableTrackHistory) {
18557
+ clearTraces(this.docCtx.document);
19145
18558
  return;
19146
18559
  }
19147
18560
  const ops = generatePatch(this.docCtx.document);
@@ -19344,7 +18757,7 @@ class ElementTrackManage {
19344
18757
  if (!ssLog) {
19345
18758
  return;
19346
18759
  }
19347
- this.docCtx.setPaintedCallback(() => {
18760
+ this.docCtx.onNextView(() => {
19348
18761
  const { startIndex, startOffset, endIndex, endOffset, editable } = ssLog;
19349
18762
  const range = new SelectionRange();
19350
18763
  const sc = this.getControl(startIndex, false);
@@ -19450,6 +18863,9 @@ class ElementTrackManage {
19450
18863
  getControl(index, pure = true) {
19451
18864
  return ElementUtil.getControlByIndex(this.docCtx.document, { currIndex: -1, index: index }, pure);
19452
18865
  }
18866
+ getControlIndex(control) {
18867
+ return ElementUtil.getControlIndex(control, true);
18868
+ }
19453
18869
  }
19454
18870
 
19455
18871
  class DocumentSvg {
@@ -19465,7 +18881,7 @@ class DocumentSvg {
19465
18881
  this.sso = sso;
19466
18882
  this.renderCtx = renderCtx;
19467
18883
  }
19468
- getVNode(render, selectionRects, parentPos) {
18884
+ getVNode(render, parentMaskRect, parentPos) {
19469
18885
  const currPos = {
19470
18886
  x: parentPos.x + render.rect.x,
19471
18887
  y: parentPos.y + render.rect.y,
@@ -19473,17 +18889,13 @@ class DocumentSvg {
19473
18889
  height: render.rect.height
19474
18890
  };
19475
18891
  //处理选区遮罩
19476
- this.createSelectionRect(render, selectionRects, currPos);
19477
- //审阅窗口重新计算位置
19478
- if (this.viewOptions.showReviewWindow && render instanceof CommsContainerRenderObject) {
19479
- CommentsUtil.arrangeComments(render);
19480
- }
19481
- const getChildNodes = (node, selectionRects) => {
18892
+ this.createSelectionRect(render, parentMaskRect, currPos);
18893
+ const getChildNodes = (node, selectionMask) => {
19482
18894
  if (node instanceof BranchRenderObject) {
19483
18895
  const children = [];
19484
18896
  for (let i = 0; i < node.length; i++) {
19485
18897
  const child = node.getChild(i);
19486
- const vNode = this.getVNode(child, selectionRects, currPos);
18898
+ const vNode = this.getVNode(child, selectionMask, currPos);
19487
18899
  if (Array.isArray(vNode)) {
19488
18900
  children.push(...vNode);
19489
18901
  }
@@ -19493,14 +18905,12 @@ class DocumentSvg {
19493
18905
  }
19494
18906
  return children;
19495
18907
  }
19496
- else {
19497
- return null;
19498
- }
18908
+ return null;
19499
18909
  };
19500
- let selectionRectsTemp = [];
18910
+ let currMaskGroup = { selection: [], mask: [] };
19501
18911
  const vNodeOptions = {
19502
18912
  getChildNodes: (node) => {
19503
- return getChildNodes(node, selectionRectsTemp);
18913
+ return getChildNodes(node, currMaskGroup);
19504
18914
  },
19505
18915
  options: this.viewOptions,
19506
18916
  highlights: [],
@@ -19520,7 +18930,7 @@ class DocumentSvg {
19520
18930
  this.highlights.push(...vNodeOptions.highlights);
19521
18931
  }
19522
18932
  if (currVNode && !currVNode.isCompleted) {
19523
- const childNodes = getChildNodes(render, selectionRectsTemp);
18933
+ const childNodes = getChildNodes(render, currMaskGroup);
19524
18934
  if (childNodes) {
19525
18935
  if (!currVNode.children) {
19526
18936
  currVNode.children = [];
@@ -19534,26 +18944,22 @@ class DocumentSvg {
19534
18944
  }
19535
18945
  }
19536
18946
  if (render instanceof ParagraphLineRectRenderObject) {
19537
- if (selectionRectsTemp.length > 0) {
19538
- const startX = selectionRectsTemp[0].x;
19539
- const endX = selectionRectsTemp[selectionRectsTemp.length - 1].x + selectionRectsTemp[selectionRectsTemp.length - 1].width;
19540
- selectionRects.push({
19541
- x: startX,
19542
- y: currPos.y,
19543
- width: endX - startX,
19544
- height: currPos.height,
19545
- color: selectionRectsTemp[0].color
19546
- });
19547
- selectionRectsTemp.length = 0;
18947
+ if (currMaskGroup.selection.length > 0) {
18948
+ this.combineParaLineSelection(parentMaskRect.selection, currMaskGroup.selection, currPos);
19548
18949
  }
19549
18950
  }
19550
18951
  else if (render instanceof TableCellRenderObject) {
19551
18952
  if (this.sso.selectionEleSets.has(render.element) && this.sso.selectionEleSets.get(render.element)?.isFullSelected) {
19552
- selectionRects.push(currPos);
19553
- selectionRectsTemp.length = 0;
18953
+ parentMaskRect.selection.push(currPos);
18954
+ currMaskGroup.selection.length = 0;
18955
+ }
18956
+ if (this.sso.commRangeSets.has(render.element) && this.sso.commRangeSets.get(render.element)?.isFullSelected) {
18957
+ parentMaskRect.mask.push(currPos);
18958
+ currMaskGroup.mask.length = 0;
19554
18959
  }
19555
18960
  }
19556
- selectionRects.push(...selectionRectsTemp);
18961
+ parentMaskRect.selection.push(...currMaskGroup.selection);
18962
+ parentMaskRect.mask.push(...currMaskGroup.mask);
19557
18963
  // if (currVNode && currVNode.data?.attrs?.transform) {
19558
18964
  // currVNode.data.attrs.transform = `translate(${currVNode.data?.attrs?.transform.x},${currVNode.data?.attrs?.transform.y})`
19559
18965
  // }
@@ -19573,13 +18979,6 @@ class DocumentSvg {
19573
18979
  if (line && !item.data.attrs.transform) {
19574
18980
  item.data.attrs.transform = `translate(${translateX},${translateY})`;
19575
18981
  }
19576
- // if (item && item.data?.attrs?.transform && typeof item.data?.attrs?.transform === 'object') {
19577
- // item.data.attrs.transform = `translate(${item.data.attrs.transform.x + translateX},${item.data.attrs.transform.y + translateY})`
19578
- // } else {
19579
- // if (line && !item.data.attrs.transform) {
19580
- // item.data.attrs.transform = `translate(${translateX},${translateY})`;
19581
- // }
19582
- // }
19583
18982
  });
19584
18983
  if (line) {
19585
18984
  return currVNode.children;
@@ -19590,32 +18989,35 @@ class DocumentSvg {
19590
18989
  }
19591
18990
  return currVNode;
19592
18991
  }
19593
- createSelectionRect(render, selectionRects, currPos) {
19594
- const items = [this.sso.selectionEleSets, this.sso.commRangeSets];
19595
- for (const item of items) {
19596
- if (item.has(render.element)) {
19597
- const range = item.get(render.element);
19598
- if (render.element && render instanceof LeafRenderObject) {
19599
- if (range.isFullSelected) {
19600
- selectionRects.push({ ...currPos, color: range['rangeColor'] });
19601
- }
19602
- else {
19603
- if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
19604
- const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
19605
- const width = endX - startX;
19606
- const x = currPos.x + startX;
19607
- // @ts-ignore
19608
- selectionRects.push({
19609
- x,
19610
- y: currPos.y,
19611
- width,
19612
- height: currPos.height,
19613
- color: range['rangeColor']
19614
- });
19615
- }
18992
+ createSelectionRect(render, selectionMask, currPos) {
18993
+ const createMaskVNode = (range, selectionRects) => {
18994
+ if (render.element && render instanceof LeafRenderObject) {
18995
+ if (range.isFullSelected) {
18996
+ selectionRects.push({ ...currPos, color: range['rangeColor'] });
18997
+ }
18998
+ else {
18999
+ if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
19000
+ const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
19001
+ const width = endX - startX;
19002
+ const x = currPos.x + startX;
19003
+ selectionRects.push({
19004
+ x,
19005
+ y: currPos.y,
19006
+ width,
19007
+ height: currPos.height,
19008
+ color: range['rangeColor']
19009
+ });
19616
19010
  }
19617
19011
  }
19618
19012
  }
19013
+ };
19014
+ if (this.sso.selectionEleSets.has(render.element)) {
19015
+ const range = this.sso.selectionEleSets.get(render.element);
19016
+ createMaskVNode(range, selectionMask.selection);
19017
+ }
19018
+ if (this.sso.commRangeSets.has(render.element)) {
19019
+ const range = this.sso.commRangeSets.get(render.element);
19020
+ createMaskVNode(range, selectionMask.mask);
19619
19021
  }
19620
19022
  }
19621
19023
  getHTMLVNode(docRenders) {
@@ -19664,12 +19066,13 @@ class DocumentSvg {
19664
19066
  }
19665
19067
  getPageSvgVNode(item) {
19666
19068
  this.highlights = [];
19667
- const rects = [];
19069
+ const rects = { selection: [], mask: [] };
19668
19070
  this.pagePos = { x: item.rect.x, y: item.rect.y };
19669
19071
  const pageSvg = this.getVNode(item, rects, { x: -item.rect.x, y: -item.rect.y });
19670
19072
  const selectionNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'selection');
19671
- const hightlightNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'highlight');
19672
- selectionNode.children = rects.map(item => ({
19073
+ const highlightNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'highlight');
19074
+ rects.selection = rects.selection.concat(rects.mask);
19075
+ selectionNode.children = rects.selection.map(item => ({
19673
19076
  sel: 'path',
19674
19077
  data: {
19675
19078
  ns: 'http://www.w3.org/2000/svg',
@@ -19682,7 +19085,7 @@ class DocumentSvg {
19682
19085
  }
19683
19086
  }
19684
19087
  }));
19685
- hightlightNode.children = this.highlights;
19088
+ highlightNode.children = this.highlights;
19686
19089
  return pageSvg;
19687
19090
  }
19688
19091
  counterMap = {};
@@ -19702,6 +19105,25 @@ class DocumentSvg {
19702
19105
  addChangeTips(tipVNode) {
19703
19106
  this.changeTips.push(tipVNode);
19704
19107
  }
19108
+ /**
19109
+ * 合并段落行选区
19110
+ * @param parentMaskRect
19111
+ * @param currMaskRect
19112
+ * @param currPos
19113
+ * @private
19114
+ */
19115
+ combineParaLineSelection(parentMaskRect, currMaskRect, currPos) {
19116
+ const startX = currMaskRect[0].x;
19117
+ const endX = currMaskRect[currMaskRect.length - 1].x + currMaskRect[currMaskRect.length - 1].width;
19118
+ parentMaskRect.push({
19119
+ x: startX,
19120
+ y: currPos.y,
19121
+ width: endX - startX,
19122
+ height: currPos.height,
19123
+ color: currMaskRect[0].color
19124
+ });
19125
+ currMaskRect.length = 0;
19126
+ }
19705
19127
  }
19706
19128
 
19707
19129
  /**
@@ -19714,7 +19136,7 @@ class EditorCalendarVNode {
19714
19136
  currCalendarMode;
19715
19137
  selectedDate;
19716
19138
  currentDate = '';
19717
- onSetValue = new Subject$1();
19139
+ onSetValue = new Subject();
19718
19140
  currTime;
19719
19141
  selectedTime;
19720
19142
  constructor(viewOptions) {
@@ -20535,6 +19957,154 @@ class DocRule {
20535
19957
  }
20536
19958
  }
20537
19959
 
19960
+ function calculateOverflow(rect, viewport) {
19961
+ const overflow = rect.y + rect.height - (viewport.y + viewport.height);
19962
+ return overflow > 0 ? overflow : 0;
19963
+ }
19964
+ function adjustRectangles(rectangles, startIndex, endIndex, overflow) {
19965
+ for (let i = startIndex; i < endIndex; i++) {
19966
+ const currentRect = rectangles[i];
19967
+ currentRect.y -= overflow;
19968
+ }
19969
+ }
19970
+ function placeRectangles(rectangles, viewport) {
19971
+ // Step 1: 过滤视窗内的矩形并按y值排序
19972
+ const sortedRectangles = rectangles
19973
+ .filter(rect => rect.y + rect.height >= viewport.y &&
19974
+ rect.y <= viewport.y + viewport.height)
19975
+ .sort((a, b) => a.y - b.y);
19976
+ // Step 2: 遍历并调整矩形位置
19977
+ for (let i = 1; i < sortedRectangles.length; i++) {
19978
+ const currentRect = sortedRectangles[i];
19979
+ const prevRect = sortedRectangles[i - 1];
19980
+ // Step 3: 调整重叠矩形的位置
19981
+ if (currentRect.y < prevRect.y + prevRect.height) {
19982
+ currentRect.y = prevRect.y + prevRect.height;
19983
+ }
19984
+ // Step 4: 处理超出视窗的情况
19985
+ let overflow = calculateOverflow(currentRect, viewport);
19986
+ if (overflow <= 0) {
19987
+ continue;
19988
+ }
19989
+ //紧挨着的上级兄弟元素之间存在足够空间
19990
+ const remainingSpace = currentRect.y - prevRect.y - prevRect.height;
19991
+ if (remainingSpace > 0) {
19992
+ if (remainingSpace >= overflow) {
19993
+ currentRect.y -= overflow;
19994
+ continue;
19995
+ }
19996
+ else {
19997
+ overflow -= remainingSpace;
19998
+ adjustRectangles(sortedRectangles, i - 1, i, remainingSpace);
19999
+ currentRect.y -= remainingSpace;
20000
+ }
20001
+ }
20002
+ const space = findSpace(sortedRectangles, viewport, i - 1, i, overflow);
20003
+ //完全没有可用空间,后续元素按照顺序排列即可
20004
+ if (space === overflow) {
20005
+ const prevRect = sortedRectangles[i - 1];
20006
+ sortedRectangles.filter((item, index) => index >= i).reduce((prev, curr) => { curr.y = prev.y + prev.height; return curr; }, prevRect);
20007
+ break;
20008
+ }
20009
+ currentRect.y -= (overflow - space);
20010
+ }
20011
+ return sortedRectangles;
20012
+ }
20013
+ function findSpace(sortedRectangles, viewport, i, overflowIndex, overflow) {
20014
+ for (let j = i; j >= 0; j--) {
20015
+ let currentRect = sortedRectangles[j];
20016
+ let aboveRect = sortedRectangles[j - 1];
20017
+ if (aboveRect === undefined) {
20018
+ aboveRect = { y: viewport.y, height: 0, width: 0, x: 0 };
20019
+ }
20020
+ const remainingSpace = currentRect.y - aboveRect.y - aboveRect.height;
20021
+ //存在可用空间
20022
+ if (remainingSpace > 0) {
20023
+ if (remainingSpace >= overflow) {
20024
+ adjustRectangles(sortedRectangles, j, overflowIndex, overflow);
20025
+ return 0;
20026
+ }
20027
+ else {
20028
+ overflow -= remainingSpace;
20029
+ // 调整当前元素到溢出元素之间的元素的y值
20030
+ adjustRectangles(sortedRectangles, j, overflowIndex, remainingSpace);
20031
+ return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
20032
+ }
20033
+ }
20034
+ else {
20035
+ return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
20036
+ }
20037
+ }
20038
+ return overflow;
20039
+ }
20040
+ /**
20041
+ * 调整页面提示框位置,使其在视窗内的位置合理
20042
+ */
20043
+ function adjustViewportElements(tipContainer, viewPort) {
20044
+ viewPort.y /= viewPort.scale;
20045
+ viewPort.height /= viewPort.scale;
20046
+ const tipContainerEle = tipContainer.elm;
20047
+ const tipContainerRect = tipContainerEle.getBoundingClientRect();
20048
+ const children = tipContainer.children;
20049
+ if (!children || children.length === 0) {
20050
+ return;
20051
+ }
20052
+ const nativeEle = [];
20053
+ for (let i = 0; i < children.length; i++) {
20054
+ const item = children[i];
20055
+ const elm = item.elm;
20056
+ if (!elm.classList.contains("tg-container")) {
20057
+ continue;
20058
+ }
20059
+ const runKey = elm.dataset['key'];
20060
+ const lineElm = tipContainerEle.querySelector(`.doc-triangle-line[data-key='${runKey}']`);
20061
+ const linePos = getEleAbsolutePos(lineElm);
20062
+ const eleRect = { elm, lineElm, x: 0, y: 0, width: 0, height: 0, linePos };
20063
+ nativeEle.push(eleRect);
20064
+ const rect = elm.getBoundingClientRect();
20065
+ eleRect.y = linePos.y;
20066
+ eleRect.x = (rect.x - tipContainerRect.x) / viewPort.scale;
20067
+ eleRect.width = rect.width / viewPort.scale;
20068
+ eleRect.height = rect.height / viewPort.scale;
20069
+ }
20070
+ if (nativeEle.length) {
20071
+ const sortedRectangles = placeRectangles(nativeEle, viewPort);
20072
+ for (let i = 0; i < sortedRectangles.length; i++) {
20073
+ const item = sortedRectangles[i];
20074
+ item.elm.style.top = item.y + 'px';
20075
+ const rotationAngle = calculateRotationAngle(item.linePos, item);
20076
+ const distance = calculateDistance(item.linePos, item);
20077
+ rotateDiv(item.lineElm, rotationAngle, distance);
20078
+ }
20079
+ }
20080
+ }
20081
+ function getEleAbsolutePos(elm) {
20082
+ const topStr = elm.style.top;
20083
+ const leftStr = elm.style.left;
20084
+ return {
20085
+ x: parseInt(leftStr.substring(0, leftStr.length - 2)),
20086
+ y: parseInt(topStr.substring(0, topStr.length - 2))
20087
+ };
20088
+ }
20089
+ function calculateRotationAngle(a, b) {
20090
+ const deltaX = b.x - a.x;
20091
+ const deltaY = b.y - a.y;
20092
+ // 使用反正切函数计算旋转角度
20093
+ const angleInRadians = Math.atan2(deltaY, deltaX);
20094
+ // 将弧度转换为度数
20095
+ const angleInDegrees = angleInRadians * (180 / Math.PI);
20096
+ return angleInDegrees;
20097
+ }
20098
+ function rotateDiv(c, angle, distance) {
20099
+ c.style.transform = `rotate(${angle}deg)`;
20100
+ c.style.width = `${distance}px`;
20101
+ }
20102
+ function calculateDistance(a, b) {
20103
+ const deltaX = b.x - a.x;
20104
+ const deltaY = b.y - a.y;
20105
+ return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
20106
+ }
20107
+
20538
20108
  class DocEditor {
20539
20109
  svgContainer;
20540
20110
  //private docContent!: HTMLElement;
@@ -20552,28 +20122,25 @@ class DocEditor {
20552
20122
  selectionOverlays;
20553
20123
  //private docRule: DocRule;
20554
20124
  historyMange;
20555
- selectionChanged = new Subject$1();
20556
- beforeRenderSubject = new Subject$1();
20557
- afterRenderSubject = new Subject$1();
20558
- onBeforeSetCursorSubject = new Subject$1();
20559
- contentChanged = new Subject$1();
20560
- onPatchVNodeSubject = new Subject$1();
20125
+ selectionChanged = new Subject();
20126
+ beforeRenderSubject = new Subject();
20127
+ afterRenderSubject = new Subject();
20128
+ onBeforeSetCursorSubject = new Subject();
20129
+ contentChanged = new Subject();
20130
+ onPatchVNodeSubject = new Subject();
20561
20131
  selectionState;
20562
- //显示右键菜单
20563
- onContextMenuItemChanged = new Subject$1();
20564
- onDblClickEvent = new Subject$1();
20565
- onClickEvent = new Subject$1();
20566
- onScrollViewEvent = new Subject$1();
20132
+ onDblClickEvent = new Subject();
20133
+ onClickEvent = new Subject();
20567
20134
  //文档改变事件:内容及样式,业务模块需要根据此事件,来追踪当前文档是否改变的状态
20568
- onDocChangedEvent = new Subject$1();
20135
+ onDocChangedEvent = new Subject();
20569
20136
  //执行flushTask,refreshDoc之前,此时可以在文档计算排版之前改变内容
20570
- onBeforeRefreshDocument = new Subject$1();
20137
+ onBeforeRefreshDocument = new Subject();
20571
20138
  //文档视图尺寸改变事件
20572
- onDocViewSizeChanged = new Subject$1();
20139
+ onDocViewSizeChanged = new Subject();
20573
20140
  //编辑器销毁事件
20574
- onDestroy = new Subject$1();
20575
- beforeNodePatch = new Subject$1();
20576
- afterNodePatch = new Subject$1();
20141
+ onDestroy = new Subject();
20142
+ beforeNodePatch = new Subject();
20143
+ afterNodePatch = new Subject();
20577
20144
  //自定义事件传递消息
20578
20145
  eventBus;
20579
20146
  editInput;
@@ -20588,7 +20155,6 @@ class DocEditor {
20588
20155
  this.viewOptions.drawCharRectColor = 'green';
20589
20156
  this.viewOptions.showLineRect = true;
20590
20157
  this.viewOptions.docSpace = 20;
20591
- this.viewOptions.reviewWindowWidth = 200;
20592
20158
  this.viewOptions.defaultFontName = '宋体';
20593
20159
  this.viewOptions.editorVersion = this.version();
20594
20160
  //this.viewOptions.scale = 2;
@@ -20774,12 +20340,15 @@ class DocEditor {
20774
20340
  return null;
20775
20341
  }
20776
20342
  this.flushTask = () => {
20343
+ //读取变更记录,可能会同步影响文档内容
20344
+ this.readDocChangeLog();
20777
20345
  this.refreshDocument();
20778
20346
  this.flushTask = null;
20779
- let cb = this.docCtx.paintedCallback;
20780
- if (cb) {
20781
- this.docCtx.setPaintedCallback(null);
20782
- cb();
20347
+ //回调
20348
+ let cbs = [...this.docCtx.nextViewFns];
20349
+ if (cbs.length) {
20350
+ this.docCtx.onNextView(null);
20351
+ cbs.forEach(cb => cb());
20783
20352
  return;
20784
20353
  }
20785
20354
  this.historyMange.generateTrack();
@@ -20940,7 +20509,7 @@ class DocEditor {
20940
20509
  this.editInput.style.left = position.x + 'px';
20941
20510
  this.editInput.style.top = position.y + 'px';
20942
20511
  this.editInput.style.height = position.height + 'px';
20943
- this.editInput.style.width = "2px";
20512
+ this.editInput.style.width = "1.6px";
20944
20513
  this.editInput.readOnly = false;
20945
20514
  this.setCursorVisibility(true);
20946
20515
  //判断光标位置是否被可见,如果不可见,需要将其设置到可见区域
@@ -21209,7 +20778,7 @@ class DocEditor {
21209
20778
  this.onDocViewSizeChanged.unsubscribe();
21210
20779
  this.flushTask = null;
21211
20780
  Object.keys(this).forEach(key => {
21212
- if (this[key] instanceof Subject$1) {
20781
+ if (this[key] instanceof Subject) {
21213
20782
  this[key].unsubscribe();
21214
20783
  }
21215
20784
  });
@@ -21315,7 +20884,7 @@ class DocEditor {
21315
20884
  }
21316
20885
  /**
21317
20886
  * 设置段落样式
21318
- * @param newProps
20887
+ * @param setterFunc
21319
20888
  */
21320
20889
  setParaStyleByFn(setterFunc) {
21321
20890
  DocumentChange.setParaStyle(this.selectionState, setterFunc);
@@ -21676,7 +21245,8 @@ class DocEditor {
21676
21245
  styleModule,
21677
21246
  classModule,
21678
21247
  attributesModule,
21679
- eventListenersModule
21248
+ eventListenersModule,
21249
+ datasetModule
21680
21250
  ]);
21681
21251
  setActiveEditorContext(this);
21682
21252
  const vNodeFunc = this.renderRoot();
@@ -21741,6 +21311,7 @@ class DocEditor {
21741
21311
  children.push(tipsContainer);
21742
21312
  children.push(...vNode);
21743
21313
  tipsContainer.children?.push(...svgGenerator.changeTips);
21314
+ this.updateTipLayoutWidth();
21744
21315
  const sub = this.afterNodePatch.subscribe(() => {
21745
21316
  this.updateTipLayoutAfterPatch();
21746
21317
  sub.unsubscribe();
@@ -21750,42 +21321,50 @@ class DocEditor {
21750
21321
  };
21751
21322
  }
21752
21323
  /**
21753
- * 更新留痕提示框位置在文档渲染后
21324
+ * 更新提示区域布局宽度,根据渲染的节点,判断是否需要设置提示区域宽度
21754
21325
  * @private
21755
21326
  */
21756
- updateTipLayoutAfterPatch() {
21757
- const children = this.tipContainer.children;
21758
- if (!children || children.length === 0) {
21759
- return;
21760
- }
21761
- let prevPos = { x: 0, y: -999999 };
21762
- const gap = 12;
21763
- for (let i = 0; i < children.length; i++) {
21764
- const item = children[i];
21765
- const elm = item.elm;
21766
- const topStr = elm.style.top;
21767
- let topPixs = Number.parseInt(topStr.substring(0, topStr.length - 2));
21768
- const rect = elm.getBoundingClientRect();
21769
- if (topPixs + gap < prevPos.y) {
21770
- topPixs = (prevPos.y + gap);
21771
- elm.style.top = topPixs + 'px';
21327
+ updateTipLayoutWidth() {
21328
+ const tipChildren = this.tipContainer?.children;
21329
+ if (!tipChildren || !tipChildren.length) {
21330
+ if (this.viewOptions.reviewWindowWidth > 0) {
21331
+ this.viewOptions.reviewWindowWidth = 0;
21332
+ //刷新页面
21333
+ this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21772
21334
  }
21773
- if (topPixs - prevPos.y < gap) {
21774
- elm.style.top = (prevPos.y + gap) + 'px';
21335
+ }
21336
+ else {
21337
+ if (this.viewOptions.reviewWindowWidth === 0) {
21338
+ this.viewOptions.reviewWindowWidth = 250;
21339
+ //刷新页面
21340
+ this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21775
21341
  }
21776
- prevPos.y = topPixs + rect.height;
21777
21342
  }
21778
21343
  }
21344
+ /**
21345
+ * 更新留痕提示框位置在文档渲染后
21346
+ * @private
21347
+ */
21348
+ updateTipLayoutAfterPatch() {
21349
+ const viewBoxRect = {
21350
+ x: this.viewOptions.pageOffset.x,
21351
+ y: this.viewOptions.pageOffset.y,
21352
+ width: this.viewOptions.viewSettings.width,
21353
+ height: this.viewOptions.viewSettings.height,
21354
+ scale: this.viewOptions.scale
21355
+ };
21356
+ adjustViewportElements(this.tipContainer, viewBoxRect);
21357
+ }
21779
21358
  createChangeTipContainer() {
21780
21359
  const docRect = this.documentPaginator.docContainer.getItems()[0].rect;
21781
- const x = docRect.x + docRect.width + 20;
21360
+ docRect.x + docRect.width + 20;
21782
21361
  return {
21783
- sel: 'div.tip-container',
21362
+ sel: 'div.decorate-container',
21784
21363
  data: {
21785
- style: {
21786
- left: x + 'px',
21787
- top: '0px',
21788
- }
21364
+ /* style: {
21365
+ left: x + 'px',
21366
+ top: '0px',
21367
+ }*/
21789
21368
  },
21790
21369
  children: []
21791
21370
  };
@@ -21866,7 +21445,6 @@ class DocEditor {
21866
21445
  },
21867
21446
  on: {
21868
21447
  click: (evt) => {
21869
- console.log('dd');
21870
21448
  onChangeHandler(item.code);
21871
21449
  }
21872
21450
  }
@@ -22034,7 +21612,7 @@ class DocEditor {
22034
21612
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
22035
21613
  }
22036
21614
  version() {
22037
- return "2.1.28";
21615
+ return "2.2.1";
22038
21616
  }
22039
21617
  switchPageHeaderEditor() {
22040
21618
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -22114,6 +21692,36 @@ class DocEditor {
22114
21692
  ])
22115
21693
  ]);
22116
21694
  }
21695
+ readDocChangeLog() {
21696
+ //获取文档的变更日志
21697
+ const ops = generatePatch(this.docCtx.document, false);
21698
+ for (let i = 0; i < ops.length; i++) {
21699
+ const op = ops[i];
21700
+ if ('delete' in op.ops) {
21701
+ const delItem = op.ops.delete;
21702
+ //获取删除的批注元素
21703
+ const getDelCommItems = ElementUtil.getMatchItems(delItem, (item) => item instanceof CommentElement);
21704
+ const maps = {};
21705
+ getDelCommItems.forEach(item => {
21706
+ let num = maps[item.props.id];
21707
+ if (num === undefined) {
21708
+ maps[item.props.id] = 1;
21709
+ }
21710
+ else {
21711
+ maps[item.props.id] = num + 1;
21712
+ }
21713
+ });
21714
+ //获取需要删除的批注元素
21715
+ const keys = Object.keys(maps).filter(key => maps[key] === 1);
21716
+ if (keys.length) {
21717
+ const commItems = this.docCtx.document.treeFilter(item => item instanceof CommentElement);
21718
+ const delCommItems = commItems.filter(item => keys.includes(item.props.id));
21719
+ delCommItems.forEach(item => item.remove());
21720
+ return true;
21721
+ }
21722
+ }
21723
+ }
21724
+ }
22117
21725
  }
22118
21726
 
22119
21727
  /**
@@ -27211,10 +26819,10 @@ class DocumentPrintOffscreenBase {
27211
26819
  docCtx;
27212
26820
  renderCtx;
27213
26821
  elementReader;
27214
- beforeRenderEvent = new Subject$1();
27215
- afterRenderEvent = new Subject$1();
27216
- beforePrint = new Subject$1();
27217
- afterPrint = new Subject$1();
26822
+ beforeRenderEvent = new Subject();
26823
+ afterRenderEvent = new Subject();
26824
+ beforePrint = new Subject();
26825
+ afterPrint = new Subject();
27218
26826
  constructor() {
27219
26827
  this.viewOptions = new ViewOptions();
27220
26828
  this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
@@ -27500,5 +27108,5 @@ function removeDuplicatesEvent(events) {
27500
27108
  return arr;
27501
27109
  }
27502
27110
 
27503
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaginator, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PermanentTeethElement, PermanentTeethFactory, PermanentTeethProps, PermanentTeethRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RowMinHeight, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TextUnitsHolder, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, addReturn, clearChildrenRenderCache, clearTraces, cloneChildren, cloneElementBase, defaultParaHanging, deleteCurrentParagraph, docOpsMap, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, removeEle, removeText, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
27111
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaginator, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PermanentTeethElement, PermanentTeethFactory, PermanentTeethProps, PermanentTeethRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RowMinHeight, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TextUnitsHolder, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, addReturn, clearChildrenRenderCache, clearTraces, cloneChildren, cloneElementBase, defaultParaHanging, deleteCurrentParagraph, docOpsMap, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, removeEle, removeText, renderErrorTip, renderUnderWavyLine, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
27504
27112
  //# sourceMappingURL=index.js.map