Created
August 6, 2020 08:26
-
-
Save allensu0314/fb701683a45ccb807b56a2c622e9a230 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 hidden or 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) { | |
var text = asyncResult.value.data; | |
var 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 | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
[email protected] | |
@types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment