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 pasting of markdown containing links #93

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

susanwere
Copy link
Contributor

@susanwere susanwere commented Feb 23, 2024

👋 This is a second attempt to fix https://github.com/github/issues/issues/5429

After merging this PR in master we realised that the fix didn't solve the issue. I did a second check and found the following issue which causes the bug.

While creating the tree walker, we specified that we only want to show nodes that are elements. This works well in the chrome browser because it generates span for texts that don't have a html tag as shown in the screenshots below. For Firefox, texts that don't have a html tag are skipped because they are not identified as elements thereby causing the bug.

The fix is to SHOW_ALL nodes for firefox and only SHOW_ELEMENTs for chrome.

Before

before.mov

After

after.mov

test/test.js Outdated Show resolved Hide resolved
@susanwere susanwere marked this pull request as ready for review February 23, 2024 13:38
@susanwere susanwere requested a review from a team as a code owner February 23, 2024 13:38
Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to make this PR @susanwere!

I've left some comments, because I think we need to go in a slightly different direction here. Let's try to ensure that:

  1. Any behaviour we add is well tested.
  2. We don't rely on the user agent to determine which behaviour we use.

Given the above two, I would be happy to re-review this if it:

  • Retains the tests that are in place (even if they're altered).
  • Adds new tests (to cover the new edge cases we've discovered).
  • Removes the user agent sniffing and uses feature detection instead.

If you need any assistance with this please let me know, and I'd be happy to pair.

src/paste-markdown-html.ts Outdated Show resolved Hide resolved
src/paste-markdown-html.ts Outdated Show resolved Hide resolved
test/test.js Outdated Show resolved Hide resolved
@susanwere susanwere requested a review from keithamus March 20, 2024 09:02
Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

This LGTM 👍 nice work!

@keithamus keithamus merged commit 38f2616 into github:main Mar 21, 2024
1 check passed
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