Edit markdown content in tiptap editor.
npm install tiptap-markdown> [!WARNING]
As Tiptap have now a solution for markdown (paid Conversion extension and more markdown handling announced for v3). I don't plan to release v1 nor addressing current issues / PR. Feel free to fork the project if you need.
The markdown extension for Tiptap editor.
For Tiptap v2
``bash`
npm install tiptap-markdown@^0.8
For Tiptap v3
`bash`
npm install tiptap-markdown@latest
`js
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';
import { Markdown } from 'tiptap-markdown';
const editor = new Editor({
content: "# Title",
extensions: [
StarterKit,
Markdown,
],
});
const markdownOutput = editor.storage.markdown.getMarkdown();
`
js
Markdown.configure({
html: true, // Allow HTML input/output
tightLists: true, // No inside
in markdown output
tightListClass: 'tight', // Add class to allowing you to remove margins when tight
bulletListMarker: '-', //
- prefix in markdown output
linkify: false, // Create links from "https://..." text
breaks: false, // New lines (\n) in markdown input are converted to
transformPastedText: false, // Allow to paste markdown text in the editor
transformCopiedText: false, // Copied text is transformed to markdown
})
`$3
`js
editor.commands.setContent('test') // setContent supports markdown format
editor.storage.markdown.getMarkdown(); // get current content as markdown
``Please make sure to update tests as appropriate.