excalidraw / excalidraw-vscode

Excalidraw for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=pomdtr.excalidraw-editor
MIT License
477 stars 60 forks source link

Files stop working when renamed from *.excalidraw to *.excalidraw.svg and vice versa #46

Closed chronicc closed 2 years ago

chronicc commented 2 years ago

Description

When an excalidraw file is renamed to another supported extension (e.g. from *.excalidraw to *.excalidraw.svg and vice versa) the file can not be opened by the excalidraw plugin anymore. It only shows a blank VSCode when opening the file.

Steps to reproduce

  1. Create a file with the supported extension (e.g. test.excalidraw)
  2. Optionally add some graphs to the file
  3. Rename the file to test.excalidraw.svg
  4. Close and open the renamed file

Expected behavior

Renaming the extension to another supported extension should not render the file unusable by VSCode.

Workaround

  1. Create a new file with the required extension
  2. Copy and paste the contents from the old file to the new file
pomdtr commented 2 years ago

Interesting usecase. I'm not sure we will be able to support it.

As an alternative workaround, you can export the current drawing to the desired format using one of these buttons (and selecting the embed scene option): image

chronicc commented 2 years ago

True, this is also a good workaround when starting from the original .excalidraw extension. Hope you can find a way. It is not super problematic since there are 2 workarounds currently. Would like to keep this open for some time if somebody wants to come up with a solution, if this is okay.

dwelle commented 2 years ago

Was just trying to do the same :).

I think we should support this as it'll block users once we may make this stable. Is there a fundamental limitation that would block this?

pomdtr commented 2 years ago

In order to support this, I think we should try to detect the format of the input without using the file extension. We would only use the extension when the user save the drawing.

I think this PR would allow us to do this: https://github.com/excalidraw/excalidraw/pull/5057

pomdtr commented 2 years ago

Ok I have a naive but working solution (basically I try to load the file as a json/png/svg sequentially).

I agree that it it feels really good to be able to change the filetype by renaming the file :)

dwelle commented 2 years ago

🌮 ❤️

chronicc commented 2 years ago

Thank you very much.