Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Защита #21

Merged
merged 70 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7fa9e2a
Merge pull request #2 from frontend-park-mail-ru/dev
Gev0rg Mar 11, 2024
4f5d9c6
Merge pull request #4 from frontend-park-mail-ru/dev
Gev0rg Mar 13, 2024
b19e507
Merge pull request #5 from frontend-park-mail-ru/dev
Gev0rg Mar 23, 2024
755cafe
Merge pull request #7 from frontend-park-mail-ru/dev
Gev0rg Apr 14, 2024
4650b33
Merge pull request #9 from frontend-park-mail-ru/dev
Gev0rg Apr 14, 2024
9166a40
Merge pull request #17 from frontend-park-mail-ru/dev
Gev0rg May 6, 2024
262271c
Исправил линтер
YarikMix May 6, 2024
cbf6ec3
Merge remote-tracking branch 'origin/main'
YarikMix May 6, 2024
dc220d0
Merge pull request #20 from frontend-park-mail-ru/dev
Gev0rg May 25, 2024
da15407
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
195565d
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
3c01cd4
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
464dfc2
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
8396660
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
a4f0cdf
Сделал уведомление о приглашении в заметку
YarikMix May 25, 2024
6a97d84
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
5aafc74
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
6b60247
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
0174f1d
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
718b43a
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
cba90c0
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
f4ba99a
Поправил баг с переносом строк на странице шереной заметки
YarikMix May 27, 2024
24acc71
Добавил в превью заметки отображение овнера
YarikMix May 27, 2024
3611099
Добавил в редактор отображение информации о владельце заметки
YarikMix May 27, 2024
76f63ec
Отключил кэширование подзаметок
YarikMix May 28, 2024
b1222e9
Сделал отображение логина овнера заметки
YarikMix May 29, 2024
d76e154
Исправил баг с рекурсией при открытии заметку с двух вкладок
YarikMix May 29, 2024
f4d4158
Исправил баг с рекурсией при открытии заметку с двух вкладок
YarikMix May 29, 2024
8660a5a
сделал ui kit
veglem May 30, 2024
6793adf
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
5c9c70e
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
e2df1d3
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
f889bc8
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
c0a3bb4
Заготовка под уведомления о приглашении в заметку
YarikMix May 25, 2024
a32d083
Сделал уведомление о приглашении в заметку
YarikMix May 25, 2024
78c9f59
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
df383b4
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
9ca92f6
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
b829a83
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
5f6de24
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
07d394f
Сделал отображение подзаметок в пошереной заметке
YarikMix May 26, 2024
a81c1fb
Поправил баг с переносом строк на странице шереной заметки
YarikMix May 27, 2024
b4938df
Добавил в превью заметки отображение овнера
YarikMix May 27, 2024
8f7bcb1
Добавил в редактор отображение информации о владельце заметки
YarikMix May 27, 2024
612afdd
Отключил кэширование подзаметок
YarikMix May 28, 2024
519f2d1
Сделал отображение логина овнера заметки
YarikMix May 29, 2024
3e2a2fc
Исправил баг с рекурсией при открытии заметку с двух вкладок
YarikMix May 29, 2024
d9289da
Исправил баг с рекурсией при открытии заметку с двух вкладок
YarikMix May 29, 2024
fca5e5a
Merge remote-tracking branch 'origin/vls-65' into vls-65
veglem May 30, 2024
41f19c2
сделал paste
veglem May 30, 2024
f1cc1f9
Вынес кнопки в UI Kit
YarikMix May 30, 2024
c07bd9c
Merge remote-tracking branch 'origin/vls-65' into vls-65
YarikMix May 30, 2024
9d21904
поправил вьювер
veglem May 31, 2024
ed406dd
Merge remote-tracking branch 'origin/vls-65' into vls-65
veglem May 31, 2024
aade028
поправил вебсокеты
veglem May 31, 2024
6b18f7d
Поправил стили
YarikMix May 31, 2024
fa0cc90
Merge remote-tracking branch 'origin/vls-65' into vls-65
YarikMix May 31, 2024
5a66378
Поправил выпадающий список
YarikMix May 31, 2024
409a6ec
Поправил стили
YarikMix May 31, 2024
7027724
Поправил стили
YarikMix May 31, 2024
745e4aa
Сделал открытие на телефоне меню тэга при зажатии
YarikMix May 31, 2024
e9c8dfa
Сделал открытие на телефоне меню тэга при зажатии
YarikMix May 31, 2024
8bfdcc7
Поправил выпадающее меню
YarikMix May 31, 2024
5192350
поправил paste
veglem May 31, 2024
62102e7
поправил paste
veglem May 31, 2024
5fc05dd
Вынес инпуты в ui kit
YarikMix May 31, 2024
54e3baf
Merge remote-tracking branch 'origin/vls-65' into vls-65
YarikMix May 31, 2024
7fbcf89
Вынес инпуты в ui kit
YarikMix May 31, 2024
6b23456
Почистил логи
YarikMix May 31, 2024
7a46ab0
Обновил редми
YarikMix May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ Frontend проекта "Notion" команды scratch senior devs
# Деплой
* [YouNote](https://you-note.ru)

# API
* [swagger](https://you-note.ru/api/swagger/index.html)

# Figma
* [figma](https://www.figma.com/design/34KaYrmEwdC9vuisY3BoID/YouNote?node-id=0%3A1&t=mdkq7otCB1sFFwJ2-1)
* [Figma](https://www.figma.com/design/34KaYrmEwdC9vuisY3BoID/YouNote?node-id=0%3A1&t=mdkq7otCB1sFFwJ2-1)

# Реактивная библиотека
* [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_
Expand All @@ -27,3 +28,7 @@ Frontend проекта "Notion" команды scratch senior devs

# Backend
* [Backend](https://github.com/go-park-mail-ru/2024_1_scratch_senior_devs)

# Как запустить
* npm install
* npm run serve
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"serve": "webpack serve --node-env=development"
},
"devDependencies": {
"@veglem/ui-kit": "^1.0.8",
"@babel/cli": "^7.23.9",
"@babel/core": "^7.24.0",
"@babel/plugin-proposal-decorators": "^7.24.0",
Expand Down
1 change: 1 addition & 0 deletions public/index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ body
top: 20px

&.locked
max-height: 100vh
overflow: hidden
1 change: 1 addition & 0 deletions public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {}));

Expand Down
1 change: 1 addition & 0 deletions public/src/assets/info_circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/src/assets/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 0 additions & 25 deletions public/src/components/Button/Button.sass

This file was deleted.

17 changes: 0 additions & 17 deletions public/src/components/Button/Button.tsx

This file was deleted.

4 changes: 3 additions & 1 deletion public/src/components/DeleteNoteDialog/DeleteNoteDialog.tsx
Original file line number Diff line number Diff line change
@@ -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<any, any>{

Expand All @@ -11,6 +11,8 @@ export class DeleteNoteDialog extends ScReact.Component<any, any>{
};

render() {
const {Button} = uiKit

return (
<div className="delete-note-dialog">
<Img src="close.svg" className="close-modal-btn" onClick={this.props.handleClose}/>
Expand Down
4 changes: 3 additions & 1 deletion public/src/components/DeleteTagDialog/DeleteTagDialog.tsx
Original file line number Diff line number Diff line change
@@ -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<any, any>{

Expand All @@ -11,6 +11,8 @@ export class DeleteTagDialog extends ScReact.Component<any, any>{
};

render() {
const {Button} = uiKit

return (
<div className="delete-tag-dialog">
<Img src="close.svg" className="close-modal-btn" onClick={this.props.handleClose}/>
Expand Down
4 changes: 0 additions & 4 deletions public/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {ScReact} from '@veglem/screact';
import './Dropdown.sass';
import {Img} from '../Image/Image';
import {AppDispatcher} from '../../modules/dispatcher';
import {AppNoteStore, NoteStoreActions} from '../../modules/stores/NoteStore';
import {AppNotesStore, NotesActions} from '../../modules/stores/NotesStore';
import {MAX_ATTACH_SIZE} from '../../utils/consts';
import {AppToasts} from '../../modules/toasts';
Expand Down Expand Up @@ -47,9 +46,6 @@ export class Dropdown extends ScReact.Component<any, any> {
};

handleOnClick = (id:string) => {
let tag = id;
let attr = null;
let content = [];

if (id === "h1") {
insertBlockPlugin('header', 'h1')
Expand Down
26 changes: 25 additions & 1 deletion public/src/components/Editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ export class Editor {
this.tippyCallbacks = tippy;
this.addPlugins();

document.onpaste = (event) => {
const isInEditor = (node: Node) => {
if (node.nodeType === Node.ELEMENT_NODE && (node as HTMLElement).contentEditable === 'true' && !(node as HTMLElement).classList.contains("note-title")) {
return true
} else if (node.parentElement == null) {
return false
} else {
return isInEditor(node.parentElement);
}
}



if (isInEditor(document.getSelection().anchorNode)) {
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";
Expand Down Expand Up @@ -105,7 +129,7 @@ export class Editor {
: selection.anchorNode.parentElement;

scanTree(this.editable);
console.log(`cursor${AppUserStore.state.username}${AppNotesStore.socket_id?.toString().replaceAll('-','').toLowerCase()}`)


elem.dataset[`cursor${AppUserStore.state.username}${AppNotesStore.socket_id?.toString().replaceAll('-','').toLowerCase()}`] = `${getCaretPosition(elem)}`;
// elem.scrollIntoView();
Expand Down
66 changes: 45 additions & 21 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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";
import {AppRouter} from '../../modules/router';

interface EditorPlugin {
pluginName: string;
Expand Down Expand Up @@ -494,16 +495,14 @@ export const defaultPlugins: EditorPlugin[] = [
img.dataset.imgid = id;
img.className = "img"



if (id in AppNoteStore.state.cache) {
img.src = AppNoteStore.state.cache[id]
} else {
AppNoteRequests.GetImage(id, AppUserStore.state.JWT, AppUserStore.state.csrf).then(url => {
img.src = url;
AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: id, value: url})
}).catch(error => {
console.log(error)

})
}

Expand All @@ -525,7 +524,7 @@ export const defaultPlugins: EditorPlugin[] = [
img.src = url;
AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: id, value: url})
}).catch(error => {
console.log(error)

})

return img
Expand Down Expand Up @@ -912,7 +911,7 @@ export const insertBlockPlugin = (pluginName: string, ...args: any) => {
});
}
const newNode = plugin.insertNode([], args);
console.log(newNode)

if (newNode) {
(nodeToReplace as HTMLElement).replaceWith(newNode);
document.getSelection().setPosition(newNode, 0);
Expand Down Expand Up @@ -1051,6 +1050,8 @@ const RenderAttach = (attach_filename:string, attach_id:string) => {
}

const RenderSubNote = (subNoteId:string) => {


const subNoteWrapper = document.createElement("button")
subNoteWrapper.className = "subnote-wrapper"

Expand All @@ -1072,8 +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

if (isOwner) {
if (isAuth && isOwner && pluginSettings.isEditable) {
const deleteSubNoteBtnContainer = document.createElement("div")
deleteSubNoteBtnContainer.className = "delete-subnote-btn-container"

Expand All @@ -1095,7 +1097,6 @@ const RenderSubNote = (subNoteId:string) => {
}
}


deleteSubNoteBtnContainer.appendChild(deleteSubNoteBtn)
subNoteContainer.appendChild(deleteSubNoteBtnContainer)
}
Expand All @@ -1104,35 +1105,58 @@ const RenderSubNote = (subNoteId:string) => {

let loaded = false

if (subNoteId in AppNoteStore.state.cache) {
subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId]
loaded = true
} else {
AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => {
// 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)})

loaded = true

}).catch((e) => {
subNoteTitle.innerHTML = "Заметка не найдена"
subNoteWrapper.dataset.deleted = "true"
});
}

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("Заметка не найдена")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -61,7 +61,7 @@ export class EditorWrapper extends Component<EditorProps, EditorState> {
updateState = (store:NoteStoreState) => {
this.syncTitle(store.note.title)

if (!this.props.isOwner && this.props.note?.public) {
if (!this.props.isOwner && this.props.note?.public && !this.props.isEditable) {
this.self.innerHTML = ""
new Viewer(
store.note.blocks,
Expand Down
Loading