markdown-text-editor 0.0.20-beta.2 → 0.0.21-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 +119 -91
- 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 +7 -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,98 +1,142 @@
|
|
|
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)
|
|
8
12
|
- [Configuration Options](#configuration-options)
|
|
9
|
-
- [Toolbar
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
13
|
+
- [Toolbar Customization](#toolbar-customization)
|
|
14
|
+
- [Example Implementations](#example-implementations)
|
|
15
|
+
- [Contribution Guidelines](#contribute)
|
|
12
16
|
- [License](#license)
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
---
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
## Overview
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm install markdown-text-editor
|
|
21
|
-
```
|
|
22
|
+
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
23
|
|
|
23
|
-
|
|
24
|
+
- **Real-time Preview:** See your markdown rendered instantly as you type.
|
|
25
|
+
- **Syntax Highlighting:** Enhanced readability with clear code and markdown formatting.
|
|
26
|
+
- **Easy Integration:** Seamlessly integrate into any web project with minimal setup.
|
|
27
|
+
- **Customizable Toolbar:** Dynamically configure and reorder toolbar options like **bold**, **italic**, and more.
|
|
28
|
+
|
|
29
|
+
Built with **Tailwind CSS** for modern styling, this plugin is perfect for developers seeking a lightweight yet feature-rich markdown editor.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
24
34
|
|
|
35
|
+
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
36
|
|
|
26
|
-
|
|
37
|
+
### Install via NPM
|
|
27
38
|
|
|
39
|
+
For projects utilizing bundling tools like Webpack, run:
|
|
28
40
|
|
|
41
|
+
```bash
|
|
42
|
+
npm install markdown-text-editor
|
|
29
43
|
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
After installation, import the `MarkdownEditor` class from the package:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
30
52
|
import MarkdownEditor from "markdown-text-editor";
|
|
31
53
|
```
|
|
32
54
|
|
|
33
|
-
|
|
55
|
+
### Basic Initialization
|
|
34
56
|
|
|
35
|
-
To
|
|
57
|
+
To get started, include a `<textarea>` element in your HTML and initialize the editor by targeting its container:
|
|
58
|
+
|
|
59
|
+
#### HTML
|
|
36
60
|
|
|
37
|
-
### HTML:
|
|
38
61
|
```html
|
|
39
62
|
<textarea class="editor-container"></textarea>
|
|
40
63
|
```
|
|
41
64
|
|
|
42
|
-
|
|
65
|
+
#### JavaScript
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
const editor = new MarkdownEditor('.editor-container', {
|
|
69
|
+
placeholder: 'Write your markdown...',
|
|
70
|
+
toolbar: ['preview', 'bold', 'italic'], // Customize toolbar options as needed
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## CSS Setup
|
|
43
77
|
|
|
44
|
-
|
|
78
|
+
### Using TailwindCSS
|
|
45
79
|
|
|
46
|
-
If you
|
|
80
|
+
If you’re leveraging **TailwindCSS**, add the following configuration to your `tailwind.config.js`:
|
|
47
81
|
|
|
48
82
|
```javascript
|
|
49
83
|
// tailwind.config.js
|
|
50
84
|
module.exports = {
|
|
51
85
|
content: [
|
|
52
|
-
// './src/**/*.{html,js}',
|
|
53
86
|
'node_modules/markdown-text-editor/**/*.js',
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
// Add your project paths here
|
|
88
|
+
],
|
|
89
|
+
};
|
|
56
90
|
```
|
|
57
91
|
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
### Without TailwindCSS
|
|
93
|
+
|
|
94
|
+
For projects not using TailwindCSS, simply import the CSS file directly:
|
|
60
95
|
|
|
61
96
|
```javascript
|
|
62
97
|
import 'markdown-text-editor/dist/markdown-text-editor.css';
|
|
63
98
|
```
|
|
64
99
|
|
|
65
|
-
|
|
66
|
-
For projects using a CDN, you can include the following links:
|
|
100
|
+
### Using a CDN
|
|
67
101
|
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
Alternatively, include the following CDN links in your HTML:
|
|
103
|
+
|
|
104
|
+
#### JavaScript:
|
|
105
|
+
|
|
106
|
+
```html
|
|
70
107
|
<script src="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.js"></script>
|
|
71
108
|
```
|
|
72
109
|
|
|
73
|
-
|
|
74
|
-
|
|
110
|
+
#### CSS:
|
|
111
|
+
|
|
112
|
+
```html
|
|
75
113
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.min.css">
|
|
76
114
|
```
|
|
77
115
|
|
|
116
|
+
---
|
|
78
117
|
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
import MarkdownEditor from 'markdown-text-editor';
|
|
118
|
+
## Configuration Options
|
|
82
119
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
Customize your Markdown editor by passing an `options` object during initialization. Below are some key configuration options:
|
|
121
|
+
|
|
122
|
+
| Option | Type | Default | Description |
|
|
123
|
+
|---------------|----------|------------------------------|-----------------------------------------------------------|
|
|
124
|
+
| `placeholder` | `string` | `'Write your markdown...'` | Sets the placeholder text for the textarea. |
|
|
125
|
+
| `toolbar` | `array` | `['bold', 'italic', 'strikethrough']` | Determines which tools appear in the toolbar and their order. |
|
|
88
126
|
|
|
89
|
-
|
|
127
|
+
---
|
|
90
128
|
|
|
91
|
-
|
|
129
|
+
## Toolbar Customization
|
|
92
130
|
|
|
93
|
-
|
|
131
|
+
Tailor the toolbar to suit your needs by choosing which formatting options to include. The MarkdownEditor Plugin supports several tools, including:
|
|
132
|
+
|
|
133
|
+
- **`bold`**: Enables bold text formatting.
|
|
134
|
+
- **`italic`**: Enables italic text formatting.
|
|
135
|
+
- **`strikethrough`**: Allows text to be struck through.
|
|
136
|
+
- **`preview`**: Toggles the real-time markdown preview.
|
|
137
|
+
|
|
138
|
+
**Example:**
|
|
94
139
|
|
|
95
|
-
**For example:**
|
|
96
140
|
```javascript
|
|
97
141
|
const editor = new MarkdownEditor('.editor-container', {
|
|
98
142
|
placeholder: 'Start writing...',
|
|
@@ -100,82 +144,66 @@ const editor = new MarkdownEditor('.editor-container', {
|
|
|
100
144
|
});
|
|
101
145
|
```
|
|
102
146
|
|
|
103
|
-
|
|
147
|
+
---
|
|
104
148
|
|
|
105
|
-
|
|
149
|
+
## Example Implementations
|
|
106
150
|
|
|
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. |
|
|
151
|
+
### Full HTML Example
|
|
111
152
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
The toolbar can be customized to include the following options (you can add more tools as needed):
|
|
115
|
-
|
|
116
|
-
- `bold`: Adds a bold button to the toolbar.
|
|
117
|
-
- `italic`: Adds an italic button to the toolbar.
|
|
118
|
-
|
|
119
|
-
Example:
|
|
120
|
-
|
|
121
|
-
```javascript
|
|
122
|
-
const editor = new MarkdownEditor('.editor-container', {
|
|
123
|
-
placeholder: 'Your markdown here...',
|
|
124
|
-
toolbar: ['preview', 'italic', 'bold'], // Shows italic first, then bold
|
|
125
|
-
});
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Example Usage
|
|
129
|
-
|
|
130
|
-
### Full Example:
|
|
153
|
+
Below is a complete HTML example demonstrating how to integrate the MarkdownEditor Plugin into your project:
|
|
131
154
|
|
|
132
155
|
```html
|
|
133
156
|
<!DOCTYPE html>
|
|
134
157
|
<html lang="en">
|
|
135
158
|
<head>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
159
|
+
<meta charset="UTF-8">
|
|
160
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
161
|
+
<title>Markdown Editor Example</title>
|
|
162
|
+
<link rel="stylesheet" href="dist/markdown-editor-plugin.css">
|
|
140
163
|
</head>
|
|
141
164
|
<body>
|
|
142
|
-
<textarea class="editor"></textarea>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
165
|
+
<textarea class="editor-container"></textarea>
|
|
166
|
+
|
|
167
|
+
<script src="dist/markdown-editor-plugin.js"></script>
|
|
168
|
+
<script>
|
|
169
|
+
const editor = new MarkdownEditor('.editor-container', {
|
|
170
|
+
placeholder: 'Type your markdown...',
|
|
171
|
+
toolbar: ['preview', 'bold', 'italic']
|
|
172
|
+
});
|
|
173
|
+
</script>
|
|
151
174
|
</body>
|
|
152
175
|
</html>
|
|
153
176
|
```
|
|
154
177
|
|
|
155
|
-
### Webpack Example
|
|
178
|
+
### Webpack Integration Example
|
|
156
179
|
|
|
157
|
-
|
|
180
|
+
For projects using Webpack, import and initialize the editor as follows:
|
|
158
181
|
|
|
159
182
|
```javascript
|
|
160
183
|
import MarkdownEditor from 'markdown-text-editor';
|
|
161
184
|
|
|
162
185
|
const editor = new MarkdownEditor('.editor-container', {
|
|
163
186
|
placeholder: 'Write markdown...',
|
|
164
|
-
toolbar: ['preview', 'bold', 'italic'],
|
|
187
|
+
toolbar: ['preview', 'bold', 'italic'],
|
|
165
188
|
});
|
|
166
189
|
```
|
|
167
190
|
|
|
168
|
-
### Customizing Styles with
|
|
191
|
+
### Customizing Styles with TailwindCSS
|
|
192
|
+
|
|
193
|
+
Customize the appearance of the editor using Tailwind utility classes. The plugin’s default styling can be easily overridden in your custom Tailwind configuration.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Contribute
|
|
169
198
|
|
|
170
|
-
|
|
199
|
+
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
200
|
|
|
172
|
-
|
|
173
|
-
- You can override these classes in your custom Tailwind config to suit your design.
|
|
201
|
+
---
|
|
174
202
|
|
|
175
|
-
##
|
|
203
|
+
## License
|
|
176
204
|
|
|
177
|
-
|
|
205
|
+
This project is released under the [MIT License](LICENSE).
|
|
178
206
|
|
|
179
|
-
|
|
207
|
+
---
|
|
180
208
|
|
|
181
|
-
|
|
209
|
+
Thank you for choosing the MarkdownEditor Plugin – your reliable, feature-rich solution for seamless markdown editing and content creation with **easy integration**. Happy coding!
|