mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
fix(renderer): remove let ModalManager to prevent SyntaxError on load
ModalManager.js is loaded via <script> tag in index.html, which declares class ModalManager in the global script scope. renderer.js was then doing 'let ModalManager;' which caused: SyntaxError: Identifier 'ModalManager' has already been declared This prevented renderer.js from executing at all, breaking tabs, editor, file open, and preview rendering. Fix: conditionally require ModalManager only if undefined, without re-declaring. In sloppy mode this safely assigns to the existing global. Amit Haridas
This commit is contained in:
+4
-7
@@ -11,13 +11,10 @@ const DOMPurify = createDOMPurify(window);
|
||||
const hljs = require('highlight.js');
|
||||
const { createEditor } = require('./editor/codemirror-setup');
|
||||
const { undo, redo } = require('@codemirror/commands');
|
||||
// Use window.ModalManager if already set by script tag, otherwise require it.
|
||||
// This prevents "Identifier 'ModalManager' has already been declared" when
|
||||
// both the script tag in index.html and CommonJS require() declare it.
|
||||
let ModalManager;
|
||||
if (typeof window !== 'undefined' && window.ModalManager) {
|
||||
ModalManager = window.ModalManager;
|
||||
} else {
|
||||
// ModalManager is loaded via <script src="utils/ModalManager.js"> in index.html.
|
||||
// It already exists in the global scope — re-declaring with let/const causes
|
||||
// SyntaxError: "Identifier 'ModalManager' has already been declared".
|
||||
if (typeof ModalManager === 'undefined') {
|
||||
const result = require('./utils/ModalManager');
|
||||
ModalManager = result.ModalManager || result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user