quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
297 stars 23 forks source link

Paste Image in Source editor #326

Open JosiahParry opened 9 months ago

JosiahParry commented 9 months ago

I quite love that I can paste an image from my clipboard into the visual editor and it saves the image into ./images. But I cannot do this using the source editor. I would reallyyyy like to! Mostly because I do not like how the visual editor edits my file and adds additional spaces between lines.

https://github.com/quarto-dev/quarto-cli/discussions/7623#discussioncomment-7601035

minh711 commented 9 months ago

Here is my solution to paste an image from clipboard in Visual Studio Code, hope it helps:

  1. Open settings.json
  2. Add the following setting:
    "files.associations": {
    "*.qmd": "markdown"
    }
  3. Save the settings.json file and restart VS Code.

Now, VS Code recognizes the .qmd files as .md files, so that you can follow the instruction here to paste an image from clipboard for .md files: https://stackoverflow.com/questions/75831497/how-can-i-paste-images-into-my-markdown-files-in-vs-code

In VS Code Settings UI, to set the pasted image to store in ./images (this is also provided in the link above): image

mpf commented 7 months ago

Nice tip. But unfortunately it has the side of effect of disabling some of the quarto highlighting.

minh711 commented 7 months ago

Nice tip. But unfortunately it has the side of effect of disabling some of the quarto highlighting.

Thank you very much for your response. I've discovered another way to achieve this without modifying the settings in settings.json.

We can find the Select Language Mode option at the bottom-right of VS Code window:

image

Then we can search and chose Markdown when we need to paste images from the clipboard:

image

Then switch back to Quarto while typing:

image

While this method may still be somewhat inconvenient, it's faster than saving the image and importing it manually.

liquidcarbon commented 5 months ago

@minh711 have you tried the other way around - using $documentExtName to associate Markdown settings with .qmd extension?

Looks like I've made the same request in the wrong repo: https://github.com/quarto-dev/quarto-cli/discussions/8962

P.S. I wish Quarto used just .md. Is it a matter of branding? Attempted vendor lock-in?