[FHL] Add InsertHorizontalLine to AutoFormat functionality#2958
Merged
BryanValverdeU merged 11 commits intomasterfrom Mar 11, 2025
Merged
[FHL] Add InsertHorizontalLine to AutoFormat functionality#2958BryanValverdeU merged 11 commits intomasterfrom
BryanValverdeU merged 11 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
PR Overview
This pull request adds a new API to insert a horizontal line and integrates auto-formatting functionality to replace paragraphs consisting solely of repeated '-', '=', or '_' characters with a horizontal rule. Key changes include:
- Adding the public API function and its underlying model API implementation for horizontal line insertion.
- Extending unit tests for both public and model APIs as well as auto-format plugin behavior.
- Updating the auto format plugin and demo UI to incorporate the new autoHorizontalLine option.
Reviewed Changes
| File | Description |
|---|---|
| packages/roosterjs-content-model-api/test/publicApi/block/insertHorizontalLineTest.ts | Tests for the public API insertion of horizontal lines. |
| packages/roosterjs-content-model-api/test/modelApi/block/insertHorizontalLineIntoModelTest.ts | Unit tests verifying model API behavior for horizontal line insertion. |
| packages/roosterjs-content-model-plugins/test/autoFormat/AutoFormatPluginTest.ts | Extended tests ensuring the auto-format behavior correctly creates a horizontal line for valid inputs. |
| packages/roosterjs-content-model-api/lib/modelApi/block/insertHorizontalLineIntoModel.ts | New model API function for inserting a horizontal divider. |
| packages/roosterjs-content-model-api/lib/publicApi/block/insertHorizontalLine.ts | Public API wrapper for the horizontal line insertion functionality. |
| packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts | AutoFormat plugin updated to detect trigger patterns and insert horizontal lines accordingly. |
| packages/roosterjs-content-model-plugins/lib/autoFormat/interface/AutoFormatOptions.ts | Extended AutoFormat options with the autoHorizontalLine flag. |
| demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx | Updated demo UI to provide a checkbox for enabling/disabling horizontal line auto-formatting. |
| packages/roosterjs-content-model-api/lib/index.ts | Export updates to include the new horizontal line APIs. |
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts:281
- [nitpick] Consider renaming the arrow function parameter 'c' to 'triggerChar' for improved clarity of intent.
return HorizontalLineTriggerCharacters.some(c => {
juliaroldi
reviewed
Mar 4, 2025
packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts
Outdated
Show resolved
Hide resolved
juliaroldi
reviewed
Mar 11, 2025
...oosterjs-content-model-plugins/lib/autoFormat/horizontalLine/checkAndInsertHorizontalLine.ts
Show resolved
Hide resolved
juliaroldi
approved these changes
Mar 11, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new feature to the AutoFormat plugin, whenever in the paragraph there are 3 or more characters of '=', '-' or '_'.
Once pressing enter, the characters should be removed and instead add a HR element:
Horizontal line styles

Following
https://support.microsoft.com/en-us/office/insert-a-horizontal-line-9bf172f6-5908-4791-9bb9-2c952197b1a9