Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 16x | import type { DOMSelection } from 'roosterjs-content-model-types'; /** * Get root node of a given DOM selection * For table selection, root node is the selected table * For image selection, root node is the selected image * For range selection, root node is the common ancestor container node of the selection range * @param selection The selection to get root node from */ export function getSelectionRootNode(selection: DOMSelection | undefined): Node | undefined { return !selection ? undefined : selection.type == 'range' ? selection.range.commonAncestorContainer : selection.type == 'table' ? selection.table : selection.type == 'image' ? selection.image : undefined; } |