@hailin-zheng/editor-core 2.0.37 → 2.0.39

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
@@ -12514,6 +12514,17 @@ class ElementUtil {
12514
12514
  offset = offset === -1 ? 1 : offset;
12515
12515
  return offset;
12516
12516
  }
12517
+ /**
12518
+ * 设置光标在数据元内容末尾
12519
+ */
12520
+ static setDataElemEndFocus(ss, ele) {
12521
+ if (ele.length === 2) {
12522
+ ss.resetRange(ele.getChild(0), 1);
12523
+ }
12524
+ else {
12525
+ ss.resetRange(ele.getChild(ele.length - 2), -1);
12526
+ }
12527
+ }
12517
12528
  }
12518
12529
 
12519
12530
  class RenderContext {
@@ -14717,9 +14728,9 @@ class DocumentArrange {
14717
14728
  blockLine = children[++j];
14718
14729
  }
14719
14730
  }
14720
- // if (cloneRender.length === 0 && sumHeight === 0) {
14721
- // return null;
14722
- // }
14731
+ if (cloneRender.length === 0 && sumHeight === 0) {
14732
+ return null;
14733
+ }
14723
14734
  ElementUtil.remeasure(cloneRender);
14724
14735
  ElementUtil.remeasure(render);
14725
14736
  if (cloneRender.length === 0) {
@@ -18842,8 +18853,10 @@ class DocumentChange {
18842
18853
  else {
18843
18854
  this.deleteRange(selectedRange);
18844
18855
  }
18845
- this.selectionState.resetRange(startPointElement, startPointOffset);
18846
- return { cursorEle: startPointElement, cursorOffset: startPointOffset };
18856
+ if (startPointElement) {
18857
+ this.selectionState.resetRange(startPointElement, startPointOffset);
18858
+ }
18859
+ //return {cursorEle: startPointElement, cursorOffset: startPointOffset};
18847
18860
  }
18848
18861
  /**
18849
18862
  * backspace删除
@@ -18906,9 +18919,8 @@ class DocumentChange {
18906
18919
  return;
18907
18920
  }
18908
18921
  if (control.isPrefix && this.viewOptions.docMode === exports.DocMode.FormEdit) {
18909
- if (this.jumpToPrevDataElement(dataEle)) {
18910
- return;
18911
- }
18922
+ this.selectionState.resetRange(dataEle.startDecorate, 1);
18923
+ return;
18912
18924
  }
18913
18925
  }
18914
18926
  if (control.isDecorate) {
@@ -18932,7 +18944,7 @@ class DocumentChange {
18932
18944
  return false;
18933
18945
  }
18934
18946
  if (prevEle) {
18935
- this.selectionState.resetRange(prevEle.endDecorate, 0);
18947
+ ElementUtil.setDataElemEndFocus(this.selectionState, prevEle);
18936
18948
  return true;
18937
18949
  }
18938
18950
  return false;
@@ -19289,6 +19301,7 @@ class DocumentChange {
19289
19301
  //在数据元内删除,调用普通的删除处理
19290
19302
  if (dataElement) {
19291
19303
  this.deleteRange(range);
19304
+ this.selectionState.resetRange(dataElement.startDecorate, 1);
19292
19305
  return;
19293
19306
  }
19294
19307
  //在数据元外删除
@@ -19877,6 +19890,14 @@ class DocumentChange {
19877
19890
  }
19878
19891
  }
19879
19892
  getCursorElementByDeleteAction(control) {
19893
+ if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
19894
+ if (control.parent instanceof DataElementInlineGroup) {
19895
+ return {
19896
+ ele: control.parent.startDecorate,
19897
+ offset: 1
19898
+ };
19899
+ }
19900
+ }
19880
19901
  const prevLeafElementInPara = ElementUtil.getRecursionPrevSiblingElement(control, false, true, this.viewOptions);
19881
19902
  //是否为同一段落
19882
19903
  if (prevLeafElementInPara && ElementUtil.isInSameParagraph(prevLeafElementInPara, control)) {
@@ -27340,6 +27361,8 @@ class DocEditor {
27340
27361
  this.editInput.style.width = "1px";
27341
27362
  this.editInput.readOnly = false;
27342
27363
  this.setCursorVisibility(true);
27364
+ //判断光标位置是否被可见,如果不可见,需要将其设置到可见区域
27365
+ //TODO:暂时不做处理
27343
27366
  //this.setCursorInputStatus();
27344
27367
  }
27345
27368
  /**
@@ -28106,12 +28129,7 @@ class DocEditor {
28106
28129
  * 设置光标在数据元内容末尾
28107
28130
  */
28108
28131
  setDataElemEndFocus(ele) {
28109
- if (ele.length === 2) {
28110
- this.selectionState.resetRange(ele.getChild(0), 1);
28111
- }
28112
- else {
28113
- this.selectionState.resetRange(ele.getChild(ele.length - 2), -1);
28114
- }
28132
+ ElementUtil.setDataElemEndFocus(this.selectionState, ele);
28115
28133
  }
28116
28134
  /**
28117
28135
  * 渲染下拉框数据元
@@ -28223,7 +28241,14 @@ class DocEditor {
28223
28241
  elm.style.left = (position.x - elmRect.width + 10) + 'px';
28224
28242
  }
28225
28243
  if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
28226
- elm.style.top = (position.y - position.height - elmRect.height) + 'px';
28244
+ const newTop = position.y - position.height - elmRect.height;
28245
+ const oldTop = position.y + 5 + position.height;
28246
+ //计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
28247
+ if (oldTop - newTop < elmRect.top - parentRect.top) {
28248
+ elm.style.top = (position.y - position.height - elmRect.height) + 'px';
28249
+ }
28250
+ //elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
28251
+ //elm.style.top = (position.y - position.height - elmRect.height) + 'px';
28227
28252
  }
28228
28253
  }
28229
28254
  }
@@ -28331,7 +28356,7 @@ class DocEditor {
28331
28356
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28332
28357
  }
28333
28358
  version() {
28334
- return "2.0.37";
28359
+ return "2.0.39";
28335
28360
  }
28336
28361
  }
28337
28362