@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.
Files changed (155) hide show
  1. package/README.md +257 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +8 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/noteplan/embeddings.d.ts +170 -0
  7. package/dist/noteplan/embeddings.d.ts.map +1 -0
  8. package/dist/noteplan/embeddings.js +684 -0
  9. package/dist/noteplan/embeddings.js.map +1 -0
  10. package/dist/noteplan/file-reader.d.ts +77 -0
  11. package/dist/noteplan/file-reader.d.ts.map +1 -0
  12. package/dist/noteplan/file-reader.js +488 -0
  13. package/dist/noteplan/file-reader.js.map +1 -0
  14. package/dist/noteplan/file-writer.d.ts +108 -0
  15. package/dist/noteplan/file-writer.d.ts.map +1 -0
  16. package/dist/noteplan/file-writer.js +621 -0
  17. package/dist/noteplan/file-writer.js.map +1 -0
  18. package/dist/noteplan/filter-store.d.ts +28 -0
  19. package/dist/noteplan/filter-store.d.ts.map +1 -0
  20. package/dist/noteplan/filter-store.js +180 -0
  21. package/dist/noteplan/filter-store.js.map +1 -0
  22. package/dist/noteplan/frontmatter-parser.d.ts +45 -0
  23. package/dist/noteplan/frontmatter-parser.d.ts.map +1 -0
  24. package/dist/noteplan/frontmatter-parser.js +259 -0
  25. package/dist/noteplan/frontmatter-parser.js.map +1 -0
  26. package/dist/noteplan/fuzzy-search.d.ts +7 -0
  27. package/dist/noteplan/fuzzy-search.d.ts.map +1 -0
  28. package/dist/noteplan/fuzzy-search.js +66 -0
  29. package/dist/noteplan/fuzzy-search.js.map +1 -0
  30. package/dist/noteplan/markdown-parser.d.ts +87 -0
  31. package/dist/noteplan/markdown-parser.d.ts.map +1 -0
  32. package/dist/noteplan/markdown-parser.js +519 -0
  33. package/dist/noteplan/markdown-parser.js.map +1 -0
  34. package/dist/noteplan/preferences.d.ts +44 -0
  35. package/dist/noteplan/preferences.d.ts.map +1 -0
  36. package/dist/noteplan/preferences.js +156 -0
  37. package/dist/noteplan/preferences.js.map +1 -0
  38. package/dist/noteplan/ripgrep-search.d.ts +29 -0
  39. package/dist/noteplan/ripgrep-search.d.ts.map +1 -0
  40. package/dist/noteplan/ripgrep-search.js +110 -0
  41. package/dist/noteplan/ripgrep-search.js.map +1 -0
  42. package/dist/noteplan/sqlite-reader.d.ts +77 -0
  43. package/dist/noteplan/sqlite-reader.d.ts.map +1 -0
  44. package/dist/noteplan/sqlite-reader.js +605 -0
  45. package/dist/noteplan/sqlite-reader.js.map +1 -0
  46. package/dist/noteplan/sqlite-writer.d.ts +63 -0
  47. package/dist/noteplan/sqlite-writer.d.ts.map +1 -0
  48. package/dist/noteplan/sqlite-writer.js +574 -0
  49. package/dist/noteplan/sqlite-writer.js.map +1 -0
  50. package/dist/noteplan/types.d.ts +97 -0
  51. package/dist/noteplan/types.d.ts.map +1 -0
  52. package/dist/noteplan/types.js +33 -0
  53. package/dist/noteplan/types.js.map +1 -0
  54. package/dist/noteplan/unified-store.d.ts +289 -0
  55. package/dist/noteplan/unified-store.d.ts.map +1 -0
  56. package/dist/noteplan/unified-store.js +1308 -0
  57. package/dist/noteplan/unified-store.js.map +1 -0
  58. package/dist/server.d.ts +4 -0
  59. package/dist/server.d.ts.map +1 -0
  60. package/dist/server.js +2468 -0
  61. package/dist/server.js.map +1 -0
  62. package/dist/tools/calendar.d.ts +311 -0
  63. package/dist/tools/calendar.d.ts.map +1 -0
  64. package/dist/tools/calendar.js +504 -0
  65. package/dist/tools/calendar.js.map +1 -0
  66. package/dist/tools/embeddings.d.ts +244 -0
  67. package/dist/tools/embeddings.d.ts.map +1 -0
  68. package/dist/tools/embeddings.js +226 -0
  69. package/dist/tools/embeddings.js.map +1 -0
  70. package/dist/tools/events.d.ts +176 -0
  71. package/dist/tools/events.d.ts.map +1 -0
  72. package/dist/tools/events.js +326 -0
  73. package/dist/tools/events.js.map +1 -0
  74. package/dist/tools/filters.d.ts +205 -0
  75. package/dist/tools/filters.d.ts.map +1 -0
  76. package/dist/tools/filters.js +347 -0
  77. package/dist/tools/filters.js.map +1 -0
  78. package/dist/tools/memory.d.ts +6 -0
  79. package/dist/tools/memory.d.ts.map +1 -0
  80. package/dist/tools/memory.js +161 -0
  81. package/dist/tools/memory.js.map +1 -0
  82. package/dist/tools/notes.d.ts +1221 -0
  83. package/dist/tools/notes.d.ts.map +1 -0
  84. package/dist/tools/notes.js +1868 -0
  85. package/dist/tools/notes.js.map +1 -0
  86. package/dist/tools/plugins.d.ts +140 -0
  87. package/dist/tools/plugins.d.ts.map +1 -0
  88. package/dist/tools/plugins.js +782 -0
  89. package/dist/tools/plugins.js.map +1 -0
  90. package/dist/tools/reminders.d.ts +207 -0
  91. package/dist/tools/reminders.d.ts.map +1 -0
  92. package/dist/tools/reminders.js +323 -0
  93. package/dist/tools/reminders.js.map +1 -0
  94. package/dist/tools/search.d.ts +58 -0
  95. package/dist/tools/search.d.ts.map +1 -0
  96. package/dist/tools/search.js +373 -0
  97. package/dist/tools/search.js.map +1 -0
  98. package/dist/tools/spaces.d.ts +484 -0
  99. package/dist/tools/spaces.d.ts.map +1 -0
  100. package/dist/tools/spaces.js +870 -0
  101. package/dist/tools/spaces.js.map +1 -0
  102. package/dist/tools/tasks.d.ts +313 -0
  103. package/dist/tools/tasks.d.ts.map +1 -0
  104. package/dist/tools/tasks.js +690 -0
  105. package/dist/tools/tasks.js.map +1 -0
  106. package/dist/tools/themes.d.ts +91 -0
  107. package/dist/tools/themes.d.ts.map +1 -0
  108. package/dist/tools/themes.js +294 -0
  109. package/dist/tools/themes.js.map +1 -0
  110. package/dist/tools/ui.d.ts +89 -0
  111. package/dist/tools/ui.d.ts.map +1 -0
  112. package/dist/tools/ui.js +137 -0
  113. package/dist/tools/ui.js.map +1 -0
  114. package/dist/utils/applescript.d.ts +5 -0
  115. package/dist/utils/applescript.d.ts.map +1 -0
  116. package/dist/utils/applescript.js +27 -0
  117. package/dist/utils/applescript.js.map +1 -0
  118. package/dist/utils/confirmation-tokens.d.ts +19 -0
  119. package/dist/utils/confirmation-tokens.d.ts.map +1 -0
  120. package/dist/utils/confirmation-tokens.js +58 -0
  121. package/dist/utils/confirmation-tokens.js.map +1 -0
  122. package/dist/utils/date-filters.d.ts +15 -0
  123. package/dist/utils/date-filters.d.ts.map +1 -0
  124. package/dist/utils/date-filters.js +129 -0
  125. package/dist/utils/date-filters.js.map +1 -0
  126. package/dist/utils/date-utils.d.ts +113 -0
  127. package/dist/utils/date-utils.d.ts.map +1 -0
  128. package/dist/utils/date-utils.js +341 -0
  129. package/dist/utils/date-utils.js.map +1 -0
  130. package/dist/utils/folder-matcher.d.ts +14 -0
  131. package/dist/utils/folder-matcher.d.ts.map +1 -0
  132. package/dist/utils/folder-matcher.js +191 -0
  133. package/dist/utils/folder-matcher.js.map +1 -0
  134. package/dist/utils/version.d.ts +10 -0
  135. package/dist/utils/version.d.ts.map +1 -0
  136. package/dist/utils/version.js +88 -0
  137. package/dist/utils/version.js.map +1 -0
  138. package/docs/plugin-api/Calendar.md +448 -0
  139. package/docs/plugin-api/CalendarItem.md +198 -0
  140. package/docs/plugin-api/Clipboard.md +101 -0
  141. package/docs/plugin-api/CommandBar.md +251 -0
  142. package/docs/plugin-api/DataStore.md +700 -0
  143. package/docs/plugin-api/Editor.md +982 -0
  144. package/docs/plugin-api/HTMLView.md +337 -0
  145. package/docs/plugin-api/NoteObject.md +588 -0
  146. package/docs/plugin-api/NotePlan.md +398 -0
  147. package/docs/plugin-api/ParagraphObject.md +242 -0
  148. package/docs/plugin-api/RangeObject.md +56 -0
  149. package/docs/plugin-api/getting-started.md +545 -0
  150. package/docs/plugin-api/plugin-api-condensed.md +526 -0
  151. package/docs/plugin-api/plugin.json +26 -0
  152. package/docs/plugin-api/script.js +542 -0
  153. package/package.json +60 -0
  154. package/scripts/calendar-helper +0 -0
  155. package/scripts/reminders-helper +0 -0
