Bases: Readonly Mode

Use case or problem

It’s currently very easy to accidentally hit the “X” next to a list item in a Base, and without an Undo feature, this can make it kind of anxiety-inducing to even have a Base open. Doubly so on mobile, where an undo feature would be hard to access.

Proposed solution

Like with normal pages, I would love to just toggle on a “Reading view”. And embedded Bases could inherit this property from the page they’re embedded into.

13 Likes

As the Obsidian team has said this feature isn’t currently planned, here’s how to do it with CSS.

Read-only base

Prevent edits while still being able to click on links:

/* All your base are belong to you
	- Prevents editing items in base rows but allows link clicking
	- Allows using views, filters, properties, and sorting */
 
.bases-tbody {
	pointer-events: none;
	
	& :is(a, .metadata-link, .mod-date + .clickable-icon, .internal-link .multi-select-pill-content) {
		pointer-events: auto;
	}
}

Customize your own

Total lockdown:

/* All your base are belong to read-only
	- Locks down all base rows
	- Allows using views, filters, properties, and sorting */

.bases-tbody {
	pointer-events: none;
}

Lockdown with exceptions:

/* Somebody set up us the bomb
	- Locks down base rows but with the exceptions listed in `is()`
	- Allows using views, filters, properties, and sorting */

.bases-tbody {
	pointer-events: none;
	
	& :is() {
		pointer-events: auto;
	}
}

Specified read-only items:

/* Make your time
	- Prevents editing base items that are listed in `is()` */

.bases-tbody :is() {
	pointer-events: none;
}

Selectors you can add:

Selector Bases item
.metadata-input-checkbox checkboxes
.metadata-input-longtext text
.multi-select-container lists (includes tags)
.multi-select-container .multi-select-pill-content tags: click to search for tag (but also edit the values in list entries)
.mod-date dates (includes links to “open daily note”)
.mod-date + .clickable-icon link to “open daily note” beside a date (“Daily notes” core plugin)
a link to row’s main note
.metadata-link link in text
.internal-link .multi-select-pill-content link in lists
8 Likes

Quick overview, I have a table displaying customer data (names, addresses, etc) which I don’t want to modify from within bases/table view, I only want to view. When displaying a list within the table, each list item has an X to remove it, which means it could be possible to accidentality delete list entries by mistake.

I want to be able to prevent this happening, some ideas:

  • Being able to view in source/preview, same as notes, can only modify in source mode.
  • Being able to “lock” columns to prevent changes

Apologies if I’ve missed that this is already a function

2 Likes

Agree with this! And thanx @dawni for the brilliant workaround!

A bit more cumbersome than using CSS but I think another workaround could be to rely on formula properties in a dedicated view to get the desired properties displayed :blush:

I mean, instead of simply selecting a key to add in the base (using the Base GUI), one can create a formula property and use something like myProp in the formula box to display its value which would be somewhat uneditable/read-only (afaik/iirc :sweat_smile: ) as one would need to edit the formula first to edit the values it displays (or update the values of the property in the relevant notes).

This is just a thought though :innocent:

2 Likes

Are these css files still valid? I tied the following to lock down the field “name” but It didn’t seem to work.

/* Make your time

  • Prevents editing base items that are listed in is() */

.bases-tbody :is(name, ) {

pointer-events: none;

}

To lock down a column based on the name of your property, you can do:

.bases-td[data-property="note.your property name"] {
	pointer-events: none;
}

The one you were using (from my earlier post) is for property types. This one is for property names.