From 64df0660c879811e815fa6c9f2790612c8063050 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Sun, 3 May 2026 16:38:47 +0530 Subject: [PATCH] fix(renderer): initialize DOMPurify with window context require('dompurify') returns a factory function, not a sanitizer instance. Calling .sanitize() on the factory threw a TypeError, which was caught by the preview renderer's try-catch and displayed a generic "Error rendering preview" message. Fix by invoking the factory with the renderer's window object. Amit Haridas --- src/renderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer.js b/src/renderer.js index 6c0d320..86b9a58 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -6,7 +6,8 @@ const { ipcRenderer } = require('electron'); const marked = require('marked'); const { markedHighlight } = require('marked-highlight'); -const DOMPurify = require('dompurify'); +const createDOMPurify = require('dompurify'); +const DOMPurify = createDOMPurify(window); const hljs = require('highlight.js'); const { createEditor } = require('./editor/codemirror-setup'); const { undo, redo } = require('@codemirror/commands');