Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MelodyDuplaix opened this issue Sep 26, 2024 · 15 comments
Labels
bug Something isn't working needs repro Reported issue needs to be reproduced

Comments

@MelodyDuplaix
Copy link

Plugin information

  • OS: Windows 11
  • Templater version: 2.7.2
  • Obsidian version: 1.7.3
  • Templater settings: Folder templates: "/",

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.

@MelodyDuplaix MelodyDuplaix added the bug Something isn't working label Sep 26, 2024
@Zachatoo
Copy link
Collaborator

Zachatoo commented Oct 1, 2024

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.

@Zachatoo Zachatoo added the awaiting response More information has been requested, waiting to hear from the submitter label Oct 1, 2024
@MelodyDuplaix
Copy link
Author

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
Copy link
Collaborator

Zachatoo commented Oct 8, 2024

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
Copy link
Author

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
Copy link
Collaborator

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.

@Zachatoo Zachatoo added needs repro Reported issue needs to be reproduced and removed awaiting response More information has been requested, waiting to hear from the submitter labels Oct 10, 2024
@jgodoy
Copy link

jgodoy commented Nov 4, 2024

I have the same issue on Windows 10... After the note is created, pressing CTRL-Z (undo) recovers the clipped text. It happens almost 100% of the time (just so that I don't say 100% of the time).

NOTE / EDIT: I'm on Obsidian 1.7.4.

@jgodoy
Copy link

jgodoy commented Nov 4, 2024

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.

What did you do to fix this?

@MelodyDuplaix
Copy link
Author

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.

What did you do to fix this?

I used an external software (power toys) to create a shortcut that open an advanced uri url, to create a file and apply the global template, and I remapped this shortcut to Ctrl Shift N. I realize however that he seemed to not really work lately. Moreover, it's still complex for what it bringsI realize however that he seemed to not really work lately. Moreover, it's still complex for what it brings.

But, I haven't tried again recently to put a global Template in templater and see if there is still the problem.

To check if it can come from an interaction between plugins, which other plugins do you use?

@Zachatoo
Copy link
Collaborator

Zachatoo commented Nov 4, 2024

A quick way to tell if it's an interaction between plugins would be to create a new vault with just the Templater community plugin installed and enabled.

@MelodyDuplaix
Copy link
Author

So, I tested again and for the moment I can no longer reproduce the problem whether in a test vault or in my personal vault.

@jgodoy
Copy link

jgodoy commented Nov 5, 2024

To check if it can come from an interaction between plugins, which other plugins do you use?

With only Templater being enabled the same thing happens.

I guess it is the order of the operations and the time Templater takes to process things.

The new note is created with the contents already populated, but then the global template is triggered and apples the template which replaces all the contents of the note... This is why undo always works.

@jgodoy
Copy link

jgodoy commented Nov 5, 2024

A quick way to tell if it's an interaction between plugins would be to create a new vault with just the Templater community plugin installed and enabled.

I think it is how the Templater plugin applies the template. This also started happening with notes shared on mobile directly to Obsidian.

I don't clip things that much, so I can't say when it started. Sharing or clipping to existing files work without issues as it doesn't trigger Templater templates.

@tlockney
Copy link

I'll just add that I'm seeing this on all my primary Apple devices (MacBook Air, iPhone, and iPad) as well, so it's not just Windows. I don't yet have any additional data points to add, though I'm planning to test it with a new, barebones vault with only Templater installed. My global template is pretty basic, so it's not a critical concern at the moment.

@tayiorbeii
Copy link

tayiorbeii commented Nov 17, 2024

I saw the same problem as @tlockney and @jgodoy when using the Obsidian Web Clipper on iOS– a new note was created, but only the title was applied then I would have to manually paste into the body.

However, this comment on Reddit pointed out that using a regex to tell Templater to ignore the "Clippings" directory allowed for the content to make its way into the note.

Here's what I used in Templater settings on both iOS and Desktop in order to work around the issue:
^(?!\/?(Clippings)\/).* (+Template)

@tlockney
Copy link

@tayiorbeii oh, nice! It somehow didn't occur to me that Templater was using regex, but now it seems obvious (and I'm guessing it's documented, but then I'd actually have to read the docs to find out🤣).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro Reported issue needs to be reproduced
Projects
None yet
Development

No branches or pull requests

5 participants