1
0
Fork 0

feat(components): Better snippet support in Draft component

The Draft react component would load the snippets that are part of our
plugin bundle. However, any additional snippets that are created by
plugins would not not get added to the `defs` section, and thus not
be rendered.

This changes the behavior by doing two things:

 - in `core` it adds an SVG object to the renderProps, and makes
   sure to run the `preRender` hook on this SVG object prior to
   returning the renderProps. This way, svg.defs now holds all
   defs, including any that may have been added by custom plugins
 - in the `Draft` component, we no longer add a list of predefined
   snippets to the defs section, but instead just use the svg.defs
   section verbatim. This removes any discrepancies in how SVG
   rendering and React rendering handles the defs section of the
   SVG document, and thus displays snippets.
This commit is contained in:
Joost De Cock 2020-11-08 18:19:10 +01:00
parent d493e30f30
commit 1a5b2769aa
10 changed files with 66 additions and 182 deletions

View file

@ -34,8 +34,8 @@ const createConfig = (component, module) => {
const config = []
// When developing, you can use this to only rebuild the components you're working on
let dev = true
let only = ['Workbench']
let dev = false
let only = ['Draft', 'Workbench']
for (let component of components) {
if (!dev || only.indexOf(component) !== -1) config.push(createConfig(component, false))
// Webpack doesn't handle .mjs very well