steven-tey / novel

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

feat: Convert the content in an Editor to a Notion Page #336

Open shenli opened 8 months ago

shenli commented 8 months ago

Describe the feature you'd like to request

Hello, I would like to create a new page in my Notion according to the content in the editor. May I know what is the best way to do this? Thanks! https://developers.notion.com/reference/page

Describe the solution you'd like to see

Have a function to convert the data in an editor to a JSON structure which can not used to create a Notion page.

Additional information

    "children": [
        {
            "object": "block",
            "heading_2": {
                "rich_text": [
                    {
                        "text": {
                            "content": "Lacinato kale"
                        }
                    }
                ]
            }
        },
        {
            "object": "block",
            "paragraph": {
                "rich_text": [
                    {
                        "text": {
                            "content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
                            "link": {
                                "url": "https://en.wikipedia.org/wiki/Lacinato_kale"
                            }
                        },
                        "href": "https://en.wikipedia.org/wiki/Lacinato_kale"
                    }
                ],
                "color": "default"
            }
        }
    ]
shenli commented 8 months ago

I find a simple way to do this: https://gist.github.com/shenli/57cfd7f211dbd45fc78b1177d9fdf269 Tested with some simple cases, it works.