From bc14d1d0f8a77294ffa24ba637e91673d634b82d Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 7 Nov 2024 20:47:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(editor)=20collaborative=20user=20t?= =?UTF-8?q?ag=20hidden=20when=20read=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the user was in read-only mode, the user tag could be displayed when they were touching the doc. This commit fixes this issue. We add the full name instead of the email in the cursor tag. --- CHANGELOG.md | 1 + .../docs/doc-editor/components/BlockNoteEditor.tsx | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16bd5a3e..4ba72658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to ## Fixed - 🦺(backend) add comma to sub regex #408 +- 🐛(editor) collaborative user tag hidden when read only #385 ## [1.7.0] - 2024-10-24 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 2ef15e5a..bbb29a61 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 @@ -4,6 +4,7 @@ import { BlockNoteView } from '@blocknote/mantine'; import '@blocknote/mantine/style.css'; import { useCreateBlockNote } from '@blocknote/react'; import { HocuspocusProvider } from '@hocuspocus/provider'; +import { t } from 'i18next'; import React, { useCallback, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; @@ -26,7 +27,13 @@ const cssEditor = (readonly: boolean) => ` }; & .bn-editor { padding-right: 30px; - ${readonly && `padding-left: 30px;`} + ${ + readonly && + ` + padding-left: 30px; + pointer-events: none; + ` + } }; & .collaboration-cursor__caret.ProseMirror-widget{ word-wrap: initial; @@ -139,14 +146,14 @@ export const BlockNoteContent = ({ provider, fragment: provider.document.getXmlFragment('document-store'), user: { - name: userData?.email || 'Anonymous', + name: userData?.full_name || userData?.email || t('Anonymous'), color: randomColor(), }, }, dictionary: locales[lang as keyof typeof locales], uploadFile, }, - [provider, uploadFile, userData?.email, lang], + [lang, provider, uploadFile, userData?.email, userData?.full_name], ); useEffect(() => {