Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type of EnrichedBlockCode #4299

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion db/model/Gdoc/enrichedToMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ ${items}
)
.with({ type: "code" }, (b): string | undefined => {
return (
"```\n" + b.text.map((text) => text.value).join("\n") + "\n```"
"```\n" +
b.text.map((text) => text.value.text).join("\n") +
"\n```"
)
})
.with({ type: "donors" }, (_): string | undefined =>
Expand Down
5 changes: 4 additions & 1 deletion db/model/Gdoc/enrichedToRaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export function enrichedBlockToRawBlock(
{ type: "code" },
(b): RawBlockCode => ({
type: b.type,
value: b.text,
value: b.text.map((text) => ({
type: "text",
value: text.value.text,
})),
})
)
.with(
Expand Down
8 changes: 6 additions & 2 deletions db/model/Gdoc/exampleEnrichedBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ export const enrichedBlockExamples: Record<
type: "code",
text: [
{
type: "text",
value: '<iframe src="https://ourworldindata.org/grapher/children-per-woman-un?region=Africa&tab=map" loading="lazy" style="width: 100%; height: 600px; border: 0px none;" allow="web-share; clipboard-write"></iframe>',
type: "simple-text",
value: {
spanType: "span-simple-text",
text: '<iframe src="https://ourworldindata.org/grapher/children-per-woman-un?region=Africa&tab=map" loading="lazy" style="width: 100%; height: 600px; border: 0px none;" allow="web-share; clipboard-write"></iframe>',
},
parseErrors: [],
},
],
parseErrors: [],
Expand Down
8 changes: 6 additions & 2 deletions db/model/Gdoc/rawToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,12 @@ const parseCode = (raw: RawBlockCode): EnrichedBlockCode => {
return {
type: "code",
text: raw.value.map((text) => ({
type: "text",
value: toAsciiQuotes(text.value),
type: "simple-text",
value: {
spanType: "span-simple-text",
text: toAsciiQuotes(text.value),
},
parseErrors: [],
})),
parseErrors: [],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export type RawBlockCode = {

export type EnrichedBlockCode = {
type: "code"
text: RawBlockText[]
text: EnrichedBlockSimpleText[]
} & EnrichedBlockWithParseErrors

export type RawBlockDonorList = {
Expand Down Expand Up @@ -366,6 +366,7 @@ export type EnrichedBlockSimpleText = {
type: "simple-text"
value: SpanSimpleText
} & EnrichedBlockWithParseErrors

export type RawBlockHtml = {
type: "html"
value: string
Expand Down
2 changes: 1 addition & 1 deletion site/gdocs/components/ArticleBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default function ArticleBlock({
.with({ type: "code" }, (block) => (
<CodeSnippet
className={getLayout("code-snippet", containerType)}
code={block.text.map((text) => text.value).join("\n")}
code={block.text.map((text) => text.value.text).join("\n")}
/>
))
.with({ type: "donors" }, (_block) => (
Expand Down
Loading