What it does
InlineAttachment adds upload functionality to a plain <textarea> or a CodeMirror instance — drag-and-drop a file onto it, or paste an image straight from the clipboard, and the file is uploaded in the background. The behaviour is the one you know from GitHub: paste a screenshot into the comment box and a link appears.
It predates the rich editors that made this standard, and it stays deliberately small — no dependencies, no editor framework, just a behaviour you attach to a textarea you already have. That focus is why it picked up 600+ stars and is still pulled into projects today.
How it works
When a paste or drop event carries a file, InlineAttachment intercepts it, inserts a placeholder at the cursor, and POSTs the file to your upload endpoint. When the upload finishes it swaps the placeholder for the final result — by default a Markdown image link, but the inserted text is fully templated, so it fits Markdown, BBCode, or whatever your editor speaks.
inlineAttachment.editors.textarea.attach(
document.getElementById('editor'),
{ uploadUrl: '/upload' }
)
Configurable, unobtrusive
Almost everything is configurable: the upload URL, the form field name, the allowed MIME types, the progress and error placeholders, and the templates used to render the final link. Sensible defaults mean a one-line attach gets you working uploads; the options are there when you need to match an existing backend. The demo folder ships a small PHP example of the receiving end.
A bit of history
InlineAttachment is one of my older open-source libraries, and it has aged into the kind of small, sharp utility this whole shelf is about — it does one thing, has no dependencies, and gets out of the way. A 3.x rewrite has been in progress on a dev branch to modernise the build and packaging while keeping that same single-purpose spirit.
