Merge branch 'release/v2.5.0' into feature/logo-handler

This commit is contained in:
Ilya Oleshko 2024-03-29 13:04:16 +03:00
commit 55cd2f5053
23 changed files with 236 additions and 194 deletions

View File

@ -84,6 +84,9 @@
})
.catch((e) => {
console.error(e);
window.DocSpaceConfig = {
errorOnLoad: e,
};
});
</script>
</body>

View File

@ -325,7 +325,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
}, [userId]);
useEffect(() => {
if (!userId || !window.DocSpaceConfig.imageThumbnails) return;
if (!userId || !window.DocSpaceConfig?.imageThumbnails) return;
initIndexedDb();
return () => {

View File

@ -107,7 +107,7 @@ export const RegisterContainer = styled.div`
margin: 0px;
}
.auth-form-container {
.auth-form-fields {
width: 100%;
.password-field{

View File

@ -514,7 +514,6 @@ const CreateUserForm = (props) => {
<FormWrapper>
<RegisterContainer registrationForm={registrationForm}>
<form className="auth-form-container">
<div className="auth-form-fields">
<div className="email-container">
<FieldContainer
@ -690,7 +689,6 @@ const CreateUserForm = (props) => {
</div>
)}
</div>
</form>
{!emailFromLink && (oauthDataExists() || ssoExists()) && (
<>

View File

@ -1996,7 +1996,7 @@ class FilesStore {
fileOptions = this.removeOptions(fileOptions, ["download"]);
}
if (!isPdf || !window.DocSpaceConfig.pdfViewer || isRecycleBinFolder) {
if (!isPdf || !window.DocSpaceConfig?.pdfViewer || isRecycleBinFolder) {
fileOptions = this.removeOptions(fileOptions, ["pdf-view"]);
}

View File

@ -105,7 +105,7 @@ class MediaViewerDataStore {
if (
!file.canOpenPlayer &&
!file.fileExst === ".pdf" &&
window.DocSpaceConfig.pdfViewer
window.DocSpaceConfig?.pdfViewer
)
return;
@ -247,7 +247,7 @@ class MediaViewerDataStore {
const canOpenPlayer =
file.viewAccessibility?.ImageView ||
file.viewAccessibility?.MediaView ||
(file.fileExst === ".pdf" && window.DocSpaceConfig.pdfViewer);
(file.fileExst === ".pdf" && window.DocSpaceConfig?.pdfViewer);
if (canOpenPlayer) {
playlist.push({

View File

@ -44,7 +44,7 @@ const FILTER_COUNT = 6;
class StorageManagement {
isInit = false;
portalInfo = null;
portalInfo = {};
activeUsersCount = null;
filesUsedSpace = {};
quotaSettings = {};

View File

@ -11,7 +11,7 @@
"deploy": "shx --silent mkdir -p ../../../publish/web/editor && shx --silent mkdir -p ../../../publish/web/editor/.next && shx --silent mkdir -p ../../../publish/web/editor/config && shx cp -r config/* ../../../publish/web/editor/config && shx --silent mkdir -p ../../../publish/web/editor/node_modules && shx --silent mkdir -p ../../../publish/web/editor/.next/static && shx cp -r .next/standalone/node_modules/* ../../../publish/web/editor/node_modules && shx cp -r .next/static/* ../../../publish/web/editor/.next/static && shx cp -r .next/standalone/packages/doceditor/.next/* ../../../publish/web/editor/.next && shx cp -f server.prod.js ../../../publish/web/editor/server.js"
},
"dependencies": {
"@onlyoffice/document-editor-react": "file:./onlyoffice-document-editor-react-v1.4.1.tgz",
"@onlyoffice/document-editor-react": "^1.5.0",
"i18next": "^20.6.1",
"next": "14.0.4",
"react": "^18.2.0",

View File

@ -55,7 +55,7 @@ export default function GlobalError({ error }: { error: Error }) {
const { i18n } = useI18N({ settings, user });
const { currentDeviceType } = useDeviceType();
const { logoUrls } = useWhiteLabel();
const { theme } = useTheme({ user });
const { theme } = useTheme({ user, i18n });
const firebaseHelper = useMemo(() => {
return new FirebaseHelper(settings?.firebase ?? ({} as TFirebaseSettings));
}, [settings?.firebase]);

View File

@ -25,6 +25,7 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import "../styles/globals.scss";
import Script from "next/script";
// import StyledComponentsRegistry from "@/utils/registry";
@ -38,7 +39,49 @@ export default async function RootLayout({
<head>
<link id="favicon" rel="shortcut icon" type="image/x-icon" />
</head>
<body>{children}</body>
<body>
{children}
<Script
id="browser-detector"
src="/static/scripts/browserDetector.js"
/>
<Script id="docspace-config">
{`
console.log("It's DocEditor INIT");
fetch("/static/scripts/config.json")
.then((response) => {
if (!response.ok) {
throw new Error("HTTP error " + response.status);
}
return response.json();
})
.then((config) => {
window.DocSpaceConfig = {
...config,
};
if (
window.navigator.userAgent.includes("ZoomWebKit") ||
window.navigator.userAgent.includes("ZoomApps")
) {
window.DocSpaceConfig.editor = {
openOnNewPage: false,
requestClose: true,
};
}
//console.log({ DocSpaceConfig: window.DocSpaceConfig });
})
.catch((e) => {
console.error(e);
window.DocSpaceConfig = {
errorOnLoad: e,
};
});
`}
</Script>
</body>
</html>
);
}

View File

@ -69,7 +69,7 @@ const CreateFileError = ({
const { i18n } = useI18N({ settings, user });
const { currentDeviceType } = useDeviceType();
const { logoUrls } = useWhiteLabel();
const { theme } = useTheme({ user });
const { theme } = useTheme({ user, i18n });
const t = i18n.t ? i18n.t.bind(i18n) : null;
const message = error.message ?? error ?? "";

View File

@ -96,7 +96,7 @@ const Root = ({
editorUrl: documentserverUrl,
t,
});
const { theme, currentColorTheme } = useTheme({ user });
const { theme, currentColorTheme } = useTheme({ user, i18n });
const { currentDeviceType } = useDeviceType();
const { logoUrls } = useWhiteLabel();
const { isShowDeepLink, setIsShowDeepLink } = useDeepLink({

View File

@ -25,6 +25,7 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import React from "react";
import { i18n } from "i18next";
import { Base, Dark, TColorScheme, TTheme } from "@docspace/shared/themes";
import { getSystemTheme } from "@docspace/shared/utils";
@ -36,9 +37,10 @@ const SYSTEM_THEME = getSystemTheme();
export interface UseThemeProps {
user?: TUser;
i18n?: i18n;
}
const useTheme = ({ user }: UseThemeProps) => {
const useTheme = ({ user, i18n = {} }: UseThemeProps) => {
const [currentColorTheme, setCurrentColorTheme] =
React.useState<TColorScheme>({} as TColorScheme);
@ -65,6 +67,7 @@ const useTheme = ({ user }: UseThemeProps) => {
const getUserTheme = React.useCallback(() => {
if (!user?.theme) return;
let theme = user.theme;
const interfaceDirection = i18n.dir ? i18n.dir() : "ltr";
if (user.theme === ThemeKeys.SystemStr) theme = SYSTEM_THEME;
@ -72,7 +75,7 @@ const useTheme = ({ user }: UseThemeProps) => {
setTheme({
...Base,
currentColorScheme: currentColorTheme,
interfaceDirection: "ltr",
interfaceDirection,
});
return;
@ -81,9 +84,9 @@ const useTheme = ({ user }: UseThemeProps) => {
setTheme({
...Dark,
currentColorScheme: currentColorTheme,
interfaceDirection: "ltr",
interfaceDirection,
});
}, [currentColorTheme, user?.theme]);
}, [currentColorTheme, user?.theme, i18n.dir]);
React.useEffect(() => {
getCurrentColorTheme();
@ -97,4 +100,3 @@ const useTheme = ({ user }: UseThemeProps) => {
};
export default useTheme;

View File

@ -28,7 +28,6 @@
import { headers } from "next/headers";
import { getLtrLanguageForEditor } from "@docspace/shared/utils/common";
import { TenantStatus, EditorConfigErrorType } from "@docspace/shared/enums";
import type { TDocServiceLocation } from "@docspace/shared/api/files/types";
@ -382,13 +381,6 @@ export async function getData(
}
}
// needed to reset rtl language in Editor
response.config.editorConfig.lang = getLtrLanguageForEditor(
response.user?.cultureName,
response.settings.culture,
true,
);
if (response.settings.tenantStatus === TenantStatus.PortalRestore) {
response.error = { message: "restore-backup" };
}
@ -451,4 +443,3 @@ export async function getData(
return { error };
}
}

View File

@ -30,19 +30,15 @@ import { initReactI18next } from "react-i18next";
import config from "../../../../../buildtools/config/appsettings.json";
import { getLtrLanguageForEditor } from "@docspace/shared/utils/common";
import { translations } from "./autoGeneratedTranslations";
export const getI18NInstance = (lng: string, portalLng: string) => {
if (typeof window === "undefined") return;
const currentLng = getLtrLanguageForEditor(lng, portalLng, true);
// const cultures = config.web.cultures.split(",");
i18n.use(initReactI18next).init({
lng: currentLng,
lng,
fallbackLng: "en",
load: "currentOnly",
@ -72,4 +68,3 @@ export const getI18NInstance = (lng: string, portalLng: string) => {
return i18n;
};

View File

@ -116,6 +116,9 @@ const template: Template = (
})
.catch((e) => {
console.error(e);
window.DocSpaceConfig = {
errorOnLoad: e,
};
});
</script>
`;

View File

@ -63,6 +63,9 @@
})
.catch((e) => {
console.error(e);
window.DocSpaceConfig = {
errorOnLoad: e,
};
});
</script>
</body>

View File

@ -90,6 +90,7 @@ const Toast = (props: ToastProps) => {
const element = (
<StyledToastContainer
containerId="toast-container"
className={className}
draggable
position="top-right"

View File

@ -132,6 +132,7 @@ const notify = (
closeButton: withCross && <CloseButton />,
autoClose: timeout === 0 ? false : timeout < 750 ? 5000 : timeout || 5000,
position: centerPosition ? "top-center" : undefined,
containerId: "toast-container",
},
);
};

View File

@ -1016,7 +1016,8 @@ class SettingsStore {
get isFrame() {
const isFrame = this.frameConfig?.name === window.name;
window.DocSpaceConfig.isFrame = isFrame;
if (window.DocSpaceConfig) window.DocSpaceConfig.isFrame = isFrame;
console.log("Table log isFrame", isFrame);
return isFrame;

View File

@ -99,7 +99,7 @@ declare global {
DocSpace: {
navigate: (path: string, state?: { [key: string]: unknown }) => void;
};
DocSpaceConfig: {
DocSpaceConfig?: {
pdfViewerUrl: string;
wrongPortalNameUrl?: string;
api: {
@ -146,6 +146,7 @@ declare global {
toDataURL: () => string;
};
dataLayer?: Record<string, unknown>[];
errorOnLoad?: Error;
}
export type ContextMenuModel =

View File

@ -3163,7 +3163,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@docspace/doceditor@workspace:packages/doceditor"
dependencies:
"@onlyoffice/document-editor-react": "file:./onlyoffice-document-editor-react-v1.4.1.tgz"
"@onlyoffice/document-editor-react": "npm:^1.5.0"
"@svgr/webpack": "npm:^8.1.0"
"@types/node": "npm:^20"
"@types/react": "npm:^18"
@ -5224,15 +5224,15 @@ __metadata:
languageName: node
linkType: hard
"@onlyoffice/document-editor-react@file:./onlyoffice-document-editor-react-v1.4.1.tgz::locator=%40docspace%2Fdoceditor%40workspace%3Apackages%2Fdoceditor":
version: 1.4.1
resolution: "@onlyoffice/document-editor-react@file:./onlyoffice-document-editor-react-v1.4.1.tgz#./onlyoffice-document-editor-react-v1.4.1.tgz::hash=e29463&locator=%40docspace%2Fdoceditor%40workspace%3Apackages%2Fdoceditor"
"@onlyoffice/document-editor-react@npm:^1.5.0":
version: 1.5.0
resolution: "@onlyoffice/document-editor-react@npm:1.5.0"
dependencies:
lodash: "npm:^4.17.21"
lodash: "npm:4.17.21"
peerDependencies:
react: ^16.9.0 || ^17 || ^18
react-dom: ^16.9.0 || ^17 || ^18
checksum: ec4713519891b41353b01190c96d023677301c3b086b015a6ee67ac41acb104aa28e02a1d471b679f847f1ba58b94f0a9bdad4b3203e3368b3ec16f4add8edc6
checksum: 2214ba9982f70c7facbcd2b778bfaf92d90ff4fd71dd36697d2ac7f15b9a5d271872954a6fac84db04c16e9976ae20c7196586bef34addde7b65ce19e8a379b4
languageName: node
linkType: hard