Hi guys,
So I am working on porting my NextJS content_blocks builder over from React databinding to the new editable regions. At the beginning this went like a breeze, because in almost no time I had a working array of content_blocks where I defined editables for text and images. And this works perfectly. But my content_blocks don’t only have text and images that are editable, but also some settings like background-color and padding. So I figured that is where components come in right? But here is where I am having problems:
- Now the first problem that arose is that the @cloudcannon/editable-regions package is not transpiled and so it is unusable with the NextJs bundler. I’ve already made a Github issue and think I tackled this by incorporating a registerReactComponent in my app directly which seems to work (I can log window.cc_components in the browser console).
- The docs are not clear on where to define the data-attributes for components (the example doesn’t show them) and doesn’t show how to handle nested front-matter paths. But I’ve tried both defining them in the component block and outside of it.
So here’s what my structure looks like:
<div data-editable="array" data-id-key="type" data-prop="content_blocks">
<div data-editable="array-item" data-id={block.type}>
<section block={block} data-component="cta" data-editable="component" data-prop="#content_blocks.4">...some text-editables</Section>
</div>
</div>
I’ve tried different things for data-prop, like content_blocks.4, content_blocks.index.4 and more but to no avail. When I remove data-prop, Cloudcannon overwrites the props resulting in an empty div, when I add it, the content shows but you cant visual edit anymore, although the outline indicators are showing on hover. Hope anyone get put me in the right direction. Is the data-prop the issue or is the registration not working correctly.
Tx!