From 262271c7f2006688bcf9830d7fb29f944056fe2a Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 6 May 2024 12:42:16 +0300 Subject: [PATCH 01/57] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BB=D0=B8=D0=BD=D1=82=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 61 ++++++++++++++++++-------------- public/src/modules/validation.ts | 8 ++--- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index cb842a32..71278889 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,29 +1,36 @@ { - "env": { - "browser": true, - "es2021": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "rules": { - "@typescript-eslint/no-explicit-any": ["off"], - "@typescript-eslint/no-this-alias": ["off"], - "@typescript-eslint/ban-ts-comment": ["off"], - "@typescript-eslint/no-var-requires": ["off"], - "@typescript-eslint/no-unused-vars": ["off"], - "no-console":"off", - "no-restricted-syntax": ["error", "WithStatement"], - "no-param-reassign": "off", - "prefer-promise-reject-errors": ["error", {"allowEmptyReject": true}], - "no-restricted-globals": ["error", "event", "fdescribe"], - // "semi": ["error", "always"], - // "quotes": ["error", "single"], - "no-alert": "error", - "no-var": "error", - "no-debugger": "error", - "no-useless-escape":"off" - } + "env": { + "browser": true, + "es2021": true + }, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint" + ], + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "@typescript-eslint/no-explicit-any": ["off"], + "@typescript-eslint/no-this-alias": ["off"], + "@typescript-eslint/ban-ts-comment": ["off"], + "@typescript-eslint/no-var-requires": ["off"], + "@typescript-eslint/no-unused-vars": ["off"], + "no-undef": "off", + "no-unused-vars": ["off"], + "no-irregular-whitespace": "off", + "no-console":"off", + "no-restricted-syntax": ["error", "WithStatement"], + "no-param-reassign": "off", + "prefer-promise-reject-errors": ["error", {"allowEmptyReject": true}], + "no-restricted-globals": ["error", "event", "fdescribe"], + // "semi": ["error", "always"], + // "quotes": ["error", "single"], + "no-alert": "error", + "no-var": "error", + "no-debugger": "error", + "no-useless-escape":"off" + } } diff --git a/public/src/modules/validation.ts b/public/src/modules/validation.ts index 4893195e..3ff97e32 100644 --- a/public/src/modules/validation.ts +++ b/public/src/modules/validation.ts @@ -1,9 +1,9 @@ -export type ValidationResult = { +export type ValidationResultType = { message?: string, result: boolean } -export const ValidatePassword = (value:string):ValidationResult => { +export const ValidatePassword = (value:string):ValidationResultType => { for (let index = 0; index < value.length; ++index){ if (!(value.charCodeAt(index) >= 97 && value.charCodeAt(index) <= 122 || value.charCodeAt(index) >= 64 && value.charCodeAt(index) <= 90 || @@ -36,7 +36,7 @@ export const ValidatePassword = (value:string):ValidationResult => { }; -export const ValidateLogin = (value):ValidationResult => { +export const ValidateLogin = (value):ValidationResultType => { for (let index = 0; index < value.length; ++index){ if (!(value.charCodeAt(index) >= 97 && value.charCodeAt(index) <= 122 || value.charCodeAt(index) >= 64 && value.charCodeAt(index) <= 90 || @@ -61,6 +61,6 @@ export const ValidateLogin = (value):ValidationResult => { return ValidationResult(true); }; -const ValidationResult = (result:boolean, message:string = null):ValidationResult => { +const ValidationResult = (result:boolean, message:string = null):ValidationResultType => { return {result, message}; }; \ No newline at end of file From da15407e53ead25eef99cb5385f8e514f3e1caa7 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 17:46:52 +0300 Subject: [PATCH 02/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 99 ++++++++++++++++--------- 1 file changed, 62 insertions(+), 37 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 95441f18..2de79284 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -79,7 +79,8 @@ class NotesStore extends BaseStore { fullScreen: false }; - private ws + private editorWS + private invitesWS public socket_id constructor() { @@ -87,6 +88,58 @@ class NotesStore extends BaseStore { this.registerEvents(); } + async init () { + await this.fetchNotes(true); + await this.fetchTags() + + this.invitesWS = new WebSocketConnection(`api/note/subscribe/on_invites`) + + this.invitesWS.onOpen(() => { + console.log("invitesWS.onOpen") + // this.editorWS.sendMessage(JSON.stringify({ + // type: "opened", + // note_id: note.id, + // user_id: AppUserStore.state.user_id, + // username: AppUserStore.state.username, + // image_path: AppUserStore.state.avatarUrl + // })) + }) + + this.invitesWS.onMessage((event) => { + console.log("invitesWS.onMessage") + + let data = JSON.parse(event.data) + + console.log(data) + }) + + return this.state; + } + + exit () { + AppNotesStore.ClearCallbacks() + AppNoteStore.ClearCallbacks() + + this.SetState(state => ({ + ...state, + notes: [], + tags: [], + selectedTags: [], + selectedNote: null, + selectedNoteSynced: null, + selectedNoteCollaborators: [], + query: '', + offset: 0, + count: 10, + fetching: false, + noteNotFound: false, + fullScreen: false + })); + + this.invitesWS.close() + this.invitesWS = null + } + private registerEvents(){ AppDispatcher.register(async (action) => { switch (action.type){ @@ -198,28 +251,6 @@ class NotesStore extends BaseStore { } }); } - - exit () { - AppNotesStore.ClearCallbacks() - AppNoteStore.ClearCallbacks() - - this.SetState(state => ({ - ...state, - notes: [], - tags: [], - selectedTags: [], - selectedNote: null, - selectedNoteSynced: null, - selectedNoteCollaborators: [], - query: '', - offset: 0, - count: 10, - fetching: false, - noteNotFound: false, - fullScreen: false - })); - } - syncNotes = () => { const notes = this.state.notes; notes.forEach((note, index) => { @@ -272,15 +303,15 @@ class NotesStore extends BaseStore { } closeWS = () => { - if (this.ws && this.state.selectedNote) { - this.ws.sendMessage(JSON.stringify({ + if (this.editorWS && this.state.selectedNote) { + this.editorWS.sendMessage(JSON.stringify({ type: "closed", note_id: this.state.selectedNote.id, user_id: AppUserStore.state.user_id })) - this.ws.close() - this.ws = null + this.editorWS.close() + this.editorWS = null this.socket_id = null } } @@ -305,10 +336,10 @@ class NotesStore extends BaseStore { blocks: note.data.content }) - this.ws = new WebSocketConnection(`note/${note.id}/subscribe_on_updates`) + this.editorWS = new WebSocketConnection(`note/${note.id}/subscribe_on_updates`) - this.ws.onOpen(() => { - this.ws.sendMessage(JSON.stringify({ + this.editorWS.onOpen(() => { + this.editorWS.sendMessage(JSON.stringify({ type: "opened", note_id: note.id, user_id: AppUserStore.state.user_id, @@ -317,7 +348,7 @@ class NotesStore extends BaseStore { })) }) - this.ws.onMessage((event) => { + this.editorWS.onMessage((event) => { let data = JSON.parse(event.data) // Если socket_id совпадает, то ничего обновлять не надо @@ -386,12 +417,6 @@ class NotesStore extends BaseStore { history.pushState(null, null, '/notes/' + id) } - async init () { - await this.fetchNotes(true); - await this.fetchTags() - return this.state; - } - async searchNotes ({query, selectedTags}) { this.SetState(state => ({ ...state, From 195565d08df1db70b0f64ee88b8d6fea04ad5833 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 17:48:36 +0300 Subject: [PATCH 03/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 2de79284..0a1d6ad0 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -92,7 +92,7 @@ class NotesStore extends BaseStore { await this.fetchNotes(true); await this.fetchTags() - this.invitesWS = new WebSocketConnection(`api/note/subscribe/on_invites`) + this.invitesWS = new WebSocketConnection(`note/subscribe/on_invites`) this.invitesWS.onOpen(() => { console.log("invitesWS.onOpen") From 3c01cd47e12e3717c8429dcef0613e6eb7ea8f4f Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:07:09 +0300 Subject: [PATCH 04/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 0a1d6ad0..449a2bd6 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -111,6 +111,36 @@ class NotesStore extends BaseStore { let data = JSON.parse(event.data) console.log(data) + + if (data.type == "invite") { + const owner = data.owner + const created = data.created + const title = data.note_title.replace("\\", "").replace('"', "") + AppToasts.info(owner + " пригласил вас в свою заметку!") + + const note = { + "id": data.note_id, + "data": null, + "create_time": data.created, + "update_time": data.created, + "owner_id": null, + "parent": "00000000-0000-0000-0000-000000000000", + "children": [], + "tags": [], + "collaborators": [], + "icon": "", + "header": "", + "favorite": false, + "public": false + } + + this.SetState(state => ({ + ...state, + // offset: state.offset + 1, ? + notes: [note, ...state.notes] + })); + + } }) return this.state; @@ -251,6 +281,7 @@ class NotesStore extends BaseStore { } }); } + syncNotes = () => { const notes = this.state.notes; notes.forEach((note, index) => { @@ -650,6 +681,8 @@ class NotesStore extends BaseStore { if (status == 204) { AppToasts.success("Приглашение успешно отправлено") + } else if (status == 409) { + AppToasts.info("Пользователь уже приглашен") } else { AppToasts.error("Пользователь не найден") } From 464dfc2fa209d119ae6c49e8e1a13d067a71feb7 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:12:02 +0300 Subject: [PATCH 05/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 9 ++++++--- public/src/utils/types.ts | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 449a2bd6..a6cdbadb 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -8,6 +8,7 @@ import {WebSocketConnection} from "../websocket"; import {insertBlockPlugin} from "../../components/Editor/Plugin"; import {AppNoteStore, NoteStoreActions} from "./NoteStore"; import {downloadFile, parseNoteTitle} from "../utils"; +import {Note} from '../../components/Note/Note'; export type NotesStoreState = { notes: NoteType[], @@ -118,10 +119,12 @@ class NotesStore extends BaseStore { const title = data.note_title.replace("\\", "").replace('"', "") AppToasts.info(owner + " пригласил вас в свою заметку!") - const note = { + const note:NoteType = { "id": data.note_id, - "data": null, - "create_time": data.created, + "data": { + "title": data.note_title, + "content": [] + }, "update_time": data.created, "owner_id": null, "parent": "00000000-0000-0000-0000-000000000000", diff --git a/public/src/utils/types.ts b/public/src/utils/types.ts index 30ebaf44..afd6748a 100644 --- a/public/src/utils/types.ts +++ b/public/src/utils/types.ts @@ -9,6 +9,7 @@ export type NoteType = { }, update_time: string, owner_id: string, + collaborators: string[], icon: string, header: string, favorite: boolean, From 8396660743c1aaefb9f3cfb6c0fb7d4cbd5f3dca Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:30:05 +0300 Subject: [PATCH 06/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Button/Button.tsx | 9 ++++++++- public/src/components/Toast/Toast.sass | 3 +++ public/src/components/Toast/Toast.tsx | 1 + public/src/modules/stores/NotesStore.ts | 4 +--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/public/src/components/Button/Button.tsx b/public/src/components/Button/Button.tsx index 63347874..ab252eed 100644 --- a/public/src/components/Button/Button.tsx +++ b/public/src/components/Button/Button.tsx @@ -1,7 +1,14 @@ import {ScReact} from '@veglem/screact'; import './Button.sass'; -export class Button extends ScReact.Component{ +type ButtonProps = { + label: string, + disabled: boolean, + className?: string, + onClick: (e) => void +} + +export class Button extends ScReact.Component{ handleClick = (e) => { this.props.onClick && !this.props.disabled && this.props.onClick(e); diff --git a/public/src/components/Toast/Toast.sass b/public/src/components/Toast/Toast.sass index 11b0eec4..1d61ad07 100644 --- a/public/src/components/Toast/Toast.sass +++ b/public/src/components/Toast/Toast.sass @@ -41,6 +41,9 @@ .toast-icon height: 30px width: 30px + background-color: #fff + border-radius: 50% + overflow: hidden .content display: flex diff --git a/public/src/components/Toast/Toast.tsx b/public/src/components/Toast/Toast.tsx index 71a3701f..931dcb05 100644 --- a/public/src/components/Toast/Toast.tsx +++ b/public/src/components/Toast/Toast.tsx @@ -2,6 +2,7 @@ import {ScReact} from '@veglem/screact'; import {Img} from '../Image/Image'; import './Toast.sass'; import {TOAST_TYPE} from '../../modules/toasts'; +import {Button} from '../Button/Button'; export type ToastProps = { type: string, diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index a6cdbadb..b77693b4 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -115,14 +115,12 @@ class NotesStore extends BaseStore { if (data.type == "invite") { const owner = data.owner - const created = data.created - const title = data.note_title.replace("\\", "").replace('"', "") AppToasts.info(owner + " пригласил вас в свою заметку!") const note:NoteType = { "id": data.note_id, "data": { - "title": data.note_title, + "title": data.note_title.replace('"', ""), "content": [] }, "update_time": data.created, From a4f0cdf03b8a79c9540626e0707614f429d9c994 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 21:46:05 +0300 Subject: [PATCH 07/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=83=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=20=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 52 ++++++------------------- public/src/utils/variables.sass | 2 +- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index b77693b4..373a72e2 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -95,52 +95,22 @@ class NotesStore extends BaseStore { this.invitesWS = new WebSocketConnection(`note/subscribe/on_invites`) - this.invitesWS.onOpen(() => { - console.log("invitesWS.onOpen") - // this.editorWS.sendMessage(JSON.stringify({ - // type: "opened", - // note_id: note.id, - // user_id: AppUserStore.state.user_id, - // username: AppUserStore.state.username, - // image_path: AppUserStore.state.avatarUrl - // })) - }) - - this.invitesWS.onMessage((event) => { - console.log("invitesWS.onMessage") - + this.invitesWS.onMessage(async (event) => { let data = JSON.parse(event.data) - console.log(data) - if (data.type == "invite") { - const owner = data.owner - AppToasts.info(owner + " пригласил вас в свою заметку!") - - const note:NoteType = { - "id": data.note_id, - "data": { - "title": data.note_title.replace('"', ""), - "content": [] - }, - "update_time": data.created, - "owner_id": null, - "parent": "00000000-0000-0000-0000-000000000000", - "children": [], - "tags": [], - "collaborators": [], - "icon": "", - "header": "", - "favorite": false, - "public": false - } + try { + const note = await AppNoteRequests.Get(data.note_id, AppUserStore.state.JWT) - this.SetState(state => ({ - ...state, - // offset: state.offset + 1, ? - notes: [note, ...state.notes] - })); + AppToasts.info(data.owner + " пригласил вас в свою заметку!") + this.SetState(state => ({ + ...state, + notes: [note, ...state.notes] + })); + } catch { + AppToasts.error("Что-то пошло не так") + } } }) diff --git a/public/src/utils/variables.sass b/public/src/utils/variables.sass index ecabf098..eed7008a 100644 --- a/public/src/utils/variables.sass +++ b/public/src/utils/variables.sass @@ -24,5 +24,5 @@ $xs: 320px $sm: 576px $md: 768px $lg: 992px -$xl: 1240px +$xl: 1275px $xxl: 1650px \ No newline at end of file From 6a97d84bc6a520464344c88f1d1d60949da1ac4e Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 16:47:46 +0300 Subject: [PATCH 08/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 6 ++++-- .../{Editor => EditorWrapper}/EditorWrapper.tsx | 8 ++++---- public/src/components/NoteEditor/NoteEditor.tsx | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) rename public/src/components/{Editor => EditorWrapper}/EditorWrapper.tsx (97%) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index c4a7723c..17fa9923 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1,7 +1,7 @@ import {AppUserStore} from "../../modules/stores/UserStore"; import {parseNoteTitle, setCursorAtNodePosition, truncate} from "../../modules/utils"; import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore"; -import {AppNoteRequests} from "../../modules/api"; +import {AppNoteRequests, AppSharedNoteRequests} from '../../modules/api'; import {AppDispatcher} from "../../modules/dispatcher"; import {AppToasts} from "../../modules/toasts"; import {AppNoteStore, NoteStoreActions} from "../../modules/stores/NoteStore"; @@ -1108,7 +1108,9 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] loaded = true } else { - AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => { + + const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + request.then(result => { if (result.data.title == null) { subNoteTitle.innerHTML = 'Подзаметка' } diff --git a/public/src/components/Editor/EditorWrapper.tsx b/public/src/components/EditorWrapper/EditorWrapper.tsx similarity index 97% rename from public/src/components/Editor/EditorWrapper.tsx rename to public/src/components/EditorWrapper/EditorWrapper.tsx index 8c127468..aafe6487 100644 --- a/public/src/components/Editor/EditorWrapper.tsx +++ b/public/src/components/EditorWrapper/EditorWrapper.tsx @@ -1,13 +1,13 @@ import {Component} from "@veglem/screact/dist/component"; import {VDomNode} from "@veglem/screact/dist/vdom"; -import "./Editor.sass" -import {Editor} from "./Editor"; +import "../Editor/Editor.sass" +import {Editor} from "../Editor/Editor"; import {AppNoteStore, NoteStoreState} from "../../modules/stores/NoteStore"; import {Tippy} from "../Tippy/Tippy"; import {isEqual} from "@veglem/screact/dist/isEqual"; -import {Viewer} from "./Viewer"; +import {Viewer} from "../Editor/Viewer"; import {NoteType} from "../../utils/types"; -import {PluginProps} from "./Plugin"; +import {PluginProps} from "../Editor/Plugin"; import {parseNoteTitle} from "../../modules/utils"; window['mobileCheck'] = function() { diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index b11a302e..a834199a 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -10,7 +10,7 @@ import {DeleteNoteDialog} from '../DeleteNoteDialog/DeleteNoteDialog'; import NoteMenu from "../NoteMenu/NoteMenu"; import {Tooltip} from "../Tooltip/Tooltip"; import {TagList} from "../TagList/TagList"; -import {EditorWrapper} from "../Editor/EditorWrapper"; +import {EditorWrapper} from "../EditorWrapper/EditorWrapper"; import {AppUserStore} from "../../modules/stores/UserStore"; import {Collaborators} from "../Collaborators/Collaborators"; import {EmojiPicker} from "../EmojiPicker/EmojiPicker"; From 5aafc74ef1d833cad7a51de786c1cdf8bb9d953d Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 16:53:13 +0300 Subject: [PATCH 09/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 17fa9923..ea03a3b3 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1073,7 +1073,10 @@ const RenderSubNote = (subNoteId:string) => { const isOwner= AppNotesStore.state.selectedNote?.owner_id == AppUserStore.state.user_id - if (isOwner) { + console.log(1) + console.log(isOwner) + if (isOwner && pluginSettings.isEditable) { + console.log(2) const deleteSubNoteBtnContainer = document.createElement("div") deleteSubNoteBtnContainer.className = "delete-subnote-btn-container" @@ -1082,6 +1085,7 @@ const RenderSubNote = (subNoteId:string) => { deleteSubNoteBtn.className = "delete-subnote-btn" if (pluginSettings.isEditable) { + console.log(3) deleteSubNoteBtnContainer.onclick = (e) => { e.stopPropagation() subNoteWrapper.remove(); From 6b60247205eb283dea09645a4488d178856c5e91 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:07:40 +0300 Subject: [PATCH 10/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 22 +++++++++++++--------- public/src/modules/router.tsx | 5 +---- public/src/pages/SharedNote/index.tsx | 8 -------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index ea03a3b3..8be8991c 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -5,6 +5,7 @@ import {AppNoteRequests, AppSharedNoteRequests} from '../../modules/api'; import {AppDispatcher} from "../../modules/dispatcher"; import {AppToasts} from "../../modules/toasts"; import {AppNoteStore, NoteStoreActions} from "../../modules/stores/NoteStore"; +import {AppRouter} from '../../modules/router'; interface EditorPlugin { pluginName: string; @@ -1072,11 +1073,9 @@ const RenderSubNote = (subNoteId:string) => { subNoteContainer.appendChild(subNoteTitle) const isOwner= AppNotesStore.state.selectedNote?.owner_id == AppUserStore.state.user_id + const isAuth = AppUserStore.state.isAuth - console.log(1) - console.log(isOwner) - if (isOwner && pluginSettings.isEditable) { - console.log(2) + if (isAuth && isOwner && pluginSettings.isEditable) { const deleteSubNoteBtnContainer = document.createElement("div") deleteSubNoteBtnContainer.className = "delete-subnote-btn-container" @@ -1085,7 +1084,6 @@ const RenderSubNote = (subNoteId:string) => { deleteSubNoteBtn.className = "delete-subnote-btn" if (pluginSettings.isEditable) { - console.log(3) deleteSubNoteBtnContainer.onclick = (e) => { e.stopPropagation() subNoteWrapper.remove(); @@ -1132,13 +1130,19 @@ const RenderSubNote = (subNoteId:string) => { }); } - if (pluginSettings.isEditable) { - subNoteWrapper.onclick = () => { - if (!subNoteWrapper.dataset.deleted && loaded) { + subNoteWrapper.onclick = () => { + if (!subNoteWrapper.dataset.deleted && loaded) { + if (isAuth) { AppDispatcher.dispatch(NotesActions.OPEN_NOTE, subNoteId) } else { - AppToasts.error("Заметка не найдена") + AppSharedNoteRequests.Get(subNoteId).then(result => { + AppRouter.openSharedNotePage(result) + }).catch((e) => { + AppToasts.error("Заметка не найдена") + }); } + } else { + AppToasts.error("Заметка не найдена") } } diff --git a/public/src/modules/router.tsx b/public/src/modules/router.tsx index 401148ee..36b088a9 100644 --- a/public/src/modules/router.tsx +++ b/public/src/modules/router.tsx @@ -135,9 +135,6 @@ export class Router extends ScReact.Component { page = this.pages['/notes']; } - console.log("history.pushState") - console.log(path) - console.log(raw) history.pushState(null, null, path); if (page === undefined) { @@ -182,7 +179,7 @@ export class Router extends ScReact.Component { } public openSharedNotePage (note:NoteType) { - history.pushState(null, null, "/notes/" + note.id); + // history.pushState(null, null, "/notes/" + note.id); this.setState(s => ({ ...s, diff --git a/public/src/pages/SharedNote/index.tsx b/public/src/pages/SharedNote/index.tsx index 07964ba0..6ccc64cb 100644 --- a/public/src/pages/SharedNote/index.tsx +++ b/public/src/pages/SharedNote/index.tsx @@ -2,8 +2,6 @@ import {ScReact} from "@veglem/screact"; import "./style.sass" import "../../components/Editor/Editor.sass" import {ViewerWrapper} from "../../components/ViewerWrapper/ViewerWrapper"; -import {AppNotesStore} from "../../modules/stores/NotesStore"; -import {NoteStoreActions} from "../../modules/stores/NoteStore"; export class SharedNotePage extends ScReact.Component { state = { @@ -15,7 +13,6 @@ export class SharedNotePage extends ScReact.Component { ...state, fullScreen: true })) - document.getElementById("header").classList.add("fullscreen") } closeFullScreen = () => { @@ -23,11 +20,6 @@ export class SharedNotePage extends ScReact.Component { ...state, fullScreen: false })) - document.getElementById("header").classList.remove("fullscreen") - } - - componentWillUnmount() { - console.log("asdfasdfas") } render () { From 0174f1d20d9da2002b3dac4d603d901b0c3dab9c Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:11:20 +0300 Subject: [PATCH 11/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 1 - public/src/modules/router.tsx | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 8be8991c..921b6563 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1097,7 +1097,6 @@ const RenderSubNote = (subNoteId:string) => { } } - deleteSubNoteBtnContainer.appendChild(deleteSubNoteBtn) subNoteContainer.appendChild(deleteSubNoteBtnContainer) } diff --git a/public/src/modules/router.tsx b/public/src/modules/router.tsx index 36b088a9..7b927add 100644 --- a/public/src/modules/router.tsx +++ b/public/src/modules/router.tsx @@ -179,7 +179,10 @@ export class Router extends ScReact.Component { } public openSharedNotePage (note:NoteType) { - // history.pushState(null, null, "/notes/" + note.id); + console.log("openSharedNotePage") + console.log(note) + + history.pushState(null, null, "/notes/" + note.id); this.setState(s => ({ ...s, From 718b43aa44dada66557aa5ace2b4a0b503e4ee06 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:14:54 +0300 Subject: [PATCH 12/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.tsx b/public/src/components/ViewerWrapper/ViewerWrapper.tsx index 63360a0b..950cae81 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.tsx +++ b/public/src/components/ViewerWrapper/ViewerWrapper.tsx @@ -22,7 +22,8 @@ export class ViewerWrapper extends ScReact.Component { private noteContentRef private viewerRef - componentDidMount() { + componentDidUpdate() { + console.log("componentDidUpdate") this.noteContentRef.innerHTML = "" new Viewer( this.props.note.data.content, From cba90c00e647d9912c397fc63116b575cf4874de Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:18:04 +0300 Subject: [PATCH 13/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.tsx b/public/src/components/ViewerWrapper/ViewerWrapper.tsx index 950cae81..eaf028db 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.tsx +++ b/public/src/components/ViewerWrapper/ViewerWrapper.tsx @@ -22,6 +22,15 @@ export class ViewerWrapper extends ScReact.Component { private noteContentRef private viewerRef + componentDidMount() { + console.log("componentDidMount") + this.noteContentRef.innerHTML = "" + new Viewer( + this.props.note.data.content, + this.noteContentRef + ); + } + componentDidUpdate() { console.log("componentDidUpdate") this.noteContentRef.innerHTML = "" From f4ba99a3b85882f69c734e219714af4dc4f7f589 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 27 May 2024 15:57:26 +0300 Subject: [PATCH 14/57] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D1=81=D0=BE=D0=BC=20=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B5=20=D1=88=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.sass b/public/src/components/ViewerWrapper/ViewerWrapper.sass index e49cd3c5..89a49dd4 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.sass +++ b/public/src/components/ViewerWrapper/ViewerWrapper.sass @@ -7,6 +7,7 @@ border-radius: 12px position: relative overflow: hidden + word-break: break-word &.fullscreen width: 100% From 24acc71d54e09e50165f25deb2987e0b85d09935 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 27 May 2024 22:53:44 +0300 Subject: [PATCH 15/57] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D0=BF=D1=80=D0=B5=D0=B2=D1=8C=D1=8E=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B2=D0=BD?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/assets/info_circle.svg | 1 + public/src/assets/user.svg | 1 + public/src/components/Note/Note.sass | 15 ++++++ public/src/components/Note/Note.tsx | 15 +++++- .../src/components/NoteEditor/NoteEditor.tsx | 48 +++++++++++-------- 5 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 public/src/assets/info_circle.svg create mode 100644 public/src/assets/user.svg diff --git a/public/src/assets/info_circle.svg b/public/src/assets/info_circle.svg new file mode 100644 index 00000000..3ea15d3d --- /dev/null +++ b/public/src/assets/info_circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/src/assets/user.svg b/public/src/assets/user.svg new file mode 100644 index 00000000..82b9c811 --- /dev/null +++ b/public/src/assets/user.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index c53da25b..2e905d73 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -27,6 +27,21 @@ align-items: center gap: 5px + .owner-info + position: absolute + display: flex + align-items: center + gap: 8px + bottom: 10px + left: 15px + color: $text-secondary-color + + &__user-avatar + width: 14px + height: 14px + filter: invert(70%) + + .note-tags-container display: flex gap: 5px diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index f1f556fc..c64bad27 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -3,9 +3,9 @@ import './Note.sass'; import {formatDate, parseNoteTitle, truncate, unicodeToChar} from "../../modules/utils"; import {NoteType} from "../../utils/types"; import {Img} from "../Image/Image"; -import {Tooltip} from "../Tooltip/Tooltip"; import {AppDispatcher} from "../../modules/dispatcher"; import {NotesActions} from "../../modules/stores/NotesStore"; +import {AppUserStore} from '../../modules/stores/UserStore'; const MAX_NOTE_CONTENT_PREVIEW_LENGTH = 20; const MAX_TAGS_PREVIEW_COUNT = 2; @@ -50,8 +50,12 @@ export class Note extends ScReact.Component { } render() { + const isOwner = this.props.note.owner_id == AppUserStore.state.user_id + + // TODO: выводить логин овнера заметки, если юзер является коллаборатором + return ( -
+
{this.props.note.icon ? unicodeToChar(this.props.note.icon) : ""}

{truncate(parseNoteTitle(this.props.note.data.title), MAX_NOTE_CONTENT_PREVIEW_LENGTH)}

@@ -60,6 +64,13 @@ export class Note extends ScReact.Component { {formatDate(this.props.note.update_time)} + + {!isOwner ? +
+ + {"user91"} +
: "" + }
); } diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index a834199a..cb422ad8 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -338,7 +338,7 @@ export class NoteEditor extends ScReact.Component
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + content={} + /> : '' }
@@ -388,19 +388,19 @@ export class NoteEditor extends ScReact.Component - {this.state.noteStatus == "sync" ? + {this.state.noteStatus == 'sync' ?
- + + hoverTooltip={'Синхронизированно'}/>
:
- + + hoverTooltip={'Сохранено'}/>
} @@ -433,16 +433,16 @@ export class NoteEditor extends ScReact.Component
-
+
-
+
+ + Date: Mon, 27 May 2024 23:01:32 +0300 Subject: [PATCH 16/57] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BE=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D1=86=D0=B5=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Note/Note.sass | 1 - public/src/components/NoteEditor/NoteEditor.tsx | 13 ++++++++----- public/src/components/Tooltip/Tooltip.tsx | 7 +++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index 2e905d73..7f8e3aec 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -41,7 +41,6 @@ height: 14px filter: invert(70%) - .note-tags-container display: flex gap: 5px diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index cb422ad8..292da5c2 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,11 +451,14 @@ export class NoteEditor extends ScReact.Component
- + { + !isOwner ? + : "" + } { onclick={() => this.props.onClick && this.props.onClick() } > -
this.openBtnRef = ref}> +
this.openBtnRef = ref}>
{this.props.iconFromUnicode ? String.fromCodePoint(parseInt(this.props.icon, 16)) : } @@ -61,10 +61,9 @@ export class Tooltip extends ScReact.Component { {this.props.showHoverTooltip ?
{this.props.hoverTooltip} -
- : - "" +
: "" } +
this.tooltipContentRef = ref}> From 76f63ecf441acf28248f3a28143287037ef61b07 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Wed, 29 May 2024 00:32:38 +0300 Subject: [PATCH 17/57] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BA=D1=8D=D1=88=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 37 ++++++++++++++----- .../src/components/NoteEditor/NoteEditor.tsx | 16 ++++---- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 921b6563..fc691ed3 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -495,8 +495,6 @@ export const defaultPlugins: EditorPlugin[] = [ img.dataset.imgid = id; img.className = "img" - - if (id in AppNoteStore.state.cache) { img.src = AppNoteStore.state.cache[id] } else { @@ -1052,6 +1050,8 @@ const RenderAttach = (attach_filename:string, attach_id:string) => { } const RenderSubNote = (subNoteId:string) => { + console.log("RenderSubNote") + const subNoteWrapper = document.createElement("button") subNoteWrapper.className = "subnote-wrapper" @@ -1105,18 +1105,36 @@ const RenderSubNote = (subNoteId:string) => { let loaded = false - if (subNoteId in AppNoteStore.state.cache) { - subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] - loaded = true - } else { - - const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + // if (subNoteId in AppNoteStore.state.cache) { + // subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] + // loaded = true + // } else { + // + // const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + // request.then(result => { + // if (result.data.title == null) { + // subNoteTitle.innerHTML = 'Подзаметка' + // } + // + // //subNoteWrapper.dataset.title = parseNoteTitle(result.data.title) + // subNoteTitle.innerHTML = parseNoteTitle(result.data.title) + // + // AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) + // + // loaded = true + // + // }).catch((e) => { + // subNoteTitle.innerHTML = "Заметка не найдена" + // subNoteWrapper.dataset.deleted = "true" + // }); + // } + + const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) request.then(result => { if (result.data.title == null) { subNoteTitle.innerHTML = 'Подзаметка' } - //subNoteWrapper.dataset.title = parseNoteTitle(result.data.title) subNoteTitle.innerHTML = parseNoteTitle(result.data.title) AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) @@ -1127,7 +1145,6 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = "Заметка не найдена" subNoteWrapper.dataset.deleted = "true" }); - } subNoteWrapper.onclick = () => { if (!subNoteWrapper.dataset.deleted && loaded) { diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index 292da5c2..a22f3286 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,14 +451,14 @@ export class NoteEditor extends ScReact.Component
- { - !isOwner ? - : "" - } + {/*{*/} + {/* !isOwner ?*/} + {/* : ""*/} + {/*}*/} Date: Wed, 29 May 2024 17:45:16 +0300 Subject: [PATCH 18/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=B0=20=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 2 -- public/src/components/Note/Note.tsx | 2 +- public/src/components/NoteEditor/NoteEditor.tsx | 16 ++++++++-------- public/src/modules/stores/NotesStore.ts | 1 - public/src/utils/types.ts | 4 +++- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index fc691ed3..455edf92 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1137,8 +1137,6 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = parseNoteTitle(result.data.title) - AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) - loaded = true }).catch((e) => { diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index c64bad27..73640677 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -68,7 +68,7 @@ export class Note extends ScReact.Component { {!isOwner ?
- {"user91"} + {this.props.note.username}
: "" }
diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index a22f3286..172140da 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,14 +451,14 @@ export class NoteEditor extends ScReact.Component
- {/*{*/} - {/* !isOwner ?*/} - {/* : ""*/} - {/*}*/} + { + !isOwner ? + : "" + } Date: Wed, 29 May 2024 23:34:24 +0300 Subject: [PATCH 19/57] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=B8=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BA=D1=83=20=D1=81=20=D0=B4=D0=B2=D1=83?= =?UTF-8?q?=D1=85=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Note/Note.sass | 1 + public/src/components/Note/Note.tsx | 2 -- public/src/modules/stores/NotesStore.ts | 5 ++++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index 7f8e3aec..16b86bad 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -11,6 +11,7 @@ cursor: pointer transition: 0.5s position: relative + // border: 1px solid hsl(217.2 32.6% 25%) * pointer-events: none diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index 73640677..1431fe74 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -52,8 +52,6 @@ export class Note extends ScReact.Component { render() { const isOwner = this.props.note.owner_id == AppUserStore.state.user_id - // TODO: выводить логин овнера заметки, если юзер является коллаборатором - return (
diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index d37db370..1099b18c 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -388,7 +388,10 @@ class NotesStore extends BaseStore { } else if (data.type == "updated") { const noteData = JSON.parse(data.message_info) as NoteDataType - if (JSON.stringify(noteData) == JSON.stringify(this.state.selectedNote.data)) { + console.log(noteData) + console.log(this.state.selectedNote.data) + console.log(JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) + if (JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) { return } From f4d4158e31d7484b8e8e299c16439075e64a7de4 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Thu, 30 May 2024 00:14:35 +0300 Subject: [PATCH 20/57] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=B8=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BA=D1=83=20=D1=81=20=D0=B4=D0=B2=D1=83?= =?UTF-8?q?=D1=85=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 1099b18c..d37db370 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -388,10 +388,7 @@ class NotesStore extends BaseStore { } else if (data.type == "updated") { const noteData = JSON.parse(data.message_info) as NoteDataType - console.log(noteData) - console.log(this.state.selectedNote.data) - console.log(JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) - if (JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) { + if (JSON.stringify(noteData) == JSON.stringify(this.state.selectedNote.data)) { return } From 8660a5a867e0d9f4898406dba7118c2d5c7650e8 Mon Sep 17 00:00:00 2001 From: ZhurmilovVadim Date: Thu, 30 May 2024 23:03:27 +0300 Subject: [PATCH 21/57] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20ui?= =?UTF-8?q?=20kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 7 +++++++ package.json | 1 + public/src/components/Toast/Toast.tsx | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1f365207..e3c6462f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@typescript-eslint/eslint-plugin": "^7.7.0", "@typescript-eslint/parser": "^7.7.0", "@veglem/screact": "^1.0.13", + "@veglem/ui-kit": "^1.0.6", "@webpack-cli/generators": "^3.0.7", "autoprefixer": "^10.4.19", "babel-loader": "^9.1.3", @@ -4087,6 +4088,12 @@ "integrity": "sha512-IQ+pAWnH/DAPCiM8O4SIJtR5tXVKl3p4WuotQmDjZOIA0rQRHiVEJ6wpsY+I07lgf6ftOyEGXXi12B2u4hihAg==", "dev": true }, + "node_modules/@veglem/ui-kit": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@veglem/ui-kit/-/ui-kit-1.0.6.tgz", + "integrity": "sha512-PO6b+aBx/BSv0d330WZONudQxQZBw7yq6xWeleSrZ5idZdTsXY5t4M1NnssYsKQ/oZZqBfN6y8xGJ43tM7pP+A==", + "dev": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", diff --git a/package.json b/package.json index 90a28a7f..2f8802bd 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "serve": "webpack serve --node-env=development" }, "devDependencies": { + "@veglem/ui-kit": "^1.0.6", "@babel/cli": "^7.23.9", "@babel/core": "^7.24.0", "@babel/plugin-proposal-decorators": "^7.24.0", diff --git a/public/src/components/Toast/Toast.tsx b/public/src/components/Toast/Toast.tsx index 71a3701f..5357674f 100644 --- a/public/src/components/Toast/Toast.tsx +++ b/public/src/components/Toast/Toast.tsx @@ -2,6 +2,7 @@ import {ScReact} from '@veglem/screact'; import {Img} from '../Image/Image'; import './Toast.sass'; import {TOAST_TYPE} from '../../modules/toasts'; +import {uiKit} from '@veglem/ui-kit/dist/ui' export type ToastProps = { type: string, @@ -16,18 +17,17 @@ export class Toast extends ScReact.Component { closeToast = () => { this.props.onHide(this.props.key1); }; - formatType ():string { if (this.props.type == TOAST_TYPE.SUCCESS) { return 'Успех'; } else if (this.props.type == TOAST_TYPE.ERROR) { return 'Ошибка'; } - return 'Инфо'; } render() { + const But = uiKit.Button return (
@@ -39,6 +39,7 @@ export class Toast extends ScReact.Component {
+
); } From 6793adf26508e39888b74de13e86dc776ec94f7d Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 17:46:52 +0300 Subject: [PATCH 22/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 99 ++++++++++++++++--------- 1 file changed, 62 insertions(+), 37 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 95441f18..2de79284 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -79,7 +79,8 @@ class NotesStore extends BaseStore { fullScreen: false }; - private ws + private editorWS + private invitesWS public socket_id constructor() { @@ -87,6 +88,58 @@ class NotesStore extends BaseStore { this.registerEvents(); } + async init () { + await this.fetchNotes(true); + await this.fetchTags() + + this.invitesWS = new WebSocketConnection(`api/note/subscribe/on_invites`) + + this.invitesWS.onOpen(() => { + console.log("invitesWS.onOpen") + // this.editorWS.sendMessage(JSON.stringify({ + // type: "opened", + // note_id: note.id, + // user_id: AppUserStore.state.user_id, + // username: AppUserStore.state.username, + // image_path: AppUserStore.state.avatarUrl + // })) + }) + + this.invitesWS.onMessage((event) => { + console.log("invitesWS.onMessage") + + let data = JSON.parse(event.data) + + console.log(data) + }) + + return this.state; + } + + exit () { + AppNotesStore.ClearCallbacks() + AppNoteStore.ClearCallbacks() + + this.SetState(state => ({ + ...state, + notes: [], + tags: [], + selectedTags: [], + selectedNote: null, + selectedNoteSynced: null, + selectedNoteCollaborators: [], + query: '', + offset: 0, + count: 10, + fetching: false, + noteNotFound: false, + fullScreen: false + })); + + this.invitesWS.close() + this.invitesWS = null + } + private registerEvents(){ AppDispatcher.register(async (action) => { switch (action.type){ @@ -198,28 +251,6 @@ class NotesStore extends BaseStore { } }); } - - exit () { - AppNotesStore.ClearCallbacks() - AppNoteStore.ClearCallbacks() - - this.SetState(state => ({ - ...state, - notes: [], - tags: [], - selectedTags: [], - selectedNote: null, - selectedNoteSynced: null, - selectedNoteCollaborators: [], - query: '', - offset: 0, - count: 10, - fetching: false, - noteNotFound: false, - fullScreen: false - })); - } - syncNotes = () => { const notes = this.state.notes; notes.forEach((note, index) => { @@ -272,15 +303,15 @@ class NotesStore extends BaseStore { } closeWS = () => { - if (this.ws && this.state.selectedNote) { - this.ws.sendMessage(JSON.stringify({ + if (this.editorWS && this.state.selectedNote) { + this.editorWS.sendMessage(JSON.stringify({ type: "closed", note_id: this.state.selectedNote.id, user_id: AppUserStore.state.user_id })) - this.ws.close() - this.ws = null + this.editorWS.close() + this.editorWS = null this.socket_id = null } } @@ -305,10 +336,10 @@ class NotesStore extends BaseStore { blocks: note.data.content }) - this.ws = new WebSocketConnection(`note/${note.id}/subscribe_on_updates`) + this.editorWS = new WebSocketConnection(`note/${note.id}/subscribe_on_updates`) - this.ws.onOpen(() => { - this.ws.sendMessage(JSON.stringify({ + this.editorWS.onOpen(() => { + this.editorWS.sendMessage(JSON.stringify({ type: "opened", note_id: note.id, user_id: AppUserStore.state.user_id, @@ -317,7 +348,7 @@ class NotesStore extends BaseStore { })) }) - this.ws.onMessage((event) => { + this.editorWS.onMessage((event) => { let data = JSON.parse(event.data) // Если socket_id совпадает, то ничего обновлять не надо @@ -386,12 +417,6 @@ class NotesStore extends BaseStore { history.pushState(null, null, '/notes/' + id) } - async init () { - await this.fetchNotes(true); - await this.fetchTags() - return this.state; - } - async searchNotes ({query, selectedTags}) { this.SetState(state => ({ ...state, From 5c9c70e0d355ead00250bec4791471afac18ef48 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 17:48:36 +0300 Subject: [PATCH 23/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 2de79284..0a1d6ad0 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -92,7 +92,7 @@ class NotesStore extends BaseStore { await this.fetchNotes(true); await this.fetchTags() - this.invitesWS = new WebSocketConnection(`api/note/subscribe/on_invites`) + this.invitesWS = new WebSocketConnection(`note/subscribe/on_invites`) this.invitesWS.onOpen(() => { console.log("invitesWS.onOpen") From e2df1d36bea1549fce41650040e0e8f9b2bc9752 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:07:09 +0300 Subject: [PATCH 24/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 0a1d6ad0..449a2bd6 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -111,6 +111,36 @@ class NotesStore extends BaseStore { let data = JSON.parse(event.data) console.log(data) + + if (data.type == "invite") { + const owner = data.owner + const created = data.created + const title = data.note_title.replace("\\", "").replace('"', "") + AppToasts.info(owner + " пригласил вас в свою заметку!") + + const note = { + "id": data.note_id, + "data": null, + "create_time": data.created, + "update_time": data.created, + "owner_id": null, + "parent": "00000000-0000-0000-0000-000000000000", + "children": [], + "tags": [], + "collaborators": [], + "icon": "", + "header": "", + "favorite": false, + "public": false + } + + this.SetState(state => ({ + ...state, + // offset: state.offset + 1, ? + notes: [note, ...state.notes] + })); + + } }) return this.state; @@ -251,6 +281,7 @@ class NotesStore extends BaseStore { } }); } + syncNotes = () => { const notes = this.state.notes; notes.forEach((note, index) => { @@ -650,6 +681,8 @@ class NotesStore extends BaseStore { if (status == 204) { AppToasts.success("Приглашение успешно отправлено") + } else if (status == 409) { + AppToasts.info("Пользователь уже приглашен") } else { AppToasts.error("Пользователь не найден") } From f889bc85213b07bf24d15d49d1668f30b1c87e41 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:12:02 +0300 Subject: [PATCH 25/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 9 ++++++--- public/src/utils/types.ts | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 449a2bd6..a6cdbadb 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -8,6 +8,7 @@ import {WebSocketConnection} from "../websocket"; import {insertBlockPlugin} from "../../components/Editor/Plugin"; import {AppNoteStore, NoteStoreActions} from "./NoteStore"; import {downloadFile, parseNoteTitle} from "../utils"; +import {Note} from '../../components/Note/Note'; export type NotesStoreState = { notes: NoteType[], @@ -118,10 +119,12 @@ class NotesStore extends BaseStore { const title = data.note_title.replace("\\", "").replace('"', "") AppToasts.info(owner + " пригласил вас в свою заметку!") - const note = { + const note:NoteType = { "id": data.note_id, - "data": null, - "create_time": data.created, + "data": { + "title": data.note_title, + "content": [] + }, "update_time": data.created, "owner_id": null, "parent": "00000000-0000-0000-0000-000000000000", diff --git a/public/src/utils/types.ts b/public/src/utils/types.ts index 30ebaf44..afd6748a 100644 --- a/public/src/utils/types.ts +++ b/public/src/utils/types.ts @@ -9,6 +9,7 @@ export type NoteType = { }, update_time: string, owner_id: string, + collaborators: string[], icon: string, header: string, favorite: boolean, From c0a3bb495b6ca2758b6daa656d4b116279f9f9c3 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 18:30:05 +0300 Subject: [PATCH 26/57] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Button/Button.tsx | 9 ++++++++- public/src/components/Toast/Toast.sass | 3 +++ public/src/components/Toast/Toast.tsx | 2 ++ public/src/modules/stores/NotesStore.ts | 4 +--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/public/src/components/Button/Button.tsx b/public/src/components/Button/Button.tsx index 63347874..ab252eed 100644 --- a/public/src/components/Button/Button.tsx +++ b/public/src/components/Button/Button.tsx @@ -1,7 +1,14 @@ import {ScReact} from '@veglem/screact'; import './Button.sass'; -export class Button extends ScReact.Component{ +type ButtonProps = { + label: string, + disabled: boolean, + className?: string, + onClick: (e) => void +} + +export class Button extends ScReact.Component{ handleClick = (e) => { this.props.onClick && !this.props.disabled && this.props.onClick(e); diff --git a/public/src/components/Toast/Toast.sass b/public/src/components/Toast/Toast.sass index 11b0eec4..1d61ad07 100644 --- a/public/src/components/Toast/Toast.sass +++ b/public/src/components/Toast/Toast.sass @@ -41,6 +41,9 @@ .toast-icon height: 30px width: 30px + background-color: #fff + border-radius: 50% + overflow: hidden .content display: flex diff --git a/public/src/components/Toast/Toast.tsx b/public/src/components/Toast/Toast.tsx index 5357674f..ead59251 100644 --- a/public/src/components/Toast/Toast.tsx +++ b/public/src/components/Toast/Toast.tsx @@ -17,12 +17,14 @@ export class Toast extends ScReact.Component { closeToast = () => { this.props.onHide(this.props.key1); }; + formatType ():string { if (this.props.type == TOAST_TYPE.SUCCESS) { return 'Успех'; } else if (this.props.type == TOAST_TYPE.ERROR) { return 'Ошибка'; } + return 'Инфо'; } diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index a6cdbadb..b77693b4 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -115,14 +115,12 @@ class NotesStore extends BaseStore { if (data.type == "invite") { const owner = data.owner - const created = data.created - const title = data.note_title.replace("\\", "").replace('"', "") AppToasts.info(owner + " пригласил вас в свою заметку!") const note:NoteType = { "id": data.note_id, "data": { - "title": data.note_title, + "title": data.note_title.replace('"', ""), "content": [] }, "update_time": data.created, From a32d083ba9624d0b1031d0cb3b969e4a4202045a Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sat, 25 May 2024 21:46:05 +0300 Subject: [PATCH 27/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=83=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=20=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B2=20=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 52 ++++++------------------- public/src/utils/variables.sass | 2 +- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index b77693b4..373a72e2 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -95,52 +95,22 @@ class NotesStore extends BaseStore { this.invitesWS = new WebSocketConnection(`note/subscribe/on_invites`) - this.invitesWS.onOpen(() => { - console.log("invitesWS.onOpen") - // this.editorWS.sendMessage(JSON.stringify({ - // type: "opened", - // note_id: note.id, - // user_id: AppUserStore.state.user_id, - // username: AppUserStore.state.username, - // image_path: AppUserStore.state.avatarUrl - // })) - }) - - this.invitesWS.onMessage((event) => { - console.log("invitesWS.onMessage") - + this.invitesWS.onMessage(async (event) => { let data = JSON.parse(event.data) - console.log(data) - if (data.type == "invite") { - const owner = data.owner - AppToasts.info(owner + " пригласил вас в свою заметку!") - - const note:NoteType = { - "id": data.note_id, - "data": { - "title": data.note_title.replace('"', ""), - "content": [] - }, - "update_time": data.created, - "owner_id": null, - "parent": "00000000-0000-0000-0000-000000000000", - "children": [], - "tags": [], - "collaborators": [], - "icon": "", - "header": "", - "favorite": false, - "public": false - } + try { + const note = await AppNoteRequests.Get(data.note_id, AppUserStore.state.JWT) - this.SetState(state => ({ - ...state, - // offset: state.offset + 1, ? - notes: [note, ...state.notes] - })); + AppToasts.info(data.owner + " пригласил вас в свою заметку!") + this.SetState(state => ({ + ...state, + notes: [note, ...state.notes] + })); + } catch { + AppToasts.error("Что-то пошло не так") + } } }) diff --git a/public/src/utils/variables.sass b/public/src/utils/variables.sass index ecabf098..eed7008a 100644 --- a/public/src/utils/variables.sass +++ b/public/src/utils/variables.sass @@ -24,5 +24,5 @@ $xs: 320px $sm: 576px $md: 768px $lg: 992px -$xl: 1240px +$xl: 1275px $xxl: 1650px \ No newline at end of file From 78c9f59e486b36b53569feab0bb9664cba3e0ff3 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 16:47:46 +0300 Subject: [PATCH 28/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 6 ++++-- .../{Editor => EditorWrapper}/EditorWrapper.tsx | 8 ++++---- public/src/components/NoteEditor/NoteEditor.tsx | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) rename public/src/components/{Editor => EditorWrapper}/EditorWrapper.tsx (97%) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index c4a7723c..17fa9923 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1,7 +1,7 @@ import {AppUserStore} from "../../modules/stores/UserStore"; import {parseNoteTitle, setCursorAtNodePosition, truncate} from "../../modules/utils"; import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore"; -import {AppNoteRequests} from "../../modules/api"; +import {AppNoteRequests, AppSharedNoteRequests} from '../../modules/api'; import {AppDispatcher} from "../../modules/dispatcher"; import {AppToasts} from "../../modules/toasts"; import {AppNoteStore, NoteStoreActions} from "../../modules/stores/NoteStore"; @@ -1108,7 +1108,9 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] loaded = true } else { - AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => { + + const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + request.then(result => { if (result.data.title == null) { subNoteTitle.innerHTML = 'Подзаметка' } diff --git a/public/src/components/Editor/EditorWrapper.tsx b/public/src/components/EditorWrapper/EditorWrapper.tsx similarity index 97% rename from public/src/components/Editor/EditorWrapper.tsx rename to public/src/components/EditorWrapper/EditorWrapper.tsx index 8c127468..aafe6487 100644 --- a/public/src/components/Editor/EditorWrapper.tsx +++ b/public/src/components/EditorWrapper/EditorWrapper.tsx @@ -1,13 +1,13 @@ import {Component} from "@veglem/screact/dist/component"; import {VDomNode} from "@veglem/screact/dist/vdom"; -import "./Editor.sass" -import {Editor} from "./Editor"; +import "../Editor/Editor.sass" +import {Editor} from "../Editor/Editor"; import {AppNoteStore, NoteStoreState} from "../../modules/stores/NoteStore"; import {Tippy} from "../Tippy/Tippy"; import {isEqual} from "@veglem/screact/dist/isEqual"; -import {Viewer} from "./Viewer"; +import {Viewer} from "../Editor/Viewer"; import {NoteType} from "../../utils/types"; -import {PluginProps} from "./Plugin"; +import {PluginProps} from "../Editor/Plugin"; import {parseNoteTitle} from "../../modules/utils"; window['mobileCheck'] = function() { diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index b11a302e..a834199a 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -10,7 +10,7 @@ import {DeleteNoteDialog} from '../DeleteNoteDialog/DeleteNoteDialog'; import NoteMenu from "../NoteMenu/NoteMenu"; import {Tooltip} from "../Tooltip/Tooltip"; import {TagList} from "../TagList/TagList"; -import {EditorWrapper} from "../Editor/EditorWrapper"; +import {EditorWrapper} from "../EditorWrapper/EditorWrapper"; import {AppUserStore} from "../../modules/stores/UserStore"; import {Collaborators} from "../Collaborators/Collaborators"; import {EmojiPicker} from "../EmojiPicker/EmojiPicker"; From df383b4cbe51a78a0ed777a09f3776aaa208d1d1 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 16:53:13 +0300 Subject: [PATCH 29/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 17fa9923..ea03a3b3 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1073,7 +1073,10 @@ const RenderSubNote = (subNoteId:string) => { const isOwner= AppNotesStore.state.selectedNote?.owner_id == AppUserStore.state.user_id - if (isOwner) { + console.log(1) + console.log(isOwner) + if (isOwner && pluginSettings.isEditable) { + console.log(2) const deleteSubNoteBtnContainer = document.createElement("div") deleteSubNoteBtnContainer.className = "delete-subnote-btn-container" @@ -1082,6 +1085,7 @@ const RenderSubNote = (subNoteId:string) => { deleteSubNoteBtn.className = "delete-subnote-btn" if (pluginSettings.isEditable) { + console.log(3) deleteSubNoteBtnContainer.onclick = (e) => { e.stopPropagation() subNoteWrapper.remove(); From 9ca92f6c06c4709b307312905135b07569ac419a Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:07:40 +0300 Subject: [PATCH 30/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 22 +++++++++++++--------- public/src/modules/router.tsx | 5 +---- public/src/pages/SharedNote/index.tsx | 8 -------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index ea03a3b3..8be8991c 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -5,6 +5,7 @@ import {AppNoteRequests, AppSharedNoteRequests} from '../../modules/api'; import {AppDispatcher} from "../../modules/dispatcher"; import {AppToasts} from "../../modules/toasts"; import {AppNoteStore, NoteStoreActions} from "../../modules/stores/NoteStore"; +import {AppRouter} from '../../modules/router'; interface EditorPlugin { pluginName: string; @@ -1072,11 +1073,9 @@ const RenderSubNote = (subNoteId:string) => { subNoteContainer.appendChild(subNoteTitle) const isOwner= AppNotesStore.state.selectedNote?.owner_id == AppUserStore.state.user_id + const isAuth = AppUserStore.state.isAuth - console.log(1) - console.log(isOwner) - if (isOwner && pluginSettings.isEditable) { - console.log(2) + if (isAuth && isOwner && pluginSettings.isEditable) { const deleteSubNoteBtnContainer = document.createElement("div") deleteSubNoteBtnContainer.className = "delete-subnote-btn-container" @@ -1085,7 +1084,6 @@ const RenderSubNote = (subNoteId:string) => { deleteSubNoteBtn.className = "delete-subnote-btn" if (pluginSettings.isEditable) { - console.log(3) deleteSubNoteBtnContainer.onclick = (e) => { e.stopPropagation() subNoteWrapper.remove(); @@ -1132,13 +1130,19 @@ const RenderSubNote = (subNoteId:string) => { }); } - if (pluginSettings.isEditable) { - subNoteWrapper.onclick = () => { - if (!subNoteWrapper.dataset.deleted && loaded) { + subNoteWrapper.onclick = () => { + if (!subNoteWrapper.dataset.deleted && loaded) { + if (isAuth) { AppDispatcher.dispatch(NotesActions.OPEN_NOTE, subNoteId) } else { - AppToasts.error("Заметка не найдена") + AppSharedNoteRequests.Get(subNoteId).then(result => { + AppRouter.openSharedNotePage(result) + }).catch((e) => { + AppToasts.error("Заметка не найдена") + }); } + } else { + AppToasts.error("Заметка не найдена") } } diff --git a/public/src/modules/router.tsx b/public/src/modules/router.tsx index 401148ee..36b088a9 100644 --- a/public/src/modules/router.tsx +++ b/public/src/modules/router.tsx @@ -135,9 +135,6 @@ export class Router extends ScReact.Component { page = this.pages['/notes']; } - console.log("history.pushState") - console.log(path) - console.log(raw) history.pushState(null, null, path); if (page === undefined) { @@ -182,7 +179,7 @@ export class Router extends ScReact.Component { } public openSharedNotePage (note:NoteType) { - history.pushState(null, null, "/notes/" + note.id); + // history.pushState(null, null, "/notes/" + note.id); this.setState(s => ({ ...s, diff --git a/public/src/pages/SharedNote/index.tsx b/public/src/pages/SharedNote/index.tsx index 07964ba0..6ccc64cb 100644 --- a/public/src/pages/SharedNote/index.tsx +++ b/public/src/pages/SharedNote/index.tsx @@ -2,8 +2,6 @@ import {ScReact} from "@veglem/screact"; import "./style.sass" import "../../components/Editor/Editor.sass" import {ViewerWrapper} from "../../components/ViewerWrapper/ViewerWrapper"; -import {AppNotesStore} from "../../modules/stores/NotesStore"; -import {NoteStoreActions} from "../../modules/stores/NoteStore"; export class SharedNotePage extends ScReact.Component { state = { @@ -15,7 +13,6 @@ export class SharedNotePage extends ScReact.Component { ...state, fullScreen: true })) - document.getElementById("header").classList.add("fullscreen") } closeFullScreen = () => { @@ -23,11 +20,6 @@ export class SharedNotePage extends ScReact.Component { ...state, fullScreen: false })) - document.getElementById("header").classList.remove("fullscreen") - } - - componentWillUnmount() { - console.log("asdfasdfas") } render () { From b829a83faa41b4448194142c00b2149dae307dfb Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:11:20 +0300 Subject: [PATCH 31/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 1 - public/src/modules/router.tsx | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 8be8991c..921b6563 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1097,7 +1097,6 @@ const RenderSubNote = (subNoteId:string) => { } } - deleteSubNoteBtnContainer.appendChild(deleteSubNoteBtn) subNoteContainer.appendChild(deleteSubNoteBtnContainer) } diff --git a/public/src/modules/router.tsx b/public/src/modules/router.tsx index 36b088a9..7b927add 100644 --- a/public/src/modules/router.tsx +++ b/public/src/modules/router.tsx @@ -179,7 +179,10 @@ export class Router extends ScReact.Component { } public openSharedNotePage (note:NoteType) { - // history.pushState(null, null, "/notes/" + note.id); + console.log("openSharedNotePage") + console.log(note) + + history.pushState(null, null, "/notes/" + note.id); this.setState(s => ({ ...s, From 5f6de2429f169bdd69993c950e06c83708b934d7 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:14:54 +0300 Subject: [PATCH 32/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.tsx b/public/src/components/ViewerWrapper/ViewerWrapper.tsx index 63360a0b..950cae81 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.tsx +++ b/public/src/components/ViewerWrapper/ViewerWrapper.tsx @@ -22,7 +22,8 @@ export class ViewerWrapper extends ScReact.Component { private noteContentRef private viewerRef - componentDidMount() { + componentDidUpdate() { + console.log("componentDidUpdate") this.noteContentRef.innerHTML = "" new Viewer( this.props.note.data.content, From 07d394f8ebdf57a3d87edd1ae020f010f6f09de5 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Sun, 26 May 2024 17:18:04 +0300 Subject: [PATCH 33/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B2=20=D0=BF=D0=BE=D1=88=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.tsx b/public/src/components/ViewerWrapper/ViewerWrapper.tsx index 950cae81..eaf028db 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.tsx +++ b/public/src/components/ViewerWrapper/ViewerWrapper.tsx @@ -22,6 +22,15 @@ export class ViewerWrapper extends ScReact.Component { private noteContentRef private viewerRef + componentDidMount() { + console.log("componentDidMount") + this.noteContentRef.innerHTML = "" + new Viewer( + this.props.note.data.content, + this.noteContentRef + ); + } + componentDidUpdate() { console.log("componentDidUpdate") this.noteContentRef.innerHTML = "" From a81c1fb33c3fccea120a305538431f67768544cb Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 27 May 2024 15:57:26 +0300 Subject: [PATCH 34/57] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D1=81=D0=BE=D0=BC=20=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B5=20=D1=88=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/ViewerWrapper/ViewerWrapper.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/components/ViewerWrapper/ViewerWrapper.sass b/public/src/components/ViewerWrapper/ViewerWrapper.sass index e49cd3c5..89a49dd4 100644 --- a/public/src/components/ViewerWrapper/ViewerWrapper.sass +++ b/public/src/components/ViewerWrapper/ViewerWrapper.sass @@ -7,6 +7,7 @@ border-radius: 12px position: relative overflow: hidden + word-break: break-word &.fullscreen width: 100% From b4938df2987e5ca9e422776341dec7442186fbd6 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 27 May 2024 22:53:44 +0300 Subject: [PATCH 35/57] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D0=BF=D1=80=D0=B5=D0=B2=D1=8C=D1=8E=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B2=D0=BD?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/assets/info_circle.svg | 1 + public/src/assets/user.svg | 1 + public/src/components/Note/Note.sass | 15 ++++++ public/src/components/Note/Note.tsx | 15 +++++- .../src/components/NoteEditor/NoteEditor.tsx | 48 +++++++++++-------- 5 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 public/src/assets/info_circle.svg create mode 100644 public/src/assets/user.svg diff --git a/public/src/assets/info_circle.svg b/public/src/assets/info_circle.svg new file mode 100644 index 00000000..3ea15d3d --- /dev/null +++ b/public/src/assets/info_circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/src/assets/user.svg b/public/src/assets/user.svg new file mode 100644 index 00000000..82b9c811 --- /dev/null +++ b/public/src/assets/user.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index c53da25b..2e905d73 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -27,6 +27,21 @@ align-items: center gap: 5px + .owner-info + position: absolute + display: flex + align-items: center + gap: 8px + bottom: 10px + left: 15px + color: $text-secondary-color + + &__user-avatar + width: 14px + height: 14px + filter: invert(70%) + + .note-tags-container display: flex gap: 5px diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index f1f556fc..c64bad27 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -3,9 +3,9 @@ import './Note.sass'; import {formatDate, parseNoteTitle, truncate, unicodeToChar} from "../../modules/utils"; import {NoteType} from "../../utils/types"; import {Img} from "../Image/Image"; -import {Tooltip} from "../Tooltip/Tooltip"; import {AppDispatcher} from "../../modules/dispatcher"; import {NotesActions} from "../../modules/stores/NotesStore"; +import {AppUserStore} from '../../modules/stores/UserStore'; const MAX_NOTE_CONTENT_PREVIEW_LENGTH = 20; const MAX_TAGS_PREVIEW_COUNT = 2; @@ -50,8 +50,12 @@ export class Note extends ScReact.Component { } render() { + const isOwner = this.props.note.owner_id == AppUserStore.state.user_id + + // TODO: выводить логин овнера заметки, если юзер является коллаборатором + return ( -
+
{this.props.note.icon ? unicodeToChar(this.props.note.icon) : ""}

{truncate(parseNoteTitle(this.props.note.data.title), MAX_NOTE_CONTENT_PREVIEW_LENGTH)}

@@ -60,6 +64,13 @@ export class Note extends ScReact.Component { {formatDate(this.props.note.update_time)} + + {!isOwner ? +
+ + {"user91"} +
: "" + }
); } diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index a834199a..cb422ad8 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -338,7 +338,7 @@ export class NoteEditor extends ScReact.Component
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + /> : '' }
-
+
{isOwner ? } - /> : "" + content={} + /> : '' }
@@ -388,19 +388,19 @@ export class NoteEditor extends ScReact.Component - {this.state.noteStatus == "sync" ? + {this.state.noteStatus == 'sync' ?
- + + hoverTooltip={'Синхронизированно'}/>
:
- + + hoverTooltip={'Сохранено'}/>
} @@ -433,16 +433,16 @@ export class NoteEditor extends ScReact.Component
-
+
-
+
+ + Date: Mon, 27 May 2024 23:01:32 +0300 Subject: [PATCH 36/57] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BE=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D1=86=D0=B5=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Note/Note.sass | 1 - public/src/components/NoteEditor/NoteEditor.tsx | 13 ++++++++----- public/src/components/Tooltip/Tooltip.tsx | 7 +++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index 2e905d73..7f8e3aec 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -41,7 +41,6 @@ height: 14px filter: invert(70%) - .note-tags-container display: flex gap: 5px diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index cb422ad8..292da5c2 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,11 +451,14 @@ export class NoteEditor extends ScReact.Component
- + { + !isOwner ? + : "" + } { onclick={() => this.props.onClick && this.props.onClick() } > -
this.openBtnRef = ref}> +
this.openBtnRef = ref}>
{this.props.iconFromUnicode ? String.fromCodePoint(parseInt(this.props.icon, 16)) : } @@ -61,10 +61,9 @@ export class Tooltip extends ScReact.Component { {this.props.showHoverTooltip ?
{this.props.hoverTooltip} -
- : - "" +
: "" } +
this.tooltipContentRef = ref}> From 612afddcd3b6a7d8be66da89d0a4088e2772f88a Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Wed, 29 May 2024 00:32:38 +0300 Subject: [PATCH 37/57] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BA=D1=8D=D1=88=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 37 ++++++++++++++----- .../src/components/NoteEditor/NoteEditor.tsx | 16 ++++---- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index 921b6563..fc691ed3 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -495,8 +495,6 @@ export const defaultPlugins: EditorPlugin[] = [ img.dataset.imgid = id; img.className = "img" - - if (id in AppNoteStore.state.cache) { img.src = AppNoteStore.state.cache[id] } else { @@ -1052,6 +1050,8 @@ const RenderAttach = (attach_filename:string, attach_id:string) => { } const RenderSubNote = (subNoteId:string) => { + console.log("RenderSubNote") + const subNoteWrapper = document.createElement("button") subNoteWrapper.className = "subnote-wrapper" @@ -1105,18 +1105,36 @@ const RenderSubNote = (subNoteId:string) => { let loaded = false - if (subNoteId in AppNoteStore.state.cache) { - subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] - loaded = true - } else { - - const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + // if (subNoteId in AppNoteStore.state.cache) { + // subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId] + // loaded = true + // } else { + // + // const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) + // request.then(result => { + // if (result.data.title == null) { + // subNoteTitle.innerHTML = 'Подзаметка' + // } + // + // //subNoteWrapper.dataset.title = parseNoteTitle(result.data.title) + // subNoteTitle.innerHTML = parseNoteTitle(result.data.title) + // + // AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) + // + // loaded = true + // + // }).catch((e) => { + // subNoteTitle.innerHTML = "Заметка не найдена" + // subNoteWrapper.dataset.deleted = "true" + // }); + // } + + const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId) request.then(result => { if (result.data.title == null) { subNoteTitle.innerHTML = 'Подзаметка' } - //subNoteWrapper.dataset.title = parseNoteTitle(result.data.title) subNoteTitle.innerHTML = parseNoteTitle(result.data.title) AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) @@ -1127,7 +1145,6 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = "Заметка не найдена" subNoteWrapper.dataset.deleted = "true" }); - } subNoteWrapper.onclick = () => { if (!subNoteWrapper.dataset.deleted && loaded) { diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index 292da5c2..a22f3286 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,14 +451,14 @@ export class NoteEditor extends ScReact.Component
- { - !isOwner ? - : "" - } + {/*{*/} + {/* !isOwner ?*/} + {/* : ""*/} + {/*}*/} Date: Wed, 29 May 2024 17:45:16 +0300 Subject: [PATCH 38/57] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=B0=20=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Plugin.ts | 2 -- public/src/components/Note/Note.tsx | 2 +- public/src/components/NoteEditor/NoteEditor.tsx | 16 ++++++++-------- public/src/modules/stores/NotesStore.ts | 1 - public/src/utils/types.ts | 4 +++- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/public/src/components/Editor/Plugin.ts b/public/src/components/Editor/Plugin.ts index fc691ed3..455edf92 100644 --- a/public/src/components/Editor/Plugin.ts +++ b/public/src/components/Editor/Plugin.ts @@ -1137,8 +1137,6 @@ const RenderSubNote = (subNoteId:string) => { subNoteTitle.innerHTML = parseNoteTitle(result.data.title) - AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)}) - loaded = true }).catch((e) => { diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index c64bad27..73640677 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -68,7 +68,7 @@ export class Note extends ScReact.Component { {!isOwner ?
- {"user91"} + {this.props.note.username}
: "" }
diff --git a/public/src/components/NoteEditor/NoteEditor.tsx b/public/src/components/NoteEditor/NoteEditor.tsx index a22f3286..172140da 100644 --- a/public/src/components/NoteEditor/NoteEditor.tsx +++ b/public/src/components/NoteEditor/NoteEditor.tsx @@ -451,14 +451,14 @@ export class NoteEditor extends ScReact.Component
- {/*{*/} - {/* !isOwner ?*/} - {/* : ""*/} - {/*}*/} + { + !isOwner ? + : "" + } Date: Wed, 29 May 2024 23:34:24 +0300 Subject: [PATCH 39/57] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=B8=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BA=D1=83=20=D1=81=20=D0=B4=D0=B2=D1=83?= =?UTF-8?q?=D1=85=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Note/Note.sass | 1 + public/src/components/Note/Note.tsx | 2 -- public/src/modules/stores/NotesStore.ts | 5 ++++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/src/components/Note/Note.sass b/public/src/components/Note/Note.sass index 7f8e3aec..16b86bad 100644 --- a/public/src/components/Note/Note.sass +++ b/public/src/components/Note/Note.sass @@ -11,6 +11,7 @@ cursor: pointer transition: 0.5s position: relative + // border: 1px solid hsl(217.2 32.6% 25%) * pointer-events: none diff --git a/public/src/components/Note/Note.tsx b/public/src/components/Note/Note.tsx index 73640677..1431fe74 100644 --- a/public/src/components/Note/Note.tsx +++ b/public/src/components/Note/Note.tsx @@ -52,8 +52,6 @@ export class Note extends ScReact.Component { render() { const isOwner = this.props.note.owner_id == AppUserStore.state.user_id - // TODO: выводить логин овнера заметки, если юзер является коллаборатором - return (
diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index d37db370..1099b18c 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -388,7 +388,10 @@ class NotesStore extends BaseStore { } else if (data.type == "updated") { const noteData = JSON.parse(data.message_info) as NoteDataType - if (JSON.stringify(noteData) == JSON.stringify(this.state.selectedNote.data)) { + console.log(noteData) + console.log(this.state.selectedNote.data) + console.log(JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) + if (JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) { return } From d9289da6933aa701deb5bf321973e00f78ab6022 Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Thu, 30 May 2024 00:14:35 +0300 Subject: [PATCH 40/57] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=B8=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BA=D1=83=20=D1=81=20=D0=B4=D0=B2=D1=83?= =?UTF-8?q?=D1=85=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/stores/NotesStore.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 1099b18c..d37db370 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -388,10 +388,7 @@ class NotesStore extends BaseStore { } else if (data.type == "updated") { const noteData = JSON.parse(data.message_info) as NoteDataType - console.log(noteData) - console.log(this.state.selectedNote.data) - console.log(JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) - if (JSON.stringify(noteData.content) == JSON.stringify(this.state.selectedNote.data)) { + if (JSON.stringify(noteData) == JSON.stringify(this.state.selectedNote.data)) { return } From 41f19c2afb19befc392701db8e52704bba3e3d16 Mon Sep 17 00:00:00 2001 From: ZhurmilovVadim Date: Thu, 30 May 2024 23:53:37 +0300 Subject: [PATCH 41/57] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20pa?= =?UTF-8?q?ste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/components/Editor/Editor.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/src/components/Editor/Editor.ts b/public/src/components/Editor/Editor.ts index 8aec5255..c49c0363 100644 --- a/public/src/components/Editor/Editor.ts +++ b/public/src/components/Editor/Editor.ts @@ -35,6 +35,17 @@ export class Editor { this.tippyCallbacks = tippy; this.addPlugins(); + document.onpaste = (event) => { + event.preventDefault(); + + let paste = (event.clipboardData).getData("text"); + const selection = window.getSelection(); + if (!selection.rangeCount) return; + selection.deleteFromDocument(); + selection.getRangeAt(0).insertNode(document.createTextNode(paste)); + selection.collapseToEnd(); + } + this.editable = document.createElement('div'); this.editable.id = "note-editor-inner" this.editable.contentEditable = "true"; From f1cc1f92317e6a4a4124ca8276a3505fc36239ac Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Fri, 31 May 2024 00:35:44 +0300 Subject: [PATCH 42/57] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D0=BA?= =?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=B2=20UI=20Kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ public/index.ts | 1 + public/src/components/Button/Button.sass | 25 ------------------- public/src/components/Button/Button.tsx | 24 ------------------ .../DeleteNoteDialog/DeleteNoteDialog.tsx | 4 ++- .../DeleteTagDialog/DeleteTagDialog.tsx | 4 ++- public/src/components/Header/Header.tsx | 4 ++- public/src/components/Login/login.tsx | 4 ++- public/src/components/Profile/Profile.tsx | 4 ++- public/src/components/Register/Register.tsx | 3 +++ .../RenameTagModal/RenameTagModal.tsx | 3 +++ .../src/components/SharePanel/SharePanel.tsx | 3 +++ public/src/components/Toast/Toast.tsx | 2 -- .../UpdatePasswordModal.tsx | 4 ++- .../YoutubeDialog/YoutubeDialog.tsx | 3 +++ public/src/pages/Notes/index.tsx | 3 ++- 16 files changed, 36 insertions(+), 58 deletions(-) delete mode 100644 public/src/components/Button/Button.sass delete mode 100644 public/src/components/Button/Button.tsx diff --git a/README.md b/README.md index 3abec47f..6254e4af 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Frontend проекта "Notion" команды scratch senior devs # Реактивная библиотека * [ScReact](https://www.npmjs.com/package/@veglem/screact) +# UI Kit +* [ui-kit](https://www.npmjs.com/package/@veglem/ui-kit) + # Авторы * [Михалёв Ярослав](https://github.com/YarikMix) - _frontend_ * [Журмилов Вадим](https://github.com/veglem) - _frontend_ diff --git a/public/index.ts b/public/index.ts index b1d2046f..75c11e8a 100644 --- a/public/index.ts +++ b/public/index.ts @@ -2,6 +2,7 @@ import {renderDOM} from '@veglem/screact/dist/render'; import {ScReact} from '@veglem/screact'; import {App} from './src/App'; import './index.sass'; +import '@veglem/ui-kit/dist/main.css'; renderDOM('root', ScReact.createComponent(App, {})); diff --git a/public/src/components/Button/Button.sass b/public/src/components/Button/Button.sass deleted file mode 100644 index a04128ad..00000000 --- a/public/src/components/Button/Button.sass +++ /dev/null @@ -1,25 +0,0 @@ -@import "/public/src/utils/variables.sass" - -.button - background-color: $primary-color - border-radius: 20px - padding: 8px 16px - border: none - outline: none - color: $white - text-align: center - cursor: pointer - transition: all 0.3s - - &.disabled - cursor: not-allowed - opacity: 0.8 - - &:hover:not(.disabled) - transform: scale(1.05) - - &:active:not(.disabled) - transform: scale(0.98) - - &.hidden - display: none diff --git a/public/src/components/Button/Button.tsx b/public/src/components/Button/Button.tsx deleted file mode 100644 index ab252eed..00000000 --- a/public/src/components/Button/Button.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {ScReact} from '@veglem/screact'; -import './Button.sass'; - -type ButtonProps = { - label: string, - disabled: boolean, - className?: string, - onClick: (e) => void -} - -export class Button extends ScReact.Component{ - - handleClick = (e) => { - this.props.onClick && !this.props.disabled && this.props.onClick(e); - }; - - render() { - return ( - - ); - } -} diff --git a/public/src/components/DeleteNoteDialog/DeleteNoteDialog.tsx b/public/src/components/DeleteNoteDialog/DeleteNoteDialog.tsx index c9b502c7..956f55e5 100644 --- a/public/src/components/DeleteNoteDialog/DeleteNoteDialog.tsx +++ b/public/src/components/DeleteNoteDialog/DeleteNoteDialog.tsx @@ -1,7 +1,7 @@ import {ScReact} from '@veglem/screact'; -import {Button} from '../Button/Button'; import './DeleteNoteDialog.sass'; import {Img} from "../Image/Image"; +import {uiKit} from '@veglem/ui-kit/dist/ui'; export class DeleteNoteDialog extends ScReact.Component{ @@ -11,6 +11,8 @@ export class DeleteNoteDialog extends ScReact.Component{ }; render() { + const {Button} = uiKit + return (
diff --git a/public/src/components/DeleteTagDialog/DeleteTagDialog.tsx b/public/src/components/DeleteTagDialog/DeleteTagDialog.tsx index 4630fc40..f8ff3ec2 100644 --- a/public/src/components/DeleteTagDialog/DeleteTagDialog.tsx +++ b/public/src/components/DeleteTagDialog/DeleteTagDialog.tsx @@ -1,7 +1,7 @@ import {ScReact} from '@veglem/screact'; -import {Button} from '../Button/Button'; import './DeleteTagDialog.sass'; import {Img} from "../Image/Image"; +import {uiKit} from '@veglem/ui-kit/dist/ui'; export class DeleteTagDialog extends ScReact.Component{ @@ -11,6 +11,8 @@ export class DeleteTagDialog extends ScReact.Component{ }; render() { + const {Button} = uiKit + return (
diff --git a/public/src/components/Header/Header.tsx b/public/src/components/Header/Header.tsx index 1342ff1c..e96ac6b4 100644 --- a/public/src/components/Header/Header.tsx +++ b/public/src/components/Header/Header.tsx @@ -1,6 +1,5 @@ import {ScReact} from '@veglem/screact'; import './Header.sass'; -import {Button} from '../Button/Button'; import {AppRouter} from '../../modules/router'; import {Logo} from '../Logo/logo'; import {Profile} from '../Profile/Profile'; @@ -8,6 +7,7 @@ import {AuthPage} from '../../pages/Auth'; import {AppUserStore, UserActions, UserStoreState} from '../../modules/stores/UserStore'; import {AppDispatcher} from '../../modules/dispatcher'; import {AppNotesStore, NotesStoreState} from "../../modules/stores/NotesStore"; +import {uiKit} from '@veglem/ui-kit/dist/ui'; export class Header extends ScReact.Component{ state = { @@ -44,6 +44,8 @@ export class Header extends ScReact.Component{ }; render() { + const {Button} = uiKit + return (