@hailin-zheng/editor-core 2.0.21 → 2.0.23

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
@@ -17899,6 +17899,23 @@ class DocumentEvent {
17899
17899
  }
17900
17900
  }
17901
17901
  }
17902
+ /**
17903
+ * 移动光标到下一个数据元素上
17904
+ */
17905
+ moveFocusToNextDataElement() {
17906
+ if (this.viewOptions.docMode !== DocMode.FormEdit) {
17907
+ return;
17908
+ }
17909
+ const currDataEle = this.getCurrentDataElement('free');
17910
+ if (currDataEle) {
17911
+ if (currDataEle instanceof DataElementLeaf) {
17912
+ this.moveCursorToRightHandle(currDataEle, 1);
17913
+ }
17914
+ else {
17915
+ this.moveCursorToRightHandle(currDataEle.endDecorate, 1);
17916
+ }
17917
+ }
17918
+ }
17902
17919
  /**
17903
17920
  * 向右移动光标
17904
17921
  */
@@ -18154,6 +18171,30 @@ class DocumentEvent {
18154
18171
  this.clicks = 0;
18155
18172
  }
18156
18173
  }
18174
+ /**
18175
+ * 获取当前光标所在的数据元
18176
+ * @returns
18177
+ */
18178
+ getCurrentDataElement(mode = 'strict') {
18179
+ const selectionState = this.selectionState;
18180
+ const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
18181
+ if (startControl && collapsed) {
18182
+ // if (!ElementUtil.verifyHitable(startControl)) {
18183
+ // return null;
18184
+ // }
18185
+ const dataEle = ElementUtil.getParent(startControl, validateDataEle);
18186
+ if (dataEle instanceof DataElementLeaf || (mode === 'free' || IsInSideDataElement(startControl, startOffset))) {
18187
+ return dataEle;
18188
+ }
18189
+ else {
18190
+ return null;
18191
+ }
18192
+ }
18193
+ else if (!collapsed && ancestorCommonControl) {
18194
+ return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
18195
+ }
18196
+ return null;
18197
+ }
18157
18198
  }
18158
18199
 
18159
18200
  /**
@@ -27157,6 +27198,7 @@ class DocEditor {
27157
27198
  this.editInput.style.left = '-2px';
27158
27199
  this.editInput.style.top = '-2px';
27159
27200
  this.editInput.readOnly = true;
27201
+ this.editInput.focus();
27160
27202
  }
27161
27203
  /**
27162
27204
  * 设置光标位置
@@ -27236,24 +27278,17 @@ class DocEditor {
27236
27278
  * @returns
27237
27279
  */
27238
27280
  getCurrentDataElement() {
27239
- const selectionState = this.documentSelection.selectionState;
27240
- const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
27241
- if (startControl && collapsed) {
27242
- if (!ElementUtil.verifyHitable(startControl)) {
27243
- return null;
27244
- }
27245
- const dataEle = ElementUtil.getParent(startControl, validateDataEle);
27246
- if (dataEle instanceof DataElementLeaf || IsInSideDataElement(startControl, startOffset)) {
27247
- return dataEle;
27248
- }
27249
- else {
27250
- return null;
27251
- }
27252
- }
27253
- else if (!collapsed && ancestorCommonControl) {
27254
- return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
27281
+ return this.documentEvent.getCurrentDataElement();
27282
+ }
27283
+ /**
27284
+ * 移动光标到下一个数据元素上
27285
+ */
27286
+ moveFocusToNextDataElement() {
27287
+ this.documentEvent.moveFocusToNextDataElement();
27288
+ const startControl = this.selectionState.range?.startControl;
27289
+ if (startControl) {
27290
+ this.bringToView(startControl);
27255
27291
  }
27256
- return null;
27257
27292
  }
27258
27293
  /**
27259
27294
  * 设置当前光标所在的数据元的值
@@ -27647,14 +27682,15 @@ class DocEditor {
27647
27682
  const docRender = ElementUtil.getParentRender(renderObj, DocumentRenderObject);
27648
27683
  const index = docRender.getIndex();
27649
27684
  const cursorPos = DocumentCursor.getElementCursorPos(ele, 0, region, index);
27650
- this.selectionState.resetRange(element, 0);
27651
- if (cursorPos.rect.y - this.viewOptions.pageOffset.y > 0 && cursorPos.rect.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
27652
- return;
27653
- }
27654
- //this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
27655
- //this.doc.scrollTo(cursorPos.rect.x, cursorPos.rect.y + 100);
27656
- this.scrollContainer.scrollTop = cursorPos.rect.y + 100;
27685
+ //this.selectionState.resetRange(element, 0);
27686
+ this.scrollToPosition(cursorPos.rect);
27687
+ }
27688
+ }
27689
+ scrollToPosition(pos) {
27690
+ if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
27691
+ return;
27657
27692
  }
27693
+ this.scrollContainer.scrollTop = pos.y + 30;
27658
27694
  }
27659
27695
  /**
27660
27696
  * 设置当前文档页边距
@@ -28074,7 +28110,8 @@ class DocEditor {
28074
28110
  const dataEle = editor.getCurrentDataElement();
28075
28111
  if (dataEle && dataEle instanceof DataElementDate) {
28076
28112
  dataEle.setValue(value);
28077
- editor.selectionState.clear();
28113
+ editor.selectionState.resetRange(dataEle.endDecorate, 1);
28114
+ //editor.selectionState.clear();
28078
28115
  }
28079
28116
  });
28080
28117
  return {