SilentVoid13 / Templater

A template plugin for obsidian
https://silentvoid13.github.io/Templater
GNU Affero General Public License v3.0
3.21k stars 194 forks source link

Problem of compatibility with the new URI of obsidian 1.7.3 and obsidian web clipper #1465

Open MelodyDuplaix opened 2 weeks ago

MelodyDuplaix commented 2 weeks ago

Plugin information

Describe the bug

Obsidian version 1.7.3 introduced a modification to the URI system, which is used by the Obsidian Web Clipper extension. The issue arises when there is a global template set in Templater's configuration, i.e., a folder template that applies to "/". When creating a note via a URI, such as with the Obsidian Web Clipper, there is usually content added—either directly from the URI or appended from the clipboard by Obsidian. I believe the content is not applied immediately, and there is a slight delay between the creation of the note and the insertion of the content. This causes a problem when using a global template with Templater because Templater tries to apply the global template to the empty note during this brief delay. As a result, approximately 50% of the time, when creating a note via the URI, the expected content is missing, and only the global template is applied.

Expected behavior

I would like the global template to be applied only if no content is inserted by Obsidian. I'm unsure how this could be achieved—perhaps by introducing a slight delay before applying the global template.

Zachatoo commented 2 weeks ago

I am not able to reproduce this on Obsidian 1.7.3 and Templater 2.7.2. Here is the root folder template I'm testing with. It is the only folder template I have in this vault.

# Heading

Content

Can you provide more details about your setup, such as if you have other folder templates, and the contents of the root folder template?

Templater already has a delay of 300ms, to account for core plugins such as Note Composer and community plugins such as Note Extractor. When I've adjusted this delay in the past, I've gotten bug reports saying that it broke other community plugins, so I would like to avoid adjusting that delay.

MelodyDuplaix commented 2 weeks ago

My root folder template is like this:

---
aliases: 
nature: 
tags: 
jour: <% tp.date.now("YYYY-MM-DD") %>
---

And, yes I also have other folder templates but I don't think that has anything to do with the problem: image

I also use the option in obsidian web clipper to not open the note (option "Save clipped note without opening it"). And, the bug isn't happen all the time, rather about once in 2.

Zachatoo commented 1 week ago

Do you have a specific URL I can test with? And the Clipper template? I've tried dozens of times and haven't been able to reproduce.

MelodyDuplaix commented 1 week ago

For example, I just retested, and it was reproduced with this page: https://resources.arc.net/hc/en-us/articles/22513842649623-Arc-for-Windows-2023-2024-Release-Notes and this clipper template : article-clipper.json.

I still can't understand why the bug doesn't appear every time, but only at certain times. I also found another solution (with advanced uri and a global shortcut to replace a general folder template) to create new notes with a global template, so this bug bothers me less now. So it's not that important to me anymore. And I don't know if others have had this bug.

Zachatoo commented 6 days ago

Tried with that site and template a dozen time, no dice. Maybe it's a Windows only bug, or some combination of plugins is causing the bug. I don't have a Windows 11 device to test with.

Regardless, I'll keep this open for a while to see if any devs can reproduce and have ideas for solutions around this.