markdown-text-editor 0.3.0 → 0.5.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 CHANGED
@@ -1,31 +1,21 @@
1
1
  ## MarkdownEditor – Best JavaScript Markdown Editor Plugin
2
2
 
3
- [![Total Downloads](https://img.shields.io/npm/dt/markdown-text-editor.svg)](https://www.npmjs.com/package/markdown-text-editor)
3
+ [![npm installs][npm_installs]](https://www.npmjs.com/package/markdown-text-editor)
4
+ [![Jsdelivr hits][jsdelivr]](https://cdn.jsdelivr.net/npm/markdown-text-editor)
4
5
  [![Latest Release](https://img.shields.io/npm/v/markdown-text-editor.svg)](https://github.com/nezanuha/markdown-text-editor/releases)
5
6
  [![License](https://img.shields.io/npm/l/markdown-text-editor.svg)](https://github.com/nezanuha/markdown-text-editor/blob/master/LICENSE)
6
7
  [![Secured](https://img.shields.io/badge/Security-Passed-green)](https://snyk.io/test/github/nezanuha/markdown-text-editor)
8
+ ![GitHub Repo stars](https://img.shields.io/github/stars/nezanuha/markdown-text-editor?style=flat)
9
+
7
10
 
8
11
  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.
9
12
 
10
- ---
11
- ## Table of Contents
13
+ ## Built With
12
14
 
13
- - [Overview](#overview)
14
- - [Installation](#installation)
15
- - [Usage](#usage)
16
- - [Markdown Content Retrieval](#markdown-content-retrieval)
17
- - [JavaScript Value Retrieval](#javascript-value-retrieval)
18
- - [HTML Template Form Submission](#html-template-form-submission)
19
- - [Set Markdown Content to Editor](#set-markdown-content-to-editor)
20
- - [Configuration Options](#configuration-options)
21
- - [Toolbar Customization](#toolbar-customization)
22
- - [Example Implementations](#full-html-example-implementations)
23
- - [Contribution Guidelines](#contribute)
24
- - [License](#license)
15
+ This Markdown editor is built using [frutjam](https://frutjam.com), a customizable Tailwind CSS UI library.
25
16
 
26
- ---
27
17
  ## Features
28
-
18
+ - ✅ **Effortless Frutjam UI Integration**: Easily integrate the Frutjam UI library with automatic editor theme adjustments based on the selected theme.
29
19
  - ✅ **Actively Maintenaning**: The plugin receives regular updates to stay up to date.
30
20
  - ✅ **User-Friendly**: It offers a WYSIWYG-style interface, making it great for non-technical users.
31
21
  - ✅ **Simple Markdown _Get/Set_**: No complicated techniques are required to get and set the markdown content. You can use the <textarea> value or name attribute to get and set markdown content.
@@ -35,322 +25,33 @@ Welcome to **MarkdownEditor**, the leading open source JavaScript markdown edito
35
25
  - ✅ **Live Preview Mode**: Watch your markdown content render while you type, providing a real-time preview of formatting, links, images, and more.
36
26
  - ✅ **Automatic Dark Mode Support**: The editor follows your system's or website's dark mode settings, giving a seamless experience.
37
27
 
38
- ---
39
-
40
- ## Overview
41
-
42
- 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:
43
-
44
- - **Real-time Preview:** See your markdown rendered instantly as you type.
45
- - **Syntax Highlighting:** Enhanced readability with clear code and markdown formatting.
46
- - **Easy Integration:** Seamlessly integrate into any web project with minimal setup.
47
- - **Customizable Toolbar:** Dynamically configure and reorder toolbar options like **bold**, **italic**, and more.
48
-
49
- ---
50
-
51
- ## Installation
52
-
53
- 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.
54
-
55
- ### Install via NPM
56
-
57
- For projects utilizing bundling tools like Webpack, run:
58
-
59
- ```bash
60
- npm install markdown-text-editor
61
- ```
62
-
63
- ---
64
-
65
- ## Usage
66
-
67
- After installation, import the `MarkdownEditor` class from the package:
68
-
69
- ```javascript
70
- import MarkdownEditor from "markdown-text-editor";
71
- ```
72
-
73
- ### Basic Initialization
28
+ ## Documentation
74
29
 
75
- To get started, include a `<textarea>` element in your HTML and initialize the editor by targeting its container:
76
-
77
- #### HTML
78
-
79
- ```html
80
- <textarea class="editor-container"></textarea>
81
- ```
82
-
83
- #### JavaScript
84
-
85
- ```javascript
86
- const editor = new MarkdownEditor('.editor-container', {
87
- placeholder: 'Write your markdown...',
88
- toolbar: ['heading', 'bold', 'italic', 'strikethrough', 'ul', 'ol', 'checklist', 'blockquote', 'link', 'preview'],
89
- });
90
- ```
30
+ For full documentation, visit [Markdown Editor](https://frutjam.com/plugins/markdown-editor).
91
31
 
92
32
  ---
93
33
 
94
- ## CSS Setup
95
-
96
- import the CSS file directly in your js code:
97
-
98
- ```javascript
99
- import 'markdown-text-editor/dist/markdown-text-editor.css';
100
- ```
101
-
102
- ### Using a CDN
103
-
104
- Alternatively, include the following CDN links in your HTML:
105
-
106
- #### JavaScript:
107
-
108
- ```html
109
- <script src="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.js"></script>
110
- ```
111
-
112
- #### CSS:
113
-
114
- ```html
115
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markdown-text-editor/dist/markdown-text-editor.css">
116
- ```
117
-
118
- ---
119
-
120
- ## Markdown Content Retrieval
121
-
122
- ### JavaScript Value Retrieval
123
-
124
- 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).
125
-
126
-
127
- #### HTML
128
-
129
- ```html
130
- <form>
131
- <textarea class="editor-container h-48" rows="5"></textarea>
132
- <button type="button" id="submit-btn">Submit</button>
133
- <div class="output"></div>
134
- </form>
135
- ```
136
-
137
- #### JavaScript
138
-
139
- ```javascript
140
- const editor = new MarkdownEditor('.editor-container', {
141
- placeholder: 'Start writing...',
142
- toolbar: ['bold', 'italic', 'preview'],
143
- });
144
-
145
- document.getElementById('submit-btn').addEventListener('click', function() {
146
- const markdownValue = document.querySelector('.editor-container').value;
147
- console.log(markdownValue);
148
- document.querySelector('.output').innerHTML = `<pre>${markdownValue}</pre>`;
149
- });
150
- ```
151
-
152
- ### HTML Template Form Submission
153
-
154
- 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.
155
-
156
- #### HTML (Form Submission)
157
-
158
- ```html
159
- <form method="POST" action="/your-server-endpoint">
160
- <textarea class="editor-container h-48" rows="5" name="markdown"></textarea>
161
- <button type="submit">Submit</button>
162
- </form>
163
- ```
164
-
165
- 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>`.
166
-
167
- #### JavaScript (MarkdownEditor Initialization)
168
-
169
- ```javascript
170
- const editor = new MarkdownEditor('.editor-container', {
171
- placeholder: 'Write your markdown...',
172
- toolbar: ['preview', 'bold', 'italic'],
173
- });
174
- ```
175
-
176
- ## Set Markdown Content to Editor
177
-
178
- ```HTML
179
- <form method="POST" action="/your-server-endpoint">
180
- <textarea class="editor-container h-48" rows="5" name="markdown">Add your markdown content here</textarea>
181
- <button type="submit">Submit</button>
182
- </form>
183
- ```
184
-
185
- ## Configuration Options
186
-
187
- Customize your Markdown editor by passing an `options` object during initialization. Below are some key configuration options:
188
-
189
- | Option | Type | Default | Description |
190
- |---------------|----------|------------------------------|-----------------------------------------------------------|
191
- | `placeholder` | `string` | `'Write your markdown...'` | Sets the placeholder text for the textarea (optional, as you can also use the standard HTML textarea attribute) |
192
- | `toolbar` | `array` | `['heading', 'bold', 'italic', 'strikethrough', 'ul', 'ol', 'checklist', 'blockquote', 'link', 'image', 'preview']` | Determines which tools appear in the toolbar and their order. |
193
-
194
- ---
195
-
196
- ## Toolbar Customization
197
-
198
- Tailor the toolbar to suit your needs by choosing which formatting options to include. The MarkdownEditor Plugin supports several tools, including:
199
-
200
- - `bold`: Enables bold text formatting.
201
- - `italic`: Enables italic text formatting.
202
- - `strikethrough`: Allows text to be struck through.
203
- - `ol`: (Ordered List): Converts text into a numbered list format.
204
- - `ul`: (Unordered List): Converts text into a bullet point list.
205
- - `checklist`: Adds checkboxes to your text, making it great for tasks, to-do lists, or tracking completion status.
206
- - `image`: Allows you to insert images via markdown syntax.
207
- - `link`: Lets you add hyperlinks to your text.
208
- - `preview`: Toggles the real-time markdown preview.
209
-
210
- **Example:**
211
-
212
- ```javascript
213
- const editor = new MarkdownEditor('.editor-container', {
214
- placeholder: 'Start writing...',
215
- toolbar: [
216
- 'bold',
217
- 'italic',
218
- 'strikethrough',
219
- 'ul',
220
- 'ol',
221
- 'checklist',
222
- 'image',
223
- 'link',
224
- 'preview'
225
- ],
226
- });
227
- ```
228
- ### Advanced Image Upload
229
-
230
- * The image tool supports a `fileInput` configuration that allows:
231
-
232
- * `accept`: Array of allowed image file types (e.g., `'webp'`, `'avif'`).
233
- * `uploadUrl`: The endpoint where image files will be uploaded.
234
- * After a successful upload, the server must return the image path, which will be automatically populated in the URL field.
34
+ ## Contribute
235
35
 
236
- **Usage example:**
36
+ 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.
237
37
 
238
- ```js
239
- const options = {
240
- placeholder: 'Start writing...',
241
- toolbar: [
242
- 'link',
243
- {
244
- image: {
245
- fileInput: {
246
- accept: ['webp', 'avif'],
247
- uploadUrl: '/api/upload', // Your upload endpoint
248
- },
249
- }
250
- },
251
- 'preview'
252
- ],
253
- }
254
- const editor = new MarkdownEditor(element, options);
255
- ```
256
- * **If `fileInput` is not configured,** the image modal will default to only showing the `URL` and `alt text` fields.
257
-
258
- **Usage example:**
259
-
260
- ```js
261
- const options = {
262
- placeholder: 'Start writing...',
263
- toolbar: [
264
- 'link',
265
- 'image',
266
- 'preview'
267
- ],
268
- }
269
- const editor = new MarkdownEditor(element, options);
270
38
  ---
271
39
 
272
- **Tip:**
273
- You can reorder or remove any toolbar buttons by modifying the toolbar array during initialization.
274
-
275
- ## Full HTML Example Implementations
276
-
277
- Below is a complete HTML example demonstrating how to integrate the MarkdownEditor Plugin into your project:
278
-
279
- ```html
280
- <!DOCTYPE html>
281
- <html lang="en">
282
- <head>
283
- <meta charset="UTF-8">
284
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
285
- <title>Markdown Editor Example</title>
286
- <link rel="stylesheet" href="dist/markdown-editor-plugin.css">
287
- </head>
288
- <body>
289
- <textarea class="editor-container h-56" rows="6"></textarea>
290
-
291
- <script src="dist/markdown-editor-plugin.js"></script>
292
- <script>
293
- const editor = new MarkdownEditor('.editor-container', {
294
- placeholder: 'Type your markdown...',
295
- toolbar: [
296
- 'bold',
297
- 'italic',
298
- 'strikethrough',
299
- 'ul',
300
- 'ol',
301
- 'checklist',
302
- 'image',
303
- 'link',
304
- {
305
- image: {
306
- fileInput: {
307
- accept: ['webp', 'avif'],
308
- uploadUrl: '/api/upload', // Your upload endpoint
309
- },
310
- }
311
- },
312
- 'preview'
313
- ],
314
- });
315
- </script>
316
- </body>
317
- </html>
318
- ```
319
-
320
- ### Webpack Integration Example
321
-
322
- For projects using Webpack, import and initialize the editor as follows:
40
+ ## License
323
41
 
324
- ```javascript
325
- import MarkdownEditor from 'markdown-text-editor';
42
+ This project is released under the [MIT License](LICENSE).
326
43
 
327
- const editor = new MarkdownEditor('.editor-container', {
328
- placeholder: 'Write markdown...',
329
- toolbar: [
330
- 'bold',
331
- 'italic',
332
- 'strikethrough',
333
- 'ul',
334
- 'ol',
335
- 'checklist',
336
- 'image',
337
- 'link',
338
- 'preview'
339
- ],
340
- });
341
- ```
342
44
  ---
343
45
 
344
- ## Contribute
345
-
346
- 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.
46
+ Thank you for choosing the MarkdownEditor Plugin – your reliable, feature-rich solution for seamless markdown editing and content creation with **easy integration**. Happy coding!
347
47
 
348
- ---
48
+ ## ⭐ Support
349
49
 
350
- ## License
50
+ If you like this project, consider giving it a star! 🌟
351
51
 
352
- This project is released under the [MIT License](LICENSE).
52
+ [![GitHub stars](https://img.shields.io/github/stars/nezanuha/markdown-text-editor.svg?style=social&label=Star&maxAge=2592000)](https://github.com/nezanuha/markdown-text-editor/stargazers)
353
53
 
354
54
  ---
355
55
 
356
- Thank you for choosing the MarkdownEditor Plugin – your reliable, feature-rich solution for seamless markdown editing and content creation with **easy integration**. Happy coding!
56
+ [jsdelivr]: https://badgen.net/jsdelivr/hits/npm/markdown-text-editor
57
+ [npm_installs]: https://badgen.net/npm/dt/markdown-text-editor