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 22 23 24 25 26 27 28 29 30 31 32 | 1x 1x 39x 39x 39x 39x 39x | import { getDOMInsertPointRect, scrollRectIntoView } from 'roosterjs-content-model-dom';
import type { EditorCore, ImageSelection, RangeSelection } from 'roosterjs-content-model-types';
/**
* @internal
*/
export function scrollCaretIntoView(core: EditorCore, selection: RangeSelection | ImageSelection) {
const rect = getDOMInsertPointRect(
core.physicalRoot.ownerDocument,
selection.type == 'image'
? {
node: selection.image,
offset: 0,
}
: selection.isReverted
? {
node: selection.range.startContainer,
offset: selection.range.startOffset,
}
: {
node: selection.range.endContainer,
offset: selection.range.endOffset,
}
);
const visibleRect = core.api.getVisibleViewport(core);
const scrollContainer = core.domEvent.scrollContainer;
Eif (rect && visibleRect) {
scrollRectIntoView(scrollContainer, visibleRect, core.domHelper, rect);
}
}
|