Git Product home page Git Product logo

Comments (16)

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

So you want to be able to have a template for the filename and content of a note?

How I understand the feature request

Lets say I create a new command Create Note from Template. How should that command work?
I haven't used the Templater Plugin yet but I guess you will have a dedicated folder with template files in it. You could now enter this path in the preferences of the Create Note from Template command. Activating it will show a searchable list with all the templates from the folder that you entered in the preferences. After selecting one it will open the normal Create Note form where filename and content will be prefilled with the values from the template.

Now as I can tell from what you wrote, the Templater Plugin supports some placeholders (e.g. Zettelkasten/date) which will be replaced when creating a new note from a template. To have this functionality in Raycast I would need to implement these placeholders too.

Some questions

Could you tell me which placeholders have to be added and what syntax is being used to mark placeholders? (e.g. {{date}})

Do you think this would come close to the templater experience? Anything to add/remove?

Thank you for the feature request!

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Hi @baseliners,

any thoughts on this?

from obsidian-raycast.

baseliners avatar baseliners commented on May 22, 2024

Hi @marcjulianschwarz - the way I was thinking about this is simpler (I think). i.e. your raycast plugin would invoke whatever mechanism Obisidian is using to create a new note using a Templater template. Not sure if the advanced URI plugin already handles templates, but if yes, it might be as simple as invoking a new note creation URI for a note in a certain folder, and if that folder has a template associated with it in Templater, that template gets used.

Personally, I'd be OK losing the form functionality that you currently have and have the plugin just drop me directly into Obsidian. If you wanted to parameterize, I'd parameterize the folder where a new note is being created, and allow for keyboard shortcuts to be assigned to each folder. i.e. I can assign a keyboard shortcut to create a note in Inbox, and another shortcut to create a note in folder XYZ, etc. This would provide a lot of flexibility and you wouldn't have to duplicate the templater functionality in your plugin. Thx!

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Hi @baseliners,

thank you for the clarifications. Now I understand how the Templater plugin works, didn't know about the folder-template-association.

In the Create Note preference section you can now enter a list of folders.

Bildschirmfoto 2022-04-23 um 12 03 43

These folders will show up as actions in the command. Triggering them will add a new empty file in the corresponding folder. You can still override the path using the form or you could add a filename with the form. I think the notes content will be replaced with the template.

Bildschirmfoto 2022-04-23 um 12 04 03

Open for feedback :)

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Right now the shortcut for every action will be created automatically (counting from 0 to 9). I might need to change this behavior as some of these keyboard combinations are already in use by the OS.

from obsidian-raycast.

baseliners avatar baseliners commented on May 22, 2024

This sounds great! How can I try it out?

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

You could download/clone this repository, then navigate to the folder and run npm install and npm run dev. The extension should then be visible in Raycast.

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

@baseliners let me know when you were able to test it.

from obsidian-raycast.

baseliners avatar baseliners commented on May 22, 2024

Thanks. I was able to install and run it, but when I trigger the action for the Inbox folder, it tries to create a note with the filename Untitled.md instead of the filename that should be generated via the Templater template. Here's what my template looks like for the Inbox folder (i.e. the following line is what the template file associated w/ Inbox contains):

<% tp.file.rename(tp.date.now("YYYY-MM-DD") + " ") %>

So in Obsidian, if I create a new note (I have Inbox as the default location for new notes), the filename generated would be something like 2022-04-23<my_text>.md (I add text manually after the date so it ends up making the filename unique).

I suppose the extension is bypassing the Templater somehow. Wonder if there's a way to have Templater still trigger even if the note creation is triggered by the Raycast extension?

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Templater will trigger. I tried some of the examples from Templaters website and they worked.
I tested your template too and it worked fine for me. It renamed the Untitled.md file.

Maybe the plugin isn't enabled or the template hasn't been selected in Templaters settings?
Do you see any errors?

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

This shows it working:

2022-04-24.23-54-47.mp4

As you can see Obsidian will throw an error that the file doesn't exist because it got renamed (Raycast is trying to open the old file name, this can be disabled in the extensions settings).

from obsidian-raycast.

baseliners avatar baseliners commented on May 22, 2024

OK great, figured out the issue. I already had a file named Untitled.md in my Inbox so it was preserving that file. May be worth choosing another default name for the temp file?

Also, noticed that if I use the Command+Shift+return shortcut to create the note, it does create the file but does not drop me into the note. If I hit Command-K and then select the action for Inbox, it does drop me into the note that was just created. Not sure if this is intended behavior? I have the checkbox checked for "Open note on Creation" so was expecting the note to be opened via the keyboard shortcut as well.

Btw, is there a way to set a global shortcut for the action to create a new note in Inbox? I set a global shortcut to "Create Note" but would be nice to have a shortcut for creating a note in a specific folder as well.. but maybe this is something that Raycast needs to support?

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Which default name would you suggest?

Can't reproduce this behavior. Both the shortcut and manually selecting the action from the list works for me.

I don't think there is a way to set global shortcuts for actions. The only way this would work is to create commands for each folder. However I don't think that this would comply with Raycasts guidelines for extensions. For "non-tech people" this could be quite confusing.

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

@baseliners any suggestions?

I can add a preference where you can choose the default note name.

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Hi @baseliners,

I just pushed a new version. You can now specify a default note name for the Create Note command which is being used when the name field is left empty.

from obsidian-raycast.

marcjulianschwarz avatar marcjulianschwarz commented on May 22, 2024

Hi @baseliners,
version 1.5 has been released and it includes your feature request.
Thank you for the contribution.

from obsidian-raycast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.