Skip to content

Commit 85102ad

Browse files
authored
Merge pull request #157 from rtCamp/fix/remove-quill
Fix: XSS vulnerability introduced from quill by removing TextEditor.
2 parents ba55f48 + 7bebc32 commit 85102ad

File tree

6 files changed

+7
-218
lines changed

6 files changed

+7
-218
lines changed

GETTING-STARTED.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ This library is built on top of several excellent open-source projects:
8585
- **[TailwindCSS](https://github.com/tailwindlabs/tailwindcss)**: Utility-first CSS framework for building design system-based UIs.
8686
- **[Headless UI](https://github.com/tailwindlabs/headlessui)**: Unstyled and accessible UI components.
8787
- **[Radix UI](https://github.com/radix-ui/themes)**: Low-level, unstyled, and accessible UI primitives.
88-
- **[React Quill](https://github.com/zenoamaro/react-quill)**: Rich text editor component for React.
8988
- **[dayjs](https://github.com/iamkun/dayjs)**: Lightweight JavaScript library for working with dates.
9089

9190
## Inspiration & Credits

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ This library is built on top of several excellent open-source projects:
9191
- **[TailwindCSS](https://github.com/tailwindlabs/tailwindcss)**: Utility-first CSS framework for building design system-based UIs.
9292
- **[Headless UI](https://github.com/tailwindlabs/headlessui)**: Unstyled and accessible UI components.
9393
- **[Radix UI](https://github.com/radix-ui/themes)**: Low-level, unstyled, and accessible UI primitives.
94-
- **[React Quill](https://github.com/zenoamaro/react-quill)**: Rich text editor component for React.
9594
- **[dayjs](https://github.com/iamkun/dayjs)**: Lightweight JavaScript library for working with dates.
9695

9796
## Inspiration & Credits

packages/frappe-ui-react/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ This library is built on top of several excellent open-source projects:
8585
- **[TailwindCSS](https://github.com/tailwindlabs/tailwindcss)**: Utility-first CSS framework for building design system-based UIs.
8686
- **[Headless UI](https://github.com/tailwindlabs/headlessui)**: Unstyled and accessible UI components.
8787
- **[Radix UI](https://github.com/radix-ui/themes)**: Low-level, unstyled, and accessible UI primitives.
88-
- **[React Quill](https://github.com/zenoamaro/react-quill)**: Rich text editor component for React.
8988
- **[dayjs](https://github.com/iamkun/dayjs)**: Lightweight JavaScript library for working with dates.
9089

9190
## Inspiration & Credits
Lines changed: 7 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
1-
/**
2-
* External dependencies.
3-
*/
4-
import { useEffect, useState } from "react";
5-
import ReactQuill, {
6-
Quill,
7-
type DeltaStatic,
8-
type EmitterSource,
9-
} from "react-quill-new";
10-
import "react-quill-new/dist/quill.snow.css";
11-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
12-
// @ts-ignore
13-
import ImageResize from "quill-resize-module/dist/resize.js";
14-
import "quill-resize-module/dist/resize.css";
15-
import "quill-paste-smart";
16-
17-
/**
18-
* Internal dependencies.
19-
*/
20-
import { preProcessLink } from "./utils";
21-
export interface TextEditorProps extends ReactQuill.ReactQuillProps {
1+
export interface TextEditorProps {
222
allowImageUpload?: boolean;
233
allowVideoUpload?: boolean;
244
className?: string;
@@ -28,96 +8,11 @@ export interface TextEditorProps extends ReactQuill.ReactQuillProps {
288
placeholder?: string;
299
}
3010

31-
Quill.register("modules/imageResize", ImageResize);
32-
33-
const TextEditor = ({
34-
allowImageUpload = false,
35-
allowVideoUpload = false,
36-
className,
37-
onChange,
38-
hideToolbar = false,
39-
...props
40-
}: TextEditorProps) => {
41-
const [editorValue, setEditorValue] = useState(props.value || "");
42-
43-
useEffect(() => {
44-
if (props?.value) {
45-
setEditorValue(props.value);
46-
}
47-
}, [props?.value]);
48-
49-
const toolbarOptions = [
50-
["bold", "italic"],
51-
[{ color: [] }],
52-
[
53-
{ list: "ordered" },
54-
{ list: "bullet" },
55-
{ indent: "-1" },
56-
{ indent: "+1" },
57-
],
58-
[{ align: [] }],
59-
["link"],
60-
];
61-
62-
if (allowImageUpload) {
63-
toolbarOptions.push(["image"]);
64-
}
65-
66-
if (allowVideoUpload) {
67-
toolbarOptions.push(["video"]);
68-
}
69-
70-
const modules = {
71-
toolbar: hideToolbar ? false : toolbarOptions,
72-
};
73-
74-
if (allowImageUpload) {
75-
// @ts-expect-error expected
76-
modules.imageResize = {
77-
modules: ["Resize", "DisplaySize", "Toolbar"],
78-
};
79-
}
80-
81-
const formatHtml = (html: string) => {
82-
return preProcessLink(html);
83-
};
84-
85-
const handleChange = (
86-
value: string,
87-
_: DeltaStatic,
88-
__: EmitterSource,
89-
editor: ReactQuill.UnprivilegedEditor
90-
) => {
91-
const formattedValue = formatHtml(value);
92-
setEditorValue(formattedValue);
93-
if (editor.getText()?.trim()) {
94-
onChange(formattedValue);
95-
} else {
96-
onChange("");
97-
}
98-
};
99-
100-
return (
101-
<>
102-
<ReactQuill
103-
{...props}
104-
style={{ resize: "vertical", overflow: "auto" }}
105-
className={`
106-
border rounded-md border-input [&>div:first-child]:border-t-0 [&>div:first-child]:border-r-0 [&>div:first-child]:border-l-0 [&>div:first-child]:border-input [&>div:first-child]:border-bottom [&>div:last-child]:border-none text-foreground bg-background whitespace-normal
107-
${
108-
hideToolbar &&
109-
"border-none !resize-none [&_.ql-editor]:min-h-0 [&_.ql-editor]:p-2"
110-
}
111-
${!hideToolbar && "break-all"}
112-
${className}
113-
`}
114-
theme="snow"
115-
modules={modules}
116-
onChange={handleChange}
117-
value={editorValue}
118-
/>
119-
</>
120-
);
121-
};
11+
/* eslint-disable @typescript-eslint/no-unused-vars */
12+
const TextEditor = (_props: TextEditorProps) => {
13+
return (
14+
<div></div>
15+
);
16+
}
12217

12318
export default TextEditor;

packages/frappe-ui-react/src/components/textEditor/textEditor.stories.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

packages/frappe-ui-react/src/components/textEditor/utils.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)