feat: add toolbar feature flag to disable toolbar in favor of bubble menu

- Add toolbar property to ComposerFeatures interface
- Update default features to disable toolbar for inline/full variants
- Add conditional rendering check for toolbar feature flag
- Enable bubble menu by default for better UX

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-06-26 11:58:10 -04:00
parent 1c38dc87e3
commit 2f20209d66
3 changed files with 31 additions and 4 deletions

View file

@ -18,6 +18,7 @@
import TextStyleDropdown from './TextStyleDropdown.svelte'
import MediaInsertDropdown from './MediaInsertDropdown.svelte'
import ComposerLinkManager from './ComposerLinkManager.svelte'
import ComposerBubbleMenu from './ComposerBubbleMenu.svelte'
import { ComposerMediaHandler } from './ComposerMediaHandler.svelte'
import { useComposerEvents } from './useComposerEvents.svelte'
import { useDropdown } from './useDropdown.svelte'
@ -259,7 +260,7 @@
</script>
<div class={`composer composer--${variant} ${className}`}>
{#if showToolbar && editor && !isLoading}
{#if showToolbar && editor && !isLoading && features.toolbar !== false}
<ComposerToolbar
bind:this={toolbarRef}
{editor}
@ -286,6 +287,9 @@
<TableRowMenu {editor} />
<TableColMenu {editor} />
{/if}
{#if features.bubbleMenu}
<ComposerBubbleMenu {editor} {features} />
{/if}
<ComposerLinkManager bind:this={linkManagerRef} {editor} {features} />
{/if}
@ -368,6 +372,7 @@
&.with-toolbar {
border-top: none;
margin-top: $unit-2x;
}
// More generous padding for full variant

View file

@ -115,6 +115,15 @@ export function getColorCommands(): any[] {
return commands.colors?.commands || []
}
// Get commands for bubble menu
export function getBubbleMenuCommands(): any[] {
const textFormattingCommands = commands['text-formatting']?.commands || []
// Return only the essential formatting commands for bubble menu
return textFormattingCommands.filter((cmd) =>
['bold', 'italic', 'underline', 'strike', 'link'].includes(cmd.name)
)
}
// Commands to exclude from toolbar
export const excludedCommands = ['colors', 'fonts']
@ -138,6 +147,11 @@ export function shouldShowSlashCommands(variant: ComposerVariant): boolean {
return variant !== 'minimal'
}
// Whether to show bubble menu
export function shouldShowBubbleMenu(variant: ComposerVariant): boolean {
return variant !== 'minimal'
}
// Default features by variant
export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
if (variant === 'minimal') {
@ -146,7 +160,9 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
mediaLibrary: false,
urlEmbed: false,
tables: false,
codeBlocks: false
codeBlocks: false,
bubbleMenu: false,
toolbar: true
}
}
@ -156,7 +172,9 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
mediaLibrary: true,
urlEmbed: false,
tables: false,
codeBlocks: false
codeBlocks: false,
bubbleMenu: true,
toolbar: false
}
}
@ -166,6 +184,8 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
mediaLibrary: true,
urlEmbed: true,
tables: true,
codeBlocks: true
codeBlocks: true,
bubbleMenu: true,
toolbar: false
}
}

View file

@ -8,6 +8,8 @@ export interface ComposerFeatures {
urlEmbed?: boolean
tables?: boolean
codeBlocks?: boolean
bubbleMenu?: boolean
toolbar?: boolean
}
export interface ComposerProps {