From 2c7de1335bbe3d6bb92ffb270870471f5ade94d9 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 5 Jul 2017 14:03:20 +0200 Subject: [PATCH] Fix plugin order execution --- src/grapesjs/index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/grapesjs/index.js b/src/grapesjs/index.js index 7f14ff74c..4001c8a8b 100644 --- a/src/grapesjs/index.js +++ b/src/grapesjs/index.js @@ -48,17 +48,18 @@ c.el = document.querySelector(els); var editor = new Editor(c).init(); - // Execute all plugins + // Execute plugins var plugs = plugins.getAll(); - for (var id in plugs){ - // Check if plugin is requested - if(c.plugins.indexOf(id) < 0) - continue; - - var opts = c.pluginsOpts[id] || {}; - var plug = plugins.get(id); - plug(editor, opts); - } + + c.plugins.forEach((pluginId) => { + let plugin = plugins.get(pluginId); + + if (plugin) { + plugin(editor, c.pluginsOpts[pluginId] || {}); + } else { + console.warn(`Plugin ${pluginId} not found`); + } + }); if(c.autorender) editor.render();