elements 通常是从 getElements/getLassoElements 等接口拿到的既有元素(带 uuid),识别前后 uuid 保持不变。该接口依赖这些元素当前仍在原生缓存中,缓存中找不到的元素会被直接跳过,不会单独报错,详见 Element 缓存与释放。
返回
APIResponse<string>:识别结果文字
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
识别元素为文字。
elements 通常是从 getElements/getLassoElements 等接口拿到的既有元素(带 uuid),识别前后 uuid 保持不变。该接口依赖这些元素当前仍在原生缓存中,缓存中找不到的元素会被直接跳过,不会单独报错,详见 Element 缓存与释放。
static recognizeElements(elements: Object[] | null | undefined, size: { width: number; height: number }): Promise<APIResponse<string>>;
| 参数 | 类型 | 说明 |
|---|---|---|
elements | Object[] | null | undefined | 元素数组(当前仅支持识别普通笔划与文本框) |
size | { width: number; height: number } | 元素所基于的笔记页宽高(像素) |
APIResponse<string>:识别结果文字import { PluginCommAPI } from 'sn-plugin-lib';
export async function exampleRecognizeElements(elements, size) {
const res = await PluginCommAPI.recognizeElements(elements, size);
if (!res.success) {
throw new Error(res.error?.message ?? 'recognizeElements 调用失败');
}
return res.result;
}