Use case or problem
Copying a range in Excel puts four flavors on the clipboard at once (Obsidian 1.14.1 on Windows, via clipboard.availableFormats()):
text/plain , text/html , text/rtf , image/png
Obsidian takes the HTML and builds a Markdown table. That is the right default and should stay. But sometimes the picture is the content — conditional formatting, merged headers, colour scales — and rebuilding it as Markdown loses exactly what I wanted. There is no way to say “this time, take the image”, even though it is already sitting in the clipboard.
The opposite complaint also exists (linked below: users who get an image and wanted the table). One default cannot serve both cases; an explicit command can.
Proposed solution
A “Paste as image” command, sibling to “Paste as plain text” (Ctrl+Shift+V), plus a context menu entry. Four details that matter, learned from implementing it:
- Insert at the cursor, like any paste.
- Route through the normal attachment pipeline, so attachment folder and naming settings — and the hooks community plugins already use — keep working unchanged.
- Composite alpha onto an opaque background. Transparent-background images render as invisible black text in dark mode.
- Do not touch the clipboard, so the very next paste can still produce the table.
A mirror “Paste as table” command would cover the linked bug report.
Current workaround (optional)
A small plugin. Two approaches I had to discard: rewriting the clipboard (kills the HTML flavor) and saving the attachment myself (bypasses attachment-naming plugins). What works is handing the editor a synthetic paste carrying only the image, so Obsidian’s own paste path does the rest:
const img = require("electron").clipboard.readImage();
const dt = new DataTransfer();
dt.items.add(new File([await flattenOntoWhite(img)], "image.png", { type: "image/png" }));
editor.focus(); // the synthetic event is silently ignored if the editor isn't focused
view.editor.cm.contentDOM.dispatchEvent(
new ClipboardEvent("paste", { clipboardData: dt, bubbles: true, cancelable: true })
);
Attachment naming and plugin hooks then behave exactly as for any pasted image. The two caveats are the ones a native version would not have: it needs the Electron clipboard API (desktop only) and a synthetic DOM event.
Related feature requests (optional)
- Pasting from Excel now pastes an image instead of a markdown table — same ambiguity, opposite side.
- Make the “paste with format” feature better customizable
- Add Svg clipboard paste — another flavor that is on the clipboard but never chosen.