Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/api/crepe.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ interface BlockEditFeatureConfig {
handleDragIcon?: string

// Menu configuration
buildMenu?: (builder: GroupBuilder) => void
buildMenu?: (builder: GroupBuilder<SlashMenuItem>) => void

// Text group labels and icons
slashMenuTextGroupLabel?: string
Expand Down Expand Up @@ -260,6 +260,7 @@ interface ToolbarFeatureConfig {
linkIcon?: string
strikethroughIcon?: string
latexIcon?: string
buildToolbar?: (builder: GroupBuilder<ToolbarItem>) => void
}

// Example:
Expand All @@ -271,6 +272,9 @@ const config: CrepeConfig = {
[Crepe.Feature.Toolbar]: {
boldIcon: customBoldIcon,
italicIcon: customItalicIcon,
buildToolbar: (builder) => {
// Custom toolbar building logic
},
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions packages/crepe/src/feature/toolbar/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ export function getGroups(config?: ToolbarFeatureConfig, ctx?: Ctx) {
},
})

config?.buildToolbar?.(groupBuilder)

return groupBuilder.build()
}
3 changes: 3 additions & 0 deletions packages/crepe/src/feature/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'
import { TextSelection } from '@milkdown/kit/prose/state'
import { createApp, ref, shallowRef, type App, type ShallowRef } from 'vue'

import type { GroupBuilder } from '../../utils'
import type { DefineFeature } from '../shared'
import type { ToolbarItem } from './config'

import { crepeFeatureConfig } from '../../core/slice'
import { CrepeFeature } from '../../feature'
Expand All @@ -23,6 +25,7 @@ interface ToolbarConfig {
linkIcon: string
strikethroughIcon: string
latexIcon: string
buildToolbar: (builder: GroupBuilder<ToolbarItem>) => void
}

export type ToolbarFeatureConfig = Partial<ToolbarConfig>
Expand Down