You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-10-06 22:17:10 +02:00
All: Use Lerna to manage monorepo
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -168,10 +168,10 @@
|
||||
<pre><code class="language-typescript"><span class="hljs-comment">// Register a new commmand called "testCommand1"</span>
|
||||
|
||||
<span class="hljs-keyword">await</span> joplin.commands.register({
|
||||
name: <span class="hljs-string">'testCommand1'</span>,
|
||||
label: <span class="hljs-string">'My Test Command 1'</span>,
|
||||
iconName: <span class="hljs-string">'fas fa-music'</span>,
|
||||
execute: <span class="hljs-function">() =></span> {
|
||||
<span class="hljs-attr">name</span>: <span class="hljs-string">'testCommand1'</span>,
|
||||
<span class="hljs-attr">label</span>: <span class="hljs-string">'My Test Command 1'</span>,
|
||||
<span class="hljs-attr">iconName</span>: <span class="hljs-string">'fas fa-music'</span>,
|
||||
<span class="hljs-attr">execute</span>: <span class="hljs-function">() =></span> {
|
||||
alert(<span class="hljs-string">'Testing plugin command 1'</span>);
|
||||
},
|
||||
});</code></pre>
|
||||
|
@@ -85,16 +85,16 @@
|
||||
<p>For example:</p>
|
||||
<pre><code class="language-typescript"><span class="hljs-comment">// Get a note ID, title and body</span>
|
||||
<span class="hljs-keyword">const</span> noteId = <span class="hljs-string">'some_note_id'</span>;
|
||||
<span class="hljs-keyword">const</span> note = <span class="hljs-keyword">await</span> joplin.data.get([<span class="hljs-string">'notes'</span>, noteId], { fields: [<span class="hljs-string">'id'</span>, <span class="hljs-string">'title'</span>, <span class="hljs-string">'body'</span>] });
|
||||
<span class="hljs-keyword">const</span> note = <span class="hljs-keyword">await</span> joplin.data.get([<span class="hljs-string">'notes'</span>, noteId], { <span class="hljs-attr">fields</span>: [<span class="hljs-string">'id'</span>, <span class="hljs-string">'title'</span>, <span class="hljs-string">'body'</span>] });
|
||||
|
||||
<span class="hljs-comment">// Get all folders</span>
|
||||
<span class="hljs-keyword">const</span> folders = <span class="hljs-keyword">await</span> joplin.data.get([<span class="hljs-string">'folders'</span>]);
|
||||
|
||||
<span class="hljs-comment">// Set the note body</span>
|
||||
<span class="hljs-keyword">await</span> joplin.data.put([<span class="hljs-string">'notes'</span>, noteId], <span class="hljs-literal">null</span>, { body: <span class="hljs-string">"New note body"</span> });
|
||||
<span class="hljs-keyword">await</span> joplin.data.put([<span class="hljs-string">'notes'</span>, noteId], <span class="hljs-literal">null</span>, { <span class="hljs-attr">body</span>: <span class="hljs-string">"New note body"</span> });
|
||||
|
||||
<span class="hljs-comment">// Create a new note under one of the folders</span>
|
||||
<span class="hljs-keyword">await</span> joplin.data.post([<span class="hljs-string">'notes'</span>], <span class="hljs-literal">null</span>, { body: <span class="hljs-string">"my new note"</span>, title: <span class="hljs-string">"some title"</span>, parent_id: folders[<span class="hljs-number">0</span>].id });</code></pre>
|
||||
<span class="hljs-keyword">await</span> joplin.data.post([<span class="hljs-string">'notes'</span>], <span class="hljs-literal">null</span>, { <span class="hljs-attr">body</span>: <span class="hljs-string">"my new note"</span>, <span class="hljs-attr">title</span>: <span class="hljs-string">"some title"</span>, <span class="hljs-attr">parent_id</span>: folders[<span class="hljs-number">0</span>].id });</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
<!--
|
||||
|
@@ -119,7 +119,7 @@
|
||||
That <code>onStart</code> method will be executed as soon as the plugin is loaded.</p>
|
||||
</div>
|
||||
<pre><code class="language-typescript">joplin.plugins.register({
|
||||
onStart: <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
||||
<span class="hljs-attr">onStart</span>: <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
||||
<span class="hljs-comment">// Run your plugin code here</span>
|
||||
}
|
||||
});</code></pre>
|
||||
|
@@ -431,6 +431,39 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
|
||||
<p>To get the IDs only of all the tags:</p>
|
||||
<pre><code>curl http://localhost:41184/tags?fields=id
|
||||
</code></pre>
|
||||
<p>By default API results will contain the following fields: <strong>id</strong>, <strong>parent_id</strong>, <strong>title</strong></p>
|
||||
<h1>Pagination<a name="pagination" href="#pagination" class="heading-anchor">🔗</a></h1>
|
||||
<p>All API calls that return multiple results will be paginated. The actual results will be under the <code>items</code> key, and if there are more results, there will also be a <code>cursor</code> key, which allows you to fetch the next results. If the <code>cursor</code> key is not present, it means you have reached the end of the data set.</p>
|
||||
<p>You can specify how the results should be sorted using the <code>order_by</code> and <code>order_dir</code> query parameters, and you can specify the number of items to be returned using the <code>limit</code> parameter (the maximum being 100 items).</p>
|
||||
<p>The following call for example will initiate a request to fetch all the notes, 10 at a time, and sorted by "updated_time" ascending:</p>
|
||||
<pre><code>curl http://localhost:41184/notes?order_by=updated_time&order_dir=ASC&limit=10
|
||||
</code></pre>
|
||||
<p>This will return a result like this</p>
|
||||
<pre><code>{ "items": [ /* 10 notes */ ], "cursor": "somecursor" }
|
||||
</code></pre>
|
||||
<p>Then you will resume fetching the results using this query:</p>
|
||||
<pre><code>curl http://localhost:41184/notes?cursor=somecursor
|
||||
</code></pre>
|
||||
<p>Note that you only need to pass the cursor to the next request, as it will continue the fetching process using the same parameters you initially provided.</p>
|
||||
<p>Eventually you will get some results that do not contain a "cursor" paramater, at which point you will have retrieved all the results</p>
|
||||
<p>As an example the pseudo-code below could be used to fetch all the notes:</p>
|
||||
<pre><code class="language-javascript">
|
||||
async function fetchJson(url) {
|
||||
return (await fetch(url)).json();
|
||||
}
|
||||
|
||||
async function fetchAllNotes() {
|
||||
let query = '';
|
||||
const url = 'http://localhost:41184/notes';
|
||||
|
||||
do {
|
||||
const response = await fetchJson(url + query);
|
||||
console.info('Printing notes:');
|
||||
console.info(response.items);
|
||||
query = '?cursor' + response.cursor;
|
||||
} while (response.cursor)
|
||||
}
|
||||
</code></pre>
|
||||
<h1>Error handling<a name="error-handling" href="#error-handling" class="heading-anchor">🔗</a></h1>
|
||||
<p>In case of an error, an HTTP status code >= 400 will be returned along with a JSON object that provides more info about the error. The JSON object is in the format <code>{ "error": "description of error" }</code>.</p>
|
||||
<h1>About the property types<a name="about-the-property-types" href="#about-the-property-types" class="heading-anchor">🔗</a></h1>
|
||||
@@ -516,6 +549,10 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
|
||||
<td>smart_filter</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>command</td>
|
||||
<td>16</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h1>Notes<a name="notes" href="#notes" class="heading-anchor">🔗</a></h1>
|
||||
|
Reference in New Issue
Block a user