Skip to content

Commit

Permalink
feat: Disable toolbar menus
Browse files Browse the repository at this point in the history
Allows to hide the toolbar for an even more minimalistic look.
  • Loading branch information
MtDalPizzol committed Dec 18, 2023
1 parent 84fae8e commit 17ac84e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/filament-tiptap-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,7 @@
*/
'disable_floating_menus' => false,
'disable_bubble_menus' => false,
'disable_toolbar_menus' => false,

'floating_menu_tools' => ['media', 'grid-builder', 'details', 'table', 'oembed', 'code-block', 'blocks'],
];
2 changes: 1 addition & 1 deletion resources/views/tiptap-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class="relative z-0 tiptap-wrapper rounded-md bg-white dark:bg-gray-900 focus-wi
x-on:delete-block.window="deleteBlock()"
x-trap.noscroll="fullScreenMode"
>
@if (! $isDisabled && $tools)
@if (! $isDisabled && ! $isToolbarMenusDisabled() && $tools)
<button type="button" x-on:click="editor().chain().focus()" class="z-20 rounded sr-only focus:not-sr-only focus:absolute focus:py-1 focus:px-3 focus:bg-white focus:text-gray-900">{{ __('filament-tiptap-editor::editor.skip_toolbar') }}</button>

<div class="tiptap-toolbar text-gray-800 border-b border-gray-950/10 bg-gray-50 divide-x divide-gray-950/10 rounded-t-md z-[1] relative flex flex-col md:flex-row dark:text-gray-300 dark:border-white/20 dark:bg-gray-950 dark:divide-white/20">
Expand Down
16 changes: 15 additions & 1 deletion src/Concerns/InteractsWithMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ trait InteractsWithMenus
protected array | Closure | null $floatingMenuTools = null;

protected ?bool $shouldShowBubbleMenus = null;

protected ?bool $shouldShowFloatingMenus = null;

protected ?bool $shouldShowToolbarMenus = null;

public function disableBubbleMenus(bool | Closure | null $condition = true): static
{
Expand All @@ -26,6 +28,13 @@ public function disableFloatingMenus(bool | Closure | null $condition = true): s
return $this;
}

public function disableToolbarMenus (bool | Closure | null $condition = true): static
{
$this->shouldShowToolbarMenus = $condition;

return $this;
}

public function floatingMenuTools(array | Closure $tools): static
{
$this->floatingMenuTools = $tools;
Expand Down Expand Up @@ -53,4 +62,9 @@ public function isBubbleMenusDisabled(): bool
{
return $this->evaluate($this->shouldShowBubbleMenus) ?? config('filament-tiptap-editor.disable_bubble_menus');
}

public function isToolbarMenusDisabled(): bool
{
return $this->evaluate($this->shouldShowToolbarMenus) ?? config('filament-tiptap-editor.disable_toolbar_menus');
}
}

0 comments on commit 17ac84e

Please sign in to comment.