@hailin-zheng/editor-core 2.2.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -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,
@@ -2113,7 +2106,6 @@ class DocumentProps extends INotifyPropertyChanged {
2113
2106
  createUserId;
2114
2107
  createUserName;
2115
2108
  createDate;
2116
- scripts;
2117
2109
  columns = 1;
2118
2110
  version;
2119
2111
  clone(dest) {
@@ -2124,7 +2116,6 @@ class DocumentProps extends INotifyPropertyChanged {
2124
2116
  clone.padding = this.padding.clone();
2125
2117
  clone.headerLine = this.headerLine;
2126
2118
  clone.footerLine = this.footerLine;
2127
- clone.scripts = this.scripts;
2128
2119
  clone.createUserId = this.createUserId;
2129
2120
  clone.createUserName = this.createUserName;
2130
2121
  clone.createDate = this.createDate;
@@ -2144,9 +2135,6 @@ class DocumentProps extends INotifyPropertyChanged {
2144
2135
  createUserName: this.createUserName,
2145
2136
  createUserId: this.createUserId,
2146
2137
  };
2147
- if (this.scripts) {
2148
- props['scripts'] = this.scripts;
2149
- }
2150
2138
  if (this.orient && this.orient !== 'portrait') {
2151
2139
  props['orient'] = this.orient;
2152
2140
  }
@@ -2380,7 +2368,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2380
2368
  printable;
2381
2369
  secretBrowse;
2382
2370
  editable = true;
2383
- deleteable;
2384
2371
  minLength;
2385
2372
  underline;
2386
2373
  expression;
@@ -2396,7 +2383,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2396
2383
  target.fieldName = source.fieldName;
2397
2384
  target.required = source.required;
2398
2385
  target.editable = source.editable;
2399
- target.deleteable = source.deleteable;
2400
2386
  target.secretBrowse = source.secretBrowse;
2401
2387
  target.printable = source.printable;
2402
2388
  target.minLength = source.minLength;
@@ -2426,9 +2412,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2426
2412
  if (!this.editable) {
2427
2413
  props['editable'] = this.editable;
2428
2414
  }
2429
- if (this.deleteable) {
2430
- props["deleteable"] = this.deleteable;
2431
- }
2432
2415
  if (this.minLength) {
2433
2416
  props["minLength"] = this.minLength;
2434
2417
  }
@@ -3652,7 +3635,8 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3652
3635
  width: this.rect.width,
3653
3636
  height: this.rect.height - 1,
3654
3637
  viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
3655
- overflow: "hidden"
3638
+ overflow: "hidden",
3639
+ "shape-rendering": "optimizeSpeed"
3656
3640
  },
3657
3641
  },
3658
3642
  children: [
@@ -3702,7 +3686,6 @@ class DocumentFactory extends ElementFactory {
3702
3686
  docProps.padding = new PaddingProps(props.padding.top, props.padding.bottom, props.padding.left, props.padding.right);
3703
3687
  docProps.headerLine = props.headerLine ?? 12;
3704
3688
  docProps.footerLine = props.footerLine ?? 12;
3705
- docProps.scripts = props.scripts;
3706
3689
  docProps.createUserId = props.createUserId;
3707
3690
  docProps.createUserName = props.createUserName;
3708
3691
  docProps.createDate = props.createDate;
@@ -3944,6 +3927,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3944
3927
  }
3945
3928
  });
3946
3929
  }
3930
+ renderErrorTip(event, this);
3947
3931
  return node;
3948
3932
  }
3949
3933
  }
@@ -3999,6 +3983,11 @@ class DataElementBaseFactory extends ElementFactory {
3999
3983
  }
4000
3984
  }
4001
3985
  }
3986
+ /**
3987
+ * 渲染数据元背景修饰
3988
+ * @param event
3989
+ * @param r
3990
+ */
4002
3991
  function exportDecoratorHTML(event, r) {
4003
3992
  const canPaint = r.element.isMouseenter || r.element.isFocused;
4004
3993
  if (!canPaint) {
@@ -4043,10 +4032,12 @@ function exportDecoratorHTML(event, r) {
4043
4032
  const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
4044
4033
  const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
4045
4034
  const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
4046
- event.highlights.push(ElementUtil.createSvgPath({ d: path,
4035
+ event.highlights.push(ElementUtil.createSvgPath({
4036
+ d: path,
4047
4037
  stroke: color,
4048
4038
  fill: 'none',
4049
- 'stroke-width': 1 }));
4039
+ 'stroke-width': 1
4040
+ }));
4050
4041
  return;
4051
4042
  }
4052
4043
  }
@@ -4061,6 +4052,110 @@ function exportDecoratorHTML(event, r) {
4061
4052
  }
4062
4053
  }
