Skip to main content
Links can only be inserted into the main layer; other layers are not supported. This API supports undo/redo in notes.
static insertTextLink(textLink: {
 destPath: string;
 destPage?: number;
 style: number;
 linkType: number;
 rect: Rect;
 fontSize: number;
 fullText: string;
 showText: string;
 isItalic: number;
}): Promise<APIResponse<number>>;
Parameters
ParameterTypeDescription
textLink.destPathstringDestination path / URL: when linkType === 4, set this to the URL; otherwise set it to the destination file path
textLink.destPagenumberDestination page (only valid when linkType === 0 or linkType === 2)
For linkType === 0: must be a non-negative integer, meaning the target note page
For linkType === 2: a negative value jumps to the document current page; a non-negative integer jumps to the specified document page
textLink.stylenumberLink style: 0 solid underline, 1 solid border, 2 dashed border
textLink.linkTypenumberLink type: 0 note page, 1 note file, 2 document, 3 image, 4 URL
textLink.rectRectText region rectangle (must be non-zero area)
textLink.fontSizenumberFont size (positive number)
textLink.fullTextstringFull text (required for text links)
textLink.showTextstringDisplay text (required for text links)
textLink.isItalicnumberItalic: 0 no, 1 yes
Supported linkType ranges may differ across APIs. Currently, insertTextLink only allows 0..4. When reading lasso link data, you may encounter linkType=6 (digest link). This type is currently read-only and cannot be created via this API. See Link / LassoLink.
Returns
  • APIResponse<number>: result is a status code (convention: 0 success, -1 failure, -2 target file requires upgrade)

Example

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;
}