Skip to content

Commit 759bc49

Browse files
feat: add buffer polyfill to demo app for UMD build compatibility
1 parent b5db86f commit 759bc49

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

apps/docs/snippets/components/doc-counter.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ export const DocCounter = ({ height = '350px' }) => {
1616
link.href = 'https://unpkg.com/superdoc@latest/dist/style.css';
1717
document.head.appendChild(link);
1818

19-
const script = document.createElement('script');
20-
script.src = 'https://unpkg.com/superdoc@latest/dist/superdoc.umd.js';
21-
script.onload = () => setTimeout(() => initializeSuperdoc(), 100);
22-
document.body.appendChild(script);
19+
// Buffer polyfill — required by the UMD build for document hashing
20+
const bufferScript = document.createElement('script');
21+
bufferScript.src = 'https://cdn.jsdelivr.net/npm/buffer@6/index.min.js';
22+
bufferScript.onload = () => {
23+
window.Buffer = window.buffer.Buffer;
24+
25+
const script = document.createElement('script');
26+
script.src = 'https://unpkg.com/superdoc@latest/dist/superdoc.umd.js';
27+
script.onload = () => setTimeout(() => initializeSuperdoc(), 100);
28+
document.body.appendChild(script);
29+
};
30+
document.body.appendChild(bufferScript);
2331

2432
return () => superdocRef.current?.destroy?.();
2533
}, []);

0 commit comments

Comments
 (0)