-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save field as json proposal #47
Conversation
js not build
Hi! Thanx for building this package! made a little proposal to add functionality to save the tiptap content as json instead of HTML. cheers! |
Hi there, thanks for the PR. I will merge this if you solve the following: the JSON.parse method ist pretty strict, so it throws an error if the content was already set to something other than JSON (like an HTML string) or if the content is empty. The "empty" problem is easily solved. You will also need to solve the problem that someone switches to this after having already used the HTML version. Maybe this helps, you could check the content and if it is HTML you could use this to convert it: https://github.com/ueberdosis/html-to-prosemirror I noticed that you did not add any JS to the PR - did you remove your scripts, or did you not run "npm run development" or "npm run production" and test the PR? |
Hi Sebastian,
Thanks for the feedback. I did the build on a local dev and got it working,
after which I decided to make a quick pr just to check if you would agree.
Tiptap, has a nice feature build in to get the content as HTML or JSON so
transforming won't be an issue. I'll build in some checks and test out the
different scenarios. I'll finnish it up later and update the PR. Keep
up the good work!
Cheers,
Pim
…On Fri, 26 Nov 2021, 09:35 Sebastian Hilger, ***@***.***> wrote:
Hi there, thanks for the PR. I will merge this if you solve the following:
the JSON.parse method ist pretty strict, so it throws an error if the
content was already set to something other than JSON (like an HTML string)
or if the content is empty. The "empty" problem is easily solved. You will
also need to solve the problem that someone switches to this after having
already used the HTML version. Maybe this helps, you could check the
content and if it is HTML you could use this to convert it:
https://github.com/ueberdosis/html-to-prosemirror
I noticed that you did not add any JS to the PR - did you remove your
scripts, or did you not run "npm run development" or "npm run production"
and test the PR?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#47 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMGBW4ZRJG5DGMW5IGQUOTUN5BGJANCNFSM5ITSPVLA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
HTML wil get saved as json with onUpdate()
Hi Sebastian, I just got the time to finish this, I make use of the setContent() tiptap function to set the value. The oncreate() function does a check if the field value is Json , if so it's parsed and set as content. If the content is HTML and someone switches the result will be saved as json on update. Cheers, |
Hi Timothé, thanks for editing the PR. I will merge it with a small change: the The new feature will be part of the 2.6.0 release coming in a few minutes. Thanks again, Sebastian |
js not build...