Skip to content

Commit

Permalink
Добавил кэширование фоток в заметке
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 16, 2024
1 parent 3ee6cb0 commit f676ce7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions public/src/components/Editor/Editor.sass
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
cursor: text
animation: fadeIn 0.3s

.img
width: 75%
min-width: 300px

@media screen and (max-width: $sm)
min-width: 90%


.subnote-wrapper
background: $modal-background
padding: 8px 16px
Expand Down
13 changes: 10 additions & 3 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ export const defaultPlugins: EditorPlugin[] = [
const id = props['imgId'] as string

img.dataset.imgid = id;
img.className = "img"

if (id in AppNoteStore.state.cache) {
img.src = AppNoteStore.state.cache[id]
Expand All @@ -507,12 +508,18 @@ export const defaultPlugins: EditorPlugin[] = [
insertNode: (innerContent, ...args) => {
const img = document.createElement('img');
img.contentEditable = 'false';
img.src = '/assets/add.svg'; //todo: default image url // скелетоны нужныыыыыы аааааааа
img.dataset.imgid = args[0];
img.src = '/assets/add.svg'; // todo: скелетон
img.className = "img"

AppNoteRequests.GetImage(args[0], AppUserStore.state.JWT, AppUserStore.state.csrf).then(url => {
const id = args[0] as string

img.dataset.imgid = id;

AppNoteRequests.GetImage(id, AppUserStore.state.JWT, AppUserStore.state.csrf).then(url => {
img.src = url;
AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: id, value: url})
})

return img;
}
},
Expand Down

0 comments on commit f676ce7

Please sign in to comment.