steven-tey / novel

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

feat: Allow Markdown and Html in InitialContent #405

Open fedjabosnic opened 1 month ago

fedjabosnic commented 1 month ago

Describe the feature you'd like to request

I'd like to set initial content to Markdown or Html in string form, received over the wire. At present, the Novel Editor only allows JSONContent to be passed into initialContent and there is no easy facility to convert. This makes it very hard to work with HTML and MD content directly, especially in string form..

Describe the solution you'd like to see

Looking at the types in the core TipTap library, it seems that we can use the union type Content - or even define a union type ourselves. I'm not sure if there are some roadblocks in the codebase but this would allow us to pass any supported type of content to the editor...

CleanShot 2024-05-31 at 16 42 23@2x

Additional information

My use-case is simple, I want to edit content coming from an api call that is either Markdown or Html, and at the moment I can't really get this running. Admittedly I'm not super experienced in Next, React or TipTap so please let me know if there is a decent solution already

MODSetter commented 1 month ago

@fedjabosnic Markdown is not supported by Tiptap. I can look into making editor compatible with html. For your current use case you can see html updates in LocalStorage (key: "html-content").

jacobsamo commented 4 weeks ago

Would also love this feature as i want to store the content in my db as HTML or text