kaori 3 лет назад
Родитель
Сommit
92af5af366

+ 0 - 24
packages/app/src/client/services/EditorContainer.js

@@ -59,30 +59,6 @@ export default class EditorContainer extends Container {
     }
   }
 
-
-  // See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example
-  showUnsavedWarning(e) {
-    // Cancel the event
-    e.preventDefault();
-
-    // display browser default message
-    // Chrome requires returnValue to be set. -> https://www.bugbugnow.net/2022/01/beforeunload-dialog.html
-    e.returnValue = '';
-    return '';
-  }
-
-  disableUnsavedWarning() {
-    window.removeEventListener('beforeunload', this.showUnsavedWarning);
-    this.isSetBeforeunloadEventHandler = false;
-  }
-
-  enableUnsavedWarning() {
-    if (!this.isSetBeforeunloadEventHandler) {
-      window.addEventListener('beforeunload', this.showUnsavedWarning);
-      this.isSetBeforeunloadEventHandler = true;
-    }
-  }
-
   clearDraft(path) {
     delete this.drafts[path];
     window.localStorage.setItem('drafts', JSON.stringify(this.drafts));

+ 0 - 1
packages/app/src/components/Page.jsx

@@ -2,7 +2,6 @@ import React, { useEffect, useRef } from 'react';
 
 import PropTypes from 'prop-types';
 
-import { isEnabledShowUnsavedWarning } from '~/client/util/editor';
 import MarkdownTable from '~/client/models/MarkdownTable';
 import AppContainer from '~/client/services/AppContainer';
 import EditorContainer from '~/client/services/EditorContainer';

+ 0 - 2
packages/app/src/stores/editor.tsx

@@ -117,8 +117,6 @@ export const useUnsavedWarning = (): SWRResponse<boolean, Error> & IUnsavedWarni
   const swrResult =  useStaticSWR<boolean, Error>('isEnabledUnsavedWarning', undefined, {fallbackData: false});
   const { data: isEnabledUnsavedWarning } = swrResult
 
-  console.log({isEnabledUnsavedWarning});
-
   const showAlertDialog = (msg: string) => {
     if(isEnabledUnsavedWarning || false){
       return window.alert(msg);