-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Bryan Valverde U <[email protected]>
- Loading branch information
1 parent
9d3deb2
commit 33531e1
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
packages/roosterjs-content-model-dom/lib/domToModel/processors/brProcessor.ts
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 |
---|---|---|
@@ -1,17 +1,28 @@ | ||
import { addSegment } from '../../modelApi/common/addSegment'; | ||
import { createBr } from '../../modelApi/creators/createBr'; | ||
import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets'; | ||
import type { ElementProcessor } from 'roosterjs-content-model-types'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const brProcessor: ElementProcessor<HTMLBRElement> = (group, element, context) => { | ||
const br = createBr(context.segmentFormat); | ||
const [start, end] = getRegularSelectionOffsets(context, element); | ||
|
||
if (start >= 0) { | ||
context.isInSelection = true; | ||
} | ||
|
||
if (context.isInSelection) { | ||
br.isSelected = true; | ||
} | ||
|
||
const paragraph = addSegment(group, br, context.blockFormat); | ||
|
||
if (end >= 0) { | ||
context.isInSelection = false; | ||
} | ||
|
||
context.domIndexer?.onSegment(element, paragraph, [br]); | ||
}; |
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