OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
688 stars 95 forks source link

Difficulty Detecting Compose Mode on macOS in Office Add-ins #5092

Open AmitaiBitonHarmonie opened 4 days ago

AmitaiBitonHarmonie commented 4 days ago

On macOS, detecting compose mode reliably in Office Add-ins has proven challenging due to limitations in Office.context.mailbox.item behavior. Specifically:

Impact: The ability to reliably detect compose vs read mode is essential for our use cases, which include showing relevant actions based on the current mode (e.g., different actions for composing a message vs. reading one). The current limitations disrupt the user experience, especially for applications that need to handle multiselection, contextless scenarios, or smooth transitions between compose and read.

Expected Behavior: Ideally, Office.context.mailbox.item should provide mode detection consistently on macOS, regardless of the permissions used, and without requiring an add-in reload when switching between compose and read.

### Steps to Reproduce:

1TheMuffinMan commented 2 days ago

Your approach with URL's in bullet #2 is the correct way to handle this.

Regarding the pinned application behavior and the app reloading between contexts. Yes, that is by design. They took a different approach to add-ins this time. They are meant to enhance the user experience rather than take complete control like the old COM add-in framework did. Add-ins now load on demand.

AmitaiBitonHarmonie commented 1 day ago

Hi There, Seems like the fix you provide is working only if I re-open the addin closed and open. Otherwise, it behaves like the last mode compose or read. You can try it. Step to repo:

  1. Outlook desktop on MAC
  2. Configure Outlook to show new messages inline ( open in the main window)

From: Nicholas Lechnowskyj @.> Sent: Saturday, November 16, 2024 5:25 PM To: OfficeDev/office-js @.> Cc: Amitai Biton @.>; Author @.> Subject: Re: [OfficeDev/office-js] Difficulty Detecting Compose Mode on macOS in Office Add-ins (Issue #5092)

To detect whether your taskpane is operating in the compose or read mode is simple, but you need to infer this from a much higher level.

In the manifest you define event handlers for read and compose and there you can define your taskpane URL with a query string or different path altogether.

      <ExtensionPoint xsi:type="MessageComposeCommandSurface">

        <OfficeTab id="TabDefault">

          <Group id="msgComposeGroup">

            <Label resid="GroupLabel"/>

            <!-- Show Delivery Trust button -->

            <Control xsi:type="Button" id="msgComposeOpenPaneButton">

              <Label resid="TaskpaneButton.Label"/>

              <Supertip>

                <Title resid="TaskpaneButton.Label"/>

                <Description resid="TaskpaneButton.Tooltip"/>

              </Supertip>

              <Icon>

                <bt:Image size="16" resid="Icon.16x16"/>

                <bt:Image size="32" resid="Icon.32x32"/>

                <bt:Image size="80" resid="Icon.80x80"/>

              </Icon>

              <Action xsi:type="ShowTaskpane">

                <SourceLocation resid="Taskpane.Url"/>

                <SupportsPinning>true</SupportsPinning>

              </Action>

            </Control>

          </Group>

        </OfficeTab>

      </ExtensionPoint>

      <!-- On email read -->

      <ExtensionPoint xsi:type="MessageReadCommandSurface">

        <OfficeTab id="TabDefault">

          <Group id="msgReadGroup">

            <Label resid="GroupLabel"/>

            <!-- Show Delivery Trust button -->

            <Control xsi:type="Button" id="msgReadOpenPaneButton">

              <Label resid="TaskpaneButton.Label"/>

              <Supertip>

                <Title resid="TaskpaneButton.Label"/>

                <Description resid="TaskpaneButtonRead.Tooltip"/>

              </Supertip>

              <Icon>

                <bt:Image size="16" resid="Icon.16x16"/>

                <bt:Image size="32" resid="Icon.32x32"/>

                <bt:Image size="80" resid="Icon.80x80"/>

              </Icon>

              <Action xsi:type="ShowTaskpane">

                <SourceLocation resid="TaskpaneRead.Url"/>

                <SupportsPinning>true</SupportsPinning>

              </Action>

            </Control>

          </Group>

        </OfficeTab>

      </ExtensionPoint>
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>