@hailin-zheng/editor-core 2.2.10 → 2.2.12

Sign up to get free protection for your applications and to get access to all the features.
package/index-cjs.js CHANGED
@@ -1539,7 +1539,7 @@ class BranchElement extends Element {
1539
1539
  }
1540
1540
  treeFilter(predicate, options) {
1541
1541
  if (!options) {
1542
- options = { includeChildren: true };
1542
+ options = { includeChildren: false };
1543
1543
  }
1544
1544
  const items = [];
1545
1545
  for (let i = 0; i < this.length; i++) {
@@ -1552,7 +1552,7 @@ class BranchElement extends Element {
1552
1552
  }
1553
1553
  }
1554
1554
  if (item instanceof BranchElement) {
1555
- items.push(...item.treeFilter(predicate));
1555
+ items.push(...item.treeFilter(predicate, options));
1556
1556
  }
1557
1557
  }
1558
1558
  return items;
@@ -1737,6 +1737,8 @@ class ViewOptions {
1737
1737
  dataDecoratorNormalColor = '#0050b3';
1738
1738
  dataDecoratorMouseEnterColor = '#0050b3';
1739
1739
  dataDecoratorFocusedColor = '#0050b3';
1740
+ //是否显示数据元修饰符
1741
+ showDataEleDecorator = true;
1740
1742
  //数据元没有输入值时背景颜色
1741
1743
  dataEleEmptyBgColor = '';
1742
1744
  //数据元鼠标悬浮颜色
@@ -1747,7 +1749,14 @@ class ViewOptions {
1747
1749
  dataEleFocusedBgColor = '#d9d9d9';
1748
1750
  //数据元正常背景颜色
1749
1751
  dataEleNormalBgColor = '#fafafa';
1752
+ //数据元错误背景颜色
1750
1753
  dataEleErrorBgColor = '#ff4d4f';
1754
+ //数据元正常背景颜色
1755
+ dataGroupEleNormalBgColor = '';
1756
+ //数据元鼠标悬浮颜色
1757
+ dataGroupMouseEnterBgColor = '';
1758
+ //数据元只读背景颜色
1759
+ dataGroupFocusedBgColor = '';
1751
1760
  viewBackcolor = 'rgb(230,230,230)';
1752
1761
  paraSymbolColor = 'rgb(128,128,128)';
1753
1762
  dataGroupColor = 'rgb(0,80,179)';
@@ -8807,6 +8816,9 @@ function IsInSideDataGroup(control, offset) {
8807
8816
  return true;
8808
8817
  }
8809
8818
  return false;
8819
+ }
8820
+ function validateDataGroup(control) {
8821
+ return control instanceof DataElementGroupElement;
8810
8822
  }
8811
8823
 
8812
8824
  class DataElementImage extends DataElementLeaf {
@@ -13403,17 +13415,20 @@ class DocumentContext {
13403
13415
  this.ss = ss;
13404
13416
  }
13405
13417
  getControlIDList() {
13406
- const dataEleList = this.ctx.treeFilter(item => validateDataEle(item));
13418
+ const dataEleList = this.ctx.treeFilter(item => this.isDataEle(item));
13407
13419
  return dataEleList.map(item => item.props.id);
13408
13420
  }
13409
13421
  getControlInstanceList(options) {
13410
- return this.ctx.treeFilter(item => validateDataEle(item), options);
13422
+ return this.ctx.treeFilter(item => this.isDataEle(item), options);
13411
13423
  }
13412
13424
  getControlById(id) {
13413
- return this.ctx.treeFind(item => validateDataEle(item) && item['props']['id'] === id);
13425
+ return this.ctx.treeFind(item => this.isDataEle(item) && item['props']['id'] === id);
13426
+ }
13427
+ isDataEle(ele) {
13428
+ return validateDataEle(ele) || ele instanceof DataElementGroupElement;
13414
13429
  }
13415
13430
  getControlByName(name) {
13416
- return this.ctx.treeFind(item => validateDataEle(item) && item['props']['name'] === name);
13431
+ return this.ctx.treeFind(item => this.isDataEle(item) && item['props']['name'] === name);
13417
13432
  }
13418
13433
  /**
13419
13434
  * 获取数据元值集合
@@ -13431,7 +13446,7 @@ class DocumentContext {
13431
13446
  * @returns
13432
13447
  */
13433
13448
  getDataElementModelList(options) {
13434
- const dataEleList = this.ctx.treeFilter(item => validateDataEle(item), options);
13449
+ const dataEleList = this.ctx.treeFilter(item => this.isDataEle(item), options);
13435
13450
  //数据元、数据组
13436
13451
  const dataInlineGroups = dataEleList.filter(item => item instanceof DataElementInlineGroup);
13437
13452
  const dataLeafs = dataEleList.filter(item => item instanceof DataElementLeaf);
@@ -15505,12 +15520,12 @@ class DocumentEvent {
15505
15520
  },
15506
15521
  mouseup: (evt) => {
15507
15522
  this.mouseup(evt, ElementUtil.getMousePos(evt, scale));
15508
- this.mouseClickHandle(evt);
15523
+ //this.mouseClickHandle(evt);
15509
15524
  },
15510
15525
  click: (evt) => {
15511
15526
  //nulltext 不触发 click 事件,暂且这么处理
15512
15527
  //移到 mouseup 事件中处理
15513
- //this.mouseClickHandle(evt);
15528
+ this.mouseClickHandle(evt);
15514
15529
  },
15515
15530
  mousemove: (evt) => {
15516
15531
  this.mousemove(evt, ElementUtil.getMousePos(evt, scale));
@@ -16737,6 +16752,30 @@ class DocumentEvent {
16737
16752
  }
16738
16753
  return null;
16739
16754
  }
16755
+ /**
16756
+ * 获取当前光标所在的数据组
16757
+ * @returns
16758
+ */
16759
+ getCurrentDataGroupElement(mode = 'strict') {
16760
+ const selectionState = this.selectionState;
16761
+ const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
16762
+ if (startControl && collapsed) {
16763
+ // if (!ElementUtil.verifyHitable(startControl)) {
16764
+ // return null;
16765
+ // }
16766
+ const dataEle = ElementUtil.getParent(startControl, validateDataGroup);
16767
+ if (mode === 'free' || IsInSideDataGroup(startControl, startOffset)) {
16768
+ return dataEle;
16769
+ }
16770
+ else {
16771
+ return null;
16772
+ }
16773
+ }
16774
+ else if (!collapsed && ancestorCommonControl) {
16775
+ return ElementUtil.getParent(ancestorCommonControl, validateDataGroup);
16776
+ }
16777
+ return null;
16778
+ }
16740
16779
  }
16741
16780
 
16742
16781
  /**
@@ -17885,6 +17924,14 @@ class DocumentChange {
17885
17924
  }
17886
17925
  return;
17887
17926
  }
17927
+ const dataGroup = ElementUtil.getDataGroupElement(range.target);
17928
+ if (dataGroup) {
17929
+ this.deleteRange(range);
17930
+ if (!startPointElement || ElementUtil.getParent(startPointElement, item => validateDataGroup(item)) !== dataGroup) {
17931
+ this.selectionState.resetRange(dataGroup.startDecorate, 1);
17932
+ }
17933
+ return;
17934
+ }
17888
17935
  //在数据元外删除
17889
17936
  else {
17890
17937
  this.loopForDelDataEleRange(range);
@@ -19764,9 +19811,11 @@ class EditorCalendarVNode {
19764
19811
  onSave() {
19765
19812
  if (!this.selectedDate.value) {
19766
19813
  this.onSetValue.next(new Date());
19814
+ this.reset();
19767
19815
  }
19768
19816
  else {
19769
19817
  this.onSetValue.next(moment__default["default"](this.selectedDate.value + ' ' + this.selectedTime.value).toDate());
19818
+ this.reset();
19770
19819
  }
19771
19820
  }
19772
19821
  navigateToToday() {
@@ -20718,12 +20767,12 @@ class DocEditor {
20718
20767
  //是否用于跟踪修改状态,在初始化、数据元赋值等情况不需要跟踪修改标志
20719
20768
  trackChangeState = true;
20720
20769
  flushToSchedule() {
20721
- if (this.docCtx.refreshType === 'content') {
20722
- this.triggerDocChange();
20723
- }
20724
20770
  if (this.flushTask) {
20725
20771
  return null;
20726
20772
  }
20773
+ // if (this.docCtx.refreshType) {
20774
+ // this.triggerDocChange();
20775
+ // }
20727
20776
  this.flushTask = () => {
20728
20777
  //读取变更记录,可能会同步影响文档内容
20729
20778
  this.readDocChangeLog();
@@ -20987,12 +21036,19 @@ class DocEditor {
20987
21036
  this.onDblClickEvent.next(evt);
20988
21037
  }
20989
21038
  /**
20990
- * 获取当前光标所在的数据元或者数据组
21039
+ * 获取当前光标所在的数据元
20991
21040
  * @returns
20992
21041
  */
20993
21042
  getCurrentDataElement() {
20994
21043
  return this.documentEvent.getCurrentDataElement();
20995
21044
  }
21045
+ /**
21046
+ * 回去当前光标所在数据组
21047
+ * @returns
21048
+ */
21049
+ getCurrentDataGroupElement() {
21050
+ return this.documentEvent.getCurrentDataGroupElement();
21051
+ }
20996
21052
  /**
20997
21053
  * 移动光标到下一个数据元素上
20998
21054
  */
@@ -22026,7 +22082,7 @@ class DocEditor {
22026
22082
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
22027
22083
  }
22028
22084
  version() {
22029
- return "2.2.10";
22085
+ return "2.2.12";
22030
22086
  }
22031
22087
  switchPageHeaderEditor() {
22032
22088
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -22143,6 +22199,9 @@ class DocEditor {
22143
22199
  else {
22144
22200
  this.docCtx.suggestions.clear();
22145
22201
  }
22202
+ if (ops.length) {
22203
+ this.triggerDocChange();
22204
+ }
22146
22205
  }
22147
22206
  /**
22148
22207
  * 处理候选词
@@ -28008,6 +28067,7 @@ exports.toTypeString = toTypeString;
28008
28067
  exports.trueChar = trueChar;
28009
28068
  exports.validateDataEle = validateDataEle;
28010
28069
  exports.validateDataEleRenderObj = validateDataEleRenderObj;
28070
+ exports.validateDataGroup = validateDataGroup;
28011
28071
  exports.validateInlineInputRenderObj = validateInlineInputRenderObj;
28012
28072
  exports.watchChanged = watchChanged;
28013
28073
  //# sourceMappingURL=index-cjs.js.map