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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 μλ£ν©λλ€. μκ³ νμ ¨μ΅λλ€.
There was a problem hiding this 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(', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe('setHTML(', () => { | |
describe('setHTML()', () => { |
)
μ΄ λΉ μ‘λ€μ γ
γ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄λ°..γ γ
const reBr = /<br\s*\/*>/i; | ||
const reHTMLTag = new RegExp(HTML_TAG, 'ig'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reg
λμ re
λ₯Ό μ¬μ©νμ μ΄μ κ° κΆκΈν©λλ€!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commonmark μ½λμͺ½μμ μ κ·μ ν리ν½μ€λ₯Ό re
λ‘ μ§μ ν΄μ μ°κ³ μλλ° μ ν¬λ λ΄λΆ μ½λλ₯Ό ν΅μΌν κ²Έ νλ‘μ νΈ μ΄λ°μ λ§μΆ° μ°κΈ°λ‘ νμ΅λλ€~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄ν΄νμ΅λλ€! π
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ¬κΈ°μ index
κ° μλ κ²½μ°λ μλμ? μλλ©΄ indexκ° 0 μ΄μμμ 체ν¬νμκΈ° μν¨μΈκ°μ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index = 1 λΆν° μ€ννκΈ° μν¨μ λλ€! λ§μ½ κ°μ₯ λ¨Όμ λμ€λ νκ·Έκ° brμΈ κ²½μ°λ μλ―Έκ° μμ΄μμ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ€λ€ μ ννλ 0 μ΄κ³Όκ΅°μ. κ·Έλ₯ λͺ
μμ μΌλ‘ index > 0
μ μλ κΉ νμ΄μ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ²μμλ index > 0
μΌλ‘ μμ±νλ€κ° κ·Έλ₯ μμ±ν΄λ μ½λ보기 μ΄λ ΅μ§ μμ κ² κ°μ λ€μ λ³κ²½νμ΄μ.
νμ κ³ λ―ΌλλλΌκ΅¬μ μ΄λ° λΆλΆμ..γ
γ
* 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
Please check if the PR fulfills these requirements
fix #xxx[,#xxx]
, where "xxx" is the issue number)Description
br
tag cannot be parsed when callingsetHTML
API.Thank you for your contribution to TOAST UI product. π π β¨