From 35597ce3c27a042679264ec098a7cd6d6f55da18 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 27 Jan 2021 13:00:10 +0000 Subject: [PATCH] Doc: Updated doc for resource creation from a plugin --- packages/app-cli/app/command-apidoc.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/app-cli/app/command-apidoc.js b/packages/app-cli/app/command-apidoc.js index 10ececd7d..2ef4cb804 100644 --- a/packages/app-cli/app/command-apidoc.js +++ b/packages/app-cli/app/command-apidoc.js @@ -312,6 +312,20 @@ async function fetchAllNotes() { lines.push(''); lines.push('The "data" field is required, while the "props" one is not. If not specified, default values will be used.'); lines.push(''); + lines.push('**From a plugin** the syntax to create a resource is also a bit special:'); + lines.push(''); + lines.push('```javascript'); + lines.push('\tawait joplin.data.post('); + lines.push('\t\t["resources"],'); + lines.push('\t\tnull,'); + lines.push('\t\t{ title: "test.jpg" }, // Resource metadata'); + lines.push('\t\t['); + lines.push('\t\t\t{'); + lines.push('\t\t\t\tpath: "/path/to/test.jpg", // Actual file'); + lines.push('\t\t\t},'); + lines.push('\t\t]'); + lines.push('\t);'); + lines.push('```'); } if (model.type === BaseModel.TYPE_TAG) {