Skip to content

Commit

Permalink
Add text/uri-list support for paste_img
Browse files Browse the repository at this point in the history
  • Loading branch information
ottersome committed Feb 20, 2025
1 parent 14e0427 commit 55f6844
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/obsidian/img_paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ local function clipboard_is_img()
-- See: [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme)
local this_os = util.get_os()
if this_os == util.OSType.Linux or this_os == util.OSType.FreeBSD then
return vim.tbl_contains(content, "image/png")
if vim.tbl_contains(content, "image/png") then
return true
elseif vim.tbl_contains(content, "text/uri-list") then
local success =
os.execute "wl-paste --type text/uri-list | sed 's|file://||' | head -n1 | tr -d '[:space:]' | xargs -I{} sh -c 'wl-copy < \"$1\"' _ {}"
return success == 0
end
elseif this_os == util.OSType.Darwin then
return string.sub(content[1], 1, 9) == "iVBORw0KG" -- Magic png number in base64
elseif this_os == util.OSType.Windows or this_os == util.OSType.Wsl then
Expand Down

0 comments on commit 55f6844

Please sign in to comment.