Skip to content

Commit

Permalink
Поправил редактор
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 24, 2024
1 parent 30c38ad commit 43224d1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
12 changes: 11 additions & 1 deletion public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {AppNoteStore, NoteStoreActions} from '../../modules/stores/NoteStore';
import {Modal} from '../Modal/Modal';
import {DeleteNoteDialog} from '../DeleteNoteDialog/DeleteNoteDialog';
import NoteMenu from "../NoteMenu/NoteMenu";
import {InviteUserModal} from "../InviteUserModal/InviteUserModal";
import {Tooltip} from "../Tooltip/Tooltip";
import {TagList} from "../TagList/TagList";
import {EditorWrapper} from "../Editor/EditorWrapper";
Expand Down Expand Up @@ -45,17 +46,18 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
selectedNote: null,
noteStatus: null,
deleteNoteModalOpen: false,
inviteUserModalOpen: false,
tagsModalOpen: false,
emojiModalOpen: false,
backgroundModalOpen: false,
shareModalOpen: false,
fullScreen: false,
dropdownOpen: false,
youtube: false,
dropdownPos: {
left: 0,
top: 0
},
youtube: false
};

private editorWrapperRef
Expand Down Expand Up @@ -110,12 +112,15 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
fullScreen: store.fullScreen
}));

console.log("updateState")
console.log(store.selectedNoteSynced)
if (store.selectedNoteSynced) {
this.setState(state => ({
...state,
noteStatus: "sync",
}));
}

};

openDeleteNoteModal = () => {
Expand Down Expand Up @@ -293,6 +298,11 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
content={<DeleteNoteDialog onSuccess={this.deleteNote} handleClose={this.closeDeleteModalDialog}/>}
/>

<Modal open={this.state.inviteUserModalOpen}
handleClose={this.closeInviteUserModal}
content={<InviteUserModal handleClose={this.closeInviteUserModal} open={this.state.inviteUserModalOpen}/>}
/>

<Modal open={this.state.tagsModalOpen}
handleClose={this.closeTagsModal}
reset={false}
Expand Down
5 changes: 3 additions & 2 deletions public/src/components/NoteMenu/NoteMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class NoteMenu extends ScReact.Component<any, any> {

render() {
const isOwner = this.props.note?.owner_id == AppUserStore.state.user_id
const isAuth = AppUserStore.state.isAuth

return (
<div className={"note-menu " + (this.state.open ? "open" : "")}>
Expand Down Expand Up @@ -101,8 +102,8 @@ export class NoteMenu extends ScReact.Component<any, any> {
</div> : ""
}

{isOwner ?
<div className="options-item mobile-option">
{isAuth ?
<div className="options-item">
<Img src={this.props.note?.favorite ? "star-filled.svg" : "star.svg"} className="icon"/>
<span>{this.props.note?.favorite ? "Удалить из избранного" : "В избранное"}</span>
</div> : ""
Expand Down
30 changes: 26 additions & 4 deletions public/src/components/SharePanel/SharePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import {Button} from "../Button/Button";
import "./SharePanel.sass"
import {ToggleButton} from "../ToggleButton/ToggleButton";
import {Img} from "../Image/Image";
import {NotesActions} from "../../modules/stores/NotesStore";
import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore";
import {parseNoteTitle} from "../../modules/utils";
import {AppDispatcher} from "../../modules/dispatcher";
import {AppToasts} from "../../modules/toasts";
import {AppUserStore} from "../../modules/stores/UserStore";

export class SharePanel extends ScReact.Component<any, any> {

private inviteInputRef

handleToggle = (value:boolean) => {
AppDispatcher.dispatch(value ? NotesActions.SET_PUBLIC : NotesActions.SET_PRIVATE)
}
Expand Down Expand Up @@ -43,17 +46,36 @@ export class SharePanel extends ScReact.Component<any, any> {
AppToasts.info("Ссылка на заметку скопирована")
}

sendInvite = (e) => {
e.preventDefault()
console.log("sendInvite")

const value = this.inviteInputRef.value

if (value == AppUserStore.state.username) {
AppToasts.info("Вы не можете пригласить самого себя")
return
}

if (value) {
AppDispatcher.dispatch(NotesActions.ADD_COLLABORATOR, {
note_id: AppNotesStore.state.selectedNote.id,
username: value
})
}
}

getNoteURL = () => "https://you-note.ru/notes/" + this.props.note?.id

render() {
return (
<div className="share_panel">
<div className="share_panel__invite-people-container">
<h3>Пригласить людей</h3>
<div className="share_panel__invite-people-container__bottom-container">
<input type="text" placeholder="Введите логин" className="invite-input"/>
<form className="share_panel__invite-people-container__bottom-container" onsubmit={this.sendInvite}>
<input type="text" placeholder="Введите логин" className="invite-input" ref={ref => this.inviteInputRef = ref}/>
<Button label="Отправить"/>
</div>
</form>
</div>
<div className="share_panel__share-link-container">
<h3>Поделиться ссылкой</h3>
Expand Down
2 changes: 1 addition & 1 deletion public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class NotesStore extends BaseStore<NotesStoreState> {
if (status == 204) {
AppToasts.success("Приглашение успешно отправлено")
} else {
AppToasts.success("Пользователя не существует")
AppToasts.error("Пользователь не найден")
}

} catch {
Expand Down
2 changes: 1 addition & 1 deletion public/src/utils/variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ $xs: 320px
$sm: 576px
$md: 768px
$lg: 992px
$xl: 1200px
$xl: 1240px
$xxl: 1650px

0 comments on commit 43224d1

Please sign in to comment.