@windoc/core 0.2.10 → 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.js +44 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4498,8 +4498,8 @@ function mergeOption(options = {}) {
|
|
|
4498
4498
|
pageGap: 20,
|
|
4499
4499
|
underlineColor: "#000000",
|
|
4500
4500
|
strikeoutColor: "#FF0000",
|
|
4501
|
-
rangeAlpha: 0.
|
|
4502
|
-
rangeColor: "#
|
|
4501
|
+
rangeAlpha: 0.8,
|
|
4502
|
+
rangeColor: "#A8C7FA",
|
|
4503
4503
|
rangeMinWidth: 5,
|
|
4504
4504
|
searchMatchAlpha: 0.6,
|
|
4505
4505
|
searchMatchColor: "#FFFF00",
|
|
@@ -6516,7 +6516,7 @@ var Cursor = class {
|
|
|
6516
6516
|
const curElement = elementList[curIndex];
|
|
6517
6517
|
const nextElement = elementList[curIndex + 1];
|
|
6518
6518
|
const isNearImage = curElement && curElement.type === "image" /* IMAGE */ || nextElement && nextElement.type === "image" /* IMAGE */;
|
|
6519
|
-
const isNearSeparator = curElement
|
|
6519
|
+
const isNearSeparator = curElement?.type === "separator" /* SEPARATOR */;
|
|
6520
6520
|
if (isNearImage || isNearSeparator) {
|
|
6521
6521
|
const { defaultSize, defaultFont } = this.options;
|
|
6522
6522
|
const ctx = this.draw.getCtx();
|
|
@@ -6524,17 +6524,27 @@ var Cursor = class {
|
|
|
6524
6524
|
ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
|
|
6525
6525
|
const textMetrics = ctx.measureText("M");
|
|
6526
6526
|
ctx.restore();
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
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
|
+
}
|
|
6534
6544
|
}
|
|
6535
6545
|
const cursorPadding = 2 * scale;
|
|
6536
6546
|
const cursorHeight = effectiveMetrics.boundingBoxAscent + effectiveMetrics.boundingBoxDescent + cursorPadding;
|
|
6537
|
-
const cursorTop = isNearImage ? leftTop[1] + cursorPosition.lineHeight - effectiveMetrics.boundingBoxDescent - cursorPadding / 2 + preY : leftTop[1] + ascent - effectiveMetrics.boundingBoxAscent - cursorPadding / 2 + preY;
|
|
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
6548
|
const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
|
|
6539
6549
|
agentCursorDom.style.left = `${cursorLeft}px`;
|
|
6540
6550
|
agentCursorDom.style.top = `${cursorTop}px`;
|
|
@@ -12700,11 +12710,12 @@ var SeparatorParticle = class {
|
|
|
12700
12710
|
if (element.dashArray?.length) {
|
|
12701
12711
|
ctx.setLineDash(element.dashArray);
|
|
12702
12712
|
}
|
|
12713
|
+
const sideGap = 4 * scale;
|
|
12703
12714
|
const offsetY = Math.round(y);
|
|
12704
12715
|
ctx.translate(0, ctx.lineWidth / 2);
|
|
12705
12716
|
ctx.beginPath();
|
|
12706
|
-
ctx.moveTo(x, offsetY);
|
|
12707
|
-
ctx.lineTo(x + element.width * scale, offsetY);
|
|
12717
|
+
ctx.moveTo(x + sideGap, offsetY);
|
|
12718
|
+
ctx.lineTo(x + element.width * scale - sideGap, offsetY);
|
|
12708
12719
|
ctx.stroke();
|
|
12709
12720
|
ctx.restore();
|
|
12710
12721
|
}
|
|
@@ -18552,7 +18563,7 @@ var ListParticle = class {
|
|
|
18552
18563
|
}
|
|
18553
18564
|
if (!text) return;
|
|
18554
18565
|
ctx.save();
|
|
18555
|
-
ctx.font = `${defaultSize * scale}px ${defaultFont}`;
|
|
18566
|
+
ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
|
|
18556
18567
|
ctx.fillText(text, x, y);
|
|
18557
18568
|
ctx.restore();
|
|
18558
18569
|
}
|
|
@@ -21546,9 +21557,10 @@ var Draw = class {
|
|
|
21546
21557
|
const lineWidth = element.lineWidth || defaultLineWidth;
|
|
21547
21558
|
element.width = availableWidth / scale;
|
|
21548
21559
|
metrics.width = availableWidth;
|
|
21549
|
-
|
|
21550
|
-
metrics.
|
|
21551
|
-
metrics.
|
|
21560
|
+
const separatorHeight = defaultSize * scale;
|
|
21561
|
+
metrics.height = separatorHeight;
|
|
21562
|
+
metrics.boundingBoxAscent = separatorHeight / 2;
|
|
21563
|
+
metrics.boundingBoxDescent = separatorHeight / 2 + lineWidth * scale;
|
|
21552
21564
|
} else if (element.type === "pageBreak" /* PAGE_BREAK */) {
|
|
21553
21565
|
element.width = availableWidth / scale;
|
|
21554
21566
|
metrics.width = availableWidth;
|
|
@@ -21612,8 +21624,8 @@ var Draw = class {
|
|
|
21612
21624
|
ctx,
|
|
21613
21625
|
element.font
|
|
21614
21626
|
);
|
|
21615
|
-
metrics.boundingBoxAscent = basisMetrics.
|
|
21616
|
-
metrics.boundingBoxDescent = basisMetrics.
|
|
21627
|
+
metrics.boundingBoxAscent = basisMetrics.fontBoundingBoxAscent * scale;
|
|
21628
|
+
metrics.boundingBoxDescent = basisMetrics.fontBoundingBoxDescent * scale;
|
|
21617
21629
|
if (element.type === "superscript" /* SUPERSCRIPT */) {
|
|
21618
21630
|
metrics.boundingBoxAscent += metrics.height / 2;
|
|
21619
21631
|
} else if (element.type === "subscript" /* SUBSCRIPT */) {
|
|
@@ -21833,6 +21845,13 @@ var Draw = class {
|
|
|
21833
21845
|
row.spaceBelow = space.below * PT_TO_PX * scale;
|
|
21834
21846
|
}
|
|
21835
21847
|
}
|
|
21848
|
+
const separatorEl = row.elementList.find(
|
|
21849
|
+
(el) => el.type === "separator" /* SEPARATOR */
|
|
21850
|
+
);
|
|
21851
|
+
if (separatorEl) {
|
|
21852
|
+
row.spaceAbove = 4 * PT_TO_PX * scale;
|
|
21853
|
+
row.spaceBelow = 1 * PT_TO_PX * scale;
|
|
21854
|
+
}
|
|
21836
21855
|
}
|
|
21837
21856
|
}
|
|
21838
21857
|
_computePageList() {
|
|
@@ -22018,7 +22037,7 @@ var Draw = class {
|
|
|
22018
22037
|
this.textParticle.complete();
|
|
22019
22038
|
this.subscriptParticle.render(ctx, element, x, y + offsetY);
|
|
22020
22039
|
} else if (element.type === "separator" /* SEPARATOR */) {
|
|
22021
|
-
this.separatorParticle.render(ctx, element, x, y);
|
|
22040
|
+
this.separatorParticle.render(ctx, element, x, y + offsetY);
|
|
22022
22041
|
} else if (element.type === "pageBreak" /* PAGE_BREAK */) {
|
|
22023
22042
|
} else if (element.type === "columnBreak" /* COLUMN_BREAK */) {
|
|
22024
22043
|
} else if (element.type === "checkbox" /* CHECKBOX */ || element.controlComponent === "checkbox" /* CHECKBOX */) {
|
|
@@ -22131,8 +22150,8 @@ var Draw = class {
|
|
|
22131
22150
|
const nextElement = elementList[startIndex2 + 1];
|
|
22132
22151
|
if (nextElement && nextElement.value === ZERO) {
|
|
22133
22152
|
rangeRecord.x = x + metrics.width;
|
|
22134
|
-
rangeRecord.y = y;
|
|
22135
|
-
rangeRecord.height = curRow.height;
|
|
22153
|
+
rangeRecord.y = y - (curRow.spaceAbove || 0);
|
|
22154
|
+
rangeRecord.height = curRow.height + (curRow.spaceAbove || 0) + (curRow.spaceBelow || 0);
|
|
22136
22155
|
rangeRecord.width += this.options.rangeMinWidth;
|
|
22137
22156
|
}
|
|
22138
22157
|
} else {
|
|
@@ -22142,8 +22161,8 @@ var Draw = class {
|
|
|
22142
22161
|
}
|
|
22143
22162
|
if (!rangeRecord.width) {
|
|
22144
22163
|
rangeRecord.x = x;
|
|
22145
|
-
rangeRecord.y = y;
|
|
22146
|
-
rangeRecord.height = curRow.height;
|
|
22164
|
+
rangeRecord.y = y - (curRow.spaceAbove || 0);
|
|
22165
|
+
rangeRecord.height = curRow.height + (curRow.spaceAbove || 0) + (curRow.spaceBelow || 0);
|
|
22147
22166
|
}
|
|
22148
22167
|
rangeRecord.width += rangeWidth;
|
|
22149
22168
|
}
|
|
@@ -23751,7 +23770,7 @@ var CommandAdapt = class {
|
|
|
23751
23770
|
{ value: ZERO }
|
|
23752
23771
|
]);
|
|
23753
23772
|
}
|
|
23754
|
-
curIndex = afterSepIndex
|
|
23773
|
+
curIndex = afterSepIndex;
|
|
23755
23774
|
}
|
|
23756
23775
|
this.range.setRange(curIndex, curIndex);
|
|
23757
23776
|
this.draw.render({ curIndex });
|