@windoc/core 0.3.0 → 0.3.2

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/dist/index.js CHANGED
@@ -6517,34 +6517,25 @@ var Cursor = class {
6517
6517
  const nextElement = elementList[curIndex + 1];
6518
6518
  const isNearImage = curElement && curElement.type === "image" /* IMAGE */ || nextElement && nextElement.type === "image" /* IMAGE */;
6519
6519
  const isNearSeparator = curElement?.type === "separator" /* SEPARATOR */;
6520
- if (isNearImage || isNearSeparator) {
6520
+ const isNearTab = curElement?.type === "tab" /* TAB */;
6521
+ if (isNearImage || isNearSeparator || isNearTab) {
6521
6522
  const { defaultSize, defaultFont } = this.options;
6522
6523
  const ctx = this.draw.getCtx();
6523
6524
  ctx.save();
6524
6525
  ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
6525
6526
  const textMetrics = ctx.measureText("M");
6526
6527
  ctx.restore();
6527
- if (isNearSeparator) {
6528
- const textHeight = textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent;
6529
- effectiveMetrics = {
6530
- width: metrics.width,
6531
- height: textHeight,
6532
- boundingBoxAscent: textMetrics.fontBoundingBoxAscent,
6533
- boundingBoxDescent: textMetrics.fontBoundingBoxDescent
6534
- };
6535
- } else {
6536
- const textHeight = textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent;
6537
- effectiveMetrics = {
6538
- width: metrics.width,
6539
- height: textHeight,
6540
- boundingBoxAscent: textMetrics.actualBoundingBoxAscent,
6541
- boundingBoxDescent: textMetrics.actualBoundingBoxDescent
6542
- };
6543
- }
6528
+ const textHeight = textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent;
6529
+ effectiveMetrics = {
6530
+ width: metrics.width,
6531
+ height: textHeight,
6532
+ boundingBoxAscent: textMetrics.fontBoundingBoxAscent,
6533
+ boundingBoxDescent: textMetrics.fontBoundingBoxDescent
6534
+ };
6544
6535
  }
6545
6536
  const cursorPadding = 2 * scale;
6546
6537
  const cursorHeight = effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding;
6547
- const cursorTop = isNearImage ? leftTop[1] + cursorPosition.lineHeight - effectiveMetrics.boundingBoxDescent - cursorPadding / 2 + preY : isNearSeparator ? leftTop[1] + ascent - (effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding) / 2 + preY : leftTop[1] + ascent - effectiveMetrics.boundingBoxAscent - cursorPadding / 2 + preY;
6538
+ const cursorTop = isNearImage ? leftTop[1] + cursorPosition.lineHeight - cursorHeight + preY : isNearSeparator ? leftTop[1] + ascent - (effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding) / 2 + preY : leftTop[1] + ascent - effectiveMetrics.boundingBoxAscent - cursorPadding / 2 + preY;
6548
6539
  const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
6549
6540
  agentCursorDom.style.left = `${cursorLeft}px`;
6550
6541
  agentCursorDom.style.top = `${cursorTop}px`;
@@ -7811,6 +7802,12 @@ function left(evt, host) {
7811
7802
  }
7812
7803
  }
7813
7804
  }
7805
+ if (!isCollapsed && !evt.shiftKey) {
7806
+ rangeManager.setRange(startIndex, startIndex);
7807
+ draw.render({ curIndex: startIndex, isSetCursor: true, isSubmitHistory: false, isCompute: false });
7808
+ evt.preventDefault();
7809
+ return;
7810
+ }
7814
7811
  const curIndex = startIndex - moveCount;
7815
7812
  let anchorStartIndex = curIndex;
7816
7813
  let anchorEndIndex = curIndex;
@@ -7947,6 +7944,12 @@ function right(evt, host) {
7947
7944
  }
7948
7945
  }
7949
7946
  }
7947
+ if (!isCollapsed && !evt.shiftKey) {
7948
+ rangeManager.setRange(endIndex, endIndex);
7949
+ draw.render({ curIndex: endIndex, isSetCursor: true, isSubmitHistory: false, isCompute: false });
7950
+ evt.preventDefault();
7951
+ return;
7952
+ }
7950
7953
  const curIndex = endIndex + moveCount;
7951
7954
  let anchorStartIndex = curIndex;
7952
7955
  let anchorEndIndex = curIndex;