From 491866e5843a652b942b2972258a455772631f34 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 8 Jun 2026 19:52:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(addons)=20try=20using=20the?= =?UTF-8?q?=20default=20client=20font?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the message builder so that rendered messages are displayed in a nicer way. Based on user feedback from the social ministries. Go for a hybrid approach: on the desktop client, insert plain text so it picks up the default font configured by the client theme; on the web client, insert HTML, as the editor there is rendered using HTML. --- src/addons/outlook/src/commands/commands.js | 12 +++-- .../outlook/src/common/messageBuilder.js | 50 +++++++++++++------ src/addons/outlook/src/taskpane/taskpane.js | 12 +++-- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/addons/outlook/src/commands/commands.js b/src/addons/outlook/src/commands/commands.js index e5e7128c..d369431b 100644 --- a/src/addons/outlook/src/commands/commands.js +++ b/src/addons/outlook/src/commands/commands.js @@ -24,19 +24,21 @@ function notify(message) { function insertMeetingLink(event, session) { createRoom(session) .then((data) => { - const { url, message } = buildMeetingMessage(data); + const isWeb = Office.context.diagnostics.platform === "OfficeOnline"; + const { url, text } = buildMeetingMessage(data, isWeb); const item = Office.context.mailbox.item; + const coercionType = isWeb ? Office.CoercionType.Html : Office.CoercionType.Text; return new Promise((resolve, reject) => { - item.body.getAsync(Office.CoercionType.Html, (getResult) => { + item.body.getAsync(coercionType, (getResult) => { if (getResult.status !== Office.AsyncResultStatus.Succeeded) { notify(`Erreur de lecture : ${getResult.error.message}`); resolve(); return; } - - const newBody = getResult.value + message; - item.body.setAsync(newBody, { coercionType: Office.CoercionType.Html }, (setResult) => { + item.body.setAsync( + getResult.value + text, + { coercionType: coercionType }, (setResult) => { if (setResult.status !== Office.AsyncResultStatus.Succeeded) { notify(`Erreur d'insertion : ${setResult.error.message}`); resolve(); diff --git a/src/addons/outlook/src/common/messageBuilder.js b/src/addons/outlook/src/common/messageBuilder.js index b50e3fb0..f29184c2 100644 --- a/src/addons/outlook/src/common/messageBuilder.js +++ b/src/addons/outlook/src/common/messageBuilder.js @@ -21,7 +21,7 @@ function _formatPhone(phone) { } // todo - escape html / link -function buildMeetingMessage(data) { +function buildMeetingMessage(data, isWeb) { if (!data?.url) { throw new Error("buildMeetingMessage: missing url in data"); } @@ -30,23 +30,45 @@ function buildMeetingMessage(data) { const phone = _formatPhone(data.telephony?.phone_number); const pin = _formatPin(data.telephony?.pin_code); - const telephonyBlock = - phone && pin - ? ` + let textLines = ""; + let phoneLines = []; -Ou appelez (audio uniquement) -(FR) ${phone} -Code : ${pin}` - : ""; + phoneLines = phone && + pin && [ + "

Ou appelez (audio uniquement)", + `
(FR) ${phone}`, + `
Code ${pin}` + ]; - const message = `
-────────────────────────────────────────
-Rejoindre la réunion ${APP_NAME}
+    textLines = [
+      "

────────────────────────────────────────", + `
Rejoindre la réunion ${APP_NAME}`, + `

${url}`, + ...phoneLines, + "
────────────────────────────────────────
", + ]; -${url}${telephonyBlock} -────────────────────────────────────────
`; + } else { - return { url, message }; + phoneLines = phone && + pin && [ + "\n\nOu appelez (audio uniquement)", + `\n(FR) ${phone}`, + `\nCode ${pin}` + ]; + + textLines = [ + "\n\n────────────────────────────────────────", + `\nRejoindre la réunion ${APP_NAME}`, + `\n\n${url}`, + ...phoneLines, + "\n────────────────────────────────────────\n", + ]; + } + + const text = textLines.join(""); + + return { url, text }; } module.exports = { buildMeetingMessage }; diff --git a/src/addons/outlook/src/taskpane/taskpane.js b/src/addons/outlook/src/taskpane/taskpane.js index 9ed3768a..a0541e51 100644 --- a/src/addons/outlook/src/taskpane/taskpane.js +++ b/src/addons/outlook/src/taskpane/taskpane.js @@ -71,18 +71,20 @@ function generateMeetingLink() { createRoom(session) .then((data) => { - const { url, message } = buildMeetingMessage(data); + const isWeb = Office.context.diagnostics.platform === "OfficeOnline"; + const { url, text } = buildMeetingMessage(data, isWeb); const item = Office.context.mailbox.item; + const coercionType = isWeb ? Office.CoercionType.Html : Office.CoercionType.Text; + return new Promise((resolve, reject) => { - item.body.getAsync(Office.CoercionType.Html, (getResult) => { + item.body.getAsync(coercionType, (getResult) => { if (getResult.status !== Office.AsyncResultStatus.Succeeded) { reject(getResult.error); return; } - item.body.setAsync( - getResult.value + message, - { coercionType: Office.CoercionType.Html }, + getResult.value + text, + { coercionType: coercionType }, (setResult) => { if (setResult.status !== Office.AsyncResultStatus.Succeeded) { reject(setResult.error);