@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,198 @@
1
+ <details>
2
+ <summary>API</summary>
3
+ <p>
4
+
5
+ ```javascript
6
+ CalendarItem
7
+
8
+ /**
9
+ * The ID of the event or reminder after it has been created by `Calendar.add(calendarItem)`.
10
+ * The ID is not set in the original CalendarItem, you need to use the return value of `Calendar.add(calendarItem)` to get it.
11
+ * Use the ID later to refer to this event (to modify or delete).
12
+ * @type {String}
13
+ */
14
+ .id
15
+
16
+ /**
17
+ * The title of the event or reminder.
18
+ * @type {String}
19
+ */
20
+ .title
21
+
22
+ /**
23
+ * The date (with time) of the event or reminder.
24
+ * @type {Date}
25
+ */
26
+ .date
27
+
28
+ /**
29
+ * The endDate (with time) of the event (reminders have no endDate). So, this can be optional.
30
+ * @type {Date}
31
+ */
32
+ .endDate
33
+
34
+ /**
35
+ * The type of the calendar item, either "event" or "reminder".
36
+ * @type {String}
37
+ */
38
+ .type
39
+
40
+ /**
41
+ * If the calendar item is all-day, means it has no specific time.
42
+ * @type {Boolean}
43
+ */
44
+ .isAllDay
45
+
46
+ /**
47
+ * If the calendar item is completed. This applies only to reminders.
48
+ * Note: Available from v3.0.15
49
+ * @type {Boolean}
50
+ */
51
+ .isCompleted
52
+
53
+ /**
54
+ * All the dates the event or reminder occurs (if it's a multi-day event for example)
55
+ * Note: Available from v3.0.15
56
+ * @type {[Date]}
57
+ */
58
+ .occurences
59
+
60
+ /**
61
+ * The calendar or reminders list where this event or reminder is (or should be) saved. If you set nothing, the event or reminder will be added to the default and this field will be set after adding.
62
+ * Note: Available from v3.0.15
63
+ * @type {String}
64
+ */
65
+ .calendar
66
+
67
+ /**
68
+ * The color of the calendar or reminders list where this event or reminder belongs, as a hex color string (e.g., "#5A9FD4").
69
+ * This is a read-only property that reflects the actual color assigned to the calendar in the system calendar app.
70
+ * Note: Available from v3.20
71
+ * @type {String}
72
+ */
73
+ .color
74
+
75
+ /**
76
+ * Text saved in the "Notes" field of the event or reminder.
77
+ * Note: Available from v3.0.26
78
+ * @type {String}
79
+ */
80
+ .notes
81
+
82
+ /**
83
+ * URL saved with the event or reminder.
84
+ * Note: Available from v3.0.26
85
+ * @type {String}
86
+ */
87
+ .url
88
+
89
+ /**
90
+ * If supported, shows the availability. The default is 0 = busy.
91
+ * notSupported = -1
92
+ * busy = 0
93
+ * free = 1
94
+ * tentative = 2
95
+ * unavailable = 3
96
+ * Note: Available from v3.3
97
+ * @type {Int}
98
+ */
99
+ .availability
100
+
101
+ /**
102
+ * List of attendee names or emails as links.
103
+ * Note: Available from v3.5
104
+ * @type {[String]}
105
+ */
106
+ .attendees
107
+
108
+ /**
109
+ * List of attendee names or emails as plain text.
110
+ * Note: Available from v3.5.2
111
+ * @type {[String]}
112
+ */
113
+ .attendeeNames
114
+
115
+ /**
116
+ * Markdown link for the given event. If you add this link to a note, NotePlan will link the event with the note and show the note in the dropdown when you click on the note icon of the event in the sidebar.
117
+ * Note: Available from v3.5, only events, reminders are not supported yet
118
+ * @type {String}
119
+ */
120
+ .calendarItemLink
121
+
122
+ /**
123
+ * Note: Available in 3.9.1
124
+ * Searches and returns all filenames it's linked to (meeting notes). Use with await. Returns an array of filenames.
125
+ * @type {Promise([String])}
126
+ */
127
+ .findLinkedFilenames()
128
+
129
+ /**
130
+ * Creates a CalendarItem. The .endDate is optional, but recommended for events. Reminders don't use this field.
131
+ * The type can be "event" or "reminder". And isAllDay can be used if you don't want to define a specific time, like holidays.
132
+ * Use the calendar variable, if you want to add the event or reminder to another calendar or reminders list other than the default. This is optional, if you set nothing, it will use the default.
133
+ * Use isCompleted only for reminders, by default it's false if you set nothing.
134
+ * @param {String}
135
+ * @param {Date}
136
+ * @param {Date}
137
+ * @param {String}
138
+ * @param {Boolean?}
139
+ * @param {String?} - Available from v3.0.15
140
+ * @param {Boolean?} - Available from v3.0.15
141
+ * @param {String?} - Available from v3.0.26
142
+ * @param {String?} - Available from v3.0.26
143
+ * @param {Int?} - Available from v3.3
144
+ * @return {CalendarItem}
145
+ */
146
+ .create(title, date, endDate, type, isAllDay, calendar, isCompleted, notes, url, availability)
147
+ ```
148
+
149
+ </p>
150
+ </details>
151
+
152
+ <details>
153
+ <summary>Examples</summary>
154
+ <p>
155
+
156
+ ```javascript
157
+ async function createEvent() {
158
+ try {
159
+ let title = await CommandBar.showInput("Enter the title of the event", "Submit title '%@', then...")
160
+
161
+ // To make this work you need to enter '2021/04/12 09:00' for example
162
+ let dateText = await CommandBar.showInput("Enter date", "Create event '" + title + "' with date '%@'")
163
+
164
+ console.log("dateText: " + dateText)
165
+
166
+ // Parses date and time text such as 'today at 5pm - 7pm'
167
+ let dates = Calendar.parseDateText(dateText)
168
+
169
+ if(dates.length >= 0) {
170
+ let parsed = dates[0]
171
+ let start = parsed.start
172
+ let end = parsed.start
173
+
174
+ if(parsed.end !== undefined) {
175
+ end = parsed.end
176
+ }
177
+
178
+ console.log("parsed start: '" + start + ", end: '" + end + "' from text: '" + dateText + "'")
179
+
180
+ // CalendarItem.create(title, start date, optional end date, "event" or "reminder", isAllDay)
181
+ var event = CalendarItem.create(title, start, end, "event", false, "", false, "hello world", "https://noteplan.co")
182
+ var createdEvent = Calendar.add(event)
183
+
184
+ if(createdEvent != undefined) {
185
+ console.log("Event created with id: " + createdEvent.id)
186
+ } else {
187
+ console.log("Failed to create event")
188
+ }
189
+ }
190
+ } catch (error) {
191
+ console.log("Plugin code error: \n"+JSON.stringify(error))
192
+ }
193
+ }
194
+ ```
195
+
196
+ </p>
197
+ </details>
198
+
@@ -0,0 +1,101 @@
1
+ Clipboard.md
2
+
3
+ <details>
4
+ <summary>API</summary>
5
+ <p>
6
+
7
+ ```javascript
8
+ Clipboard
9
+
10
+ /**
11
+ * Get or set the current text of the clipboard.
12
+ * @type {String}
13
+ */
14
+ .string
15
+
16
+ /**
17
+ * Returns a list of types.
18
+ * @type {[String]}
19
+ */
20
+ .types
21
+
22
+ /**
23
+ * Set the text of the clipboard using a specific type.
24
+ * @param {String}
25
+ * @param {String}
26
+ */
27
+ .setStringForType(string, type)
28
+
29
+ /**
30
+ * Get the text in the clipboard accessing a specific type.
31
+ * @param {String}
32
+ * @return {String}
33
+ */
34
+ .stringForType(type)
35
+
36
+ /**
37
+ * Set the data as base64 string for a specific type like an image or RTF.
38
+ * @param {String}
39
+ * @param {String}
40
+ */
41
+ .setBase64DataStringForType(base64String, type)
42
+
43
+ /**
44
+ * Get the base64 data string for a specific type like an image or RTF from the clipboard.
45
+ * @param {String}
46
+ * @return {String}
47
+ */
48
+ .base64DataStringForType(type)
49
+
50
+ /**
51
+ * Get the data in the clipboard accessing a specific type.
52
+ * @param {String}
53
+ * @return {Data}
54
+ */
55
+ .dataForType(type)
56
+
57
+ /**
58
+ * Set the data in the clipboard for a specific type.
59
+ * @param {Data}
60
+ * @param {String}
61
+ */
62
+ .setDataForType(data, type)
63
+
64
+ /**
65
+ * Clears the contents of the clipboard.
66
+ */
67
+ .clearContents()
68
+
69
+ /**
70
+ * Pass in the types you are interested in and get the available type back.
71
+ * @param {[String]}
72
+ * @return {String}
73
+ */
74
+ .availableType(fromTypes)
75
+
76
+ ```
77
+
78
+ </p>
79
+ </details>
80
+
81
+ <details>
82
+ <summary>Examples</summary>
83
+ <p>
84
+
85
+
86
+ ```javascript
87
+
88
+ function test() {
89
+ console.log("inside the clipboard: " + Clipboard.string)
90
+ Clipboard.string = "hello world"
91
+ }
92
+
93
+ function seeTypes() {
94
+ console.log("types: " + Clipboard.types)
95
+ }
96
+
97
+ ```
98
+
99
+ </p>
100
+ </details>
101
+
@@ -0,0 +1,251 @@
1
+ <details>
2
+ <summary>API - CommandBar</summary>
3
+ <p>
4
+
5
+ ```javascript
6
+ CommandBar
7
+
8
+ /**
9
+ * Get or set the current text input placeholder (what you can read when no input is typed in) of the Command Bar.
10
+ * @type {String}
11
+ */
12
+ .placeholder
13
+
14
+ /**
15
+ * Get the current text input content of the Command Bar (what the user normally types in).
16
+ * @type {String}
17
+ */
18
+ .searchText
19
+
20
+ /**
21
+ * Hides the Command Bar
22
+ */
23
+ .hide()
24
+
25
+ /**
26
+ * Display an array of choices as a list which the user can "fuzzy-search" filter by typing something.
27
+ * The user selection is returned as a Promise. So use it with "await CommandBar.showOptions(...)".
28
+ * The result is a CommandBarResultObject (as Promise success result), which has ".value" and ".index".
29
+ *
30
+ * Options can be provided in two formats:
31
+ * 1. String array (for backward compatibility): ["Option 1", "Option 2", ...]
32
+ * 2. Object array (available from v3.18) with properties:
33
+ * - text: string (required) - The display text
34
+ * - icon: string (optional) - Icon to display (FontAwesome icon name)
35
+ * - shortDescription: string (optional) - Text displayed on the right side
36
+ * - color: string (optional) - Color for the icon (hex like "#FF0000" or tailwind color name)
37
+ * - shortDescriptionColor: string (optional) - Color for the description text (hex or tailwind)
38
+ * - alpha: number (optional) - Opacity for the icon and shortDescription (0-1). Default opacity will be used if not specified
39
+ * - darkAlpha: number (optional) - Opacity for the icon and shortDescription for the dark theme (0-1). Default opacity will be used if not specified
40
+ *
41
+ * Example object format:
42
+ * [
43
+ * { text: "Option 1", icon: "star", color: "#FFD700" },
44
+ * { text: "Option 2", icon: "check", shortDescription: "Premium", shortDescriptionColor: "#00FF00" },
45
+ * { text: "Option 3", icon: "info", shortDescription: "Beta feature", alpha: 0.8, darkAlpha: 0.9 }
46
+ * ]
47
+ *
48
+ * Use the ".index" attribute to refer back to the selected item in the original array.
49
+ * If you want to provide an existing search text that will be inserted into the command bar, use the third parameter.
50
+ *
51
+ * @param {[String]|[Object]} options - Array of strings or objects with options
52
+ * @param {String} placeholder - Placeholder text for the search input
53
+ * @param {String} searchText - Initial search text to populate
54
+ * @return {Promise<CommandBarResultObject>} - Promise resolving to result with .value and .index
55
+ */
56
+ .showOptions(options, placeholder, searchText)
57
+
58
+ /**
59
+ * Asks the user to enter something into the CommandBar.
60
+ * Use the "placeholder" value to display a question, like "Type the name of the task".
61
+ * Use the "submitText" to describe what happens with the selection, like "Create task named '%@'".
62
+ * The "submitText" value supports the variable "%@" in the string, that NotePlan autofills with the typed text.
63
+ * It returns a Promise, so you can wait (using "await...") for the user input with the entered text as success result.
64
+ * If you want to provide an existing search text that will be inserted into the command bar, use the third variable.
65
+ * @param {String}
66
+ * @param {String}
67
+ * @param {String}
68
+ * @return {Promise (String)}
69
+ */
70
+ .showInput(placeholder, submitText, searchText)
71
+
72
+ /**
73
+ * Note: Available from v3.0.25
74
+ * Shows or hides a window with a loading indicator or a progress ring (if progress is defined) and an info text (optional).
75
+ * `text` is optional, if you define it, it will be shown below the loading indicator.
76
+ * `progress` is also optional. If it's defined, the loading indicator will change into a progress ring. Use float numbers from 0-1 to define how much the ring is filled.
77
+ * When you are done, call `showLoading(false)` to hide the window. See an example function in the example section below.
78
+ * @param {Bool}
79
+ * @param {String?}
80
+ * @param {Float?}
81
+ */
82
+ .showLoading(visible, text, progress)
83
+
84
+ /**
85
+ * Note: Available from v3.0.25
86
+ * If you call this, anything after `await CommandBar.onAsyncThread()` will run on an asynchronous thread.
87
+ * Use this together with `showLoading`, so that the work you do is not blocking the user interface.
88
+ * Otherwise the loading window will be also blocked.
89
+ *
90
+ * Warning: Don't use any user interface calls (other than showLoading) on an asynchronous thread. The app might crash.
91
+ * You need to return to the main thread before you change anything in the window (such as Editor functions do).
92
+ * Do not call any functions from Editor.* on an async thread.
93
+ * Use `onMainThread()` to return to the main thread. See an example function in the example section below.
94
+ * @return {Promise}
95
+ */
96
+ .onAsyncThread()
97
+
98
+ /**
99
+ * Note: Available from v3.0.25
100
+ * If you call this, anything after `await CommandBar.onMainThread()` will run on the main thread.
101
+ * Call this after `onAsyncThread`, once your background work is done.
102
+ * It is safe to call Editor and other user interface functions on the main thread.
103
+ * See an example function in the example section below.
104
+ * @return {Promise}
105
+ */
106
+ .onMainThread()
107
+
108
+ /**
109
+ * Note: Available from v3.3.2
110
+ * Show a native prompt to the user with a title and a message text. Define at least one button for the user to select (the parameter is an array of strings, each string the title of a button). If you don't supply any buttons, an "OK" button will be displayed. The promise returns as value the pressed button index (i.e. "0" would be the first supplied button).
111
+ * @param {String}
112
+ * @param (String)
113
+ * @param ([String]?)
114
+ * @return {Promise<Int>}
115
+ */
116
+ .prompt(title, message, buttons)
117
+
118
+ /**
119
+ * Note: Available from v3.3.2
120
+ * Show a native text input prompt to the user with a title and a message text. The buttons will be automatically "OK" and "Cancel". You can supply a default text which will be prefilled. If the user hits "Cancel", the promise returns false.
121
+ * @param {String}
122
+ * @param (String)
123
+ * @param (String?)
124
+ * @return {Promise<Bool | String>}
125
+ */
126
+ .textPrompt(title, message, defaultText)
127
+ ```
128
+
129
+ </p>
130
+ </details>
131
+
132
+ <details>
133
+ <summary>API - CommandBarObject</summary>
134
+ <p>
135
+
136
+ ```javascript
137
+ CommandBarObject
138
+
139
+ /**
140
+ * Get the index of the selected option based on the list used in `CommandBar.showOptions(...)`.
141
+ * @type {Int}
142
+ */
143
+ .index
144
+
145
+ /**
146
+ * Get the value of the selected option based on the list used in `CommandBar.showOptions(...)`.
147
+ * @type {String}
148
+ */
149
+ .value
150
+
151
+ /**
152
+ * Available in v3.7
153
+ * Get the keyboard modifier ("cmd", "opt", "shift", "ctrl") that were pressed while selecting a result.
154
+ * @type {[String]}
155
+ */
156
+ .keyModifiers
157
+ ```
158
+
159
+ </p>
160
+ </details>
161
+
162
+ <details>
163
+ <summary>Examples</summary>
164
+ <p>
165
+
166
+
167
+ ```javascript
168
+
169
+ async function createNote() {
170
+ try {
171
+ let title = await CommandBar.showInput("Enter title of the new note", "Create a new note with title = '%@'")
172
+ let folder = await CommandBar.showOptions(DataStore.folders, "Select a folder for '" + title + "'")
173
+
174
+ if(title != undefined && title !== "") {
175
+ var filename = DataStore.newNote(title, folder.value)
176
+ console.log("Created note with filename: " + filename)
177
+ } else {
178
+ console.log("Title undefined or empty: " + title)
179
+ }
180
+ } catch (error) {
181
+ console.log("Plugin code error: \n"+JSON.stringify(error))
182
+ }
183
+ }
184
+
185
+ async function inputTest() {
186
+ try {
187
+ var reply = await CommandBar.showInput("1. Enter something", "Submit '%@'")
188
+ console.log("Reply: " + reply)
189
+ } catch (error) {
190
+ console.log("Plugin code error: \n"+JSON.stringify(error))
191
+ }
192
+ }
193
+
194
+ async function addTaskToNote() {
195
+ try {
196
+ let notes = DataStore.projectNotes
197
+
198
+ // CommandBar.showOptions only takes [string] as input
199
+ let re = await CommandBar.showOptions(notes.map(n => n.title), "Select note for new todo")
200
+ let note = notes[re.index] // Use .index to refer to the original array
201
+
202
+ let todoTitle = await CommandBar.showInput("Type the task", "Add task '%@' to '" + note.title + "'")
203
+ note.insertTodo(todoTitle, 1)
204
+ } catch (error) {
205
+ console.log("Plugin code error: \n"+JSON.stringify(error))
206
+ }
207
+ }
208
+
209
+ async function loadingDemo() {
210
+ try {
211
+ // Show the loading indicator with text
212
+ CommandBar.showLoading(true, "doing some work")
213
+
214
+ // Begin an asynchronous thread, so the loading indicator won't be blocked
215
+ await CommandBar.onAsyncThread()
216
+
217
+ // Do some arbitrary work
218
+ let total = 50000000
219
+ for (let i = 0; i < total; i++) {
220
+ let a = i * i
221
+
222
+ if(i % 1000000 == 0) {
223
+ // Show progress
224
+ CommandBar.showLoading(true, "doing some work", i / total)
225
+ }
226
+ }
227
+
228
+ // Switch back to the main thread, so we can make edits to the Editor
229
+ await CommandBar.onMainThread()
230
+ CommandBar.showLoading(false)
231
+ } catch (error) {
232
+ console.log("Plugin code error: \n"+JSON.stringify(error))
233
+ }
234
+ }
235
+
236
+ async function demoPrompt() {
237
+ try {
238
+ let typedText = await CommandBar.textPrompt("Your dialog title", "Your detailed message", "some default text")
239
+ console.log("typedText: " + typedText) // Will be 1 if user hits cancel
240
+
241
+ let buttonIndex = await CommandBar.prompt("Your dialog title", "Your message", ["OK", "Cancel", "third", "fourth"])
242
+ console.log("buttonIndex: " + buttonIndex)
243
+ } catch (error) {
244
+ console.log("Plugin code error: \n"+JSON.stringify(error))
245
+ }
246
+ }
247
+ ```
248
+
249
+ </p>
250
+ </details>
251
+