Skip to content

feat: 🎸 Add plugin feature to crepe#1931

Closed
Striar-Yunis wants to merge 1 commit intoMilkdown:mainfrom
Striar-Yunis:main
Closed

feat: 🎸 Add plugin feature to crepe#1931
Striar-Yunis wants to merge 1 commit intoMilkdown:mainfrom
Striar-Yunis:main

Conversation

@Striar-Yunis
Copy link

This commit adds the ability to add to the toolbar and slash menu with custom actions and rendering.

BREAKING CHANGE: 🧨 None

✅ Closes: NA

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

Summary

Hello I needed to be able to extend the Crepe editor and couldn't find a clean way to do it. This PR adds hooks into Crepe that allows for additional toolbar and slash menu features. The actual change is quite small, most of it is the examples. If there is interest in this PR, I'd move everything in dev to the stackblitz examples and would remove the package changes.

How did you test this change?

Under ./dev in the PR (to move to stackblitz) there are a vanilla and react example which implement custom toolbar and slash menu examples. They add support for extra text features and custom elements.

image
image
image
image

This commit adds the ability to add to the toolbar and slash menu with
custom actions and rendering.

BREAKING CHANGE: 🧨 None

✅ Closes: NA
@changeset-bot
Copy link

changeset-bot bot commented May 31, 2025

⚠️ No Changeset found

Latest commit: ff22c74

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented May 31, 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 May 31, 2025 9:59pm

@yswang0927
Copy link

Great! These are all the features I want 👍

@Saul-Mirone
Copy link
Member

Is this a vibe coded pr?

@Striar-Yunis
Copy link
Author

I just wanted something to POC the interaction to see if there was interest beyond myself, and I wasn’t too sure how nice the rendering was going to play with React.

As noted above, the actual code in this PR as it stands should definitely not be merged. If there’s interest I’d take a day to implement this properly.

@Saul-Mirone
Copy link
Member

Thanks for the pr. In fact I'm working on similar parts. It gives me some inspirations about how to make the toolbar configurable. We need to at least support the same features on Vue.

@Striar-Yunis
Copy link
Author

If implemented properly is this something you’d be open to merging? My initial thoughts on doing this PR the right way:

If there is a ‘Plugin’ system implemented should the existing toolbar and slash menu items be updated to follow the same?

How much node state does it make sense to expose to the underlying plugins? Should plugins be expected to to function with imports only from @milkdown/crepe?

Should dom/markdown serialization methods always be required? I would think so.

As to your statement on cue, I don’t know it very well. My thought for React and Vanilla custom blocks is that they are made aware of their DOM node and mount it as root. I’d hope vue has something similar.

@Saul-Mirone
Copy link
Member

In fact I have another package called prosemirror-adapter which implemented all the features about the node view part. It provides the feature to let users write prosemirror view in several different frameworks. So I don't plan to accept the part in the dev folder. (And dev folder is used to build internal tools, it's not for demo)

image

@Striar-Yunis
Copy link
Author

Oh wow that package takes care of all the hard parts. I’ll reduce this PR just down to a couple functions that take the adapter output and some metadata for button styling.

@Saul-Mirone
Copy link
Member

Closing in favour of #1950

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.

4 participants