-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Content Model to handle Delete/Backspace key in more cases (#2162) * Do not set focus when quite shadow edit (#2163) * Fix #237217 (#2164) * Fix #237735 (#2165) * Fix #236416 (#2166) * copyPaste * update versions * Fix #2160 (#2167) * Fix #2160 * fix build --------- Co-authored-by: Jiuqing Song <jisong@microsoft.com>
- Loading branch information
1 parent
f527296
commit 8a4f529
Showing
17 changed files
with
1,359 additions
and
1,027 deletions.
There are no files selected for viewing
29 changes: 17 additions & 12 deletions
29
...content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.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,23 +1,28 @@ | ||
import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets'; | ||
import { handleRegularSelection } from './childProcessor'; | ||
import { addSelectionMarker } from '../utils/addSelectionMarker'; | ||
import type { ElementProcessor } from 'roosterjs-content-model-types'; | ||
|
||
/** | ||
* @internal | ||
* @param group | ||
* @param element | ||
* @param node | ||
* @param context | ||
*/ | ||
export const delimiterProcessor: ElementProcessor<Node> = (group, element, context) => { | ||
let index = 0; | ||
const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, element); | ||
export const delimiterProcessor: ElementProcessor<Node> = (group, node, context) => { | ||
const range = context.selection?.type == 'range' ? context.selection.range : null; | ||
|
||
for (let child = element.firstChild; child; child = child.nextSibling) { | ||
handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset); | ||
if (range) { | ||
if (node.contains(range.startContainer)) { | ||
context.isInSelection = true; | ||
|
||
delimiterProcessor(group, child, context); | ||
index++; | ||
} | ||
addSelectionMarker(group, context); | ||
} | ||
|
||
if (context.selection?.type == 'range' && node.contains(range.endContainer)) { | ||
if (!context.selection.range.collapsed) { | ||
addSelectionMarker(group, context); | ||
} | ||
|
||
handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset); | ||
context.isInSelection = false; | ||
} | ||
} | ||
}; |
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
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.