inline-attacher
v0.1.1
Published
📎 A modern port from Inline Attachment
Maintainers
Readme
📎 Inline Attacher
A modern port of Inline Attachment
🔗 https://eastsun5566.github.io/inline-attacher/
Installation
npm i inline-attacherUsage
Input / Textarea
import { attach } from "inline-attacher"; const textarea = document.querySelector("textarea"); attach(textarea, { uploadUrl: "https://example.com/upload" });CodeMirror v6
import { EditorView } from "@codemirror/view"; import { inlineAttachmentExtension } from "inline-attacher"; const editor = new EditorView({ extensions: [ inlineAttachmentExtension({ uploadUrl: "https://example.com/upload" }), ], parent: document.body, });Custom upload handler
import { attach } from "inline-attacher"; const textarea = document.querySelector("textarea"); attach(textarea, { async uploadHandler({ file, filename, formData }) { const response = await myUploader.upload({ file, filename, formData, }); return { url: response.publicUrl }; }, });The returned object is handled the same way as the built-in upload response:
responseUrlKeyis used to read the uploaded file URL before replacing the placeholder text.
