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 | 1x 1x 12x 12x 8x 4x | import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';
import type { ReadonlyContentModelDocument } from 'roosterjs-content-model-types';
import type { ImageAndParagraph } from '../types/ImageAndParagraph';
/**
* @internal
*/
export function getSelectedImage(model: ReadonlyContentModelDocument): ImageAndParagraph | null {
const selections = getSelectedSegmentsAndParagraphs(model, false);
if (selections.length == 1 && selections[0][0].segmentType == 'Image' && selections[0][1]) {
return {
image: selections[0][0],
paragraph: selections[0][1],
};
} else {
return null;
}
}
|