wix-incubator / react-native-zss-rich-text-editor

React Native rich text editor based on ZSSRichTextEditor
Other
839 stars 310 forks source link

The Editor works fine in iOS but Android didn't work #50

Open JohnHour89 opened 7 years ago

JohnHour89 commented 7 years ago

Hi, Sir, I was able to use the editor and the toolbar actions works well in iOS platform but it doesn't work in Android (The content also didn't display in the editor on Android). Please help to rectify this issue. Thank you. Below is the screenshot of use your editor in the app:

in iOS: screen shot 2017-08-16 at 11 20 03 am

in Android:

screen shot 2017-08-16 at 11 20 56 am

phuongpt commented 7 years ago

style issue, try something like this

render() {
    return (
      <View style={this.getStyle('container')}>
        <RichTextEditor
          ref={(r)=>this.richtext = r}
          style={[this.getStyle('richText'), this.props.editorStyle]}
          contentInset={{right: 0, left: 0}}
          bounces={false}
          hiddenTitle={true}
          enableOnChange={true}
          contentPlaceholder={this.props.placeholder}
          initialContentHTML={this.state.value}
          editorInitializedCallback={() => this.onEditorInitialized()}
          />
        <View style={[this.getStyle('toolbar'), this.props.toolbarStyle]}>
          <RichTextToolbar
            getEditor={() => this.richtext}
            />
        </View>
        <KeyboardSpacer/>
      </View>
    );
  },

  defaultStyles: {
    container: {
      flex: 1,
      backgroundColor: '#ffffff',
    },
    richText: {
      alignItems:'center',
      justifyContent: 'center',
      backgroundColor: 'transparent',
      marginTop: 60
    },
    toolbar:{
      position: 'absolute',
      top: 0,
      left: 0,
      right: 0
    }
  },
JohnHour89 commented 7 years ago

Sorry, I didn't put my code here, actually I got try your code and change a little bit but it is still the same show nothing here on editor in Android platform. This is my previous code:

render() {
    return (
        <View style={styles.editorContainer}>
            <RichTextEditor
              ref={(r)=>this.richtext = r}
              style={styles.richText}
              initialTitleHTML={'Title!!'}
              initialContentHTML={'Hello <b>World</b> <p>this is a new paragraph</p> <p>this is another new paragraph</p>'}
              editorInitializedCallback={() => this.onEditorInitialized()}
          />
            <RichTextToolbar
              getEditor={() => this.richtext}
              actions={defaultActions}
              iconTint='black'
              selectedButtonStyle={{backgroundColor:'yellow'}}
            />
      </View>
  );
},

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'stretch',
  },
richText: {
    alignItems:'center',
    justifyContent: 'center',
    backgroundColor: 'transparent',
  },
JohnHour89 commented 7 years ago

Do you think that it is style issue? If it is why can display in iOS but cannot display in Android platform?

JohnHour89 commented 7 years ago

I have realised the packager when running the app it didn't processing the assets which is required in Android whereas in iOS the editor.html it was successfully build:

When running for Android: screen shot 2017-08-17 at 2 03 26 pm

When running for iOS:

screen shot 2017-08-17 at 2 01 52 pm

May I know what is the problem with it? Thank you

cizhaoyang commented 7 years ago

How is the version of react-native ?

JohnHour89 commented 7 years ago

@cizhaoyang react-native 0.31.0 and I got try testing on the iphone simulator only the image attachment function is not available.

nguyenchr commented 7 years ago

@JohnHour89 did you ever figure this one out? Seems I have the same problem, it can't find editor.html

lottery2017 commented 6 years ago

可能需要你把这个html文件拷贝到android的assets目录下 in english: may be you should copy this html file to android assets dir

remch1990 commented 6 years ago

I have this problem, in Android debug works fine, without debug dont work, any fix?

omnikitty commented 6 years ago

For me, I copied editor.html file from the module to android/app/src/main/assets, and then it showed up fine. Not sure why it doesn't do it on its own!

remch1990 commented 6 years ago

@omnikitty only you copied the file in that location and it is works? works in android? i have flavors for diferents apps, i have to copy this file in the same location main/assets or in the file of the flavor?

ethanyuwang commented 6 years ago

Having the same problem. Have already copied editor.html to android/app/src/main/assets

omnikitty commented 6 years ago

@remch1990 Yep, I just copied it there and it worked in android. I also removed the styling from @phuongpt's suggestion. I don't have different flavors for my app, so not sure how that works. If it doesn't work, try checking to make sure it works in iOS simulator first.

steveccable commented 6 years ago

So FWIW, I had this same problem, and based on this line in the JS source, I realized it was looking for editor.html in android/app/assets rather than in android/app/src/main/assets, which is where the file was put by gradle after following their setup instructions. Once I moved the file to the right place, it worked fine. Strange that this seems to contradict the above suggestions...

omnikitty commented 6 years ago

@steveccable Nice catch. I'm not certain, but I think it's because my project doesn't have an android/app/assets folder, so it looks for it in the android/app/src/main/assets instead by default?

MaxInMoon commented 5 years ago

Any news on it guys?