Skip to content

Commit

Permalink
feat(designer-ui): Allow makers to use class attributes and table
Browse files Browse the repository at this point in the history
… styling in raw HTML (#5000)

* Allow `class` attributes and `table` styling

* Update unit tests
  • Loading branch information
ek68794998 committed Jun 20, 2024
1 parent 17bedd4 commit 3446119
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,28 @@ describe('lib/html/plugins/toolbar/helper/util', () => {
describe('isAttributeSupportedByHtmlEditor', () => {
it.each<[string, string, boolean]>([
['', 'href', false],
['a', 'class', true],
['a', '', false],
['a', 'href', true],
['a', 'id', true],
['a', 'style', true],
['span', 'class', true],
['span', 'cellpadding', false],
['span', 'href', false],
['span', 'id', true],
['span', 'style', true],
['p', 'class', true],
['p', 'cellpadding', false],
['p', 'href', false],
['p', 'id', true],
['p', 'style', true],
['img', 'class', true],
['img', 'id', true],
['img', 'alt', true],
['img', 'script', false],
['img', 'src', true],
['table', 'class', true],
['table', 'cellpadding', true],
])('should return <%s %s="..." /> as supported=%p', (inputTag, inputAttr, expected) => {
expect(isAttributeSupportedByHtmlEditor(inputTag, inputAttr)).toBe(expected);
});
Expand Down
3 changes: 2 additions & 1 deletion libs/designer-ui/src/lib/html/plugins/toolbar/helper/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ const lexicalSupportedTagNames = new Set([
'ul',
]);
const htmlEditorSupportedAttributes: { '*': string[] } & Record<string, string[]> = {
'*': ['id', 'style'],
'*': ['class', 'id', 'style'],
a: ['href'],
img: ['alt', 'src'],
table: ['border', 'cellpadding', 'cellspacing'],
};

export interface Position {
Expand Down

0 comments on commit 3446119

Please sign in to comment.