Editor component to have "as JSON" prop #2063
Replies: 3 comments 4 replies
-
|
Side note: if anyone is wanting to get this up and running in your own app, check out https://www.martyfriedel.com/blog/making-the-livewire-flux-editor-component-return-json-instead-of-html (and thanks to Josh too!) Be great to see it as trivial as a prop - but in the meantime it is still do-able. |
Beta Was this translation helpful? Give feedback.
-
|
See this request as well #742 with @jacksleight reply:
|
Beta Was this translation helpful? Give feedback.
-
|
i'va managed to make it work, the solution is a bit "hacky" and I don't like it... but it works for now 🤷♂️. You need to remove the wire:model directive from the editor and add a hidden input field with it: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently the Editor returns its content as HTML. Tiptap can, however, also return it as JSON.
It would be superb to have this as a prop to toggle its output.
The getter for the component is currently returning either
nullor HTML using the editor'sgetHTMLhelper.For JSON, this would need to be adjusted to return
[](instead of null) and the JSON using the editor'sgetJSONhelper.One of the biggest strengths is that it makes it more trivial to work alongside Statamic, having both backend content (in Statamic's CP using their Bard fieldtype, built on Tiptap) and front end content (driven by Flux's Editor component) more effortlessly compatible.
Better yet, given we can extend Flux's Editor ourselves, it is possible to create extensions for Tiptap that mimic the structured markup of Bard's Sets in Statamic world. I've done this on a non-Flux project using an Alpine build of Tiptap, and is game changing for front end authoring for Statamic-based apps.
(Note, for Statamic devs, there's an additional wrapper that the getJSON includes that needs to be trimmed for full compatibility, but that's a dev problem not a Flux issue. The huge benefit is interoperability between Bard and Flux's editor).
Beta Was this translation helpful? Give feedback.
All reactions