useEffect(() => {
const fetchLanguages = async () => {
try {
const [sourceLangData, targetLangData] = await Promise.all([
GetSourceLanguage(),
GetTargetLanguage()
]);
setSourceLanguages(sourceLangData);
setTargetLanguages(targetLangData);
} catch (error) {
console.error('Error fetching languages:', error);
}
};
fetchLanguages();
}, []);
const handleFetchData = async (sourceLang, targetLang, text) => {
setLoading(true);
try {
const translation = await fetchTranslation(sourceLang, targetLang, text);
insertProcessedText(translation);
// Reset dropdown values
setSourceLanguage('');
setTargetLanguage('');
} catch (error) {
console.error('Error during fetch operation:', error);
} finally {
setLoading(false);
}
};
const handleGetSelection = () => {
Getslectedbodytext((text: any) => {
if (!text) {
toast.error('No text selected!');
return;
}
setSelectedText(text);
handleFetchData(sourceLanguage, targetLanguage, text);
});
};
恐怕目前没有任何方法可以在 PowerPoint 中使用 Office.js 获取对表格形状中特定单元格的引用。但这是个好主意。请在 Microsoft 365 开发者平台 推荐。一定要标记它
Office Add-ins development
。