跳转到主要内容
必须选中文档的文本内容才能调用该接口,否则会调用失败。
static getSelectedText(): Promise<APIResponse<string>>;
返回

示例

import { PluginDocAPI } from 'sn-plugin-lib';

/**
 * 获取当前选中文本的示例。
 */
export async function exampleGetSelectedText() {
  const res = await PluginDocAPI.getSelectedText();
  if (!res.success) {
    throw new Error(res.error?.message ?? 'getSelectedText 调用失败');
  }
  return res.result;
}