@hailin-zheng/editor-core 2.2.6 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/editor.css CHANGED
@@ -17,7 +17,7 @@
17
17
  }
18
18
 
19
19
  .data-list > div {
20
- padding: 10px 6px;
20
+ padding: 6px 4px;
21
21
  display: flex;
22
22
  align-items: center;
23
23
  gap: 10px;
package/index-cjs.js CHANGED
@@ -1746,7 +1746,7 @@ class ViewOptions {
1746
1746
  showCharRect;
1747
1747
  //数据元交互修饰模式
1748
1748
  dataEleDecoratorMode = 'outline';
1749
- dataEleDecoratorColor = '#0050b3';
1749
+ dataEleDecoratorColor = '#ddd';
1750
1750
  showTabChar;
1751
1751
  showSpaceChar;
1752
1752
  showLineBreak;
@@ -2528,6 +2528,10 @@ class DataEleListProps extends DataEleBaseTextProps {
2528
2528
  super();
2529
2529
  }
2530
2530
  options = [];
2531
+ /**
2532
+ * 是否保存选项到病历文件里面
2533
+ */
2534
+ saveOptions = true;
2531
2535
  dropDownStyle;
2532
2536
  /**
2533
2537
  * 是否允许多选
@@ -2858,28 +2862,14 @@ class ValidateProps {
2858
2862
  return clone;
2859
2863
  }
2860
2864
  }
2861
- class DataElementGroupProps extends INotifyPropertyChanged {
2862
- id;
2863
- name;
2864
- hidden;
2865
+ class DataElementGroupProps extends DataEleBaseProps {
2865
2866
  clone(dest) {
2866
- dest = dest ?? new DataElementGroupProps();
2867
- dest.id = this.id;
2868
- dest.name = this.name;
2869
- dest.hidden = this.hidden;
2867
+ const clone = dest ?? new DataElementGroupProps();
2868
+ super.cloneBaseProps(clone);
2870
2869
  }
2871
- getSerializeProps() {
2870
+ getSerializeProps(options) {
2872
2871
  const props = {};
2873
- if (this.id) {
2874
- props.id = this.id;
2875
- }
2876
- if (this.name) {
2877
- props.name = this.name;
2878
- }
2879
- if (this.hidden) {
2880
- props.hidden = this.hidden;
2881
- }
2882
- return props;
2872
+ return this.getBaseProps(props, options);
2883
2873
  }
2884
2874
  }
2885
2875
  class DataElementBarcodeProps {
@@ -2962,6 +2952,9 @@ class DataDecorateRenderObject extends LeafRenderObject {
2962
2952
  if (event.mode === 'print') {
2963
2953
  return null;
2964
2954
  }
2955
+ // if(this.element.parent.parent.type==='data-group'){
2956
+ // return null;
2957
+ // }
2965
2958
  const element = this.element;
2966
2959
  const lineWidth = 3;
2967
2960
  let path = '';
@@ -3962,19 +3955,83 @@ class DataElementInlineGroup extends InlineGroupInputElement {
3962
3955
  expressFn;
3963
3956
  beginMeasure(data) {
3964
3957
  super.beginMeasure(data);
3965
- if (!this.props.expression || !data.viewOptions.enableDyExpression) {
3958
+ // if (!this.props.expression || !data.options.enableDyExpression) {
3959
+ // return;
3960
+ // }
3961
+ // try {
3962
+ // if (!this.expressFn) {
3963
+ // const code = parser(this.props.expression);
3964
+ // this.expressFn = new Function(`with(this){ ${code} }`);
3965
+ // }
3966
+ // this.expressFn.bind(data.execute)();
3967
+ // //this.expressFn();
3968
+ // } catch (e) {
3969
+ // this.expressFn = new Function();
3970
+ // }
3971
+ }
3972
+ parserExpress;
3973
+ /**
3974
+ * 解析可见性表达式
3975
+ * @param ele
3976
+ * @param execute
3977
+ * @private
3978
+ */
3979
+ parseEleExpression(data) {
3980
+ const execute = data.execute;
3981
+ //不存在表达式,或者不启用表达式,不做处理
3982
+ if (!this.props.expression || !data.options.enableDyExpression)
3966
3983
  return;
3967
- }
3984
+ //存在表达式,并且已经解析过,不再做处理
3985
+ if (this.parserExpress)
3986
+ return;
3987
+ const reactiveMode = data.renderCtx.drawMode !== 'print';
3968
3988
  try {
3969
- if (!this.expressFn) {
3970
- const code = parser(this.props.expression);
3971
- this.expressFn = new Function(`with(this){ ${code} }`);
3989
+ const depIdItems = [];
3990
+ const depEleMap = new Map();
3991
+ let compliedCode = parser(this.props.expression, depIdItems);
3992
+ compliedCode = addReturn(compliedCode);
3993
+ if (depIdItems.length) {
3994
+ depIdItems.forEach(dep => {
3995
+ const refCtx = execute.getObject(dep);
3996
+ if (refCtx.ref) {
3997
+ const refEle = refCtx.ref.item;
3998
+ depEleMap.set(dep, refCtx);
3999
+ //当前有可能是checkbox数组
4000
+ const refEles = Array.isArray(refEle) ? refEle : [refEle];
4001
+ reactiveMode && refEles.forEach(item => {
4002
+ //求值依赖元素更改的时候,发布当前元素重新计算的指令
4003
+ item.onChangeSubject.subscribe(() => {
4004
+ this.pubOnChange('self');
4005
+ });
4006
+ });
4007
+ }
4008
+ });
3972
4009
  }
3973
- this.expressFn.bind(data.execute)();
3974
- //this.expressFn();
4010
+ this.parserExpress = { compliedCode, func: new Function(`with(this){ ${compliedCode} }`), depItems: depEleMap };
3975
4011
  }
3976
4012
  catch (e) {
3977
- this.expressFn = new Function();
4013
+ console.error('解析表达式出错,parseEleExpression', this.props.expression);
4014
+ }
4015
+ }
4016
+ /**
4017
+ * 元素可见行求值
4018
+ * @param ele
4019
+ * @param executeCtx
4020
+ * @private
4021
+ */
4022
+ evalEleExpr(executeCtx) {
4023
+ if (this.parserExpress && this.parserExpress.func) {
4024
+ try {
4025
+ executeCtx.setCurrentCtx(this, this.parserExpress.depItems);
4026
+ const func = this.parserExpress.func.bind(executeCtx);
4027
+ func();
4028
+ }
4029
+ catch (e) {
4030
+ console.error(e, "表达式执行出错:evalVisibleExpr", this.parserExpress.compliedCode);
4031
+ }
4032
+ finally {
4033
+ executeCtx.clearCurrentCtx();
4034
+ }
3978
4035
  }
3979
4036
  }
3980
4037
  /**
@@ -8609,7 +8666,7 @@ class DataElementGroupElement extends InlineGroupInputElement {
8609
8666
  return {
8610
8667
  type: this.type,
8611
8668
  props: {
8612
- ...this.props.getSerializeProps()
8669
+ ...this.props.getSerializeProps(viewOptions)
8613
8670
  }
8614
8671
  };
8615
8672
  }
@@ -8631,9 +8688,7 @@ class DataElementGroupFactory extends DataElementBaseFactory {
8631
8688
  createElement(data) {
8632
8689
  const props = data.props;
8633
8690
  const ele = new DataElementGroupElement();
8634
- ele.props.id = props.id;
8635
- ele.props.name = props.name;
8636
- ele.props.hidden = Boolean(props.hidden);
8691
+ ElementUtil.readEleBaseProps(ele.props, props);
8637
8692
  return ele;
8638
8693
  }
8639
8694
  }
@@ -8938,7 +8993,11 @@ class DataElementText extends DataElementInlineGroup {
8938
8993
  super('data-ele-text');
8939
8994
  this.props = new DataEleBaseTextProps();
8940
8995
  }
8941
- createRenderObject() {
8996
+ createRenderObject(data) {
8997
+ if (data.options.enableDyExpression) {
8998
+ this.parseEleExpression(data);
8999
+ this.evalEleExpr(data.execute);
9000
+ }
8942
9001
  return new DataElementTextRenderObject(this);
8943
9002
  }
8944
9003
  serialize(viewOptions) {
@@ -13896,7 +13955,7 @@ class ParagraphMeasure {
13896
13955
  }
13897
13956
  }
13898
13957
  arrangeInlineGroupElement(parentLine, ele) {
13899
- const { options, renderCtx } = this;
13958
+ const { options, renderCtx, execute } = this;
13900
13959
  let render = this.createRenderObject(ele);
13901
13960
  //记录多行情况下的渲染对象,用于计算总长度,生成fill-null-space
13902
13961
  const inlineGroupRenders = [];
@@ -13932,7 +13991,7 @@ class ParagraphMeasure {
13932
13991
  isCloseToBody: parentLine.isCloseToBody,
13933
13992
  applyNewLine() {
13934
13993
  parentLine.applyNewLine();
13935
- render = ele.createRenderObject({ options, renderCtx });
13994
+ render = ele.createRenderObject({ options, renderCtx, execute });
13936
13995
  parentLine.add(render);
13937
13996
  inlineGroupRenders.push(render);
13938
13997
  },
@@ -14267,7 +14326,8 @@ class ParagraphMeasure {
14267
14326
  }
14268
14327
  return element.createRenderObject({
14269
14328
  options: this.options,
14270
- renderCtx: this.renderCtx
14329
+ renderCtx: this.renderCtx,
14330
+ execute: this.execute
14271
14331
  });
14272
14332
  }
14273
14333
  }
@@ -14426,8 +14486,9 @@ class DocumentArrange {
14426
14486
  this.pMeasure = new ParagraphMeasure(this.options, this.renderCtx, this.execute);
14427
14487
  const data = {
14428
14488
  doc,
14429
- viewOptions: this.options,
14489
+ options: this.options,
14430
14490
  execute: this.execute,
14491
+ renderCtx: this.renderCtx,
14431
14492
  createParaFn: () => this.createDefaultPara()
14432
14493
  };
14433
14494
  this.reset(data);
@@ -14630,7 +14691,7 @@ class DocumentArrange {
14630
14691
  if (this.options.textRowLineMode && ele instanceof TableElement && ele.cacheRender) {
14631
14692
  const cacheRender = ele.cacheRender;
14632
14693
  clearChildrenRenderCache(ele);
14633
- textLineRenderMode(cacheRender, { options: this.options, renderCtx: this.renderCtx });
14694
+ textLineRenderMode(cacheRender, { options: this.options, renderCtx: this.renderCtx, execute: this.execute });
14634
14695
  }
14635
14696
  }
14636
14697
  getDocInnerRect(documentRender) {
@@ -19448,7 +19509,7 @@ class EditorCalendarVNode {
19448
19509
  data: {
19449
19510
  style: {
19450
19511
  position: 'absolute',
19451
- left: (position.x - 10) + 'px',
19512
+ left: (position.x) + 'px',
19452
19513
  top: position.y + 5 + position.height + 'px',
19453
19514
  'min-width': '100px',
19454
19515
  'background-color': 'white',
@@ -19584,6 +19645,9 @@ class EditorCalendarVNode {
19584
19645
  on: {
19585
19646
  click: () => {
19586
19647
  this.onClickDayItem(day.date);
19648
+ },
19649
+ dblclick: () => {
19650
+ this.onSave();
19587
19651
  }
19588
19652
  }
19589
19653
  },
@@ -19641,12 +19705,7 @@ class EditorCalendarVNode {
19641
19705
  data: {
19642
19706
  on: {
19643
19707
  click: () => {
19644
- if (!this.selectedDate.value) {
19645
- this.onSetValue.next(new Date());
19646
- }
19647
- else {
19648
- this.onSetValue.next(moment__default["default"](this.selectedDate.value + ' ' + this.selectedTime.value).toDate());
19649
- }
19708
+ this.onSave();
19650
19709
  }
19651
19710
  }
19652
19711
  },
@@ -19666,6 +19725,14 @@ class EditorCalendarVNode {
19666
19725
  ]
19667
19726
  };
19668
19727
  }
19728
+ onSave() {
19729
+ if (!this.selectedDate.value) {
19730
+ this.onSetValue.next(new Date());
19731
+ }
19732
+ else {
19733
+ this.onSetValue.next(moment__default["default"](this.selectedDate.value + ' ' + this.selectedTime.value).toDate());
19734
+ }
19735
+ }
19669
19736
  navigateToToday() {
19670
19737
  this.currYear.value = new Date().getFullYear();
19671
19738
  this.currMonth.value = new Date().getMonth();
@@ -20378,7 +20445,6 @@ class DocEditor {
20378
20445
  beforeRenderSubject = new Subject();
20379
20446
  afterRenderSubject = new Subject();
20380
20447
  onBeforeSetCursorSubject = new Subject();
20381
- contentChanged = new Subject();
20382
20448
  onPatchVNodeSubject = new Subject();
20383
20449
  selectionState;
20384
20450
  onDblClickEvent = new Subject();
@@ -20670,10 +20736,12 @@ class DocEditor {
20670
20736
  }
20671
20737
  loadDoc(data) {
20672
20738
  suppressTracking(() => {
20673
- this.adjustPageLayout();
20674
- this.elementReader.read(data);
20675
- this.refreshDocument();
20676
- this.historyMange.clear();
20739
+ this.noEffectChange(() => {
20740
+ this.adjustPageLayout();
20741
+ this.elementReader.read(data);
20742
+ this.refreshDocument();
20743
+ this.historyMange.clear();
20744
+ });
20677
20745
  });
20678
20746
  }
20679
20747
  /**
@@ -20691,7 +20759,6 @@ class DocEditor {
20691
20759
  suppressTracking(() => {
20692
20760
  this.documentPaginator.rePages();
20693
20761
  });
20694
- this.contentChanged.next();
20695
20762
  }
20696
20763
  this.updateSelection();
20697
20764
  this.setCursor();
@@ -21594,7 +21661,7 @@ class DocEditor {
21594
21661
  const scaleFitContainer = {
21595
21662
  sel: 'div#scale-fit-container',
21596
21663
  data: {
21597
- style: { overflow: 'hidden', height: '0px', }
21664
+ style: { height: '0px', }
21598
21665
  },
21599
21666
  children: [docContent]
21600
21667
  };
@@ -21756,7 +21823,7 @@ class DocEditor {
21756
21823
  data: {
21757
21824
  style: {
21758
21825
  position: 'absolute',
21759
- left: (position.x - 10) + 'px',
21826
+ left: (position.x) + 'px',
21760
21827
  top: position.y + 5 + position.height + 'px',
21761
21828
  },
21762
21829
  hook: {
@@ -21922,7 +21989,7 @@ class DocEditor {
21922
21989
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
21923
21990
  }
21924
21991
  version() {
21925
- return "2.2.6";
21992
+ return "2.2.7";
21926
21993
  }
21927
21994
  switchPageHeaderEditor() {
21928
21995
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -22225,6 +22292,13 @@ class DocEditor {
22225
22292
  this.documentChange.appendText(text, this.docCtx.suggestions.currentMatchedText);
22226
22293
  }
22227
22294
  }
22295
+ parser(code, returnProcess = false) {
22296
+ const res = parser(code);
22297
+ if (returnProcess) {
22298
+ return addReturn(res);
22299
+ }
22300
+ return res;
22301
+ }
22228
22302
  }
22229
22303
 
22230
22304
  /**