Skip to content
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

Editor auto height #156

Open
exhibition315 opened this issue Dec 11, 2018 · 2 comments
Open

Editor auto height #156

exhibition315 opened this issue Dec 11, 2018 · 2 comments

Comments

@exhibition315
Copy link

exhibition315 commented Dec 11, 2018

If I put the RichTextEditor into scrollview without height, there is no editor be shown.
Is any possible to make editor height automatically base on content?

My code snip:

<ScrollView>
    // other components
    <RichTextEditor 
        initialContentHTML="some html content"
        style={{flex:1}}
    />
</ScrollView>
@JLHuu
Copy link

JLHuu commented Jan 2, 2019

@exhibition315 Have you solved the problem?I have the same problem

@ChenTianSaber
Copy link

I solved this.

  1. open "editor.html " and edit this function.
function setHTML(editorId, html) {
				var editor = $('#' + editorId);
				editor.html(html);

				var div = document.getElementById('zss_editor_content');
				var clientHeight = div.clientHeight;
				// alert(clientHeight);
				WebViewBridge.send(JSON.stringify({type: 'GET_CONTENT_HEIGHT', data:clientHeight}));

			}

this code means that get the height and send it when setHTML (you can send the height any time you want )

  1. open RichTextEditor and edit this function
onBridgeMessage(str){
    try {
      const message = JSON.parse(str);

      ...other code

-----new------
        case messages.GET_CONTENT_HEIGHT: {
          this.props.onContentHeight && this.props.onContentHeight(message.data);
          break;
        }
-----new------
      }
    } catch(e) {
      // alert('NON JSON MESSAGE');
    }
  }

this code means get the height and callback it.

3.use props

<RichTextEditor
                        ref={(r)=>this.richtext = r}
                        style={{alignItems:'center', justifyContent: 'center', backgroundColor: 'transparent',width:width}}
                        initialContentHTML={item.attributes.content}
                        hiddenTitle={true}
                        onContentHeight={(height)=>{
                            // alert('onContentHeight:'+height);
                            this.articleData.changeArticleContentHeight(height);
                        }}
                    />

I think you know how to do it. You get the height now, so you just update the height of RichTextEditor.

My English is not good . I wish this can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants