ondras / my-mind

Online Mindmapping Software
https://my-mind.github.io
MIT License
3.3k stars 652 forks source link

[FEATURE] - Store small maps in query string #116

Open melvincarvalho opened 4 years ago

melvincarvalho commented 4 years ago

It could be a nice feature to store small maps in a query string

This would allow ability to share via a URI. Maybe use a url shortener for long URIs

Some markdown editors do this

https://jbt.github.io/markdown-editor/#U1bwSy1XcMlPLs1NzSvh4grJyCxWAKLEPIXUisTcgpxUAA==

This is an example

Note: the use of # should be discouraged here IMHO because it is more useful to use # to create an anchor in a document

What is needed?

globalThis.qs = Object.fromEntries(
  new URLSearchParams(document.location.search)
)
ondras commented 4 years ago

I agree that the simplicity of sharing a map in a server-less way via a URL is tempting. On the other hand, what are the real expectations here? What map size are we expecting to store in a query string argument?

URLs are, in practice, limited by approximately 2Kb. This means that some maps will fit and some will not; folks will be storing a map in URL and then - once a threshold is reached - the app will fail to continue the storage.

Using a shortener is also somewhat problematic, because you would have to hit their API every time the "save" button is hit.

melvincarvalho commented 4 years ago

Very good points!

Regarding the query string length I think the limit would be 2kb due to internet explorer. Other desktop browsers are about 64k. Not sure the reasons, possibly this allows data: URIs

https://stackoverflow.com/a/812962

Mobile browsers might be different tho. I would expect the feature to be for beginners to get started, with small starter maps, but ultimately a webdav server would be preferred for bigger concepts

Agree that shorteners are problematic. I suppose the use case here would be small maps for sharing and bookmarking. Perhaps those maps in turn could link to larger stored maps. Definitely a solution with trade offs.

Denperidge commented 3 years ago

It may sound a bit primitive, but perhaps simply url encoding the json/mymind file might work, even without shortening? It'd be possible to open a small dialog (for example, after clicking "share by url") with "copy to clipboard", along with a compatibility warning depending on how many characters are used.

E.g. if the url length is over 81578 characters, display "Due to the size of this mindmap, this url may not open in Internet Explorer and Microsoft Edge, but should work without problems in..."