Stacks-Editor icon indicating copy to clipboard operation
Stacks-Editor copied to clipboard

fix(html-comment): fix html comments from being visible in the rich editor

Open giamir opened this issue 2 years ago • 4 comments

Closes #195

Hello, first time contributor here. 👋 I thought I would pick up an issue labeled as good first issue to familiarize myself with the codebase and your code conventions. I have to say the PR turned out to be a bit bigger than I initially thought. Nevertheless I hope this is useful and I look forward to your feedback.

Describe your changes

Issue Analysis The blue bar in RT mode described in #195 appears because of this CSS rule which applies to all selected html_block nodes markdown-it parses out (html comments are treated as any another html_block node). Furthermore I found that all the html comments get a margin bottom in RT mode (which I assume is not desired behavior) as a consequence of being categorized as any other html_block by the parser.

Proposed Solution The solution I implemented introduces an html_comment markdown-it plugin which allows to differentiate html comments and handle them accordingly in the RT mode. The plugin detects only html comments blocks. Html comments inlined with other elements/text are ignored and they are processed as they were before.

<!-- a comment -->
✅ Detected
 
<!-- 
  a comment 
  over multiple lines 
-->
✅ Detected



some text <!-- a comment -->
❌ Ignored

<!-- a comment --> <p>some html</p>
❌ Ignored

A more detailed explanation about the plugin's logic can be found in the related unit test file (html-comment.test.ts).

PR Checklist

  • [x] All new/changed functionality includes unit and (optionally) e2e tests as appropriate
  • [x] All new/changed functions have /** ... */ docs
  • [x] I've added the bug/enhancement and other labels as appropriate

Environment(s) tested

  • Device: Chrome
  • OS: MacOS 12.5
  • Browser: Chrome
  • Version: 99

giamir avatar Aug 10 '22 16:08 giamir

Thank you for the PR! I'll try and review the next chance I get.

b-kelly avatar Aug 10 '22 17:08 b-kelly

Hi @b-kelly, Let me know if there is anything I can do to make your review process easier and prevent this branch from going stale. I tried to outline my solutioning in the PR summary but I'd also be open to go through the changes on a quick sync meeting if you prefer. Thanks.

giamir avatar Aug 23 '22 08:08 giamir

@giamir Sorry, I've been up to my eyeballs in non-Stacks-Editor related tasks this last week. I plan on getting a new release out by the end of the month (this week likely), so my goal is to have your PR reviewed and merged by then. Thank you for your patience!

b-kelly avatar Aug 23 '22 13:08 b-kelly

No problem, @b-kelly. I did not mean to create a sense of urgency. I only wanted to offer support. I appreciate your efforts as a maintainer and I can certainly empathise with busy times at work.

giamir avatar Aug 23 '22 13:08 giamir