drawio-desktop icon indicating copy to clipboard operation
drawio-desktop copied to clipboard

File associations in MacOS

Open jamesharr opened this issue 3 years ago • 2 comments

  • [x] I agree to follow the Code of Conduct that this project adheres to.
  • [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Is your feature request related to a problem? Please describe. Many times when I'm working on a project with a number of different file types that are all usually stored in the same folder. I'd like to open a draw.io diagram from Finder (or Explorer if I was in windows). The current workflow I use is kind of awkward and unintuitive. See below for the workarounds I've been using today.

As a context item, I store a lot of my diagrams as .png files so that others who don't have draw.io can at least view them. It also provides a preview of the diagram in many cases, which is a great convenience. So my feature request revolves around two things 1) ability to preview for people who don't use draw.io 2) Finder/Explorer ability to open a PNG directly into draw.io without jumping through too many hoops. Hitting a single "Open With" menu for me is an acceptable

Describe the solution you'd like I would like the draw.io application to somehow advertise to macOS that it is capable of opening .png/.xml files. Even if I choose not to open every PNG file, it can at least show up in the "Open With" dialog in macOS.

Describe alternatives you've considered These are more work-arounds:

  • I open a new window of draw.io, and click/drag the file into it. If I forget to open a new document first, it just inserts the image into my existing diagram, which is a frustrating experience.
  • I go into the File/Open dialog in draw.io and have to navigate to the same folder that I have open in another window
  • I just use "open with", "other", change "recommended applications" to "all applications", and scroll around until I find draw.io

Other solutions that could possibly work (may require some experimentations):

  • Investigate if OS's can support double extensions, IE: .drawio.png

Additional context This is the typical Open With dialog. I'd like it if I can make draw.io appear in there. 2021-11-19 at 08 19

This is what happens when I select "Other applications". image

Digging around in stackexchange, I found this work-around for a different application, but I fully expect any changes I make to be overwritten as soon as draw.io upgrades:

  • https://apple.stackexchange.com/questions/131583/adding-to-open-with-list

jamesharr avatar Nov 19 '21 14:11 jamesharr

So, an example PR was closed because making drawing able to open a png via Finder would be too confusing. Are there any alternative ideas?

jamesharr avatar Nov 20 '21 12:11 jamesharr

I have a workaround solution for this. I created an Application using Automator that opens draw.io or Preview based on the double file extension. Then I associated .png files with the Application. You can simply double-click the .png file (or many .png files) and the correct app will open. Here's steps to do that:

  1. Open Automator and create a new Application.
  2. Add a "Run Shell Script" step
  3. Change "shell" to "/bin/bash" and set "Pass input" to "as arguments"
  4. Paste the script below.
  5. Save the Application to your Applications folder.
  6. Right-click on a .png file, click Get Info.
  7. In the "Open With..." dropdown, choose "Other..." and then choose the new Application.
  8. Click "Change all..." to associate all .png files with the new Application.

The script:

for FILENAME in "${@:1}"; do
  if [[ "$FILENAME" == *drawio.png ]]; then
    open -a draw.io "$FILENAME"
  else
    open -a Preview "$FILENAME"
  fi
done

georgeflug avatar Nov 10 '22 02:11 georgeflug

I think that workaround is good enough. Associating with .png on install is a step too far for me.

davidjgraph avatar Mar 24 '23 17:03 davidjgraph