gsantner / markor

Text editor - Notes & ToDo (for Android) - Markdown, todo.txt, plaintext, math, ..
https://github.com/gsantner/markor/discussions/2269
Other
3.84k stars 368 forks source link

Allow filename to be left unspecified #2104

Closed DavidRV00 closed 1 year ago

DavidRV00 commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Description

Hello, I'm loving Markor so far, but what I'd really like to do is just click "+" and start writing, without having the friction of specify a filename. When I have an idea I want to remember, it's important for me to just be able to get it down as quick as I can.

There are a couple ways this could be done:

  1. Just allow not specifying a filename, and have Markor pick a default (maybe the current timestamp) if it's left empty.
  2. Allow selecting a default template (for example I would just use the template '202901012359-zettelkasten' every time if I could, since it allows multiple notes to be written quickly without filename clash). I can select this manually each time, but it would be great if I could have it auto-selected, or if Markor just remembered what I picked last time.

I've seen a couple similar-sounding issues relating to templates, but nothing relevant that's still open.

Information

Android version: 12 Device: OnePlus Nord N200 5G App Version: 2.10.9

Source

F-Droid

Format / File type

Not specific

Additional info / Log

-
harshad1 commented 1 year ago

Default timestamp makes the most sense. Need to pre-highlight this so one can easily replace the default.

Also note that starting typing immediately is what quicknote is for :)

DavidRV00 commented 1 year ago

Quicknote is awesome! But just for my usual usecase, it doesn't quite work because it doesn't spawn a new file each time; can't go back and look at it later if I've written a new quicknote.

harshad1 commented 1 year ago

Here is a fun hack for you

Markor will execute any JS code in a script tags when you switch to view mode

I use the following code to open a file with today's date in the current folder. If the file does not exist it will be created.

You can modify this to open a new file in the current folder with any programmatically generated name. If you want a new unique name you could use seconds or a UUID

<script>
let anchor = document.createElement('a');

// This asinine approach is from https://stackoverflow.com/a/28149561
// offset in milliseconds
let offset = (new Date()).getTimezoneOffset() * 60000;

let iso = (new Date(Date.now() - offset)).toISOString()

let today = iso.split('T')[0]

let textNode = document.createTextNode("Today's worklog");

// Append the textNode as a child to anchor.
anchor.appendChild(textNode);

anchor.href = "./" + today + ".md";

anchor.style.fontSize = "x-large";

document.body.appendChild(anchor);

window.location.href = anchor.href

</script>
harshad1 commented 1 year ago

Make a shortcut to this html file and it will open in view mode -> create a new file with a unique name and open it for editing. All in one click.

You can use this to emulate Obsidian's daily note as I am doing in this example

DavidRV00 commented 1 year ago

Awesome, I'll try this out this week, thanks.

To clarify, you're saying that I should add this html file (or a shortcut to it) in my markor notes directory, and open it from within markor, and that will execute the code and open a newly-created note?

harshad1 commented 1 year ago

Pretty much

DavidRV00 commented 1 year ago

It works, thanks!

Do you think it would be worthwhile to have this as a built-in feature of the app, though? I could potentially volunteer to work on a pull request for it if so.

harshad1 commented 1 year ago

In some sense it is a built in feature of markor :)

Imo the most useful thing would be to create a guide to using js in markor. This is the only trick I know, there are likely others.

gsantner commented 1 year ago

I think there is a viable option suggested. Markor gives you freedom to do what you want on many places (of course if you know how to). This one is specifically: If you reference a local file and trigger opening it with Markor - it is automatically created if it does not exist. Thus it works to generate some (whatever timestamp based format or other logic) filename and ask to open it.

Humbly said, I want to keep it possible for users to do such things (don't want to put restrictions here), and also for the other part of users - I don't want to bloat everything.

I think Markor got a lot of stuff over years and sometimes feels a bit bloated on some things, at last more than I want it to be. My goal always has been to make the most functionality out of the least amount of features.