my-mind icon indicating copy to clipboard operation
my-mind copied to clipboard

[FEATURE] - Store small maps in query string

Open melvincarvalho opened this issue 5 years ago • 3 comments

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?

  • A parameter in the query string to indicate content ( content | body | map ) perhaps
  • A parser of the query string e.g.
globalThis.qs = Object.fromEntries(
  new URLSearchParams(document.location.search)
)
  • And encoding for maps (e.g. json.stringify + shortener)
  • On load a method that will check the query string, extract the map, decode, and validate it
  • On load a function to render the map and probe sequence in case url is already there
  • Ability to save map / share to query string
  • Some UI, perhaps add one element to the dropdown for saving

melvincarvalho avatar Oct 04 '20 17:10 melvincarvalho

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.

ondras avatar Oct 06 '20 10:10 ondras

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.

melvincarvalho avatar Oct 06 '20 11:10 melvincarvalho

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..."

Denperidge avatar Jan 19 '21 11:01 Denperidge