mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
[visual] Handle selections adjacent to lists and section headings (#13581)
GitOrigin-RevId: 35b289102110f88587679740eeed575e16f6788b
This commit is contained in:
@@ -64,6 +64,28 @@ export function getAncestorStack(
|
||||
return stack.reverse()
|
||||
}
|
||||
|
||||
export const wrappedNodeOfType = (
|
||||
state: EditorState,
|
||||
range: SelectionRange,
|
||||
type: string | number
|
||||
): SyntaxNode | null => {
|
||||
if (range.empty) {
|
||||
return null
|
||||
}
|
||||
|
||||
const ancestorNode = ancestorNodeOfType(state, range.from, type, 1)
|
||||
|
||||
if (
|
||||
ancestorNode &&
|
||||
ancestorNode.from === range.from &&
|
||||
ancestorNode.to === range.to
|
||||
) {
|
||||
return ancestorNode
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export const ancestorNodeOfType = (
|
||||
state: EditorState,
|
||||
pos: number,
|
||||
|
||||
Reference in New Issue
Block a user