How can I get the Quill editor running in TypeScript?
I have a working example of the WYSIWYG-editor Quill from the Quill site. The following code just has to be copied into an HTML file such as example.html
and there will be a simple text editor example:
<!-- Include stylesheet -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<!-- Create the editor container -->
<div id="editor">
<p>Hello World!</p>
<p>Some initial <strong>bold</strong> text</p>
<p><br></p>
</div>
<!-- Include the Quill library -->
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<!-- Initialize Quill editor -->
<script>
var quill = new Quill('#editor', {
theme: 'snow'
});
</script>
Now I am trying to get this example running in TypeScript. The first thing would be to install quill
and then install the types for TypeScript which should be @types/quill
. Adding them in the package.json
file and running yarn
or npm
loads the classes:
"dependencies": {
"@types/jquery": "3.3.31",
"@types/quill": "^2.0.3",
"@types/react": "16.9.11",
"@types/react-dom": "16.9.4",
"@types/react-router-dom": "5.1.2",
"bootstrap": "4.3.1",
"jquery": "3.4.1",
"popper.js": "1.16.0",
"quill": "^1.3.7",
"react": "16.11.0",
"react-dom": "16.11.0",
"react-router-dom": "5.1.2",
},
But when running the example with the webpack-dev-server
I get an error. The command is:
"scripts": {
"develop": "webpack-dev-server --mode development --open --port 8081 --host 0.0.0.0 --config webpack.dev.config.js"
}
The error is:
ERROR in [at-loader] ./node_modules/@types/quill/node_modules/quill-delta/dist/Delta.d.ts:1:8
TS1259: Module '"/home/myuser/Documents/quill-example/node_modules/@types/quill/node_modules/fast-diff/diff"' can only be default-imported using the 'esModuleInterop' flag
I suppose there is something wrong with the @types/quill
package, right? But what is exactly failing? What is the esModuleInterop
doing exactly? Is there any fix to this error?
I could not find any Quill TypeScript example. It should be fairly easy to get it running in TypeScript, right?