Hi! I’m facing an issue while developing a plugin. I wrote a plugin that should add comments to the text of a DOCX document. Everything works successfully and comments appear, but after refreshing the editor page, the comments disappear.
Here’s the plugin code snippet responsible for saving comments:
function handleReviewButtonClick(plugin) {
plugin.callCommand(function () {
// Получаем весь текст документа
let document = Api.GetDocument();
let props = {
Numbering: false, // не хочу нумерацию
Math: false, // не хочу математические формулы
ParaSeparator: "\n", // разделитель параграфов
TabSymbol: "\t" // символ табуляции
};
let text = document.GetText(props);
fetch("https://llm-agent-proxy/ai/review", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ content: text })
})
.then(response => {
if (!response.ok) throw new Error("Ошибка сети");
return response.json();
})
.then(data => {
console.log("Получены комментарии:", data);
// Вставляем комментарии в документ
for (let i = 0; i < data.length; i++) {
let comment = data[i];
let targetList = document.Search(comment.target);
for (let j = 0; j < targetList.length; j++) {
Api.AddComment(targetList[j], comment.text, "AI Reviewer");
}
}
})
.catch(err => {
console.error("Ошибка при проверке документа:", err);
});
});
}
I`m using OnlyOffice in docker with version 9.1.0
Could you please advise what might be causing this?