d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
'use client'
|
|
|
|
import Script from 'next/script'
|
|
|
|
declare global {
|
|
interface Window {
|
|
Office?: {
|
|
onReady: () => Promise<{ host: string | null; platform: string | null }>
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Office.js nullifies window.history.replaceState and pushState (a legacy
|
|
* IE10 workaround inside the library) which breaks Next.js's client-side
|
|
* router. Cache the originals at module load — before <Script> renders
|
|
* Office.js into the DOM — so we can restore them after it loads.
|
|
*
|
|
* See https://learn.microsoft.com/en-us/answers/questions/1070090/using-office-javascript-api-in-next-js.
|
|
*/
|
|
const cachedHistory =
|
|
typeof window !== 'undefined'
|
|
? {
|
|
replaceState: window.history.replaceState.bind(window.history),
|
|
pushState: window.history.pushState.bind(window.history),
|
|
}
|
|
: null
|
|
|
|
/**
|
|
* Loads Office.js and signals readiness so Office host applications
|
|
* (Excel, Word, PowerPoint, Outlook) recognize this page as a valid add-in.
|
|
*
|
|
* Office.onReady() must be called once Office.js is loaded — see
|
|
* https://learn.microsoft.com/en-us/javascript/api/office#office-office-onready-function(1).
|
|
*/
|
|
export function OfficeEmbedInit() {
|
|
return (
|
|
<Script
|
|
src='https://appsforoffice.microsoft.com/lib/1/hosted/office.js'
|
|
strategy='afterInteractive'
|
|
onReady={() => {
|
|
if (cachedHistory) {
|
|
window.history.replaceState = cachedHistory.replaceState
|
|
window.history.pushState = cachedHistory.pushState
|
|
}
|
|
void window.Office?.onReady()
|
|
}}
|
|
/>
|
|
)
|
|
}
|