@@ -0,0 +1,398 @@
1
+ Global functions and variables for NotePlan
2
+
3
+ <details>
4
+ <summary>API</summary>
5
+ <p>
6
+
7
+ ```javascript
8
+ /**
9
+ * Note: Available from v3.3.2
10
+ * Returns the environment information:
11
+ * .languageCode {String?}
12
+ * .regionCode {String?}
13
+ * .is12hFormat {Bool}
14
+ * .preferredLanguages {[String]}
15
+ * .secondsFromGMT {Int}
16
+ * .localTimeZoneAbbreviation {String}
17
+ * .localTimeZoneIdentifier: {String}
18
+ * .isDaylightSavingTime {Bool}
19
+ * .daylightSavingTimeOffset: {Double}
20
+ * .nextDaylightSavingTimeTransition: {Date}
21
+ * .platform: {String = "macOS" | "iPadOS" | "iOS"}
22
+ * .hasSettings: {Bool}
23
+ * .version: {String}, NotePlans version, for example "3.4.1"
24
+ * .versionNumber: {Integer}, NotePlans version,for example 341
25
+ * .buildVersion: {Integer}, NotePlans build number,for example 730
26
+ * .templateFolder: {String}, relative path to the template folder = "@Templates"
27
+ * .machineName: {String}, name of the device, like 'macbook-pro.local', available in v3.9.7
28
+ * .screenWidth: {number}, available in v3.9.7
29
+ * .screenHeight: {number}, available in v3.9.7
30
+ .osVersion: {String}, available in v3.18.1
31
+ */
32
+ .environment
33
+
34
+ /**
35
+ * Note: Available from v3.15.1
36
+ * This is an async function, use it with "await". Sends a prompt to OpenAI and returns the result.
37
+ * Optionally send the content of notes as well to process by specifying them in the list 'filenames', which is an array. For example ["note1.md", "folder/note2.md"]. This needs to be the exact path to the note. Your note extension might differ, the default is .txt, if you haven't changed it.
38
+ * For calendar notes, you can use YYYYMMDD.md, like 20241101.md, or 2024-W10.md for weeks, etc. Natural language input is also supported like "this week", "today", "tomorrow", "this month", "next year", etc.
39
+ * Available from v3.16.3:
40
+ * Use a relative expression as filename to get the "last 7 days" for example. It will search for the daily notes of the last 7 days in this case. This string needs to have exactly this form: 1. use "next" or "last", 2. define a number, like "7", 3. define one of the timeframes: "days", "weeks", "months", "quarters", "years".
41
+ * Filenames also support folders, they need to be prefixed with a slash "/", like "/Projects/Work".
42
+ * Define an OpenAI model using the "model" variable. Works only if you set your own key. Then you can set it to "o1" for example and use one of the most advanced models.
43
+ * @param { String }
44
+ * @param { String[] }
45
+ * @param { Boolean }
46
+ * @param { String }
47
+ * @return {Promise<String>}
48
+ */
49
+ .ai(prompt, filenames, useStrictFilenames, model)
50
+
51
+ /**
52
+ * Note: Available from v3.5
53
+ * If a folder is selected in the sidebar on Mac, it returns the folder name as string, if something else is selected it returns nil.
54
+ * @return {String?}
55
+ */
56
+ .selectedSidebarFolder
57
+
58
+ /**
59
+ * Note: Available from v3.3.2
60
+ * Opens the configuration view for the currently executing plugin. If no settings are available in the plugin.json, the promise will fail.
61
+ * As of 3.3.2 this is only available on macOS. You can check if this particular plugin has settings and if the platform is macOS using the environment variable.
62
+ * See the examples section for more.
63
+ * @return {Promise}
64
+ */
65
+ .showConfigurationView()
66
+
67
+ /**
68
+ * Note: Available from v3.5
69
+ * Reloads the cached files and rebuilds the sidebar. Use it in case there are inconsistencies in the sidebar.
70
+ */
71
+ .resetCaches()
72
+
73
+ /**
74
+ * Note: Available from v3.5.2
75
+ * Opens the given URL using the default browser (x-callback-urls can also be triggered with this).
76
+ */
77
+ .openURL(url)
78
+
79
+
80
+ /**
81
+ * Note: Available from v3.7.2
82
+ * Returns the ranges that have changed between the two versions.
83
+ * @param { String }
84
+ * @param { String }
85
+ * @return {[RangeObject]}
86
+ */
87
+ .stringDiff(version1, version2)
88
+
89
+
90
+ /**
91
+ * Note: Available from v3.8.1
92
+ * Returns a list of all opened editors (in the main view, in split views and in floating windows). See more details in the "Editor" documentation.
93
+ * @return { [Editor] }
94
+ */
95
+ .editors
96
+
97
+
98
+ /**
99
+ * Returns a list of all opened HTML windows, including both standalone windows and embedded views
100
+ * (main content area and split views).
101
+ *
102
+ * An HTML window has the same window functions like an editor: focus(), close(), id { get }, customId { get set }
103
+ *
104
+ * Properties:
105
+ * - id {String}: Unique identifier for the window (UUID for embedded views, window UUID for standalone)
106
+ * - customId {String}: The developer-assigned window ID (set via options when opening the view).
107
+ * Use this for finding windows by ID in helper functions like isHTMLWindowOpen().
108
+ * - type {String}: Always returns "html"
109
+ * - displayType {String}: The display type of the window. Returns one of:
110
+ * - "window": Standalone window
111
+ * - "sheet": Modal sheet presentation
112
+ * - "mainView": Embedded in main content area
113
+ * - "splitView": Embedded in split view
114
+ * - windowRect {Object}: Window frame coordinates (only for standalone windows; returns {} for embedded views)
115
+ *
116
+ * Methods:
117
+ * - focus(): Brings the window to front and focuses it. For embedded views, this will open/show
118
+ * the view if it's not currently visible (same behavior as clicking the sidebar item).
119
+ * - close(): Closes the window. For embedded views, this removes them from the sidebar and cleans up.
120
+ * - runJavaScript(code: String): Executes JavaScript code in the window's WebView. Returns a Promise.
121
+ *
122
+ * @return {Array<HTMLWindowObject>} Array of HTML window objects
123
+ *
124
+ * @example
125
+ * // Find a window by customId and interact with it
126
+ * const myWindow = NotePlan.htmlWindows.find(w => w.customId === "my-plugin-window");
127
+ * if (myWindow) {
128
+ * console.log(`Found window: ${myWindow.customId}, displayType: ${myWindow.displayType}`);
129
+ * myWindow.focus(); // Opens/focuses the window
130
+ * myWindow.runJavaScript("console.log('Hello from plugin!');"); // Execute JavaScript
131
+ * }
132
+ *
133
+ * @example
134
+ * // Check if a window is open and close it
135
+ * const targetWindow = NotePlan.htmlWindows.find(w => w.customId === "my-window-id");
136
+ * if (targetWindow) {
137
+ * targetWindow.close(); // Closes standalone windows or removes embedded views from sidebar
138
+ * }
139
+ */
140
+ .htmlWindows
141
+
142
+ /**
143
+ * Note: Available from v3.19.2
144
+ * Toggles the sidebar visibility on iOS and macOS.
145
+ *
146
+ * @param {boolean} forceCollapse - If true, forces the sidebar to hide/collapse.
147
+ * @param {boolean} forceOpen - If true, forces the sidebar to show/expand.
148
+ * @param {boolean} animated - If true (default), animates the sidebar toggle. If false, instantly shows/hides without animation (macOS only).
149
+ *
150
+ * Note: If both forceCollapse and forceOpen are true, forceOpen takes precedence on macOS.
151
+ *
152
+ * @example
153
+ * // Toggle the sidebar (show if hidden, hide if shown)
154
+ * NotePlan.toggleSidebar(false, false, true);
155
+ *
156
+ * @example
157
+ * // Force show/open the sidebar with animation
158
+ * NotePlan.toggleSidebar(false, true, true);
159
+ *
160
+ * @example
161
+ * // Force hide/collapse the sidebar with animation
162
+ * NotePlan.toggleSidebar(true, false, true);
163
+ *
164
+ * @example
165
+ * // Force hide the sidebar without animation (macOS only)
166
+ * NotePlan.toggleSidebar(true, false, false);
167
+ */
168
+ .toggleSidebar(forceCollapse, forceOpen, animated)
169
+
170
+ /**
171
+ * Note: Available from v3.19.2 (macOS only)
172
+ * Sets the width of the sidebar in pixels.
173
+ * The width is persisted and will be applied when the sidebar is visible.
174
+ *
175
+ * @param {number} width - The width in pixels (e.g., 250)
176
+ *
177
+ * @example
178
+ * // Set sidebar width to 300 pixels
179
+ * NotePlan.setSidebarWidth(300);
180
+ *
181
+ * @example
182
+ * // Set sidebar to a narrow width
183
+ * NotePlan.setSidebarWidth(200);
184
+ */
185
+ .setSidebarWidth(width)
186
+
187
+ /**
188
+ * Note: Available from v3.19.2 (macOS only)
189
+ * Gets the current width of the sidebar in pixels.
190
+ * Returns 0 on iOS/iPadOS or if the sidebar is not available.
191
+ *
192
+ * @return {number} The current sidebar width in pixels
193
+ *
194
+ * @example
195
+ * // Get the current sidebar width
196
+ * const currentWidth = NotePlan.getSidebarWidth();
197
+ * console.log(`Sidebar width: ${currentWidth}px`);
198
+ *
199
+ * @example
200
+ * // Double the sidebar width
201
+ * const currentWidth = NotePlan.getSidebarWidth();
202
+ * NotePlan.setSidebarWidth(currentWidth * 2);
203
+ */
204
+ .getSidebarWidth()
205
+
206
+
207
+ /**
208
+ * Note: Available from v3.19.2 (macOS only)
209
+ * Checks whether the sidebar is currently collapsed.
210
+ * Returns false on iOS/iPadOS or if the sidebar is not available.
211
+ *
212
+ * @return {boolean} true if the sidebar is collapsed, false otherwise
213
+ *
214
+ * @example
215
+ * // Check if sidebar is collapsed
216
+ * if (NotePlan.isSidebarCollapsed()) {
217
+ * console.log("Sidebar is collapsed");
218
+ * } else {
219
+ * console.log("Sidebar is visible");
220
+ * }
221
+ *
222
+ * @example
223
+ * // Toggle sidebar only if it's currently collapsed
224
+ * if (NotePlan.isSidebarCollapsed()) {
225
+ * NotePlan.toggleSidebar(false, true, true);
226
+ * }
227
+ */
228
+ .isSidebarCollapsed()
229
+
230
+ /**
231
+ * Note: Available from v3.19.2
232
+ * Fetches current weather data and forecast using OpenWeatherMap API.
233
+ * Automatically detects location via IP geolocation or uses provided coordinates.
234
+ * Returns formatted weather information with emojis and detailed weather data.
235
+ *
236
+ * @param {string} units - Temperature units: "metric" (Celsius, m/s) or "imperial" (Fahrenheit, mph).
237
+ * If empty or invalid, defaults to locale's measurement system preference.
238
+ * @param {number} latitude - Latitude coordinate (use 0 or NaN for IP-based location detection)
239
+ * @param {number} longitude - Longitude coordinate (use 0 or NaN for IP-based location detection)
240
+ * @return {Promise<Object>} Promise that resolves to weather data object with formatted output and detailed information.
241
+ * On error, still resolves with a formatted error message in the `formatted` field.
242
+ *
243
+ * @example
244
+ * // Get weather for current location (IP-based) using await
245
+ * const weather = await NotePlan.getWeather("", 0, 0);
246
+ * console.log(weather.formatted);
247
+ * // Output:
248
+ * // ### San Francisco Weather for Tue, 2025-10-28
249
+ * // ☀️ **Clear Sky** - High: **18°C**, Low: **12°C**, Wind: **8m/s**, Visibility: **10km**
250
+ * // 🌅 Sunrise: **7:15 AM**, Sunset: **6:30 PM**, Peak UVI: **5**
251
+ *
252
+ * @example
253
+ * // Get weather for specific location (New York City) with error handling
254
+ * try {
255
+ * const weather = await NotePlan.getWeather("imperial", 40.7128, -74.0060);
256
+ * console.log(`${weather.emoji} ${weather.condition}`);
257
+ * console.log(`Temperature: ${weather.temperature}${weather.temperatureUnit}`);
258
+ * console.log(`High: ${weather.highTemp}, Low: ${weather.lowTemp}`);
259
+ * console.log(`Humidity: ${weather.humidity}%`);
260
+ * console.log(`Wind: ${weather.windSpeed}${weather.windSpeedUnit}`);
261
+ * console.log(`Location: ${weather.cityName}, ${weather.state}, ${weather.country}`);
262
+ * } catch (error) {
263
+ * console.log("Error fetching weather:", error);
264
+ * }
265
+ *
266
+ * @example
267
+ * // Get weather for London and insert into editor
268
+ * const weather = await NotePlan.getWeather("metric", 51.5074, -0.1278);
269
+ * Editor.insertTextAtCursor(weather.formatted);
270
+ *
271
+ * @example
272
+ * // Use locale-based units (empty string auto-detects)
273
+ * const weather = await NotePlan.getWeather();
274
+ * console.log(weather.formatted);
275
+ *
276
+ * @returns {Object} weather - Weather data object
277
+ * @returns {string} weather.formatted - Pre-formatted markdown weather output with emojis (or error message on failure)
278
+ *
279
+ * @returns {string} weather.cityName - City name (from IP location or reverse geocoding)
280
+ * @returns {string} weather.state - State/administrative area
281
+ * @returns {string} weather.region - Region/sub-administrative area
282
+ * @returns {string} weather.country - Country name
283
+ * @returns {string} weather.countryCode - ISO country code
284
+ * @returns {string} weather.postalCode - Postal/ZIP code
285
+ * @returns {string} weather.subLocality - Sub-locality
286
+ * @returns {string} weather.thoroughfare - Street address
287
+ *
288
+ * @returns {string} weather.ipAddress - IP address used for geolocation (only when using IP-based detection)
289
+ * @returns {number} weather.ipVersion - IP version (4 or 6, only when using IP-based detection)
290
+ * @returns {string} weather.capital - Capital city of the country (only when using IP-based detection)
291
+ * @returns {Array<string>} weather.phoneCodes - Phone country codes (only when using IP-based detection)
292
+ * @returns {Array<string>} weather.timeZones - Time zones (only when using IP-based detection)
293
+ * @returns {string} weather.continent - Continent name (only when using IP-based detection)
294
+ * @returns {string} weather.continentCode - Continent code (only when using IP-based detection)
295
+ * @returns {Array<string>} weather.currencies - Currency codes (only when using IP-based detection)
296
+ * @returns {Array<string>} weather.languages - Language codes (only when using IP-based detection)
297
+ * @returns {string} weather.asn - Autonomous System Number (only when using IP-based detection)
298
+ * @returns {string} weather.asnOrganization - ASN organization name (only when using IP-based detection)
299
+ * @returns {boolean} weather.isProxy - Whether the IP is a proxy (only when using IP-based detection)
300
+ *
301
+ * @returns {number} weather.temperature - Current temperature
302
+ * @returns {string} weather.temperatureUnit - Temperature unit symbol (°C or °F)
303
+ * @returns {number} weather.apparentTemperature - Feels-like temperature
304
+ * @returns {number} weather.humidity - Humidity percentage
305
+ * @returns {number} weather.windSpeed - Wind speed
306
+ * @returns {string} weather.windSpeedUnit - Wind speed unit (m/s or mph)
307
+ * @returns {number} weather.windDirection - Wind direction in degrees
308
+ * @returns {number} weather.uvIndex - UV index
309
+ * @returns {string} weather.condition - Weather condition description
310
+ * @returns {string} weather.emoji - Weather emoji based on condition
311
+ * @returns {string} weather.iconCode - OpenWeatherMap icon code
312
+ * @returns {number} weather.visibility - Visibility distance
313
+ * @returns {string} weather.visibilityUnit - Visibility unit (km)
314
+ * @returns {number} weather.highTemp - Today's high temperature
315
+ * @returns {number} weather.lowTemp - Today's low temperature
316
+ * @returns {string} weather.sunrise - Sunrise time (formatted as h:mm AM/PM)
317
+ * @returns {string} weather.sunset - Sunset time (formatted as h:mm AM/PM)
318
+ *
319
+ * @returns {Object} weather.location - Complete location information object
320
+ * @returns {number} weather.location.latitude - Latitude
321
+ * @returns {number} weather.location.longitude - Longitude
322
+ * @returns {string} weather.location.cityName - City name
323
+ * @returns {string} weather.location.state - State/administrative area
324
+ * @returns {string} weather.location.region - Region/sub-administrative area
325
+ * @returns {string} weather.location.country - Country name
326
+ * @returns {string} weather.location.countryCode - ISO country code
327
+ * @returns {string} weather.location.postalCode - Postal/ZIP code
328
+ * @returns {string} weather.location.subLocality - Sub-locality
329
+ * @returns {string} weather.location.thoroughfare - Street address
330
+ * @returns {string} weather.location.ipAddress - IP address (only when using IP-based detection)
331
+ * @returns {number} weather.location.ipVersion - IP version (only when using IP-based detection)
332
+ * @returns {string} weather.location.capital - Capital city (only when using IP-based detection)
333
+ * @returns {Array<string>} weather.location.phoneCodes - Phone country codes (only when using IP-based detection)
334
+ * @returns {Array<string>} weather.location.timeZones - Time zones (only when using IP-based detection)
335
+ * @returns {string} weather.location.continent - Continent name (only when using IP-based detection)
336
+ * @returns {string} weather.location.continentCode - Continent code (only when using IP-based detection)
337
+ * @returns {Array<string>} weather.location.currencies - Currency codes (only when using IP-based detection)
338
+ * @returns {Array<string>} weather.location.languages - Language codes (only when using IP-based detection)
339
+ * @returns {string} weather.location.asn - Autonomous System Number (only when using IP-based detection)
340
+ * @returns {string} weather.location.asnOrganization - ASN organization name (only when using IP-based detection)
341
+ * @returns {boolean} weather.location.isProxy - Whether the IP is a proxy (only when using IP-based detection)
342
+ */
343
+ .getWeather(units, latitude, longitude)
344
+ ```
345
+
346
+ </p>
347
+ </details>
348
+
349
+ <details>
350
+ <summary>Examples</summary>
351
+ <p>
352
+
353
+
354
+ ```javascript
355
+ function showEnvironment() {
356
+ console.log("NotePlan.environment.languageCode: " + NotePlan.environment.languageCode)
357
+ console.log("NotePlan.environment.preferredLanguages: " + NotePlan.environment.preferredLanguages)
358
+ console.log("NotePlan.environment.regionCode: " + NotePlan.environment.regionCode)
359
+ console.log("NotePlan.environment.is12hFormat: " + NotePlan.environment.is12hFormat)
360
+ console.log("NotePlan.environment.secondsFromGMT: " + NotePlan.environment.secondsFromGMT)
361
+ console.log("NotePlan.environment.localTimeZoneAbbreviation: " + NotePlan.environment.localTimeZoneAbbreviation)
362
+ console.log("NotePlan.environment.localTimeZoneIdentifier: " + NotePlan.environment.localTimeZoneIdentifier)
363
+ console.log("NotePlan.environment.isDaylightSavingTime: " + NotePlan.environment.isDaylightSavingTime)
364
+ console.log("NotePlan.environment.daylightSavingTimeOffset: " + NotePlan.environment.daylightSavingTimeOffset)
365
+ console.log("NotePlan.environment.nextDaylightSavingTimeTransition: " + NotePlan.environment.nextDaylightSavingTimeTransition)
366
+ console.log("NotePlan.environment.hasSettings: " + NotePlan.environment.hasSettings)
367
+ console.log("NotePlan.environment.platform: " + NotePlan.environment.platform)
368
+ }
369
+
370
+ function showConfiguration() {
371
+ if(NotePlan.environment.hasSettings && NotePlan.environment.platform == "macOS") {
372
+ await NotePlan.showConfigurationView().catch(e => console.log(e))
373
+ console.log("user finished configuring")
374
+ } else {
375
+ console.log("this plugin has no settings or we are running iOS")
376
+ }
377
+ }
378
+
379
+ async function onEdit(note) {
380
+ console.log("\n")
381
+ console.log("onEdit triggered, note: '" + note.filename + "'")
382
+
383
+ // Get changed ranges
384
+ const ranges = NotePlan.stringDiff(note.versions[1].content, note.versions[0].content)
385
+ console.log("Changed content from index: " + ranges[0].start + " to: " + ranges[0].end)
386
+ console.log("\n")
387
+ }
388
+
389
+ function randomBulletWithAI() {
390
+ // Calls OpenAI with the given prompt and the content of this year's note to fetch a random bullet
391
+ const text = await NotePlan.ai("Return a bullet. Not just the first one, make it random", ["this year"])
392
+ return text
393
+ }
394
+ ```
395
+
396
+ </p>
397
+ </details>
398
+
@@ -0,0 +1,242 @@
1
+ <details>
2
+ <summary>API</summary>
3
+ <p>
4
+
5
+ ```javascript
6
+ ParagraphObject
7
+
8
+ /**
9
+ * Get or set the type of the paragraph
10
+ * @type {"open", "done", "scheduled", "cancelled", "title", "quote", "list" (= bullet), "empty" (no content) or "text" (= plain text), "checklist", "checklistDone", "checklistCancelled", "checklistScheduled" }
11
+ */
12
+ .type
13
+
14
+ /**
15
+ * Get or set the content of the paragraph (without the Markdown 'type' prefix, such as '* [ ]' for open task and without leading indents)
16
+ * @type {String}
17
+ */
18
+ .content
19
+
20
+ /**
21
+ * Get the content of the paragraph (**with** the Markdown 'type' prefix, such as '* [ ]' for open task and **with** leading indents)
22
+ * @type {String}
23
+ */
24
+ .rawContent
25
+
26
+ /**
27
+ * Get the Markdown prefix of the paragraph (like '* [ ]' for open task)
28
+ * @type {String}
29
+ */
30
+ .prefix
31
+
32
+ /**
33
+ * Get the range of the paragraph.
34
+ * @type {RangeObject}
35
+ */
36
+ .contentRange
37
+
38
+ /**
39
+ * Get the line index of the paragraph.
40
+ * @type {Int}
41
+ */
42
+ .lineIndex
43
+
44
+ /**
45
+ * Get the date of the paragraph, if any (in case of scheduled tasks).
46
+ * @type {Date}
47
+ */
48
+ .date
49
+
50
+ /**
51
+ * Get the heading of the paragraph (looks for a previous heading paragraph).
52
+ * @type {String}
53
+ */
54
+ .heading
55
+
56
+ /**
57
+ * Get the heading range of the paragraph (looks for a previous heading paragraph).
58
+ * @type {RangeObject}
59
+ */
60
+ .headingRange
61
+
62
+ /**
63
+ * Get the heading level of the paragraph ('# heading' = level 1).
64
+ * @type {Int}
65
+ */
66
+ .headingLevel
67
+
68
+ /**
69
+ * If the task is a recurring one (contains '@repeat(...)')
70
+ * @type {Boolean}
71
+ */
72
+ .isRecurring
73
+
74
+ /**
75
+ * Get or set the amount of indentations.
76
+ * @type {Int}
77
+ */
78
+ .indents
79
+
80
+ /**
81
+ * Get the filename of the note this paragraph was loaded from (can be undefined).
82
+ * @type {String}
83
+ */
84
+ .filename
85
+
86
+ /**
87
+ * Get the note type of the note this paragraph was loaded from (can be undefined).
88
+ * @type {String}
89
+ */
90
+ .noteType
91
+
92
+ /**
93
+ * Get the linked note titles this paragraph contains, such as '[[Note Name]]' (will return names without the brackets).
94
+ * @type {[String]}
95
+ */
96
+ .linkedNoteTitles
97
+
98
+ /**
99
+ * Creates a duplicate object, so you can change values without affecting the original object
100
+ * @return {ParagraphObject}
101
+ */
102
+ .duplicate()
103
+
104
+
105
+ /**
106
+ * Note: Available from v3.3
107
+ * Returns indented paragraphs (children) underneath a task
108
+ * This includes bullets, tasks, quotes, text.
109
+ * Children are counted until a blank line, HR, title, or another item at the
110
+ * same level as the parent task. So for items to be counted as children, they
111
+ * need to be contiguous vertically.
112
+ * Important note: .children() for a task paragraph will return every child,
113
+ * grandchild, greatgrandchild, etc. So a task that has a child task that has
114
+ * a child task will have 2 children (and the first child will have one)
115
+ * It can return null, if there was a problem loading the text of the underlying note.
116
+ * @type {[ParagraphObject]?}
117
+ */
118
+ .children()
119
+
120
+ /**
121
+ * Note: Available from v3.5.2
122
+ * Returns the NoteObject behind this paragraph. This is a convenience method, so you don't need to use DataStore.
123
+ * @type {NoteObject?}
124
+ */
125
+ .note
126
+
127
+ /**
128
+ * Note: Available from v3.5.2
129
+ * Returns the given blockId if any.
130
+ * @type {String?}
131
+ */
132
+ .blockId
133
+
134
+ /**
135
+ * Note: Available from v3.5.2
136
+ * Returns an array of all paragraphs having the same blockID. You can use `paragraph[0].note` to access the note behind it and make updates via `paragraph[0].note.updateParagraph(paragraph[0])` if you make changes to the content, type, etc (like checking it off as type = "done")
137
+ * @type {[ParagraphObject]} - getter
138
+ */
139
+ .referencedBlocks
140
+ ```
141
+
142
+ </p>
143
+ </details>
144
+
145
+ <details>
146
+ <summary>Example</summary>
147
+ <p>
148
+
149
+ Load current paragraphs and let user modify one:
150
+ ```javascript
151
+ async function modifyExistingParagraphs() {
152
+ try {
153
+ let paragraphs = Editor.paragraphs
154
+
155
+ // Change the content and type of a paragraph
156
+ let re = await CommandBar.showOptions(paragraphs.map(p => (p.lineIndex + ": " + p.content)), "Select a paragraph to modify")
157
+ let newParagraphText = await CommandBar.showInput("New content of selected paragraph", "Change paragraph to '%@'")
158
+ let newType = await CommandBar.showOptions(["open", "done", "scheduled", "cancelled", "quote", "empty", "list"], "Select the new type")
159
+
160
+ paragraphs[re.index].content = newParagraphText
161
+ paragraphs[re.index].type = newType.value
162
+ Editor.paragraphs = paragraphs
163
+
164
+ } catch (error) {
165
+ console.log("Plugin code error: \n"+JSON.stringify(error))
166
+ }
167
+ }
168
+ ```
169
+
170
+ Print a paragraph to console:
171
+ ```javascript
172
+ function printParagraph(p) {
173
+ if(p == undefined) {
174
+ console.log("paragraph is undefined")
175
+ return
176
+ }
177
+
178
+ console.log(
179
+ "\n\ncontent: " + p.content +
180
+ "\n\ttype: " + p.type +
181
+ "\n\tprefix: " + p.prefix +
182
+ "\n\tcontentRange: " + rangeToString(p.contentRange) +
183
+ "\n\tlineIndex: " + p.lineIndex +
184
+ "\n\tdate: " + p.date +
185
+ "\n\theading: " + p.heading +
186
+ "\n\theadingRange: " + rangeToString(p.headingRange) +
187
+ "\n\theadingLevel: " + p.headingLevel +
188
+ "\n\tisRecurring: " + p.isRecurring +
189
+ "\n\tindents: " + p.indents +
190
+ "\n\tfilename: " + p.filename +
191
+ "\n\tnoteType: " + p.noteType +
192
+ "\n\tlinkedNoteTitles: " + p.linkedNoteTitles
193
+ )
194
+ }
195
+
196
+ function rangeToString(r) {
197
+ if(r == undefined) {
198
+ return "Range is undefined!"
199
+ return
200
+ }
201
+
202
+ return "location: " + r.start + ", length: " + r.length
203
+ }
204
+ ```
205
+
206
+ Get children from paragraph (indented items like bullets or sub-tasks):
207
+ ```javascript
208
+ async function childrenOfSelectedParagraph() {
209
+ try {
210
+ let paragraphs = Editor.selectedParagraphs
211
+ console.log(paragraphs[0].content)
212
+
213
+ console.log("load children")
214
+ let children = paragraphs[0].children()
215
+
216
+ if(children) {
217
+ console.log("found: " + children.length + " children")
218
+ children.forEach(p => console.log(p.content))
219
+ } else {
220
+ console.log("couldn't load children")
221
+ }
222
+ } catch (error) {
223
+ console.log("Plugin code error: \n"+JSON.stringify(error))
224
+ }
225
+ }
226
+
227
+ function updateReferencedBlocks() {
228
+ let para = Editor.paragraphs
229
+ let ref = para[0].referencedBlocks
230
+
231
+ console.log("referenced blocks: " + ref.length)
232
+ ref.forEach((todo, i) => {
233
+ console.log(i + ": " + todo.filename)
234
+ todo.type = "done"
235
+ todo.note.updateParagraph(todo)
236
+ });
237
+ }
238
+ ```
239
+
240
+ </p>
241
+ </details>
242
+
@@ -0,0 +1,56 @@
1
+ <details>
2
+ <summary>API</summary>
3
+ <p>
4
+
5
+ ```javascript
6
+ RangeObject
7
+
8
+ /**
9
+ * Character start index of the range.
10
+ * @type {Int}
11
+ */
12
+ .start
13
+
14
+ /**
15
+ * Character end index of the range.
16
+ * @type {Int}
17
+ */
18
+ .end
19
+
20
+ /**
21
+ * Character length of the range (end - start).
22
+ * @type {Int}
23
+ */
24
+ .length
25
+
26
+ /**
27
+ * Create an instance of a Range object with the start and end positions. The length variable is calculated automatically and doesn't have to be set.
28
+ * Example: Range.create(0, 10)
29
+ * @param { Integer }
30
+ * @param { Integer }
31
+ * @return {RangeObject}
32
+ */
33
+ .create(start, end)
34
+ ```
35
+
36
+ </p>
37
+ </details>
38
+
39
+ <details>
40
+ <summary>Examples</summary>
41
+ <p>
42
+
43
+
44
+ ```javascript
45
+ function rangeOfParagraph() {
46
+ let selection = Editor.selection
47
+ let range = Editor.paragraphRangeAtCharacterIndex(selection.start)
48
+
49
+ let text = "Location: " + range.start + ", length: " + range.length
50
+ CommandBar.showOptions([text], "The paragraph range is:")
51
+ }
52
+ ```
53
+
54
+ </p>
55
+ </details>
56
+