diff --git a/docs/modules/Canvas.md b/docs/modules/Canvas.md index 107af37bc..5463ae468 100644 --- a/docs/modules/Canvas.md +++ b/docs/modules/Canvas.md @@ -132,6 +132,33 @@ In the next section, we'll see how it's possible to reuse the built-in spots and In the example below we'll see how to reuse the built-in `hover` canvas spot to render our custom highlighting rectangle (we'll disable the rendering of the default one) and create a new one in order to render a button below the selected `text` components. +[DEMO](https://jsfiddle.net/artur_arseniev/zdetbjsg/) + + + +Worth noting a few important points: + +* Our custom container has to be moved inside the GrapesJS spots container. +```js +editor.onReady(() => { + Canvas.getSpotsEl().appendChild(this.$el); +}); +``` +* We pass the `component` to our custom spot, in order to have the style coordinates properly updated when we scroll the page or update the component. +```js +Canvas.addSpot({ type: customSpotType, component }); +``` +* The single spot is placed properly with `spot.getStyle()` +```html +
...
+``` +* The spots container, by default, relies on `pointer-events: none`, in order to prevent the spot from blocking the interaction with the components. This is why we have to re-enable the pointer event on the button in order to make it interactable. +```css +.spot-text-btn { + /*...*/ + pointer-events: auto; +} +```