Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Get fragment from text/html when application/x-slate-fragment is missing on copy-paste slate fragment in android #4433

Merged
merged 8 commits into from
Aug 13, 2021

Conversation

imdbsd
Copy link
Contributor

@imdbsd imdbsd commented Aug 10, 2021

Description
application/x-slate-fragment is missing on paste event clipbooard data. So im thingking about adding a clipboard ref for android editable to holding what user copy or cut. Then on paste event, editor can compare the ref with the even clipboard data

Issue
Fixes: #4432

Example
fix-bug-copy-paste-slate

Context
This will hold what user copy or cut in a ref, so paste event can compare it with the event clipboardData. Use it by pass the native event clipboard.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Aug 10, 2021

🦋 Changeset detected

Latest commit: 7ce5438

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dylans dylans changed the title fix(android): Add clipboard ref for handliing copy-paste slate fragment in android fix(android): Add clipboard ref for handling copy-paste slate fragment in android Aug 10, 2021
Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems ok to me (I've recently spent some time working with DataTransfer). I think it would be beneficial to document why this exists, and why Android's paste buffer is excluding our attempt to add application/x-slate-fragment

@imdbsd
Copy link
Contributor Author

imdbsd commented Aug 12, 2021

hai @dylans thanks for the feedback. im just checking it again, and make a tweak for condition props onPaste was call preventDefault. So application/x-slate-fragment still accessible from the props

@imdbsd imdbsd requested a review from dylans August 12, 2021 05:10
@imdbsd
Copy link
Contributor Author

imdbsd commented Aug 12, 2021

im just realize, that the cliboard data text/html has data-slate-fragment in the attribute that same as application/x-slate-fragment. Will change my PR to get the fragment from there instead

@imdbsd
Copy link
Contributor Author

imdbsd commented Aug 12, 2021

Im just update it to check the fragment in text/html data and pass it to the event. It also help too fix copy paste from different slate editor, since what i do with ref, won't fix that. Please kindly rereview it again

@imdbsd imdbsd changed the title fix(android): Add clipboard ref for handling copy-paste slate fragment in android fix(android): Get fragment from text/html when application/x-slate-fragment is missing on copy-paste slate fragment in android Aug 12, 2021
@imdbsd
Copy link
Contributor Author

imdbsd commented Aug 12, 2021

updated fix result

fix-get-slate-fragment

@dylans dylans merged commit a1f925b into ianstormtaylor:main Aug 13, 2021
@github-actions github-actions bot mentioned this pull request Aug 13, 2021
@dylans dylans mentioned this pull request Sep 11, 2021
dylans pushed a commit to dylans/slate that referenced this pull request Sep 13, 2021
…agment is missing on copy-paste slate fragment in android (ianstormtaylor#4433)

* fix(android): clipboard application/x-slate-fragment is missing on paste in android

* add event onCut

* add changeset

* make slate fragment available when props onPaste, call preventDefault

* .

* get the fragment from text/html when it missing

* remove setData

* use getClipboardData instead of hooks
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.

[android]: clipboard data application/x-slate-fragment is missing when paste on android
2 participants