'Error : Delta is not a constructor' while using Clipboard in Module
See original GitHub issueFirst of all, Great Job.
My goal is to check if any <img>
is pasted in the editor. If yes, then I want to call my backend API for the storage of the image and then replace the base64
version of the src with the URL
sent by the API (You already know the custom image handling stuff).
I figured that I have to use the clipboard
in the Modules for the said task.
So here is my starter code for the same:
SandBox Link
import React from "react";
import ReactQuill, { Delta } from "react-quill";
import "react-quill/dist/quill.snow.css";
const customImgForPaste = (node, delta) => {
console.log("The node here : ", node, " , Delta : ", delta);
return delta.compose(new Delta().retain(delta.length(), {}));
};
const modules = {
toolbar: [
[{ header: "1" }, { header: "2" }, { font: [] }],
[{ size: [] }],
["bold", "italic", "underline", "strike", "blockquote"],
[
{ list: "ordered" },
{ list: "bullet" },
{ indent: "-1" },
{ indent: "+1" }
],
["link", "image", "video"],
["clean"]
],
clipboard: {
matchers: [
["img", customImgForPaste]
],
}
};
export default function App() {
const [text, setText] = React.useState("");
const onChange = (text) => {
setText(text);
};
return (
<ReactQuill
theme="snow"
placeholder="Type here"
value={text}
onChange={onChange}
modules={modules}
/>
);
}
But it says Error: Delta is not a constructor
.
What am I doing wrong?
How can I replace the image’s src with the API’s response’s URL?
Many thanks.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >webpack imported module is not a constructor - Stack Overflow
For me, this error was caused by importing through index files. I had multiple directories with their index.ts files that exported all the...
Read more >When I run this code I got an Typeerror: quickdb is not ... - Reddit
When I run this code I got an Typeerror: quickdb is not a constructor. var express = require('express'); var app = express(); var...
Read more >Clipboard Module - Quill Rich Text Editor
The Clipboard handles copy, cut and paste between Quill and external ... matcher functions are called with the DOM Node and Delta interpretation...
Read more >TypeScript style guide - TS.dev
See also export visibility below. Constructors copy link to the clipboard. Constructor calls must use parentheses, even when no arguments are passed: const ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@giovannipds try this:
This will give the
Delta
the exact same type as the regular quillDelta
Hi @AjayDhimanELS,
You can try the following way of loading
Delta
:BR