Skip to content

Commit ddab4dc

Browse files
committed
Updated code block PDF conversion and styling
1 parent 50b1328 commit ddab4dc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • packages/xl-pdf-exporter/src/pdf/defaultSchema

packages/xl-pdf-exporter/src/pdf/defaultSchema/blocks.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
114114
);
115115
},
116116
codeBlock: (block) => {
117-
const textContent = (block.content as StyledText<any>[])[0]?.text || "";
117+
// Code blocks should always contain a single `StyledText` inline content.
118+
// However, if this is not the case for whatever reason, we can merge the
119+
// text content of all `StyledText` content in them.
120+
const textContent = (block.content as StyledText<any>[])
121+
.map((item) => item.text)
122+
.join("");
118123
const lines = textContent.split("\n").map((line, index) => {
119124
const indent = line.match(/^\s*/)?.[0].length || 0;
120125

@@ -135,8 +140,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
135140
wrap={false}
136141
style={{
137142
padding: 24 * PIXELS_PER_POINT,
138-
backgroundColor: "#161616",
139-
color: "#ffffff",
143+
border: "1px solid #000000",
140144
lineHeight: 1.25,
141145
fontSize: FONT_SIZE * PIXELS_PER_POINT,
142146
fontFamily: "GeistMono",

0 commit comments

Comments
 (0)