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
export default class MyClassToCallTheServer { | |
#internvalValue = null; | |
#loading = false; | |
constrcutor() { | |
this.#internalValue = this.#callTheServer(); | |
} | |
doSomethingWithTheServerData = async () => { | |
while(this.#loading) await new Promise(resolve => setTimeout(resolve, 10)); | |
// the #internalValue is not null because we waited | |
return this.#internalValue; |
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
export default class MyClassToCallTheServer { | |
#internvalValue = null; | |
constrcutor() { | |
// this.#internalValue = await this.#callTheServer(); <-- the await will fail to compile | |
this.#internalValue = this.#callTheServer(); | |
} | |
doSomethingWithTheServerData = () => { | |
// the #internalValue is still null becasue we could not await in the constructor | |
return this.#internalValue; | |
} |
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
const myObj = new MyClassToCallTheServer(); | |
let someValue = myObj.doSomegthingWithTheServerData(); |
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
/** | |
* Returns the data type based on the base64 string | |
* @param {String} base64String | |
* @param {String} fileName | |
* @returns {String} | |
*/ | |
detectMimeType(base64String, fileName) { | |
var ext = fileName.substring(fileName.lastIndexOf(".") + 1); | |
if (ext === undefined || ext === null || ext === "") ext = "bin"; | |
ext = ext.toLowerCase(); |
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
export async function getUserName() { | |
try { | |
let tokenData = await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: false, forMSGraphAccess: true }); | |
var parts = tokenData.split("."); | |
var token = JSON.parse(atob(parts[1])); | |
return token.preferred_username; | |
} | |
catch (exception) { | |
console.log(exception.message); | |
} |
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
const ns = "http://pfe.microsoft.com/excelpoc/1.0"; | |
const xml = "<message xmlns='http://pfe.microsoft.com/excelpoc/1.0'>" + | |
"<sentby>[who]</sentby>" + | |
"<info>[data]</info>" + | |
"</message>"; | |
const from_tp = "TASKPANE ADD-IN"; | |
function sendMessage() { | |
Excel.run(function(context) { | |
var data = xml.replace("[who]", from_tp).replace("[data]", "This message is coming from the taskpane."); | |
const customXmlPart = context.workbook.customXmlParts.add(data); |
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
Office.initialize = function(reason) { | |
// background thread checker | |
window.setInterval(() => { checkForPart(); }, 1000); | |
} | |
const ns = "http://pfe.microsoft.com/excelpoc/1.0"; | |
const xml = "<message xmlns='http://pfe.microsoft.com/excelpoc/1.0'>" + | |
"<sentby>[who]</sentby>" + | |
"<info>[data]</info>" + | |
"</message>"; |
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
[DllImport("user32.dll")] | |
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); | |
[DllImport("user32.dll", SetLastError = true)] | |
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); | |
/// <summary> | |
/// Startup for Outlook Add-in | |
/// </summary> | |
/// <param name="sender"></param> | |
/// <param name="e"></param> | |
private void ThisAddIn_Startup(object sender, System.EventArgs e) |
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
plugins: [ | |
new CleanWebpackPlugin(), | |
new HtmlWebpackPlugin({ | |
filename: "taskpane.html", | |
template: "./src/dialogs/taskpane.html", | |
chunks: ["polyfill", "common", "shared", "taskpane"] | |
}), | |
new HtmlWebpackPlugin({ | |
filename: "dialog.html", | |
template: "./src/dialogs/dialog.html", |
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
entry: { | |
polyfill: "@babel/polyfill", | |
dialog: "./src/dialogs/dialog.js", | |
commands: "./src/commands/commands.js", | |
shared: "./src/common/shared.js", | |
common: "./src/common/common.js", | |
taskpane: "./src/taskpane/taspane.js" | |
}, |