|
@@ -23,6 +23,7 @@ import {
|
|
|
} from './context';
|
|
} from './context';
|
|
|
import { localStorageMiddleware } from './middlewares/sync-to-storage';
|
|
import { localStorageMiddleware } from './middlewares/sync-to-storage';
|
|
|
import { useStaticSWR } from './use-static-swr';
|
|
import { useStaticSWR } from './use-static-swr';
|
|
|
|
|
+import { constants } from 'zlib';
|
|
|
|
|
|
|
|
const { isSharedPage } = pagePathUtils;
|
|
const { isSharedPage } = pagePathUtils;
|
|
|
|
|
|
|
@@ -70,27 +71,26 @@ export const useIsMobile = (): SWRResponse<boolean, Error> => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const updateBodyClassesByEditorMode = (newEditorMode: EditorMode, isSidebar = false) => {
|
|
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) {
|
|
switch (newEditorMode) {
|
|
|
case EditorMode.View:
|
|
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;
|
|
break;
|
|
|
case EditorMode.Editor:
|
|
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
|
|
// editing /Sidebar
|
|
|
if (isSidebar) {
|
|
if (isSidebar) {
|
|
|
- $('body').addClass('editing-sidebar');
|
|
|
|
|
|
|
+ bodyElement.classList.add('editing-sidebar');
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case EditorMode.HackMD:
|
|
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;
|
|
break;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|