globocom / react-native-draftjs-render

React Native render for draft.js model
MIT License
390 stars 62 forks source link

atomic:image #26

Closed Yoruba closed 7 years ago

Yoruba commented 7 years ago

Please add atomic:image to getBlocks.js to support other draft editors?

   case 'atomic:image': {
          const separator = checkCounter(counters);
          if (separator) {
            const atomicView = [];
            atomicView.push(separator);
            atomicView.push(atomicHandler(item));
            return atomicView;
          }
          return atomicHandler(item);
        }

Thanks, Adri

raphaelpor commented 7 years ago

Hi @Yoruba!

We support atomic types with the atomicHandler() parameter. Check out this example.

Yoruba commented 7 years ago

Thanks for the response raphaelpor, you are right but some draft editors like medium draft use type atomic:image instead of image.

When that is the case the image is not render because there is no handler for atomic:image.

{ "key": "e4g3h", "text": "", "type": "atomic:image", "depth": 0, "inlineStyleRanges": [], "entityRanges": [], "data": { "src": "https://lorempixel.com/400/200/" } },

In the view I use

 if (item.type === 'atomic:image') {
    return (
      <View key={item.key} style={{ flex: 1 }}>
        <FitImage source={{ uri: item.data.src }}   />
      </View>
    )
  }
raphaelpor commented 7 years ago

I'm sorry, @Yoruba. But we don't give support to other editors like "medium-draft". We do it only for draft.js editors.

Anyway, we think you can fork this project and do it by yourself.