Documentation Index
Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
Use this file to discover all available pages before exploring further.
static createNote(params: {
notePath: string;
template: string;
mode: number;
isPortrait: boolean;
}): Promise<APIResponse<boolean>>;
Parameters
| Parameter | Type | Description |
|---|
params.notePath | string | Note file path |
params.template | string | Template source: - system template: call getNoteSystemTemplates and pass Template.name; - custom template: pass a custom template image path |
params.mode | number | Create mode: 0 normal, 1 recognition layout |
params.isPortrait | boolean | Whether portrait orientation is used |
Returns
Example
import { PluginFileAPI, PluginCommAPI } from 'sn-plugin-lib';
/**
* Create note example (using a system template).
*/
export async function exampleCreateNote() {
const notePath = '/storage/emulated/0/Note/new.note';
// Get the system template list and pick a Template.name
const tplRes = await PluginCommAPI.getNoteSystemTemplates();
if (!tplRes.success) {
throw new Error(tplRes.error?.message ?? 'getNoteSystemTemplates call failed');
}
const templates = (tplRes.result ?? []) as any[];
const templateName = templates[0]?.name;
if (!templateName) {
throw new Error('failed to get a system template name');
}
const res = await PluginFileAPI.createNote({
notePath,
template: templateName,
mode: 0,
isPortrait: true,
});
if (!res.success) {
throw new Error(res.error?.message ?? 'createNote call failed');
}
return res.result;
}