Skip to content

Conversation

@samuelnovaes
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • All tests are passing

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@samuelnovaes samuelnovaes changed the title Able to paste images with Ctrl + V Paste images with Ctrl + V Jul 21, 2021
@antoine92190
Copy link
Collaborator

Thanks for the great feature!
I don't really understand the complexity though, can we rather do:

onPasteImage(pasteEvent) {
    const items = pasteEvent.clipboardData?.items

    if (items) {
        items.forEach(item => {
            if (item.type.indexOf('image') !== -1) {
                const blob = item.getAsFile()
                this.onFileChange([blob])
            }
        })
    }
}

@samuelnovaes
Copy link
Contributor Author

Thanks for the great feature!
I don't really understand the complexity though, can we rather do:

onPasteImage(pasteEvent) {
    const items = pasteEvent.clipboardData?.items

    if (items) {
        items.forEach(item => {
            if (item.type.indexOf('image') !== -1) {
                const blob = item.getAsFile()
                this.onFileChange([blob])
            }
        })
    }
}

Thanks for your feedback! I created a new commit reducing the onPasteImage function complexity

@antoine92190 antoine92190 merged commit a221ac6 into advanced-chat:master Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants