markdown-text-editor 1.5.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/dist/markdown-text-editor.es.js +832 -688
- package/dist/markdown-text-editor.es.js.map +1 -1
- package/dist/markdown-text-editor.min.js +56 -53
- package/dist/markdown-text-editor.min.js.map +1 -1
- package/dist/markdown-text-editor.umd.js +56 -53
- package/dist/markdown-text-editor.umd.js.map +1 -1
- package/package.json +14 -7
- package/types/index.d.ts +176 -0
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ Most JavaScript markdown editors (EasyMDE, SimpleMDE, CodeMirror-based editors)
|
|
|
31
31
|
| Zero CSS conflicts | ✅ | ❌ |
|
|
32
32
|
| RTL support | ✅ | ❌ |
|
|
33
33
|
| Built-in Find & Replace | ✅ | ❌ |
|
|
34
|
+
| Swap the markdown parser | ✅ | ❌ |
|
|
34
35
|
| Keyboard shortcuts | ✅ | Partial |
|
|
35
36
|
| Dark mode / theming | ✅ | Limited |
|
|
36
|
-
| ~116KB bundle | ✅ | ~300KB+ |
|
|
37
37
|
|
|
38
38
|
## 🚀 Quick Start
|
|
39
39
|
|
|
@@ -77,22 +77,25 @@ That's it. Form submission, `.value` access, and all native textarea behaviour w
|
|
|
77
77
|
|
|
78
78
|
## ✨ Features
|
|
79
79
|
|
|
80
|
-
- 🔌 **Native Form Integration** — Works exactly like a standard `<textarea>`. No complex APIs — just use `.value` or the `name` attribute. Compatible with Django, Laravel, PHP, Rails, Node.js
|
|
80
|
+
- 🔌 **Native Form Integration** — Works exactly like a standard `<textarea>`. No complex APIs — just use `.value` or the `name` attribute. Compatible with Django, Laravel, PHP, Rails, Node.js, and with React or Vue via a ref and `destroy()` on unmount
|
|
81
81
|
- 🔀 **WYSIWYG Hybrid Mode** — Renders bold, italic, headings, and code live as you type while keeping the underlying Markdown. Switch to plain mode for raw syntax editing
|
|
82
82
|
- ⚡ **Live Preview** — Full side-by-side Markdown preview with clickable task list checkboxes that sync back to the source instantly
|
|
83
|
+
- 🔧 **Bring Your Own Renderer** — Swap marked for markdown-it or any other parser so the preview matches whatever your backend renders. The sanitizer is replaceable too, and DOMPurify still runs by default
|
|
84
|
+
- 🏷️ **Variable Dropdown** — Give template authors a menu of readable names that insert placeholders like `{{customer.name}}`. Entries can be grouped, and a sample value can stand in for the placeholder in the preview
|
|
83
85
|
- 🖼️ **Advanced Image Upload** — Upload images directly to your server or S3. Avoids heavy Base64 strings for better performance and SEO
|
|
84
86
|
- 🔍 **Find & Replace** — Built-in panel (`Ctrl+F` / `Ctrl+H`) with live match counter, next/prev navigation, case-sensitive toggle, and replace all
|
|
85
87
|
- ⌨️ **Keyboard Shortcuts** — `Ctrl+B`, `Ctrl+I`, `Ctrl+K`, `Ctrl+Z`, `Ctrl+1`–`Ctrl+3` for headings, and more
|
|
86
88
|
- 📝 **Smart List Continuation** — GitHub-style: press `Enter` inside a list and the bullet/number continues automatically
|
|
87
89
|
- 🔄 **Undo / Redo** — Full diff-based history with exact cursor restoration. Works with `Ctrl+Z`, `Ctrl+Y`, `Ctrl+Shift+Z`
|
|
88
90
|
- ♿ **Accessible by Default** — `role="toolbar"`, `aria-pressed`, `aria-disabled`, `disabled`, screen-reader-friendly SVGs, and correct focus restoration on modal close
|
|
89
|
-
- 🛡️ **XSS Safe** — Preview output sanitized via [DOMPurify](https://github.com/cure53/DOMPurify) before rendering
|
|
91
|
+
- 🛡️ **XSS Safe** — Preview output sanitized via [DOMPurify](https://github.com/cure53/DOMPurify) before rendering, including the output of a custom renderer
|
|
90
92
|
- 🛡️ **CSP Compatible** — No inline event handlers. Works with strict Content Security Policy headers
|
|
91
93
|
- 🌍 **RTL Support** — Native Right-to-Left support for Arabic, Urdu, Farsi, and other RTL languages
|
|
92
94
|
- 🌙 **Dark Mode & Theming** — Inherits `data-theme` from any ancestor element. Built-in light, dark, snowberry, and darkberry themes. Fully customizable via CSS variables
|
|
93
95
|
- 🎛️ **Modular Toolbar** — Pick exactly which tools appear and in what order
|
|
96
|
+
- 🟦 **TypeScript Ready** — Definitions ship with the package. Options, toolbar entries and variable shapes are all checked, so a mistyped tool name is a compile error rather than a silently missing button
|
|
94
97
|
- 📦 **Universal Module Support** — ESM, CommonJS, UMD, and IIFE. Works with Vite, webpack, Rollup, or directly via `<script src>` CDN — no configuration needed
|
|
95
|
-
- 🚀 **High Performance** — ~
|
|
98
|
+
- 🚀 **High Performance** — ~52KB gzipped (245KB minified). Debounced preview, cached layout calculations, conflict-free Tab/Enter handling for large documents
|
|
96
99
|
|
|
97
100
|
## 🛠 Developer Workflow
|
|
98
101
|
|
|
@@ -137,6 +140,21 @@ const editor = new MarkdownEditor('#markdown-editor', {
|
|
|
137
140
|
editor.destroy();
|
|
138
141
|
```
|
|
139
142
|
|
|
143
|
+
In React, create the editor in an effect and return `destroy` as the cleanup — that also covers StrictMode running effects twice in development:
|
|
144
|
+
|
|
145
|
+
```jsx
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const editor = new MarkdownEditor(ref.current, { onChange });
|
|
148
|
+
return () => editor.destroy();
|
|
149
|
+
}, []);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Use `defaultValue`, not `value`. The editor writes to the textarea directly, so a controlled binding (or Vue's `:value`) would overwrite what the user is typing. Full React and Vue examples are in the [documentation](https://frutjam.com/community/plugins/markdown-editor).
|
|
153
|
+
|
|
154
|
+
The same two rules cover Svelte, Angular and anything else: don't bind the value, and call `destroy()` on unmount. In Angular, `onChange` fires outside the zone, so wrap it in `zone.run()` for change detection to notice.
|
|
155
|
+
|
|
156
|
+
Options are read once when the editor is constructed. Changing them later has no effect — destroy the editor and create a new one instead.
|
|
157
|
+
|
|
140
158
|
## 📖 Documentation
|
|
141
159
|
|
|
142
160
|
Full API reference, configuration options, theming guide, and advanced image upload docs:
|
|
@@ -158,6 +176,8 @@ Full API reference, configuration options, theming guide, and advanced image upl
|
|
|
158
176
|
|
|
159
177
|
Contributions are welcome! Bug fixes, feature requests, and improvements — open an issue or submit a pull request.
|
|
160
178
|
|
|
179
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, tests, project layout, and how to add a toolbar tool.
|
|
180
|
+
|
|
161
181
|
---
|
|
162
182
|
|
|
163
183
|
## License
|