Fix: Markdow Copy now works over non-secure HTTP
This commit is contained in:
@@ -442,8 +442,27 @@ export default function App() {
|
|||||||
const handleExportMd = useCallback(async () => {
|
const handleExportMd = useCallback(async () => {
|
||||||
const md = generateMarkdownTable(nodes)
|
const md = generateMarkdownTable(nodes)
|
||||||
if (!md) { toast.error('No nodes to export'); return }
|
if (!md) { toast.error('No nodes to export'); return }
|
||||||
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
await navigator.clipboard.writeText(md)
|
await navigator.clipboard.writeText(md)
|
||||||
toast.success('Markdown table copied to clipboard')
|
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])
|
}, [nodes])
|
||||||
|
|
||||||
const handleExportYaml = useCallback(() => {
|
const handleExportYaml = useCallback(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user