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: cannot parse the br tag when calling setHTML API #1644

Merged
merged 6 commits into from Jul 7, 2021
Merged

Conversation

js87zz
Copy link
Contributor

@js87zz js87zz commented Jul 6, 2021

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description


Thank you for your contribution to TOAST UI product. πŸŽ‰ 😘 ✨

Copy link

@dongsik-yoo dongsik-yoo left a comment

Choose a reason for hiding this comment

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

리뷰 μ™„λ£Œν•©λ‹ˆλ‹€. μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€.

Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

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

λ¦¬λ·°μ™„λ£Œν•©λ‹ˆλ‹€.

@@ -132,13 +132,22 @@ describe('editor', () => {
expect(getPreviewHTML()).toBe('<h1>heading</h1>');
});

it('setHTML()', () => {
editor.setHTML('<h1>heading</h1>');
describe('setHTML(', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe('setHTML(', () => {
describe('setHTML()', () => {

)이 λΉ μ‘Œλ„€μš” γ…‹γ…‹

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이런..γ…‹γ…‹

Comment on lines +241 to +242
const reBr = /<br\s*\/*>/i;
const reHTMLTag = new RegExp(HTML_TAG, 'ig');
Copy link
Contributor

Choose a reason for hiding this comment

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

reg λŒ€μ‹  reλ₯Ό μ‚¬μš©ν•˜μ‹  μ΄μœ κ°€ κΆκΈˆν•©λ‹ˆλ‹€!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commonmark μ½”λ“œμͺ½μ—μ„œ μ •κ·œμ‹ ν”„λ¦¬ν”½μŠ€λ₯Ό re둜 μ§€μ •ν•΄μ„œ μ“°κ³  μžˆλŠ”λ° 저희도 λ‚΄λΆ€ μ½”λ“œλ₯Ό 톡일할 κ²Έ ν”„λ‘œμ νŠΈ μ΄ˆλ°˜μ— 맞좰 μ“°κΈ°λ‘œ ν–ˆμŠ΅λ‹ˆλ‹€~

Copy link
Contributor

Choose a reason for hiding this comment

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

μ΄ν•΄ν–ˆμŠ΅λ‹ˆλ‹€! πŸ‘

@js87zz js87zz merged commit 5effae2 into master Jul 7, 2021
@js87zz js87zz deleted the fix/setHTML branch July 7, 2021 07:15
Copy link

@adhrinae adhrinae left a comment

Choose a reason for hiding this comment

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

(λŠ¦μ—ˆμ§€λ§Œ) 리뷰 μ™„λ£Œν•©λ‹ˆλ‹€.

if (reBr.test(htmlTag)) {
let alternativeTag = '';

if (index) {
Copy link

Choose a reason for hiding this comment

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

μ—¬κΈ°μ„œ index κ°€ μ—†λŠ” κ²½μš°λ„ μžˆλ‚˜μš”? μ•„λ‹ˆλ©΄ indexκ°€ 0 μ΄μƒμž„μ„ μ²΄ν¬ν•˜μ‹œκΈ° μœ„ν•¨μΈκ°€μš”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

index = 1 λΆ€ν„° μ‹€ν–‰ν•˜κΈ° μœ„ν•¨μž…λ‹ˆλ‹€! λ§Œμ•½ κ°€μž₯ λ¨Όμ € λ‚˜μ˜€λŠ” νƒœκ·Έκ°€ br인 κ²½μš°λŠ” μ˜λ―Έκ°€ μ—†μ–΄μ„œμš”~

Copy link

Choose a reason for hiding this comment

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

λ„€λ„€ μ •ν™•νžˆλŠ” 0 μ΄ˆκ³Όκ΅°μš”. κ·Έλƒ₯ λͺ…μ‹œμ μœΌλ‘œ index > 0 은 μ•ˆλ κΉŒ ν–ˆμ–΄μš”.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

μ²˜μŒμ—λŠ” index > 0으둜 μž‘μ„±ν–ˆλ‹€κ°€ κ·Έλƒ₯ μž‘μ„±ν•΄λ„ μ½”λ“œλ³΄κΈ° 어렡지 μ•Šμ„ 것 κ°™μ•„ λ‹€μ‹œ λ³€κ²½ν–ˆμ–΄μš”.
항상 κ³ λ―Όλ˜λ”λΌκ΅¬μš” 이런 뢀뢄은..γ…‹γ…‹

ahamelers pushed a commit to ahamelers/tui.editor that referenced this pull request Aug 21, 2023
* refactor: move tag regexp to constants.ts

* feat: add replaceBRWithEmptyBlock function

* fix: replace BR with empty block in setHTML

* chore: add test case(setHTML)

* refactor: replace br in loop

* chore: apply code review
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.

None yet

4 participants