Links can only be inserted into the main layer; other layers are not supported. This API supports undo/redo in notes.
Returns
APIResponse<number>:resultis a status code (convention:0success,-1failure,-2target file requires upgrade)
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Insert a text link into the main layer of the currently opened note page.
static insertTextLink(textLink: {
destPath: string;
destPage?: number;
style: number;
linkType: number;
rect: Rect;
fontSize: number;
fullText: string;
showText: string;
isItalic: number;
}): Promise<APIResponse<number>>;
| Parameter | Type | Description |
|---|---|---|
textLink.destPath | string | Destination path / URL: when linkType === 4, set this to the URL; otherwise set it to the destination file path |
textLink.destPage | number | Destination page (only valid when linkType === 0 or linkType === 2)For linkType === 0: must be a non-negative integer, meaning the target note pageFor linkType === 2: a negative value jumps to the document current page; a non-negative integer jumps to the specified document page |
textLink.style | number | Link style: 0 solid underline, 1 solid border, 2 dashed border |
textLink.linkType | number | Link type: 0 note page, 1 note file, 2 document, 3 image, 4 URL |
textLink.rect | Rect | Text region rectangle (must be non-zero area) |
textLink.fontSize | number | Font size (positive number) |
textLink.fullText | string | Full text (required for text links) |
textLink.showText | string | Display text (required for text links) |
textLink.isItalic | number | Italic: 0 no, 1 yes |
APIResponse<number>:
result is a status code (convention: 0 success, -1 failure, -2 target file requires upgrade)import { PluginNoteAPI, type Rect } from 'sn-plugin-lib';
/**
* Example: insert a text link into the current note page.
*/
export async function exampleInsertTextLink() {
const rect: Rect = { left: 100, top: 100, right: 300, bottom: 160 };
const res = await PluginNoteAPI.insertTextLink({
destPath: '/storage/emulated/0/Note/demo.note',
destPage: 1,
style: 0,
linkType: 0,
rect,
fontSize: 32,
fullText: 'Full Text',
showText: 'Show Text',
isItalic: 0,
});
if (!res.success) {
throw new Error(res.error?.message ?? 'insertTextLink call failed');
}
return res.result;
}