Skip to content

Commit

Permalink
chore: add test case(converting the html block which has "=" attr value)
Browse files Browse the repository at this point in the history
  • Loading branch information
js87zz committed Jul 6, 2021
1 parent 5aef309 commit d5d6c56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions apps/editor/src/__test__/unit/convertor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,13 @@ describe('Convertor', () => {
assertConverting(markdown, markdown);
});

it('should convert html block element which has "=" character as the attribute value', () => {
const markdown =
'<iframe width="420" height="315" src="//player.bilibili.com/player.html?aid=588782532&bvid=BV1hB4y1K7ro&cid=360826679&page=1"></iframe>';

assertConverting(markdown, markdown);
});

it('should convert html inline node', () => {
const markdown = '<big class="my-big">content</big>';

Expand Down
6 changes: 3 additions & 3 deletions apps/editor/src/wysiwyg/nodes/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export function getHTMLAttrsByHTMLString(html: string) {

return attrs
? attrs.reduce<Record<string, string | null>>((acc, attr) => {
const [name, ...value] = attr.trim().split('=');
const [name, ...values] = attr.trim().split('=');

if (value.length > 0) {
acc[name] = value.join('=').replace(/'|"/g, '').trim();
if (values.length) {
acc[name] = values.join('=').replace(/'|"/g, '').trim();
}

return acc;
Expand Down

0 comments on commit d5d6c56

Please sign in to comment.