Convert Slack's clipboard format to Slack-compatible Markdown
npm install slack-to-markdownslack/texty clipboard format. This library converts that content to Markdown that can be pasted into other applications (or back into Slack) and render correctly.``typescript
import { slackToMarkdown } from "slack-to-markdown";
// Pass the raw clipboard string - it handles parsing
const markdown = slackToMarkdown(clipboardData);
// Falls back to original string if not valid Slack format
slackToMarkdown("plain text") // => "plain text"
`
`typescript`
document.addEventListener("paste", (e) => {
const slackData = e.clipboardData?.getData("slack/texty");
if (slackData) {
e.preventDefault();
const markdown = slackToMarkdown(slackData);
// Insert markdown at cursor, or do whatever you want with it
}
});
`bash``
npm test