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

Execution of the tp.file.selection() function erase the selection in the note #1374

Closed
OXiOSDev opened this issue May 13, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@OXiOSDev
Copy link

Hello, I hope you can help me.
When I use the tp.file.selection() function, the part of the text that I have selected is deleted from the note in which I selected it.
Thanks for your help

Plugin information (please complete the following information):

  • OS: MacOS Sonoma 14.4.1
  • Templater version: 2.3.1
  • Obsidian version: 1.6.0
  • Templater settings: Template folder location: "ZZ-SYSTEM-CONFIGURATION/PLUGINS-CONFIGURATION/TEMPLATES",

Describe the bug
When I Use the tp.file.selection ( ) function the selected text is erased from the note

Expected behavior
I'd like to be able to assign the selected text to a constant without deleting the text of the original note.

Screenshots
The text from a note
CleanShot 2024-05-13 at 16 31 18@2x
The selected text
CleanShot 2024-05-13 at 16 31 46@2x
The simplest possible script execute with Templater: Open Insert Template modal
CleanShot 2024-05-13 at 16 32 21@2x
The note after the execution of the script
CleanShot 2024-05-13 at 16 35 47@2x

Additional context
I've deactivated all the plugins except templater to test the interactions.

@OXiOSDev OXiOSDev added the bug Something isn't working label May 13, 2024
@Zachatoo
Copy link
Collaborator

This isn't related to tp.file.selection(). You can have an empty template file and your selection will be replaced. This is expected behavior.

If you don't want to have your selection removed, then you need to re-add your selection to the note. Here's a few ways to do that.

<% tp.file.selection() %>
<%*
const selectedContent = tp.file.selection();
tR += selectedContent;
%>

@Zachatoo Zachatoo closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@OXiOSDev
Copy link
Author

Thank you very much for your prompt reply

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

No branches or pull requests

2 participants