-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image is not rendering. Does anybody faced this problem? #66
Comments
did you solved this problem? |
Here is my state. {
"blocks": [
{
"key": "c407s",
"text": " ",
"type": "atomic",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [{ "offset": 0, "length": 1, "key": 0 }],
"data": {}
}
],
"entityMap": {
"0": {
"type": "IMAGE",
"mutability": "IMMUTABLE",
"data": {
"url": "https://shanghai.aliyuncs.com/images/41600b6b-37be-4229-8adb-da4bfa4c6b7e.jpg",
"name": "1668482961564_5",
"type": "IMAGE",
"meta": {
"id": "images/41600b6b-37be-4229-8adb-da4bfa4c6b7e.jpg",
"title": "c96fd0302923c17f7dcf2b8f859fdc50.jpg",
"alt": "c96fd0302923c17f7dcf2b8f859fdc50.jpg",
"loop": false,
"autoPlay": false,
"controls": false,
"poster": ""
}
}
}
}
} It works after I add a atomicHandler like this: const atomicHandler = (item: any, entityMap: any): any => {
for (let entityItem of item.entityRanges) {
if (entityMap.hasOwnProperty(entityItem.key)) {
const entity = entityMap[entityItem.key];
console.log(entity);
if (entity.type === 'IMAGE') {
return (
<Image
source={{uri: entity.data.url}}
width={100}
/>
);
}
}
}
return null;
}; getRNDraftJSBlocks({
contentState: state,
atomicHandler,
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"entityMap":{"0":{"type":"IMAGE","mutability":"MUTABLE","data":{"src":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRWO_UAe27eAhTik2ggPbzKGQfuXD1oVosA_Q&usqp=CAU","height":"auto","width":"auto","alignment":"right"}}}
The text was updated successfully, but these errors were encountered: