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: convert by using HTML tag when it is not between spaces #2572

Merged
merged 5 commits into from
Jun 28, 2022

Conversation

jajugoguma
Copy link
Contributor

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

  • Fix the converter to match the spec difference between WYSIWYG and Markdown.
    • Following markdown spec (Rule 5), the markdown like **"text"**a is not parsed.
    • But in WYSIWIG, It is possible that typing content like "test"a.
    • So, to match both, when typing it in WYSIWIG and converting to markdown, It will be converted by using an HTML tag, not a markdown delimiter.

Typing content in WYSIWYG

As-Is

To-Be


Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

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.

리뷰 완료합니다.

const { content } = parent;

const isFrontNodeEndWithSpace =
index === 0 || isEndWithSpace(content.child(index - 1).text ?? 'a');

Choose a reason for hiding this comment

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

기본값으로 처리한 'a' 는 공백 문자를 넣으면 isEndWithSpace 혹은 isStartWithSpace 가 제대로 동작하지 않으니까 임의로 넣은 문자인가요?

Copy link
Contributor

Choose a reason for hiding this comment

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

그러게요. 'a'가 뭘 나타내는건지 의미를 만들어 상수화 시켜야겠습니다.

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 215 to 217
if (betweenSpace) {
delim = '**';
} else {

Choose a reason for hiding this comment

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

delim 변수를 선언할 때 기본값을 정하고, 분기문은 한번만 둬도 되지 않을까요?

let delim = '**';

if (!betweenSpace) {
  delim = entering ? '<strong>' : '</strong>';
}

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.

리뷰 완료합니다.

const { content } = parent;

const isFrontNodeEndWithSpace =
index === 0 || isEndWithSpace(content.child(index - 1).text ?? 'a');
Copy link
Contributor

Choose a reason for hiding this comment

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

그러게요. 'a'가 뭘 나타내는건지 의미를 만들어 상수화 시켜야겠습니다.

rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
};
},

emph({ node }, { entering }) {
emph({ node }, { entering }, betweenSpace) {
Copy link
Contributor

Choose a reason for hiding this comment

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

같이 처리했네요. 좋습니다. 👍👍👍

@jajugoguma jajugoguma merged commit 66db3f8 into master Jun 28, 2022
@jajugoguma jajugoguma deleted the fix/convert-strong-to-match-spec branch June 28, 2022 02:27
kshnurov added a commit to kshnurov/tui.editor that referenced this pull request Sep 26, 2022
jajugoguma pushed a commit that referenced this pull request Feb 16, 2023
ahamelers pushed a commit to ahamelers/tui.editor that referenced this pull request Aug 21, 2023
* wip: convert strong to tag when it is not between spaces

* fix: convert strong to tag when it is not between spaces

* fix: convertor that follows the same rule

* test: add test for convertor

* chore: apply code reviews
ahamelers pushed a commit to ahamelers/tui.editor that referenced this pull request Aug 21, 2023
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.

4 participants