From ce119c6328d8a8a65dad5473ff12bfcea726daa8 Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Wed, 21 Feb 2024 00:58:05 +0530 Subject: fix: fixed line numbers and text wrapping in editor --- client/src/components/Editor/Editor.jsx | 29 ++++------- client/src/components/Editor/Editor.module.css | 29 ++--------- .../components/prism-themes/prism-line-numbers.css | 60 ++++++++++++++++++++++ client/vite.config.js | 1 + 4 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 client/src/components/prism-themes/prism-line-numbers.css diff --git a/client/src/components/Editor/Editor.jsx b/client/src/components/Editor/Editor.jsx index 795ac49..dc7f901 100644 --- a/client/src/components/Editor/Editor.jsx +++ b/client/src/components/Editor/Editor.jsx @@ -1,9 +1,14 @@ -import React, { useState, useEffect, useRef, useMemo } from "react"; +import React, { useState, useEffect, useRef } from "react"; import { useLocation, useNavigate, useParams } from "react-router-dom"; import Prism from "prismjs"; import styles from "./Editor.module.css"; import "../prism-themes/prism-gruvbox-dark.css"; -import { CLIENT_BASE_URL, SERVER_BASE_URL, URL_REGEX } from "../../utils/constants"; +import "../prism-themes/prism-line-numbers.css"; +import { + CLIENT_BASE_URL, + SERVER_BASE_URL, + URL_REGEX, +} from "../../utils/constants"; import Header from "../Header/Header"; const Editor = () => { @@ -67,8 +72,7 @@ const Editor = () => { if (location.pathname === `/r/${id}`) { window.location.href = data.content; } - } - else { + } else { setLanguage(data.language); setText(data.content); } @@ -83,8 +87,6 @@ const Editor = () => { } }, [id]); - const lines = useMemo(() => text.split("\n"), [text]); - return ( <>
@@ -96,17 +98,6 @@ const Editor = () => { )}
-
- {lines.map((_, index) => ( -
- {index + 1} -
- ))} -