markdown-notes-engine 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 ADDED
@@ -0,0 +1,196 @@
1
+ # Markdown Notes Engine
2
+
3
+ [![npm version](https://img.shields.io/npm/v/markdown-notes-engine.svg)](https://www.npmjs.com/package/markdown-notes-engine)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A complete, production-ready markdown note-taking engine with GitHub integration and media hosting. Add powerful note-taking capabilities to any Node.js application with just a few lines of code.
7
+
8
+ ## Features
9
+
10
+ - **Full Markdown Support** - Rich markdown editing with live preview
11
+ - **GitHub Integration** - Automatic version control for all notes
12
+ - **Media Hosting** - Image and video uploads to Cloudflare R2 or AWS S3
13
+ - **Syntax Highlighting** - Beautiful code blocks with highlight.js
14
+ - **Auto-save** - Never lose your work with automatic saving
15
+ - **Search** - Full-text search across all notes
16
+ - **Dark Mode** - Built-in dark mode support
17
+ - **Responsive** - Works beautifully on mobile and desktop
18
+ - **Keyboard Shortcuts** - Boost productivity with keyboard shortcuts
19
+ - **Drag & Drop** - Upload media with drag and drop
20
+
21
+ ## Quick Start
22
+
23
+ ### Installation
24
+
25
+ ```bash
26
+ npm install markdown-notes-engine
27
+ ```
28
+
29
+ ### Backend (Express)
30
+
31
+ ```javascript
32
+ const { createNotesRouter } = require('markdown-notes-engine');
33
+
34
+ const notesRouter = createNotesRouter({
35
+ github: {
36
+ token: process.env.GITHUB_TOKEN,
37
+ owner: process.env.GITHUB_OWNER,
38
+ repo: process.env.GITHUB_REPO
39
+ },
40
+ storage: {
41
+ type: 'r2',
42
+ accountId: process.env.R2_ACCOUNT_ID,
43
+ accessKeyId: process.env.R2_ACCESS_KEY_ID,
44
+ secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
45
+ bucketName: process.env.R2_BUCKET_NAME,
46
+ publicUrl: process.env.R2_PUBLIC_URL
47
+ }
48
+ });
49
+
50
+ app.use('/api', notesRouter);
51
+ ```
52
+
53
+ ### Frontend (JavaScript)
54
+
55
+ ```html
56
+ <div id="notes-app"></div>
57
+
58
+ <script src="node_modules/markdown-notes-engine/lib/frontend/index.js"></script>
59
+ <script>
60
+ const editor = new NotesEditor({
61
+ container: '#notes-app',
62
+ apiEndpoint: '/api'
63
+ });
64
+ </script>
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ For complete documentation, see:
70
+ - **[Full Documentation](lib/README.md)** - Complete API reference and usage guide
71
+ - **[Express Example](examples/express-app/README.md)** - Working Express.js integration example
72
+
73
+ ## Examples
74
+
75
+ Check out the `/examples` directory for complete working examples:
76
+
77
+ - **Express App** - Full Express.js integration with frontend
78
+ - More examples coming soon!
79
+
80
+ ## Architecture
81
+
82
+ The package provides:
83
+
84
+ ### Backend
85
+ - **`createNotesRouter(config)`** - Express router with all API endpoints
86
+ - **`GitHubClient`** - GitHub API wrapper for note storage
87
+ - **`StorageClient`** - R2/S3 client for media uploads
88
+ - **`MarkdownRenderer`** - Markdown to HTML renderer with syntax highlighting
89
+
90
+ ### Frontend
91
+ - **`NotesEditor`** - Complete note-taking UI component
92
+ - **Styles** - Beautiful, customizable styles with dark mode
93
+
94
+ ## Requirements
95
+
96
+ - Node.js >= 16.0.0
97
+ - GitHub personal access token with `repo` scope
98
+ - Cloudflare R2 or AWS S3 account (for media uploads)
99
+
100
+ ## Environment Variables
101
+
102
+ ```env
103
+ GITHUB_TOKEN=ghp_xxxxxxxxxxxx
104
+ GITHUB_OWNER=your-username
105
+ GITHUB_REPO=your-notes-repo
106
+
107
+ R2_ACCOUNT_ID=your-account-id
108
+ R2_ACCESS_KEY_ID=your-access-key
109
+ R2_SECRET_ACCESS_KEY=your-secret-key
110
+ R2_BUCKET_NAME=your-bucket
111
+ R2_PUBLIC_URL=https://your-bucket.r2.dev
112
+ ```
113
+
114
+ ## Development
115
+
116
+ This repository contains both the package source and a working notes application.
117
+
118
+ ### Project Structure
119
+
120
+ ```
121
+ markdown-notes-engine/
122
+ ├── lib/ # NPM package source
123
+ │ ├── backend/ # Express router and API
124
+ │ ├── frontend/ # Editor UI component
125
+ │ └── index.js # Main package entry
126
+ ├── examples/ # Usage examples
127
+ │ └── express-app/ # Express integration example
128
+ ├── server.js # Demo server
129
+ ├── public/ # Demo frontend
130
+ └── package.json # Package configuration
131
+ ```
132
+
133
+ ### Running the Demo
134
+
135
+ ```bash
136
+ # Install dependencies
137
+ npm install
138
+
139
+ # Create .env file with your credentials
140
+ cp .env.example .env
141
+
142
+ # Start the server
143
+ npm run dev
144
+ ```
145
+
146
+ Open `http://localhost:3001` to see the demo application.
147
+
148
+ ## API Endpoints
149
+
150
+ When mounted, the notes router provides:
151
+
152
+ - `GET /structure` - Get file tree
153
+ - `GET /note` - Get note content
154
+ - `POST /note` - Save note
155
+ - `DELETE /note` - Delete note
156
+ - `POST /folder` - Create folder
157
+ - `DELETE /folder` - Delete folder
158
+ - `POST /upload-image` - Upload image
159
+ - `POST /upload-video` - Upload video
160
+ - `POST /render` - Render markdown
161
+ - `GET /search` - Search notes
162
+
163
+ ## Keyboard Shortcuts
164
+
165
+ - `Ctrl/Cmd + S` - Save note
166
+ - `Ctrl/Cmd + P` - Toggle preview
167
+ - `Ctrl/Cmd + N` - New note
168
+ - `Ctrl/Cmd + U` - Upload image
169
+ - `Ctrl/Cmd + Shift + U` - Upload video
170
+
171
+ ## Contributing
172
+
173
+ Contributions are welcome! Please feel free to submit a Pull Request.
174
+
175
+ ## License
176
+
177
+ MIT License - see [LICENSE](LICENSE) for details
178
+
179
+ ## Support
180
+
181
+ - 📖 [Documentation](lib/README.md)
182
+ - 💬 [Issues](https://github.com/cdthomp1/notes/issues)
183
+ - 📧 [Contact](mailto:your-email@example.com)
184
+
185
+ ## Acknowledgments
186
+
187
+ Built with:
188
+ - [Express](https://expressjs.com/) - Web framework
189
+ - [Marked](https://marked.js.org/) - Markdown parser
190
+ - [Highlight.js](https://highlightjs.org/) - Syntax highlighting
191
+ - [Octokit](https://github.com/octokit/rest.js/) - GitHub API client
192
+ - [AWS SDK](https://aws.amazon.com/sdk-for-javascript/) - S3/R2 client
193
+
194
+ ---
195
+
196
+ Made with ❤️ for markdown lovers everywhere
package/lib/README.md ADDED
@@ -0,0 +1,312 @@
1
+ # Markdown Notes Engine
2
+
3
+ A complete, production-ready markdown note-taking engine with GitHub integration and media hosting. Add powerful note-taking capabilities to any Node.js application with just a few lines of code.
4
+
5
+ ## Features
6
+
7
+ - **Full Markdown Support**: Rich markdown editing with live preview
8
+ - **GitHub Integration**: Automatic version control - all notes saved to GitHub
9
+ - **Media Hosting**: Image and video uploads to Cloudflare R2 or AWS S3
10
+ - **Syntax Highlighting**: Beautiful code blocks with highlight.js
11
+ - **Auto-save**: Automatic note saving with configurable debounce
12
+ - **Search**: Full-text search across all notes
13
+ - **Dark Mode**: Built-in dark mode support
14
+ - **Responsive**: Mobile-friendly UI
15
+ - **Keyboard Shortcuts**: Productivity-focused shortcuts
16
+ - **Drag & Drop**: Drag and drop images/videos directly into the editor
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install markdown-notes-engine
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ### Backend Setup (Express)
27
+
28
+ ```javascript
29
+ const express = require('express');
30
+ const { createNotesRouter } = require('markdown-notes-engine');
31
+
32
+ const app = express();
33
+
34
+ // Create the notes router with your configuration
35
+ const notesRouter = createNotesRouter({
36
+ github: {
37
+ token: process.env.GITHUB_TOKEN,
38
+ owner: process.env.GITHUB_OWNER,
39
+ repo: process.env.GITHUB_REPO
40
+ },
41
+ storage: {
42
+ type: 'r2', // or 's3'
43
+ accountId: process.env.R2_ACCOUNT_ID,
44
+ accessKeyId: process.env.R2_ACCESS_KEY_ID,
45
+ secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
46
+ bucketName: process.env.R2_BUCKET_NAME,
47
+ publicUrl: process.env.R2_PUBLIC_URL
48
+ },
49
+ options: {
50
+ autoUpdateReadme: true // Auto-update README with note index
51
+ }
52
+ });
53
+
54
+ // Mount the router
55
+ app.use('/api', notesRouter);
56
+
57
+ app.listen(3000, () => {
58
+ console.log('Notes app running on http://localhost:3000');
59
+ });
60
+ ```
61
+
62
+ ### Frontend Setup (HTML + JavaScript)
63
+
64
+ ```html
65
+ <!DOCTYPE html>
66
+ <html>
67
+ <head>
68
+ <meta charset="UTF-8">
69
+ <title>My Notes App</title>
70
+ <!-- Include the styles -->
71
+ <link rel="stylesheet" href="node_modules/markdown-notes-engine/lib/frontend/styles.css">
72
+ </head>
73
+ <body>
74
+ <div id="notes-app"></div>
75
+
76
+ <!-- Include the frontend module -->
77
+ <script src="node_modules/markdown-notes-engine/lib/frontend/index.js"></script>
78
+ <script>
79
+ // Initialize the editor
80
+ const editor = new NotesEditor({
81
+ container: '#notes-app',
82
+ apiEndpoint: '/api',
83
+ theme: 'light', // or 'dark'
84
+ autoSave: true,
85
+ autoSaveDelay: 2000
86
+ });
87
+ </script>
88
+ </body>
89
+ </html>
90
+ ```
91
+
92
+ ## Configuration
93
+
94
+ ### Backend Configuration
95
+
96
+ #### GitHub Settings
97
+
98
+ ```javascript
99
+ github: {
100
+ token: 'ghp_xxxxxxxxxxxx', // GitHub personal access token
101
+ owner: 'your-username', // Repository owner
102
+ repo: 'your-notes-repo' // Repository name
103
+ }
104
+ ```
105
+
106
+ **Required GitHub Token Permissions:**
107
+ - `repo` (Full control of private repositories)
108
+
109
+ #### Storage Settings (Cloudflare R2)
110
+
111
+ ```javascript
112
+ storage: {
113
+ type: 'r2',
114
+ accountId: 'your-account-id',
115
+ accessKeyId: 'your-access-key',
116
+ secretAccessKey: 'your-secret-key',
117
+ bucketName: 'your-bucket-name',
118
+ publicUrl: 'https://your-bucket.r2.dev'
119
+ }
120
+ ```
121
+
122
+ #### Storage Settings (AWS S3)
123
+
124
+ ```javascript
125
+ storage: {
126
+ type: 's3',
127
+ region: 'us-east-1',
128
+ accessKeyId: 'your-access-key',
129
+ secretAccessKey: 'your-secret-key',
130
+ bucketName: 'your-bucket-name',
131
+ publicUrl: 'https://your-bucket.s3.amazonaws.com'
132
+ }
133
+ ```
134
+
135
+ #### Options
136
+
137
+ ```javascript
138
+ options: {
139
+ autoUpdateReadme: true // Automatically update README.md with note index
140
+ }
141
+ ```
142
+
143
+ ### Frontend Configuration
144
+
145
+ ```javascript
146
+ const editor = new NotesEditor({
147
+ container: '#notes-app', // CSS selector for container element
148
+ apiEndpoint: '/api', // API endpoint (where backend is mounted)
149
+ theme: 'light', // 'light' or 'dark'
150
+ autoSave: true, // Enable auto-save
151
+ autoSaveDelay: 2000, // Auto-save delay in milliseconds
152
+ onSave: (path, content) => {}, // Callback when note is saved
153
+ onLoad: (path, content) => {}, // Callback when note is loaded
154
+ onError: (message, error) => {} // Error callback
155
+ });
156
+ ```
157
+
158
+ ## API Endpoints
159
+
160
+ When you mount the notes router, it provides these endpoints:
161
+
162
+ ### Notes Management
163
+ - `GET /structure` - Get file tree structure
164
+ - `GET /note?path={path}` - Get note content
165
+ - `POST /note` - Save/create note
166
+ - `DELETE /note` - Delete note
167
+ - `POST /folder` - Create folder
168
+ - `DELETE /folder` - Delete folder
169
+
170
+ ### Media Upload
171
+ - `POST /upload-image` - Upload image (multipart)
172
+ - `POST /upload-image-base64` - Upload image (base64)
173
+ - `POST /upload-video` - Upload video
174
+ - `DELETE /image` - Delete image
175
+ - `DELETE /video` - Delete video
176
+
177
+ ### Utilities
178
+ - `POST /render` - Render markdown to HTML
179
+ - `GET /search?q={query}` - Search notes
180
+
181
+ ## Keyboard Shortcuts
182
+
183
+ - `Ctrl/Cmd + S` - Save note
184
+ - `Ctrl/Cmd + P` - Toggle preview mode
185
+ - `Ctrl/Cmd + N` - Create new note
186
+ - `Ctrl/Cmd + U` - Upload image
187
+ - `Ctrl/Cmd + Shift + U` - Upload video
188
+ - `Esc` - Close modals
189
+
190
+ ## Advanced Usage
191
+
192
+ ### Using Individual Components
193
+
194
+ You can use individual backend components if you need more control:
195
+
196
+ ```javascript
197
+ const { GitHubClient, StorageClient, MarkdownRenderer } = require('markdown-notes-engine');
198
+
199
+ // GitHub client
200
+ const github = new GitHubClient({
201
+ token: 'xxx',
202
+ owner: 'user',
203
+ repo: 'repo'
204
+ });
205
+
206
+ // Get file structure
207
+ const structure = await github.getFileStructure();
208
+
209
+ // Get file content
210
+ const file = await github.getFile('path/to/note.md');
211
+
212
+ // Save file
213
+ await github.saveFile('path/to/note.md', 'content', file.sha);
214
+
215
+ // Storage client
216
+ const storage = new StorageClient({
217
+ type: 'r2',
218
+ accountId: 'xxx',
219
+ accessKeyId: 'xxx',
220
+ secretAccessKey: 'xxx',
221
+ bucketName: 'bucket',
222
+ publicUrl: 'https://bucket.r2.dev'
223
+ });
224
+
225
+ // Upload image
226
+ const imageUrl = await storage.uploadImage(buffer, 'image.png', 'folder');
227
+
228
+ // Markdown renderer
229
+ const renderer = new MarkdownRenderer();
230
+ const html = renderer.render('# Hello World');
231
+ ```
232
+
233
+ ### Frontend Callbacks
234
+
235
+ Use callbacks to integrate with your application:
236
+
237
+ ```javascript
238
+ const editor = new NotesEditor({
239
+ container: '#notes-app',
240
+ apiEndpoint: '/api',
241
+ onSave: (path, content) => {
242
+ console.log(`Note saved: ${path}`);
243
+ // Send analytics, show toast notification, etc.
244
+ },
245
+ onLoad: (path, content) => {
246
+ console.log(`Note loaded: ${path}`);
247
+ document.title = path;
248
+ },
249
+ onError: (message, error) => {
250
+ console.error(message, error);
251
+ // Show error notification
252
+ }
253
+ });
254
+ ```
255
+
256
+ ## Environment Variables
257
+
258
+ Create a `.env` file in your project root:
259
+
260
+ ```env
261
+ # GitHub
262
+ GITHUB_TOKEN=ghp_xxxxxxxxxxxx
263
+ GITHUB_OWNER=your-username
264
+ GITHUB_REPO=your-notes-repo
265
+
266
+ # Cloudflare R2
267
+ R2_ACCOUNT_ID=your-account-id
268
+ R2_ACCESS_KEY_ID=your-access-key
269
+ R2_SECRET_ACCESS_KEY=your-secret-key
270
+ R2_BUCKET_NAME=your-bucket
271
+ R2_PUBLIC_URL=https://your-bucket.r2.dev
272
+ ```
273
+
274
+ ## Examples
275
+
276
+ See the `/examples` directory for complete working examples:
277
+
278
+ - **Express App** - Full Express.js integration
279
+ - **Next.js App** - Integration with Next.js
280
+ - **Static Site** - Vanilla HTML/JS usage
281
+
282
+ ## Styling
283
+
284
+ The package includes default styles, but you can customize them:
285
+
286
+ ```css
287
+ /* Override default styles */
288
+ .notes-container {
289
+ font-family: 'Your Custom Font';
290
+ }
291
+
292
+ .notes-sidebar {
293
+ background: #your-color;
294
+ }
295
+
296
+ /* Or create your own theme */
297
+ .notes-container.my-theme {
298
+ /* Your custom styles */
299
+ }
300
+ ```
301
+
302
+ ## License
303
+
304
+ MIT
305
+
306
+ ## Contributing
307
+
308
+ Contributions are welcome! Please open an issue or submit a pull request.
309
+
310
+ ## Support
311
+
312
+ For issues and questions, please open an issue on GitHub.