Skip to content

Commit

Permalink
Поправил превью у заметок
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 17, 2024
1 parent f676ce7 commit d7a5f8b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
22 changes: 0 additions & 22 deletions public/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class Dropdown extends ScReact.Component<any, any> {
let attr = null;
let content = [];

// TODO
if (id === "h1") {
insertBlockPlugin('header', 'h1')
} else if (id === "h2") {
Expand All @@ -66,42 +65,30 @@ export class Dropdown extends ScReact.Component<any, any> {
insertBlockPlugin('todo')
} else if (id === 'image') {

// TODO

const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = '.jpg,.png,.jpeg';
fileInput.hidden = true;

// this.ref.append(fileInput);

fileInput.onchange = (e: InputEvent) => {
fileInput.remove();

const file = (e.target as HTMLInputElement).files[0]
if (file.size < MAX_ATTACH_SIZE) {
AppNoteRequests.UploadFile(AppNotesStore.state.selectedNote.id, file, AppUserStore.state.JWT, AppUserStore.state.csrf).then(response => {
// AppUserStore.state.csrf = response.headers.get('x-csrf-token');
AppDispatcher.dispatch(UserActions.UPDATE_CSRF, response.headers.get('x-csrf-token'))
response.json().then(respJson => {
insertBlockPlugin('img', respJson.id);
})
})

// AppDispatcher.dispatch(NotesActions.UPLOAD_IMAGE, {
// file: file,
// noteId: AppNotesStore.state.selectedNote.id,
// blockId: this.props.blockId
// });
// AppDispatcher.dispatch(NoteStoreActions.REMOVE_CURSOR, {});
} else {
AppToasts.error('Фото слишком большое');
}
};
fileInput.click();

} else if (id === 'document') {
// TODO

const fileInput = document.createElement('input');
fileInput.type = 'file';
Expand All @@ -111,21 +98,12 @@ export class Dropdown extends ScReact.Component<any, any> {
fileInput.remove();
const file = (e.target as HTMLInputElement).files[0]
if (file.size < MAX_ATTACH_SIZE) {
// AppDispatcher.dispatch(NotesActions.UPLOAD_FILE, {
// file: file,
// noteId: AppNotesStore.state.selectedNote.id,
// blockId: this.props.blockId,
// fileName: (e.target as HTMLInputElement).files[0].name
// });
AppNoteRequests.UploadFile(AppNotesStore.state.selectedNote.id, file, AppUserStore.state.JWT, AppUserStore.state.csrf).then(response => {
AppDispatcher.dispatch(UserActions.UPDATE_CSRF, response.headers.get('x-csrf-token'))
// AppUserStore.state.csrf = response.headers.get('x-csrf-token');
response.json().then(respJson => {

insertBlockPlugin('file', respJson.id, file.name);
})
})
// AppDispatcher.dispatch(NoteStoreActions.REMOVE_CURSOR);
} else {
AppToasts.error('Файл слишком большой');
}
Expand Down
5 changes: 0 additions & 5 deletions public/src/components/NoteEditor/NoteEditor.sass
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
width: 100%
height: 80px
z-index: 0
//background: url("test.jpg"), linear-gradient(rgba(0,0,0,0.15))
//background-size: cover
//background-repeat: no-repeat
//background-position: center center
//filter: brightness(40%)

.top-panel
display: flex
Expand Down
2 changes: 2 additions & 0 deletions public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ class NotesStore extends BaseStore<NotesStoreState> {
blocks: noteData.content
})

this.syncNotes()

}
})
}
Expand Down

0 comments on commit d7a5f8b

Please sign in to comment.