News for hackers. Stuff that matters.
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by vanderZwan on Wednesday July 11, 2018 @10:13AM (#17507048)
> The code makes use of localStorage() to save the raw text and the time and date of when the edit has been made.

Given that localStorage only has 5MiB available to it, you could try using the localForage library to have a localStorage-like API around IndexedDB, so that people can store even larger notes (you could even support storing pasted images as PNG blobs). Even better: is has automatic localForage fallback.

Alternatively, you might want to either compress the text with LZ-String before storing it[1]. (BTW, version 2.0 is currently in the works and much faster, especially if you use the "Unsafe" version[2])

[0] https://localforage.github.io/localForage/

[1] http://pieroxy.net/blog/pages/lz-string/index.html

[2] https://github.com/pieroxy/lz-string/pull/98#issuecomment-40...

Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by whowouldathunk on Wednesday July 11, 2018 @10:34AM (#17507237)
You realize that all of Pride and Prejudice is ~280KB, right?

http://www.gutenberg.org/ebooks/1342

:)

Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by kreetx on Wednesday July 11, 2018 @10:54AM (#17507409)
I was going to oppose this but then checked the size of all of my notes-- two years of org-mode --and you're right, it's 1.8MB (without the .git).
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by vanderZwan on Wednesday July 11, 2018 @11:47AM (#17507814)
I did not! :)

Well, then imagine I just suggested it for the image blobs ;)

Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by LyndsySimon on Wednesday July 11, 2018 @10:54AM (#17507412)
Even so, I often store images within my online notes. Linking out to them is one option, but of course means that my notes would be dependent upon a third party host. Being able to paste image blobs into the document and store them with the text would be an advantage if I were to want to use this.
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by asadlionpk on Wednesday July 11, 2018 @06:39PM (#17510806)
I don't think you can paste images into a Markdown editor.
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by shakna on Wednesday July 11, 2018 @08:29PM (#17511332)
Most Markdown parsers will accept a data:uri blob, as they allow inline HTML.
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by vanderZwan on Wednesday July 11, 2018 @07:18PM (#17511003)
Do github comments count?
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by ploxiln on Wednesday July 11, 2018 @10:27PM (#17511743)
Minor correction: the plain text version is 708 KiB, the ePub version which is 280 KiB uses compression (it's a zip file).

Another nifty datapoint: the plain text of War and Peace is 3.2 MiB

Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by weaksauce on Wednesday July 11, 2018 @02:47PM (#17509286)
There is a very real problem with this extension that will upset people that use it. It’s using the window.localStorage object that will possibly be cleared out when the browser history gets erased. It asks for the storage permission in the manifest but does nothing with it. To the op, use chrome.localstorage() for any read and write operations(edit note that this is async)... that protects against clearing the history. If you plan on storing images you can just request the unlimitedStorage permission to get a full indexdb instance with the same simple api that is simple to use. (not sure if this perm is valid on chrome)
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by plibither8 on Wednesday July 11, 2018 @09:22PM (#17511544)
I didn't think about this! Thanks a lot for bringing this to my notice, I'll lookup a workaround and a safe transition to probably chrome.localStorage.
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by PretzelFisch on Wednesday July 11, 2018 @11:17AM (#17507573)
I am pretty sure you can ask the user to use more and 5mb is just the mobile default for a site. https://www.html5rocks.com/en/tutorials/offline/quota-resear...
Re:Show HN: Markdown New Tab – A new tab replacement to jot ... by vanderZwan on Wednesday July 11, 2018 @12:17PM (#17508070)
I just checked MDN, since I've had problems with html5rocks tutorials being outdated due to specs changing in the past (not related to localStorage though), but all pages I can find on it seem to overlook the whole quota aspect[0]. However, the Chrome dev page on the topic[1] mentions this:

> Unlimited storage is similar to persistent storage, but it is available only to Chrome apps and extensions (.crx files). The size of unlimited storage is limited only by the availability of space in the user's hard drive. You can ask for the unlimitedStorage permission in the manifest file for an app or extension. At installation, the user is informed of permissions required by the app or extension. By proceeding with the installation, the user implicitly grants permission for all pages whose URLs are listed in the manifest.json file.

[0] https://developer.mozilla.org/en-US/docs/Web/API/Storage

[1] https://developer.chrome.com/apps/offline_storage