Skip to content
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

Merged
merged 8 commits into from
Jan 9, 2022
Merged

Save field as json proposal #47

merged 8 commits into from
Jan 9, 2022

Conversation

OpJePl44tsm4n
Copy link
Contributor

@OpJePl44tsm4n OpJePl44tsm4n commented Nov 23, 2021

js not build...

@OpJePl44tsm4n
Copy link
Contributor Author

Hi!

Thanx for building this package! made a little proposal to add functionality to save the tiptap content as json instead of HTML.

cheers!

@manogi
Copy link
Owner

manogi commented Nov 26, 2021

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?

@OpJePl44tsm4n
Copy link
Contributor Author

OpJePl44tsm4n commented Nov 26, 2021 via email

@OpJePl44tsm4n
Copy link
Contributor Author

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,

@manogi
Copy link
Owner

manogi commented Jan 9, 2022

Hi Timothé, thanks for editing the PR. I will merge it with a small change: the saveAsJson() method now requires no parameter. I think it should better work like the nullable() method or this package's own syntaxHighlighting() method, which simply turn on the feature when the method is called.

The new feature will be part of the 2.6.0 release coming in a few minutes.

Thanks again, Sebastian

@manogi manogi merged commit 346a838 into manogi:master Jan 9, 2022
@OpJePl44tsm4n OpJePl44tsm4n deleted the saveAsJson branch January 10, 2022 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants