From c39d2b40a8b38ab2da248cb636959d4379b4f501 Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Fri, 28 Jun 2024 19:51:17 +0100 Subject: [PATCH] Added Fixes & Features --- .../plugins/markdown/rendering/renderers.tsx | 4 +- code/client/src/pwa/manifest-config.ts | 40 +++++++++---------- code/client/src/pwa/pwa-config.ts | 18 ++++----- .../src/ui/components/sidebar/Sidebar.scss | 2 +- .../src/ui/components/sidebar/Sidebar.tsx | 9 ++++- .../collaborators/Collaborators.scss | 10 ++--- .../collaborators/Collaborators.tsx | 26 ++++++++++-- .../document/components/cursor/Cursor.tsx | 4 +- code/client/vite.config.ts | 10 ++--- .../http/middlewares/errorMiddleware.ts | 2 - .../ws/events/document/onCursorChange.ts | 2 +- .../ws/events/document/onJoinDocument.ts | 9 +++-- code/shared/src/users/types.ts | 1 + 13 files changed, 80 insertions(+), 57 deletions(-) diff --git a/code/client/src/domain/editor/slate/plugins/markdown/rendering/renderers.tsx b/code/client/src/domain/editor/slate/plugins/markdown/rendering/renderers.tsx index baf7d91d..68341eda 100644 --- a/code/client/src/domain/editor/slate/plugins/markdown/rendering/renderers.tsx +++ b/code/client/src/domain/editor/slate/plugins/markdown/rendering/renderers.tsx @@ -53,9 +53,9 @@ export const getLeafRenderer = ({ attributes, leaf, children }: RenderLeafProps) children = renderer(children); } if (leaf.cursor) { - const { color, range, styles } = leaf.cursor; + const { color, range, styles, id } = leaf.cursor; children = Range.isCollapsed(range!) ? ( - + ) : ( ); diff --git a/code/client/src/pwa/manifest-config.ts b/code/client/src/pwa/manifest-config.ts index 86f3e0d7..2093f829 100644 --- a/code/client/src/pwa/manifest-config.ts +++ b/code/client/src/pwa/manifest-config.ts @@ -1,22 +1,22 @@ -import {ManifestOptions} from "vite-plugin-pwa"; +import { ManifestOptions } from 'vite-plugin-pwa'; -const manifestConfig : Partial = { - name: 'NoteSpace', - short_name: 'NoteSpace', - description: 'A multiplatform note management and sharing app', - theme_color: '#ffffff', - icons: [ - { - src: '/assets/icon.png', - sizes: '192x192', - type: 'image/png', - }, - { - src: '/assets/icon.png', - sizes: '512x512', - type: 'image/png', - }, - ], -} +const manifestConfig: Partial = { + name: 'NoteSpace', + short_name: 'NoteSpace', + description: 'A multiplatform note management and sharing app', + theme_color: '#ffffff', + icons: [ + { + src: '/assets/icon.png', + sizes: '192x192', + type: 'image/png', + }, + { + src: '/assets/icon.png', + sizes: '512x512', + type: 'image/png', + }, + ], +}; -export default manifestConfig; \ No newline at end of file +export default manifestConfig; diff --git a/code/client/src/pwa/pwa-config.ts b/code/client/src/pwa/pwa-config.ts index b367228f..348755d0 100644 --- a/code/client/src/pwa/pwa-config.ts +++ b/code/client/src/pwa/pwa-config.ts @@ -1,11 +1,11 @@ -import {VitePWAOptions} from "vite-plugin-pwa"; +import { VitePWAOptions } from 'vite-plugin-pwa'; //import manifestConfig from "./manifest-config"; -const pwaConfig : Partial = { - registerType: 'autoUpdate', - //manifest: manifestConfig, - //devOptions: { - // enabled: true, - //} -} -export default pwaConfig; \ No newline at end of file +const pwaConfig: Partial = { + registerType: 'autoUpdate', + //manifest: manifestConfig, + //devOptions: { + // enabled: true, + //} +}; +export default pwaConfig; diff --git a/code/client/src/ui/components/sidebar/Sidebar.scss b/code/client/src/ui/components/sidebar/Sidebar.scss index 239914ab..713ca03d 100644 --- a/code/client/src/ui/components/sidebar/Sidebar.scss +++ b/code/client/src/ui/components/sidebar/Sidebar.scss @@ -26,7 +26,7 @@ border: none; color: black; font-size: 5vh; - padding: 0; + padding: 0 0 2vh 0; margin: 0; transition: transform 1s ease-in-out; diff --git a/code/client/src/ui/components/sidebar/Sidebar.tsx b/code/client/src/ui/components/sidebar/Sidebar.tsx index b8b06163..aa787630 100644 --- a/code/client/src/ui/components/sidebar/Sidebar.tsx +++ b/code/client/src/ui/components/sidebar/Sidebar.tsx @@ -18,10 +18,15 @@ function Sidebar() { if (!isLoaded || !isLoggedIn) return null; return ( -
+
- ); })}
diff --git a/code/client/src/ui/pages/document/components/cursor/Cursor.tsx b/code/client/src/ui/pages/document/components/cursor/Cursor.tsx index 971e29dc..8d6dd1ff 100644 --- a/code/client/src/ui/pages/document/components/cursor/Cursor.tsx +++ b/code/client/src/ui/pages/document/components/cursor/Cursor.tsx @@ -3,17 +3,19 @@ import { InlineStyle } from '@notespace/shared/src/document/types/styles'; import './Cursor.scss'; type CursorProps = { + id: string; color: string; styles: InlineStyle[]; children: ReactNode; }; -function Cursor({ children, styles, color }: CursorProps) { +function Cursor({ children, styles, color, id }: CursorProps) { const width = styles.includes('bold') ? '1.5px' : '1px'; const angle = styles.includes('italic') ? '11deg' : '0deg'; return ( <> ({ ...client.user, color: getCursorColor(client.socketId), + socketId: client.socketId, })) .filter(u => u.id !== user.id); - socket.emit('joinedDocument', users); + socket.emit('joinedDocument', collaborators); }; } diff --git a/code/shared/src/users/types.ts b/code/shared/src/users/types.ts index 21a206e8..b7eb1778 100644 --- a/code/shared/src/users/types.ts +++ b/code/shared/src/users/types.ts @@ -10,4 +10,5 @@ export type User = UserData & { export type Collaborator = UserData & { color: string; + socketId: string; };