Skip to content

Comments

[FHL] Add InsertHorizontalLine to AutoFormat functionality#2958

Merged
BryanValverdeU merged 11 commits intomasterfrom
u/bvalverde/insertHorizontalBar
Mar 11, 2025
Merged

[FHL] Add InsertHorizontalLine to AutoFormat functionality#2958
BryanValverdeU merged 11 commits intomasterfrom
u/bvalverde/insertHorizontalBar

Conversation

@BryanValverdeU
Copy link
Contributor

@BryanValverdeU BryanValverdeU commented Mar 3, 2025

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:

HorizontalLineFhl

Horizontal line styles
image

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 => {

@BryanValverdeU BryanValverdeU changed the title [FHL] Add InsertHorizontalLine API and also add AutoFormat functionality [FHL] Add InsertHorizontalLine to AutoFormat functionality Mar 4, 2025
@BryanValverdeU BryanValverdeU merged commit 40ebf51 into master Mar 11, 2025
7 checks passed
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.

2 participants