Skip to main content
static createNote(params: {
 notePath: string;
 template: string;
 mode: number;
 isPortrait: boolean;
}): Promise<APIResponse<boolean>>;
Parameters
ParameterTypeDescription
params.notePathstringNote file path
params.templatestringTemplate source:
- system template: call getNoteSystemTemplates and pass Template.name;
- custom template: pass a custom template image path
params.modenumberCreate mode: 0 normal, 1 recognition layout
params.isPortraitbooleanWhether 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;
}