-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(edit-content): Make our dotAddImage custom plugins for TinyMCE wo…
…rk in Angular FILEASSET #27969 (#28075) * fix: make FILEASSET images work with Angular TinyMCE implementation * fix tests --------- Co-authored-by: Freddy Montes <[email protected]>
- Loading branch information
Showing
4 changed files
with
101 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...nt/src/lib/fields/dot-edit-content-wysiwyg-field/dot-wysiwyg-plugin/utils/editor.utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,69 @@ | ||
// import { DotPageRenderState } from '../../../../apps/dotcms-ui/src/app/portlets/dot-edit-page/shared/models'; | ||
// import { mockDotRenderedPage } from '../../../../apps/dotcms-ui/src/app/test/dot-page-render.mock'; | ||
// import { mockUser } from '../../../../apps/dotcms-ui/src/app/test/login-service.mock'; | ||
// import { getDownloadLink } from './dot-utils'; | ||
// import { DotPageRender } from '@dotcms/dotcms-models'; | ||
|
||
// describe('Dot Utils', () => { | ||
// it('should return anchor with the correct values', () => { | ||
// const blobMock = new Blob(['']); | ||
// const fileName = 'doc.txt'; | ||
// spyOn(window.URL, 'createObjectURL'); | ||
// const anchor = getDownloadLink(blobMock, fileName); | ||
|
||
// expect(anchor.download).toEqual(fileName); | ||
// expect(window.URL.createObjectURL).toHaveBeenCalledWith(blobMock); | ||
// }); | ||
|
||
// it('should return unique URL with host, language and device Ids', () => { | ||
// const mockRenderedPageState = new DotPageRenderState( | ||
// mockUser(), | ||
// new DotPageRender({ | ||
// ...mockDotRenderedPage(), | ||
// viewAs: { | ||
// ...mockDotRenderedPage().viewAs, | ||
// device: { | ||
// identifier: 'abc123', | ||
// cssHeight: '800', | ||
// cssWidth: '1200', | ||
// name: 'custom', | ||
// inode: '123zxc' | ||
// } | ||
// } | ||
// }) | ||
// ); | ||
|
||
// const url = dotUtils.generateDotFavoritePageUrl(mockRenderedPageState); | ||
|
||
// expect(url).toEqual('/an/url/test?&language_id=1&device_id=abc123'); | ||
// }); | ||
// }); | ||
import { DotCMSBaseTypesContentTypes } from '@dotcms/dotcms-models'; | ||
import { EMPTY_CONTENTLET } from '@dotcms/utils-testing'; | ||
|
||
import { getImageAssetUrl } from './dot-utils'; | ||
|
||
describe('Dot Utils', () => { | ||
describe('getImageAssetUrl', () => { | ||
it('should return fileAssetVersion when baseType is FILEASSET and fileAssetVersion is defined', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: DotCMSBaseTypesContentTypes.FILEASSET, | ||
fileAssetVersion: 'fileAssetVersion', | ||
fileAsset: 'fileAsset' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual('fileAssetVersion'); | ||
}); | ||
|
||
it('should return fileAsset when baseType is FILEASSET and fileAssetVersion is not defined', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: DotCMSBaseTypesContentTypes.FILEASSET, | ||
fileAsset: 'fileAsset' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual('fileAsset'); | ||
}); | ||
|
||
it('should return assetVersion when baseType is DOTASSET and assetVersion is defined', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: DotCMSBaseTypesContentTypes.DOTASSET, | ||
assetVersion: 'assetVersion', | ||
asset: 'asset' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual('assetVersion'); | ||
}); | ||
|
||
it('should return asset when baseType is DOTASSET and assetVersion is not defined', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: DotCMSBaseTypesContentTypes.DOTASSET, | ||
asset: 'asset' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual('asset'); | ||
}); | ||
|
||
it('should return asset when baseType is not FILEASSET or DOTASSET', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: 'OTHER', | ||
asset: 'asset' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual('asset'); | ||
}); | ||
|
||
it('should return empty string when asset is not defined and baseType is not FILEASSET or DOTASSET', () => { | ||
const contentlet = { | ||
...EMPTY_CONTENTLET, | ||
baseType: 'OTHER' | ||
}; | ||
|
||
expect(getImageAssetUrl(contentlet)).toEqual(''); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters