// Loads src/public/editor.js (and markdown-preview.js, the link gate it needs) into a vm context with a // bare `window`, so model-level tests can call MosaicEditor.roundTrip without a browser. import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import vm from 'node:vm'; const pub = join(dirname(fileURLToPath(import.meta.url)), '../../src/public'); export function loadEditor() { const sandbox = { console }; sandbox.window = sandbox; sandbox.globalThis = sandbox; vm.createContext(sandbox); for (const f of ['markdown-preview.js', 'editor.js']) vm.runInContext(readFileSync(join(pub, f), 'utf8'), sandbox, { filename: f }); return sandbox.MosaicEditor; }