zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.07k stars 221 forks source link

BUG: Data Loss, when switched from markdown to Excalidraw view #1711

Open psarras opened 5 months ago

psarras commented 5 months ago

Your environment Please run Command Palette/Show Debug info in Obsidian and paste the result here.

SYSTEM INFO: Obsidian version: v1.5.11 Installer version: v1.4.13 Operating system: Windows 10 Enterprise 10.0.19045 Login status: not logged in Insider build toggle: off Live preview: on Base theme: dark Community theme: Minimal v7.1.1 Snippets enabled: 6 Restricted mode: off Plugins installed: 55 Plugins enabled: 45 1: Kanban v1.5.3 2: Calendar v1.5.10 3: Wikilinks to MDLinks v0.0.12 4: Tag Wrangler v0.6.1 5: Templater v2.1.4 6: Image Toolkit v1.4.1 7: Tracker v1.13.1 8: Note Refactor v1.8.2 9: Show Current File Path v0.5.2 10: Natural Language Dates v0.6.2 11: QuickAdd v1.6.1 12: Recent Files v1.3.9 13: Ozan's Image in Editor Plugin v2.2.5 14: Advanced Tables v0.20.0 15: Advanced URI v1.38.1 16: Auto Link Title v1.5.3 17: Better Word Count v0.10.1 18: Periodic Notes v0.0.17 19: Window Collapse v1.0.2 20: Iconize v2.9.1 21: Style Settings v1.0.7 22: Supercharged Links v0.11.1 23: Settings Search v1.3.10 24: BRAT v0.8.3 25: Code Editor Shortcuts v1.14.0 26: Minimal Theme Settings v7.3.1 27: Local REST API v2.0.4 28: Shell commands v0.21.0 29: Sortable v0.3.1 30: Media Extended v2.11.1 31: Media DB Plugin v0.6.0 32: Omnisearch v1.21.1 33: Todoist Plugin v1.11.1 34: Metadata Menu v0.7.7 35: Outliner v4.8.0 36: Copy Block Link v1.0.4 37: Strange New Worlds (SNW) v1.2.5 38: Commander v0.5.1 39: Advanced Slides v1.20.0 40: Workspaces Plus v0.3.3 41: LanguageTool Integration v0.3.6 42: Relative Line Numbers v3.0.0 43: Excalidraw v2.1.3 44: Book Search v0.6.3 45: Dataview v0.5.66

RECOMMENDATIONS: Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets. Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Describe the bug

To Reproduce Steps to reproduce the behavior:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

I have tried to recover the file by copy pasting a past snapshot into a fresh document, didn't work. It seems like there is something corrupted on the document

I tried to open the file from the online editor excalidraw.com, didn't work.

I tried to open the file on a fresh obsidian instance, didn't work

The file still has the elements I drew but everything dissapears as soon as I try to add something new.

psarras commented 5 months ago

I was about to copy the excalidraw file...however I fixed the problem. I still think there is a bug and perhaps it is related with my setup. But I have encountered it before...

I am not sure why it happened but my drawing become like so:

image

i.e. for some reason a new "Drawing" sections was created above the "Text Elements". and the main drawing data though are repeated further down. like so:

image

I didn't intentionally copied the contents (the document is large, so it wouldn't even be possible for me to do it easily!

Let me know if you have any ideas why this is happening.

At least there is an easy temporary fix, whenever this happens for anyone at the same situation as myself.

Delete the Drawing sections that is located above the "Text Elements" section.

psarras commented 5 months ago

I think I managed to replicate it, it is probably my fault.

I've added some things on the template below the line

==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠==

if you switch to markdown before anything, nothing changes. if you add something you inject a "Text Element" header I guess at a predefined line on the document, and because the number of lines are not the same it chops the "Drawing" header along with the first 3 lines of json". Excalidraw recovers by but then you have 2 drawing headers, sees the first that is empty and things there is nothing there!

I guess it would be best to allow for templates to add data anywhere, but maybe that is a big ask? I've amended my template and now it is fine on my end.

zsviczian commented 5 months ago

You are using many plugins. Can you test this with all other plugins disabled and see if you are able to reproduce this issue?

The ==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== line is not even required and as you mention you can place anything in the template as long as it is above %% # Drawing or # Text Elements if text elements are present.

zsviczian commented 5 months ago

Just as an additional note... I found that when switching from Markdown to Excalidraw the markdown view does not save the last edit unless you change lines. I am going to explore this... and see if I can do something about it.