2023-04-21 11:55:11 +08:00
|
|
|
import React, { Suspense } from 'react';
|
2023-04-17 15:32:52 +08:00
|
|
|
import ReactDom from 'react-dom';
|
2023-04-21 11:55:11 +08:00
|
|
|
import { I18nextProvider } from 'react-i18next';
|
|
|
|
import i18n from './_i18n/i18n-sdoc-editor';
|
2023-04-27 10:36:49 +08:00
|
|
|
import { Utils } from './utils/utils';
|
2023-05-09 20:32:29 +08:00
|
|
|
import Loading from './components/loading';
|
2023-10-26 17:15:42 +08:00
|
|
|
import SdocEditor from './pages/sdoc/sdoc-editor';
|
2024-11-22 17:11:55 +08:00
|
|
|
import { MetadataStatusProvider } from './hooks';
|
|
|
|
import { CollaboratorsProvider } from './metadata';
|
2024-11-29 09:53:51 +08:00
|
|
|
import { TagsProvider } from './tag/hooks';
|
2024-12-21 15:39:40 +08:00
|
|
|
import { SimpleViewer } from '@seafile/sdoc-editor';
|
2023-04-17 15:32:52 +08:00
|
|
|
|
2025-01-22 15:42:05 +08:00
|
|
|
const { serviceURL, avatarURL, siteRoot, lang, mediaUrl, isPro, fileServerRoot } = window.app.config;
|
2023-04-23 16:54:59 +08:00
|
|
|
const { username, name } = window.app.userInfo;
|
2023-05-06 12:28:43 +08:00
|
|
|
const {
|
2024-12-07 17:40:43 +08:00
|
|
|
repoID, repoName, repoEncrypted, parentDir, filePerm,
|
2024-12-23 16:50:01 +08:00
|
|
|
docPath, docName, docUuid, seadocAccessToken, seadocServerUrl, assetsUrl,
|
2023-09-28 15:13:25 +08:00
|
|
|
isSdocRevision, isPublished, originFilename, revisionCreatedAt, originFileVersion,
|
2025-01-04 14:45:10 +08:00
|
|
|
originFilePath, originDocUuid, revisionId, isFreezed, mobileLogin, isRepoAdmin,
|
|
|
|
enableSeafileAI
|
2023-05-06 12:28:43 +08:00
|
|
|
} = window.app.pageOptions;
|
2023-04-17 15:32:52 +08:00
|
|
|
|
2023-04-18 18:23:03 +08:00
|
|
|
window.seafile = {
|
|
|
|
repoID,
|
2024-12-09 16:56:29 +08:00
|
|
|
isRepoAdmin,
|
2023-04-17 15:32:52 +08:00
|
|
|
docPath,
|
|
|
|
docName,
|
|
|
|
docUuid,
|
2023-04-18 18:23:03 +08:00
|
|
|
isOpenSocket: true,
|
|
|
|
serviceUrl: serviceURL,
|
|
|
|
accessToken: seadocAccessToken,
|
|
|
|
sdocServer: seadocServerUrl,
|
2023-04-23 16:54:59 +08:00
|
|
|
name,
|
2023-04-21 11:55:11 +08:00
|
|
|
username,
|
2023-04-23 16:54:59 +08:00
|
|
|
avatarURL,
|
2023-04-27 10:36:49 +08:00
|
|
|
siteRoot,
|
|
|
|
docPerm: filePerm,
|
|
|
|
historyURL: Utils.generateHistoryURL(siteRoot, repoID, docPath),
|
2023-05-09 20:32:29 +08:00
|
|
|
parentFolderURL: `${siteRoot}library/${repoID}/${Utils.encodePath(repoName + parentDir)}`,
|
2023-05-13 15:34:41 +08:00
|
|
|
assetsUrl,
|
2023-05-22 18:26:56 +08:00
|
|
|
isShowInternalLink: true,
|
2023-07-06 14:56:31 +08:00
|
|
|
isStarIconShown: true, // for star/unstar
|
2023-07-06 17:47:24 +08:00
|
|
|
isSdocRevision,
|
|
|
|
isPublished,
|
2023-07-07 16:07:14 +08:00
|
|
|
originFilename,
|
2023-09-28 15:13:25 +08:00
|
|
|
originFileVersion,
|
|
|
|
originFilePath,
|
|
|
|
originDocUuid,
|
2023-07-07 16:07:14 +08:00
|
|
|
revisionCreatedAt,
|
2023-08-07 17:45:28 +08:00
|
|
|
lang,
|
2023-10-26 17:15:42 +08:00
|
|
|
revisionId,
|
2023-11-17 13:00:30 +08:00
|
|
|
mediaUrl,
|
2023-11-21 13:53:40 +08:00
|
|
|
isFreezed,
|
2023-12-14 10:33:19 +08:00
|
|
|
isPro: isPro === 'True' ? true : false,
|
2024-12-07 14:21:37 +08:00
|
|
|
mobileLogin,
|
2025-01-04 14:45:10 +08:00
|
|
|
enableSeafileAI,
|
2025-01-22 15:42:05 +08:00
|
|
|
fileServerRoot,
|
2023-04-17 15:32:52 +08:00
|
|
|
};
|
|
|
|
|
2024-12-09 16:56:29 +08:00
|
|
|
const repoInfo = { encrypted: repoEncrypted, permission: filePerm, is_admin: isRepoAdmin };
|
2024-12-07 17:40:43 +08:00
|
|
|
|
2023-04-21 11:55:11 +08:00
|
|
|
ReactDom.render(
|
|
|
|
<I18nextProvider i18n={ i18n } >
|
|
|
|
<Suspense fallback={<Loading />}>
|
2024-12-30 19:00:50 +08:00
|
|
|
<MetadataStatusProvider repoID={repoID} repoInfo={repoInfo}>
|
2024-09-03 10:46:53 +08:00
|
|
|
<CollaboratorsProvider repoID={repoID}>
|
2024-12-07 17:40:43 +08:00
|
|
|
<TagsProvider repoID={repoID} repoInfo={repoInfo}>
|
2024-12-23 16:50:01 +08:00
|
|
|
{filePerm === 'rw' ? <SdocEditor /> : <SimpleViewer />}
|
2024-11-29 09:53:51 +08:00
|
|
|
</TagsProvider>
|
2024-09-03 10:46:53 +08:00
|
|
|
</CollaboratorsProvider>
|
2024-11-22 17:11:55 +08:00
|
|
|
</MetadataStatusProvider>
|
2023-04-21 11:55:11 +08:00
|
|
|
</Suspense>
|
|
|
|
</I18nextProvider>,
|
|
|
|
document.getElementById('wrapper')
|
|
|
|
);
|