decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

onChange handler for editor preview components

Open mspae opened this issue 3 years ago • 0 comments

TL;DR: I want to propose an onChange handler to preview components in order to build a visual editing component within the preview pane. (preview is purely read-only at the moment)

  • Am I missing something?
  • Are there any technical reasons against this?
  • Would the contributors be interested in merging such a feature if I put together a MR?

Context

The site I'm configuring netlify-cms for consists of quite complex grid elements. These are written as shortcodes (SSG is Hugo) and with responsive grid positioning attributes as shortcode attributes. This is a little too complex to comfortably edit it just with a text editor, therefore I created an in-page drag and drop-based configuration UI which can serialize the changes back to shortcode attributes. I want to have the visual editor UI in the preview pane and a relatively straight forward text/markdown rendering in the editing pane/markdown field.

Unfortunately I can't find a way to propagate changes from the preview pane back to the store since the preview widgets don't have an onChange handler. As far as I can tell there is no technical reason for this and it is purely because "it's a preview component, duh" – I get that, but for my use case this isn't really a good solution.

I think it is conceivable that this use case could also come up in other situations where users want WYSIWYG editing UI separate from textual representation of markdown and having this handler could unlock quite a lot of potential in that direction.

Other solutions I looked at

  • I could instead build the whole grid display within the markdown editor and have all the grid elements be inline editor components but I actually still want a purely textual representation of the markdown (and it sounds messier).
  • I could work around this issue by creating some sort of horrible global state bridge construct to find a solution but I'd rather not i.e. this proposal.

mspae avatar Jul 09 '22 11:07 mspae