Hello! I am studying plugins for the only office document editor. Now I have a plugin that counts paragraphs in a document. I also want to display the current cursor position in the text (paragraph number and character number in the paragraph). How do I do this? Here is my current code:
(function (window, undefined) {
window.Asc.plugin.init = function (text) {
function documentResearch() {
var oDocument = Api.GetDocument();
var oParagraphs = oDocument.GetAllParagraphs()
const par_count = oParagraphs.length
//How can i find the current cursor position here?
//const cur_par = ???
//const cur_char = ???
return [{name:"par_count", value:par_count}]
}
function setFields(fields) {
fields.forEach(({name, value}) => {
const element = document.getElementById(name)
element.innerHTML = value
});
}
const documentResearchParams = [documentResearch, false, true, (responce=[]) => {setFields(responce)}]
window.Asc.plugin.button = function () {
this.executeCommand("close", "");
};
window.Asc.plugin.event_onTargetPositionChanged = function () {
this.callCommand(...documentResearchParams)
};
this.callCommand(...documentResearchParams)
};
})(window, undefined);