Created
January 2, 2024 20:19
-
-
Save glachancecmaisonneuve/480d0467ab069816faa18ac88a391bf9 to your computer and use it in GitHub Desktop.
Gets the selected text in the item body or subject in Compose mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Get selected text (Compose) | |
description: Gets the selected text in the item body or subject in Compose mode. | |
host: OUTLOOK | |
api_set: {} | |
script: | |
content: | | |
$("#get-selected-data").click(getSelectedData); | |
function getSelectedData() { | |
Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, function(asyncResult) { | |
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { | |
const text = asyncResult.value.data; | |
const prop = asyncResult.value.sourceProperty; | |
console.log("Selected text in " + prop + ": " + text); | |
} else { | |
console.error(asyncResult.error); | |
} | |
}); | |
} | |
language: typescript | |
template: | |
content: |- | |
<section class="ms-font-m"> | |
<p class="ms-font-m">This sample shows how to get the selected text in the item body or subject/title.</p> | |
<p><b>Required mode</b>: Compose</p> | |
</section> | |
<section class="samples ms-font-m"> | |
<h3>Try it out</h3> | |
<p>Select text in the item body or subject then push the <b>Get selected text</b> button.</p> | |
<button id="get-selected-data" class="ms-Button"> | |
<span class="ms-Button-label">Get selected text</span> | |
</button> | |
</section> | |
language: html | |
style: | |
content: |- | |
section.samples { | |
margin-top: 20px; | |
} | |
section.samples .ms-Button, section.setup .ms-Button { | |
display: block; | |
margin-bottom: 5px; | |
margin-left: 20px; | |
min-width: 80px; | |
} | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css | |
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css | |
core-js@2.4.1/client/core.min.js | |
@types/core-js | |
jquery@3.1.1 | |
@types/jquery@3.3.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment