forked from tangled.org/core

web: image upload with file picker, conversion and shrinking #5

Open ezra.eti.tf
targeting master from ezra/image-upload
Open opened by and assigned to ezra.eti.tf
targeting master from ezra/image-upload

Builds on boltless' image upload.

  • the toolbar Image button opens the native file picker when the editor can upload, and keeps inserting ![](url) otherwise
  • the alt text is inserted as "Image" (or the selected text) and left selected so it can be typed over
  • images can also be pasted
  • a file over 1 MB is shrunk in the browser (resized, re-encoded as jpeg or webp) until it fits
  • formats the browser can decode but the lexicon doesn't accept are converted the same way
  • svg is rasterized, so no svg is ever uploaded or served
  • a gif over 1 MB, an unreadable file or an image that can't be shrunk under 1 MB shows an error alert under the editor instead of an html comment in the body
  • fixes the prettier failure in comment.ts

Not covered: nothing serves /blob/<did>/<cid> in this repo, so saved images only render once that exists.

Commits 2

web/markdown-editor: pick, convert and shrink images before upload
web: image upload