-
Notifications
You must be signed in to change notification settings - Fork 1
Rich text editor2 #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Rich text editor2 #162
Changes from all commits
58e64d5
46f6853
157853e
2116ec9
0e0acf2
eacd3d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import React, { useEffect, useRef } from 'react'; | ||
| import Quill from 'quill'; | ||
| import 'quill/dist/quill.snow.css'; | ||
|
|
||
| interface RichTextEditorProps { | ||
| onFileUpload: (fileContent: string) => void; | ||
| } | ||
|
|
||
| const RichTextEditor: React.FC<RichTextEditorProps> = ({ onFileUpload }) => { | ||
| const quillRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| const quill = new Quill(quillRef.current as HTMLElement, { | ||
| theme: 'snow', | ||
| placeholder: 'Write something...', | ||
| }); | ||
|
|
||
| // Optional: Add event listeners or customize Quill further if needed | ||
|
|
||
| return () => { | ||
| quill.off('text-change', () => {}); | ||
| quill.off('selection-change', () => {}); | ||
| }; | ||
|
Comment on lines
+20
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why u decided to add dummy subs? |
||
| }, []); | ||
|
|
||
| const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| const file = event.target.files?.[0]; | ||
|
|
||
| if (file) { | ||
| const reader = new FileReader(); | ||
| reader.onload = (e) => { | ||
| const fileContent = e.target?.result as string; | ||
| onFileUpload(fileContent); | ||
| }; | ||
| reader.readAsText(file); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which markdown langs are supported? |
||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <div ref={quillRef} /> | ||
| <input type="file" onChange={handleFileChange} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default RichTextEditor; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to keep it here. We use VCS to avoid keeping unused code at the codebase