@windoc/core 0.3.1 → 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.mjs CHANGED
@@ -6438,34 +6438,25 @@ var Cursor = class {
6438
6438
  const nextElement = elementList[curIndex + 1];
6439
6439
  const isNearImage = curElement && curElement.type === "image" /* IMAGE */ || nextElement && nextElement.type === "image" /* IMAGE */;
6440
6440
  const isNearSeparator = curElement?.type === "separator" /* SEPARATOR */;
6441
- if (isNearImage || isNearSeparator) {
6441
+ const isNearTab = curElement?.type === "tab" /* TAB */;
6442
+ if (isNearImage || isNearSeparator || isNearTab) {
6442
6443
  const { defaultSize, defaultFont } = this.options;
6443
6444
  const ctx = this.draw.getCtx();
6444
6445
  ctx.save();
6445
6446
  ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
6446
6447
  const textMetrics = ctx.measureText("M");
6447
6448
  ctx.restore();
6448
- if (isNearSeparator) {
6449
- const textHeight = textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent;
6450
- effectiveMetrics = {
6451
- width: metrics.width,
6452
- height: textHeight,
6453
- boundingBoxAscent: textMetrics.fontBoundingBoxAscent,
6454
- boundingBoxDescent: textMetrics.fontBoundingBoxDescent
6455
- };
6456
- } else {
6457
- const textHeight = textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent;
6458
- effectiveMetrics = {
6459
- width: metrics.width,
6460
- height: textHeight,
6461
- boundingBoxAscent: textMetrics.actualBoundingBoxAscent,
6462
- boundingBoxDescent: textMetrics.actualBoundingBoxDescent
6463
- };
6464
- }
6449
+ const textHeight = textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent;
6450
+ effectiveMetrics = {
6451
+ width: metrics.width,
6452
+ height: textHeight,
6453
+ boundingBoxAscent: textMetrics.fontBoundingBoxAscent,
6454
+ boundingBoxDescent: textMetrics.fontBoundingBoxDescent
6455
+ };
6465
6456
  }
6466
6457
  const cursorPadding = 2 * scale;
6467
6458
  const cursorHeight = effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding;
6468
- 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;
6459
+ 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;
6469
6460
  const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
6470
6461
  agentCursorDom.style.left = `${cursorLeft}px`;
6471
6462
  agentCursorDom.style.top = `${cursorTop}px`;
@@ -7732,6 +7723,12 @@ function left(evt, host) {
7732
7723
  }
7733
7724
  }
7734
7725
  }
7726
+ if (!isCollapsed && !evt.shiftKey) {
7727
+ rangeManager.setRange(startIndex, startIndex);
7728
+ draw.render({ curIndex: startIndex, isSetCursor: true, isSubmitHistory: false, isCompute: false });
7729
+ evt.preventDefault();
7730
+ return;
7731
+ }
7735
7732
  const curIndex = startIndex - moveCount;
7736
7733
  let anchorStartIndex = curIndex;
7737
7734
  let anchorEndIndex = curIndex;
@@ -7868,6 +7865,12 @@ function right(evt, host) {
7868
7865
  }
7869
7866
  }
7870
7867
  }
7868
+ if (!isCollapsed && !evt.shiftKey) {
7869
+ rangeManager.setRange(endIndex, endIndex);
7870
+ draw.render({ curIndex: endIndex, isSetCursor: true, isSubmitHistory: false, isCompute: false });
7871
+ evt.preventDefault();
7872
+ return;
7873
+ }
7871
7874
  const curIndex = endIndex + moveCount;
7872
7875
  let anchorStartIndex = curIndex;
7873
7876
  let anchorEndIndex = curIndex;