Using registerPlugin
to insert dynamic behavior in the block editor
#53657
Unanswered
brittonwalker
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @brittonwalker, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi 👋, I had a request from a client to help streamline some processes for their editors while maintaining flexibility over the content in the block editor when creating articles. Here are some examples:
My original idea was to find a way to hook into the editor on some sort of save hook situation. I initially found success on this but there ended up being issues that I concluded were likely server related. The work was messy and required a bit of logic that made me think I was hacking and pushing too far. When a bug got reported that I felt I couldn't reproduce locally, I decided to shift gears.
My question is if it's strange to use
registerPlugin
to mount a component that renders no markup but performs these actions. I can give an example of auseEffect
that listens for the firstcore/paragraph
and applies a drop cap. I thought this was all good to go but a colleague noticed that if we removed of the first paragraph the undo history wouldn't work. I found__unstableMarkNextChangeAsNotPersistent
through reference somewhere in the github and it solved my issue.Is this smart/dumb? Is this good/bad? Is there a better way? I haven't come across anything like this through an example but I thought others might have done something similar and wanted to share/hear from anyone that has gotten into this zone.
Beta Was this translation helpful? Give feedback.
All reactions