@windoc/core 0.3.27 → 0.3.28
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2234,7 +2234,7 @@ declare class ListParticle {
|
|
|
2234
2234
|
indent(): void;
|
|
2235
2235
|
outdent(): void;
|
|
2236
2236
|
unsetList(): void;
|
|
2237
|
-
getListIndentWidth(element: IElement): number;
|
|
2237
|
+
getListIndentWidth(element: IElement, markerWidth: number): number;
|
|
2238
2238
|
private _getListMarkerStyleElement;
|
|
2239
2239
|
private _getListMarkerText;
|
|
2240
2240
|
computeListStyle(ctx: CanvasRenderingContext2D, elementList: IElement[]): Map<string, number>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2234,7 +2234,7 @@ declare class ListParticle {
|
|
|
2234
2234
|
indent(): void;
|
|
2235
2235
|
outdent(): void;
|
|
2236
2236
|
unsetList(): void;
|
|
2237
|
-
getListIndentWidth(element: IElement): number;
|
|
2237
|
+
getListIndentWidth(element: IElement, markerWidth: number): number;
|
|
2238
2238
|
private _getListMarkerStyleElement;
|
|
2239
2239
|
private _getListMarkerText;
|
|
2240
2240
|
computeListStyle(ctx: CanvasRenderingContext2D, elementList: IElement[]): Map<string, number>;
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
module.exports = __toCommonJS(index_exports);
|
|
79
79
|
|
|
80
80
|
// src/version.ts
|
|
81
|
-
var version = "0.3.
|
|
81
|
+
var version = "0.3.28";
|
|
82
82
|
|
|
83
83
|
// src/dataset/enum/Common.ts
|
|
84
84
|
var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
|
|
@@ -19074,10 +19074,11 @@ var ListParticle = class {
|
|
|
19074
19074
|
const curIndex = isSetCursor ? endIndex : startIndex;
|
|
19075
19075
|
this.draw.render({ curIndex, isSetCursor });
|
|
19076
19076
|
}
|
|
19077
|
-
|
|
19078
|
-
|
|
19077
|
+
// Each level indents by the list's marker column, so a nested marker starts
|
|
19078
|
+
// exactly where its parent's text starts
|
|
19079
|
+
getListIndentWidth(element, markerWidth) {
|
|
19079
19080
|
const level = element.listLevel ?? 0;
|
|
19080
|
-
return level *
|
|
19081
|
+
return level * markerWidth;
|
|
19081
19082
|
}
|
|
19082
19083
|
_getListMarkerStyleElement(elementList, startIndex = 0) {
|
|
19083
19084
|
const startElement = elementList[startIndex];
|
|
@@ -19207,8 +19208,9 @@ var ListParticle = class {
|
|
|
19207
19208
|
leftTop: [startX]
|
|
19208
19209
|
}
|
|
19209
19210
|
} = position;
|
|
19210
|
-
const
|
|
19211
|
-
|
|
19211
|
+
const level = startElement.listLevel ?? 0;
|
|
19212
|
+
const markerWidth = offsetX / (level + 1);
|
|
19213
|
+
return startX - markerWidth + tabWidth;
|
|
19212
19214
|
}
|
|
19213
19215
|
getListMarker(row) {
|
|
19214
19216
|
const startElement = row.elementList[0];
|
|
@@ -22491,8 +22493,9 @@ var Draw = class {
|
|
|
22491
22493
|
boundingBoxAscent: 0,
|
|
22492
22494
|
boundingBoxDescent: 0
|
|
22493
22495
|
};
|
|
22494
|
-
const
|
|
22495
|
-
const
|
|
22496
|
+
const listMarkerWidth = element.listId && listStyleMap.get(element.listId) || 0;
|
|
22497
|
+
const listIndentWidth = element.listId ? this.listParticle.getListIndentWidth(element, listMarkerWidth) : 0;
|
|
22498
|
+
const offsetX = curRow.offsetX || listMarkerWidth + listIndentWidth || 0;
|
|
22496
22499
|
const availableWidth = innerWidth - offsetX;
|
|
22497
22500
|
const isStartElement = curRow.elementList.length === 1;
|
|
22498
22501
|
x += isStartElement ? offsetX : 0;
|
|
@@ -23240,7 +23243,10 @@ var Draw = class {
|
|
|
23240
23243
|
if (element.listId) {
|
|
23241
23244
|
row.isList = true;
|
|
23242
23245
|
const baseListOffset = listStyleMap.get(element.listId) || 0;
|
|
23243
|
-
const rowListIndent = this.listParticle.getListIndentWidth(
|
|
23246
|
+
const rowListIndent = this.listParticle.getListIndentWidth(
|
|
23247
|
+
element,
|
|
23248
|
+
baseListOffset
|
|
23249
|
+
);
|
|
23244
23250
|
row.offsetX = baseListOffset + rowListIndent;
|
|
23245
23251
|
row.listIndex = listState.listIndex;
|
|
23246
23252
|
}
|
|
@@ -24707,6 +24713,8 @@ async function createDocument(ctx) {
|
|
|
24707
24713
|
});
|
|
24708
24714
|
const footerChildren = opts.footer.disabled ? [] : await serializeFooter(ctx, width, height, margins);
|
|
24709
24715
|
const { pageNumber } = draw.getOptions();
|
|
24716
|
+
endWithParagraph(headerChildren);
|
|
24717
|
+
endWithParagraph(footerChildren);
|
|
24710
24718
|
return new import_docx2.Document({
|
|
24711
24719
|
compatabilityModeVersion: 15,
|
|
24712
24720
|
// LibreOffice formats PAGE/NUMPAGES results from the paragraph style
|
|
@@ -24933,6 +24941,7 @@ async function serializeRow(ctx, row, zone, options, suffix) {
|
|
|
24933
24941
|
}
|
|
24934
24942
|
return new import_docx2.Paragraph({
|
|
24935
24943
|
children,
|
|
24944
|
+
run: hasInlineImage(row) ? { size: IMAGE_MARK_HALF_POINTS } : void 0,
|
|
24936
24945
|
style: suffix?.style,
|
|
24937
24946
|
pageBreakBefore,
|
|
24938
24947
|
widowControl: false,
|
|
@@ -24942,9 +24951,23 @@ async function serializeRow(ctx, row, zone, options, suffix) {
|
|
|
24942
24951
|
});
|
|
24943
24952
|
}
|
|
24944
24953
|
var EXACT_BASELINE_RATIO = 0.8;
|
|
24954
|
+
var IMAGE_MARK_HALF_POINTS = 2;
|
|
24955
|
+
var IMAGE_MARK_DESCENT_PX = 0.3;
|
|
24956
|
+
function hasInlineImage(row) {
|
|
24957
|
+
return row.elementList.some((el) => el.type === "image" /* IMAGE */);
|
|
24958
|
+
}
|
|
24945
24959
|
function rowLine(ctx, row, baseline = row.ascent / ctx.scale) {
|
|
24946
24960
|
const { scale } = ctx;
|
|
24947
24961
|
const height = row.height / scale;
|
|
24962
|
+
if (hasInlineImage(row)) {
|
|
24963
|
+
const lineTw2 = pxTw(Math.min(baseline, height) + IMAGE_MARK_DESCENT_PX);
|
|
24964
|
+
return {
|
|
24965
|
+
lineTw: lineTw2,
|
|
24966
|
+
beforeTw: 0,
|
|
24967
|
+
afterTw: Math.max(0, pxTw(height) - lineTw2),
|
|
24968
|
+
atLeast: true
|
|
24969
|
+
};
|
|
24970
|
+
}
|
|
24948
24971
|
const ascent = Math.min(baseline, height);
|
|
24949
24972
|
const line = Math.min(
|
|
24950
24973
|
ascent / EXACT_BASELINE_RATIO,
|
|
@@ -24956,7 +24979,7 @@ function rowLine(ctx, row, baseline = row.ascent / ctx.scale) {
|
|
|
24956
24979
|
pxTw(ascent) - Math.round(lineTw * EXACT_BASELINE_RATIO)
|
|
24957
24980
|
);
|
|
24958
24981
|
const afterTw = Math.max(0, pxTw(height) - lineTw - beforeTw);
|
|
24959
|
-
return { lineTw, beforeTw, afterTw };
|
|
24982
|
+
return { lineTw, beforeTw, afterTw, atLeast: false };
|
|
24960
24983
|
}
|
|
24961
24984
|
function rowLead(ctx, row, options) {
|
|
24962
24985
|
const separator = row.elementList.find(
|
|
@@ -24971,12 +24994,12 @@ function rowLead(ctx, row, options) {
|
|
|
24971
24994
|
return rowLine(ctx, row, baseline).beforeTw + tw(ctx, (row.offsetY || 0) + (row.spaceAbove || 0)) + pxTw(options.padTop || 0);
|
|
24972
24995
|
}
|
|
24973
24996
|
function rowSpacing(ctx, row, options) {
|
|
24974
|
-
const { lineTw, afterTw } = rowLine(ctx, row);
|
|
24997
|
+
const { lineTw, afterTw, atLeast } = rowLine(ctx, row);
|
|
24975
24998
|
return {
|
|
24976
24999
|
before: options.skipLead ? 0 : rowLead(ctx, row, options),
|
|
24977
25000
|
after: afterTw + tw(ctx, row.spaceBelow || 0) + pxTw(options.padBottom || 0) + (options.extraAfter || 0),
|
|
24978
25001
|
line: lineTw,
|
|
24979
|
-
lineRule: import_docx2.LineRuleType.EXACT
|
|
25002
|
+
lineRule: atLeast ? import_docx2.LineRuleType.AT_LEAST : import_docx2.LineRuleType.EXACT
|
|
24980
25003
|
};
|
|
24981
25004
|
}
|
|
24982
25005
|
function createSeparatorParagraph(ctx, row, element, x, rowY2, zone, options) {
|
|
@@ -25028,6 +25051,12 @@ function createLineImage(width, height, color, dashArray) {
|
|
|
25028
25051
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
25029
25052
|
return bytes;
|
|
25030
25053
|
}
|
|
25054
|
+
function endWithParagraph(children) {
|
|
25055
|
+
if (children[children.length - 1] instanceof import_docx2.Table) {
|
|
25056
|
+
children.push(createSpacerParagraph(false));
|
|
25057
|
+
}
|
|
25058
|
+
return children;
|
|
25059
|
+
}
|
|
25031
25060
|
function createSpacerParagraph(pageBreakBefore, height = 0) {
|
|
25032
25061
|
return new import_docx2.Paragraph({
|
|
25033
25062
|
pageBreakBefore,
|
|
@@ -25070,7 +25099,7 @@ async function serializeTable(ctx, element, position, zone) {
|
|
|
25070
25099
|
);
|
|
25071
25100
|
cells.push(
|
|
25072
25101
|
new import_docx2.TableCell({
|
|
25073
|
-
children: cellChildren.length ? cellChildren : [createSpacerParagraph(false)],
|
|
25102
|
+
children: cellChildren.length ? endWithParagraph(cellChildren) : [createSpacerParagraph(false)],
|
|
25074
25103
|
columnSpan: td.colspan > 1 ? td.colspan : void 0,
|
|
25075
25104
|
rowSpan: td.rowspan > 1 ? td.rowspan : void 0,
|
|
25076
25105
|
width: { size: pxTw(td.width), type: import_docx2.WidthType.DXA },
|