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 33 34 35 36 37 38 39 40 41 42 | 1x 1x 1x 16x 16x 24x 24x 11x 11x 12x 16x | import { queryContentModelBlocks } from 'roosterjs-content-model-api';
import type {
ReadonlyContentModelBlockGroup,
ReadonlyContentModelParagraph,
} from 'roosterjs-content-model-types';
import type { ImageAndParagraph } from '../types/ImageAndParagraph';
/**
* @internal
*/
export const EDITING_MARKER = 'isEditing';
/**
* @internal
*/
export function findEditingImage(
group: ReadonlyContentModelBlockGroup,
imageId?: string
): ImageAndParagraph | null {
let imageAndParagraph: ImageAndParagraph | null = null;
queryContentModelBlocks<ReadonlyContentModelParagraph>(
group,
'Paragraph',
(paragraph: ReadonlyContentModelParagraph): paragraph is ReadonlyContentModelParagraph => {
for (const segment of paragraph.segments) {
if (
segment.segmentType == 'Image' &&
((imageId && segment.format.id == imageId) ||
segment.format.imageState == EDITING_MARKER)
) {
imageAndParagraph = { image: segment, paragraph };
return true;
}
}
return false;
},
true /*findFirstOnly*/
);
return imageAndParagraph;
}
|