Skip to content

Commit 7481090

Browse files
committed
Add text/uri-list support for paste_img
1 parent 5eea5d2 commit 7481090

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added better handling for undefined template fields, which will now be prompted for.
1414
- Added support for the [`snacks.picker`](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) picker
1515
- Added support for the [`blink.cmp`](https://github.com/Saghen/blink.cmp) completion plugin.
16+
- Added support `text/uri-list` to `ObsidianPasteImg`.
1617

1718
### Changed
1819

lua/obsidian/img_paste.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ local function clipboard_is_img()
4040
-- See: [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme)
4141
local this_os = util.get_os()
4242
if this_os == util.OSType.Linux or this_os == util.OSType.FreeBSD then
43-
return vim.tbl_contains(content, "image/png")
43+
if vim.tbl_contains(content, "image/png") then
44+
return true
45+
elseif vim.tbl_contains(content, "text/uri-list") then
46+
local success =
47+
os.execute "wl-paste --type text/uri-list | sed 's|file://||' | head -n1 | tr -d '[:space:]' | xargs -I{} sh -c 'wl-copy < \"$1\"' _ {}"
48+
return success == 0
49+
end
4450
elseif this_os == util.OSType.Darwin then
4551
return string.sub(content[1], 1, 9) == "iVBORw0KG" -- Magic png number in base64
4652
elseif this_os == util.OSType.Windows or this_os == util.OSType.Wsl then

0 commit comments

Comments
 (0)