Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.61",
"quill": "^1.3.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.18.0",
Expand Down Expand Up @@ -42,6 +43,7 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@types/quill": "^2.0.14",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"eslint": "^8.54.0"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/CoursePage/CoursePage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-ignore
import React, { useEffect, useState } from 'react';
import CourseDetails from "./Components/CourseDetails";
import { getCourseDetails } from '../../api/courseService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {CSSProperties, useEffect, useState} from 'react';
import CourseInstance from "./Components/CourseInstance";
import { getCoursesList } from '../../api/coursesListService';


// TypeScript interfaces for type checking
interface Course {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
import { CSSProperties } from 'react';
import { useMyContext } from '../../../MyContext';


const cellStyle: CSSProperties = {
border: '1px solid black',
padding: '10px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import React, {CSSProperties, useEffect, useState} from 'react';

import TemplateInstance from "./Components/TemplateInstance";
import { getCourseTemplates } from '../../api/templateListService';
//import RichTextEditor from "../../pages/RichTextEditor";

// Example using RichTextEditor:
/*const YourPageComponent: React.FC = () => {
const handleFileUpload = (fileContent: string) => {
// Do something with the file content, e.g., save it or display it
console.log('File content:', fileContent);
};

return (
<div>
<h1>Your Page</h1>
<RichTextEditor onFileUpload={handleFileUpload} />
</div>
);
};*/
Comment on lines +5 to +20
Copy link
Copy Markdown
Contributor

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


const tableStyle: CSSProperties = {
width: '100%', // Makes the table full-width
Expand Down
47 changes: 47 additions & 0 deletions frontend/src/pages/RichTextEditor.tsx
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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;
Loading