15 lines
593 B
TypeScript
15 lines
593 B
TypeScript
import { Descendant } from 'slate';
|
|||
|
|
import { toPlainText } from '../components/editor/output';
|
||
|
|
|
||
|
|
/** localStorage key prefix for a persisted composer draft (`draft-msg-<draftKey>`). */
|
||
|
|
export const DRAFT_MSG_KEY_PREFIX = 'draft-msg-';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Whether a Slate composer draft holds real (non-whitespace) text, as opposed to
|
||
|
|
* an empty editor (which is still a non-empty array of empty paragraphs). Shared
|
||
|
|
* by the composer's DraftIndicator and the room-nav draft indicator.
|
||
|
|
*/
|
||
|
|
export function hasMsgDraft(draft: Descendant[]): boolean {
|
||
|
|
return toPlainText(draft, false).trim().length > 0;
|
||
|
|
}
|