|
|
@@ -19,10 +19,11 @@ import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import {
|
|
|
useCurrentPageId, useCurrentPagePath, useIsEditable, useIsTrashPage, useIsUserPage, useIsGuestUser, useEmptyPageId,
|
|
|
- useIsNotCreatable, useIsSharedUser, useNotFoundTargetPathOrId, useIsForbidden, useIsIdenticalPath, useIsNotFoundPermalink, useCurrentUser, useIsDeleted,
|
|
|
+ useIsNotCreatable, useIsSharedUser, useNotFoundTargetPathOrId, useIsForbidden, useIsIdenticalPath, useIsNotFoundPermalink, useCurrentUser,
|
|
|
} from './context';
|
|
|
import { localStorageMiddleware } from './middlewares/sync-to-storage';
|
|
|
import { useStaticSWR } from './use-static-swr';
|
|
|
+import { constants } from 'zlib';
|
|
|
|
|
|
const { isSharedPage } = pagePathUtils;
|
|
|
|
|
|
@@ -70,27 +71,26 @@ export const useIsMobile = (): SWRResponse<boolean, Error> => {
|
|
|
};
|
|
|
|
|
|
const updateBodyClassesByEditorMode = (newEditorMode: EditorMode, isSidebar = false) => {
|
|
|
+ const bodyElement = document.getElementsByTagName('body')[0];
|
|
|
+ if (bodyElement == null) {
|
|
|
+ logger.warn('The body tag was not successfully obtained');
|
|
|
+ return;
|
|
|
+ }
|
|
|
switch (newEditorMode) {
|
|
|
case EditorMode.View:
|
|
|
- $('body').removeClass('on-edit');
|
|
|
- $('body').removeClass('builtin-editor');
|
|
|
- $('body').removeClass('hackmd');
|
|
|
- $('body').removeClass('editing-sidebar');
|
|
|
+ bodyElement.classList.remove('on-edit', 'builtin-editor', 'hackmd', 'editing-sidebar');
|
|
|
break;
|
|
|
case EditorMode.Editor:
|
|
|
- $('body').addClass('on-edit');
|
|
|
- $('body').addClass('builtin-editor');
|
|
|
- $('body').removeClass('hackmd');
|
|
|
+ bodyElement.classList.add('on-edit', 'builtin-editor');
|
|
|
+ bodyElement.classList.remove('hackmd');
|
|
|
// editing /Sidebar
|
|
|
if (isSidebar) {
|
|
|
- $('body').addClass('editing-sidebar');
|
|
|
+ bodyElement.classList.add('editing-sidebar');
|
|
|
}
|
|
|
break;
|
|
|
case EditorMode.HackMD:
|
|
|
- $('body').addClass('on-edit');
|
|
|
- $('body').addClass('hackmd');
|
|
|
- $('body').removeClass('builtin-editor');
|
|
|
- $('body').removeClass('editing-sidebar');
|
|
|
+ bodyElement.classList.add('on-edit', 'hackmd');
|
|
|
+ bodyElement.classList.remove('builtin-editor', 'editing-sidebar');
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
@@ -396,9 +396,9 @@ export const usePageTreeDescCountMap = (initialData?: UpdateDescCountData): SWRR
|
|
|
|
|
|
export const useIsAbleToShowTrashPageManagementButtons = (): SWRResponse<boolean, Error> => {
|
|
|
const { data: currentUser } = useCurrentUser();
|
|
|
- const { data: isDeleted } = useIsDeleted();
|
|
|
+ const { data: isTrashPage } = useIsTrashPage();
|
|
|
|
|
|
- return useStaticSWR('isAbleToShowTrashPageManagementButtons', isDeleted && currentUser != null);
|
|
|
+ return useStaticSWR('isAbleToShowTrashPageManagementButtons', isTrashPage && currentUser != null);
|
|
|
};
|
|
|
|
|
|
export const useIsAbleToShowPageManagement = (): SWRResponse<boolean, Error> => {
|