@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,588 @@
|
|
|
1
|
+
<details>
|
|
2
|
+
<summary>API</summary>
|
|
3
|
+
<p>
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
NoteObject
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns the relative path of the note (including the folder, like `folder/filename.txt`).
|
|
10
|
+
* Can be also used to set the filename and NotePlan will rename it on disc (available from v3.6)
|
|
11
|
+
* If this note is from a teamspace, the filename will end with the ID of the note and the teamspace in the path will also be an ID, use "resolvedFilename" to display it in a human readable format.
|
|
12
|
+
* { get set }
|
|
13
|
+
* @type {String}
|
|
14
|
+
*/
|
|
15
|
+
.filename
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the relative, resolved path of the note (including the folder, like `folder/filename.txt`).
|
|
20
|
+
* If it's a teamspace note, it replaces the IDs in the path with the name of the teamspace and the name of the note. Teamspace note filenames end otherwise with an ID, and the teamspace is also represented as an ID.
|
|
21
|
+
* Note: Don't use this filename to read or write the note. Use `.filename`, instead.
|
|
22
|
+
* { get }
|
|
23
|
+
* @type {String}
|
|
24
|
+
*/
|
|
25
|
+
.resolvedFilename
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if it's a teamspace note, false if it's a private note.
|
|
29
|
+
* { get }
|
|
30
|
+
* @type {Boolean}
|
|
31
|
+
*/
|
|
32
|
+
.isTeamspaceNote
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the title of the teamspace this note belongs to.
|
|
36
|
+
* { get }
|
|
37
|
+
* @type {String}
|
|
38
|
+
*/
|
|
39
|
+
.teamspaceTitle
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the ID of the teamspace this note belongs to.
|
|
43
|
+
* { get }
|
|
44
|
+
* @type {String}
|
|
45
|
+
*/
|
|
46
|
+
.teamspaceID
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Note: Available from v3.6.1
|
|
50
|
+
* Renames the note. You can also define a folder path. The note will be moved to that folder and the folder will be automatically created.
|
|
51
|
+
* It returns the actual filename. If the filename already exists, a number will be appended. If the filename begins with ".", it will be removed.
|
|
52
|
+
* @param {String}
|
|
53
|
+
* @return {String}
|
|
54
|
+
*/
|
|
55
|
+
.rename(newFilename)
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Type of the note, either "Notes" or "Calendar".
|
|
59
|
+
* { get }
|
|
60
|
+
* @type {String}
|
|
61
|
+
*/
|
|
62
|
+
.type
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Title = first line of the note.
|
|
66
|
+
* { get }
|
|
67
|
+
* @type {String}
|
|
68
|
+
*/
|
|
69
|
+
.title
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Optional date if it's a calendar note
|
|
73
|
+
* { get }
|
|
74
|
+
* @type {Date}
|
|
75
|
+
*/
|
|
76
|
+
.date
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Date and time when the note was last modified.
|
|
80
|
+
* { get }
|
|
81
|
+
* @type {Date}
|
|
82
|
+
*/
|
|
83
|
+
.changedDate
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Date and time of the creation of the note.
|
|
87
|
+
* { get }
|
|
88
|
+
* @type {Date}
|
|
89
|
+
*/
|
|
90
|
+
.createdDate
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* All #hashtags contained in this note.
|
|
94
|
+
* { get }
|
|
95
|
+
* @type {[String]}
|
|
96
|
+
*/
|
|
97
|
+
.hashtags
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* All @mentions contained in this note.
|
|
101
|
+
* { get }
|
|
102
|
+
* @type {[String]}
|
|
103
|
+
*/
|
|
104
|
+
.mentions
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get or set the raw text of the note (means there is no hidden or rendered Markdown). If you set the content, NotePlan will write it immediately to file. If you get the content, it will be read directly from the file.
|
|
108
|
+
* { get set }
|
|
109
|
+
* @type {String}
|
|
110
|
+
*/
|
|
111
|
+
.content
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Same as content, but attached image and file paths are resolved to the absolute path, useful if the note is being copied, like in Templates, so the images are copied over, too. Don't use it by default, because it can cause conflicts due to the different paths in the file vs the variable.
|
|
115
|
+
* { get }
|
|
116
|
+
* @type {String}
|
|
117
|
+
*/
|
|
118
|
+
.contentWithAbsoluteAttachmentPaths
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Get or set paragraphs contained in this note (these can be tasks, plain text, headings...). If you set the paragraph array, it will join them and save the new content to file.
|
|
122
|
+
* { get set }
|
|
123
|
+
* @type {[ParagraphObject]}
|
|
124
|
+
*/
|
|
125
|
+
.paragraphs
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Note: Available from v3.2
|
|
129
|
+
* Get paragraphs contained in this note which contain a link to another (non day) note.
|
|
130
|
+
* @type {[ParagraphObject]}
|
|
131
|
+
* { get }
|
|
132
|
+
*/
|
|
133
|
+
.linkedItems
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Note: Available from v3.2
|
|
137
|
+
* Get paragraphs contained in this note which contain a link to a daily note.
|
|
138
|
+
* { get }
|
|
139
|
+
* @type {[ParagraphObject]}
|
|
140
|
+
*/
|
|
141
|
+
.datedTodos
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Note: Available from v3.2
|
|
145
|
+
* Get all backlinks pointing to the current note as Paragraph objects. In this array, the toplevel items are all notes linking to the current note and the 'subItems' attributes (of the paragraph objects) contain the paragraphs with a link to the current note. The headings of the linked paragraphs are also listed here, although they don't have to contain a link.
|
|
146
|
+
* The content of the paragraphs has normalized indent hierarchy so items that appear without their parents don't look oddly indented
|
|
147
|
+
* { get }
|
|
148
|
+
* @type {[ParagraphObject]}
|
|
149
|
+
*/
|
|
150
|
+
.backlinks
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Note: Available from v3.7.2
|
|
154
|
+
* Get all available versions of a note from the backup database. It returns an array with objects that have following attributes: `content` (full content of the note) and `date` (when this version was saved). You can use this in combination with note triggers and diffs to figure out what has changed inside the note. The first entry in the array is the current version and the second contains the content of the previous version, etc.
|
|
155
|
+
* { get }
|
|
156
|
+
* @type {[{ content: String, date: Date }]}
|
|
157
|
+
*/
|
|
158
|
+
.versions
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Inserts the given text at the given character position (index)
|
|
162
|
+
* @param {String} text - Text to insert
|
|
163
|
+
* @param {Number} index - Position to insert at (you can get this using 'renderedSelection' for example)
|
|
164
|
+
*/
|
|
165
|
+
.insertTextInCharacterIndex(text, index)
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Replaces the text at the given range with the given text
|
|
169
|
+
* @param {String} text - Text to insert
|
|
170
|
+
* @param {Number} location - Position to insert at (you can get this using 'renderedSelection' for example)
|
|
171
|
+
* @param {Number} length - Amount of characters to replace from the location
|
|
172
|
+
*/
|
|
173
|
+
.replaceTextAtCharacterRange(text, location, length)
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Note: Available from v3.4, macOS only
|
|
177
|
+
* Opens the print dialog for the current note, so the user can save it as PDF or print it.
|
|
178
|
+
* @param {Bool}
|
|
179
|
+
*/
|
|
180
|
+
.printNote(withBacklinksAndEvents)
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Note: Available from v3.5
|
|
184
|
+
* Returns all types assigned to this note in the frontmatter as an array of strings.
|
|
185
|
+
* You can assign types to a note with frontmatter using `type: meeting-note, empty-note` for example (comma separated).
|
|
186
|
+
* { get }
|
|
187
|
+
* @type {[String]}
|
|
188
|
+
*/
|
|
189
|
+
.frontmatterTypes
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Returns the frontmatter key-value pairs inside the note.
|
|
193
|
+
* { get }
|
|
194
|
+
* @type {[String:String]}
|
|
195
|
+
*/
|
|
196
|
+
.frontmatterAttributes
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Returns the ordered frontmatter key-value pairs inside the note as individual objects inside an array with two values: "key" and "value". Ordered means they are ordered as they appear in the same order as inside the note.
|
|
200
|
+
* Example:
|
|
201
|
+
* const note = DataStore.projectNoteByTitle("Stoicism")[0]
|
|
202
|
+
* for (const attribute of note.frontmatterAttributesArray) {
|
|
203
|
+
* console.log(attribute.key + ": " + attribute.value)
|
|
204
|
+
* }
|
|
205
|
+
* { get }
|
|
206
|
+
* @type {[[String:String]]}
|
|
207
|
+
*/
|
|
208
|
+
.frontmatterAttributesArray
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Sets a single frontmatter attribute with the given key and value.
|
|
212
|
+
* If the key already exists, updates its value. If it doesn't exist, adds a new key-value pair.
|
|
213
|
+
* @param {string} key - The frontmatter key to set
|
|
214
|
+
* @param {string} value - The value to set for the key
|
|
215
|
+
* Available from v3.18.1
|
|
216
|
+
*/
|
|
217
|
+
.setFrontmatterAttribute(key, value)
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Updates multiple frontmatter attributes at once in a single operation.
|
|
221
|
+
* More efficient than calling setFrontmatterAttribute multiple times as it only reads and writes the note content once.
|
|
222
|
+
* Each attribute object should have "key" and "value" properties.
|
|
223
|
+
* @param {Array<{key: string, value: string}>} attributes - Array of key-value pairs to update
|
|
224
|
+
* @example
|
|
225
|
+
* note.updateFrontmatterAttributes([
|
|
226
|
+
* { key: "title", value: "My Title" },
|
|
227
|
+
* { key: "type", value: "project" },
|
|
228
|
+
* { key: "status", value: "draft" }
|
|
229
|
+
* ])
|
|
230
|
+
* Available from v3.18.1
|
|
231
|
+
*/
|
|
232
|
+
.updateFrontmatterAttributes(attributes)
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Note: Available from v3.9.1
|
|
236
|
+
* Returns the database record ID of the published note (on CloudKit). Returns null if the note is not published yet.
|
|
237
|
+
* Use this to verify if a note has been published and to build the public link: https://noteplan.co/n/{publicRecordID}
|
|
238
|
+
* { get }
|
|
239
|
+
* @type {String?}
|
|
240
|
+
*/
|
|
241
|
+
.publicRecordID
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Note: Available from v3.9.1
|
|
245
|
+
* Publishes the note using CloudKit (inserts a record on the public database). Build the web-link to the note by using the publicRecordID.
|
|
246
|
+
* @return {Promise}
|
|
247
|
+
*/
|
|
248
|
+
.publish()
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Note: Available from v3.9.1
|
|
252
|
+
* Unpublishes the note from CloudKit (deletes the database entry from the public database).
|
|
253
|
+
* @return {Promise}
|
|
254
|
+
*/
|
|
255
|
+
.unpublish()
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Note: Available from v3.9.3
|
|
259
|
+
* Returns the conflicted version if any. Otherwise, returns undefined.
|
|
260
|
+
* @return { Object(filename: String, url: string, content: String) }
|
|
261
|
+
*/
|
|
262
|
+
.conflictedVersion
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Note: Available from v3.9.3
|
|
266
|
+
* Resolves a conflict, if any, using the current version (which is version 1 in the conflict bar inside the UI). Once resolved you need to reload the note.
|
|
267
|
+
*/
|
|
268
|
+
.resolveConflictWithCurrentVersion()
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Note: Available from v3.9.3
|
|
273
|
+
* Resolves a conflict, if any, using the other version (which is version 2 in the conflict bar inside the UI). Once resolved you need to reload the note.
|
|
274
|
+
*/
|
|
275
|
+
.resolveConflictWithOtherVersion()
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
</p>
|
|
279
|
+
</details>
|
|
280
|
+
|
|
281
|
+
<details>
|
|
282
|
+
<summary>API - Paragraphs</summary>
|
|
283
|
+
<p>
|
|
284
|
+
|
|
285
|
+
```javascript
|
|
286
|
+
|
|
287
|
+
/* When you are changing the text in the note through the functions below,
|
|
288
|
+
* they are saved immediately. But it takes a few seconds for NotePlan to register
|
|
289
|
+
* the file changes and update the UI. So the editor content will update with a delay.
|
|
290
|
+
* If you want the changes to appear immediately, use the `Editor.*` functions.
|
|
291
|
+
|
|
292
|
+
* When you get the list of paragraphs from the note and then make changes that
|
|
293
|
+
* alter the line indeces of other paragraphs (like in the case of insert...,
|
|
294
|
+
* remove..., etc.), you need to get a new array of paragraphs to keep
|
|
295
|
+
* changing them. Paragraphs have no IDs and so NotePlan relies on the
|
|
296
|
+
* line index to match them up. So if the index changes, the reference is lost.
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
NoteObject
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Returns a range object of the full paragraph of the given character position.
|
|
303
|
+
* @param {Number} pos - Character position
|
|
304
|
+
* @return {RangeObject} - The range of the paragraph = { .start, .end, .length }
|
|
305
|
+
*/
|
|
306
|
+
.paragraphRangeAtCharacterIndex(pos)
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Inserts a plain paragrah at the given line index
|
|
310
|
+
* @param {String} content - Text of the paragraph
|
|
311
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
312
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} type
|
|
313
|
+
*/
|
|
314
|
+
.insertParagraph(content, lineIndex, type)
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Inserts a todo at the given line index
|
|
318
|
+
* @param {String} content - Name of the todo (without the todo '* [ ] ' Markdown)
|
|
319
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
320
|
+
*/
|
|
321
|
+
.insertTodo(content, lineIndex)
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Inserts a completed todo at the given line index
|
|
325
|
+
* @param {String} content - Text of the completed todo (without the todo '* [x] ' Markdown)
|
|
326
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
327
|
+
*/
|
|
328
|
+
.insertCompletedTodo(content, lineIndex)
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Inserts a cancelled todo at the given line index
|
|
332
|
+
* @param {String} content - Text of the cancelled todo (without the todo '* [-] ' Markdown)
|
|
333
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
334
|
+
*/
|
|
335
|
+
.insertCancelledTodo(content, lineIndex)
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Inserts a scheduled todo at the given line index
|
|
339
|
+
* @param {String} content - Text of the scheduled todo (without the todo '* [>] ' Markdown)
|
|
340
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
341
|
+
* @param {Date} date - (optional) JavaScript date object if you need the date link '>YYYY-MM-DD'
|
|
342
|
+
*/
|
|
343
|
+
.insertScheduledTodo(content, lineIndex, date)
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Inserts a quote at the given line index
|
|
347
|
+
* @param {String} content - Text of the quote (without the quote '> ' Markdown)
|
|
348
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
349
|
+
*/
|
|
350
|
+
.insertQuote(content, lineIndex)
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Inserts a list (bullet) item at the given line index
|
|
354
|
+
* @param {String} content - Text of the bullet (without the bullet '- ' Markdown)
|
|
355
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
356
|
+
*/
|
|
357
|
+
.insertList(content, lineIndex)
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Inserts a heading at the given line index
|
|
361
|
+
* @param {String} content - Text of the heading (without the heading '## ' Markdown)
|
|
362
|
+
* @param {Number} lineIndex - Line index where the todo should be inserted
|
|
363
|
+
* @param {Number} level - Heading level, 1 - based, for example 2 = "## <text>"
|
|
364
|
+
*/
|
|
365
|
+
.insertHeading(content, lineIndex, level)
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Appends a todo at the end of the note
|
|
369
|
+
* @param {String} content - Text of the todo (without the heading '* [ ] ' Markdown)
|
|
370
|
+
*/
|
|
371
|
+
.appendTodo(content)
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Prepends a todo at the beginning of the note (after the title heading)
|
|
375
|
+
* @param {String} content - Text of the todo (without the heading '* [ ] ' Markdown)
|
|
376
|
+
*/
|
|
377
|
+
.prependTodo(content)
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Appends a paragraph at the end of the note
|
|
381
|
+
* @param {String} content - Text of the paragaraph
|
|
382
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} type
|
|
383
|
+
*/
|
|
384
|
+
.appendParagraph(content, type)
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Prepends a paragraph at the beginning of the note (after the title heading)
|
|
388
|
+
* @param {String} content - Text of the paragaraph
|
|
389
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} type
|
|
390
|
+
*/
|
|
391
|
+
.prependParagraph(content, type)
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Inserts a todo below the given title of a heading (at the beginning or end of existing text)
|
|
395
|
+
* @param {String} content - Text of the todo
|
|
396
|
+
* @param {String} headingTitle - Title of the heading (without '# Markdown)
|
|
397
|
+
* @param {Boolean} shouldAppend - If the todo should be appended at the bottom of existing text
|
|
398
|
+
* @param {Boolean} shouldCreate - If the heading should be created if non-existing
|
|
399
|
+
*/
|
|
400
|
+
.addTodoBelowHeadingTitle(content, headingTitle, shouldAppend, shouldCreate)
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Inserts a paragraph below the given title of a heading (at the beginning or end of existing text)
|
|
404
|
+
* @param {String} content - Text of the paragraph
|
|
405
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} paragraphType
|
|
406
|
+
* @param {String} headingTitle - Title of the heading (without '# Markdown)
|
|
407
|
+
* @param {Boolean} shouldAppend - If the todo should be appended at the bottom of existing text
|
|
408
|
+
* @param {Boolean} shouldCreate - If the heading should be created if non-existing
|
|
409
|
+
*/
|
|
410
|
+
.addParagraphBelowHeadingTitle(content, paragraphType, headingTitle, shouldAppend: Bool, shouldCreate)
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Appends a todo below the given heading index (at the end of existing text)
|
|
414
|
+
* @param {String} content - Text of the todo
|
|
415
|
+
* @param {Number} headinLineIndex - Line index of the heading (get the line index from a paragraph object)
|
|
416
|
+
*/
|
|
417
|
+
.appendTodoBelowHeadingLineIndex(content, headinLineIndex)
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Appends a paragraph below the given heading index (at the end of existing text)
|
|
421
|
+
* @param {String} content - Text of the paragraph
|
|
422
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} paragraphType
|
|
423
|
+
* @param {Number} headinLineIndex - Line index of the heading (get the line index from a paragraph object)
|
|
424
|
+
*/
|
|
425
|
+
.appendParagraphBelowHeadingLineIndex(content, paragraphType, headinLineIndex)
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Inserts a todo after a given paragraph
|
|
429
|
+
* @param {String} content - Text of the paragraph
|
|
430
|
+
* @param {ParagraphObject} otherParagraph - Another paragraph, get it from `.paragraphs`
|
|
431
|
+
*/
|
|
432
|
+
.insertTodoAfterParagraph(content, otherParagraph)
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Inserts a todo before a given paragraph
|
|
436
|
+
* @param {String} content - Text of the paragraph
|
|
437
|
+
* @param {ParagraphObject} otherParagraph - Another paragraph, get it from `.paragraphs`
|
|
438
|
+
*/
|
|
439
|
+
.insertTodoBeforeParagraph(content, otherParagraph)
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Inserts a paragraph after a given paragraph
|
|
443
|
+
* @param {String} content - Text of the paragraph
|
|
444
|
+
* @param {ParagraphObject} otherParagraph - Another paragraph, get it from `.paragraphs`
|
|
445
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} paragraphType
|
|
446
|
+
*/
|
|
447
|
+
.insertParagraphAfterParagraph(content, otherParagraph, paragraphType)
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Inserts a paragraph before a given paragraph
|
|
451
|
+
* @param {String} content - Text of the paragraph
|
|
452
|
+
* @param {ParagraphObject} otherParagraph - Another paragraph, get it from `.paragraphs`
|
|
453
|
+
* @param {"open", "done", "scheduled", "cancelled", "quote", "title", "list" (= bullet), "text" (= plain text) or "empty" (= no text)} paragraphType
|
|
454
|
+
*/
|
|
455
|
+
.insertParagraphBeforeParagraph(content, otherParagraph, paragraphType)
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Removes a paragraph at a given line index
|
|
459
|
+
* @param {Number} lineIndex - Line index of the paragraph
|
|
460
|
+
*/
|
|
461
|
+
.removeParagraphAtIndex(lineIndex)
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Removes a given paragraph. If you need to remove multiple paragraphs, prefer using `.removeParagraphs(ps)`, which is safer.
|
|
465
|
+
* @param {ParagraphObject} paragraph - Paragraph object to remove, get it from `.paragraphs`
|
|
466
|
+
*/
|
|
467
|
+
.removeParagraph(paragraph)
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Removes an array paragraphs
|
|
471
|
+
* @param {[ParagraphObject]} paragraphs - Paragraph objects to remove, get it from `.paragraphs`
|
|
472
|
+
*/
|
|
473
|
+
.removeParagraphs(paragraphs)
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Updates a given paragraph. Get the paragraph, then modify it and update the text in the note or editor using this method.
|
|
477
|
+
* @param {ParagraphObject} paragraph - Paragraph object to update, get it from `.paragraphs`
|
|
478
|
+
*/
|
|
479
|
+
.updateParagraph(paragraph)
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Updates an array paragraphs. Get the paragraphs, then modify them and update the text in the note or editor using this method.
|
|
483
|
+
* @param {[ParagraphObject]} paragraphs - Paragraph objects to update, get it from `.paragraphs`
|
|
484
|
+
*/
|
|
485
|
+
.updateParagraphs(paragraphs)
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Note: Available from v3.5.2
|
|
489
|
+
* Generates a unique block ID and adds it to the content of this paragraph. Remember to call .updateParagraph(p) to write it to the note. You can call this on the Editor or note you got the paragraph from.
|
|
490
|
+
* @param {ParagraphObject}
|
|
491
|
+
*/
|
|
492
|
+
.addBlockID(paragraph)
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Note: Available from v3.5.2
|
|
496
|
+
* Removes the unique block ID, if it exists in the content. Remember to call .updateParagraph(p) to write it to the note afterwards. You can call this on the Editor or note you got the paragraph from.
|
|
497
|
+
* @param {ParagraphObject}
|
|
498
|
+
*/
|
|
499
|
+
.removeBlockID(paragraph)
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
</p>
|
|
503
|
+
</details>
|
|
504
|
+
|
|
505
|
+
<details>
|
|
506
|
+
<summary>Examples</summary>
|
|
507
|
+
<p>
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
```javascript
|
|
511
|
+
function overwriteNote() {
|
|
512
|
+
var note = DataStore.projectNoteByFilename("TEST.txt")
|
|
513
|
+
if(note != undefined) {
|
|
514
|
+
note.content = "# TEST\nThis is new content with random number: " + Math.floor(Math.random() * 100)
|
|
515
|
+
} else {
|
|
516
|
+
console.log("Note not found! - Create a note 'TEST.txt'.")
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
async function addTaskToNote() {
|
|
521
|
+
try {
|
|
522
|
+
let notes = DataStore.projectNotes
|
|
523
|
+
|
|
524
|
+
// CommandBar.showOptions only takes [string] as input
|
|
525
|
+
let re = await CommandBar.showOptions(notes.map(n => n.title), "Select note for new todo")
|
|
526
|
+
let note = notes[re.index]
|
|
527
|
+
|
|
528
|
+
let todoTitle = await CommandBar.showInput("Type the task", "Add task '%@' to '" + note.title + "'")
|
|
529
|
+
note.insertTodo(todoTitle, 1)
|
|
530
|
+
} catch (error) {
|
|
531
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function addTaskToHeading() {
|
|
536
|
+
try {
|
|
537
|
+
// addTodoBelowHeading(todoTitle, headingTitle, true or false = should append, true or false = should create if non-existing)
|
|
538
|
+
// First ask for the note we want to add the todo
|
|
539
|
+
let notes = DataStore.projectNotes
|
|
540
|
+
|
|
541
|
+
// CommandBar.showOptions only takes [string] as input
|
|
542
|
+
let re = await CommandBar.showOptions(notes.map(n => n.title), "Select note for new todo")
|
|
543
|
+
let note = notes[re.index]
|
|
544
|
+
printNote(note)
|
|
545
|
+
|
|
546
|
+
// Ask to which heading to add the todo
|
|
547
|
+
let headings = note.paragraphs.filter(p => p.type == "title")
|
|
548
|
+
let re2 = await CommandBar.showOptions(headings.map(p => (p.prefix + p.content)), "Select a heading")
|
|
549
|
+
|
|
550
|
+
let heading = headings[re2.index]
|
|
551
|
+
console.log("Selected heading: " + heading.content)
|
|
552
|
+
|
|
553
|
+
// Ask for the todo title finally
|
|
554
|
+
let todoTitle = await CommandBar.showInput("Type the task", "Add task '%@' to '" + note.title + "'")
|
|
555
|
+
console.log("Adding todo: " + todoTitle + " to " + note.title + " in heading: " + heading.content)
|
|
556
|
+
|
|
557
|
+
// Add todo to the heading in the note
|
|
558
|
+
note.appendTodoBelowHeadingLineIndex(todoTitle, heading.lineIndex) // This works also if there are duplicate headings
|
|
559
|
+
// note.appendParagraphBelowHeadingLineIndex(todoTitle, "quote", heading.lineIndex)
|
|
560
|
+
// note.addTodoBelowHeadingTitle(todoTitle, heading.content, false, true)
|
|
561
|
+
// note.addParagraphBelowHeadingTitle(todoTitle, "done", heading.content, true, true)
|
|
562
|
+
// note.insertTodoAfterParagraph(todoTitle, heading.content)
|
|
563
|
+
// note.insertTodoBeforeParagraph(todoTitle, heading.content)
|
|
564
|
+
// note.insertParapgrahBeforeParagraph(todoTitle, heading.content, "list")
|
|
565
|
+
// note.insertParagraphAfterParagraph(todoTitle, heading.content, "list")
|
|
566
|
+
} catch (error) {
|
|
567
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
async function assignBlockID() {
|
|
572
|
+
try {
|
|
573
|
+
let note = DataStore.projectNoteByTitle("Note A")[0]
|
|
574
|
+
let para = note.paragraphs
|
|
575
|
+
note.addBlockID(para[1])
|
|
576
|
+
note.updateParagraph(para[1])
|
|
577
|
+
} catch (error) {
|
|
578
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// See more Paragraph examples under "Editor" in the documentation.
|
|
583
|
+
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
</p>
|
|
587
|
+
</details>
|
|
588
|
+
|