Gives back the half-written dump when the dump creation modal is closed by mistake, with Escape or a click outside. It is kept in localStorage, all but an attached file, which can't be stored.
There is one draft, not one per tab: whoever closed the modal by mistake wants back what they were just writing, wherever they reopen it.
Removes the stored draft, once the dump is posted or the poster chose to start afresh.
Checks whether draft holds nothing worth restoring. A title taken from the
preview doesn't count, since the preview gives it back.
Returns the stored draft, or null when there is none worth restoring or storage is blocked. A field that doesn't parse takes its empty value.
Stores draft, or removes the stored one when draft is empty. A failure is
silent: the draft is a convenience, never a precondition for posting.
Saved by DumpCreateModal on every change, and restored when it next opens
without a shared link. Posting the dump clears it.
- categoryIds: string[]
-
comment: string
In Markdown.
- isPublic: boolean
- title: string
-
titleFromUser: boolean
Whether the poster typed
title. When not, the modal takes the title from the link's preview again. -
url: string
As typed, not yet normalized.
The modal's starting values, when no draft is restored.
Usage
import * as mod from "src/utils/dump/draft.ts";