@windoc/core 0.2.11 → 0.3.0

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
@@ -4419,8 +4419,8 @@ function mergeOption(options = {}) {
4419
4419
  pageGap: 20,
4420
4420
  underlineColor: "#000000",
4421
4421
  strikeoutColor: "#FF0000",
4422
- rangeAlpha: 0.6,
4423
- rangeColor: "#AECBFA",
4422
+ rangeAlpha: 0.8,
4423
+ rangeColor: "#A8C7FA",
4424
4424
  rangeMinWidth: 5,
4425
4425
  searchMatchAlpha: 0.6,
4426
4426
  searchMatchColor: "#FFFF00",
@@ -6437,7 +6437,7 @@ var Cursor = class {
6437
6437
  const curElement = elementList[curIndex];
6438
6438
  const nextElement = elementList[curIndex + 1];
6439
6439
  const isNearImage = curElement && curElement.type === "image" /* IMAGE */ || nextElement && nextElement.type === "image" /* IMAGE */;
6440
- const isNearSeparator = curElement && curElement.type === "separator" /* SEPARATOR */ || nextElement && nextElement.type === "separator" /* SEPARATOR */;
6440
+ const isNearSeparator = curElement?.type === "separator" /* SEPARATOR */;
6441
6441
  if (isNearImage || isNearSeparator) {
6442
6442
  const { defaultSize, defaultFont } = this.options;
6443
6443
  const ctx = this.draw.getCtx();
@@ -6445,17 +6445,27 @@ var Cursor = class {
6445
6445
  ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
6446
6446
  const textMetrics = ctx.measureText("M");
6447
6447
  ctx.restore();
6448
- const textHeight = textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent;
6449
- effectiveMetrics = {
6450
- width: metrics.width,
6451
- height: textHeight,
6452
- boundingBoxAscent: textMetrics.actualBoundingBoxAscent,
6453
- boundingBoxDescent: textMetrics.actualBoundingBoxDescent
6454
- };
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
+ }
6455
6465
  }
6456
6466
  const cursorPadding = 2 * scale;
6457
6467
  const cursorHeight = effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding;
6458
- const cursorTop = isNearImage ? leftTop[1] + cursorPosition.lineHeight - effectiveMetrics.boundingBoxDescent - cursorPadding / 2 + preY : leftTop[1] + ascent - effectiveMetrics.boundingBoxAscent - cursorPadding / 2 + preY;
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
6469
  const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
6460
6470
  agentCursorDom.style.left = `${cursorLeft}px`;
6461
6471
  agentCursorDom.style.top = `${cursorTop}px`;
@@ -12621,11 +12631,12 @@ var SeparatorParticle = class {
12621
12631
  if (element.dashArray?.length) {
12622
12632
  ctx.setLineDash(element.dashArray);
12623
12633
  }
12634
+ const sideGap = 4 * scale;
12624
12635
  const offsetY = Math.round(y);
12625
12636
  ctx.translate(0, ctx.lineWidth / 2);
12626
12637
  ctx.beginPath();
12627
- ctx.moveTo(x, offsetY);
12628
- ctx.lineTo(x + element.width * scale, offsetY);
12638
+ ctx.moveTo(x + sideGap, offsetY);
12639
+ ctx.lineTo(x + element.width * scale - sideGap, offsetY);
12629
12640
  ctx.stroke();
12630
12641
  ctx.restore();
12631
12642
  }
@@ -18473,7 +18484,7 @@ var ListParticle = class {
18473
18484
  }
18474
18485
  if (!text) return;
18475
18486
  ctx.save();
18476
- ctx.font = `${defaultSize * scale}px ${defaultFont}`;
18487
+ ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
18477
18488
  ctx.fillText(text, x, y);
18478
18489
  ctx.restore();
18479
18490
  }
@@ -21467,9 +21478,10 @@ var Draw = class {
21467
21478
  const lineWidth = element.lineWidth || defaultLineWidth;
21468
21479
  element.width = availableWidth / scale;
21469
21480
  metrics.width = availableWidth;
21470
- metrics.height = lineWidth * scale;
21471
- metrics.boundingBoxAscent = -rowMargin;
21472
- metrics.boundingBoxDescent = -rowMargin + metrics.height;
21481
+ const separatorHeight = defaultSize * scale;
21482
+ metrics.height = separatorHeight;
21483
+ metrics.boundingBoxAscent = separatorHeight / 2;
21484
+ metrics.boundingBoxDescent = separatorHeight / 2 + lineWidth * scale;
21473
21485
  } else if (element.type === "pageBreak" /* PAGE_BREAK */) {
21474
21486
  element.width = availableWidth / scale;
21475
21487
  metrics.width = availableWidth;
@@ -21754,6 +21766,13 @@ var Draw = class {
21754
21766
  row.spaceBelow = space.below * PT_TO_PX * scale;
21755
21767
  }
21756
21768
  }
21769
+ const separatorEl = row.elementList.find(
21770
+ (el) => el.type === "separator" /* SEPARATOR */
21771
+ );
21772
+ if (separatorEl) {
21773
+ row.spaceAbove = 4 * PT_TO_PX * scale;
21774
+ row.spaceBelow = 1 * PT_TO_PX * scale;
21775
+ }
21757
21776
  }
