⚠️ POSSIBLY BREAKING CHANGE
Docs
- Updated Traits module page
Changed
- ⚠️
editor.addComponents
now returns always an array of added components. So, if you ever used its result like this:now it should beconst component = editor.addComponents('<div>...');
const component = editor.addComponents('<div>...')[0];
- ⚠️ Updated traits layout. If you've ever customized the CSS of your traits you might see something broken
- Upgrade to Babel 7
- Recreate view element on
script
prop update - Log a warning in case no sector, in StyleManager, is found #2068
Added
- Added support for components generated from JSX (React preset).
In this way, you can useeditor.addComponents(<div>Hello JSX</div>)
to add components. JSX helps the editor in performances as it skips the parsing of an HTML string but keeps the readability of your code.
If you work in a different framework environment with JSX support (eg. writing JSX in Vue SFC generates another kind of objects) you can use a customprocessor
callback function as an option in theDomComponent
module to transform those objects (quick example from the code). - Added the possibility to specify the position on sector add via API #2094
- Added
draggableComponents
option (defaulttrue
) in DomComponents. This allows moving
components by dragging the component itself (not only by the move icon in the toolbar) - Allow dropping blocks absolutely when the
absolute
mode is active - Added
script-export
property to Component (check the API Reference of the property) - Added
escapeName
option and method in SelectorManager #1703
With this option you can now set a custom name escape strategy on selectors (eg. classes)grapesjs.init({ ... selectorManager: { escapeName: name => name.replace(' ', '___'), }, });
- Added
props
method in Trait and Component - Added new [API for extending Traits] (https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type)
- Added new Drag Mode API for changing drag modes of components in canvas
config.dragMode
- The initial configuration for the global drag modeeditor.setDragMode
- change the global drag mode of componentscomponent.setDragMode
- change the drag mode of a single component