diff --git a/package.json b/package.json index 9013f4cf..a01dbe09 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "superstatic": "^6.0.4", "travis-cov": "^0.2.5", "ts-loader": "^6.2.1", - "typescript": "^3.7.2", + "typescript": "^3.8.3", "webpack": "^4.41.2", "webpack-cli": "^3.3.10" } diff --git a/src/index.tsx b/src/core.tsx similarity index 98% rename from src/index.tsx rename to src/core.tsx index f83a11db..3f496bea 100644 --- a/src/index.tsx +++ b/src/core.tsx @@ -7,7 +7,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import isEqual from 'lodash/isEqual'; -import Quill, { +import type Quill from 'quill'; +import type { QuillOptionsStatic, DeltaStatic, RangeStatic, @@ -96,7 +97,7 @@ class ReactQuill extends React.Component { /* Export Quill to be able to call `register` */ - static Quill = Quill; + static Quill: undefined | { new(...args: any): Quill } = undefined; /* Changing one of these props should cause a full re-render and a @@ -329,7 +330,11 @@ class ReactQuill extends React.Component { configuration, have its events bound, */ createEditor(element: Element, config: QuillOptions) { - const editor = new Quill(element, config); + const QuillClass = ReactQuill.Quill; + if (!QuillClass) { + throw Error("You must define ReactQuill.Quill before using ReactQuill"); + } + const editor = new QuillClass(element, config); if (config.tabIndex != null) { this.setEditorTabIndex(editor, config.tabIndex); } diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..9d023d46 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,9 @@ +import Quill from 'quill'; + +import ReactQuill from './core'; + +if (!ReactQuill.Quill) { + ReactQuill.Quill = Quill; +} + +export = ReactQuill; diff --git a/webpack.config.js b/webpack.config.js index 34c5666a..c74a8804 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const dir = (...args) => Path.resolve(__dirname, ...args); module.exports = { mode: 'production', - entry: dir('src/index.tsx'), + entry: dir('src/index.ts'), resolve: { extensions: ['.js', '.ts', '.tsx'], diff --git a/yarn.lock b/yarn.lock index cafe2e98..6e8916dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5898,10 +5898,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" - integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ== +typescript@^3.8.3: + version "3.9.10" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" + integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== union-value@^1.0.0: version "1.0.1"