Open chrisgrieser opened 1 year ago
@chrisgrieser Thanks!
There's an item for that in the README.md TODO section. I've actually been thinking a lot about that and the code supports it, but it has multiple issues described in the code itself:
/* XXX Issues with allowing a user-configured history folder:
- any history folder will mimic the the structure of the note
directory (alternatively history files could be on a flat
directory with the name coming from a hash of the full path, but
that makes renaming more involved, and fishing for history files
less intuitive)
- due to an Obsidian design decision, folders cannot start with "."
so the user-defined history folder be visible in the file explorer
- Note this limitation is not consistently enforced through the
API:
- Obsidian does allow createBinary on a path starting with a
dot and it successfully creates the file
- Unfortunately getAbstractFileFromPath on a path starting
with a dot fails so the file can be created (which only
requires the path) but not modified (which requires a
TAbstractFile)
- because it's visible, the user can rename the edit history folder
from the obsidian UI,
- renaming the topmost directory could be supported since the
only thing needed would be to update the internal variable.
Obisidan API notifies of the top level rename and each
children, which can be ignored. This will need care depending
on the reporting order of root vs. children and the update of
the internal variable.
- if the user renames a non-top level directory then all
children history files would go out of sync, so this is a
problem.
- the Obsidian setting onChange gets called on every keystroke, so
configuring the edit history folder in settings would cause a
rename on each keystroke. There doesn't seem to be a final
changed(), hide() is not called either
- it's not clear whether the folder should be deleted if empty
- it's not clear if it's safe to just copy all the files found with
whatever extension new Setting(containerEl) .setName('Edits
folder') .setDesc('Folder to store the edit history file. Empty to
store the edit file in the same directory alongside the original
file. Due to Obsidian limitations this must start with a character
other than "."') .addText(text => text .setPlaceholder('Enter the
folder name')
.setValue(this.plugin.settings.editHistoryRootFolder)
.onChange(async (value) => { logInfo("onChange");
logInfo('Edits folder: ' + value); // Only allow top level
folders
this.plugin.settings.editHistoryRootFolder = value;
// XXX Can the folder just be renamed via the file explorer
interface? // XXX Check no dir component starts with "." // XXX
Delete edits? copy them to new folder? trash them? // XXX Ask the
user to delete folder? // XXX Ask for confirmation? // XXX Use
private apis to store in some hidden folder? await
this.plugin.saveSettings();
}));
*/
https://github.com/antoniotejada/obsidian-edit-history/blob/master/main.ts#L899
I will give it more thought, but the more I think about it and the more I use it the more I like the fact that the edit history files are alongside the notes.
Leaving this open.
Your suggestion of preceding the edit history file by "." looks the most doable, but I think it will need to use the adapter Obsidian API which is frown upon (that is for sure the case if you try to create folders starting with ".", will need to verify for files).
I know that the pandoc reference list plugin creates files in a .pandoc
folder in the vault, and it's from one of the Obsidian devs, so maybe they are using a good method?
https://obsidian.md/plugins?id=obsidian-pandoc-reference-list
I like this addon, but the way it's storing the edited files is messing up my structure. If you can't hide or do something with the files visibly showing themselves, it would be nice to allow a subfolder to be specified.
Such as all edits being migrated to a folder at the bottom of the list called .history or something and not planted directly below the file that was changed. Then if I need to see the edits, I can just go to the specified folder and pick out what I need to view edits for.
@Aetherinox they don't show for me in the Obsididan file explorer, I guess you have enabled "detect all file extensions" under Obsidian Files & Links?
To me keeping the edit history file alongside the note is a feature, not a bug. It makes edit history file backup transparent and having its own folder only makes things more complicated as I describe above, so I'm not very motivated to do anything about it.
The most likely thing I may do is to put a settings toggle so the edit history filename starts with a dot, which should hide it in some operating systems, and from a cursory test also in the Obsidian file explorer even with "detect all file extensions" set.
I know that the pandoc reference list plugin creates files in a
.pandoc
folder in the vault, and it's from one of the Obsidian devs, so maybe they are using a good method? https://obsidian.md/plugins?id=obsidian-pandoc-reference-list
For the record, pandoc plugin uses the bad api,
https://github.com/OliverBalfour/obsidian-pandoc/blob/68ff9e3733cc73055156455721fc736ad45c7d5e/renderer.ts#L166 https://github.com/OliverBalfour/obsidian-pandoc/blob/68ff9e3733cc73055156455721fc736ad45c7d5e/main.ts#L64
Disabling detect all file extensions seems to address the issue of it showing, but do you know if there's a place where the recognized files are listed? Because I'm wondering why I turned that on now and must have had a reason. But with my vault being so massive, it's hard to track down where.
Adding the prefix of a period would be helpful on my linux system.
@Aetherinox
Disabling detect all file extensions seems to address the issue of it showing, but do you know if there's a place where the recognized files are listed?
I'm not aware there's such a thing, but I just found out about detect all file extensions myself by poking around.
Looking at the sources, that setting corresponds to showUnsupportedFiles
t.prototype.isSupportedFile = function(e) {
var t = this.app;
return !!t.vault.getConfig("showUnsupportedFiles") || t.viewRegistry.isExtensionRegistered(e.extension)
}
So if the extension is registered then the file will be shown in the Obsidian file explorer (and available as file suggestion in the quick picker, etc). My guess is that they are regarded as registered if they have an associated core or plugin view.
Adding the prefix of a period would be helpful on my linux system.
Right, note would also hide it from the Obsidian file explorer even if you have "detect all file extensions".
My guess is that they are regarded as registered if they have an associated core or plugin view.
@Aetherinox Boils down to calling registerExtensions
See
https://docs.obsidian.md/Reference/TypeScript+API/Plugin/registerExtensions
https://github.com/MeepTech/obsidian-custom-file-extensions-plugin
This CSS
snippet hides the edtz
files from the file explorer.
.tree-item.nav-file:has(div[data-path$=edtz]) {
display: none;
}
Obsidian v1.4.9
@gapmiss
This
CSS
snippet hides theedtz
files from the file explorer..tree-item.nav-file:has(div[data-path$=edtz]) { display: none; }
Obsidian v1.4.9
That sounds like a great suggestion for the styles.css file, thanks!
There's also files and links -> Excluded files. Also see discussions
Thanks for such a great plugin. For hiding the file extension through "css" and some other setting helps but as a makeup only. I personally do not want to potentially "double" the number of my files in my vault.. and perhaps want to avoid them being indexed too.. Also I don't want to see them in the file explorer as well.. Too many files.. So please reconsider to give us an option to store your "edtz" files in a dedicated folder.. Thank you..
Thanks for the plugin, this was actually sth, I've been looking for a while.
What I'd like to have is a method to keep the edit history files out of sight. Right now, they are saved in the same folder as the note, so when you switch to the file explorer, your folder is cluttered with files you are not going to actively work with.
So what I'd like to propose is one of two options which would accomplish that.
.
prefix (e.g..notename.md.edtz
). At least on mac and Linux, this hides those files by default.