Skip to content

feat: 🎸 improve the block menu config api#1953

Merged
Saul-Mirone merged 1 commit intomainfrom
improve-block-menu-config
Jun 7, 2025
Merged

feat: 🎸 improve the block menu config api#1953
Saul-Mirone merged 1 commit intomainfrom
improve-block-menu-config

Conversation

@Saul-Mirone
Copy link
Member

@Saul-Mirone Saul-Mirone commented Jun 7, 2025

Closes: #1916

  • I read the contributing guide
  • I agree to follow the code of conduct

Summary

Improve the block menu config api.

1. Restructured Configuration Interface

  • Replaced flat configuration properties with nested group-based configuration
  • Introduced three main configuration groups:
    • textGroup: For text-related blocks (paragraphs, headings, quotes, dividers)
    • listGroup: For list-related blocks (bullet, ordered, task lists)
    • advancedGroup: For advanced blocks (images, code blocks, tables, math)

2. Enhanced Type Safety

  • Added DeepPartial utility type for better type inference
  • Introduced nullable configuration options to allow disabling specific menu items
  • Improved type definitions for menu item configurations

3. Improved Customization

  • Each menu item can now be individually enabled/disabled by setting it to null
  • Groups can be completely hidden by setting the entire group to null
  • Maintained backward compatibility with default values

4. Code Organization

  • Added new types.ts utility file for shared type definitions
  • Refactored menu configuration logic to be more maintainable
  • Improved conditional rendering of menu items based on feature flags

Breaking Changes

The configuration interface has been significantly changed. Users will need to update their configurations to use the new nested structure. For example:

// Old configuration
{
  slashMenuTextGroupLabel: 'Text Blocks',
  slashMenuH1Label: 'Large Heading'
}

// New configuration
{
  textGroup: {
    label: 'Text Blocks',
    h1: {
      label: 'Large Heading'
    }
  }
}

Migration Guide

  1. Group your existing configuration properties into the appropriate groups
  2. Convert flat properties to nested objects
  3. Use null to disable specific menu items or entire groups
  4. Update any custom menu building logic to work with the new structure

How did you test this change?

CI, Manually.

@vercel
Copy link

vercel bot commented Jun 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
milkdown-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2025 4:35am

@Saul-Mirone Saul-Mirone added this pull request to the merge queue Jun 7, 2025
Merged via the queue into main with commit 8da11a8 Jun 7, 2025
14 checks passed
@Saul-Mirone Saul-Mirone deleted the improve-block-menu-config branch June 7, 2025 05:12
@github-actions github-actions bot mentioned this pull request Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] More flexible BlockEdit Feature config

1 participant