-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rich Text Editor | Added HardBreak extension in editor for force line…
… break (<br> tag) (#1517) # Pull Request ## 🤨 Rationale Fix for [Bug 2516897](https://dev.azure.com/ni/DevCentral/_workitems/edit/2516897): Switching to a new line by pressing enter adds more spaces than expected. - Pressing enter in the editor for a new line adds a `Paragraph tag` which has more space than expected between lines. - Enabling [HardBreak ](https://tiptap.dev/api/nodes/hard-break) will allow the user to switch to a new line by pressing `Shift/Ctrl/Cmd + Enter` which will make minimal space between lines by adding `<br> tag` instead of `Paragraph Tag`. ## 👩💻 Implementation - Added [`HardBreak` ](https://tiptap.dev/api/nodes/hard-break) node in Tiptap Editor. - Enabled [`newline`](https://github.com/markdown-it/markdown-it/blob/2b6cac25823af011ff3bc7628bc9b06e483c5a08/lib/rules_inline/newline.js#L27C8-L28C42) and [`escape`](https://github.com/markdown-it/markdown-it/blob/2b6cac25823af011ff3bc7628bc9b06e483c5a08/lib/rules_inline/escape.js#L1) rules in MarkdownIt for `RichTextMarkdownParser` to parse the HardBreak markdown syntax as per [CommonMark Spec](https://spec.commonmark.org/0.30/#hard-line-breaks) to `<br> tag`. - Added `hardBreak` node to `RichTextMarkdownSerializer` to serialize the `<br> tag` to respective hard break markdown syntax. - As we are using `prosemirror-markdown`, it serializes the `<br>` tag to backslash with [line ending](https://spec.commonmark.org/0.30/#hard-line-breaks) syntax as per the [CommonMark Spec example 633](https://spec.commonmark.org/0.30/#example-633). In Windows `Shift/Ctrl+ Enter` and in Mac `Cmd + Enter` will switch to a new line (line break). We are not exposing any format buttons to add line breaks (Hard Break), The only way to break the line is by using the Keys mentioned above. ## 🧪 Testing - Added unit tests and visual tests for the functionality. - Manually tested and verified the functionality of the supported features in Storybook build. ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
- Loading branch information
Showing
12 changed files
with
409 additions
and
9 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-90bda8e4-208e-4e0c-ae48-b3730a529c57.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Shift/Ctrl/Cmd + Enter will add line break in editor", | ||
"packageName": "@ni/nimble-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.