Fix: Markdow Copy now works over non-secure HTTP

This commit is contained in:
hooli
2026-06-20 01:22:22 +01:00
parent 1efc1c95ca
commit 40f3edce68
+21 -2
View File
@@ -442,8 +442,27 @@ export default function App() {
const handleExportMd = useCallback(async () => {
const md = generateMarkdownTable(nodes)
if (!md) { toast.error('No nodes to export'); return }
await navigator.clipboard.writeText(md)
toast.success('Markdown table copied to clipboard')
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(md)
toast.success('Markdown table copied to clipboard')
} else {
// Only allowed access to navigator.clipboard over HTTPS not HTTP
// Use the temporary 'hidden text area for alternative copy method
const textArea = document.createElement("textarea");
textArea.value = md;
textArea.style.position = "absolute";
textArea.style.left = "-999999px";
document.body.prepend(textArea);
textArea.select();
try {
document.execCommand('copy');
toast.success("Markdown table copied to clipboard")
} catch (err) {
toast.error(`Markdown copy failed: ${err instanceof Error ? err.message : String(err)}`)
} finally {
textArea.remove();
}
}
}, [nodes])
const handleExportYaml = useCallback(() => {