NanoMD: Lightweight Markdown Editor
[!NOTE]
(Formerly known as PDMarkdownKit, renamed to NanoMD starting from version 1.8.0
)
NanoMD is a lightweight Markdown editing and viewing library built on pure JavaScript and native APIs. Can be easily embedded into websites, offers rich features, and supports real-time previewing.
Features
High-Performance Editing
- Smart virtual DOM updates for optimal performance
- Real-time split-screen preview with WYSIWYG experience
- Intelligent scroll synchronization
- Optimized for large documents with zero lag
Advanced Markdown Support
- Complete standard syntax support
- Extended features:
- Code formatting and syntax highlighting
- Real-time math formula rendering
- Automatic table formatting
- Checkable task lists
- Quick block quotes
Media Integration
- Automatic YouTube and Vimeo video embedding with previews
- Smart image handling:
- Automatic thumbnail generation
- Flexible size control
- Multiple alignment options
- Responsive media support
Technical Advantages
- Pure JavaScript implementation, no external dependencies
- Efficient virtual DOM implementation
- Modular architecture design
- Complete ES Module support
Documentation
Installation
Install via npm
npm i @pardnchiu/nanomd
Include via CDN
UMD version
<script src="https://cdn.jsdelivr.net/npm/@pardnchiu/nanomd@[VERSION]/dist/NanoMD.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdmarkdownkit@[VERSION]/dist/PDMarkdownKit.js"></script>
ES Module version
import { MDEditor, MDViewer, MDParser } from "https://cdn.jsdelivr.net/npm/@pardnchiu/nanomd@[VERSION]/dist/NanoMD.esm.js";
import { editor, viewer } from "https://cdn.jsdelivr.net/npm/pdmarkdownkit@[VERSION]/dist/PDMarkdownKit.module.js";
import { editor, viewer } from "https://cdn.jsdelivr.net/npm/pdmarkdownkit@[VERSION]/dist/PDMarkdownKit.js";
How to use
Initialize editor
and viewer
const domEditor = new MDEditor({
id: "",
defaultContent: "",
hotKey: 1,
preventRefresh: 0,
tabPin: 0,
wrap: 1,
autoSave: 1,
event: {
save: result => {
console.log(result);
}
},
style: {
mode: "",
fill: 1,
fontFamily: "",
showRow: 0,
placeholder: {
text: "Content",
color: "#ff000080"
},
focus: {
backgroundColor: "#ff00001a",
color: "#ff0000"
}
}
});
const domViewer = new MDViewer({
id: "",
emptyContent: "",
style: {
mode: "",
fill: "",
fontFamily: "",
},
sync: {
editor: domEditor,
delay: 50,
scrollSync: 1,
},
hashtag: {
path: "?keyword=",
target: "_blank"
}
});
(...).appendChild(domEditor.body);
(...).appendChild(domViewer.body);
const domParser = new MDParser({
standard: 1
});
console.log(domParser.parse("**Text to parse**"));
License
Similar to MIT License but provides obfuscated code only:
- Same as MIT: Free to use, modify and redistribute, including commercial use
- Main difference: Provides obfuscated code by default, source code available for purchase
- License terms: Must retain original copyright notice (same as MIT)
For detailed terms and conditions, please see the Software Usage Agreement.
Creator
邱敬幃 Pardn Chiu
©️ 2023 邱敬幃 Pardn Chiu