@hailin-zheng/editor-core 1.1.31 → 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,15 +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
- array.push(log);
684
689
  }
685
690
  function inputText(ele, startIndex, input) {
686
691
  const options = getDocCtx(ele);
@@ -789,6 +794,13 @@ function generatePatch(doc) {
789
794
  }
790
795
  formatOpsMap.set(ele, op);
791
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
+ }
792
804
  patchs.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
793
805
  }
794
806
  //清空