diff --git a/apps/builder/app/shared/content-model.test.tsx b/apps/builder/app/shared/content-model.test.tsx index 8f6ec62bce38..a0d4d09453a1 100644 --- a/apps/builder/app/shared/content-model.test.tsx +++ b/apps/builder/app/shared/content-model.test.tsx @@ -521,6 +521,40 @@ test("support xml node with tags", () => { ).toBeTruthy(); }); +test("support headings inside of summary", () => { + expect( + isTreeSatisfyingContentModel({ + ...renderData( + + + + + + + + ), + metas: defaultMetas, + instanceSelector: ["bodyId"], + }) + ).toBeTruthy(); +}); + +test("support links inside of details", () => { + expect( + isTreeSatisfyingContentModel({ + ...renderData( + + + + + + ), + metas: defaultMetas, + instanceSelector: ["bodyId"], + }) + ).toBeTruthy(); +}); + describe("component content model", () => { test("restrict children with specific component", () => { expect( diff --git a/packages/html-data/bin/elements.ts b/packages/html-data/bin/elements.ts index f04ac57fc1d6..972ff0acc401 100644 --- a/packages/html-data/bin/elements.ts +++ b/packages/html-data/bin/elements.ts @@ -45,7 +45,15 @@ const elementsByTag: Record = {}; return !tag.includes(" "); }); const description = getTextContent(row.childNodes[1]); - const categories = parseList(getTextContent(row.childNodes[2])); + let categories = parseList(getTextContent(row.childNodes[2])).map( + (item) => { + if (item === "heading") { + // legend and summary refer to it as heading content + return "heading content"; + } + return item; + } + ); let children = parseList(getTextContent(row.childNodes[4])); for (const tag of elements) { // textarea does not have value attribute and text content is used as initial value @@ -53,6 +61,14 @@ const elementsByTag: Record = {}; if (tag === "textarea") { children = []; } + // move interactive category from details to summary + // so details content could accept other interactive elements + if (tag === "details") { + categories = categories.filter((item) => item !== "interactive"); + } + if (tag === "summary") { + categories.push("interactive"); + } elementsByTag[tag] = { description, categories, diff --git a/packages/html-data/src/__generated__/elements.ts b/packages/html-data/src/__generated__/elements.ts index be27fde09740..14daffa58d81 100644 --- a/packages/html-data/src/__generated__/elements.ts +++ b/packages/html-data/src/__generated__/elements.ts @@ -142,7 +142,7 @@ export const elementsByTag: Record = { }, details: { description: "Disclosure control for hiding details", - categories: ["flow", "interactive", "palpable"], + categories: ["flow", "palpable"], children: ["summary", "flow"], }, dfn: { @@ -209,32 +209,32 @@ export const elementsByTag: Record = { }, h1: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, h2: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, h3: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, h4: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, h5: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, h6: { description: "Heading", - categories: ["flow", "heading", "palpable"], + categories: ["flow", "heading content", "palpable"], children: ["phrasing"], }, head: { @@ -535,7 +535,7 @@ export const elementsByTag: Record = { }, summary: { description: "Caption for details", - categories: ["none"], + categories: ["none", "interactive"], children: ["phrasing", "heading content"], }, sup: {