From 565c1d454d2c10ed65025b33e6cb9782ccd95a13 Mon Sep 17 00:00:00 2001 From: Pierre Boneure Date: Tue, 18 Feb 2025 11:06:12 +0100 Subject: [PATCH 1/2] fix: Make headless mode work without jsdom #392 --- src/components/index.ts | 2 +- src/index.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/index.ts b/src/components/index.ts index 8362a62..71c20a3 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -40,7 +40,7 @@ export default (editor: Editor, opt: RequiredPluginOptions) => { const { Components } = editor; // @ts-ignore const ComponentsView = Components.ComponentsView; - const sandboxEl = document.createElement('div'); + const sandboxEl = editor.getConfig().headless ? undefined as unknown as HTMLDivElement : document.createElement('div'); // MJML Core model let coreMjmlModel = { diff --git a/src/index.ts b/src/index.ts index 4667b95..402a105 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,6 @@ import type { Plugin } from 'grapesjs'; import loadBlocks from './blocks'; import loadCommands from './commands'; import loadComponents from './components'; -import mjml2html from './components/parser'; import en from './locale/en'; import loadPanels from './panels'; import loadStyle from './style'; @@ -36,7 +35,7 @@ const plugin: Plugin = (editor, opt = {}) => { customComponents: [], importPlaceholder: '', imagePlaceholderSrc: '', - mjmlParser: mjml2html, + mjmlParser: opt.mjmlParser ? opt.mjmlParser : require("./components/parser"), overwriteExport: true, preMjml: '', postMjml: '', From a2096e0bee622fa96ec779065cc7e161c5359c73 Mon Sep 17 00:00:00 2001 From: Pierre Boneure Date: Mon, 28 Jul 2025 11:27:54 +0200 Subject: [PATCH 2/2] removing a change that was made for debug --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 402a105..bb4fcbd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,7 +35,7 @@ const plugin: Plugin = (editor, opt = {}) => { customComponents: [], importPlaceholder: '', imagePlaceholderSrc: '', - mjmlParser: opt.mjmlParser ? opt.mjmlParser : require("./components/parser"), + mjmlParser: mjml2html, overwriteExport: true, preMjml: '', postMjml: '',