I couldn’t find the event name that listens to user selected events.
I am conducting the following tests:
(function (window) {
window.Asc.plugin.init = function (initData) {
try {
const getUserSelected = () => {
Asc.plugin.callCommand(function () {
let doc = Api.GetDocument();
let range = doc.GetRangeBySelect();
if (!range) return;
let startPos = range.GetStartPos();
let endPos = range.GetEndPos();
let startPage = range.GetStartPage();
let endPage = range.GetEndPage();
let text = range.GetText();
let selection = { startPos, endPos, startPage, endPage, text };
return selection;
}, false, true, function (selection) {
window.parent.window.parent.postMessage(selection, '*');
});
};
// When I click document,It's ok.
window.Asc.plugin.attachEvent("onClick", (data) => {
console.log('getRangeData---onClick:', data);
});
// But this :
// I don't hnow what event name to use here. I want to trigger the function when user selects text in the document.
window.Asc.plugin.attachEvent("When user selected dispatch's EventName", (data) => {
getUserSelected();
});
} catch (error) {
console.error("error: ", error);
}
};
})(window);
Can you tell me how to implement this feature?