Closed eunjae-lee closed 8 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
plugin-sandbox | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 14, 2023 1:17pm |
I think this implementation is much easier to follow from the developer/consumer perspective.
I will create a stacked branch on top of this, and continue this approach. Maybe I will find out if there are any restrictions. :)
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite.
In the end I abstracted the first approach because I was struggling the extract the vi.mock from the file as it is hoisted. You can find more information here (https://storyblok.slack.com/archives/C04P3JBHWHW/p1700068753644059)
What?
This is a different approach. Instead of mocking
postMessage
andaddEventListener
, this actually changescreateFieldPlugin()
.We used to have only
createFieldPlugin()
and now we also haveinternalCreateFieldPlugin()
. TheinternalCreateFieldPlugin()
accepts two more options:postToContainer
listenToContainer
The
createFieldPlugin
calls theinternalCreateFieldPlugin
with those implementations, but in our testing helper, we mock@storyblok/field-plugin
, and replacescreateFieldPlugin
with different implementations ofpostToContainer
andlistenToContainer
.But this requires us to actually export
internalCreateFieldPlugin
from the library, which is not that big of a deal, in my opinion. (of course, we could rename it)Not sure which take I prefer (the previous one and this)
but probably a good food for thought :)