Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into fix-pasting-markdown-with-html
  • Loading branch information
Susan Were Susan Were
Susan Were authored and Susan Were committed Mar 20, 2024
commit 893f17848df1b75dd8db34af95d128e2cb0c8519
14 changes: 4 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 42 additions & 42 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,31 @@ describe('paste-markdown', function () {
assert.equal(textarea.value, markdownSentence)
})

it('finds the right link when identical labels are present', function () {
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'><span>example<span> </span>
</span><a href="https://example.com/">example</a>`
const plaintextSentence = 'example example'
const markdownSentence = 'example [example](https://example.com/)'

paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
})

it('skip markdown formatting with (Ctrl+Shift+v)', function () {
const data = {
'text/html': tableHtml,
}

dispatchSkipFormattingKeyEvent(textarea)
paste(textarea, data)
assertUnformattedPaste(textarea)

textarea.value = ''
paste(textarea, data)
assert.include(textarea.value, tableMarkdown)
})

it('pastes markdown with links correctly when identical labels are present', function () {
Comment thread
susanwere marked this conversation as resolved.
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'><span>
Expand Down Expand Up @@ -396,12 +421,24 @@ describe('paste-markdown', function () {
assert.equal(textarea.value, markdownSentence)
})

it('finds the right link when identical labels are present', function () {
it('pastes markdown with link labels that contains special characters in html', function () {
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'><span>example<span> </span>
</span><a href="https://example.com/">example</a>`
const plaintextSentence = 'example example'
const markdownSentence = 'example [example](https://example.com/)'
const sentence = `<meta charset='utf-8'>
<p>foo&bar <a href="https://www.abcxyz.org/">foo bar</a> <a href="https://example.com/?q=foo&bar=baz">foo&bar</a></p>`
const plaintextSentence = 'foo&bar foo bar foo&bar'
const markdownSentence =
'foo&bar [foo bar](https://www.abcxyz.org/) [foo&bar](https://example.com/?q=foo&bar=baz)'

paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
})

it('pastes markdown with link labels that contains emojis in html', function () {
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'>
<p>foo bar <a href="https://www.abcxyz.org/">foo</a> bar foo <a href="https://example.com/">🚀 bar 🚀</a></p>`
const plaintextSentence = 'foo bar foo bar foo 🚀 bar 🚀'
const markdownSentence = 'foo bar [foo](https://www.abcxyz.org/) bar foo [🚀 bar 🚀](https://example.com/)'

paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
Expand Down Expand Up @@ -445,43 +482,6 @@ bar bar foo`
paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
})

it('skip markdown formatting with (Ctrl+Shift+v)', function () {
const data = {
'text/html': tableHtml
}

dispatchSkipFormattingKeyEvent(textarea)
paste(textarea, data)
assertUnformattedPaste(textarea)

textarea.value = ''
paste(textarea, data)
assert.include(textarea.value, tableMarkdown)
})

it('pastes markdown with link labels that contains special characters in html', function () {
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'>
<p>foo&bar <a href="https://www.abcxyz.org/">foo bar</a> <a href="https://example.com/?q=foo&bar=baz">foo&bar</a></p>`
const plaintextSentence = 'foo&bar foo bar foo&bar'
const markdownSentence =
'foo&bar [foo bar](https://www.abcxyz.org/) [foo&bar](https://example.com/?q=foo&bar=baz)'

paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
})

it('pastes markdown with link labels that contains emojis in html', function () {
// eslint-disable-next-line github/unescaped-html-literal
const sentence = `<meta charset='utf-8'>
<p>foo bar <a href="https://www.abcxyz.org/">foo</a> bar foo <a href="https://example.com/">🚀 bar 🚀</a></p>`
const plaintextSentence = 'foo bar foo bar foo 🚀 bar 🚀'
const markdownSentence = 'foo bar [foo](https://www.abcxyz.org/) bar foo [🚀 bar 🚀](https://example.com/)'

paste(textarea, {'text/html': sentence, 'text/plain': plaintextSentence})
assert.equal(textarea.value, markdownSentence)
})
})
})

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.