diff --git a/src/editor/config/config.js b/src/editor/config/config.js index 6bb121b9b..0d09b8a33 100644 --- a/src/editor/config/config.js +++ b/src/editor/config/config.js @@ -140,6 +140,13 @@ export default { // use it later, but this option comes really handy when deal with big templates. clearStyles: 0, + // Specify the global drag mode of components. By default, components are moved + // following the HTML flow. Two other options are available: + // 'absolute' - Move components absolutely (design tools way) + // 'translate' - Use translate CSS from transform property + // To get more about this feature read: https://github.com/artf/grapesjs/issues/1936 + dragMode: 0, + // Dom element el: '', diff --git a/src/editor/index.js b/src/editor/index.js index 06378f0d8..529752bc6 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -617,6 +617,17 @@ export default (config = {}) => { return this; }, + /** + * Change the global drag mode of components. + * To get more about this feature read: https://github.com/artf/grapesjs/issues/1936 + * @param {String} value Drag mode, options: 'absolute' | 'translate' + * @returns {this} + */ + setDragMode(value) { + em.setDragMode(value); + return this; + }, + /** * Trigger event log message * @param {*} msg Message to log diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 1655d0096..c6c36d41d 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -624,6 +624,10 @@ export default Backbone.Model.extend({ return this.get('Canvas').getZoomDecimal(); }, + setDragMode(value) { + return this.set('dmode', value); + }, + /** * Returns true if the editor is in absolute mode * @returns {Boolean}