react-md-editor
react-md-editor copied to clipboard
Markdown content from Preview
Hi,
In my application, I am using markdown editor along with preview to create a markdown template which gets stored in the backend. This is fine.
In another part of my application, I just show the template content as preview where the editor and tool bar are hidden like below:
Now the users can check/uncheck the checkboxes or input some values in those text boxes which is fine.
But how do I get these updated changes done in the preview as raw markdown for me store in the backend?
Any help would be appreciated. Thank you!
@SundaramMaheshkumar You can define your own md syntax, such as <!--input:value=xxxx--!>
Define your own rehype plug-in to parse your grammar
@jaywcjlove
I am not sure whether I understand you properly.
Please find my codesandbox here.
In there, I have a button called Get content
after the preview. Ideally, I want to get the updated raw markdown content ( as there would be changes when users input in HTML text boxes or checkboxes) on onClick
of that button.
Currently, in that sandbox, I did a crude way of getting the raw HTML from the preview. But if I could get the markdown instead of processing the HTML, it would be great. But I couldn't figure out, how to achieve that!!!
Thanks.
@jaywcjlove
Any suggestion or idea of how to achieve the above? Thank you
Do you want to change the content, and then want to get the changed markdown content? @jaywcjlove
@jaywcjlove
I am not sure whether I understand you properly.
Please find my codesandbox here.
In there, I have a button called
Get content
after the preview. Ideally, I want to get the updated raw markdown content ( as there would be changes when users input in HTML text boxes or checkboxes) ononClick
of that button.Currently, in that sandbox, I did a crude way of getting the raw HTML from the preview. But if I could get the markdown instead of processing the HTML, it would be great. But I couldn't figure out, how to achieve that!!!
Thanks.
@jaywcjlove
As you see above images and in the sandbox, I type values in HTML text boxes or checkboxes in the preview. Yes, I wanted to get the markdown with these changes. In the sandbox, I did a crude way of getting the HTML and but am not sure how to get the changes in md format itself.
@SundaramMaheshkumar Storing it in HTML comments or HTML attributes might be a good idea, but you'll need to change the markdown content yourself.
@jaywcjlove
Thanks. I'll just use the HTML as the library supports pure HTML too. Because updating HTML and then updating markdown manually seems redundant.