@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-cjs.js CHANGED
@@ -681,7 +681,9 @@ function insertEle(ele) {
681
681
  // return;
682
682
  // }
683
683
  appendToOps(options.doc, ele, {
684
- insert: ele.clone(true)
684
+ //如果当前插入的为单元格,由于新插入的单元格,内部的内容没有补足,导致后续计算索引会出现问题
685
+ //之前为ele.clone(true);
686
+ insert: ele
685
687
  });
686
688
  }
687
689
  function removeEle(ele) {
@@ -701,15 +703,18 @@ function appendToOps(doc, ele, ops) {
701
703
  if (!array) {
702
704
  docOpsMap.set(doc, array = []);
703
705
  }
706
+ const log = getOpsLog(ele, ops);
707
+ array.push(log);
708
+ }
709
+ function getOpsLog(ele, ops) {
704
710
  const prevEle = ElementUtil.getPrevSiblingElement(ele);
705
- const log = {
711
+ return {
706
712
  index: ElementUtil.getControlIndex(ele, true),
707
713
  parentIndex: ElementUtil.getControlIndex(ele.parent, true),
708
714
  prevIndex: prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1,
709
715
  ele,
710
716
  ops
711
717
  };
712
- array.push(log);
713
718
  }
714
719
  function inputText(ele, startIndex, input) {
715
720
  const options = getDocCtx(ele);
@@ -818,6 +823,13 @@ function generatePatch(doc) {
818
823
  }
819
824
  formatOpsMap.set(ele, op);
820
825
  }
826
+ if ('insert' in op.ops) {
827
+ op.ops.insert = ele.clone(true);
828
+ const log = getOpsLog(ele, op.ops);
829
+ op.index = log.index;
830
+ op.prevIndex = log.prevIndex;
831
+ op.parentIndex = log.parentIndex;
832
+ }
821
833
  patchs.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
822
834
  }
823
835
  //清空