@hailin-zheng/editor-core 2.2.9 → 2.2.10

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/index-cjs.js CHANGED
@@ -8701,7 +8701,7 @@ class BreakFactory extends ElementFactory {
8701
8701
  }
8702
8702
  }
8703
8703
 
8704
- class DataElementGroupElement extends DataElementInlineGroup {
8704
+ class DataElementGroupElement extends InlineGroupInputElement {
8705
8705
  constructor() {
8706
8706
  super('data-group');
8707
8707
  this.props = new DataElementGroupProps();
@@ -8741,7 +8741,6 @@ class DataElementGroupElement extends DataElementInlineGroup {
8741
8741
  });
8742
8742
  }
8743
8743
  }
8744
- this.onChangedValidate();
8745
8744
  }
8746
8745
  getValue() {
8747
8746
  return ElementSerialize.serializeString(this, { all: false });
@@ -8793,6 +8792,21 @@ class DataElementGroupFactory extends DataElementBaseFactory {
8793
8792
  dataEleProps.dataType = props.dataType;
8794
8793
  return dataEleProps;
8795
8794
  }
8795
+ }
8796
+ /**
8797
+ * 是否在数据组内部
8798
+ * @param control
8799
+ * @param offset
8800
+ */
8801
+ function IsInSideDataGroup(control, offset) {
8802
+ const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementGroupElement);
8803
+ if (mathEle) {
8804
+ if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
8805
+ return false;
8806
+ }
8807
+ return true;
8808
+ }
8809
+ return false;
8796
8810
  }
8797
8811
 
