sibiraj-s / ngx-editor

🖋️ Rich Text Editor for angular using ProseMirror
https://sibiraj-s.github.io/ngx-editor/
MIT License
457 stars 191 forks source link

[Bug]: Input rules do not apply styles correctly. Some marker characters are not replaced #490

Closed raphael-inglin-ergon closed 1 year ago

raphael-inglin-ergon commented 1 year ago

What happened?

When using markdown syntax to e.g. write bold text by typing **bold text** it will be replaced to show **bold text* instead of bold text. Same applies to italics. This can be easily reproduced in the demo application: https://ngx-editor.stackblitz.io/.

Potential Cause & Solution

After a quick look at the code, I think the issue comes from the regex patterns in defaultPlugins.ts combined with the application of those rules in markInputRule.ts. All groups in the regex patterns are non-capturing, so the if(match[2]) branch is never executed and the wrong range is being replaced. It could probably be fixed by using capturing groups at the right place or using named groups.

Version

15.3.0

Angular Version

16.1.0

What browsers are you seeing the problem on?

No response

Link to reproduce

https://ngx-editor.stackblitz.io/

Relevant log output

No response

Willing to submit a PR?

Yes

sibiraj-s commented 1 year ago

Thanks for report. Please raise a PR, I will try to merge it soon.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.