fix: change getAsset to not return a promise (#3232)
* fix: change getAsset to not return a promise * fix: update markdown widget per getAsset changes * test: fix editor component image test * docs: update getAsset docs
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import component from '../index';
|
||||
|
||||
const getAsset = path => Promise.resolve(path);
|
||||
const getAsset = path => path;
|
||||
const image = '/image';
|
||||
const alt = 'alt';
|
||||
const title = 'title';
|
||||
@ -32,8 +32,8 @@ describe('editor component image', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should generate valid react props', async () => {
|
||||
await expect(component.toPreview({ image, alt, title }, getAsset)).resolves.toMatchObject({
|
||||
it('should generate valid react props', () => {
|
||||
expect(component.toPreview({ image, alt, title }, getAsset)).toMatchObject({
|
||||
props: { src: image, alt, title },
|
||||
});
|
||||
});
|
||||
|
@ -12,10 +12,10 @@ const image = {
|
||||
toBlock: ({ alt, image, title }) =>
|
||||
`}"` : ''})`,
|
||||
// eslint-disable-next-line react/display-name
|
||||
toPreview: async ({ alt, image, title }, getAsset, fields) => {
|
||||
toPreview: ({ alt, image, title }, getAsset, fields) => {
|
||||
const imageField = fields?.find(f => f.get('widget') === 'image');
|
||||
const folder = imageField?.get('media_folder');
|
||||
const src = await getAsset(image, folder);
|
||||
const src = getAsset(image, folder);
|
||||
return <img src={src || ''} alt={alt || ''} title={title || ''} />;
|
||||
},
|
||||
pattern: /^!\[(.*)\]\((.*?)(\s"(.*)")?\)$/,
|
||||
|
Reference in New Issue
Block a user