markdown-text-editor 0.0.1-beta.1

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 Nezanuha
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # MarkdownEditor Plugin Documentation
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.
4
+
5
+ ## Table of Contents
6
+ - [Installation](#installation)
7
+ - [Usage](#usage)
8
+ - [Configuration Options](#configuration-options)
9
+ - [Toolbar Options](#toolbar-options)
10
+ - [Methods](#methods)
11
+ - [Example Usage](#example-usage)
12
+ - [License](#license)
13
+
14
+ ## Installation
15
+
16
+ To install the plugin in your project, you can include the plugin JavaScript file and its associated styles.
17
+
18
+ 1. **Install via NPM** (for bundling tools like Webpack):
19
+ ```
20
+ npm install frutjam
21
+ ```
22
+
23
+ ## Usage
24
+
25
+
26
+ Import the `markdownEditor` class from frutjam:
27
+
28
+
29
+ ```
30
+ import { markdownEditor } from "frutjam";
31
+ ```
32
+
33
+ ### Basic Example:
34
+
35
+ To initialize the Markdown editor, you need an empty container (like a `div`) in your HTML and initialize the editor by passing the container's ID and options.
36
+
37
+ #### HTML:
38
+ ```html
39
+ <div id="editor-container"></div>
40
+ ```
41
+
42
+ #### JavaScript:
43
+ ```javascript
44
+ import { MarkdownEditor } from 'frutjam';
45
+
46
+ const editor = new MarkdownEditor('editor-container', {
47
+ placeholder: 'Write your markdown...',
48
+ toolbar: ['bold', 'italic'], // Define the tools you want in the toolbar
49
+ });
50
+ ```
51
+
52
+ This will create a markdown editor with a toolbar at the top and a preview area below the text input.
53
+
54
+ ### Dynamic Toolbar:
55
+
56
+ You can specify which formatting options you want in the toolbar. The plugin supports different tools that can be reordered.
57
+
58
+ For example:
59
+ ```javascript
60
+ const editor = new MarkdownEditor('editor-container', {
61
+ placeholder: 'Start writing...',
62
+ toolbar: ['bold', 'italic', 'strikethrough', 'preview'],
63
+ });
64
+ ```
65
+
66
+ ## Configuration Options
67
+
68
+ You can customize the Markdown editor by passing an `options` object when initializing it.
69
+
70
+ | Option | Type | Default | Description |
71
+ |-------------|----------|----------------------------|-----------------------------------------------------|
72
+ | `placeholder` | `string` | `'Write your markdown...'` | The placeholder text for the textarea. |
73
+ | `toolbar` | `array` | `['bold', 'italic', 'strikethrough']` | The tools to display in the toolbar and their order. |
74
+
75
+ ## Toolbar Options
76
+
77
+ The toolbar can be customized to include the following options (you can add more tools as needed):
78
+
79
+ - `bold`: Adds a bold button to the toolbar.
80
+ - `italic`: Adds an italic button to the toolbar.
81
+
82
+ Example:
83
+
84
+ ```javascript
85
+ const editor = new MarkdownEditor('editor-container', {
86
+ placeholder: 'Your markdown here...',
87
+ toolbar: ['italic', 'bold'], // Shows italic first, then bold
88
+ });
89
+ ```
90
+
91
+ ## Example Usage
92
+
93
+ ### Full Example:
94
+
95
+ ```html
96
+ <!DOCTYPE html>
97
+ <html lang="en">
98
+ <head>
99
+ <meta charset="UTF-8">
100
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
101
+ <title>Markdown Editor Example</title>
102
+ <link rel="stylesheet" href="dist/markdown-editor-plugin.css">
103
+ </head>
104
+ <body>
105
+ <div id="editor-container"></div>
106
+
107
+ <script src="dist/markdown-editor-plugin.js"></script>
108
+ <script>
109
+ const editor = new MarkdownEditor('editor-container', {
110
+ placeholder: 'Type some markdown...',
111
+ toolbar: ['bold', 'italic'] // Toolbar order: bold first, then italic
112
+ });
113
+ </script>
114
+ </body>
115
+ </html>
116
+ ```
117
+
118
+ ### Webpack Example:
119
+
120
+ To use the plugin with Webpack, import the plugin and initialize it as shown below:
121
+
122
+ ```javascript
123
+ import { markdownEditor } from 'frutjam';
124
+
125
+ const editor = new MarkdownEditor('editor-container', {
126
+ placeholder: 'Write markdown...',
127
+ toolbar: ['bold', 'italic'], // Custom toolbar options
128
+ });
129
+ ```
130
+
131
+ ### Customizing Styles with Tailwind:
132
+
133
+ You can modify the appearance of the editor and toolbar using Tailwind utility classes. For example:
134
+
135
+ - The toolbar and editor area are styled with Tailwind by default.
136
+ - You can override these classes in your custom Tailwind config to suit your design.
137
+
138
+ ## Folder Structure
139
+
140
+ Here’s a suggested folder structure for your project:
141
+
142
+ ```
143
+ /src
144
+ /components
145
+ /editor
146
+ Toolbar.js - Handles toolbar creation
147
+ MarkdownEditor.js - Main editor logic
148
+ /tools
149
+ BoldTool.js - Logic for Bold tool
150
+ ItalicTool.js - Logic for Italic tool
151
+ /styles
152
+ main.css - Includes Tailwind CSS
153
+ main.js - Entry point, initializes the editor
154
+ /webpack.config.js - Webpack configuration
155
+ /dist
156
+ markdown-editor-plugin.js - Generated JS file (bundled)
157
+ markdown-editor-plugin.css - Generated CSS file
158
+ ```
159
+
160
+ ## Conclusion
161
+
162
+ This **MarkdownEditor Plugin** allows easy setup of markdown editing with dynamic toolbar controls, making it flexible and reusable for various projects.