diff --git a/resources/views/components/menus/default-floating-menu.blade.php b/resources/views/components/menus/default-floating-menu.blade.php
index 435e1eb3..3bcbdd85 100644
--- a/resources/views/components/menus/default-floating-menu.blade.php
+++ b/resources/views/components/menus/default-floating-menu.blade.php
@@ -2,6 +2,7 @@
'statePath' => null,
'tools' => [],
'blocks' => [],
+ 'shouldSupportBlocks' => false,
])
@@ -12,5 +13,5 @@
@if (in_array('table', $tools)) @endif
@if (in_array('oembed', $tools)) @endif
@if (in_array('code-block', $tools)) @endif
- @if (in_array('blocks', $tools) && $blocks) @endif
+ @if ($blocks && $shouldSupportBlocks) @endif
diff --git a/resources/views/tiptap-editor.blade.php b/resources/views/tiptap-editor.blade.php
index b6469a7f..bf2ab0ea 100644
--- a/resources/views/tiptap-editor.blade.php
+++ b/resources/views/tiptap-editor.blade.php
@@ -108,7 +108,7 @@ class="relative z-0 tiptap-wrapper rounded-md bg-white dark:bg-gray-900"
@endif
@if (! $isFloatingMenusDisabled() && filled($floatingMenuTools))
-
+
@endif
diff --git a/src/TiptapEditor.php b/src/TiptapEditor.php
index dc77e2c2..fb14f798 100644
--- a/src/TiptapEditor.php
+++ b/src/TiptapEditor.php
@@ -50,7 +50,7 @@ protected function setUp(): void
$this->tools = config('filament-tiptap-editor.profiles.default');
$this->extensions = config('filament-tiptap-editor.extensions') ?? [];
- $this->afterStateHydrated(function (TiptapEditor $component, string | array | null $state) {
+ $this->afterStateHydrated(function (TiptapEditor $component, string | array | null $state): void {
if (! $state) {
if ($this->expectsJSON()) {
@@ -64,27 +64,29 @@ protected function setUp(): void
if ($this->getBlocks() && $this->expectsJSON()) {
$state = $this->renderBlockPreviews($state, $component);
} elseif ($this->expectsText()) {
- $state = $this->getText();
+ $state = tiptap_converter()->asText($state);
+ } elseif ($this->expectsHTML()) {
+ $state = tiptap_converter()->asHTML($state);
}
$component->state($state);
});
- $this->afterStateUpdated(function (TiptapEditor $component, Component $livewire) {
+ $this->afterStateUpdated(function (TiptapEditor $component, Component $livewire): void {
$livewire->validateOnly($component->getStatePath());
});
- $this->dehydrateStateUsing(function (TiptapEditor $component, string | array | null $state) {
+ $this->dehydrateStateUsing(function (TiptapEditor $component, string | array | null $state): string | array | null {
if ($state && $this->expectsJSON()) {
return $this->decodeBlocksBeforeSave($state);
}
if ($state && $this->expectsText()) {
- return $component->getText();
+ return tiptap_converter()->asText($state);
}
- return $state;
+ return tiptap_converter()->asHTML($state);
});
$this->registerListeners([
diff --git a/tests/src/FormsTest.php b/tests/src/FormsTest.php
index 550ec87b..376e94b6 100644
--- a/tests/src/FormsTest.php
+++ b/tests/src/FormsTest.php
@@ -2,6 +2,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
+use FilamentTiptapEditor\Enums\TiptapOutput;
use FilamentTiptapEditor\Tests\Models\Page;
use FilamentTiptapEditor\Tests\Fixtures\Livewire as LivewireFixture;
use FilamentTiptapEditor\Tests\Resources\PageResource\Pages\CreatePage;
@@ -76,11 +77,12 @@ public function form(Form $form): Form
->model(Page::class)
->schema([
TextInput::make('title'),
- TiptapEditor::make('html_content'),
+ TiptapEditor::make('html_content')
+ ->output(TiptapOutput::Html),
TiptapEditor::make('json_content')
- ->output(\FilamentTiptapEditor\Enums\TiptapOutput::Json),
+ ->output(TiptapOutput::Json),
TiptapEditor::make('text_content')
- ->output(\FilamentTiptapEditor\Enums\TiptapOutput::Text),
+ ->output(TiptapOutput::Text),
]);
}
diff --git a/tests/src/Resources/PageResource.php b/tests/src/Resources/PageResource.php
index 65ac19fc..a0dc01f1 100644
--- a/tests/src/Resources/PageResource.php
+++ b/tests/src/Resources/PageResource.php
@@ -23,7 +23,8 @@ public static function form(Form $form): Form
return $form
->schema([
Forms\Components\TextInput::make('title'),
- TiptapEditor::make('html_content'),
+ TiptapEditor::make('html_content')
+ ->output(TiptapOutput::Html),
TiptapEditor::make('json_content')
->output(TiptapOutput::Json),
TiptapEditor::make('text_content')