21758
21777
  }
21759
21778
  _computePageList() {
@@ -21939,7 +21958,7 @@ var Draw = class {
21939
21958
  this.textParticle.complete();
21940
21959
  this.subscriptParticle.render(ctx, element, x, y + offsetY);
21941
21960
  } else if (element.type === "separator" /* SEPARATOR */) {
21942
- this.separatorParticle.render(ctx, element, x, y);
21961
+ this.separatorParticle.render(ctx, element, x, y + offsetY);
21943
21962
  } else if (element.type === "pageBreak" /* PAGE_BREAK */) {
21944
21963
  } else if (element.type === "columnBreak" /* COLUMN_BREAK */) {
21945
21964
  } else if (element.type === "checkbox" /* CHECKBOX */ || element.controlComponent === "checkbox" /* CHECKBOX */) {
@@ -22052,8 +22071,8 @@ var Draw = class {
22052
22071
  const nextElement = elementList[startIndex2 + 1];
22053
22072
  if (nextElement && nextElement.value === ZERO) {
22054
22073
  rangeRecord.x = x + metrics.width;
22055
- rangeRecord.y = y;
22056
- rangeRecord.height = curRow.height;
22074
+ rangeRecord.y = y - (curRow.spaceAbove || 0);
22075
+ rangeRecord.height = curRow.height + (curRow.spaceAbove || 0) + (curRow.spaceBelow || 0);
22057
22076
  rangeRecord.width += this.options.rangeMinWidth;
22058
22077
  }
22059
22078
  } else {
@@ -22063,8 +22082,8 @@ var Draw = class {
22063
22082
  }
22064
22083
  if (!rangeRecord.width) {
22065
22084
  rangeRecord.x = x;
22066
- rangeRecord.y = y;
22067
- rangeRecord.height = curRow.height;
22085
+ rangeRecord.y = y - (curRow.spaceAbove || 0);
22086
+ rangeRecord.height = curRow.height + (curRow.spaceAbove || 0) + (curRow.spaceBelow || 0);
22068
22087
  }
22069
22088
  rangeRecord.width += rangeWidth;
22070
22089
  }
@@ -23672,7 +23691,7 @@ var CommandAdapt = class {
23672
23691
  { value: ZERO }
23673
23692
  ]);
23674
23693
  }
23675
- curIndex = afterSepIndex - 1;
23694
+ curIndex = afterSepIndex;
23676
23695
  }
23677
23696
  this.range.setRange(curIndex, curIndex);
23678
23697
  this.draw.render({ curIndex });