6 ms·
> 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 availab
by vanderZwan 8y ago
> 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/ https://localforage.github.io/localForage/
[1] http://pieroxy.net/blog/pages/lz-string/index.html http://pieroxy.net/blog/pages/lz-string/index.html
[2] https://github.com/pieroxy/lz-string/pull/98#issuecomment-404166788 https://github.com/pieroxy/lz-string/pull/98#issuecomment-40...
- PretzelFisch 8y agoI 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-research/ https://www.html5rocks.com/en/tutorials/offline/quota-resear...
- vanderZwan 8y agoI 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 https://developer.mozilla.org/en-US/docs/Web/API/Storage [1] https://developer.chrome.com/apps/offline_storage https://developer.chrome.com/apps/offline_storage
- whowouldathunk 8y agoYou realize that all of Pride and Prejudice is ~280KB, right? http://www.gutenberg.org/ebooks/1342 http://www.gutenberg.org/ebooks/1342 :)
- kreetx 8y agoI 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).
- LyndsySimon 8y agoEven 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.
- asadlionpk 8y agoI don't think you can paste images into a Markdown editor.
- vanderZwan 8y agoDo github comments count?
- shakna 8y agoMost Markdown parsers will accept a data:uri blob, as they allow inline HTML.
- vanderZwan 8y agoI did not! :) Well, then imagine I just suggested it for the image blobs ;)
- ploxiln 8y agoMinor 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
- weaksauce 8y agoThere 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)
- plibither8 8y agoI 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.