react-native-rich-editor icon indicating copy to clipboard operation
react-native-rich-editor copied to clipboard

editor does not always appear

Open iamjon opened this issue 4 years ago • 13 comments
trafficstars

Hi, I have a weird issue with the editor. I load the component, it appears but doesn't load the webview. If I save the code it refreshes and the editor magically appears. I'm attaching an example, I also noticed if I close the parent component and reopen it, it works as desired.

https://user-images.githubusercontent.com/617757/103286157-75a63800-49e8-11eb-9b9f-fe2872e20627.mp4

"react-native": "0.63.2", "react-native-webview": "11.0.2", "react-native-pell-rich-editor": "^1.5.3",

iamjon avatar Dec 29 '20 13:12 iamjon

I can't see any problems in the video

stulip avatar Dec 31 '20 07:12 stulip

at 6 seconds you'll see the component load but there's not editor, it should look the way it does at 25 seconds in with the placeholder

iamjon avatar Dec 31 '20 08:12 iamjon

@iamjon You can look at this part of your code

stulip avatar Dec 31 '20 08:12 stulip

@stulip I'm sorry I don't understand. Here is my component import React, { Component } from 'react'; import { View, StyleSheet, Keyboard, TouchableWithoutFeedback, Text, KeyboardAvoidingView } from 'react-native'; import { RichEditor, RichToolbar } from 'react-native-pell-rich-editor';

interface RichTextProps { defaultHtml: string; onUpdate: (html) => void; }

export class RichText extends Component<RichTextProps, any> { richtext = React.createRef<RichEditor>();

constructor(props) {
    super(props);
}


onEditorInitialized = () => {
   console.log('initalised');
}

handleChange = (html) => {
    if (this.props.onUpdate){
        this.props.onUpdate(html);
    }
}

render() {
    return (
        <KeyboardAvoidingView behavior="padding" enabled keyboardVerticalOffset={0} style={styles.keyboardView}>
            <TouchableWithoutFeedback onPress={Keyboard.dismiss} >
                <View style={styles.main}>
                    <RichEditor
                        ref={this.richtext}
                        initialContentHTML={this.props.defaultHtml}
                        placeholder={"PlaceHolder"}
                        editorInitializedCallback={this.onEditorInitialized}
                        onChange={this.handleChange}
                    />
                </View>
            </TouchableWithoutFeedback>
            <View style={styles.toolbarWrap}>
                 <RichToolbar getEditor={() => this.richtext.current} />
            </View>
        </KeyboardAvoidingView>
    );
}

}

iamjon avatar Dec 31 '20 08:12 iamjon

I put this code in. In the example of this project, your situation does not appear

stulip avatar Dec 31 '20 08:12 stulip

I am also experiencing this issue. The RicheEditor component will take a while to load. However, for my use case it would suffice if I knew when the component has been mounted already, that way I could place a loader in the meantime.

Andrea-Arguello avatar Jan 04 '21 17:01 Andrea-Arguello

I didn't think of that. Good call. I'll have to investigate further. I think the following functions might help. The webview functions can be passed as props from the RichEditor. onEditorInitialized = () => { console.log('initalised'); }

might work

webview functions that can help:

https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#methods

mainly onloadprogress https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#onloadprogress

and onloadend https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#onloadend

and renderloading +startInLoadingState https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#renderloading

iamjon avatar Jan 05 '21 08:01 iamjon

I ended up setting a state variable called “loaded” that changes to true when onEditorInitialized is called. Hope this helps.

Andrea-Arguello avatar Jan 05 '21 17:01 Andrea-Arguello

So in my case it was being caused this line in RichEditor.js

const opacity = that.state.isInit ? 1 : 0;

I used patch package and set the opacity to 1 and it started working all the time.

iamjon avatar Feb 24 '21 14:02 iamjon

@stulip is this something you want to examine further or can I close the issue?

iamjon avatar Feb 24 '21 14:02 iamjon

Hi, I have a weird issue with the editor. I load the component, it appears but doesn't load the webview. If I save the code it refreshes and the editor magically appears. I'm attaching an example, I also noticed if I close the parent component and reopen it, it works as desired.

Screenrecorder-2020-12-29-15-10-26-822.mp4 "react-native": "0.63.2", "react-native-webview": "11.0.2", "react-native-pell-rich-editor": "^1.5.3",

Today i get same issue, tks for your question.

cuongnv40 avatar Mar 09 '21 02:03 cuongnv40

I've got same issue, and I set the opacity = 1 that is working well. image

franklinatdn avatar Oct 04 '21 13:10 franklinatdn

A patch version 1.8.7 is released to fix the problem of non-representation caused by this transparency

stulip avatar Dec 24 '21 09:12 stulip