Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/spreadsheet/preview: fix font height
Adorian Dorandcbdaf10f4ec
diff --git a/packages/commons/src/lib/spreadsheet/render_to_html.spec.ts b/packages/commons/src/lib/spreadsheet/render_to_html.spec.tsindex e2dd21418e..03b84c49eb 100644--- a/packages/commons/src/lib/spreadsheet/render_to_html.spec.ts+++ b/packages/commons/src/lib/spreadsheet/render_to_html.spec.ts@@ -585,7 +585,7 @@ describe("renderSpreadsheetToHtml", () => {}// An untouched cell keeps the box that only caps it, so its own alignment still places it.- expect(rotated(0)).toContain(`<span style="display:block;overflow:hidden;max-height:22px">`);+ expect(rotated(0)).toContain(`<span style="display:block;overflow:hidden;max-height:22px;line-height:normal">`);});it("leaves a cell unwrapped when it has no rotation to apply", () => {@@ -1396,7 +1396,7 @@ describe("renderSpreadsheetToHtml", () => {expect(html).toContain("<td></td>");expect(unboxed(html)).toContain("<td>C</td>");// A may run across the empty column, so its text carries the room it has.- expect(html).toContain(`<td style="padding:0px 2px 2px 2px"><span style="display:block;overflow:hidden;max-height:22px;width:calc(100% + 88px);margin-right:-88px">A</span></td>`);+ expect(html).toContain(`<td style="padding:0px 2px 2px 2px"><span style="display:block;overflow:hidden;max-height:22px;width:calc(100% + 88px);margin-right:-88px;line-height:normal">A</span></td>`);});it("renders numeric cell values", () => {diff --git a/packages/commons/src/lib/spreadsheet/render_to_html.ts b/packages/commons/src/lib/spreadsheet/render_to_html.tsindex 109d4eb10f..f000bb6c40 100644--- a/packages/commons/src/lib/spreadsheet/render_to_html.ts+++ b/packages/commons/src/lib/spreadsheet/render_to_html.ts@@ -639,6 +639,13 @@ function cellShownAt(col: number, neighbours: RowNeighbours): ICellData | undefireturn info?.kind === "member" ? cellData[info.anchorRow]?.[info.anchorColumn] : cellData[row]?.[col];}+/**+ * A cell's text is laid out on the font's own leading, as the editor lays it out. The page around it+ * sets a line height for prose, which is taller than a spreadsheet row expects and pushes the text+ * out of the bottom of a box measured from the row.+ */+const CELL_LINE_HEIGHT = "line-height:normal";+/*** Wraps a cell's text in the box that fixes its size. An HTML row grows to whatever it holds, while* a spreadsheet row is exactly as tall as it says and clips what does not fit, so without this the@@ -656,6 +663,7 @@ function cellBox(html: string, bound: SpillBound | null, height: number): stringif (bound.before) parts.push(`margin-left:${px(-bound.before)}px`);if (bound.after) parts.push(`margin-right:${px(-bound.after)}px`);}+ parts.push(CELL_LINE_HEIGHT);return `<span style="${parts.join(";")}">${html}</span>`;}@@ -693,6 +701,7 @@ function turnedBox(html: string, height: number, style: IStyleData | null): stri`justify-content:${turnedJustify(style)}`];if (height > 0) parts.push(`height:${px(height)}px`);+ parts.push(CELL_LINE_HEIGHT);return `<span style="${parts.join(";")}">${html}</span>`;}