husjon / obsidian-file-cleaner-redux

A plugin for Obsidian to help clean up files in your vault
MIT License
28 stars 2 forks source link

.excalidraw.md files are not deleted + feature ideas #61

Closed Iphinis closed 1 week ago

Iphinis commented 3 weeks ago

Hello,

Is it normal that .excalidraw.md files aren't deleted with . and even with .excalidraw.md or .excalidraw. ?

I also tried *.excalidraw. and .excalidraw.md but those seems to be incorrect expressions (they are deleted instantly when I close the settings panel). Maybe it is because it ends with ".md" ? (that expression doesn't work either, thankfully ahah, for security reasons I suppose)

Also I have an idea, when the deleting prompt appears it would be nice if we could check for each file (or even folder) whether we delete it.

Another little thing is that it would be nice in the setting panel if the textbox had a min-width (according to its content, or not, as you wish).

Thanks in advance.

husjon commented 3 weeks ago

Hmm this might be because of the .md suffix which might make it so that the plugin assumes that is is a normal markdown file and does not do further processing (other than the file being completely empty). I'll need to look into this further.

As for the file extensions you tried, I think you should have tried the following: .excalidraw.* and .excalidraw.md, as in omitting the initial *.

Regarding the check for each file (and/or folder) to be deleted, do you mean just inspection or to select if they should be deleted or not as in a checkbox, if so this is in the works (however taking some time) with the following issue #58

As for textbox min-width in settings, this I agree with wholly, I created an issue for it and I'll take a loook at it in the near future (#62).

Iphinis commented 3 weeks ago

Yup, I think I have already tried it when I opened the issue but I didn't want to bother writing all my tests. To be sure I just did it right now and it doesn't work.

Yes something like a checkbox for each element! Because when I clear my files there could be a situation where I don't want to remove a certain file at the moment. Furthermore, you could also create an option to ignore certain files (as you did for folders), and in addition creating a button next to the checkbox and the file/folder name to add it to the ignored list (when the user wants to clear the vault).

Thank you very much for considering my suggestions! Implement them if you wish and perhaps gradually ;)

husjon commented 2 weeks ago

So, I've had a look at why the excalidraw files are not deleted. They do use their own format, however it does follow markdown standard so it is possible to parse and determine if they are empty or not.

My main issue is that Excalidraw by default compresses the files to make the drawings take less space (not a bad thing at all it just complicates things), this seem to use an external library which I kinda do not want to include in this plugin for this one specific case. What I am however thinking off is to make it possible so that if the Excalidraw files are not compressed (which can be toggled in Excalidraws settings), I can clean them up by inspecting the content and verify that they are empty.

This will unfortunately take a bit of time to get it working. However with the rewrite I did back in June will make it a bit easier as I did make it possible to further inspection code blocks etc (which Excalidraw uses to contain the drawing data).

As for the size of the text boxes, I have prepared a fix and will be releasing it shortly (#63), they will now be resizable within a certain range and wont freak out like before. :)

husjon commented 1 week ago

Hi @Iphinis, I have now prepared a pull request to add support for Excalidraw files (see #66). As mentioned in my previous comment, this will require the user to disable compression in Excalidraw.

I will merge the PR some time tomorrow, it will be a part of v1.1.0.

Iphinis commented 1 week ago

Hi @husjon! First of all, thank you so much for your work!! I just tried the new features and actually what I meant by deleting excalidraws was delete those that weren't referenced (or embeded as they say) in a .md document.

I think you misunderstood my request but it's also a cool feature to clean empty drawings :)

Would it be possible to implement the suppression of unreferenced excalidraw files, like it's done for other formats such as .png etc ? What I mean is that I want to keep drawings that are referenced such as ![[Drawing.excalidraw]] in Wikilinks format but delete those that aren't embeded/referenced/linked in a markdown file.

Thank you in advance!

husjon commented 1 week ago

Ah, so if I understand it correctly excalidraw files should have been handled like attachments instead of how they are now, is that correct?

If so, please also leave a comment in the the following issue above so I can track it there (#68), thanks :)