wp-shortcake/shortcake-gutenberg

Build translation layer for js-hooks registered with shortcake

Opened this issue · 0 comments

This issue is going to be quite tricky as I'm understanding it, and may not be feasible in the end. I'd like to begin working out how to do it, though.

The user story goes basically like this:

As an engineering team who's built a lot of custom shortcodes
I want to make sure that the dynamic fields we've built continue to work after our site migrates to Gutenberg
Because in some cases our shortcode field logic has cases where some fields are dependant on the values of other fields.

This will require a couple different moving pieces at least:

  • Any update in an attribute field component, should trigger the appropriate js hooks for Shortcake to render. This will mean somehow expressing the component state to an approximation of the backbone models that the current hooks expect as arguments.

  • Since the existing Shortcake js hooks basically expose a read-only interface without any API for updating fields, the common practice has been to use DOM manipulation to affect fields based on a change to a field: hiding or showing fields based on a selection in a field, for example, or changing the options available for selection in one field depending on the value selected in another, for example. This will be really messy to try to duplicate in React, but it might be possible to somehow render a hidden Backbone view and listen to it to update the React component in a predefined set of ways (updating value, visibility, and possibly class names?).