Merge pull request #590 from ONLYOFFICE/feature/optimization-editor
Doceditor: add loaded scripts with bundle
This commit is contained in:
commit
195c008b12
@ -24,16 +24,17 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
import type { Metadata } from "next";
|
||||
import { headers } from "next/headers";
|
||||
import Script from "next/script";
|
||||
|
||||
import { getSelectorsByUserAgent } from "react-device-detect";
|
||||
|
||||
import { ValidationStatus } from "@docspace/shared/enums";
|
||||
|
||||
import { getData, validatePublicRoomKey } from "@/utils/actions";
|
||||
import { RootPageProps } from "@/types";
|
||||
import Root from "@/components/Root";
|
||||
import FilePassword from "@/components/file-password";
|
||||
import { ValidationStatus } from "@docspace/shared/enums";
|
||||
|
||||
const initialSearchParams: RootPageProps["searchParams"] = {
|
||||
fileId: undefined,
|
||||
@ -71,8 +72,6 @@ async function Page({ searchParams }: RootPageProps) {
|
||||
}
|
||||
}
|
||||
|
||||
const startDate = new Date();
|
||||
|
||||
const data = await getData(
|
||||
fileId ?? fileid ?? "",
|
||||
version,
|
||||
@ -82,13 +81,22 @@ async function Page({ searchParams }: RootPageProps) {
|
||||
type,
|
||||
);
|
||||
|
||||
const timer = new Date().getTime() - startDate.getTime();
|
||||
|
||||
if (data.error?.status === "not-found" && error) {
|
||||
data.error.message = error;
|
||||
}
|
||||
|
||||
return <Root {...data} timer={timer} />;
|
||||
let url = data.config?.editorUrl ?? data.error?.editorUrl;
|
||||
|
||||
if (url && !url.endsWith("/")) url += "/";
|
||||
|
||||
const docApiUrl = `${url}web-apps/apps/api/documents/api.js`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Root {...data} />
|
||||
<Script id="editor-api" strategy="beforeInteractive" src={docApiUrl} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Page;
|
||||
|
@ -24,6 +24,8 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
/* eslint-disable @next/next/no-before-interactive-script-outside-document */
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
import runtime from "../../../runtime.json";
|
||||
@ -35,9 +37,11 @@ const Scripts = () => {
|
||||
<>
|
||||
<Script
|
||||
id="browser-detector"
|
||||
strategy="beforeInteractive"
|
||||
src={`/static/scripts/browserDetector.js?hash=${runtime?.checksums?.["browserDetector.js"] ?? hashDate}`}
|
||||
/>
|
||||
<Script id="portal-config">
|
||||
|
||||
<Script id="portal-config" strategy="beforeInteractive">
|
||||
{`
|
||||
console.log("It's DocEditor INIT");
|
||||
fetch("/static/scripts/config.json?hash=${runtime?.checksums["config.json"] ?? hashDate}")
|
||||
|
Loading…
Reference in New Issue
Block a user