
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
markdown-text-editor
Advanced tools
A simple JavaScript Markdown editor plugin with real-time preview, and easy integration.
Welcome to MarkdownEditor, the leading open source JavaScript markdown editor plugin. Enjoy a simple, powerful, and embeddable markdown editor with real-time preview, syntax highlighting, responsive design, and seamless integration for all web projects.
The MarkdownEditor Plugin is designed to be the best, simple, and embeddable JavaScript markdown editor plugin available. It is an open source project that boasts:
Integrating the MarkdownEditor Plugin into your project is straightforward. You can install it using NPM, import the JavaScript file directly, or use a CDN for rapid deployment.
For projects utilizing bundling tools like Webpack, run:
npm install markdown-text-editor
After installation, import the MarkdownEditor
class from the package:
import MarkdownEditor from "markdown-text-editor";
To get started, include a <textarea>
element in your HTML and initialize the editor by targeting its container:
<textarea class="editor-container"></textarea>
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Write your markdown...',
toolbar: ['heading', 'bold', 'italic', 'strikethrough', 'ul', 'ol', 'checklist', 'blockquote', 'link', 'preview'],
});
import the CSS file directly in your js code:
import 'markdown-text-editor/dist/markdown-text-editor.css';
Alternatively, include the following CDN links in your HTML:
<script src="https://cdn.jsdelivr.net/npm/markdown-text-editor@0.3.0/dist/markdown-text-editor.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markdown-text-editor@0.3.0/dist/markdown-text-editor.min.css">
In this method, you can access the markdown content entered into the editor directly using JavaScript. This is helpful when you want to dynamically retrieve the value and process it in your application (e.g., displaying it elsewhere or sending it via AJAX).
<form>
<textarea class="editor-container h-48" rows="5"></textarea>
<button type="button" id="submit-btn">Submit</button>
<div class="output"></div>
</form>
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Start writing...',
toolbar: ['bold', 'italic', 'preview'],
});
document.getElementById('submit-btn').addEventListener('click', function() {
const markdownValue = document.querySelector('.editor-container').value;
console.log(markdownValue);
document.querySelector('.output').innerHTML = `<pre>${markdownValue}</pre>`;
});
If you prefer a traditional form submission approach (for example, in server-side applications like Django), you can integrate the markdown editor into a form that submits the value to the server for processing.
<form method="POST" action="/your-server-endpoint">
<textarea class="editor-container h-48" rows="5" name="markdown"></textarea>
<button type="submit">Submit</button>
</form>
you can retrieve the value from a traditional <textarea>
in a form submission without any custom element. When the form is submitted, the content inside the <textarea>
is automatically included as part of the form data, using the name attribute of the <textarea>
.
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Write your markdown...',
toolbar: ['preview', 'bold', 'italic'],
});
<form method="POST" action="/your-server-endpoint">
<textarea class="editor-container h-48" rows="5" name="markdown">Add your markdown content here</textarea>
<button type="submit">Submit</button>
</form>
Customize your Markdown editor by passing an options
object during initialization. Below are some key configuration options:
Option | Type | Default | Description |
---|---|---|---|
placeholder | string | 'Write your markdown...' | Sets the placeholder text for the textarea (optional, as you can also use the standard HTML textarea attribute) |
toolbar | array | ['heading', 'bold', 'italic', 'strikethrough', 'ul', 'ol', 'checklist', 'blockquote', 'link', 'image', 'preview'] | Determines which tools appear in the toolbar and their order. |
Tailor the toolbar to suit your needs by choosing which formatting options to include. The MarkdownEditor Plugin supports several tools, including:
bold
: Enables bold text formatting.italic
: Enables italic text formatting.strikethrough
: Allows text to be struck through.ol
: (Ordered List): Converts text into a numbered list format.ul
: (Unordered List): Converts text into a bullet point list.checklist
: Adds checkboxes to your text, making it great for tasks, to-do lists, or tracking completion status.image
: Allows you to insert images via markdown syntax.link
: Lets you add hyperlinks to your text.preview
: Toggles the real-time markdown preview.Example:
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Start writing...',
toolbar: [
'bold',
'italic',
'strikethrough',
'ul',
'ol',
'checklist',
'image',
'link',
'preview'
],
});
The image tool supports a fileInput
configuration that allows:
accept
: Array of allowed image file types (e.g., 'webp'
, 'avif'
).uploadUrl
: The endpoint where image files will be uploaded.After a successful upload, the server must return the image path, which will be automatically populated in the URL field.
Usage example:
const options = {
placeholder: 'Start writing...',
toolbar: [
'link',
{
image: {
fileInput: {
accept: ['webp', 'avif'],
uploadUrl: '/api/upload', // Your upload endpoint
},
}
},
'preview'
],
}
const editor = new MarkdownEditor(element, options);
If fileInput
is not configured, the image modal will default to only showing the URL
and alt text
fields.
Usage example:
const options = {
placeholder: 'Start writing...',
toolbar: [
'link',
'image',
'preview'
],
}
const editor = new MarkdownEditor(element, options);
altInput
)You can configure whether the alt text input for images in the markdown editor is required.
{
image: {
fileInput: {
accept: ['webp', 'avif'],
uploadUrl: '/api/upload' // Your upload endpoint
},
altInput: {
required: false // Optional: disables alt text validation (default is true)
}
}
}
required: true
(default): Enforces alt text input for better SEO and accessibility.required: false
: Allows inserting images without alt text.This configuration helps developers control alt text validation for each markdown editor instance. For example, when using multiple editors in the same app, you can define different alt text rules per instance.
Tip: You can reorder or remove any toolbar buttons by modifying the toolbar array during initialization.
Below is a complete HTML example demonstrating how to integrate the MarkdownEditor Plugin into your project:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markdown Editor Example</title>
<link rel="stylesheet" href="dist/markdown-editor-plugin.css">
</head>
<body>
<textarea class="editor-container h-56" rows="6"></textarea>
<script src="dist/markdown-editor-plugin.js"></script>
<script>
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Type your markdown...',
toolbar: [
'bold',
'italic',
'strikethrough',
'ul',
'ol',
'checklist',
'link',
{
image: {
fileInput: {
accept: ['webp', 'avif'],
uploadUrl: '/api/upload', // Your upload endpoint
},
}
},
'preview'
],
});
</script>
</body>
</html>
For projects using Webpack, import and initialize the editor as follows:
import MarkdownEditor from 'markdown-text-editor';
const editor = new MarkdownEditor('.editor-container', {
placeholder: 'Write markdown...',
toolbar: [
'bold',
'italic',
'strikethrough',
'ul',
'ol',
'checklist',
'image',
'link',
'preview'
],
});
Contributions to this open source project are highly encouraged! If you have bug fixes, feature enhancements, or new ideas, please consider opening an issue or submitting a pull request. Your help will ensure that this best, simple, embeddable JavaScript markdown editor plugin continues to evolve and serve the community with real-time preview and syntax highlighting capabilities.
This project is released under the MIT License.
Thank you for choosing the MarkdownEditor Plugin – your reliable, feature-rich solution for seamless markdown editing and content creation with easy integration. Happy coding!
If you like this project, consider giving it a star! 🌟
[0.4.0] - 2025-08-06
.modal
), to avoid design conflicts with other frameworks such as Bootstrap.FAQs
A simple JavaScript Markdown editor plugin with real-time preview, and easy integration.
The npm package markdown-text-editor receives a total of 80 weekly downloads. As such, markdown-text-editor popularity was classified as not popular.
We found that markdown-text-editor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.