Option to lock editing of individual notes

Unfortunately, it doesn’t help with templates, because the YAML gets inserted when you use the template.

Within the template note, force the view mode by writing in the YAML.

Write: “obsidianUIMode: preview”

Then when you open that template, it will open in preview as default. The YAML insertion when you use the template on a new note isn’t relevant here

It’s very relevant here. I don’t want that YAML in every note I insert that template into. It rather defeats the point of having a template.

Ah okay, I see what you mean.

I’ve never accidentally edited any of my template notes, they just live inside a template folder. I only access that when I’m adding to or editing my templates.

I’m looking for this feature too. Did any of you find a good solution?

Likewise.

Wow. I just realised I replied to my own reply from seven days ago not realising it was me.

2 Likes

I’m pasting my comment from Disable auto-save or change frequency - #68 by Iconca here because i feel it’s directly connected. I’d love to be able do Ctrl+save a file at some point. Do a bunch of stuff to it and then, if I screwed up sth, simply close the note and be back into the last saved stage of my work. Autosave is constantly messing up things for me. Or if this isn’t possible, at list, to have an option to lock a note that i’m done working on. Ideally locking the actual content, not only the view mode. Because I would often want to see source code of the note as a reference, while not being able to destroy it. In fact I’d really, really appreciate both options. Write now I’m kind of scared to use Obsidian at all and especially for any topic really significant to me.

1 Like

I get that. There are times I like to do experiments with files and then roll back if it doesn’t work.

May I make a suggestion? You might really benefit from checking out git. Because you can save snapshots of your notes, and then roll back to versions. Some people use a plugin to auto-snapshot with git. I just do manual snapshots occasionally, and review the stuff that has changed. There is also another community plugin that lets you navigate git versions and see what changed.

Git, or any other version control software. It could help get rid of some of that fear, and give you confidence to experiment again. And if things get destroyed, you can just roll back.

(Also a good idea to be able to lock a note, even in source mode.)

1 Like

Of course I’m very grateful for suggestions I’ve thought about something like manual snapshots although it still wont prevent doing things by accident. Since all notes in a volt are often connected and influence each other. I did notice some comments about auto-snapshots. I imagine it may be a little overkill for my use, but I’ll definitely check it.
Exact science like coding and stuff it’s not my strongest point. But the amount off customization available in Obsidian is mind-blowing. It’s sth I really appreciate because I don’t absorb knowledge if things aren’t arranged exactly how I want them. So I’m definitely not giving up. Actually I’m just making a list of things about Obsidian to look up. I guess your proposition will go under nr 17 :slight_smile:

This is a feature worth implementing as the currect workaround with YAML doesn’t make any sense. I think the perfect solution would be adding an option in settings to give every note it’s own view mode.

Hi all, an easy solution for the “Accidental Save” issue is to set the template files to READ ONLY in your file system. I just tested this and when I tried to edit a template file Obsidian threw an error saying it couldn’t write to the file. Its easy to reverse this when you do want to edit the templates. And this of course could be applied to any file you don’t want changed.

Keep in mind that if you have Sync set up, this will probably create issues.

@Iconca I completely agree. I, too, am to afraid to use it how I want to because of how easy it is to make a change to something you want just so.

@rigmarole Snapshots will definitely help but sometimes I don’t know until months later that I’ve changed something and even sometimes I don’t know what and the note has been added to since so it gets complicated.

I don’t know what the solution is but I wish there were something in the GUI that allowed me to “lock” certain parts of the notes. I realise this is tricky.

I’ve been experimenting with the plugin mentioned in another thread;

However, it doesn’t lock notes; just makes them open as previews.

Is it bad to reply to this given that it’s from a while ago?

The only thing preventing me from using Obsidian as a place to gather knowledge is the inability to lock fields.

It isn’t bad if you have additional information to contribute. But bumping the thread just to bump it would be against our COC for “campaigning”. So kindly: please no more. We all wish our favourite features could get priority.

3 Likes

Use case or problem

I often store code snippets, solutions from websites and scripts and so on in Obsidian. Basically I use it as my personal knowledge base. Once a note is edited to it’s final state, I would like to write protect it, so there is no possibility for accidental changes.

Current workaround (Does not work)

I tried to workaround this issue by simply toggling the protection bit of a note directly in macOS Finders Fileinfo-Panel. Unfortunately, Obsidian “flips out” on these files, so it doesn’t work this way.

Proposed solution

There should be a checkbox or a context menu item somewhere to toggle the protection mode of a note.

I propose to fix the “workaround” first. If this works, a GUI feature could easily be implemented on a plug-in level.

I can’t implement feature requests, but I can propose potential workaround. When reading your request, I immediately thought of the Force note view mode plugin. This allows you to force the mode any file is opened in.

In other words, if you add obsidianUIMode: preview to the finalised notes in your vault with this plugin enabled, at least you have to consciously switch back to an editing mode before you’re able to do any changes to that file. :smiley:

1 Like

Another option is using some CSS and a cssClass to lock editing of a note. The CSS:

.lock-note * {
    -webkit-user-modify: read-only !important;
}

and in the Properties of the note(s) you want locked:

The Properties in document will be editable, i.e., you can remove the lock-note class by clicking the x, but not if you switch to Source mode. If you get stuck in lock-mode, you can remove the cssclass from the sidebar Files properties tab or using an external app.

https://help.obsidian.md/Extending+Obsidian/CSS+snippets

1 Like

Do you know how this works, @ariehen ? It also seems like it’s better to use contenteditable: false, according to contenteditable - HTML: HyperText Markup Language | MDN

But it beats me how this is meant to work…

1 Like

Huh, it looks like user-modify is “non standard” and “depreciated”.
https://developer.mozilla.org/en-US/docs/Web/CSS/user-modify Seems to work though. :smiley:

I hadn’t used contenteditable before, but it pops up in the app.css a few times:

Screenshot 2024-03-18 at 9.38.58

Will give that a try the next time around.