react-native-cn-richtext-editor icon indicating copy to clipboard operation
react-native-cn-richtext-editor copied to clipboard

Initial value HTML

Open nlshuynguyen opened this issue 6 years ago • 3 comments

When I put HTML value, it return error: Cannot read property "length" of null

 constructor(props) {
    super(props);

    this.state = {
      selectedTag: 'body',
      selectedStyles: [],
      value: [getInitialObject()]
    };
    this.state.value = convertToObject(`   
    <h1>This HTML snippet is now rendered with native components !</h1>
    <h2>Enjoy a webview-free and blazing fast application</h2>
    <img src="https://i.imgur.com/dHLmxfO.jpg?2" />
    <em style="textAlign: center;">Look at how happy this native cat is</em>`);
    this.editor = null;
  }

<CNRichTextEditor
              ref={input => this.editor = input}
              onSelectedTagChanged={this.onSelectedTagChanged}
              onSelectedStyleChanged={this.onSelectedStyleChanged}
              value={this.state.value}
              style={{ backgroundColor: '#fff' }}
              styleList={defaultStyles}
              onValueChanged={this.onValueChanged}
            />

image

nlshuynguyen avatar Oct 11 '19 03:10 nlshuynguyen

Update with PR #87

Issue must be solved by then.

mqtik avatar Nov 06 '19 14:11 mqtik

I am also having this issue and it seems that the merged PR did not fix the issue? This package looks very promising and could be great but I have existing html (generated from web TinyMCE) that is throwing this error.

jacobSND avatar Dec 30 '19 13:12 jacobSND

Hi @jacobSND, you may try CNEditor Component which accept a html string as initial value. You may install it using npm i react-native-cn-richtext-editor@next. For more information about how to use this pre-release you may read README in the next branch.

imnapo avatar Jan 04 '20 11:01 imnapo