From 410ef6c2ca87e0cd3a8d3c27b2cef7bb1ade0ba0 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 31 Mar 2022 17:53:18 +0430 Subject: wip --- spring-front/src/App.js | 20 +++++--- spring-front/src/components/Left.js | 91 +++++++++++------------------------- spring-front/src/components/Right.js | 19 +++++--- spring-front/src/index.css | 2 +- 4 files changed, 53 insertions(+), 79 deletions(-) (limited to 'spring-front') diff --git a/spring-front/src/App.js b/spring-front/src/App.js index 2393152..492930e 100644 --- a/spring-front/src/App.js +++ b/spring-front/src/App.js @@ -2,11 +2,17 @@ import React from "react"; import Left from "./components/Left.js"; import Right from "./components/Right.js"; -export default function App() { - return ( -
- - -
- ); +export default class App extends React.Component { + constructor(props) { + super(props); + } + + render() { + return ( +
+ + +
+ ); + } } diff --git a/spring-front/src/components/Left.js b/spring-front/src/components/Left.js index af4def7..dc1bbd5 100644 --- a/spring-front/src/components/Left.js +++ b/spring-front/src/components/Left.js @@ -7,29 +7,18 @@ import "../index.css"; hljs.registerLanguage("markdown", markdown); -class Code extends React.Component { +export default class Editor extends React.Component { constructor(props) { super(props); + this.handleInput = this.handleInput.bind(this); + this.handleScroll = this.handleScroll.bind(this); + this.handleKeyDown = this.handleKeyDown.bind(this); this.updateCodeSyntaxHighlighting = this.updateCodeSyntaxHighlighting.bind(this); this.handleChange = this.handleChange.bind(this); this.state = { value: "" }; } - handleChange(event) { - this.setState({ value: event.target.value }); - this.updateCodeSyntaxHighlighting(); - console.log(this.state.value); - } - - componentDidMount() { - this.updateCodeSyntaxHighlighting(); - } - - componentDidUpdate() { - this.updateCodeSyntaxHighlighting(); - } - updateCodeSyntaxHighlighting() { document.querySelectorAll("pre code").forEach((block) => { console.log("block:", block); @@ -38,30 +27,6 @@ class Code extends React.Component { }); } - render() { - return ( - - ); - } -} - -class Editor extends React.Component { - constructor(props) { - super(props); - this.handleInput = this.handleInput.bind(this); - this.handleScroll = this.handleScroll.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); - this.handleChange = this.handleChange.bind(this); - this.state = { value: "" }; - } - handleChange(event) { this.setState({ value: event.target.value }); } @@ -69,12 +34,8 @@ class Editor extends React.Component { handleInput(event) { let text = this.state.value; let result_element = document.getElementById("highlight-content"); - // if (text[text.length - 1] == "\n") { - // text += " "; - // } result_element.textContent = text; - // .replace(new RegExp("&", "g"), "&") - // .replace(new RegExp("<", "g"), "<"); + this.updateCodeSyntaxHighlighting(); let result_element_2 = document.querySelector("#highlight"); result_element_2.scrollTop = event.currentTarget.scrollTop; result_element_2.scrollLeft = event.currentTarget.scrollLeft; @@ -103,27 +64,27 @@ class Editor extends React.Component { render() { return ( - +
+ + +
); } } - -export default function Left() { - return ( -
- - -
- ); -} diff --git a/spring-front/src/components/Right.js b/spring-front/src/components/Right.js index 94227f7..4bfe073 100644 --- a/spring-front/src/components/Right.js +++ b/spring-front/src/components/Right.js @@ -1,10 +1,17 @@ import React from "react"; import "../index.css"; -export default function Right() { - return ( -
-

Parsed Markdown goes here!!!

-
- ); +export default class Right extends React.Component { + constructor(props) { + super(props); + this.state = { value: "" }; + } + + render() { + return ( +
+

Parsed Markdown goes here!!!

+
+ ); + } } diff --git a/spring-front/src/index.css b/spring-front/src/index.css index 1577812..c35738f 100644 --- a/spring-front/src/index.css +++ b/spring-front/src/index.css @@ -9,6 +9,7 @@ pre,textarea,code { overflow-wrap: break-word; caret-color: green; white-space: pre-wrap; + tab-size: 2; } .editor { @@ -44,7 +45,6 @@ pre,textarea,code { font-size: 13pt; font-family: monospace; line-height: 15pt; - tab-size: 2; } #editor, #highlight { -- cgit v1.2.3