@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-cjs.js CHANGED
@@ -17929,6 +17929,23 @@ class DocumentEvent {
17929
17929
  }
17930
17930
  }
17931
17931
  }
17932
+ /**
17933
+ * 移动光标到下一个数据元素上
17934
+ */
17935
+ moveFocusToNextDataElement() {
17936
+ if (this.viewOptions.docMode !== exports.DocMode.FormEdit) {
17937
+ return;
17938
+ }
17939
+ const currDataEle = this.getCurrentDataElement('free');
17940
+ if (currDataEle) {
17941
+ if (currDataEle instanceof DataElementLeaf) {
17942
+ this.moveCursorToRightHandle(currDataEle, 1);
17943
+ }
17944
+ else {
17945
+ this.moveCursorToRightHandle(currDataEle.endDecorate, 1);
17946
+ }
17947
+ }
17948
+ }
17932
17949
  /**
17933
17950
  * 向右移动光标
17934
17951
  */
@@ -18184,6 +18201,30 @@ class DocumentEvent {
18184
18201
  this.clicks = 0;
18185
18202
  }
18186
18203
  }
18204
+ /**
18205
+ * 获取当前光标所在的数据元
18206
+ * @returns
18207
+ */
18208
+ getCurrentDataElement(mode = 'strict') {
18209
+ const selectionState = this.selectionState;
18210
+ const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
18211
+ if (startControl && collapsed) {
18212
+ // if (!ElementUtil.verifyHitable(startControl)) {
18213
+ // return null;
18214
+ // }
18215
+ const dataEle = ElementUtil.getParent(startControl, validateDataEle);
18216
+ if (dataEle instanceof DataElementLeaf || (mode === 'free' || IsInSideDataElement(startControl, startOffset))) {
18217
+ return dataEle;
18218
+ }
18219
+ else {
18220
+ return null;
18221
+ }
18222
+ }
18223
+ else if (!collapsed && ancestorCommonControl) {
18224
+ return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
18225
+ }
18226
+ return null;
18227
+ }
18187
18228
  }
18188
18229
 
18189
18230
  /**
@@ -27187,6 +27228,7 @@ class DocEditor {
27187
27228
  this.editInput.style.left = '-2px';
27188
27229
  this.editInput.style.top = '-2px';
27189
27230
  this.editInput.readOnly = true;
27231
+ this.editInput.focus();
27190
27232
  }
27191
27233
  /**
27192
27234
  * 设置光标位置
@@ -27266,24 +27308,17 @@ class DocEditor {
27266
27308
  * @returns
27267
27309
  */
27268
27310
  getCurrentDataElement() {
27269
- const selectionState = this.documentSelection.selectionState;
27270
- const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
27271
- if (startControl && collapsed) {
27272
- if (!ElementUtil.verifyHitable(startControl)) {
27273
- return null;
27274
- }
27275
- const dataEle = ElementUtil.getParent(startControl, validateDataEle);
27276
- if (dataEle instanceof DataElementLeaf || IsInSideDataElement(startControl, startOffset)) {
27277
- return dataEle;
27278
- }
27279
- else {
27280
- return null;
27281
- }
27282
- }
27283
- else if (!collapsed && ancestorCommonControl) {
27284
- return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
27311
+ return this.documentEvent.getCurrentDataElement();
27312
+ }
27313
+ /**
27314
+ * 移动光标到下一个数据元素上
27315
+ */
27316
+ moveFocusToNextDataElement() {
27317
+ this.documentEvent.moveFocusToNextDataElement();
27318
+ const startControl = this.selectionState.range?.startControl;
27319
+ if (startControl) {
27320
+ this.bringToView(startControl);
27285
27321
  }
27286
- return null;
27287
27322
  }
27288
27323
  /**
27289
27324
  * 设置当前光标所在的数据元的值
@@ -27677,14 +27712,15 @@ class DocEditor {
27677
27712
  const docRender = ElementUtil.getParentRender(renderObj, DocumentRenderObject);
27678
27713
  const index = docRender.getIndex();
27679
27714
  const cursorPos = DocumentCursor.getElementCursorPos(ele, 0, region, index);
27680
- this.selectionState.resetRange(element, 0);
27681
- if (cursorPos.rect.y - this.viewOptions.pageOffset.y > 0 && cursorPos.rect.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
27682
- return;
27683
- }
27684
- //this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
27685
- //this.doc.scrollTo(cursorPos.rect.x, cursorPos.rect.y + 100);
27686
- this.scrollContainer.scrollTop = cursorPos.rect.y + 100;
27715
+ //this.selectionState.resetRange(element, 0);
27716
+ this.scrollToPosition(cursorPos.rect);
27717
+ }
27718
+ }
27719
+ scrollToPosition(pos) {
27720
+ if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
27721
+ return;
27687
27722
  }
27723
+ this.scrollContainer.scrollTop = pos.y + 30;
27688
27724
  }
27689
27725
  /**
27690
27726
  * 设置当前文档页边距
@@ -28104,7 +28140,8 @@ class DocEditor {
28104
28140
  const dataEle = editor.getCurrentDataElement();
28105
28141
  if (dataEle && dataEle instanceof DataElementDate) {
28106
28142
  dataEle.setValue(value);
28107
- editor.selectionState.clear();
28143
+ editor.selectionState.resetRange(dataEle.endDecorate, 1);
28144
+ //editor.selectionState.clear();
28108
28145
  }
28109
28146
  });
28110
28147
  return {