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