diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx index 0a21cd45..ca1ed005 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx @@ -4,6 +4,7 @@ import * as Y from 'yjs'; import { useUpdateDoc } from '@/features/docs/doc-management/'; import { KEY_LIST_DOC_VERSIONS } from '@/features/docs/doc-versioning'; +import { isFirefox } from '@/utils/userAgent'; import { toBase64 } from '../utils'; @@ -87,10 +88,7 @@ const useSaveDoc = (docId: string, doc: Y.Doc, canSave: boolean) => { * if he wants to leave the page, by adding the popup, we let the time to the * request to be sent, and intercepted by the service worker (for the offline part). */ - const isFirefox = - navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - - if (typeof e !== 'undefined' && e.preventDefault && isFirefox) { + if (typeof e !== 'undefined' && e.preventDefault && isFirefox()) { e.preventDefault(); } }; diff --git a/src/frontend/apps/impress/src/utils/index.ts b/src/frontend/apps/impress/src/utils/index.ts index 559df58c..4f823731 100644 --- a/src/frontend/apps/impress/src/utils/index.ts +++ b/src/frontend/apps/impress/src/utils/index.ts @@ -1,2 +1,4 @@ +export * from './userAgent'; export * from './string'; +export * from './styleBuilder'; export * from './system'; diff --git a/src/frontend/apps/impress/src/utils/userAgent.ts b/src/frontend/apps/impress/src/utils/userAgent.ts new file mode 100644 index 00000000..fa30acf2 --- /dev/null +++ b/src/frontend/apps/impress/src/utils/userAgent.ts @@ -0,0 +1,2 @@ +export const isFirefox = () => + navigator.userAgent.toLowerCase().indexOf('firefox') > -1;