Skip to content

Commit

Permalink
Merge pull request #2796 from microsoft/u/juliaroldi/patch-fix-images
Browse files Browse the repository at this point in the history
Bump RoosterJs Plugins to 9.10.1
  • Loading branch information
juliaroldi authored Sep 12, 2024
2 parents 5a9c925 + 32efe39 commit 0292cbd
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function findEditingImage(
switch (segment.segmentType) {
case 'Image':
if (
(segment.dataset.isEditing && !imageId) ||
segment.format.id == imageId
(imageId && segment.format.id == imageId) ||
segment.dataset.isEditing
) {
return {
paragraph: block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,281 @@ describe('findEditingImage', () => {
},
});
});

it('editing image - no id - no editing image | by Id', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'test',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
],
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: '#000000',
},
};

const image = findEditingImage(model);
expect(image).toEqual(null);
});

it('editing image - no id - editing image', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'test',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Text',
text: 'second line',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'second-Image',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {
isEditing: 'true',
},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
],
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: '#000000',
},
};

const image = findEditingImage(model);
expect(image).toEqual({
image: {
segmentType: 'Image',
src: 'second-Image',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {
isEditing: 'true',
},
},
paragraph: {
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'second-Image',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {
isEditing: 'true',
},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
});
});

it('editing image - with id - editing image', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'test',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
id: 'testId',
},
dataset: {},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Text',
text: 'second line',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'second-Image',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
},
dataset: {
isEditing: 'true',
},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
],
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: '#000000',
},
};

const image = findEditingImage(model, 'testId');
expect(image).toEqual({
image: {
segmentType: 'Image',
src: 'test',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
id: 'testId',
},
dataset: {},
},
paragraph: {
blockType: 'Paragraph',
segments: [
{
segmentType: 'Image',
src: 'test',
format: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
maxWidth: '1800px',
id: 'testId',
},
dataset: {},
},
],
format: {},
segmentFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: 'rgb(0, 0, 0)',
},
},
});
});
});
4 changes: 3 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"react": "9.0.0",
"main": "9.10.0",
"legacyAdapter": "8.62.1",
"overrides": {}
"overrides": {
"roosterjs-content-model-plugins": "9.10.1"
}
}

0 comments on commit 0292cbd

Please sign in to comment.