From 55238a7767e95b4a3f0dc2cc1352031a50df4e83 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 23 Dec 2024 12:13:10 +0100 Subject: [PATCH] save --- docker-compose.yml | 4 +++- .../docs/doc-editor/components/BlockNoteEditor.tsx | 3 ++- .../docs/doc-management/stores/useProviderStore.tsx | 8 +++++++- src/frontend/apps/impress/src/utils/userAgent.ts | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 62d2d914b..bc9a8c6a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - "1081:1080" minio: - user: ${DOCKER_USER:-1000} + # user: ${DOCKER_USER:-1000} image: minio/minio environment: - MINIO_ROOT_USER=impress @@ -166,6 +166,8 @@ services: - env.d/development/common ports: - "4444:4444" + volumes: + - ./src/frontend/servers/y-provider:/home/frontend/servers/y-provider kc_postgresql: image: postgres:14.3 diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx index 868c5a6d2..4bd34f2d5 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx @@ -74,7 +74,8 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { const { setEditor } = useEditorStore(); const { t } = useTranslation(); - const readOnly = !doc.abilities.partial_update; + //const readOnly = !doc.abilities.partial_update; + const readOnly = false; useSaveDoc(doc.id, provider.document, !readOnly); const { i18n } = useTranslation(); const lang = i18n.language; diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/stores/useProviderStore.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/stores/useProviderStore.tsx index 58ca76f3b..65a82de85 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/stores/useProviderStore.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/stores/useProviderStore.tsx @@ -3,6 +3,7 @@ import * as Y from 'yjs'; import { create } from 'zustand'; import { Base64 } from '@/features/docs/doc-management'; +import { isFirefox } from '@/utils'; export interface UseCollaborationStore { createProvider: ( @@ -35,8 +36,13 @@ export const useProviderStore = create((set, get) => ({ Y.applyUpdate(doc, Buffer.from(initialDoc, 'base64')); } + // console.log('navigator.userAgent', navigator.userAgent); + // console.log('providerUrl', wsUrl); + const withWS = isFirefox(); + //const withWS = true; + const provider = new HocuspocusProvider({ - url: wsUrl, + url: !withWS ? 'ws://localhost:6666' : wsUrl, name: storeId, document: doc, onConnect: () => { diff --git a/src/frontend/apps/impress/src/utils/userAgent.ts b/src/frontend/apps/impress/src/utils/userAgent.ts index fa30acf28..8235e3add 100644 --- a/src/frontend/apps/impress/src/utils/userAgent.ts +++ b/src/frontend/apps/impress/src/utils/userAgent.ts @@ -1,2 +1,5 @@ export const isFirefox = () => navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + +export const isEdge = () => + navigator.userAgent.toLowerCase().indexOf('edg') > -1;