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 CHANGED
@@ -1,181 +1,267 @@
1
- # MarkdownEditor Plugin Documentation
1
+ ## MarkdownEditor Plugin Documentation
2
2
 
3
- This document explains how to use the **MarkdownEditor Plugin**, a customizable, reusable markdown editor with toolbar functionality that allows options like **bold** and **italic** formatting. Users can dynamically set which tools to display and in what order. The plugin is built with Tailwind CSS for styling and provides easy integration into any project.
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 Options](#toolbar-options)
10
- - [Methods](#methods)
11
- - [Example Usage](#example-usage)
14
+ - [Toolbar Customization](#toolbar-customization)
15
+ - [Example Implementations](#example-implementations)
16
+ - [Contribution Guidelines](#contribute)
12
17
  - [License](#license)
13
18
 
14
- ## Installation
19
+ ---
15
20
 
16
- To install the plugin in your project, you can include the plugin JavaScript file and its associated styles.
21
+ ## Overview
17
22
 
18
- 1. **Install via NPM** (for bundling tools like Webpack):
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
- ## Usage
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
- Import the `MarkdownEditor` class from markdown-text-editor:
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
- ## Basic Example:
56
+ ### Basic Initialization
34
57
 
35
- To initialize the Markdown editor, you need to add `textarea` tag in your HTML and initialize the editor by passing the container's ID or class and options.
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
- ### CSS Setup
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
- #### Using TailwindCSS
77
+ ## CSS Setup
45
78
 
46
- If you are using **TailwindCSS**, add the following configuration to your `tailwind.config.js` file:
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
- #### Without TailwindCSS
59
- If you are not using TailwindCSS, you can directly import the CSS file into your project:
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
- #### Using CDN
66
- For projects using a CDN, you can include the following links:
101
+ ### Using a CDN
67
102
 
68
- **JavaScript:**
69
- ```javascript
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
- **CSS:**
74
- ```javascript
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
- #### Using a bundler e.g. Webpack:
80
- ```javascript
81
- import MarkdownEditor from 'markdown-text-editor';
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: 'Write your markdown...',
85
- toolbar: ['preview', 'bold', 'italic'], // Define the tools you want in the 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
- This will create a markdown editor with a toolbar at the top and a preview area below the text input.
151
+ ### HTML Template Form Submission
90
152
 
91
- ### Dynamic Toolbar:
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
- You can specify which formatting options you want in the toolbar. The plugin supports different tools that can be reordered.
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: 'Start writing...',
99
- toolbar: ['bold', 'italic', 'strikethrough', 'preview'],
170
+ placeholder: 'Write your markdown...',
171
+ toolbar: ['preview', 'bold', 'italic'],
100
172
  });
101
173
  ```
102
174
 
175
+
103
176
  ## Configuration Options
104
177
 
105
- You can customize the Markdown editor by passing an `options` object when initializing it.
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
- | Option | Type | Default | Description |
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 Options
187
+ ## Toolbar Customization
113
188
 
114
- The toolbar can be customized to include the following options (you can add more tools as needed):
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
- - `bold`: Adds a bold button to the toolbar.
117
- - `italic`: Adds an italic button to the toolbar.
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: 'Your markdown here...',
124
- toolbar: ['preview', 'italic', 'bold'], // Shows italic first, then bold
200
+ placeholder: 'Start writing...',
201
+ toolbar: ['bold', 'italic', 'strikethrough', 'preview'],
125
202
  });
126
203
  ```
127
204
 
128
- ## Example Usage
205
+ ---
206
+
207
+ ## Example Implementations
208
+
209
+ ### Full HTML Example
129
210
 
130
- ### Full Example:
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
- <meta charset="UTF-8">
137
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
138
- <title>Markdown Editor Example</title>
139
- <link rel="stylesheet" href="dist/markdown-editor-plugin.css">
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
- <script src="dist/markdown-editor-plugin.js"></script>
145
- <script>
146
- const editor = new MarkdownEditor('.editor-container', {
147
- placeholder: 'Type some markdown...',
148
- toolbar: ['preview', 'bold', 'italic'] // Toolbar order: bold first, then italic
149
- });
150
- </script>
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
- To use the plugin with Webpack, import the plugin and initialize it as shown below:
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'], // Custom toolbar options
245
+ toolbar: ['preview', 'bold', 'italic'],
165
246
  });
166
247
  ```
167
248
 
168
- ### Customizing Styles with Tailwind:
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
- You can modify the appearance of the editor and toolbar using Tailwind utility classes. For example:
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
- - The toolbar and editor area are styled with Tailwind by default.
173
- - You can override these classes in your custom Tailwind config to suit your design.
259
+ ---
174
260
 
175
- ## Contribute to the Project
261
+ ## License
176
262
 
177
- If you're interested in improving this editor, I welcome contributions! Feel free to open issues or submit pull requests with bug fixes, features, or enhancements. Your contributions will help keep the project active and thriving.
263
+ This project is released under the [MIT License](LICENSE).
178
264
 
179
- Thank you for your support and consideration. Let’s continue to improve Markdown editing together!
265
+ ---
180
266
 
181
- ## A Product of Nezanuha
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!