@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,700 @@
|
|
|
1
|
+
<details>
|
|
2
|
+
<summary>API</summary>
|
|
3
|
+
<p>
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
DataStore
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get the preference for the default file (note) extension, such as "txt" or "md".
|
|
10
|
+
* @type {String}
|
|
11
|
+
*/
|
|
12
|
+
.defaultFileExtension
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get all folders as array of strings. Including the root "/". This includes folders that begin with "@" such as "@Archive" and "@Templates". It excludes the trash folder.
|
|
16
|
+
* @type {[String]}
|
|
17
|
+
*/
|
|
18
|
+
.folders
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get all calendar notes.
|
|
22
|
+
* @type {[NoteObject]}
|
|
23
|
+
*/
|
|
24
|
+
.calendarNotes
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get all regular, project notes. This includes notes and templates from folders that begin with "@" such as "@Archive" and "@Templates". It excludes notes in the trash folder though.
|
|
28
|
+
* @type {[NoteObject]}
|
|
29
|
+
*/
|
|
30
|
+
.projectNotes
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns an array of teamspaces represented as Note Objects with title and filename populated. Example of a filename: `%%NotePlanCloud%%/275ce631-6c20-4f76-b5fd-a082a9ac5160`
|
|
34
|
+
* @type {[NoteObject]}
|
|
35
|
+
*/
|
|
36
|
+
.teamspaces
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get all cached hashtags (#tag) that are used across notes. It returns the tags with a leading '#'.
|
|
40
|
+
* @type {[String]}
|
|
41
|
+
*/
|
|
42
|
+
.hashtags
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get all cached mentions (@name) that are used across notes. It returns the tags with a leading '@'.
|
|
46
|
+
* @type {[String]}
|
|
47
|
+
*/
|
|
48
|
+
.mentions
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get the names of all available filters that can be used in the "Reviews" / "Filters" (renamed) view.
|
|
52
|
+
* Note: Available from v3.6
|
|
53
|
+
* @type {[String]}
|
|
54
|
+
*/
|
|
55
|
+
.filters
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the value of a given preference (can be undefined, if the setting was never set, so check for this case).
|
|
59
|
+
* Available keys:
|
|
60
|
+
* "themeLight" // theme used in light mode
|
|
61
|
+
* "themeDark" // theme used in dark mode
|
|
62
|
+
* "fontDelta" // delta to default font size
|
|
63
|
+
* "firstDayOfWeek" // first day of calendar week
|
|
64
|
+
* "isAgendaVisible" // only iOS, indicates if the calendar and note below calendar are visible
|
|
65
|
+
* "isAgendaExpanded" // only iOS, indicates if calendar above note is shown as week (true) or month (false)
|
|
66
|
+
* "isAsteriskTodo" // "Recognize * as todo" = checked in markdown preferences
|
|
67
|
+
* "isDashTodo" // "Recognize - as todo" = checked in markdown preferences
|
|
68
|
+
* "isNumbersTodo" // "Recognize 1. as todo" = checked in markdown preferences
|
|
69
|
+
* "defaultTodoCharacter" // returns * or -
|
|
70
|
+
* "isAppendScheduleLinks" // "Append links when scheduling" checked in todo preferences
|
|
71
|
+
* "isAppendCompletionLinks" // "Append completion date" checked in todo preferences
|
|
72
|
+
* "isCopyScheduleGeneralNoteTodos" // "Only add date when scheduling in notes" checked in todo preferences
|
|
73
|
+
* "isSmartMarkdownLink" // "Smart Markdown Links" checked in markdown preferences
|
|
74
|
+
* "fontSize" // Font size defined in editor preferences (might be overwritten by custom theme)
|
|
75
|
+
* "fontFamily" // Font family defined in editor preferences (might be overwritten by custom theme)
|
|
76
|
+
* "isRenderingMarkdown" // "Render Markdown" in the preferences (means hiding markdown characters).
|
|
77
|
+
* @param {String}
|
|
78
|
+
* @return {String?}
|
|
79
|
+
*/
|
|
80
|
+
.preference(key)
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Note: Available from NotePlan v3.1+
|
|
84
|
+
* Change a saved preference or create a new one. It will most likely be picked up by NotePlan after a restart, if you use one of the keys utilized by NotePlan.
|
|
85
|
+
* To change a NotePlan preference, use the keys found in the description of the function `.preference(key)`.
|
|
86
|
+
* You can also save custom preferences specific to the plugin, if you need any. Prepend it with the plugin id or similar to avoid collisions with existing keys.
|
|
87
|
+
* Preferences are saved locally and won't be synced.
|
|
88
|
+
* @param {String}
|
|
89
|
+
* @param {Any}
|
|
90
|
+
*/
|
|
91
|
+
.setPreference(key, value)
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Returns the calendar note for the given date and timeframe (optional, the default is "day", see below for more options). Additionally, you can define a teamspace filename or ID as "parent" (third variable), to get the calendar note from that teamspace. By default, if undefined or empty, it will return the private calendar note.
|
|
95
|
+
* @param {Date}
|
|
96
|
+
* @param {String} - "day" (default), "week", "month", "quarter" or "year"
|
|
97
|
+
* @param {String?}
|
|
98
|
+
* @return {NoteObject}
|
|
99
|
+
*/
|
|
100
|
+
.calendarNoteByDate(date, timeframe, parent)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the calendar note for the given date string (can be undefined, if the calendar note was not created yet). See the date formats below for various types of calendar notes:
|
|
105
|
+
* Daily: "YYYYMMDD", example: "20210410"
|
|
106
|
+
* Weekly: "YYYY-Wwn", example: "2022-W24"
|
|
107
|
+
* Quarter: "YYYY-Qq", example: "2022-Q4"
|
|
108
|
+
* Monthly: "YYYY-MM", example: "2022-10"
|
|
109
|
+
* Yearly: "YYYY", example: "2022"
|
|
110
|
+
* Optionally define a teamspace with the "parent" variable using the ID or filename of the teamspace. By default it returns the private calendar note.
|
|
111
|
+
* @param {String}
|
|
112
|
+
* @param {String?}
|
|
113
|
+
* @return {NoteObject}
|
|
114
|
+
*/
|
|
115
|
+
.calendarNoteByDateString(dateString, parent)
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns all regular notes with the given title (first line in editor). Since multiple notes can have the same title, an array is returned. Use 'caseSensitive' (default = false) to search for a note ignoring the case and set 'searchAllFolders' to true if you want to look for notes in trash and archive as well. By default NotePlan won't return notes in trash and archive.
|
|
119
|
+
* @param {String}
|
|
120
|
+
* @param {Boolean}
|
|
121
|
+
* @param {Boolean}
|
|
122
|
+
* @return {[NoteObject]}
|
|
123
|
+
*/
|
|
124
|
+
.projectNoteByTitle(title, caseInsensitive, searchAllFolders)
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns all regular notes with the given case insenstivie title (first line in editor). Since multiple notes can have the same title, an array is returned.
|
|
128
|
+
* @param {String}
|
|
129
|
+
* @return {[NoteObject]}
|
|
130
|
+
*/
|
|
131
|
+
.projectNoteByTitleCaseInsensitive(title)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the regular note for the given filename with file-extension, the filename has to include the relative folder such as `folder/filename.txt`. Use no folder if it's in the root (means without leading slash).
|
|
136
|
+
* @param {String}
|
|
137
|
+
* @return {NoteObject}
|
|
138
|
+
*/
|
|
139
|
+
.projectNoteByFilename(filename)
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns a regular or calendar note for the given filename. Type can be "Notes" or "Calendar". Include relative folder and file extension (`folder/filename.txt` for example).
|
|
143
|
+
* Use "YYYYMMDD.ext" for calendar notes, like "20210503.txt".
|
|
144
|
+
* Optionally define the teamspace using the "parent" variable. This should be the ID or filename of the teamspace, if empty or undefined, it will fetch the note from the private notes.
|
|
145
|
+
* @param {String}
|
|
146
|
+
* @param {String}
|
|
147
|
+
* @param {String?}
|
|
148
|
+
* @return {NoteObject}
|
|
149
|
+
*/
|
|
150
|
+
.noteByFilename(filename, type, parent)
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Note: Available from v3.5.2
|
|
154
|
+
* Returns an array of paragraphs having the same blockID like the given one. 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")
|
|
155
|
+
* If you pass no paragraph as argument this will return all synced lines that are available.
|
|
156
|
+
* @param {ParagraphObject?}
|
|
157
|
+
* @return {[ParagraphObject]}
|
|
158
|
+
*/
|
|
159
|
+
.referencedBlocks(paragraph)
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Move a regular note using the given filename (include extension and relative folder like `folder/filename.txt`, if it's in the root folder don't add a leading slash) to another folder. Use "/" for the root folder as destination.
|
|
163
|
+
* Returns the final filename (if the there is a duplicate, it will add a number).
|
|
164
|
+
* If you want to move a calendar note, use as type "calendar", by default it uses "note" (available from v3.9.3).
|
|
165
|
+
* @param {String}
|
|
166
|
+
* @param {String}
|
|
167
|
+
* @param {String} (default is "note")
|
|
168
|
+
* @return {String}
|
|
169
|
+
*/
|
|
170
|
+
.moveNote(filename, folder, type)
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Available from v3.18.2
|
|
174
|
+
* Move a regular note using the given filename (include extension and relative folder like `folder/filename.txt`, if it's in the root folder don't add a leading slash) to the trash folder.
|
|
175
|
+
* Returns true if successful.
|
|
176
|
+
* Calendar notes cannot be moved to trash.
|
|
177
|
+
* Teamspace notes are deleted immediately (teamspaces have no trash folder as of now), but a copy is made inside the system trash bin, if the user needs to recover the note.
|
|
178
|
+
* @param {String}
|
|
179
|
+
* @return {Boolean}
|
|
180
|
+
*/
|
|
181
|
+
.trashNote(filename)
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Creates a regular note using the given title and folder. Use "/" for the root folder. It will write the given title as "# title" into the new file.
|
|
185
|
+
* Returns the final filename with relative folder (`folder/filename.txt` for example). Ff the there is a duplicate, it will add a number.
|
|
186
|
+
* @param {String}
|
|
187
|
+
* @param {String}
|
|
188
|
+
* @return {String}
|
|
189
|
+
*/
|
|
190
|
+
.newNote(title, folder)
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Creates a regular note using the given content and folder. Use "/" for the root folder. The content should ideally also include a note title at the top.
|
|
194
|
+
* Returns the final filename with relative folder (`folder/filename.txt` for example). Ff the there is a duplicate, it will add a number.
|
|
195
|
+
* Alternatively, you can also define the filename as the third optional variable (v3.5.2+)
|
|
196
|
+
* Note: Available from v3.5
|
|
197
|
+
* @param {String}
|
|
198
|
+
* @param {String}
|
|
199
|
+
* @param {String} (optional)
|
|
200
|
+
* @return {String}
|
|
201
|
+
*/
|
|
202
|
+
.newNoteWithContent(content, folder, filename)
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Note: Available from NotePlan v3.1+
|
|
206
|
+
* Save a JavaScript object as JSON file. The file will be saved under "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
207
|
+
* This can be used to save preferences or other persistent data. The JSON file will be synced by NotePlan.
|
|
208
|
+
* The filename is optional, if you don't use any filename, NotePlan will assume "settings.json".
|
|
209
|
+
* Returns true if the file could be saved, false if not and prints the error.
|
|
210
|
+
* @param {Object}
|
|
211
|
+
* @param {String?}
|
|
212
|
+
* @return {Boolean}
|
|
213
|
+
*/
|
|
214
|
+
.saveJSON(object, filename?)
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Note: Available from NotePlan v3.1+
|
|
218
|
+
* Load a JavaScript object from a JSON file. The file has to be located in "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
219
|
+
* You can access the json files of other plugins as well, if the filename is known using relative paths "../[other plugin-id]/[filename]" or simply go into the "data"'s root directory "../[filename]" to access a global file.
|
|
220
|
+
* The filename is optional, if you don't use any filename, NotePlan will assume "settings.json".
|
|
221
|
+
* Returns undefined, if the JSON couldn't be loaded and prints an error message.
|
|
222
|
+
* @param {String?}
|
|
223
|
+
* @return {Object?}
|
|
224
|
+
*/
|
|
225
|
+
.loadJSON(filename?)
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Note: Available from NotePlan v3.3.2
|
|
229
|
+
* Loads the plugin related settings as a JavaScript object. If no settings file exists yet, this will create one from the settings schema in the plugin.json and use the default values.
|
|
230
|
+
* The settings.json file is located in "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
231
|
+
* If no settings schema is available, it will return null.
|
|
232
|
+
* Read more about plugin settings here: https://help.noteplan.co/article/123-plugin-configuration
|
|
233
|
+
* this is a setter and getter, so you can also assign a JavaScript object and it will be saved in the settings file.
|
|
234
|
+
* @return {Object?}
|
|
235
|
+
*/
|
|
236
|
+
.settings
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Note: Available from NotePlan v3.2+
|
|
240
|
+
* Save data to a file, as base64 string (optionally as plain string). The file will be saved under "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
241
|
+
* Returns true if the file could be saved, false if not and prints the error.
|
|
242
|
+
* @param {String}
|
|
243
|
+
* @param {String}
|
|
244
|
+
* @param {Boolean}
|
|
245
|
+
* @return {Boolean}
|
|
246
|
+
*/
|
|
247
|
+
.saveData(data, filename, saveAsString)
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Note: Available from NotePlan v3.2+
|
|
251
|
+
* Load binary data from file encoded as base64 string (or optionally as plain string).
|
|
252
|
+
* The file has to be located in "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
253
|
+
* You can access the files of other plugins as well, if the filename is known using relative paths "../[other plugin-id]/[filename]" or simply go into the "data"'s root directory "../[filename]" to access a global file.
|
|
254
|
+
* Returns undefined, if the file couldn't be loaded and prints an error message.
|
|
255
|
+
* @param {String}
|
|
256
|
+
* @param {Boolean}
|
|
257
|
+
* @return {String?}
|
|
258
|
+
*/
|
|
259
|
+
.loadData(filename, loadAsString)
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Note: Available from NotePlan v3.8.1+
|
|
263
|
+
* Checks the existence of a file in the data folder.
|
|
264
|
+
* The file has to be located in "[NotePlan Folder]/Plugins/data/[plugin-id]/[filename]".
|
|
265
|
+
* @param {String}
|
|
266
|
+
* @return {Boolean}
|
|
267
|
+
*/
|
|
268
|
+
.fileExists(filename)
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Note: Available from NotePlan v3.5.2
|
|
272
|
+
* Loads all available plugins asynchronously from the GitHub repository and returns a list.
|
|
273
|
+
* You can show a loading indicator using the first parameter (true) if this is part of some user interaction. Otherwise, pass "false" so it happens in the background.
|
|
274
|
+
* Set `showHidden` to true if it should also load hidden plugins. Hidden plugins have a flag `isHidden`.
|
|
275
|
+
* Set the third parameter `skipMatchingLocalPlugins` to true if you want to see only the available plugins from GitHub and not merge the data with the locally available plugins. Then the version will always be that of the plugin that is available online.
|
|
276
|
+
* @param {Boolean}
|
|
277
|
+
* @param {Boolean}
|
|
278
|
+
* @param {Boolean}
|
|
279
|
+
* @return {Promise}
|
|
280
|
+
*/
|
|
281
|
+
.listPlugins(showLoading, showHidden, skipMatchingLocalPlugins)
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Note: Available from NotePlan v3.5.2
|
|
285
|
+
* Installs a given plugin (load a list of plugins using `.listPlugins` first). If this is part of a user interfaction, pass "true" for `showLoading` to show a loading indicator.
|
|
286
|
+
* @param {PluginObject}
|
|
287
|
+
* @param {Boolean}
|
|
288
|
+
* @return {Promise}
|
|
289
|
+
*/
|
|
290
|
+
.installPlugin(pluginObject, showLoading)
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Note: Available from NotePlan v3.5.2
|
|
294
|
+
* Returns all installed plugins as PluginObject(s).
|
|
295
|
+
* @return {[PluginObject]}
|
|
296
|
+
*/
|
|
297
|
+
.installedPlugins()
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Note: Available from NotePlan v3.6
|
|
301
|
+
* Checks if the given pluginID is installed or not.
|
|
302
|
+
* @param {String}
|
|
303
|
+
* @return {Boolean}
|
|
304
|
+
*/
|
|
305
|
+
.isPluginInstalledByID(pluginID)
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Note: Available from NotePlan v3.6
|
|
309
|
+
* Installs a given array of pluginIDs if needed. It checks online if a new version is available and downloads it.
|
|
310
|
+
* Use it without `await` so it keeps running in the background or use it with `await` in "blocking mode" if you need to install a plugin as a dependency. In this case you can use `showPromptIfSuccessful = true` to show the user a message that a plugin was installed and `showProgressPrompt` will show a loading indicator beforehand. With both values set to false or not defined it will run in "silent" mode and show no prompts. Optionally display the user a failed prompt with the 4th variable.
|
|
311
|
+
* Returns an object with the success/fail status and a description: `{ code: -1, message: "something went wrong" }` for example. Anything code >= 0 is a success.
|
|
312
|
+
* @param {[String]}
|
|
313
|
+
* @param {Boolean}
|
|
314
|
+
* @param {Boolean}
|
|
315
|
+
* @param {Boolean}
|
|
316
|
+
* @return {Promise}
|
|
317
|
+
*/
|
|
318
|
+
.installOrUpdatePluginsByID([pluginID], showPromptIfSuccessful, showProgressPrompt, showFailedPrompt)
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Note: Available from NotePlan v3.5.2
|
|
322
|
+
* Invoke a given command from a plugin (load a list of plugins using `.listPlugins` first, then get the command from the `.commands` list).
|
|
323
|
+
* If the command supports it, you can also pass an array of arguments which can contain any type (object, date, string, integer,...)
|
|
324
|
+
* It returns the particular return value of that command which can be a Promise so you can use it with `await`.
|
|
325
|
+
* @param {PluginCommandObject}
|
|
326
|
+
* @param {[Object]}
|
|
327
|
+
* @return {Return value of the command, like a Promise}
|
|
328
|
+
*/
|
|
329
|
+
.invokePluginCommand(command, arguments)
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Note: Available from NotePlan v3.5.2
|
|
333
|
+
* Invoke a given command from a plugin using the name and plugin ID, so you don't need to load it from the list.
|
|
334
|
+
* If the command doesn't exist locally null will be returned with a log message.
|
|
335
|
+
* If the command supports it, you can also pass an array of arguments which can contain any type (object, date, string, integer,...)
|
|
336
|
+
* This function expects that the called command returns some value. If it doesn't return anything naturally, you can return an empty object `{}`, or an error message will show up in the logs (which you can also ignore).
|
|
337
|
+
* @param {String}
|
|
338
|
+
* @param {String}
|
|
339
|
+
* @param {[Object]}
|
|
340
|
+
* @return {Return value of the command, like a Promise}
|
|
341
|
+
*/
|
|
342
|
+
.invokePluginCommandByName(command, pluginId, arguments)
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Note: Available from NotePlan v3.6
|
|
346
|
+
* This function is async, use it with `await`, so that the UI is not being blocked during a long search.
|
|
347
|
+
* Searches all notes for a keyword in multiple threads to speed it up. By default it searches in project notes and in the calendar notes. Use the second parameters "types" to exclude a type. Otherwise, pass `null` or nothing.
|
|
348
|
+
* Optionally pass a list of folders (`inNotes`) to limit the search to notes that ARE in those folders (applies only to project notes)
|
|
349
|
+
* Optionally pass a list of folders (`notInFolders`) to limit the search to notes NOT in those folders (applies only to project notes)
|
|
350
|
+
* Optionally include scheduled tasks (i.e. tasks with >today or >YYYY-MM-DD, etc.). This is by default off, if you turn it on with `true`, you might get results from excluded folders if they are referencing a calendar note.
|
|
351
|
+
* Searches for keywords case-insensitive.
|
|
352
|
+
* This supports advanced search (exact match, exclusions, groups, boolean OR) and search operators (so you can filter for tasks similar to the filters view), learn more here: https://help.noteplan.co/article/269-advanced-search
|
|
353
|
+
* @param {String} = keyword to search for
|
|
354
|
+
* @param {[String]?} = types: ["notes", "calendar"] (by default all, unless search operators are used, or pass `null`)
|
|
355
|
+
* @param {[String]?} = array of folders
|
|
356
|
+
* @param {[String]?} = array of folders
|
|
357
|
+
* @param {Boolean}
|
|
358
|
+
* @return {[ParagraphObject}
|
|
359
|
+
*/
|
|
360
|
+
.search(keyword, types, inFolders, notInFolders, shouldLoadDatedTodos)
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Note: Available from NotePlan v3.6
|
|
364
|
+
* Convenience function for search
|
|
365
|
+
* This function is async, use it with `await`, so that the UI is not being blocked during a long search.
|
|
366
|
+
* Searches all project notes for a keyword in multiple threads to speed it up.
|
|
367
|
+
* Optionally pass a list of folders (`inNotes`) to limit the search to notes that ARE in those folders (applies only to project notes)
|
|
368
|
+
* Optionally pass a list of folders (`notInFolders`) to limit the search to notes NOT in those folders (applies only to project notes)
|
|
369
|
+
* @param {String} = keyword to search for
|
|
370
|
+
* @param {[String]?} = array of folders
|
|
371
|
+
* @param {[String]?} = array of folders
|
|
372
|
+
* @return {[ParagraphObject}
|
|
373
|
+
*/
|
|
374
|
+
.searchProjectNotes(keyword, inFolders, notInFolders)
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Note: Available from NotePlan v3.6
|
|
378
|
+
* Convenience function for search
|
|
379
|
+
* This function is async, use it with `await`, so that the UI is not being blocked during a long search.
|
|
380
|
+
* Searches all calendar notes for a keyword in multiple threads to speed it up.
|
|
381
|
+
* Optionally include scheduled tasks (i.e. tasks with >today or >YYYY-MM-DD, etc.). This is by default off, if you turn it on with `true`, you will get results from regular notes too.
|
|
382
|
+
* @param {String} = keyword to search for
|
|
383
|
+
* @param {Boolean}
|
|
384
|
+
* @return {[ParagraphObject}
|
|
385
|
+
*/
|
|
386
|
+
.searchCalendarNotes(keyword, shouldLoadDatedTodos)
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Note: Available from NotePlan v3.7.1
|
|
390
|
+
* Updates the cache, so you can access changes faster. And returns the updated note (from the update cache).
|
|
391
|
+
* @param {NoteObject}
|
|
392
|
+
* @param {Boolean}
|
|
393
|
+
* @return {NoteObject}
|
|
394
|
+
*/
|
|
395
|
+
.updateCache(note, shouldUpdateTags)
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Note: Available from NotePlan v3.8
|
|
399
|
+
* Creates a folder if it doesn't exist yet. Can be with subfolders like "main/sub1/sub2".
|
|
400
|
+
* @param {String}
|
|
401
|
+
* @return {Bool}
|
|
402
|
+
*/
|
|
403
|
+
.createFolder(folderPath)
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Note: Available from NotePlan v3.8.1
|
|
407
|
+
* Returns all overdue tasks (i.e. tasks that are open and in the past). Use with await, it runs in the background. If there are a lot of tasks consider showing a loading bar.
|
|
408
|
+
* You can optionally use a search keyword, if you are looking for a specific overdue task. It will search the content of the task for that string. Leave it blank otherwise.
|
|
409
|
+
* @param {String} (optional)
|
|
410
|
+
* @return {Promise - [Paragraph]}
|
|
411
|
+
*/
|
|
412
|
+
.listOverdueTasks(keyword)
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
</p>
|
|
416
|
+
</details>
|
|
417
|
+
|
|
418
|
+
<details>
|
|
419
|
+
<summary>Examples</summary>
|
|
420
|
+
<p>
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
```javascript
|
|
424
|
+
|
|
425
|
+
function queryNotes() {
|
|
426
|
+
try {
|
|
427
|
+
// With note type parameters "Calendar" or "Notes"
|
|
428
|
+
// var note = DataStore.noteByFilename("20210411", "Calendar")
|
|
429
|
+
|
|
430
|
+
// Using a date object
|
|
431
|
+
// var note = DataStore.calendarNoteByDate(new Date())
|
|
432
|
+
|
|
433
|
+
// Using an ISO string "YYYYMMDD", with or without the file-extension
|
|
434
|
+
// var note = DataStore.calendarNoteByDateString("20210410")
|
|
435
|
+
|
|
436
|
+
// Returns multiple notes potentially if the user has named multiple notes with the same title.
|
|
437
|
+
// var note = DataStore.projectNoteByTitle("TEST")[0]
|
|
438
|
+
|
|
439
|
+
// Search for title - case insensitive
|
|
440
|
+
// var note = DataStore.projectNoteByTitleCaseInsensitive("test")[0]
|
|
441
|
+
|
|
442
|
+
// Here the file-extension is important
|
|
443
|
+
var note = DataStore.projectNoteByFilename("test.txt")
|
|
444
|
+
// note.insertTodo("hello World", 9999) // Add a task at the end of the note
|
|
445
|
+
printNote(note)
|
|
446
|
+
|
|
447
|
+
// Get the default file extension for notes. It's a getter, the setter hasn't been implemented because it might cause chaos if it's not called through the preferences.
|
|
448
|
+
var extension = DataStore.defaultFileExtension
|
|
449
|
+
console.log("The default file extension for notes is: '" + extension + "'")
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function createNewNote() {
|
|
456
|
+
try {
|
|
457
|
+
// DataStore.newNote(title, folder)
|
|
458
|
+
let filename = DataStore.newNote("This is a test", "TEST")
|
|
459
|
+
console.log("Created note with filename: " + filename)
|
|
460
|
+
} catch (error) {
|
|
461
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Note: Don't pass JS objects into the `CommandBar.show...` functions, NotePlan might crash. Only pass strings / array of strings.
|
|
466
|
+
async function createNoteWithCommandBarInput() {
|
|
467
|
+
try {
|
|
468
|
+
// CommandBar.showInput(placeholder, text of first result with variable for keyword, JS callback function)
|
|
469
|
+
let title = await CommandBar.showInput("Enter title of the new note", "Create a new note with title = '%@'")
|
|
470
|
+
let folder = (await CommandBar.showOptions(DataStore.folders, "Select a folder for '" + title + "'")).value
|
|
471
|
+
|
|
472
|
+
if(title != undefined && title !== "") {
|
|
473
|
+
var filename = DataStore.newNote(title, folder)
|
|
474
|
+
console.log("Created note with filename: " + filename)
|
|
475
|
+
} else {
|
|
476
|
+
console.log("Reply undefined or empty: " + title)
|
|
477
|
+
// Some error message
|
|
478
|
+
}
|
|
479
|
+
} catch (error) {
|
|
480
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function getPreferences() {
|
|
485
|
+
console.log("isAsteriskTodo: " + DataStore.preference("isAsteriskTodo"))
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function saveLoadJSON() {
|
|
489
|
+
try {
|
|
490
|
+
let filename = "pluginid-preferences.json"
|
|
491
|
+
|
|
492
|
+
// Create an object
|
|
493
|
+
let preferences = { a: "hello world", b: true }
|
|
494
|
+
|
|
495
|
+
// Save object
|
|
496
|
+
let success = DataStore.saveJSON(preferences, filename)
|
|
497
|
+
|
|
498
|
+
// Load object
|
|
499
|
+
let loadedObject = DataStore.loadJSON(filename)
|
|
500
|
+
console.log(loadedObject.a)
|
|
501
|
+
} catch (error) {
|
|
502
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function testSettings() {
|
|
507
|
+
let theSettings = DataStore.settings
|
|
508
|
+
console.log(JSON.stringify(DataStore.settings))
|
|
509
|
+
DataStore.settings = { hello: "world" }
|
|
510
|
+
console.log(JSON.stringify(DataStore.settings))
|
|
511
|
+
DataStore.settings = { }
|
|
512
|
+
console.log(JSON.stringify(DataStore.settings))
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function listTeamspaceCalendarNotes() {
|
|
516
|
+
// Get all teamspaces
|
|
517
|
+
const teamspaces = DataStore.teamspaces
|
|
518
|
+
console.log(`\n=== Found ${teamspaces.length} teamspaces ===\n`)
|
|
519
|
+
|
|
520
|
+
// Use specific date string
|
|
521
|
+
const dateString = "20250415"
|
|
522
|
+
console.log(`Using date string: ${dateString}\n`)
|
|
523
|
+
|
|
524
|
+
// For each teamspace, get the note and print content
|
|
525
|
+
for (const teamspace of teamspaces) {
|
|
526
|
+
console.log(`\nTeamspace: ${teamspace.title}`)
|
|
527
|
+
|
|
528
|
+
// Get note for this teamspace
|
|
529
|
+
const note = DataStore.calendarNoteByDateString(
|
|
530
|
+
dateString,
|
|
531
|
+
teamspace.filename
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
if (note) {
|
|
535
|
+
// Print the first 100 characters of the note content
|
|
536
|
+
const contentPreview = note.content
|
|
537
|
+
? note.content.substring(0, 100)
|
|
538
|
+
: "No content"
|
|
539
|
+
|
|
540
|
+
console.log(
|
|
541
|
+
`\n"${contentPreview}${
|
|
542
|
+
note.content && note.content.length > 100 ? "..." : ""
|
|
543
|
+
}"`
|
|
544
|
+
)
|
|
545
|
+
} else {
|
|
546
|
+
console.log(`No note found for this date in this teamspace`)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
console.log(`\n${"=".repeat(50)}`)
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
</p>
|
|
555
|
+
</details>
|
|
556
|
+
|
|
557
|
+
<details>
|
|
558
|
+
<summary>PluginObject</summary>
|
|
559
|
+
<p>
|
|
560
|
+
|
|
561
|
+
```javascript
|
|
562
|
+
/**
|
|
563
|
+
* ID of the plugin
|
|
564
|
+
* { get }
|
|
565
|
+
* @type {String}
|
|
566
|
+
*/
|
|
567
|
+
.id
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Name of the plugin
|
|
571
|
+
* { get }
|
|
572
|
+
* @type {String}
|
|
573
|
+
*/
|
|
574
|
+
.name
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Description of the plugin
|
|
578
|
+
* { get }
|
|
579
|
+
* @type {String}
|
|
580
|
+
*/
|
|
581
|
+
.desc
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Author of the plugin
|
|
585
|
+
* { get }
|
|
586
|
+
* @type {String}
|
|
587
|
+
*/
|
|
588
|
+
.author
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* RepoUrl of the plugin
|
|
592
|
+
* { get }
|
|
593
|
+
* @type {String?}
|
|
594
|
+
*/
|
|
595
|
+
.repoUrl
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Release page URL of the plugin (on GitHub)
|
|
599
|
+
* { get }
|
|
600
|
+
* @type {String?}
|
|
601
|
+
*/
|
|
602
|
+
.releaseUrl
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Version of the plugin
|
|
606
|
+
* { get }
|
|
607
|
+
* @type {String}
|
|
608
|
+
*/
|
|
609
|
+
.version
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* This is the online data of the plugin. It might not be installed locally.
|
|
613
|
+
* { get }
|
|
614
|
+
* @type {Boolean}
|
|
615
|
+
*/
|
|
616
|
+
.isOnline
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Script filename that contains the code for this plugin (like script.js)
|
|
620
|
+
* { get }
|
|
621
|
+
* @type {String}
|
|
622
|
+
*/
|
|
623
|
+
.script
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* If this is a locally installed plugin, you can use this variable to check if an updated version is available online.
|
|
627
|
+
* { get }
|
|
628
|
+
* @type {PluginObject}
|
|
629
|
+
*/
|
|
630
|
+
.availableUpdate
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* A list of available commands for this plugin.
|
|
634
|
+
* { get }
|
|
635
|
+
* @type {PluginCommandObject}
|
|
636
|
+
*/
|
|
637
|
+
.commands
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* (Optional) Information about the last update.
|
|
641
|
+
* { get }
|
|
642
|
+
* @type {String?}
|
|
643
|
+
*/
|
|
644
|
+
.lastUpdateInfo
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* (Optional) List of required files.
|
|
648
|
+
* { get }
|
|
649
|
+
* @type {String?}
|
|
650
|
+
*/
|
|
651
|
+
.requiredFiles
|
|
652
|
+
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
</p>
|
|
656
|
+
</details>
|
|
657
|
+
|
|
658
|
+
<details>
|
|
659
|
+
<summary>PluginCommandObject</summary>
|
|
660
|
+
<p>
|
|
661
|
+
|
|
662
|
+
```javascript
|
|
663
|
+
/**
|
|
664
|
+
* Name of the plugin command
|
|
665
|
+
* { get }
|
|
666
|
+
* @type {String}
|
|
667
|
+
*/
|
|
668
|
+
.name
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Description of the plugin command
|
|
672
|
+
* { get }
|
|
673
|
+
* @type {String}
|
|
674
|
+
*/
|
|
675
|
+
.desc
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* ID of the plugin this command belongs to
|
|
679
|
+
* { get }
|
|
680
|
+
* @type {String}
|
|
681
|
+
*/
|
|
682
|
+
.pluginID
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Name of the plugin this command belongs to.
|
|
686
|
+
* { get }
|
|
687
|
+
* @type {String}
|
|
688
|
+
*/
|
|
689
|
+
.pluginName
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* List of optional argument descriptions for the specific command. Use this if you want to invoke this command from another plugin to inform the user what he nees to enter for example.
|
|
693
|
+
* { get }
|
|
694
|
+
* @type {[String]}
|
|
695
|
+
*/
|
|
696
|
+
.arguments
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
</p>
|
|
700
|
+
</details>
|