4063
4054
  }
4055
+ /**
4056
+ * 渲染数据源验证错误提示框
4057
+ */
4058
+ function renderErrorTip(event, r) {
4059
+ if (!event.options.enableDataEleInputValidate || event.mode === 'print') {
4060
+ return;
4061
+ }
4062
+ const ele = r.element;
4063
+ //元素调用内部验证
4064
+ ele.onChangedValidate();
4065
+ if (!ele.errorTip) {
4066
+ return;
4067
+ }
4068
+ //渲染底部波浪线
4069
+ renderUnderWavyLine(event, r, 'red');
4070
+ if (ele.paintRenders.indexOf(r) !== 0) {
4071
+ return;
4072
+ }
4073
+ const { x, y } = event.globalPos;
4074
+ const docRender = ElementUtil.getParentRender(r, DocumentRenderObject);
4075
+ const content = ele.errorTip;
4076
+ let left = ele.isFocused ? -10 : 5;
4077
+ //显示在文档的右测
4078
+ left += docRender.rect.x + docRender.rect.width + 20;
4079
+ let sel = 'div.tg-container';
4080
+ if (ele.isFocused) {
4081
+ sel += '.tg-container--selected';
4082
+ }
4083
+ const node = {
4084
+ sel,
4085
+ key: ele.props.id,
4086
+ data: {
4087
+ style: {
4088
+ left: `${left}px`,
4089
+ top: `${y}px`
4090
+ },
4091
+ dataset: {
4092
+ key: ele.key
4093
+ }
4094
+ },
4095
+ children: [{
4096
+ sel: 'div.header',
4097
+ data: {},
4098
+ children: [{
4099
+ sel: 'span.header-user',
4100
+ data: {},
4101
+ text: ele.props.caption,
4102
+ }]
4103
+ }, {
4104
+ sel: 'div.content',
4105
+ data: {},
4106
+ text: content
4107
+ }]
4108
+ };
4109
+ event.addChangeTips(node);
4110
+ const triangleTipX = x + r.rect.width / 2;
4111
+ const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
4112
+ const tipLineA = {
4113
+ sel: 'div.doc-triangle-line',
4114
+ data: {
4115
+ style: {
4116
+ left: `${triangleTipX}px`,
4117
+ top: `${y + r.rect.height}px`,
4118
+ width: tipLineAWidth + 'px'
4119
+ }
4120
+ }
4121
+ };
4122
+ const tipLineB = {
4123
+ sel: 'div.doc-triangle-line',
4124
+ data: {
4125
+ style: {
4126
+ left: `${triangleTipX + tipLineAWidth}px`,
4127
+ top: `${y + r.rect.height}px`,
4128
+ width: 20 + 'px'
4129
+ },
4130
+ dataset: {
4131
+ key: ele.key
4132
+ }
4133
+ }
4134
+ };
4135
+ const triangleTip = {
4136
+ sel: `div.doc-triangle`,
4137
+ data: {
4138
+ style: {
4139
+ left: `${triangleTipX}px`,
4140
+ top: `${y + r.rect.height * 2 / 3}px`
4141
+ }
4142
+ }
4143
+ };
4144
+ event.addChangeTips(triangleTip);
4145
+ event.addChangeTips(tipLineA);
4146
+ event.addChangeTips(tipLineB);
4147
+ }
4148
+ /**
4149
+ * 渲染底部波浪线
4150
+ */
4151
+ function renderUnderWavyLine(event, r, color) {
4152
+ const { x, y } = event.relativePagePos;
4153
+ let d = `M ${x} ${y + r.rect.height - 2} q 1.5,2, `;
4154
+ const width = r.rect.width;
4155
+ d += Array(Math.ceil(width / 3)).fill("3,0").join(' t ');
4156
+ const path = ElementUtil.createSvgPath({ d, fill: 'none', stroke: color });
4157
+ event.highlights.push(path);
4158
+ }
4064
4159
  /**
4065
4160
  * 获取渲染元素相对稳当的位置
4066
4161
  * @param render
@@ -6801,7 +6896,7 @@ class CommentElement extends LeafElement {
6801
6896
  constructor() {
6802
6897
  super('comm');
6803
6898
  //this.isDecorate = true;
6804
- this.disableClick = true;
6899
+ //this.disableClick = true;
6805
6900
  this.props = new CommProps();
6806
6901
  this.color = CommonUtil.randomRgbColor(0.5);
6807
6902
  }
@@ -6831,6 +6926,9 @@ class CommentElement extends LeafElement {
6831
6926
  }
6832
6927
  class CommentRenderObject extends LeafRenderObject {
6833
6928
  exportSVG(event) {
6929
+ if (event.mode === 'print') {
6930
+ return;
6931
+ }
6834
6932
  const renderPos = { ...event.relativePagePos };
6835
6933
  const paraLinePos = ElementUtil.getParaLinePos(this, { x: renderPos.x, y: renderPos.y });
6836
6934
  const color = '#ff4d4f';
@@ -8337,9 +8435,6 @@ class DataElementDate extends DataElementInlineGroup {
8337
8435
  this.onChangedValidate();
8338
8436
  }
8339
8437
  isValid(val, format) {
8340
- if (!format) {
8341
- format = this.props.format ?? 'YYYY-MM-DD';
8342
- }
8343
8438
  const date = moment(val, format);
8344
8439
  return date.isValid();
8345
8440
  }
@@ -8354,8 +8449,7 @@ class DataElementDate extends DataElementInlineGroup {
8354
8449
  if (res) {
8355
8450
  return res;
8356
8451
  }
8357
- const format = this.props.format ?? 'YYYY-MM-DD';
8358
- const date = moment(this.getValue(), format, true);
8452
+ const date = moment(this.getValue(), true);
8359
8453
  if (!date.isValid()) {
8360
8454
  return '日期格式不正确';
8361
8455
  }
@@ -10725,7 +10819,6 @@ class ElementUtil {
10725
10819
  dest.printable = props.printable ?? true;
10726
10820
  dest.required = props.required;
10727
10821
  dest.secretBrowse = props.secretBrowse;
10728
- dest.deleteable = props.deleteable;
10729
10822
  dest.underline = props.underline;
10730
10823
  dest.expression = props.expression;
10731
10824
  dest.hidden = props.hidden;
@@ -12811,54 +12904,6 @@ class PaintContent {
12811
12904
  }
12812
12905
  }
12813
12906
 
12814
- class DocumentEvalFunc {
12815
- docCtx;
12816
- constructor(docCtx) {
12817
- this.docCtx = docCtx;
12818
- }
12819
- scriptsFunc;
12820
- /**
12821
- * 实例化动态脚本
12822
- */
12823
- initScripts(scripts) {
12824
- this.destroyScripts();
12825
- if (scripts) {
12826
- try {
12827
- const func = new Function("docCtx", scripts);
12828
- this.scriptsFunc = func(this.docCtx);
12829
- }
12830
- catch (e) {
12831
- console.error("自定义标本解析错误", e);
12832
- }
12833
- }
12834
- // const func = (docCtx: DocumentContext) => {
12835
- // const sexELe = docCtx.getControlById('NqoYI')
12836
- // const dyEle = docCtx.getControlById('gTuBI');
12837
- // return () => {
12838
- // if (sexELe && dyEle) {
12839
- // const sexValue = sexELe.getValue();
12840
- // const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
12841
- // dyEle.setValue(dyValue);
12842
- // }
12843
- // };
12844
- // };
12845
- }
12846
- /**
12847
- * 销毁动态脚本实例
12848
- */
12849
- destroyScripts() {
12850
- if (this.scriptsFunc) {
12851
- this.scriptsFunc = null;
12852
- }
12853
- }
12854
- /**
12855
- * 触发动态脚本
12856
- */
12857
- invokedScripts() {
12858
- this.scriptsFunc?.();
12859
- }
12860
- }
12861
-
12862
12907
  /**
12863
12908
  * 当前打开的文档的上下文信息,当前文档所有的属性设置都暴露在上下文中
12864
12909
  */
