Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Show one Alert styling target in Markdown Embed (#6411)
Oleg Isonend6c1a3c76370
diff --git a/packages/sdk-components-react/src/__generated__/markdown-embed.stories.tsx b/packages/sdk-components-react/src/__generated__/markdown-embed.stories.tsxindex 292b991b75..c8caee31f2 100644--- a/packages/sdk-components-react/src/__generated__/markdown-embed.stories.tsx+++ b/packages/sdk-components-react/src/__generated__/markdown-embed.stories.tsx@@ -5,7 +5,7 @@ const Component = () => {<Box className={`w-box`}><MarkdownEmbedcode={- '# Styling Markdown with Markdown Embed\n\nMarkdown Embed allows styling of Markdown, which primarily comes from external data.\n\n## How to Use Markdown Embed\n\n- Every element is shown in the Navigator.\n- Apply styles and Tokens to each element.\n- Adjustments to elements apply universally within this embed, ensuring consistency across your content.\n\n---\n\n## This sample text contains all the elements that can be styled.\n\nAny elements that were not used above are used below.\n\n### Heading 3\n#### Heading 4\n##### Heading 5\n###### Heading 6\n\n[Links](#) connect your content to relevant resources.\n\n**Bold text** makes your important points stand out.\n\n*Italic text* is great for emphasizing terms.\n\n1. First Step\n2. Second Step\n\n\n\n> Capture attention with a powerful quote.\n\n> [!NOTE]\n> Add helpful context without interrupting the main content.\n\n> [!TIP]\n> Share a useful suggestion.\n\n> [!IMPORTANT]\n> Highlight essential information.\n\n> [!WARNING]\n> Point out something readers should be careful about.\n\n> [!CAUTION]\n> Explain a potential negative consequence.\n\nUsing `console.log("Hello World");` will log to the console.\n\n| Header 1 | Header 2 | Header 3 |\n|------------|------------|------------|\n| Cell 1.1 | Cell 1.2 | Cell 1.3 |\n| Cell 2.1 | Cell 2.2 | Cell 2.3 |\n| Cell 3.1 | Cell 3.2 | Cell 3.3 |'+ '# Styling Markdown with Markdown Embed\n\nMarkdown Embed allows styling of Markdown, which primarily comes from external data.\n\n## How to Use Markdown Embed\n\n- Every element is shown in the Navigator.\n- Apply styles and Tokens to each element.\n- Adjustments to elements apply universally within this embed, ensuring consistency across your content.\n\n---\n\n## This sample text contains all the elements that can be styled.\n\nAny elements that were not used above are used below.\n\n### Heading 3\n#### Heading 4\n##### Heading 5\n###### Heading 6\n\n[Links](#) connect your content to relevant resources.\n\n**Bold text** makes your important points stand out.\n\n*Italic text* is great for emphasizing terms.\n\n1. First Step\n2. Second Step\n\n\n\n> Capture attention with a powerful quote.\n\n> [!NOTE]\n> Add helpful context without interrupting the main content.\n\nUsing `console.log("Hello World");` will log to the console.\n\n| Header 1 | Header 2 | Header 3 |\n|------------|------------|------------|\n| Cell 1.1 | Cell 1.2 | Cell 1.3 |\n| Cell 2.1 | Cell 2.2 | Cell 2.3 |\n| Cell 3.1 | Cell 3.2 | Cell 3.3 |'}className={`w-markdown-embed w-alert`}></MarkdownEmbed>diff --git a/packages/sdk-components-react/src/alert-template.test.ts b/packages/sdk-components-react/src/alert-template.test.tsindex 12474ff138..f3ac8c4a51 100644--- a/packages/sdk-components-react/src/alert-template.test.ts+++ b/packages/sdk-components-react/src/alert-template.test.ts@@ -16,6 +16,14 @@ const getVariantBackgroundStates = ({ template }: TemplateMeta) =>.styles.filter(({ property }) => property === "backgroundColor").map(({ state }) => state);+const getAlertDescendantLabels = ({ template }: TemplateMeta) =>+ renderTemplate(template, undefined, [], { componentIds })+ .instances.filter(+ ({ component, label }) =>+ component === "ws:descendant" && label?.toLowerCase().includes("alert")+ )+ .map(({ label }) => label);+test("provides light backgrounds for every Markdown Embed alert variant", () => {expect(getVariantBackgroundStates(MarkdownEmbed)).toEqual(['[data-state="note"]',@@ -25,3 +33,7 @@ test("provides light backgrounds for every Markdown Embed alert variant", () =>'[data-state="caution"]',]);});++test("exposes alerts as one Markdown Embed descendant", () => {+ expect(getAlertDescendantLabels(MarkdownEmbed)).toEqual(["Alert"]);+});diff --git a/packages/sdk-components-react/src/markdown-embed.template.tsx b/packages/sdk-components-react/src/markdown-embed.template.tsxindex 5bee17171c..624f539c13 100644--- a/packages/sdk-components-react/src/markdown-embed.template.tsx+++ b/packages/sdk-components-react/src/markdown-embed.template.tsx@@ -42,18 +42,6 @@ Any elements that were not used above are used below.> [!NOTE]> Add helpful context without interrupting the main content.-> [!TIP]-> Share a useful suggestion.--> [!IMPORTANT]-> Highlight essential information.--> [!WARNING]-> Point out something readers should be careful about.--> [!CAUTION]-> Explain a potential negative consequence.-Using \`console.log("Hello World");\` will log to the console.| Header 1 | Header 2 | Header 3 |@@ -86,20 +74,6 @@ export const meta: TemplateMeta = {selector=" [data-state]"ws:style={markdownAlertStyle}/>- <ws.descendant ws:label="Note alert" selector={' [data-state="note"]'} />- <ws.descendant ws:label="Tip alert" selector={' [data-state="tip"]'} />- <ws.descendant- ws:label="Important alert"- selector={' [data-state="important"]'}- />- <ws.descendant- ws:label="Warning alert"- selector={' [data-state="warning"]'}- />- <ws.descendant- ws:label="Caution alert"- selector={' [data-state="caution"]'}- /><ws.descendant ws:label="Code Text" selector=" code" /><ws.descendant ws:label="List" selector=" :where(ul, ol)" /><ws.descendant ws:label="List Item" selector=" li" />