Hacker News new | ask | show | jobs
by PowerfulWizard 748 days ago
Here's what I use (as a bookmark):

    data:text/html,<body contenteditable style="line-height:1.5;font-size:20px;">
No save function obviously but this lets me open a new tab and dump some text.
4 comments

Seeing the replies to your comment, I have to ask: Notepad++ persists your unsaved notes, has dark mode and themes, is fast and lightweight... why insist on forcing text-editor-like behavior on the browser? It feels like a solution in need of a problem.
(For myself) because 99% of my time is spent in an IDE or a browser, and there's less mental overhead for me to open a new tab and start typing than for me to open a new app and do so.
The IDE is literally a text editor. Why not hit file -> new file and write stuff in there?
For me it's the risk of littering in a project repo.

So I use Zim wiki instead: https://zim-wiki.org/

AFAIK all editors and IDEs I've ever used can open a random file in a new tab, even if it is outside of the repository.
Because "random human-language notes" are conceptually different from source code for me.
Sublime Text fits the “nameless notes” niche for me for similar reasons. It’s super speedy, has plenty of customizability, and has rock solid auto save+restore for unsaved text.
Can you restore a closed tab of unsaved text?
Not out of the box I believe, but I use a package from their directory to do just that.
>why insist on forcing text-editor-like behavior on the browser? It feels like a solution in need of a problem.

Because the browser is the operating system.

I might be only half joking.

I hear people say it a lot and I know what they mean but I just can't agree... to me an OS runs on hardware. (or virtualized hardware) Browsers run on an OS. If you have "boot to browser" the OS is still the kernel. Browsers are userspace.

It's like that saying "The difference between a boat and a ship is that a ship can carry a boat, but a boat can't carry a ship." And I know there is jslinux but at that point we're in a Turing tarpit where you can say that the Lua VM or wasm is "an OS" and the term is just a five-dollar word for "abstraction layer". Is a function call an OS? Come on.

Right? I use the gnome default editor for this. Also persists unsaved notes, its always available and has some few basic features that sometimes come in handy (regex match, etc)
> persists your unsaved notes

Except when you brainfart on the OS shutdown and choose the wrong answer.

But yes, I even do the culling every couple of months.

You should pick a text editor that doesn’t throw up a dialog when quitting then. I use CotEditor on macOS specifically for random notes, everything’s unsaved and some notes have survived dozens of reboots over a number of years.
> doesn’t throw up a dialog when quitting then

It doesn't! At least when I Alt+F4 it.

> everything’s unsaved and some notes have survived dozens of reboots

Yep, this is exactly how I use it.

But somehow that one time (note: it was on the shutdown) something went terribly wrong.

I wonder if your notes were borked out of session.xml, but the files were still available at AppData\Roaming\Notepad++\backup.

I've changed machines where the user profile was in a different location, copied my AppData, and replacing the old location in Notepad++'s session.xml was enough to restore my unsaved notes.

Nah.

Of course I tried everything (except looking in the shadow copy? Don't remember), but in the essence the shutdown triggered Save All workflow (somehow) and I responded with 'No'.

*weep*

you mean emacs/?
Nice! I bookmarked it and I'm gonna start using it, thank you.

For a quick and dirty save, you can press Ctrl+P to open the print window/dialog and select "Save as PDF", or you can press Ctrl+S and save as a single HTML file.

Edit: to make the text cursor focus automatically when the page loads, you can add the autofocus attribute to the body tag.

Following might work to save as well.

     data:text/html,<html contenteditable onload="document.body.innerHTML = localStorage['text']" oninput="localStorage['text'] = document.body.innerHTML" style="line-height:1.5;font-size:20px;">
While you can't save to localStorage as my sibling commenters have shown, greyface- down below in the thread posted a version that saves to the hash fragment of the URI. Saving to the (Data) URI has a benefit over localStorage of allowing you to save by bookmarking, which also enables you to save many notes, not just one.

I code-golfed greyface-'s code and made the text cursor autofocus on page load:

  data:text/html,<body contenteditable autofocus oninput="history.replaceState(0,0,'%23'+btoa(this.outerHTML))" onload="location.hash&& document.write(atob(location.hash.slice(1)))">#
Dug into this for a bit, sadly:

> Webstorage is tied to an origin. 'data:' URLs have unique origins in Blink (that is, they match no other origins, not even themselves). even if we decided that 'data:' URLs should be able to access localStorage, the data wouldn't be available next time you visited the URL, as the origins wouldn't match.

It will need a hostname or a page at least.

  Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.
Along the same lines, I created a simple HTML site to interface with Japanese Translation tools: https://blog.frost.kiwi/just-a-text-box/
dark mode:

  data:text/html,<body contenteditable style="line-height:1.5;font-size:20px;color:lightgray;background-color:black">