siyuan-note/siyuan · warning

image clipboard is unavailable

Error message

image clipboard is unavailable

What it means

writePNGBlob copies an image to the clipboard via the async Clipboard API (navigator.clipboard.write with a ClipboardItem). If either API is missing, it deliberately throws this error so the caller (copyBlob) can fall back to an alternative copy path.

Solutions

  1. Ensure the page is served over HTTPS (or localhost) with clipboard-write permission
  2. Use an environment that supports ClipboardItem (modern Chromium/Safari/Firefox)
  3. Rely on the existing fallback path (copyImage/blobToPNGClipboard via img+canvas) instead of failing
  4. For Electron, confirm the clipboard permission is not blocked in the BrowserWindow/webPreferences

Example fix

// before
await writePNGBlob(blob);
// after
if (navigator.clipboard?.write && typeof ClipboardItem !== "undefined") {
    await writePNGBlob(blob);
} else { fallbackCopyImage(blob); }
Defensive patterns

Strategy: fallback

Validate before calling

const canUseImageClipboard = typeof navigator !== "undefined" && !!navigator.clipboard?.write && typeof ClipboardItem !== "undefined";

Type guard

const supportsClipboardWrite = (): boolean => !!navigator.clipboard?.write && typeof ClipboardItem !== "undefined";

Try / catch

try { await writePNGBlob(blob); } catch { fallbackCopyViaImgCanvas(blob); }

Prevention

When it happens

Trigger: Calling copyBlob/writePNGBlob in an environment without navigator.clipboard.write or the ClipboardItem constructor — e.g. non-HTTPS origins, older browsers, WebViews (some Android/iOS WebView builds), or iframes without clipboard permission policy.

Common situations: Embedding the editor in a WebView or iframe lacking clipboard-write permission; serving over plain HTTP; unsupported browsers (older Firefox/Safari without full ClipboardItem support); document not focused during clipboard write.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/613adbaf246967d7. Report an issue: GitHub.

Appendix: source

Thrown at app/src/menus/util.ts:226

        });
    }
    /// #endif
    if (onlyGetMenus) {
        return openSubmenus;
    }
    window.siyuan.menus.menu.append(new MenuItem({
        id: "openBy",
        label: window.siyuan.languages.openBy,
        icon: "iconOpen",
        submenu: openSubmenus,
    }).element);
    /// #endif
};

export const writePNGBlob = async (blob: Blob): Promise<boolean> => {
    try {
        if (!navigator.clipboard?.write || typeof ClipboardItem === "undefined") {
            throw new Error("image clipboard is unavailable");
        }
        await navigator.clipboard.write([
            new ClipboardItem({
                // @ts-ignore
                ["image/png"]: blob
            })
        ]);
        return true;
    } catch (e) {
        showMessage(window.siyuan.languages.clipboardPermissionDenied);
        return false;
    }
};

export const copyPNGByLink = (link: string) => {
    if (isInAndroid()) {
        window.JSAndroid.writeImageClipboard(link);
        return;

View on GitHub (pinned to 9f775e8a12)