GithubHelp home page GithubHelp logo

react-native-webview-quill's Introduction

⛔️ DEPRECATED - Do you want to take ownership? Please contact me

React Native Webview Quill

Quill component for React Native built using postMessage communication and a WebView.

npm npm npm npm

Installation

npm install react-native-webview-quill

to use you must set a webview provider once on your project

import {providerRegistry} from "react-native-webview-quill"
import {WebView} from 'react-native-webview-quill/src/providers/WebView/ReactNative/index';

providerRegistry.WebViewProvider = WebView

then you can use the Quill component:

import {Quill} from 'react-native-webview-quill';

Preview

screenshot

Properties

All properties are optional.

Property Description
onContentChange A callback receiving the quilljs contents as parameter, whenever the contents change.
options A quilljs instance config, see their documentation.
containerStyle The style property for the inner WebView component, see documentation.
content The initial quilljs contents, useful for readonly/viewer component.

Functions

Use this.quill.reloadResources(), to force component to update content.

componentDidUpdate(prevProps, prevState){
  if (prevState.delta !== this.state.delta)
    this.quill.reloadResources()
}

<Quill
  ref={(quill) => { this.quill = quill }}
  content={ this.state.delta } />

Example Usage

This example is typescript, though the library works with plain javascript as well.

//Generic Dependencies
import * as React from 'react';
import { StatusBar, View } from 'react-native';

// React native webview quill
import { DeltaStatic, providerRegistry, Quill } from 'react-native-webview-quill';
import { WebView } from 'react-native-webview-quill/src/providers/WebView/ReactNative/index';

// Only once: Set the webview implementation to use
// Should be done once, probably in your index.js
providerRegistry.WebViewProvider = WebView;

// This is a example of a QuillDelta object that describes the
// content and formatting of the richtext editor
// More information at https://quilljs.com/docs/delta/
const defaultOps: DeltaStatic = {
  ops: [
    {
      insert: 'Test',
      attributes: {
        bold: true,
      },
    },
  ],
};

export default class App extends React.Component<{}, { content: DeltaStatic }> {
  constructor(props: any) {
    super(props);
    this.state = {
      content: defaultOps,
    };
  }

  public render() {
    //Render a full screen quill editor
    return (
      <View style={{ flex: 1 }}>
        <View style={{ height: StatusBar.currentHeight }} />
        <Quill
          content={
            /* the initial content */
            this.state.content
          }
          onContentChange={
            /* Callend when an edit is made */
            this.onContentChange
          }
          containerStyle={
            /*The style passed to the editor container*/
            { flex: 1 }
           }
        />
      </View>
    );
  }

  private onContentChange = (content: DeltaStatic) => {
    // Save this content
    this.setState({ content });
  };
}

react-native-webview-quill's People

Contributors

bmmevius avatar bramthedev avatar cagigas avatar dependabot[bot] avatar jolanrensen avatar luudjanssen avatar mousetail avatar revadike avatar stefanhoekstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-webview-quill's Issues

Could I use formula type by using this library?

Hi, I saw that insert statements that return texts work well.
And then, I tried to use formula type text like e=mc^2. However {insert:{formula:'e=mc^2'}} format returned nothing. Also it prevented rendering subsequent insert statements.
I know that to use this formula type in quill, it needs to integrate Katex. Is there a way to use formula in this library without it? Or is it structurally possible for me to integrate katex with this library?
Thank you.

Purpose of using encodeURIComponent function in generateWebViewIndex.ts

First of all, thank you for your quill editor integration for react-native.

I have one question about the encodeURIComponent function.
When I wrote code-block and try to render it in quill editor and it showed encoded html which is generated from generateWebViewIndex function instead of right code-block.

After I deleted encodeURIComponent function then it showed right code-block.
I know the purpose of encoding URI but does it needs to be encoded entire html string?

Thank you

RN Version : 0.61.5

Cannot dipslay Quill component

Hello, my problem next, I want to display some styled text in Quill on the newly created project but with no result. I just get a blank screen in the place where should be Quill. One thing to note that I provide WebView with react-native-webview standalone package
RN version 0.61.5

Thanks

Screenshot 2020-03-02 at 19 54 16

Screenshot 2020-03-02 at 19 56 09

TODO: Write local resource provider

Right now, all resources from Quill are loaded via a CDN. We should, however also implement a local resource provider for offline implementation of this component.

Module `quill-delta` does not exist in the Haste module map

Issue description

App crashed after installation of this library with the aforementioned error.

Steps to reproduce the issue

  1. Install this library via 'npm i react-native-webview-quill' in the project folder.
  2. Copy the example usage from https://github.com/LuudJanssen/react-native-webview-quill into a newly made test component (I changed the class name though).
  3. Run the app via 'react-native run-ios' or 'react-native run-android'. Both will crash with aforementioned error.

What's the expected result?

  • The application should run, and the rich text editor should be fully functional upon navigating to the test page.

What's the actual result?

  • App crashed with error message: 'Module quill-delta does not exist in the Haste module map'

What have I tried to solve the problem?

  1. Clear watchman watches: watchman watch-del-all
  2. Delete and re-install the node_modules folder: rm -rf node_modules && npm i
  3. Reset Metro Bundler cache: npm start -- --reset-cache
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*

Environment

System:

  • OS: macOS 10.14.6
  • CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  • Memory: 2.46 GB / 32.00 GB
  • Shell: 3.2.57 - /bin/bash

Binaries:

  • Node: 10.16.0 - /usr/local/bin/node
  • Yarn: 1.16.0 - /usr/local/bin/yarn
  • npm: 6.10.0 - /usr/local/bin/npm
  • Watchman: 4.9.0 - /usr/local/bin/watchman

SDKs:

  • iOS SDK:
    Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0

IDEs:

  • Android Studio: 3.5 AI-191.8026.42.35.5791312
  • Xcode: 11.0/11A420a - /usr/bin/xcodebuild

npmPackages:

  • react: 16.8.6 => 16.8.6
  • react-native: ^0.60.3 => 0.60.3

npmGlobalPackages:

  • create-react-native-app: 2.0.2
  • react-native-cli: 2.0.1
  • react-native-gesture-handler: 1.3.0
  • react-native: 0.60.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.