Skip to content

Commit

Permalink
Merge pull request #8 from FlexConfirmMail/load-scripts-by-webpack-co…
Browse files Browse the repository at this point in the history
…mpletely

Load scripts by webpack completely
  • Loading branch information
HashidaTKS authored Oct 1, 2024
2 parents 847dea2 + e978a16 commit d6af775
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/web/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>No title</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
blank
Expand Down
10 changes: 8 additions & 2 deletions src/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const data = {
},
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Office.initialize = function (reason) {};
Office.initialize = function (reason) {
console.debug("Office.initialize reasion = ", reason);
};

function toArray(str) {
if (!str) {
Expand All @@ -31,6 +32,7 @@ function toArray(str) {
}

async function loadFile(url) {
console.debug("loadFile ", url);
try {
const response = await fetch(url);
const data = await response.text();
Expand Down Expand Up @@ -100,6 +102,7 @@ function getAllData(callback) {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function onMessageSend(event) {
console.debug("onMessageSend ", event);
getAllData(function () {
Office.context.ui.displayDialogAsync(
window.location.origin + "/dialog.html",
Expand All @@ -126,9 +129,11 @@ function onMessageSend(event) {
);
});
}
window.onMessageSend = onMessageSend;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function onNewMessageComposeCreated(event) {
console.debug("onNewMessageComposeCreated ", event);
Office.context.mailbox.item.subject.setAsync("新規メールの件名", function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("件名が設定されました");
Expand All @@ -138,3 +143,4 @@ function onNewMessageComposeCreated(event) {
});
event.completed();
}
window.onNewMessageComposeCreated = onNewMessageComposeCreated;
1 change: 0 additions & 1 deletion src/web/dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<script src="https://unpkg.com/@fluentui/web-components" type="module"></script>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="dialog.js" type="module"></script>
<link href="dialog.css" rel="stylesheet">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = async (env, options) => {
new HtmlWebpackPlugin({
filename: "app.html",
template: "./src/web/app.html",
chunks: ["polyfill"],
chunks: ["polyfill", "app"],
}),
new CopyWebpackPlugin({
patterns: [
Expand Down Expand Up @@ -80,7 +80,7 @@ module.exports = async (env, options) => {
new HtmlWebpackPlugin({
filename: "dialog.html",
template: "./src/web/dialog.html",
chunks: ["polyfill"],
chunks: ["polyfill", "dialog"],
}),
],
devServer: {
Expand Down

0 comments on commit d6af775

Please sign in to comment.