Skip to content

Commit

Permalink
Handle the case where the pasted data is not an image (#7628)
Browse files Browse the repository at this point in the history
* Handle the case where the pasted data is not an image or it is image AND text
* Change method name for paste handling

---------

Co-authored-by: Andrew Henry <[email protected]>
  • Loading branch information
shefalijoshi and akhenry authored Apr 4, 2024
1 parent e3adeb6 commit d33da65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/plugins/notebook/components/NotebookEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@drop.capture="cancelEditMode"
@drop.prevent="dropOnEntry"
@click="selectAndEmitEntry($event, entry)"
@paste="addImageFromPaste"
@paste="addImageOrTextFromPaste"
>
<div class="c-ne__time-and-content">
<div class="c-ne__time-and-creator-and-delete">
Expand Down Expand Up @@ -384,7 +384,7 @@ export default {

this.manageEmbedLayout();
},
async addImageFromPaste(event) {
async addImageOrTextFromPaste(event) {
const clipboardItems = Array.from(
(event.clipboardData || event.originalEvent.clipboardData).items
);
Expand All @@ -409,7 +409,9 @@ export default {
})
);
this.manageEmbedLayout();
this.timestampAndUpdate();
// the pasted clipboard data also include text (or text only and no images).
// So we will also update the text here
this.updateEntryValue(event);
},
convertMarkDownToHtml(text = '') {
let markDownHtml = this.marked.parse(text, {
Expand Down

0 comments on commit d33da65

Please sign in to comment.