Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[功能请求] 快速插入图片 #14

Open
supremew opened this issue Apr 25, 2022 · 2 comments
Open

[功能请求] 快速插入图片 #14

supremew opened this issue Apr 25, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@supremew
Copy link

supremew commented Apr 25, 2022

Is your feature request related to a problem? Please describe.
coc-markdown-preview-enhanced 中插入图片还不是很快捷。

Describe the solution you'd like
增加一个插入图片的命令,别如 insert-image; 例如

  1. 在 yaml front matter 头, 设置图片储存位置。 默认值可以是 文件所在目录下以文件名去掉扩张名的文件夹;
  2. 在 yaml front matter 头,设置图片链接前缀。 例如 https://www.xxx.xxx/image/ 或 /xxx/xx/image (本地图片位子)
  3. 根据 1 和 2 中设置进行拼接得到完整的图片路径;

例1, 位于 /home/archlinux/md/测试.md 文件, 文件中设置了 image-directory, image-prefix 时

---
title: 测试
image-directory: image 
image-prefix: https://www.picturebed.com/
---
# 图片测试

在这里执行图片插入命令 `image-insert`, 可以辅助插入

![](https://www.picturebed.com/image/)

例2, 位于 /home/archlinux/md/测试2.md, 未设置 image-directory, 设置了 image-prefix.

---
title: 测试
image-directory:  
image-prefix: https://www.picturebed.com/
---
# 图片测试

在这里执行图片插入命令 `image-insert`, 可以辅助插入

![](https://www.picturebed.com/测试2/)

例3, 位于 /home/archlinux/md/测试3.md, 未设置 image-directory,image-prefix.

---
title: 测试
image-directory:  
image-prefix: 
---
# 图片测试

在这里执行图片插入命令 `image-insert`, 可以辅助插入

![](测试3/)

例4, 位于 /home/archlinux/md/测试3.md, 未设置 image-directory,image-prefix.

---
title: 测试
image-directory:  .images/
image-prefix: /home/archlinux/
---
# 图片测试

在这里执行图片插入命令 `image-insert`, 可以辅助插入

![](/home/archlinux/.images/)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@supremew supremew added the enhancement New feature or request label Apr 25, 2022
@weirongxu
Copy link
Owner

这个功能不太适合在这里实现,上游依赖的是 mume 可能得 mume 先实现类似的功能。

@NeumoNeumo
Copy link

You may try out img-paste.vim as an alternative. The default keymap to insert an image is <leader>p. Additionally, you can specify different insertion format for different filetypes using auto command.
For example, this is my config to save image at in the folder img/<FilenameWithoutExtension>/:

vim.cmd[[
augroup vimrc
  " Remove all vimrc autocommands
  autocmd!
  au FileType markdown let g:mdip_imgdir = "/img/" .. expand("%:t:r")
augroup END]]

你可以试试img-paste.vim作为平替,默认快捷键是<leader>p。你还可以为不同格式的文件设置不同的插入的样式(例如latex, markdown),这要用到vim的自动指令。
比如这是我的设置,把图片保存到img/<FilenameWithoutExtension>/:

vim.cmd[[
augroup vimrc
  " Remove all vimrc autocommands
  autocmd!
  au FileType markdown let g:mdip_imgdir = "/img/" .. expand("%:t:r")
augroup END]]

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants