←back to thread

578 points smusamashah | 7 comments | | HN request time: 0.208s | source | bottom
1. yunruse ◴[] No.42463032[source]
This is very neat! I'd be interested to see something like this with a saving mechanism reminiscent of TiddlyWiki [0], which is saved as a portable HTML file. Documents that contain their own editors like this are really neat for offline use and long-term storage.

[0] https://tiddlywiki.com/#SavingMechanism

replies(3): >>42463240 #>>42463298 #>>42464740 #
2. zimpenfish ◴[] No.42463240[source]
I guess that's something you could add into the remote backup server. I'm considering writing my own (in Go/Rust) and I might see if I can add that.
3. pseudosavant ◴[] No.42463298[source]
I have implemented Google Drive and MS OneDrive support in my one-file video player app. I'm using it for reading, but I think it could be used to push back changes to a file for saving.
4. smusamashah ◴[] No.42464740[source]
I tried this script (which Claude came up with) to save file with all it's changes. The steps are

1. Put this script in html file and add a save/download button to trigger it

2. Set `contenteditable` on you editable elements

That's it. Now make changes on the page and click download button to save the page with your changes. This should allow seeing your work without necessarily depending on JS.

The script:

    <script>
    function downloadHTMLFile() {
      // Get the current HTML content
      const html = document.documentElement.outerHTML;

      // Create a temporary link element
      const link = document.createElement('a');
      link.setAttribute('download', 'example-page.html');

      // Encode the HTML content as a data URI
      const encodedContent = encodeURIComponent(html);
      link.setAttribute('href', 'data:text/html;charset=utf-8,' + encodedContent);

      // Append the link to the DOM and click it
      document.body.appendChild(link);
      link.click();

      // Remove the temporary link element
      document.body.removeChild(link);
    }
    </script>
replies(1): >>42466016 #
5. nicoburns ◴[] No.42466016[source]
No need for the script. Browsers have "save as file" functionality built in!
replies(1): >>42467561 #
6. smusamashah ◴[] No.42467561{3}[source]
I dont think using save as keeps the changes you make in HTML using contenteditable.
replies(1): >>42467842 #
7. nicoburns ◴[] No.42467842{4}[source]
Ah, you might be right about that. Good point!