MetaEdit plugin

MetaEdit for Obsidian

Demo

Link

Features

  • Add or update Yaml properties and Dataview fields easily
  • Ignore properties to hide them from the menu
  • Auto Properties that have customizable, pre-defined values selectable through a suggester
  • Multi-Value Mode that allows you to detect and vectorize/create arrays from your values
  • Progress Properties that automatically update properties/fields
    • Works with total task, completed task, and incomplete task counts. Mark a task as completed (from anywhere), and the file will be updated with the new count.
  • Transform properties between YAML and Dataview
  • Delete properties easily
  • Auto update properties in files linked to from Kanban boards on lane change
  • Edit metadata through a filemenu
  • Edit last value in tags - works with Obsidian Tracker, too.
  • API to use in other plugins and Templater templates.

Some demos

Edit meta through link

Tag support

API


Dev Info

Made by Christian B. B. Houmann
Discord: Chhrriissyy#6548
Twitter: https://twitter.com/chrisbbh
Feel free to @ me if you have any questions.

Also from dev: NoteTweet, Templater Templates

18 Likes

I just released another API function: update.

This allows you to update metadata in your scripts, dataviewjs blocks, templatesā€¦ you name it.

Repository: GitHub - chhoumann/MetaEdit: MetaEdit for Obsidian

Hereā€™s a demo. You can get the dataviewjs block code here.

4 Likes

Iā€™m getting the ā€œFailed to load plugin Meta-edit,ā€ error.

Thatā€™s odd. I canā€™t recreate it. What preceded the error? Is this your first installation? Did you update? How?

It was my first installation, done by expanding the zip file in the plugins folder. I removed and reinstalled a couple of times with the same results. Anything else I can do to help you diagnose?

Did you extract the ZIP file straight into the plugins folder? Or did you create a new folder in the plugins first, and extracted the ZIP file contents in there? Or did you extract the folder from the ZIP file into the plugins folder?

Do other plugins work?
What are the contents of your metaedit folder in plugins?
Is the metaedit folder written like ā€˜metaeditā€™ or ā€˜MetaEditā€™ - maybe rename to all lowercase.

I have updated the instructions for installation. There is now a video showcasing how to install it: GitHub - chhoumann/MetaEdit: MetaEdit for Obsidian

Thanks for the help. As you likely suspected, it was user error. Iā€™d downloaded the MetaEdit-master zip, rather than the 1.6.2 zip. All systems are go. The video is helpful. Thanks again.

1 Like

Iā€™m glad to hear that it works now! :grinning_face_with_smiling_eyes:

1 Like

Hi there,
I like the idea of the plugin, and the demos you provide are impressive, but my script-fu is weak ā€¦ is there a walk-through somewhere of some of the examples (the tags and the library ratings, at least?) - the gifs go too fast for me to see whatā€™s going on, and I canā€™t for the life of me figure out the setupā€¦
thanks!

2 Likes

Hey! Thereā€™s only really that which is on the repository.

Could you clarify what you are having trouble with more specifically? :slight_smile:

The two gif demos that are shown in your original post - the one with the book ratings and the one with tag support ā€¦ do you have a sample setup that I could look at to figure out how you did it?

Ahh, I see. Those were taken on my own vault to demonstrate the ā€˜Edit Metaā€™ feature and how tags are supported.

Edit Meta
You can right-click any file / link and click ā€˜Edit Metaā€™, which will ask you which frontmatter property or dataview field you want to edit.

Tag support
You can change the value of a tag. If you use the MetaEdit method, it changes the last item in a tag. So if itā€™s #tag/nested, it would change nested.

I hope this helps a bit. Itā€™s been a while since I changed the things shown in the GIF, so I canā€™t just retrieve them, unfortunately.

It took a bit of trial and error to work out the inner workings, but I was able to make metaedit work with dataviewjs. For my use case, I have a monthly note (named YYYY-MM.md) and daily note (named YYYY-MM-DD.md) that all live in the LogBook directory. The daily notes include metadata about when I start and end my day, and hours I worked. I created a file with the code below and itā€™s embedded it in my monthly note.

Now, I just click on hours, startTime, endTime, or note cell, and can edit the value in the monthly note without leaving the page. The only downside is that the only way to clear a value is to type a space in the modal prior to hitting enter. Would love to be able to just hit enter to clear. editMetaElement doesnā€™t return the content on what was entered so thereā€™s no way to know whether a value was entered or not - if it did, I could use the update operation to clear out the value on my own.


const app = this.app;
const metaedit = app.plugins.plugins["metaedit"];

const init_dom = (row) => {
	const sel = `table.dataview.table-view-table td > span > a[data-href='${row.file.path}']`;
	const tr = dv.container.querySelector(sel).closest("tr");
	
	const labels = tr.querySelectorAll("._dataview-labels");
	for (let i = 0; i < labels.length; i++) {
		const data = labels[i].data
		const file = app.vault.getAbstractFileByPath(row.file.path);
		const prop = {key: data.name, content:data.actual, type: data.type};
		labels[i].addEventListener('click', async (evt) => {
			metaedit.controller.editMetaElement(prop, [], file);
		});
	}
}

const field = (row, name, type) => {	
	let data = {};
	data.row = row;
	data.name = name;
	data.actual = row[name];
	data.value = row[name];
	data.type = type || 1;

	const el = this.container.createEl('span', {"text": row[name] || "-"});
	el.classList.add("_dataview-labels");
	el.data = data;
	return el;
};

try {
	var workspace = dv.container.closest("div.workspace-leaf");
	var title = workspace.querySelector("div.view-header-title");
	var prefix = title.innerHTML;
	
	let pages = dv.pages('"LogBook"')
		.sort(t => t.file.name)
		.where(t => t.file.name.startsWith(`${prefix}-`) && t["type"] == "logbook-daily");

	dv.table(
		["File", "Hours", "Day", "Start Time", "End Time", "Notes", ""], 
		pages
		.map(t => [
			t.file.link, 
			field(t, 'hours'),
			t["weekday"], 
			field(t, 'startTime'),
			field(t, 'endTime'),
			field(t, 'notes')
		])
	);
	
	setTimeout(function(){
		for (let i = 0; i < pages.length; i++) {
			init_dom(pages[i]);
		}
	}, 0);
} catch (err) {
	window.console.info(err);
}

Screen Recording 2021-07-28 at 8.14.53 PM

8 Likes

I just realized that supercharged links actually does this all for you.

You can right click the link with MetaEdit enabled and click Edit Meta, toošŸ˜

2 Likes

that is so cool. it tried metaedit but couldnā€™t figure out how i can edit values on dataview tables. is it dependent on the script you used or it is a metaedit feature?

thanks for this great plugin.

is there a way to pre-set nested values. for example giving project.order a defined set of values. I am not sure its not supported or i am doing the syntax wrong

Very true. Iā€™ve been playing with both plugins to get a sense of what they can do. What I really like about yours is the exposed API. Thatā€™s something supercharged links does not have.

1 Like

Iā€™ve already responded elsewhere to this, but to people wondering; both are dependencies. The scripts utilize the MetaEdit API.

1 Like

Thank you! Nested properties are not currently supported. Have some things in the works for them.

2 Likes