Skip to content
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

adding syntax highlighter #11

Merged
merged 1 commit into from
Jun 26, 2023
Merged
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
36 changes: 36 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@monaco-editor/react": "^4.5.1",
"autoprefixer": "10.4.14",
"codemirror": "^6.0.1",
"file-saver": "^2.0.5",
Expand Down
13 changes: 8 additions & 5 deletions src/app/codeedit/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { saveAs } from 'file-saver';
import Search from '../assets/search';
import { AiFillHtml5, } from 'react-icons/ai'
import { FaCss3, FaJs } from 'react-icons/fa'

import { Editor } from '@monaco-editor/react';
export default function Nav() {
const [htmlCode, setHtmlCode] = useState(`
<!DOCTYPE html>
Expand Down Expand Up @@ -111,7 +111,7 @@ export default function Nav() {
};
useEffect(() => {
document.querySelectorAll('textarea').forEach((textarea) => {
textarea.addEventListener('keydown', function(e) {
textarea.addEventListener('keydown', function (e) {
if (e.key === 'Tab') {
e.preventDefault();

Expand Down Expand Up @@ -161,17 +161,20 @@ export default function Nav() {
)}
{showIndexHtmlSection && (
<section className='w-full h-full'>
<textarea value={htmlCode} onChange={handleHtmlChange} className='bg-slate-500 w-full h-full'></textarea>
<Editor theme='vs-dark' defaultLanguage='html' width='100%' height='100%' defaultValue={`${htmlCode ? htmlCode : '<!-- add some html code here -->'} `} />
{/* <textarea value={htmlCode} onChange={handleHtmlChange} className='bg-slate-500 w-full h-full'></textarea> */}
</section>
)}
{showStyleCssSection && (
<section className='w-full h-full'>
<textarea value={cssCode} onChange={handleCssChange} className='bg-slate-500 w-full h-full'></textarea>
<Editor theme='vs-dark' defaultLanguage='css' width='100%' height='100%' defaultValue={`${cssCode ? cssCode : '/* add some CSS code here */'} `} />
{/* <textarea value={cssCode} onChange={handleCssChange} className='bg-slate-500 w-full h-full'></textarea> */}
</section>
)}
{showScriptJsSection && (
<section className='w-full h-full'>
<textarea value={jsCode} onChange={handleJsChange} className='bg-slate-500 w-full h-full'></textarea>
<Editor theme='vs-dark' defaultLanguage='javascript' width='100%' height='100%' defaultValue={`${jsCode ? jsCode : '// add some JvaScript code here '} `} />
{/* <textarea value={jsCode} onChange={handleJsChange} className='bg-slate-500 w-full h-full'></textarea> */}
</section>
)}
{!showViewSection && !showIndexHtmlSection && !showStyleCssSection && !showScriptJsSection && (
Expand Down