@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,337 @@
|
|
|
1
|
+
<details>
|
|
2
|
+
<summary>API</summary>
|
|
3
|
+
<p>
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
HTMLView
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Available in v3.6.2
|
|
10
|
+
* Open a modal sheet above the main window with the given html code
|
|
11
|
+
* @param { String }
|
|
12
|
+
* @param { Integer } (optional)
|
|
13
|
+
* @param { Integer } (optional)
|
|
14
|
+
*/
|
|
15
|
+
.showSheet(html, width, height)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Available in v3.7
|
|
19
|
+
* Open a non-modal window above the main window with the given html code and window title. It returns a promise with the created window object. Assign optionally the width and height.
|
|
20
|
+
* Run it with await window = showWindow(...), so you can adjust the window position and height later.
|
|
21
|
+
* @param { String }
|
|
22
|
+
* @param { String }
|
|
23
|
+
* @param { Integer } (optional)
|
|
24
|
+
* @param { Integer } (optional)
|
|
25
|
+
* @return { Promise(Window) }
|
|
26
|
+
*/
|
|
27
|
+
.showWindow(html, title, width, height)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Available in v3.9.1
|
|
31
|
+
* Open a non-modal window above the main window with the given html code and window title. It returns a promise with the created window object. Optionally, supply an object as the 3rd parameter to set window options:
|
|
32
|
+
* { width, height, x, y, customId, shouldFocus }
|
|
33
|
+
* By default, it will focus and bring to front the window on first launch
|
|
34
|
+
* If you are re-loading an existing HTML window's content, by default the window will not change z-order or focus (if it is in the back, it will stay in the back)
|
|
35
|
+
* you can override this by setting { shouldFocus: true } to bring to front on reload.
|
|
36
|
+
* If you are setting the customId in the options it will be assigned as the `customId` to the returning window.
|
|
37
|
+
* Assigning a customId will allow you to open multiple windows (one per customId). If you call `runJavaScript`, make sure to pass the same customID as the second variable.
|
|
38
|
+
* Run it with window = await showWindowWithOptions(...), so you can adjust the window position and height later.
|
|
39
|
+
* @param { String }
|
|
40
|
+
* @param { String }
|
|
41
|
+
* @param { Object({ x: Float, y: Float, width: Float, height: Float, customId: String, shouldFocus: Bool}) }
|
|
42
|
+
* @return { Promise(Window) }
|
|
43
|
+
*/
|
|
44
|
+
.showWindowWithOptions(html, title, options)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Available in v3.20
|
|
48
|
+
* Shows HTML content in the main application window, either in the main content area or as a split view (a sidebar entry will be added, so the user can open it also with opt+click as split view).
|
|
49
|
+
* @param { String } html - The HTML content to display
|
|
50
|
+
* @param { String } title - The title for the view
|
|
51
|
+
* @param { Object } options - (optional) Configuration options:
|
|
52
|
+
* - splitView: Boolean - Show as split view (true) or in main content area (false, default)
|
|
53
|
+
* - id/customId/customID: String - (optional) Unique identifier for reusing the same view
|
|
54
|
+
* - icon: String - Font Awesome icon string for the navigation bar and sidebar (without "fa-")
|
|
55
|
+
* - iconColor: String - Tailwind color name (e.g., "blue-500") or hex color (e.g., "#3b82f6")
|
|
56
|
+
* - autoTopPadding: Boolean - Auto-add top padding for navigation bar (default: true)
|
|
57
|
+
* - showReloadButton: Boolean - Show the reload button in the navigation bar (default: true)
|
|
58
|
+
* - reloadPluginID: String - (optional) Plugin ID to use for reload (overrides auto-captured value)
|
|
59
|
+
* - reloadCommandName: String - (optional) Command/function name to call on reload (overrides auto-captured value)
|
|
60
|
+
* - reloadCommandArgs: Array - (optional) Arguments to pass to the reload command
|
|
61
|
+
* @returns { Promise } Returns a promise that resolves with { success: true, windowID: String }
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Show HTML in main content area with icon
|
|
65
|
+
* await HTMLView.showInMainWindow(
|
|
66
|
+
* '<h1>Hello World</h1><p>This is displayed in the main view.</p>',
|
|
67
|
+
* 'My View',
|
|
68
|
+
* { icon: 'star', iconColor: 'blue-500' }
|
|
69
|
+
* )
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Show HTML as split view with custom icon and color
|
|
73
|
+
* await HTMLView.showInMainWindow(
|
|
74
|
+
* '<div>Split view content</div>',
|
|
75
|
+
* 'Split View',
|
|
76
|
+
* {
|
|
77
|
+
* splitView: true,
|
|
78
|
+
* icon: 'chart-line',
|
|
79
|
+
* iconColor: '#3b82f6'
|
|
80
|
+
* }
|
|
81
|
+
* )
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Reuse a view by ID
|
|
85
|
+
* await HTMLView.showInMainWindow(
|
|
86
|
+
* '<div>Updated content</div>',
|
|
87
|
+
* 'Updated View',
|
|
88
|
+
* { splitView: true }
|
|
89
|
+
* )
|
|
90
|
+
*/
|
|
91
|
+
.showInMainWindow(html, title, options)
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Available in v3.8
|
|
95
|
+
* After opening an html window, make changes to the contents of the window by running JS code directly inside the opened window. Make sure to pass the customId as the second argument if you have opened the window with a customId.
|
|
96
|
+
* Returns a promise you can wait for with the return value, if any (depends if you added one to the JS code that is supposed to be executed).
|
|
97
|
+
* @param { String }
|
|
98
|
+
* @param { String? }
|
|
99
|
+
* @return { Promise }
|
|
100
|
+
*/
|
|
101
|
+
.runJavaScript(code, customId)
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* To get the window, use NotePlan.htmlWindows or the return value of HTMLView.showWindow.
|
|
105
|
+
* Set / get the position and size of the window that contains the editor. Returns an object with x, y, width, height values.
|
|
106
|
+
* If you want to change the coordinates or size, save the rect in a variable, modify the variable, then assign it to windowRect.
|
|
107
|
+
* The position of the window might not be very intuitive, because the coordinate system of the screen works differently (starts at the bottom left for example). Recommended is to adjust the size and position of the window relatively to it's values or other windows.
|
|
108
|
+
*
|
|
109
|
+
* Note this is available with v3.9.1 and works only on Mac
|
|
110
|
+
* Example:
|
|
111
|
+
*
|
|
112
|
+
* const rect = Editor.windowRect
|
|
113
|
+
* rect.height -= 50
|
|
114
|
+
* Editor.windowRect = rect
|
|
115
|
+
*
|
|
116
|
+
* @type { x: Integer, y: Integer, width: Integer, height: Integer }
|
|
117
|
+
*/
|
|
118
|
+
.windowRect
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
</p>
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
<details>
|
|
126
|
+
<summary>API Access in HTML Views</summary>
|
|
127
|
+
<p>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
/**
|
|
133
|
+
* ============================================================================
|
|
134
|
+
* NOTEPLAN API ACCESS FROM INSIDE HTML VIEWS
|
|
135
|
+
* ============================================================================
|
|
136
|
+
*
|
|
137
|
+
* HTML views can access NotePlan's JavaScript APIs directly from within the
|
|
138
|
+
* WebView. This enables rich interactive experiences where your HTML can
|
|
139
|
+
* query calendar events, notes, and more.
|
|
140
|
+
*
|
|
141
|
+
* **IMPORTANT:** All API calls return Promises and must be awaited.
|
|
142
|
+
*
|
|
143
|
+
* ----------------------------------------------------------------------------
|
|
144
|
+
* CURRENTLY AVAILABLE APIs (from inside HTML views):
|
|
145
|
+
* ----------------------------------------------------------------------------
|
|
146
|
+
*
|
|
147
|
+
* ✅ Calendar API - Full access to calendar events and reminders
|
|
148
|
+
* - Calendar.eventsToday()
|
|
149
|
+
* - Calendar.eventsBetween(startDate, endDate)
|
|
150
|
+
* - Calendar.remindersToday()
|
|
151
|
+
* - Calendar.remindersBetween(startDate, endDate)
|
|
152
|
+
* - Calendar.availableCalendars()
|
|
153
|
+
* - Calendar.availableReminderLists()
|
|
154
|
+
* - Calendar.add(calendarItem)
|
|
155
|
+
* - etc.
|
|
156
|
+
*
|
|
157
|
+
* Returns: CalendarItemObject[] with properties:
|
|
158
|
+
* - title, date, endDate, type, isAllDay, isCompleted
|
|
159
|
+
* - calendar, calendarID, notes, url, availability
|
|
160
|
+
* - location, isRecurring, color, attendees, attendeeNames
|
|
161
|
+
*
|
|
162
|
+
* ----------------------------------------------------------------------------
|
|
163
|
+
* NOT YET ENABLED APIs (planned for future releases):
|
|
164
|
+
* ----------------------------------------------------------------------------
|
|
165
|
+
*
|
|
166
|
+
* ⏳ DataStore API - Access to notes
|
|
167
|
+
* - DataStore.projectNotes
|
|
168
|
+
* - DataStore.calendarNotes
|
|
169
|
+
* - DataStore.projectNoteByTitle(title)
|
|
170
|
+
* - DataStore.calendarNoteByDate(date)
|
|
171
|
+
*
|
|
172
|
+
* ⏳ Editor API - Access to current editor content
|
|
173
|
+
* - Editor.paragraphs
|
|
174
|
+
* - Editor.selectedParagraphs
|
|
175
|
+
* - Editor.paragraphsInRange(start, end)
|
|
176
|
+
*
|
|
177
|
+
* ⏳ Clipboard API - Clipboard access
|
|
178
|
+
*
|
|
179
|
+
* ⏳ CommandBar API - Command bar interactions
|
|
180
|
+
*
|
|
181
|
+
* ⏳ NotePlan API - General NotePlan functions
|
|
182
|
+
*
|
|
183
|
+
* ----------------------------------------------------------------------------
|
|
184
|
+
* USAGE EXAMPLE (from inside HTML):
|
|
185
|
+
* ----------------------------------------------------------------------------
|
|
186
|
+
*
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
<html>
|
|
190
|
+
<head>
|
|
191
|
+
<meta charset="utf-8">
|
|
192
|
+
<style>
|
|
193
|
+
body { font-family: -apple-system, sans-serif; padding: 20px; }
|
|
194
|
+
.event { padding: 8px; margin: 4px 0; background: #f0f0f0; border-radius: 4px; }
|
|
195
|
+
</style>
|
|
196
|
+
</head>
|
|
197
|
+
<body>
|
|
198
|
+
<h1>Today's Events</h1>
|
|
199
|
+
<div id="events">Loading...</div>
|
|
200
|
+
|
|
201
|
+
<script>
|
|
202
|
+
async function loadEvents() {
|
|
203
|
+
try {
|
|
204
|
+
// Simply call the Calendar API - it's already available!
|
|
205
|
+
const events = await Calendar.eventsToday();
|
|
206
|
+
|
|
207
|
+
const container = document.getElementById('events');
|
|
208
|
+
if (events.length === 0) {
|
|
209
|
+
container.innerHTML = '<p>No events today</p>';
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
container.innerHTML = events.map(event =>
|
|
214
|
+
'<div class="event">' +
|
|
215
|
+
'<strong>' + event.title + '</strong><br>' +
|
|
216
|
+
'<small>' + new Date(event.date).toLocaleTimeString() + '</small>' +
|
|
217
|
+
'</div>'
|
|
218
|
+
).join('');
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error('Error:', error);
|
|
221
|
+
document.getElementById('events').innerHTML = '<p>Error loading events</p>';
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Check if Calendar API is available, otherwise wait for it
|
|
226
|
+
if (typeof Calendar !== 'undefined') {
|
|
227
|
+
loadEvents();
|
|
228
|
+
} else {
|
|
229
|
+
window.addEventListener('notePlanBridgeReady', loadEvents);
|
|
230
|
+
}
|
|
231
|
+
</script>
|
|
232
|
+
</body>
|
|
233
|
+
</html>
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* ----------------------------------------------------------------------------
|
|
237
|
+
* COMMUNICATION BACK TO NOTEPLAN (Legacy jsBridge method):
|
|
238
|
+
* ----------------------------------------------------------------------------
|
|
239
|
+
*
|
|
240
|
+
* For running plugin code from inside HTML views, use the jsBridge:
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
const openNote = () => {
|
|
244
|
+
window.webkit.messageHandlers.jsBridge.postMessage({
|
|
245
|
+
code: ${openNote},
|
|
246
|
+
onHandle: "onHandleUpdateNoteCount",
|
|
247
|
+
id: "1"
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
function onHandleUpdateNoteCount(result, id) {
|
|
252
|
+
// result: The return value from the executed code (may be a string or JSON object)
|
|
253
|
+
// id: The identifier you passed in the postMessage call
|
|
254
|
+
document.getElementById("openNoteResultLabel").innerHTML = "Done! Result: " + (result || "no return value");
|
|
255
|
+
console.log("Result:", result);
|
|
256
|
+
console.log("Call ID:", id);
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
</p>
|
|
261
|
+
</details>
|
|
262
|
+
|
|
263
|
+
<details>
|
|
264
|
+
<summary>Examples</summary>
|
|
265
|
+
<p>
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
const openNote = JSON.stringify(`
|
|
270
|
+
(function() {
|
|
271
|
+
Editor.openNoteByFilename("10 - Projects/HTML View.md");
|
|
272
|
+
})()
|
|
273
|
+
`)
|
|
274
|
+
|
|
275
|
+
try {
|
|
276
|
+
|
|
277
|
+
HTMLView.showWindow(
|
|
278
|
+
`<html>
|
|
279
|
+
<head>
|
|
280
|
+
<meta charset="utf-8">
|
|
281
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
282
|
+
</head>
|
|
283
|
+
<body>
|
|
284
|
+
<p id="openNoteResultLabel">0</p>
|
|
285
|
+
<button onclick=openNote()>Open Note</button>
|
|
286
|
+
</body>
|
|
287
|
+
<script>
|
|
288
|
+
const openNote = () => {
|
|
289
|
+
window.webkit.messageHandlers.jsBridge.postMessage({
|
|
290
|
+
code: ${openNote},
|
|
291
|
+
onHandle: "onHandleuUpdateNoteCount",
|
|
292
|
+
id: "1"
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
function onHandleuUpdateNoteCount(re, id) {
|
|
297
|
+
document.getElementById("openNoteResultLabel").innerHTML = "done"
|
|
298
|
+
}
|
|
299
|
+
</script>
|
|
300
|
+
</html>`, "Test Plugin")
|
|
301
|
+
|
|
302
|
+
} catch(error) {
|
|
303
|
+
console.log(error)
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
</p>
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
<details>
|
|
311
|
+
<summary>External API Access (fetch)</summary>
|
|
312
|
+
<p>
|
|
313
|
+
|
|
314
|
+
HTML WebViews include a native `fetch()` backed by URLSession — **no CORS restrictions**.
|
|
315
|
+
Use the standard Fetch API to call external APIs directly:
|
|
316
|
+
|
|
317
|
+
```javascript
|
|
318
|
+
// fetch() works like the standard browser Fetch API
|
|
319
|
+
const response = await fetch('https://api.example.com/data');
|
|
320
|
+
const data = await response.json();
|
|
321
|
+
|
|
322
|
+
// Supports all standard options
|
|
323
|
+
const response = await fetch('https://api.example.com/post', {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
headers: { 'Content-Type': 'application/json' },
|
|
326
|
+
body: JSON.stringify({ key: 'value' })
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**Rules:**
|
|
331
|
+
- Only **HTTPS** URLs work (HTTP blocked by App Transport Security)
|
|
332
|
+
- Standard Response API: `response.ok`, `response.status`, `response.json()`, `response.text()`
|
|
333
|
+
- 30-second timeout per request
|
|
334
|
+
|
|
335
|
+
</p>
|
|
336
|
+
</details>
|
|
337
|
+
|