{"record":{"id":"2664e4fcd50878ff","repo":"GraphiteEditor/Graphite","slug":"no-valid-clipboard-data","errorCode":null,"errorMessage":"No valid clipboard data","messagePattern":"No valid clipboard data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"frontend/src/utility-functions/clipboard.ts","lineNumber":148,"sourceCode":"\t\t\t\t\tconst blob = await item.getType(imageType);\n\t\t\t\t\tconst reader = new FileReader();\n\t\t\t\t\treader.onload = async () => {\n\t\t\t\t\t\tif (reader.result instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tconst imageData = await extractPixelData(new Blob([reader.result], { type: imageType }));\n\t\t\t\t\t\t\teditor.pasteImage(undefined, new Uint8Array(imageData.data), imageData.width, imageData.height);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\treader.readAsArrayBuffer(blob);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\t// The API limits what kinds of data we can access, so we can get copied images and our text encodings of copied nodes, but not files (like\n\t\t\t\t// .graphite or even image files). However, the user can paste those with Ctrl+V, which we recommend they in the error message that's shown to them.\n\t\t\t\treturn false;\n\t\t\t}),\n\t\t);\n\n\t\tif (!success) throw new Error(\"No valid clipboard data\");\n\t} catch (err) {\n\t\tconst unsupported = stripIndents`\n\t\t\tThis browser does not support reading from the clipboard.\n\t\t\tUse the standard keyboard shortcut to paste instead.\n\t\t\t`;\n\t\tconst denied = stripIndents`\n\t\t\tThe browser's clipboard permission has been denied.\n\n\t\t\tOpen the browser's website settings (usually accessible\n\t\t\tjust left of the URL bar) to allow this permission.\n\t\t\t`;\n\t\tconst nothing = stripIndents`\n\t\t\tNo valid clipboard data was found. You may have better\n\t\t\tsuccess pasting with the standard keyboard shortcut instead.\n\t\t\t`;\n\n\t\tconst matchMessage = {\n\t\t\t\"clipboard-read\": unsupported,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/frontend/src/utility-functions/clipboard.ts#L130-L166","documentation":"navigator.clipboard.read() succeeded but none of the returned ClipboardItems exposed a flavor the editor consumes — no text/plain (used for layer encodings) and no readable image type. Every per-item handler returned false, Promise.any resolved to false, and the function throws; the catch maps this message to a dialog suggesting the standard paste shortcut.","triggerScenarios":"The clipboard holds only flavors the async Clipboard API cannot expose: files copied in the OS file manager (.graphite or image files), private application/x-* types, or rich text (text/html) without a text/plain flavor.","commonSituations":"Copying a document file in the OS file manager and then using Edit > Paste — the async API cannot expose files, only the paste event can; copying from applications that write only HTML/RTF flavors with no plain-text equivalent.","solutions":["Paste with Ctrl+V instead — the paste event can access file data the async API cannot","If the content came from another app, re-copy it as plain text or an image","When writing to the clipboard programmatically (e.g. copied layers), always include a text/plain representation alongside custom flavors"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Probe ClipboardItems for a flavor the editor can consume before processing\nconst usableTypes = (items: ClipboardItem[]): boolean =>\n\titems.some((item) => item.types.includes(\"text/plain\") || item.types.some((t) => t.startsWith(\"image/\")));","typeGuard":null,"tryCatchPattern":"// Rely on the existing catch mapping: \"No valid clipboard data\" -> dialog that recommends Ctrl+V\nif (!success) throw new Error(\"No valid clipboard data\");","preventionTips":["Treat menu-driven paste as best-effort; the paste event is the reliable path for files","When serializing layers to the clipboard, always write a text/plain flavor alongside custom ones","Probe item.types before reading and show a targeted hint for file-only clipboard content"],"tags":["clipboard","mime-types","paste"],"backgroundTag":"clipboard-unsupported-content","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}