// Page-sized pastes turn into a `Pasted text` attachment chip instead of being // dumped into the editor. Short paragraphs and everyday lists should stay // inline so the composer still feels like a normal text field. const PASTED_TEXT_MIN_CHARS = 3200; const PASTED_TEXT_MIN_LINES = 24; const PASTED_TEXT_FILENAME_PREFIX = "pasted-text-"; // A copied HTML document/source is recognizable from its markup: a closing tag // (``), a doctype, or a common structural/element tag. We key off the // *content* the user actually pasted, not the clipboard's `text/html` flavor — // editors (VS Code) and rich-text apps (Google Docs) populate `text/html` with // syntax-highlight spans or formatting wrappers even when the real content is // plain code/prose, so trusting `text/html` blindly would mangle those pastes. const HTML_SOURCE_SIGNAL = /]|<\/[a-z][a-z0-9-]*\s*>|<(?:body|head|div|span|section|main|header|footer|nav|article|aside|ul|ol|li|table|thead|tbody|tr|td|th|h[1-6]|p|a|img|button|input|textarea|select|form|label|script|style|link|meta|svg|canvas|template)\b/i; // A real HTML *document* announces itself with a doctype / html / head / body. // When one of these is present we keep the HTML classification even if an inline //