Skip to content
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
34 changes: 34 additions & 0 deletions apps/builder/app/shared/content-model.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,40 @@ test("support xml node with tags", () => {
).toBeTruthy();
});

test("support headings inside of summary", () => {
expect(
isTreeSatisfyingContentModel({
...renderData(
<ws.element ws:tag="body" ws:id="bodyId">
<ws.element ws:tag="details">
<ws.element ws:tag="summary">
<ws.element ws:tag="h3"></ws.element>
</ws.element>
</ws.element>
</ws.element>
),
metas: defaultMetas,
instanceSelector: ["bodyId"],
})
).toBeTruthy();
});

test("support links inside of details", () => {
expect(
isTreeSatisfyingContentModel({
...renderData(
<ws.element ws:tag="body" ws:id="bodyId">
<ws.element ws:tag="details">
<ws.element ws:tag="a"></ws.element>
</ws.element>
</ws.element>
),
metas: defaultMetas,
instanceSelector: ["bodyId"],
})
).toBeTruthy();
});

describe("component content model", () => {
test("restrict children with specific component", () => {
expect(
Expand Down
18 changes: 17 additions & 1 deletion packages/html-data/bin/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,30 @@ const elementsByTag: Record<string, Element> = {};
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
// introduce fake value attribute to manage initial state similar to input
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,
Expand Down
16 changes: 8 additions & 8 deletions packages/html-data/src/__generated__/elements.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.