reggie3/react-native-webview-quilljs

getDelta return undefined.

Closed this issue · 5 comments

Hi Team,

I am trying to use this library, but not able to get the content as per the documentation.
Is there any other way to get the data from editor?

Regards,
Nilesh

Can you post the code you're using?

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { WebViewQuillEditor } from 'react-native-webview-quilljs';
import { Container, Button, Text } from 'native-base';

export default class RkEditor extends Component {

static navigationOptions = () => {
    return {
        headerTitle: 'Editor',
        headerBackTitle: null,
    };
};

static propTypes = {
    contentToDisplay: PropTypes.object,
}

static defaultProps = {
    // url: 'http://localhost:8080/uat/editor'
}

onLoadCallback = (item) => {
    console.log(item);
}

_getDeltaCallback = () => {
    const editor = this.webViewQuillEditor;
    console.log(editor);
    debugger;
}

render() {
    return (
        <Container style={{ flex: 1 }}>
            <Container>
                <WebViewQuillEditor
                    ref={component => (this.webViewQuillEditor = component)}
                    // getDeltaCallback={() => this._getDeltaCallback()}
                    contentToDisplay={this.props.contentToDisplay}
                    onLoad={this.onLoadCallback}
                    style={{ height: 100 }}
                />
            </Container>
            <Button onPress={() => this._getDeltaCallback()}>
                <Text>Get Text</Text>
            </Button>
        </Container>
    );
}

}

Your _getDeltaCallback receives an argument that contains the editor contents. Try something like this:

_getDeltaCallback = (contents) => {
    const editor = this.webViewQuillEditor;
    console.log(contents);
    debugger;
}

Closing for inactivity

Still same issue.

i passed arguments in _getDeltaCallback but "contents" argument is undefined.