Closed AngadSethi closed 9 months ago
@AngadSethi Did you cast your content as array in the model? Worked for me.
Yes, that works. Thanks @williamengbjerg!
The problem, however, is that this saves the content as an array of blocks, whereas all my other entries are HTML strings. So, to render the content
, I'll need to write some detection logic to convert the array-formatted entries to HTML, which, I think, can have multiple unintended side-effects.
This issue isn't really a high-priority one. I'll just lock the version, so everything's hunky-dory until this is fixed.
Personally I would write a command to go through my database and convert any existing html to json / array using the converter built into the plugin. Then for output you don't have to worry about it. On output you can use that same converter to output html where needed.
Will do, @awcodes. Thanks!
A tangential question, though: this isn't the intended behaviour, right?
If you want to use blocks it has to be stored as an array.
I think you might be misunderstanding what the output format is. It tells the code how to format the content coming out of the editor for saving it to the database, not the output from the db to your rendered view.
@awcodes, I can see that 3.1.0
adds support for custom blocks, but if I'm not using them, the returned result should stay the same, right?
Here's what I'm trying to do:
My content
form element is defined like this:
TiptapEditor::make("content")
->required()
->columnSpanFull()
->output(TiptapOutput::Html)
When I was on version 3.0.5
, the content
property of the data
array of this form would be a string, like:
"content" => "<p>This is a sample string</p>"
After updating to 3.1.2
, the same property, without any code change, is now an array:
"content" => [
"type" => "doc"
"content" => [
0 => [
"type" => "paragraph"
"attrs" => [
"textAlign" => "start"
"class" => null
]
"content" => [
0 => [
"type" => "text"
"text" => "This is a sample string."
]
]
]
]
]
I'm wondering if this is intentional? If there is, maybe there is some other way to force the editor to return HTML?
Are you casting the model's field as an array? It should only be storing arrays if you tell it to. Otherwise should be a sting of html. Make sure you're on 3.1.2 as well.
@awcodes, I'm not casting it as an array. I've also created a minimal reproducible example here: https://github.com/AngadSethi/tiptap-editor-replicate-error. Maybe this helps? Please do let me know if I'm going about this the wrong way
Here's the output of the editor:
The ArticleResource
is here: https://github.com/AngadSethi/tiptap-editor-replicate-error/blob/main/app/Filament/Resources/ArticleResource.php
Thanks @awcodes!
Filament Version
v3.0.97
Plugin Version
v3.1.2
PHP Version
PHP 8.1
Problem description
I have a simple Filament resource, with a TipTap editor. Creating a new resource was working fine earlier but upon upgrading to 3.1.2, no matter what
output
parameter I select it always returns anarray
. I have tried editing both the config option and using->output(\FilamentTiptapEditor\Enums\TiptapOutput::Html)
Can you please help out?
Expected behavior
Expected it to return valid HTML instead.
Steps to reproduce
Reproduction repository
No response
Relevant log output