markdown-text-editor 0.0.21-beta.2 → 0.0.23-beta.3
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 +165 -79
- package/dist/index.css +76 -175
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown-text-editor.css +76 -175
- package/dist/markdown-text-editor.css.map +1 -1
- package/dist/markdown-text-editor.js +1 -1
- package/dist/markdown-text-editor.js.map +1 -1
- package/package.json +6 -4
- package/src/plugins/markdown/Toolbar/tools/MarkdownTool.js +1 -0
- package/src/plugins/markdown/Toolbar/tools/PreviewTool.js +9 -3
- package/src/plugins/markdown/editor.js +2 -0
- package/src/plugins/markdown/preview.js +1 -1
package/README.md
CHANGED
|
@@ -1,181 +1,267 @@
|
|
|
1
|
-
|
|
1
|
+
## MarkdownEditor Plugin Documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Welcome to the documentation for the **MarkdownEditor Plugin** – an **open source project** offering the **best, simple, embeddable JavaScript Markdown editor plugin or library**. This powerful tool provides **real-time preview**, **syntax highlighting**, and **easy integration** into your projects. Whether you’re building a blog, note-taking app, or any content-rich website, this plugin delivers a robust and customizable markdown editing experience.
|
|
4
|
+
|
|
5
|
+
---
|
|
4
6
|
|
|
5
7
|
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Overview](#overview)
|
|
6
10
|
- [Installation](#installation)
|
|
7
11
|
- [Usage](#usage)
|
|
12
|
+
- [Markdown Content Retrieval](#markdown-content-retrieval)
|
|
8
13
|
- [Configuration Options](#configuration-options)
|
|
9
|
-
- [Toolbar
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
14
|
+
- [Toolbar Customization](#toolbar-customization)
|
|
15
|
+
- [Example Implementations](#example-implementations)
|
|
16
|
+
- [Contribution Guidelines](#contribute)
|
|
12
17
|
- [License](#license)
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
---
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
## Overview
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm install markdown-text-editor
|
|
21
|
-
```
|
|
23
|
+
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:
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
- **Real-time Preview:** See your markdown rendered instantly as you type.
|
|
26
|
+
- **Syntax Highlighting:** Enhanced readability with clear code and markdown formatting.
|
|
27
|
+
- **Easy Integration:** Seamlessly integrate into any web project with minimal setup.
|
|
28
|
+
- **Customizable Toolbar:** Dynamically configure and reorder toolbar options like **bold**, **italic**, and more.
|
|
29
|
+
|
|
30
|
+
Built with **Tailwind CSS** for modern styling, this plugin is perfect for developers seeking a lightweight yet feature-rich markdown editor.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
24
35
|
|
|
36
|
+
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.
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
### Install via NPM
|
|
27
39
|
|
|
40
|
+
For projects utilizing bundling tools like Webpack, run:
|
|
28
41
|
|
|
42
|
+
```bash
|
|
43
|
+
npm install markdown-text-editor
|
|
29
44
|
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
After installation, import the `MarkdownEditor` class from the package:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
30
53
|
import MarkdownEditor from "markdown-text-editor";
|
|
31
54
|
```
|
|
32
55
|
|
|
33
|
-
|
|
56
|
+
### Basic Initialization
|
|
34
57
|
|
|
35
|
-
To
|
|
58
|
+
To get started, include a `<textarea>` element in your HTML and initialize the editor by targeting its container:
|
|
59
|
+
|
|
60
|
+
#### HTML
|
|
36
61
|
|
|
37
|
-
### HTML:
|
|
38
62
|
```html
|
|
39
63
|
<textarea class="editor-container"></textarea>
|
|
40
64
|
```
|
|
41
65
|
|
|
42
|
-
|
|
66
|
+
#### JavaScript
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
const editor = new MarkdownEditor('.editor-container', {
|
|
70
|
+
placeholder: 'Write your markdown...',
|
|
71
|
+
toolbar: ['preview', 'bold', 'italic'], // Customize toolbar options as needed
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
43
76
|
|
|
44
|
-
|
|
77
|
+
## CSS Setup
|
|
45
78
|
|
|
46
|
-
|
|
79
|
+
### Using TailwindCSS
|
|
80
|
+
|
|
81
|
+
If you’re leveraging **TailwindCSS**, add the following configuration to your `tailwind.config.js`:
|
|
47
82
|
|
|
48
83
|
```javascript
|
|
49
84
|
// tailwind.config.js
|
|
50
85
|
module.exports = {
|
|
51
86
|
content: [
|
|
52
|
-
// './src/**/*.{html,js}',
|
|
53
87
|
'node_modules/markdown-text-editor/**/*.js',
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
// Add your project paths here
|
|
89
|
+
],
|
|
90
|
+
};
|
|
56
91
|
```
|
|
57
92
|
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
### Without TailwindCSS
|
|
94
|
+
|
|
95
|
+
For projects not using TailwindCSS, simply import the CSS file directly:
|
|
60
96
|
|
|
61
97
|
```javascript
|
|
62
98
|
import 'markdown-text-editor/dist/markdown-text-editor.css';
|
|
63
99
|
```
|
|
64
100
|
|
|
65
|
-
|
|
66
|
-
For projects using a CDN, you can include the following links:
|
|
101
|
+
### Using a CDN
|
|
67
102
|
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
Alternatively, include the following CDN links in your HTML:
|
|
104
|
+
|
|
105
|
+
#### JavaScript:
|
|
106
|
+
|
|
107
|
+
```html
|
|
70
108
|
<script src="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.js"></script>
|
|
71
109
|
```
|
|
72
110
|
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
#### CSS:
|
|
112
|
+
|
|
113
|
+
```html
|
|
75
114
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.min.css">
|
|
76
115
|
```
|
|
77
116
|
|
|
117
|
+
---
|
|
78
118
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
119
|
+
## Markdown Content Retrieval
|
|
120
|
+
|
|
121
|
+
### JavaScript Value Retrieval
|
|
122
|
+
|
|
123
|
+
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).
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
#### HTML
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<form>
|
|
130
|
+
<textarea class="editor-container"></textarea>
|
|
131
|
+
<button type="button" id="submit-btn">Submit</button>
|
|
132
|
+
<div class="output"></div>
|
|
133
|
+
</form>
|
|
134
|
+
```
|
|
82
135
|
|
|
136
|
+
#### JavaScript
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
83
139
|
const editor = new MarkdownEditor('.editor-container', {
|
|
84
|
-
placeholder: '
|
|
85
|
-
toolbar: ['
|
|
140
|
+
placeholder: 'Start writing...',
|
|
141
|
+
toolbar: ['bold', 'italic', 'preview'],
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
document.getElementById('submit-btn').addEventListener('click', function() {
|
|
145
|
+
const markdownValue = document.querySelector('.editor-container').value;
|
|
146
|
+
console.log(markdownValue);
|
|
147
|
+
document.querySelector('.output').innerHTML = `<pre>${markdownValue}</pre>`;
|
|
86
148
|
});
|
|
87
149
|
```
|
|
88
150
|
|
|
89
|
-
|
|
151
|
+
### HTML Template Form Submission
|
|
90
152
|
|
|
91
|
-
|
|
153
|
+
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.
|
|
92
154
|
|
|
93
|
-
|
|
155
|
+
#### HTML (Form Submission)
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<form method="POST" action="/your-server-endpoint">
|
|
159
|
+
<textarea class="editor-container" name="markdown"></textarea>
|
|
160
|
+
<button type="submit">Submit</button>
|
|
161
|
+
</form>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
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>`.
|
|
165
|
+
|
|
166
|
+
#### JavaScript (MarkdownEditor Initialization)
|
|
94
167
|
|
|
95
|
-
**For example:**
|
|
96
168
|
```javascript
|
|
97
169
|
const editor = new MarkdownEditor('.editor-container', {
|
|
98
|
-
placeholder: '
|
|
99
|
-
toolbar: ['
|
|
170
|
+
placeholder: 'Write your markdown...',
|
|
171
|
+
toolbar: ['preview', 'bold', 'italic'],
|
|
100
172
|
});
|
|
101
173
|
```
|
|
102
174
|
|
|
175
|
+
|
|
103
176
|
## Configuration Options
|
|
104
177
|
|
|
105
|
-
|
|
178
|
+
Customize your Markdown editor by passing an `options` object during initialization. Below are some key configuration options:
|
|
179
|
+
|
|
180
|
+
| Option | Type | Default | Description |
|
|
181
|
+
|---------------|----------|------------------------------|-----------------------------------------------------------|
|
|
182
|
+
| `placeholder` | `string` | `'Write your markdown...'` | Sets the placeholder text for the textarea. |
|
|
183
|
+
| `toolbar` | `array` | `['bold', 'italic', 'strikethrough']` | Determines which tools appear in the toolbar and their order. |
|
|
106
184
|
|
|
107
|
-
|
|
108
|
-
|-------------|----------|----------------------------|-----------------------------------------------------|
|
|
109
|
-
| `placeholder` | `string` | `'Write your markdown...'` | The placeholder text for the textarea. |
|
|
110
|
-
| `toolbar` | `array` | `['bold', 'italic', 'strikethrough']` | The tools to display in the toolbar and their order. |
|
|
185
|
+
---
|
|
111
186
|
|
|
112
|
-
## Toolbar
|
|
187
|
+
## Toolbar Customization
|
|
113
188
|
|
|
114
|
-
|
|
189
|
+
Tailor the toolbar to suit your needs by choosing which formatting options to include. The MarkdownEditor Plugin supports several tools, including:
|
|
115
190
|
|
|
116
|
-
-
|
|
117
|
-
-
|
|
191
|
+
- **`bold`**: Enables bold text formatting.
|
|
192
|
+
- **`italic`**: Enables italic text formatting.
|
|
193
|
+
- **`strikethrough`**: Allows text to be struck through.
|
|
194
|
+
- **`preview`**: Toggles the real-time markdown preview.
|
|
118
195
|
|
|
119
|
-
Example
|
|
196
|
+
**Example:**
|
|
120
197
|
|
|
121
198
|
```javascript
|
|
122
199
|
const editor = new MarkdownEditor('.editor-container', {
|
|
123
|
-
placeholder: '
|
|
124
|
-
toolbar: ['
|
|
200
|
+
placeholder: 'Start writing...',
|
|
201
|
+
toolbar: ['bold', 'italic', 'strikethrough', 'preview'],
|
|
125
202
|
});
|
|
126
203
|
```
|
|
127
204
|
|
|
128
|
-
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Example Implementations
|
|
208
|
+
|
|
209
|
+
### Full HTML Example
|
|
129
210
|
|
|
130
|
-
|
|
211
|
+
Below is a complete HTML example demonstrating how to integrate the MarkdownEditor Plugin into your project:
|
|
131
212
|
|
|
132
213
|
```html
|
|
133
214
|
<!DOCTYPE html>
|
|
134
215
|
<html lang="en">
|
|
135
216
|
<head>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
217
|
+
<meta charset="UTF-8">
|
|
218
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
219
|
+
<title>Markdown Editor Example</title>
|
|
220
|
+
<link rel="stylesheet" href="dist/markdown-editor-plugin.css">
|
|
140
221
|
</head>
|
|
141
222
|
<body>
|
|
142
|
-
<textarea class="editor"></textarea>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
223
|
+
<textarea class="editor-container"></textarea>
|
|
224
|
+
|
|
225
|
+
<script src="dist/markdown-editor-plugin.js"></script>
|
|
226
|
+
<script>
|
|
227
|
+
const editor = new MarkdownEditor('.editor-container', {
|
|
228
|
+
placeholder: 'Type your markdown...',
|
|
229
|
+
toolbar: ['preview', 'bold', 'italic']
|
|
230
|
+
});
|
|
231
|
+
</script>
|
|
151
232
|
</body>
|
|
152
233
|
</html>
|
|
153
234
|
```
|
|
154
235
|
|
|
155
|
-
### Webpack Example
|
|
236
|
+
### Webpack Integration Example
|
|
156
237
|
|
|
157
|
-
|
|
238
|
+
For projects using Webpack, import and initialize the editor as follows:
|
|
158
239
|
|
|
159
240
|
```javascript
|
|
160
241
|
import MarkdownEditor from 'markdown-text-editor';
|
|
161
242
|
|
|
162
243
|
const editor = new MarkdownEditor('.editor-container', {
|
|
163
244
|
placeholder: 'Write markdown...',
|
|
164
|
-
toolbar: ['preview', 'bold', 'italic'],
|
|
245
|
+
toolbar: ['preview', 'bold', 'italic'],
|
|
165
246
|
});
|
|
166
247
|
```
|
|
167
248
|
|
|
168
|
-
### Customizing Styles with
|
|
249
|
+
### Customizing Styles with TailwindCSS
|
|
250
|
+
|
|
251
|
+
Customize the appearance of the editor using Tailwind utility classes. The plugin’s default styling can be easily overridden in your custom Tailwind configuration.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Contribute
|
|
169
256
|
|
|
170
|
-
|
|
257
|
+
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.
|
|
171
258
|
|
|
172
|
-
|
|
173
|
-
- You can override these classes in your custom Tailwind config to suit your design.
|
|
259
|
+
---
|
|
174
260
|
|
|
175
|
-
##
|
|
261
|
+
## License
|
|
176
262
|
|
|
177
|
-
|
|
263
|
+
This project is released under the [MIT License](LICENSE).
|
|
178
264
|
|
|
179
|
-
|
|
265
|
+
---
|
|
180
266
|
|
|
181
|
-
|
|
267
|
+
Thank you for choosing the MarkdownEditor Plugin – your reliable, feature-rich solution for seamless markdown editing and content creation with **easy integration**. Happy coding!
|