@hailin-zheng/editor-core 1.1.30 → 1.1.32

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.js CHANGED
@@ -652,7 +652,9 @@ function insertEle(ele) {
652
652
  // return;
653
653
  // }
654
654
  appendToOps(options.doc, ele, {
655
- insert: ele.clone(true)
655
+ //如果当前插入的为单元格,由于新插入的单元格,内部的内容没有补足,导致后续计算索引会出现问题
656
+ //之前为ele.clone(true);
657
+ insert: ele
656
658
  });
657
659
  }
658
660
  function removeEle(ele) {
@@ -672,19 +674,18 @@ function appendToOps(doc, ele, ops) {
672
674
  if (!array) {
673
675
  docOpsMap.set(doc, array = []);
674
676
  }
677
+ const log = getOpsLog(ele, ops);
678
+ array.push(log);
679
+ }
680
+ function getOpsLog(ele, ops) {
675
681
  const prevEle = ElementUtil.getPrevSiblingElement(ele);
676
- const log = {
682
+ return {
677
683
  index: ElementUtil.getControlIndex(ele, true),
678
684
  parentIndex: ElementUtil.getControlIndex(ele.parent, true),
679
685
  prevIndex: prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1,
680
686
  ele,
681
687
  ops
682
688
  };
683
- if (log.prevIndex === -1) {
684
- const nextEle = ElementUtil.getNextSiblingElement(ele);
685
- log.nextIndex = nextEle ? ElementUtil.getControlIndex(nextEle, true) : -1;
686
- }
687
- array.push(log);
688
689
  }
689
690
  function inputText(ele, startIndex, input) {
690
691
  const options = getDocCtx(ele);
@@ -774,14 +775,15 @@ function generatePatch(doc) {
774
775
  if (!ops || !ops.length) {
775
776
  return [];
776
777
  }
777
- const delOpsMap = getDeleteEleOps(ops);
778
+ getDeleteEleOps(ops);
778
779
  for (let i = 0; i < ops.length; i++) {
779
780
  const op = ops[i];
780
781
  const ele = op.ele;
781
782
  //修改样式
782
783
  if ('format' in op.ops) {
783
784
  //修改插入或者删除的不做处理
784
- if (insertOpsMap.has(ele) || delOpsMap.has(ele)) {
785
+ //|| delOpsMap.has(ele)
786
+ if (insertOpsMap.has(ele)) {
785
787
  continue;
786
788
  }
787
789
  //合并操作属性
@@ -792,6 +794,13 @@ function generatePatch(doc) {
792
794
  }
793
795
  formatOpsMap.set(ele, op);
794
796
  }
797
+ if ('insert' in op.ops) {
798
+ op.ops.insert = ele.clone(true);
799
+ const log = getOpsLog(ele, op.ops);
800
+ op.index = log.index;
801
+ op.prevIndex = log.prevIndex;
802
+ op.parentIndex = log.parentIndex;
803
+ }
795
804
  patchs.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
796
805
  }
797
806
  //清空
@@ -5118,8 +5127,8 @@ class TableUtil {
5118
5127
  const hMergeEndIndex = this.getHMergeEndIndex(tb, i, colIndex);
5119
5128
  //当前单元格处于合并行的最后一行,并且合并的行数为2行
5120
5129
  if (hMergeEndIndex === colIndex && hMergeEndIndex - hMergeStartIndex === 1) {
5121
- const masterVMergeCell = tb.getChild(hMergeStartIndex).getChild(i);
5122
- masterVMergeCell.props.hMerge = null;
5130
+ const masterHMergeCell = tb.getChild(i).getChild(hMergeStartIndex);
5131
+ masterHMergeCell.props.hMerge = null;
5123
5132
  }
5124
5133
  }
5125
5134
  row.removeChild(cell);