From f1fce4431f9084c9235a90cfd0c073c84f74c1e8 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 9 Jun 2026 17:20:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(addons)=20insert=20meeting?= =?UTF-8?q?=20link=20at=20the=20cursor=20position?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of appending the meeting link at the end of the email, insert it where the user's cursor is. This ensures the link is not placed after the email signature, or below the quoted thread in a reply. --- src/addons/outlook/src/commands/commands.js | 37 ++++++++------------- src/addons/outlook/src/taskpane/taskpane.js | 30 +++++------------ 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/addons/outlook/src/commands/commands.js b/src/addons/outlook/src/commands/commands.js index d369431b..09480d33 100644 --- a/src/addons/outlook/src/commands/commands.js +++ b/src/addons/outlook/src/commands/commands.js @@ -30,35 +30,26 @@ function insertMeetingLink(event, session) { const coercionType = isWeb ? Office.CoercionType.Html : Office.CoercionType.Text; return new Promise((resolve, reject) => { - item.body.getAsync(coercionType, (getResult) => { - if (getResult.status !== Office.AsyncResultStatus.Succeeded) { - notify(`Erreur de lecture : ${getResult.error.message}`); + item.body.setSelectedDataAsync(text, { coercionType }, (setResult) => { + if (setResult.status !== Office.AsyncResultStatus.Succeeded) { + notify(`Erreur d'insertion : ${setResult.error.message}`); resolve(); return; } - item.body.setAsync( - getResult.value + text, - { coercionType: coercionType }, (setResult) => { - if (setResult.status !== Office.AsyncResultStatus.Succeeded) { - notify(`Erreur d'insertion : ${setResult.error.message}`); - resolve(); - return; - } - if (item.itemType !== Office.MailboxEnums.ItemType.Appointment) { + if (item.itemType !== Office.MailboxEnums.ItemType.Appointment) { + notify("Lien de réunion inséré !"); + resolve(); + return; + } + + item.location.setAsync(url, (locationResult) => { + if (locationResult.status !== Office.AsyncResultStatus.Succeeded) { + notify(`Erreur de localisation : ${locationResult.error.message}`); + } else { notify("Lien de réunion inséré !"); - resolve(); - return; } - - item.location.setAsync(url, (locationResult) => { - if (locationResult.status !== Office.AsyncResultStatus.Succeeded) { - notify(`Erreur de localisation : ${locationResult.error.message}`); - } else { - notify("Lien de réunion inséré !"); - } - resolve(); - }); + resolve(); }); }); }); diff --git a/src/addons/outlook/src/taskpane/taskpane.js b/src/addons/outlook/src/taskpane/taskpane.js index a0541e51..77c22007 100644 --- a/src/addons/outlook/src/taskpane/taskpane.js +++ b/src/addons/outlook/src/taskpane/taskpane.js @@ -77,29 +77,17 @@ function generateMeetingLink() { const coercionType = isWeb ? Office.CoercionType.Html : Office.CoercionType.Text; return new Promise((resolve, reject) => { - item.body.getAsync(coercionType, (getResult) => { - if (getResult.status !== Office.AsyncResultStatus.Succeeded) { - reject(getResult.error); + item.body.setSelectedDataAsync(text, { coercionType }, (setResult) => { + if (setResult.status !== Office.AsyncResultStatus.Succeeded) { + reject(setResult.error); return; } - item.body.setAsync( - getResult.value + text, - { coercionType: coercionType }, - (setResult) => { - if (setResult.status !== Office.AsyncResultStatus.Succeeded) { - reject(setResult.error); - return; - } - - // ─── If calendar event, also set location ────────────── - if (item.itemType === Office.MailboxEnums.ItemType.Appointment) { - item.location.setAsync(url, () => resolve()); - return; - } - - resolve(); - } - ); + // ─── If calendar event, also set location ────────────── + if (item.itemType === Office.MailboxEnums.ItemType.Appointment) { + item.location.setAsync(url, () => resolve()); + return; + } + resolve(); }); }); })