8798
8812
  class DataElementImage extends DataElementLeaf {
@@ -12525,6 +12539,14 @@ class ElementUtil {
12525
12539
  static getDataElement(ele) {
12526
12540
  return this.getParent(ele, item => item instanceof DataElementInlineGroup);
12527
12541
  }
12542
+ /**
12543
+ * 向上查找类型为数据元的父级
12544
+ * @param ele
12545
+ * @returns
12546
+ */
12547
+ static getDataGroupElement(ele) {
12548
+ return this.getParent(ele, item => item instanceof DataElementGroupElement);
12549
+ }
12528
12550
  static getOSPlatform() {
12529
12551
  const userAgent = navigator.userAgent;
12530
12552
  if (userAgent.indexOf('Windows') > -1) {
@@ -12673,23 +12695,35 @@ class ElementUtil {
12673
12695
  if (startControl.paintRenders.length === 0) {
12674
12696
  return false;
12675
12697
  }
12698
+ if (!ElementUtil.verifyHitable(startControl)) {
12699
+ return false;
12700
+ }
12676
12701
  if (viewOptions.docMode === exports.DocMode.Design) {
12677
12702
  return true;
12678
12703
  }
12679
- //表单模式下,如果不在数据元素中,则不显示光标
12704
+ //表单模式下
12680
12705
  if (viewOptions.docMode === exports.DocMode.FormEdit) {
12681
- if (!IsInSideDataElement(startControl, startOffset)) {
12682
- return false;
12706
+ //如果光标在数据元素中,判断是否可编辑
12707
+ if (IsInSideDataElement(startControl, startOffset)) {
12708
+ const dataEle = ElementUtil.getDataElement(startControl);
12709
+ //数据元不可编辑
12710
+ if (dataEle && !dataEle.props.editable) {
12711
+ return false;
12712
+ }
12713
+ return true;
12683
12714
  }
12684
- }
12685
- if (!ElementUtil.verifyHitable(startControl)) {
12686
- return false;
12687
- }
12688
- //表单模式下,数据元不可编辑
12689
- if (viewOptions.docMode === exports.DocMode.FormEdit && IsInSideDataElement(startControl, startOffset)) {
12690
- const dataEle = ElementUtil.getDataElement(startControl);
12691
- if (dataEle && !dataEle.props.editable) {
12692
- return false;
12715
+ else {
12716
+ //不在数据元中,需要判断是否在数据组中
12717
+ if (IsInSideDataGroup(startControl, startOffset)) {
12718
+ const dataGroup = ElementUtil.getDataGroupElement(startControl);
12719
+ //数据元不可编辑
12720
+ if (dataGroup && !dataGroup.props.editable) {
12721
+ return false;
12722
+ }
12723
+ }
12724
+ else {
12725
+ return false;
12726
+ }
12693
12727
  }
12694
12728
  }
12695
12729
  return true;
@@ -17531,8 +17565,12 @@ class DocumentChange {
17531
17565
  * @private
17532
17566
  */
17533
17567
  canDeleteInlineGroup(dataEle) {
17568
+ //当前编辑模式为表单模式,单独的数据元不可删除
17569
+ //存在于数据组内的数据元可以删除
17534
17570
  if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
17535
- return false;
17571
+ if (dataEle.parent.type !== 'data-group') {
17572
+ return false;
17573
+ }
17536
17574
  }
17537
17575
  return dataEle.length === 2;
17538
17576
  }
@@ -18462,9 +18500,13 @@ class DocumentChange {
18462
18500
  }
18463
18501
  getCursorElementByDeleteAction(control) {
18464
18502
  if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
18465
- if (control.parent instanceof DataElementInlineGroup) {
18503
+ //是否属于数据元或者数据组区域
18504
+ const isInDataAre = (ele) => {
18505
+ return ele.parent instanceof DataElementInlineGroup || ele.parent instanceof DataElementGroupElement;
18506
+ };
18507
+ if (isInDataAre(control)) {
18466
18508
  const prevLeafElementInPara = ElementUtil.getRecursionPrevSiblingElement(control, true, true, this.viewOptions);
18467
- if (prevLeafElementInPara && ElementUtil.getParent(prevLeafElementInPara, item => item instanceof DataElementInlineGroup)) {
18509
+ if (prevLeafElementInPara && isInDataAre(prevLeafElementInPara)) {
18468
18510
  return {
18469
18511
  ele: prevLeafElementInPara,
18470
18512
  offset: ElementUtil.getElementEndOffset(prevLeafElementInPara)
@@ -18472,7 +18514,7 @@ class DocumentChange {
18472
18514
  }
18473
18515
  else {
18474
18516
  return {
18475
- ele: control.parent.startDecorate,
18517
+ ele: (control.parent).startDecorate,
18476
18518
  offset: 1
18477
18519
  };
18478
18520
  }
@@ -20945,7 +20987,7 @@ class DocEditor {
20945
20987
  this.onDblClickEvent.next(evt);
20946
20988
  }
20947
20989
  /**
20948
- * 获取当前光标所在的数据元
20990
+ * 获取当前光标所在的数据元或者数据组
20949
20991
  * @returns
20950
20992
  */
20951
20993
  getCurrentDataElement() {
@@ -21984,7 +22026,7 @@ class DocEditor {
21984
22026
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
21985
22027
  }
21986
22028
  version() {
21987
- return "2.2.9";
22029
+ return "2.2.10";
21988
22030
  }
21989
22031
  switchPageHeaderEditor() {
21990
22032
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -27839,6 +27881,7 @@ exports.InlineGroupRenderObject = InlineGroupRenderObject;
27839
27881
  exports.InlineMuiltBlockLineRenderObject = InlineMuiltBlockLineRenderObject;
27840
27882
  exports.InputElementEvent = InputElementEvent;
27841
27883
  exports.IsInSideDataElement = IsInSideDataElement;
27884
+ exports.IsInSideDataGroup = IsInSideDataGroup;
27842
27885
  exports.IsInSideInlineGroupInputElement = IsInSideInlineGroupInputElement;
27843
27886
  exports.KeyboradElementEvent = KeyboradElementEvent;
27844
27887
  exports.LeafElement = LeafElement;