angular - 以角度编写的单词插件 - 查找并选择文本
问题描述
我负责一个单词插件,需要添加新功能,但我失败得很厉害,希望有人能帮助我:)
我有一个按钮,如果单击此按钮,则应在单词文本中选择给定字符串的第一次出现。
谢谢!
package.json "@types/office-js": "0.0.75",
编辑:
HTML 代码
<a href="#" class="button-select-text (click)="selectText(givenString)">
角码
public selectText(givenString: string) {
console.log('String to select: ' + givenString);
if (this._common.officeVersion[0] !== '16') {
this._common.getWordFile('', Office.FileType.Text)
.then(response => {
console.log('Text from Word: ' + response.fileContent);
// todo now select/mark the givenString in word itself
});
} else {
Word.run(context => {
const wordText = context.load(context.document.body, 'text');
console.log('Text from Word: ' + wordText);
// todo now select/mark the givenString in word itself
});
}
}
解决方案
在 中Word.run
,您可以使用Word.Range.select()方法在 Word 中选择字符串。
我找不到使用共享 API 以编程方式选择数据的方法(您在 2016 年之前的代码分支中使用)。
推荐阅读
- java - 连接处于活动状态且数据库正常工作时,ResultSet 为空
- flutter - 未定义命名参数“body”。错误
- html - 如何将不同屏幕尺寸的按钮保持在同一位置?
- r - 不支持 UNC 路径。闪亮的应用程序无法通过批处理文件运行
- mysql - MySQL LIKE 查询 - 仅返回 SELECT 中匹配的子字符串
- typescript - React Hook 打字稿,更新枚举值
- flutter - Firebase 按预期拒绝使用 PermissionDenied 进行更新,但侦听节点的客户端仍会收到发送的数据
- python - setup.py 要求 pkg 不存在或存在于特定版本中
- mysql - 如何从sql中的子查询中选择一列?
- svg - threejs:试图将 objloader 传递给 var