@@ -12869,22 +12914,29 @@ class EditorContext {
12869
12914
  cursorRect;
12870
12915
  _document;
12871
12916
  syncRefresh;
12872
- dynamicFunc;
12873
12917
  docChange;
12874
12918
  clearPrevDocCb;
12875
12919
  //绘制结束之后回调函数
12876
- nextViewFn;
12920
+ nextViewFns = [];
12921
+ //批注元素存在的标志,用于判断文档空间进行布局
12922
+ commentFlag = false;
12923
+ //留痕元素存在的标志,用于判断文档空间进行布局
12924
+ trackFlag = false;
12877
12925
  constructor(selectionState, viewOptions) {
12878
12926
  this.selectionState = selectionState;
12879
12927
  this.viewOptions = viewOptions;
12880
- this.dynamicFunc = new DocumentEvalFunc(this);
12881
12928
  //this.imageLoader = new DocumentImagesLoader();
12882
12929
  this.selectionState.onChangedEvent.subscribe(() => {
12883
12930
  this.syncRefresh?.();
12884
12931
  });
12885
12932
  }
12886
12933
  onNextView(cb) {
12887
- this.nextViewFn = cb;
12934
+ if (!cb) {
12935
+ this.nextViewFns.length = 0;
12936
+ return;
12937
+ }
12938
+ //this.nextViewFn = cb;
12939
+ this.nextViewFns.push(cb);
12888
12940
  }
12889
12941
  get document() {
12890
12942
  return this._document;
@@ -12892,7 +12944,6 @@ class EditorContext {
12892
12944
  set document(value) {
12893
12945
  this.clearPrevDocCb?.();
12894
12946
  this._document = value;
12895
- this.initScripts();
12896
12947
  // this.refSub = this._document.refreshSubject.subscribe((data) => {
12897
12948
  // data = data ?? 'content';
12898
12949
  // this.isDirty = this.isDirty || data === 'content';
@@ -12920,8 +12971,6 @@ class EditorContext {
12920
12971
  }
12921
12972
  clear() {
12922
12973
  this.selectionState.clear();
12923
- //this.imageLoader.clear();
12924
- this.dynamicFunc.destroyScripts();
12925
12974
  this.isDirty = false;
12926
12975
  //this.clearEleDepMaps();
12927
12976
  }
@@ -12973,12 +13022,6 @@ class EditorContext {
12973
13022
  this.document.viewOptions.textRowLineMode = !this.document.viewOptions.textRowLineMode;
12974
13023
  this.syncRefresh();
12975
13024
  }
12976
- /**
12977
- * 实例化动态脚本
12978
- */
12979
- initScripts() {
12980
- this.dynamicFunc.initScripts(this.document.props.scripts);
12981
- }
12982
13025
  /**
12983
13026
  * 替换数据元
12984
13027
  */
@@ -12997,6 +13040,15 @@ class EditorContext {
12997
13040
  }
12998
13041
  return this._document.modifyFlag === ModifyFlag.None ? 'appearance' : 'content';
12999
13042
  }
13043
+ adaptiveScale() {
13044
+ if (this.viewOptions.pageLayoutMode !== 'fit-page') {
13045
+ return this.viewOptions.scale;
13046
+ }
13047
+ const docWidth = this.viewOptions.contentWidth;
13048
+ const viewWidth = this.viewOptions.viewSettings.width;
13049
+ const availableWidth = viewWidth * 0.9;
13050
+ return Math.round(availableWidth * 100 / docWidth) / 100;
13051
+ }
13000
13052
  }
13001
13053
  /**
13002
13054
  * 文档上下文
@@ -14162,9 +14214,7 @@ class DocumentArrange {
14162
14214
  execute: this.execute,
14163
14215
  createParaFn: () => this.createDefaultPara()
14164
14216
  };
14165
- doc.clearMarkItems();
14166
- this.clearPaintCache(doc, data);
14167
- //this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
14217
+ this.reset(data);
14168
14218
  const docRenders = this.arrangeDoc();
14169
14219
  this.setMeasureCompletedModifyFlag(doc);
14170
14220
  this.cacheDocRenders(docRenders);
@@ -14172,7 +14222,17 @@ class DocumentArrange {
14172
14222
  return docRenders;
14173
14223
  });
14174
14224
  }
14175
- //commentsRender!: CommsContainerRenderObject;
14225
+ /**
14226
+ * 重置文档测量的相关信息
14227
+ * @param data
14228
+ * @private
14229
+ */
14230
+ reset(data) {
14231
+ this.docCtx.document.clearMarkItems();
14232
+ this.docCtx.trackFlag = false;
14233
+ this.docCtx.commentFlag = false;
14234
+ this.clearPaintCache(data.doc, data);
14235
+ }
14176
14236
  arrangeDoc() {
14177
14237
  const doc = this.docCtx.document;
14178
14238
  const docRender = doc.createRenderObject();
@@ -14716,8 +14776,12 @@ class DocumentArrange {
14716
14776
  }
14717
14777
  identifyComment(ele) {
14718
14778
  if (ele instanceof CommentElement) {
14779
+ this.docCtx.commentFlag = true;
14719
14780
  this.docCtx.document.identifyCommMark(ele);
14720
14781
  }
14782
+ else if (ele instanceof TrackRunElement) {
14783
+ this.docCtx.trackFlag = true;
14784
+ }
14721
14785
  }
14722
14786
  cacheDoc;
14723
14787
  cacheDocRenders(docs) {
@@ -14798,8 +14862,31 @@ class DocumentPaginator {
14798
14862
  this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
14799
14863
  const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
14800
14864
  this.docPages = newMeasure.measureDoc();
14865
+ this.adjustTipLayoutWidth();
14801
14866
  this.layoutPages();
14802
14867
  }
14868
+ /**
14869
+ * 处理计算提示框布局宽度
14870
+ * @private
14871
+ */
14872
+ adjustTipLayoutWidth() {
14873
+ let layoutFlag = false;
14874
+ if (this.docCtx.trackFlag && this.docCtx.viewOptions.showTrackChangesTip || this.docCtx.commentFlag) {
14875
+ layoutFlag = true;
14876
+ }
14877
+ if (layoutFlag) {
14878
+ if (this.viewOptions.reviewWindowWidth === 0) {
14879
+ this.viewOptions.reviewWindowWidth = 250;
14880
+ this.viewOptions.scale = this.docCtx.adaptiveScale();
14881
+ }
14882
+ }
14883
+ else {
14884
+ if (this.viewOptions.reviewWindowWidth > 0) {
14885
+ this.viewOptions.reviewWindowWidth = 0;
14886
+ this.viewOptions.scale = this.docCtx.adaptiveScale();
14887
+ }
14888
+ }
14889
+ }
14803
14890
  /**
14804
14891
  * 文档页面显示布局
14805
14892
  */
@@ -16807,7 +16894,7 @@ class DocumentChange {
16807
16894
  if (res && res.isCancel) {
16808
16895
  return;
16809
16896
  }
16810
- this.docComment.syncUpdateComments();
16897
+ //this.docComment.syncUpdateComments();
16811
16898
  if (collapsed) {
16812
16899
  this.onBackspaceElement(startControl, startOffset);
16813
16900
  }
@@ -18449,6 +18536,7 @@ class ElementTrackManage {
18449
18536
  */
18450
18537
  generateTrack() {
18451
18538
  if (!this.docCtx.viewOptions.enableTrackHistory) {
18539
+ clearTraces(this.docCtx.document);
18452
18540
  return;
18453
18541
  }
18454
18542
  const ops = generatePatch(this.docCtx.document);
@@ -20226,8 +20314,6 @@ class DocEditor {
20226
20314
  trackChangeState = true;
20227
20315
  flushToSchedule() {
20228
20316
  if (this.docCtx.refreshType === 'content') {
20229
- //触发动态脚本
20230
- this.docCtx.dynamicFunc.invokedScripts();
20231
20317
  this.triggerDocChange();
20232
20318
  }
20233
20319
  if (this.flushTask) {
@@ -20238,10 +20324,11 @@ class DocEditor {
20238
20324
  this.readDocChangeLog();
20239
20325
  this.refreshDocument();
20240
20326
  this.flushTask = null;
20241
- let cb = this.docCtx.nextViewFn;
20242
- if (cb) {
20327
+ //回调
20328
+ let cbs = [...this.docCtx.nextViewFns];
20329
+ if (cbs.length) {
20243
20330
  this.docCtx.onNextView(null);
20244
- cb();
20331
+ cbs.forEach(cb => cb());
20245
20332
  return;
20246
20333
  }
20247
20334
  this.historyMange.generateTrack();
@@ -20402,7 +20489,7 @@ class DocEditor {
20402
20489
  this.editInput.style.left = position.x + 'px';
20403
20490
  this.editInput.style.top = position.y + 'px';
20404
20491
  this.editInput.style.height = position.height + 'px';
20405
- this.editInput.style.width = "2px";
20492
+ this.editInput.style.width = "1.6px";
20406
20493
  this.editInput.readOnly = false;
20407
20494
  this.setCursorVisibility(true);
20408
20495
  //判断光标位置是否被可见,如果不可见,需要将其设置到可见区域
@@ -20585,14 +20672,7 @@ class DocEditor {
20585
20672
  * @private
20586
20673
  */
20587
20674
  adaptiveScale() {
20588
- if (this.viewOptions.pageLayoutMode !== 'fit-page') {
20589
- return;
20590
- }
20591
- const docWidth = this.docCtx.viewOptions.docPageSettings.width;
20592
- const viewWidth = this.docCtx.viewOptions.viewSettings.width;
20593
- const availableWidth = viewWidth * 0.9;
20594
- const scale = Math.round(availableWidth * 100 / docWidth) / 100;
20595
- this.viewOptions.scale = scale;
20675
+ this.viewOptions.scale = this.docCtx.adaptiveScale();
20596
20676
  }
20597
20677
  /**
20598
20678
  * 缩放视图
@@ -21191,12 +21271,20 @@ class DocEditor {
21191
21271
  },
21192
21272
  children: []
21193
21273
  };
21274
+ const scaleFitContainer = {
21275
+ sel: 'div#scale-fit-container',
21276
+ data: {
21277
+ style: { overflow: 'hidden', height: '0px', }
21278
+ },
21279
+ children: [docContent]
21280
+ };
21194
21281
  if (!this.documentPaginator?.docContainer) {
21195
- return docContent;
21282
+ return scaleFitContainer;
21196
21283
  }
21197
21284
  const tipsContainer = this.createChangeTipContainer();
21198
21285
  this.tipContainer = tipsContainer;
21199
21286
  docContent.data.style.height = this.documentPaginator.getDocumentContainerHeight().height + 'px';
21287
+ scaleFitContainer.data.style['height'] = this.documentPaginator.getDocumentContainerHeight().height * this.viewOptions.scale + 'px';
21200
21288
  const docRenders = this.documentPaginator.docContainer.getItems();
21201
21289
  const svgGenerator = new DocumentSvg(this.viewOptions, this.selectionOverlays, this.renderContext);
21202
21290
  const vNode = svgGenerator.getHTMLVNode(docRenders);
@@ -21204,12 +21292,12 @@ class DocEditor {
21204
21292
  children.push(tipsContainer);
21205
21293
  children.push(...vNode);
21206
21294
  tipsContainer.children?.push(...svgGenerator.changeTips);
21207
- this.updateTipLayoutWidth();
21295
+ //this.updateTipLayoutWidth();
21208
21296
  const sub = this.afterNodePatch.subscribe(() => {
21209
21297
  this.updateTipLayoutAfterPatch();
21210
21298
  sub.unsubscribe();
21211
21299
  });
21212
- return docContent;
21300
+ return scaleFitContainer;
21213
21301
  }
21214
21302
  };
21215
21303
  }
@@ -21223,14 +21311,14 @@ class DocEditor {
21223
21311
  if (this.viewOptions.reviewWindowWidth > 0) {
21224
21312
  this.viewOptions.reviewWindowWidth = 0;
21225
21313
  //刷新页面
21226
- this.adjustPageLayout();
21314
+ this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21227
21315
  }
21228
21316
  }
21229
21317
  else {
21230
21318
  if (this.viewOptions.reviewWindowWidth === 0) {
21231
21319
  this.viewOptions.reviewWindowWidth = 250;
21232
21320
  //刷新页面
21233
- this.adjustPageLayout();
21321
+ this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21234
21322
  }
21235
21323
  }
21236
21324
  }
@@ -21318,30 +21406,21 @@ class DocEditor {
21318
21406
  };
21319
21407
  const itemsVNode = options.map(item => {
21320
21408
  const ckbVNode = {
21321
- sel: multiSelect ? 'input.magic-checkbox' : 'input.magic-radio',
21322
- data: {
21323
- attrs: {
21324
- type: 'checkbox',
21325
- name: 'data-list',
21326
- }
21327
- }
21409
+ sel: multiSelect ? 'div.editor-list-checkbox' : 'div.editor-list-radiobox',
21410
+ data: {}
21328
21411
  };
21329
21412
  if (item.checked) {
21330
- ckbVNode.data.attrs['checked'] = true;
21413
+ ckbVNode.sel += '.checked';
21414
+ //ckbVNode.data.attrs['checked'] = true;
21331
21415
  }
21332
21416
  return {
21333
- sel: 'div', data: {}, children: [ckbVNode, {
21417
+ sel: 'div', data: { on: {
21418
+ click: () => {
21419
+ onChangeHandler(item.code);
21420
+ }
21421
+ } }, children: [ckbVNode, {
21334
21422
  sel: 'label',
21335
- data: {
21336
- attrs: {
21337
- //for:"data-list-"+item.code,
21338
- },
21339
- on: {
21340
- click: (evt) => {
21341
- onChangeHandler(item.code);
21342
- }
21343
- }
21344
- },
21423
+ data: {},
21345
21424
  text: item.value
21346
21425
  }]
21347
21426
  };
@@ -21505,7 +21584,7 @@ class DocEditor {
21505
21584
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
21506
21585
  }
21507
21586
  version() {
21508
- return "2.2.0";
21587
+ return "2.2.2";
21509
21588
  }
21510
21589
  switchPageHeaderEditor() {
21511
21590
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -21655,6 +21734,54 @@ class DocumentCombine {
21655
21734
  }
21656
21735
  }
21657
21736
 
21737
+ class DocumentEvalFunc {
21738
+ docCtx;
21739
+ constructor(docCtx) {
21740
+ this.docCtx = docCtx;
21741
+ }
21742
+ scriptsFunc;
21743
+ /**
21744
+ * 实例化动态脚本
21745
+ */
21746
+ initScripts(scripts) {
21747
+ this.destroyScripts();
21748
+ if (scripts) {
21749
+ try {
21750
+ const func = new Function("docCtx", scripts);
21751
+ this.scriptsFunc = func(this.docCtx);
21752
+ }
21753
+ catch (e) {
21754
+ console.error("自定义标本解析错误", e);
21755
+ }
21756
+ }
21757
+ // const func = (docCtx: DocumentContext) => {
21758
+ // const sexELe = docCtx.getControlById('NqoYI')
21759
+ // const dyEle = docCtx.getControlById('gTuBI');
21760
+ // return () => {
21761
+ // if (sexELe && dyEle) {
21762
+ // const sexValue = sexELe.getValue();
21763
+ // const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
21764
+ // dyEle.setValue(dyValue);
21765
+ // }
21766
+ // };
21767
+ // };
21768
+ }
21769
+ /**
21770
+ * 销毁动态脚本实例
21771
+ */
21772
+ destroyScripts() {
21773
+ if (this.scriptsFunc) {
21774
+ this.scriptsFunc = null;
21775
+ }
21776
+ }
21777
+ /**
21778
+ * 触发动态脚本
21779
+ */
21780
+ invokedScripts() {
21781
+ this.scriptsFunc?.();
21782
+ }
21783
+ }
21784
+
21658
21785
  function createPrintTemplate({ width, height, orient }) {
21659
21786
  return `
21660
21787
  <!DOCTYPE html>
@@ -27001,5 +27128,5 @@ function removeDuplicatesEvent(events) {
27001
27128
  return arr;
27002
27129
  }
27003
27130
 
27004
- 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, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
27131
+ 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 };
27005
27132
  //# sourceMappingURL=index.js.map