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:
parent
1c38dc87e3
commit
2f20209d66
3 changed files with 31 additions and 4 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
import TextStyleDropdown from './TextStyleDropdown.svelte'
|
import TextStyleDropdown from './TextStyleDropdown.svelte'
|
||||||
import MediaInsertDropdown from './MediaInsertDropdown.svelte'
|
import MediaInsertDropdown from './MediaInsertDropdown.svelte'
|
||||||
import ComposerLinkManager from './ComposerLinkManager.svelte'
|
import ComposerLinkManager from './ComposerLinkManager.svelte'
|
||||||
|
import ComposerBubbleMenu from './ComposerBubbleMenu.svelte'
|
||||||
import { ComposerMediaHandler } from './ComposerMediaHandler.svelte'
|
import { ComposerMediaHandler } from './ComposerMediaHandler.svelte'
|
||||||
import { useComposerEvents } from './useComposerEvents.svelte'
|
import { useComposerEvents } from './useComposerEvents.svelte'
|
||||||
import { useDropdown } from './useDropdown.svelte'
|
import { useDropdown } from './useDropdown.svelte'
|
||||||
|
|
@ -259,7 +260,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={`composer composer--${variant} ${className}`}>
|
<div class={`composer composer--${variant} ${className}`}>
|
||||||
{#if showToolbar && editor && !isLoading}
|
{#if showToolbar && editor && !isLoading && features.toolbar !== false}
|
||||||
<ComposerToolbar
|
<ComposerToolbar
|
||||||
bind:this={toolbarRef}
|
bind:this={toolbarRef}
|
||||||
{editor}
|
{editor}
|
||||||
|
|
@ -286,6 +287,9 @@
|
||||||
<TableRowMenu {editor} />
|
<TableRowMenu {editor} />
|
||||||
<TableColMenu {editor} />
|
<TableColMenu {editor} />
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if features.bubbleMenu}
|
||||||
|
<ComposerBubbleMenu {editor} {features} />
|
||||||
|
{/if}
|
||||||
<ComposerLinkManager bind:this={linkManagerRef} {editor} {features} />
|
<ComposerLinkManager bind:this={linkManagerRef} {editor} {features} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
@ -368,6 +372,7 @@
|
||||||
|
|
||||||
&.with-toolbar {
|
&.with-toolbar {
|
||||||
border-top: none;
|
border-top: none;
|
||||||
|
margin-top: $unit-2x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// More generous padding for full variant
|
// More generous padding for full variant
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,15 @@ export function getColorCommands(): any[] {
|
||||||
return commands.colors?.commands || []
|
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
|
// Commands to exclude from toolbar
|
||||||
export const excludedCommands = ['colors', 'fonts']
|
export const excludedCommands = ['colors', 'fonts']
|
||||||
|
|
||||||
|
|
@ -138,6 +147,11 @@ export function shouldShowSlashCommands(variant: ComposerVariant): boolean {
|
||||||
return variant !== 'minimal'
|
return variant !== 'minimal'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Whether to show bubble menu
|
||||||
|
export function shouldShowBubbleMenu(variant: ComposerVariant): boolean {
|
||||||
|
return variant !== 'minimal'
|
||||||
|
}
|
||||||
|
|
||||||
// Default features by variant
|
// Default features by variant
|
||||||
export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
|
export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
|
||||||
if (variant === 'minimal') {
|
if (variant === 'minimal') {
|
||||||
|
|
@ -146,7 +160,9 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
|
||||||
mediaLibrary: false,
|
mediaLibrary: false,
|
||||||
urlEmbed: false,
|
urlEmbed: false,
|
||||||
tables: false,
|
tables: false,
|
||||||
codeBlocks: false
|
codeBlocks: false,
|
||||||
|
bubbleMenu: false,
|
||||||
|
toolbar: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +172,9 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
|
||||||
mediaLibrary: true,
|
mediaLibrary: true,
|
||||||
urlEmbed: false,
|
urlEmbed: false,
|
||||||
tables: false,
|
tables: false,
|
||||||
codeBlocks: false
|
codeBlocks: false,
|
||||||
|
bubbleMenu: true,
|
||||||
|
toolbar: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,6 +184,8 @@ export function getDefaultFeatures(variant: ComposerVariant): ComposerFeatures {
|
||||||
mediaLibrary: true,
|
mediaLibrary: true,
|
||||||
urlEmbed: true,
|
urlEmbed: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
codeBlocks: true
|
codeBlocks: true,
|
||||||
|
bubbleMenu: true,
|
||||||
|
toolbar: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ export interface ComposerFeatures {
|
||||||
urlEmbed?: boolean
|
urlEmbed?: boolean
|
||||||
tables?: boolean
|
tables?: boolean
|
||||||
codeBlocks?: boolean
|
codeBlocks?: boolean
|
||||||
|
bubbleMenu?: boolean
|
||||||
|
toolbar?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComposerProps {
|
export interface ComposerProps {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue