From 0260dd4ccbd954d0f2c8c36e091007f76f5c0dfd Mon Sep 17 00:00:00 2001 From: Aleksandr Varnin <10187586+cmrd-senya@users.noreply.github.com> Date: Mon, 5 Sep 2022 20:07:20 +0300 Subject: [PATCH 1/4] Rename src/index to src/core --- src/{index.tsx => core.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{index.tsx => core.tsx} (100%) diff --git a/src/index.tsx b/src/core.tsx similarity index 100% rename from src/index.tsx rename to src/core.tsx From 9e93a6b94efcf6e9a18714ded70f1ede5a6fbbba Mon Sep 17 00:00:00 2001 From: Aleksandr Varnin <10187586+cmrd-senya@users.noreply.github.com> Date: Mon, 5 Sep 2022 20:09:24 +0300 Subject: [PATCH 2/4] Bump Typescript to 3.8 to support type imports --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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/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" From a7b06461addc09bb52dabfc38a7b11ff173e0795 Mon Sep 17 00:00:00 2001 From: Aleksandr Varnin <10187586+cmrd-senya@users.noreply.github.com> Date: Mon, 5 Sep 2022 20:09:45 +0300 Subject: [PATCH 3/4] POC of loading different Quill class --- src/core.tsx | 11 ++++++++--- src/index.ts | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/index.ts diff --git a/src/core.tsx b/src/core.tsx index f83a11db..3f496bea 100644 --- a/src/core.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; From 09fd0fd65b57324f9cc481e9743750530cf1fe3f Mon Sep 17 00:00:00 2001 From: Aleksandr Varnin <10187586+cmrd-senya@users.noreply.github.com> Date: Mon, 5 Sep 2022 20:11:13 +0300 Subject: [PATCH 4/4] Update entrypoint as it's not tsx anymore --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'],