Skip to content

Commit d751d49

Browse files
authored
Fix links and embedded YouTube videos in BoxEmbed (#2274)
make links and embedded YouTube videos render correctly inside boxEmbed
1 parent f01c7ef commit d751d49

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

components/embeds/boxEmbed.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { TinaMarkdown } from "tinacms/dist/rich-text";
66
import { toolbarFields } from "@/tina/collection/shared/toolbarFields";
77
import MarkdownComponentMapping from "../tina-markdown/markdown-component-mapping";
88
import { Figure, inlineFigureDefaultItem, inlineFigureFields } from "./figure";
9+
import { youtubeEmbedTemplate } from "./youtubeEmbed";
10+
import { imageEmbedTemplate } from "./imageEmbed";
911

1012
type BoxVariant = "greybox" | "info" | "todo" | "china" | "codeauditor" | "highlight" | "warning" | "tips";
1113

@@ -88,19 +90,14 @@ export function BoxEmbed(props: any) {
8890
const figure: string = data?.figure || "";
8991
const figurePrefix: any = data?.figurePrefix || "none";
9092

91-
const components = {
92-
...MarkdownComponentMapping,
93-
a: ({ children }: any) => <span>{children}</span>,
94-
};
95-
9693
return (
9794
<>
9895
<div className={`p-4 rounded-sm my-4 ${config.containerClass}`}>
9996
<div className="flex items-start">
10097
{config.icon}
10198
<div className={`[&_p:last-child]:mb-0 ${config.textClass ?? ""}`}>
10299
<div>
103-
<TinaMarkdown content={data.body} components={components} />
100+
<TinaMarkdown content={data.body} components={MarkdownComponentMapping} />
104101
</div>
105102
</div>
106103
</div>
@@ -148,6 +145,7 @@ export const boxEmbedTemplate: Template = {
148145
label: "Body",
149146
type: "rich-text",
150147
toolbarOverride: toolbarFields,
148+
templates: [youtubeEmbedTemplate, imageEmbedTemplate],
151149
},
152150
...(inlineFigureFields as any),
153151
],

tina/tina-lock.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)