@noteplanco/noteplan-mcp 1.1.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/README.md +257 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/noteplan/embeddings.d.ts +170 -0
- package/dist/noteplan/embeddings.d.ts.map +1 -0
- package/dist/noteplan/embeddings.js +684 -0
- package/dist/noteplan/embeddings.js.map +1 -0
- package/dist/noteplan/file-reader.d.ts +77 -0
- package/dist/noteplan/file-reader.d.ts.map +1 -0
- package/dist/noteplan/file-reader.js +488 -0
- package/dist/noteplan/file-reader.js.map +1 -0
- package/dist/noteplan/file-writer.d.ts +108 -0
- package/dist/noteplan/file-writer.d.ts.map +1 -0
- package/dist/noteplan/file-writer.js +621 -0
- package/dist/noteplan/file-writer.js.map +1 -0
- package/dist/noteplan/filter-store.d.ts +28 -0
- package/dist/noteplan/filter-store.d.ts.map +1 -0
- package/dist/noteplan/filter-store.js +180 -0
- package/dist/noteplan/filter-store.js.map +1 -0
- package/dist/noteplan/frontmatter-parser.d.ts +45 -0
- package/dist/noteplan/frontmatter-parser.d.ts.map +1 -0
- package/dist/noteplan/frontmatter-parser.js +259 -0
- package/dist/noteplan/frontmatter-parser.js.map +1 -0
- package/dist/noteplan/fuzzy-search.d.ts +7 -0
- package/dist/noteplan/fuzzy-search.d.ts.map +1 -0
- package/dist/noteplan/fuzzy-search.js +66 -0
- package/dist/noteplan/fuzzy-search.js.map +1 -0
- package/dist/noteplan/markdown-parser.d.ts +87 -0
- package/dist/noteplan/markdown-parser.d.ts.map +1 -0
- package/dist/noteplan/markdown-parser.js +519 -0
- package/dist/noteplan/markdown-parser.js.map +1 -0
- package/dist/noteplan/preferences.d.ts +44 -0
- package/dist/noteplan/preferences.d.ts.map +1 -0
- package/dist/noteplan/preferences.js +156 -0
- package/dist/noteplan/preferences.js.map +1 -0
- package/dist/noteplan/ripgrep-search.d.ts +29 -0
- package/dist/noteplan/ripgrep-search.d.ts.map +1 -0
- package/dist/noteplan/ripgrep-search.js +110 -0
- package/dist/noteplan/ripgrep-search.js.map +1 -0
- package/dist/noteplan/sqlite-reader.d.ts +77 -0
- package/dist/noteplan/sqlite-reader.d.ts.map +1 -0
- package/dist/noteplan/sqlite-reader.js +605 -0
- package/dist/noteplan/sqlite-reader.js.map +1 -0
- package/dist/noteplan/sqlite-writer.d.ts +63 -0
- package/dist/noteplan/sqlite-writer.d.ts.map +1 -0
- package/dist/noteplan/sqlite-writer.js +574 -0
- package/dist/noteplan/sqlite-writer.js.map +1 -0
- package/dist/noteplan/types.d.ts +97 -0
- package/dist/noteplan/types.d.ts.map +1 -0
- package/dist/noteplan/types.js +33 -0
- package/dist/noteplan/types.js.map +1 -0
- package/dist/noteplan/unified-store.d.ts +289 -0
- package/dist/noteplan/unified-store.d.ts.map +1 -0
- package/dist/noteplan/unified-store.js +1308 -0
- package/dist/noteplan/unified-store.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2468 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/calendar.d.ts +311 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +504 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/embeddings.d.ts +244 -0
- package/dist/tools/embeddings.d.ts.map +1 -0
- package/dist/tools/embeddings.js +226 -0
- package/dist/tools/embeddings.js.map +1 -0
- package/dist/tools/events.d.ts +176 -0
- package/dist/tools/events.d.ts.map +1 -0
- package/dist/tools/events.js +326 -0
- package/dist/tools/events.js.map +1 -0
- package/dist/tools/filters.d.ts +205 -0
- package/dist/tools/filters.d.ts.map +1 -0
- package/dist/tools/filters.js +347 -0
- package/dist/tools/filters.js.map +1 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +161 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notes.d.ts +1221 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +1868 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/plugins.d.ts +140 -0
- package/dist/tools/plugins.d.ts.map +1 -0
- package/dist/tools/plugins.js +782 -0
- package/dist/tools/plugins.js.map +1 -0
- package/dist/tools/reminders.d.ts +207 -0
- package/dist/tools/reminders.d.ts.map +1 -0
- package/dist/tools/reminders.js +323 -0
- package/dist/tools/reminders.js.map +1 -0
- package/dist/tools/search.d.ts +58 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +373 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/spaces.d.ts +484 -0
- package/dist/tools/spaces.d.ts.map +1 -0
- package/dist/tools/spaces.js +870 -0
- package/dist/tools/spaces.js.map +1 -0
- package/dist/tools/tasks.d.ts +313 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +690 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/themes.d.ts +91 -0
- package/dist/tools/themes.d.ts.map +1 -0
- package/dist/tools/themes.js +294 -0
- package/dist/tools/themes.js.map +1 -0
- package/dist/tools/ui.d.ts +89 -0
- package/dist/tools/ui.d.ts.map +1 -0
- package/dist/tools/ui.js +137 -0
- package/dist/tools/ui.js.map +1 -0
- package/dist/utils/applescript.d.ts +5 -0
- package/dist/utils/applescript.d.ts.map +1 -0
- package/dist/utils/applescript.js +27 -0
- package/dist/utils/applescript.js.map +1 -0
- package/dist/utils/confirmation-tokens.d.ts +19 -0
- package/dist/utils/confirmation-tokens.d.ts.map +1 -0
- package/dist/utils/confirmation-tokens.js +58 -0
- package/dist/utils/confirmation-tokens.js.map +1 -0
- package/dist/utils/date-filters.d.ts +15 -0
- package/dist/utils/date-filters.d.ts.map +1 -0
- package/dist/utils/date-filters.js +129 -0
- package/dist/utils/date-filters.js.map +1 -0
- package/dist/utils/date-utils.d.ts +113 -0
- package/dist/utils/date-utils.d.ts.map +1 -0
- package/dist/utils/date-utils.js +341 -0
- package/dist/utils/date-utils.js.map +1 -0
- package/dist/utils/folder-matcher.d.ts +14 -0
- package/dist/utils/folder-matcher.d.ts.map +1 -0
- package/dist/utils/folder-matcher.js +191 -0
- package/dist/utils/folder-matcher.js.map +1 -0
- package/dist/utils/version.d.ts +10 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +88 -0
- package/dist/utils/version.js.map +1 -0
- package/docs/plugin-api/Calendar.md +448 -0
- package/docs/plugin-api/CalendarItem.md +198 -0
- package/docs/plugin-api/Clipboard.md +101 -0
- package/docs/plugin-api/CommandBar.md +251 -0
- package/docs/plugin-api/DataStore.md +700 -0
- package/docs/plugin-api/Editor.md +982 -0
- package/docs/plugin-api/HTMLView.md +337 -0
- package/docs/plugin-api/NoteObject.md +588 -0
- package/docs/plugin-api/NotePlan.md +398 -0
- package/docs/plugin-api/ParagraphObject.md +242 -0
- package/docs/plugin-api/RangeObject.md +56 -0
- package/docs/plugin-api/getting-started.md +545 -0
- package/docs/plugin-api/plugin-api-condensed.md +526 -0
- package/docs/plugin-api/plugin.json +26 -0
- package/docs/plugin-api/script.js +542 -0
- package/package.json +60 -0
- package/scripts/calendar-helper +0 -0
- package/scripts/reminders-helper +0 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
//
|
|
2
|
+
// script.js
|
|
3
|
+
// NotePlan Plugin Boilerplate
|
|
4
|
+
//
|
|
5
|
+
// This is a boilerplate template for creating NotePlan plugins.
|
|
6
|
+
// Copy this file and plugin.json to create a new plugin.
|
|
7
|
+
//
|
|
8
|
+
// 📖 GETTING STARTED:
|
|
9
|
+
// For complete setup instructions, installation guide, and usage with AI assistants,
|
|
10
|
+
// see getting-started.md in this directory.
|
|
11
|
+
//
|
|
12
|
+
// 📚 API DOCUMENTATION:
|
|
13
|
+
// All API documentation is available in .md files in this directory:
|
|
14
|
+
// - Calendar.md - Calendar and Reminder APIs
|
|
15
|
+
// - CalendarItem.md - CalendarItem object structure
|
|
16
|
+
// - Editor.md - Editor APIs for note manipulation
|
|
17
|
+
// - HTMLView.md - HTML view APIs for creating UI
|
|
18
|
+
// - NotePlan.md - Core NotePlan APIs
|
|
19
|
+
// - NoteObject.md - Note object structure
|
|
20
|
+
// - ParagraphObject.md - Paragraph object structure
|
|
21
|
+
// - And more...
|
|
22
|
+
//
|
|
23
|
+
// ⚠️ IMPORTANT NOTES:
|
|
24
|
+
//
|
|
25
|
+
// API AVAILABILITY:
|
|
26
|
+
// - Native plugin functions: Can use ALL APIs (Editor, Calendar, NotePlan, HTMLView, etc.)
|
|
27
|
+
// - HTML views:
|
|
28
|
+
// - Calendar API: ✅ Available directly
|
|
29
|
+
// - Editor/NotePlan/Other APIs: ⚠️ Available via JavaScript bridge
|
|
30
|
+
// Use window.webkit.messageHandlers.jsBridge.postMessage() to access
|
|
31
|
+
// See showHTMLWithEditorAPI() example for the pattern
|
|
32
|
+
//
|
|
33
|
+
// PLUGIN LOCATION:
|
|
34
|
+
// Plugins must be installed in: NotePlan Sync Folder/Plugins/your-plugin-name/
|
|
35
|
+
// Find the location via: NotePlan Settings → "Open plugin folder"
|
|
36
|
+
//
|
|
37
|
+
// TESTING:
|
|
38
|
+
// - Native functions: Edit script.js, then run command again in NotePlan
|
|
39
|
+
// - HTML views: Edit script.js, then click reload button in the view (if showReloadButton: true)
|
|
40
|
+
//
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Example Command Function
|
|
44
|
+
*
|
|
45
|
+
* This is a simple example command that demonstrates:
|
|
46
|
+
* - Basic plugin function structure
|
|
47
|
+
* - Accessing Editor API
|
|
48
|
+
* - Using console.log for debugging
|
|
49
|
+
*
|
|
50
|
+
* To use: Add this function name to plugin.json "jsFunction" field
|
|
51
|
+
*/
|
|
52
|
+
async function exampleCommand() {
|
|
53
|
+
try {
|
|
54
|
+
// Check if Editor is available
|
|
55
|
+
if (typeof Editor === "undefined") {
|
|
56
|
+
console.log("❌ Editor API not available")
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Get current note information
|
|
61
|
+
const filename = Editor.filename || Editor.resolvedFilename
|
|
62
|
+
const paragraphs = Editor.paragraphs || []
|
|
63
|
+
|
|
64
|
+
console.log(`Current note: ${filename}`)
|
|
65
|
+
console.log(`Paragraphs: ${paragraphs.length}`)
|
|
66
|
+
|
|
67
|
+
// Example: Get first paragraph
|
|
68
|
+
if (paragraphs.length > 0) {
|
|
69
|
+
const firstParagraph = paragraphs[0]
|
|
70
|
+
console.log(`First paragraph type: ${firstParagraph.type}`)
|
|
71
|
+
console.log(`First paragraph content: ${firstParagraph.content}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Your plugin logic here...
|
|
75
|
+
console.log("✅ Example command executed successfully")
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.log(`❌ Error: ${error.message}`)
|
|
78
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Example: HTML View Command (Persistent Main View)
|
|
84
|
+
*
|
|
85
|
+
* Creates a persistent HTML view in the main window.
|
|
86
|
+
*
|
|
87
|
+
* ⚠️ IMPORTANT: HTML views can ONLY access the Calendar API.
|
|
88
|
+
* Other APIs (Editor, NotePlan, etc.) are NOT available in HTML views.
|
|
89
|
+
*
|
|
90
|
+
* Testing: Use the reload button in the navigation bar to test changes.
|
|
91
|
+
*
|
|
92
|
+
* See HTMLView.md for API documentation and getting-started.md for setup guide.
|
|
93
|
+
*/
|
|
94
|
+
async function showExampleHTMLView() {
|
|
95
|
+
try {
|
|
96
|
+
const html = `
|
|
97
|
+
<html>
|
|
98
|
+
<head>
|
|
99
|
+
<meta charset="utf-8">
|
|
100
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
101
|
+
<style>
|
|
102
|
+
body {
|
|
103
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
|
|
104
|
+
padding: 20px;
|
|
105
|
+
background-color: #ffffff;
|
|
106
|
+
color: #000000;
|
|
107
|
+
}
|
|
108
|
+
@media (prefers-color-scheme: dark) {
|
|
109
|
+
body {
|
|
110
|
+
background-color: #1c1c1e;
|
|
111
|
+
color: #ffffff;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
h1 {
|
|
115
|
+
font-size: 24px;
|
|
116
|
+
margin-bottom: 16px;
|
|
117
|
+
}
|
|
118
|
+
button {
|
|
119
|
+
padding: 10px 20px;
|
|
120
|
+
margin: 5px;
|
|
121
|
+
font-size: 14px;
|
|
122
|
+
background: #007AFF;
|
|
123
|
+
color: white;
|
|
124
|
+
border: none;
|
|
125
|
+
border-radius: 6px;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
button:hover {
|
|
129
|
+
background: #0051D5;
|
|
130
|
+
}
|
|
131
|
+
#result {
|
|
132
|
+
margin-top: 20px;
|
|
133
|
+
padding: 15px;
|
|
134
|
+
background: #f5f5f5;
|
|
135
|
+
border-radius: 6px;
|
|
136
|
+
white-space: pre-wrap;
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
}
|
|
139
|
+
@media (prefers-color-scheme: dark) {
|
|
140
|
+
#result {
|
|
141
|
+
background: #2c2c2e;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
145
|
+
</head>
|
|
146
|
+
<body>
|
|
147
|
+
<h1>Example HTML View</h1>
|
|
148
|
+
<p>This is a persistent HTML view that appears in the sidebar.</p>
|
|
149
|
+
<p><strong>Note:</strong> Only Calendar API is available in HTML views.</p>
|
|
150
|
+
|
|
151
|
+
<button onclick="testCalendarAPI()">Test Calendar API</button>
|
|
152
|
+
<div id="result">Click the button to test Calendar API...</div>
|
|
153
|
+
|
|
154
|
+
<script>
|
|
155
|
+
// Wait for NotePlan bridge to be ready
|
|
156
|
+
function waitForBridge() {
|
|
157
|
+
return new Promise((resolve) => {
|
|
158
|
+
if (window.__notePlanBridgeReady && typeof Calendar !== 'undefined') {
|
|
159
|
+
resolve();
|
|
160
|
+
} else {
|
|
161
|
+
window.addEventListener('notePlanBridgeReady', () => resolve(), { once: true });
|
|
162
|
+
setTimeout(() => resolve(), 2000);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function testCalendarAPI() {
|
|
168
|
+
const result = document.getElementById('result');
|
|
169
|
+
result.textContent = 'Testing Calendar API...';
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
await waitForBridge();
|
|
173
|
+
|
|
174
|
+
if (typeof Calendar === 'undefined') {
|
|
175
|
+
result.textContent = '❌ Calendar API not available in HTML view';
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Test Calendar API (this is the ONLY API available in HTML views)
|
|
180
|
+
const calendars = await Calendar.availableCalendars({});
|
|
181
|
+
const eventsToday = await Calendar.eventsToday('');
|
|
182
|
+
|
|
183
|
+
result.textContent = \`✅ Calendar API is working!
|
|
184
|
+
|
|
185
|
+
Found \${calendars.length} calendars
|
|
186
|
+
Found \${eventsToday.length} events today
|
|
187
|
+
|
|
188
|
+
Note: Editor, NotePlan, and other APIs are NOT available in HTML views.
|
|
189
|
+
Only Calendar API can be used directly in HTML views.\`;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
result.textContent = \`❌ Error: \${error.message}\`;
|
|
192
|
+
console.error('Calendar API test error:', error);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Initialize on load
|
|
197
|
+
window.addEventListener('load', async () => {
|
|
198
|
+
await waitForBridge();
|
|
199
|
+
console.log('HTML view loaded and bridge ready');
|
|
200
|
+
console.log('Available APIs in HTML view:', typeof Calendar !== 'undefined' ? 'Calendar ✅' : 'None');
|
|
201
|
+
});
|
|
202
|
+
</script>
|
|
203
|
+
</body>
|
|
204
|
+
</html>
|
|
205
|
+
`
|
|
206
|
+
|
|
207
|
+
// Show in main window
|
|
208
|
+
// This makes it accessible without running the command again
|
|
209
|
+
// Use the reload button in the navigation bar to test changes quickly
|
|
210
|
+
await HTMLView.showInMainWindow(html, "Example View", {
|
|
211
|
+
icon: "star", // Font Awesome icon name (without "fa-")
|
|
212
|
+
iconColor: "blue-500", // Tailwind color or hex
|
|
213
|
+
customId: "example-view", // Allows reusing/updating the same view
|
|
214
|
+
showReloadButton: true, // Show reload button in navigation (useful for testing)
|
|
215
|
+
})
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.log(`❌ Error showing HTML view: ${error.message}`)
|
|
218
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Example: HTML View with JavaScript Bridge (Accessing Editor API)
|
|
224
|
+
*
|
|
225
|
+
* Demonstrates how to access NotePlan APIs (Editor, NotePlan, etc.) from HTML views
|
|
226
|
+
* using the JavaScript bridge. This is the workaround for accessing non-Calendar APIs.
|
|
227
|
+
*
|
|
228
|
+
* IMPORTANT: Only Calendar API is directly available in HTML views.
|
|
229
|
+
* To access Editor, NotePlan, or other APIs, you must use the JavaScript bridge:
|
|
230
|
+
* window.webkit.messageHandlers.jsBridge.postMessage()
|
|
231
|
+
*
|
|
232
|
+
* See getting-started.md for detailed explanation and more examples.
|
|
233
|
+
*/
|
|
234
|
+
async function showHTMLWithEditorAPI() {
|
|
235
|
+
try {
|
|
236
|
+
// Stringify the NotePlan API call that will be executed via bridge
|
|
237
|
+
const openNoteCode = JSON.stringify(`
|
|
238
|
+
(function() {
|
|
239
|
+
Editor.openNoteByFilename("10 - Projects/HTML View.md");
|
|
240
|
+
return "Note opened successfully";
|
|
241
|
+
})()
|
|
242
|
+
`)
|
|
243
|
+
|
|
244
|
+
const getFilenameCode = JSON.stringify(`
|
|
245
|
+
(function() {
|
|
246
|
+
return Editor.filename || Editor.resolvedFilename || "No note open";
|
|
247
|
+
})()
|
|
248
|
+
`)
|
|
249
|
+
|
|
250
|
+
const html = `
|
|
251
|
+
<html>
|
|
252
|
+
<head>
|
|
253
|
+
<meta charset="utf-8">
|
|
254
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
255
|
+
<style>
|
|
256
|
+
body {
|
|
257
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
|
|
258
|
+
padding: 20px;
|
|
259
|
+
background-color: #ffffff;
|
|
260
|
+
color: #000000;
|
|
261
|
+
}
|
|
262
|
+
@media (prefers-color-scheme: dark) {
|
|
263
|
+
body {
|
|
264
|
+
background-color: #1c1c1e;
|
|
265
|
+
color: #ffffff;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
h1 {
|
|
269
|
+
font-size: 24px;
|
|
270
|
+
margin-bottom: 16px;
|
|
271
|
+
}
|
|
272
|
+
button {
|
|
273
|
+
padding: 10px 20px;
|
|
274
|
+
margin: 5px;
|
|
275
|
+
font-size: 14px;
|
|
276
|
+
background: #007AFF;
|
|
277
|
+
color: white;
|
|
278
|
+
border: none;
|
|
279
|
+
border-radius: 6px;
|
|
280
|
+
cursor: pointer;
|
|
281
|
+
}
|
|
282
|
+
button:hover {
|
|
283
|
+
background: #0051D5;
|
|
284
|
+
}
|
|
285
|
+
#result {
|
|
286
|
+
margin-top: 20px;
|
|
287
|
+
padding: 15px;
|
|
288
|
+
background: #f5f5f5;
|
|
289
|
+
border-radius: 6px;
|
|
290
|
+
white-space: pre-wrap;
|
|
291
|
+
font-size: 12px;
|
|
292
|
+
}
|
|
293
|
+
@media (prefers-color-scheme: dark) {
|
|
294
|
+
#result {
|
|
295
|
+
background: #2c2c2e;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
</style>
|
|
299
|
+
</head>
|
|
300
|
+
<body>
|
|
301
|
+
<h1>HTML View with Editor API</h1>
|
|
302
|
+
<p>This example shows how to access Editor API from HTML using the JavaScript bridge.</p>
|
|
303
|
+
|
|
304
|
+
<button onclick="openNote()">Open Note via Bridge</button>
|
|
305
|
+
<button onclick="getFilename()">Get Current Filename</button>
|
|
306
|
+
|
|
307
|
+
<div id="result">Click a button to test the JavaScript bridge...</div>
|
|
308
|
+
|
|
309
|
+
<script>
|
|
310
|
+
// Function to open a note via JavaScript bridge
|
|
311
|
+
function openNote() {
|
|
312
|
+
const result = document.getElementById('result');
|
|
313
|
+
result.textContent = 'Calling Editor API via bridge...';
|
|
314
|
+
|
|
315
|
+
window.webkit.messageHandlers.jsBridge.postMessage({
|
|
316
|
+
code: ${openNoteCode},
|
|
317
|
+
onHandle: "onHandleOpenNote", // Callback function name
|
|
318
|
+
id: "1" // Optional: ID for tracking
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Function to get current filename via JavaScript bridge
|
|
323
|
+
function getFilename() {
|
|
324
|
+
const result = document.getElementById('result');
|
|
325
|
+
result.textContent = 'Getting filename via bridge...';
|
|
326
|
+
|
|
327
|
+
window.webkit.messageHandlers.jsBridge.postMessage({
|
|
328
|
+
code: ${getFilenameCode},
|
|
329
|
+
onHandle: "onHandleFilename",
|
|
330
|
+
id: "2"
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Callback function to handle the open note response
|
|
335
|
+
function onHandleOpenNote(result, id) {
|
|
336
|
+
const resultDiv = document.getElementById('result');
|
|
337
|
+
resultDiv.textContent = \`✅ Note opened successfully!
|
|
338
|
+
|
|
339
|
+
Result: \${result}
|
|
340
|
+
Call ID: \${id}
|
|
341
|
+
|
|
342
|
+
This demonstrates accessing Editor API from HTML view via JavaScript bridge.\`;
|
|
343
|
+
console.log('Open note result:', result, 'ID:', id);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Callback function to handle the filename response
|
|
347
|
+
function onHandleFilename(filename, id) {
|
|
348
|
+
const resultDiv = document.getElementById('result');
|
|
349
|
+
resultDiv.textContent = \`✅ Filename retrieved!
|
|
350
|
+
|
|
351
|
+
Current note: \${filename}
|
|
352
|
+
Call ID: \${id}
|
|
353
|
+
|
|
354
|
+
This demonstrates accessing Editor API from HTML view via JavaScript bridge.\`;
|
|
355
|
+
console.log('Filename result:', filename, 'ID:', id);
|
|
356
|
+
}
|
|
357
|
+
</script>
|
|
358
|
+
</body>
|
|
359
|
+
</html>
|
|
360
|
+
`
|
|
361
|
+
|
|
362
|
+
await HTMLView.showInMainWindow(html, "Editor API via Bridge", {
|
|
363
|
+
icon: "code",
|
|
364
|
+
iconColor: "green-500",
|
|
365
|
+
customId: "editor-api-bridge-example",
|
|
366
|
+
showReloadButton: true,
|
|
367
|
+
})
|
|
368
|
+
} catch (error) {
|
|
369
|
+
console.log(`❌ Error showing HTML view with Editor API: ${error.message}`)
|
|
370
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Example: Calendar API Usage
|
|
376
|
+
*
|
|
377
|
+
* Demonstrates how to use Calendar API
|
|
378
|
+
*
|
|
379
|
+
* NOTE: Calendar API is available BOTH in:
|
|
380
|
+
* - Native plugin functions (this file) ✅
|
|
381
|
+
* - HTML views (directly, no bridge needed) ✅
|
|
382
|
+
*
|
|
383
|
+
* See Calendar.md and CalendarItem.md for full API documentation
|
|
384
|
+
*/
|
|
385
|
+
async function exampleCalendarUsage() {
|
|
386
|
+
try {
|
|
387
|
+
// Check if Calendar API is available
|
|
388
|
+
if (typeof Calendar === "undefined") {
|
|
389
|
+
console.log("❌ Calendar API not available")
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Get available calendars
|
|
394
|
+
const calendars = Calendar.availableCalendars()
|
|
395
|
+
console.log(`Found ${calendars.length} calendars`)
|
|
396
|
+
|
|
397
|
+
// Get events for today
|
|
398
|
+
const eventsToday = await Calendar.eventsToday("")
|
|
399
|
+
console.log(`Found ${eventsToday.length} events today`)
|
|
400
|
+
|
|
401
|
+
// Example: Get events between dates
|
|
402
|
+
const startDate = new Date()
|
|
403
|
+
const endDate = new Date()
|
|
404
|
+
endDate.setDate(endDate.getDate() + 7) // Next 7 days
|
|
405
|
+
|
|
406
|
+
const events = await Calendar.eventsBetween(startDate, endDate, "")
|
|
407
|
+
console.log(`Found ${events.length} events in next 7 days`)
|
|
408
|
+
|
|
409
|
+
// Your calendar logic here...
|
|
410
|
+
} catch (error) {
|
|
411
|
+
console.log(`❌ Error: ${error.message}`)
|
|
412
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Example: Editor API Usage
|
|
418
|
+
*
|
|
419
|
+
* Demonstrates how to manipulate notes using Editor API
|
|
420
|
+
*
|
|
421
|
+
* NOTE: Editor API is ONLY available in:
|
|
422
|
+
* - Native plugin functions (this file) ✅
|
|
423
|
+
* - HTML views ❌ NOT available
|
|
424
|
+
*
|
|
425
|
+
* See Editor.md for full API documentation
|
|
426
|
+
*/
|
|
427
|
+
async function exampleEditorUsage() {
|
|
428
|
+
try {
|
|
429
|
+
if (typeof Editor === "undefined") {
|
|
430
|
+
console.log("❌ Editor API not available")
|
|
431
|
+
return
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Get current note information
|
|
435
|
+
const filename = Editor.filename || Editor.resolvedFilename
|
|
436
|
+
const paragraphs = Editor.paragraphs || []
|
|
437
|
+
|
|
438
|
+
console.log(`Current note: ${filename}`)
|
|
439
|
+
console.log(`Total paragraphs: ${paragraphs.length}`)
|
|
440
|
+
|
|
441
|
+
// Example: Find headings
|
|
442
|
+
const headings = paragraphs.filter(
|
|
443
|
+
(p) => (p.headingLevel && p.headingLevel > 0) || p.type === "title"
|
|
444
|
+
)
|
|
445
|
+
console.log(`Found ${headings.length} headings`)
|
|
446
|
+
|
|
447
|
+
// Example: Insert text at cursor
|
|
448
|
+
// Editor.insertTextAtCursor("Hello from plugin!\n")
|
|
449
|
+
|
|
450
|
+
// Example: Replace selected text
|
|
451
|
+
// Editor.replaceSelection("Replaced text")
|
|
452
|
+
|
|
453
|
+
// Your editor logic here...
|
|
454
|
+
} catch (error) {
|
|
455
|
+
console.log(`❌ Error: ${error.message}`)
|
|
456
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Example: NotePlan API Usage
|
|
462
|
+
*
|
|
463
|
+
* Demonstrates how to use core NotePlan APIs
|
|
464
|
+
*
|
|
465
|
+
* NOTE: NotePlan API is ONLY available in:
|
|
466
|
+
* - Native plugin functions (this file) ✅
|
|
467
|
+
* - HTML views ❌ NOT available
|
|
468
|
+
*
|
|
469
|
+
* See NotePlan.md for full API documentation
|
|
470
|
+
*/
|
|
471
|
+
async function exampleNotePlanUsage() {
|
|
472
|
+
try {
|
|
473
|
+
if (typeof NotePlan === "undefined") {
|
|
474
|
+
console.log("❌ NotePlan API not available")
|
|
475
|
+
return
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Get environment information
|
|
479
|
+
const env = NotePlan.environment
|
|
480
|
+
console.log(`Platform: ${env.platform}`)
|
|
481
|
+
console.log(`Version: ${env.version}`)
|
|
482
|
+
console.log(`Language: ${env.languageCode}`)
|
|
483
|
+
|
|
484
|
+
// Example: Get all notes
|
|
485
|
+
// const notes = NotePlan.allNotes
|
|
486
|
+
// console.log(`Total notes: ${notes.length}`)
|
|
487
|
+
|
|
488
|
+
// Example: Get calendar notes
|
|
489
|
+
// const calendarNotes = NotePlan.calendarNotes
|
|
490
|
+
// console.log(`Calendar notes: ${calendarNotes.length}`)
|
|
491
|
+
|
|
492
|
+
// Your NotePlan logic here...
|
|
493
|
+
} catch (error) {
|
|
494
|
+
console.log(`❌ Error: ${error.message}`)
|
|
495
|
+
console.log(`Stack: ${error.stack || "N/A"}`)
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Helper: Wait for API to be available
|
|
501
|
+
*
|
|
502
|
+
* Useful when working with HTML views that need to wait for bridge initialization
|
|
503
|
+
*/
|
|
504
|
+
function waitForAPI(apiName, timeout = 5000) {
|
|
505
|
+
return new Promise((resolve, reject) => {
|
|
506
|
+
if (typeof window !== "undefined" && window[apiName]) {
|
|
507
|
+
resolve()
|
|
508
|
+
return
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const startTime = Date.now()
|
|
512
|
+
const checkInterval = setInterval(() => {
|
|
513
|
+
if (typeof window !== "undefined" && window[apiName]) {
|
|
514
|
+
clearInterval(checkInterval)
|
|
515
|
+
resolve()
|
|
516
|
+
} else if (Date.now() - startTime > timeout) {
|
|
517
|
+
clearInterval(checkInterval)
|
|
518
|
+
reject(new Error(`Timeout waiting for ${apiName}`))
|
|
519
|
+
}
|
|
520
|
+
}, 100)
|
|
521
|
+
})
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Helper: Log formatted message
|
|
526
|
+
*
|
|
527
|
+
* Utility function for consistent logging
|
|
528
|
+
*/
|
|
529
|
+
function log(message, type = "info") {
|
|
530
|
+
const prefix =
|
|
531
|
+
{
|
|
532
|
+
info: "ℹ️",
|
|
533
|
+
success: "✅",
|
|
534
|
+
error: "❌",
|
|
535
|
+
warning: "⚠️",
|
|
536
|
+
}[type] || ""
|
|
537
|
+
|
|
538
|
+
console.log(`${prefix} ${message}`)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Export functions if needed (for module systems, though NotePlan uses global scope)
|
|
542
|
+
// In NotePlan plugins, functions are typically global, so exports are optional
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noteplanco/noteplan-mcp",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "MCP server for NotePlan note and task management",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"noteplan-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"docs/",
|
|
13
|
+
"scripts/calendar-helper",
|
|
14
|
+
"scripts/reminders-helper",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run build:swift && tsc",
|
|
25
|
+
"build:swift": "swiftc -target arm64-apple-macosx14.0 -o scripts/calendar-helper-arm64 scripts/calendar-helper.swift && swiftc -target x86_64-apple-macosx14.0 -o scripts/calendar-helper-x86_64 scripts/calendar-helper.swift && lipo -create scripts/calendar-helper-arm64 scripts/calendar-helper-x86_64 -output scripts/calendar-helper && rm scripts/calendar-helper-arm64 scripts/calendar-helper-x86_64 && swiftc -target arm64-apple-macosx14.0 -o scripts/reminders-helper-arm64 scripts/reminders-helper.swift && swiftc -target x86_64-apple-macosx14.0 -o scripts/reminders-helper-x86_64 scripts/reminders-helper.swift && lipo -create scripts/reminders-helper-arm64 scripts/reminders-helper-x86_64 -output scripts/reminders-helper && rm scripts/reminders-helper-arm64 scripts/reminders-helper-x86_64",
|
|
26
|
+
"build:ts": "tsc",
|
|
27
|
+
"smoke:workflow": "node scripts/workflow-smoke.mjs",
|
|
28
|
+
"start": "node dist/index.js",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"mcp",
|
|
34
|
+
"noteplan",
|
|
35
|
+
"model-context-protocol",
|
|
36
|
+
"notes",
|
|
37
|
+
"tasks",
|
|
38
|
+
"calendar",
|
|
39
|
+
"reminders",
|
|
40
|
+
"ai"
|
|
41
|
+
],
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/NotePlan/noteplan-mcp.git"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
49
|
+
"better-sqlite3": "^11.0.0",
|
|
50
|
+
"fuse.js": "^7.1.0",
|
|
51
|
+
"uuid": "^9.0.0",
|
|
52
|
+
"zod": "^3.22.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
56
|
+
"@types/node": "^20.0.0",
|
|
57
|
+
"@types/uuid": "^9.0.0",
|
|
58
|
+
"typescript": "^5.0.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
Binary file
|
|
Binary file
|