steven-tey / novel

Notion-style WYSIWYG editor with AI-powered autocompletion.
https://novel.sh
Apache License 2.0
12.47k stars 1.03k forks source link

How can I make custom attrs parse into html tag? #264

Closed mrunhap closed 8 months ago

mrunhap commented 8 months ago

For example, I have this content:

{
    "type": "heading",
    "attrs": {
        "level": 2,
        "some-custom-attr":"foo"
    },
    "content": [
        {
            "attrs": { "other-custom-attr":"bar"},
            "type": "text",
            "text": "level2 heading"
        }
    ]
}

I want some-custom-attr or other-custom-attr can be seen in html tag(I don't know how to describe this since I'm not a frontend developer), maybe like:

<h2 some-custom-attrr="foo">
level2 heading
</h2>

or

<h2 other-custom-attrr="foo">
level2 heading
</h2>