Typemark is a lightweight React Markdown editor component built with TypeScript.
It allows developers to easily build a Markdown editing experience with simple command handling — no dependencies other than react
and react-dom
.
🤞 Here is a quick Demo...
- ⚛️ React 17, 18, 19 support
- ✨ Simple command-based API
- 🧩 Easily extendable command map
- 💅 Auto-resizing textarea
- ✅ Written in TypeScript
npm install typemark
import { useState } from "react";
import { useEditor, EditorElement, Bold, Italic, Code, Heading1 } from "typemark";
export default function TypeMark() {
const [value, setValue] = useState<string>('')
// Create the editor
const editor = useEditor({
commandMap: { Bold, Italic, Code, Heading1 },
});
return (
<div className='container'>
<h3>Typemark demo</h3>
<div>
<button onClick={async () => await editor.command.execute("Heading1")}>H1</button>
<button onClick={async () => await editor.command.execute("Bold")}>Bold</button>
<button onClick={async () => await editor.command.execute("Italic")}>Italic</button>
<button onClick={async () => await editor.command.execute("Code")}>Code</button>
</div>
<EditorElement
className=""
editor={editor}
value={value}
onChange={e => setValue(e.target.value)} />
</div>
)
}
Creates a new editor instance.
commandMap
: An object of available commands (Bold
,Italic
,Code
, etc.)
ref
: Ref to the textareatextController
: Internal controller for managing textarea contentcommand
: The command executor
A resizable <textarea>
component connected to the editor instance.
editor
: The result fromuseEditor
& All native<textarea>
props (e.g.value
,onChange
)
You can define your own commands by extending the Command
interface.
Coming soon
: A full guide on building custom commands.
This package is based on the open-source react-mde by Andre Pena.
Upgraded and maintained by Coding Samrat.