我是 Office 应用程序开发的新手。我想在按钮单击时为选定的文本添加评论。我可以使用以下代码获取选定的文本,但我不知道如何在选定的文本中添加注释。
代码:Home.js
(function () {
"use strict";
// The initialize function must be run each time a new page is loaded
Office.initialize = function (reason) {
$(document).ready(function () {
app.initialize();
$('#get-data-from-selection').click(getDataFromSelection);
});
};
// Reads data from current document selection and displays a notification
function getDataFromSelection() {
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
app.showNotification('The selected text is:', '"' + result.value + '"');
} else {
app.showNotification('Error:', result.error.message);
}
}
);
}
})();
有人可以指导我在所选文本中添加评论吗?