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/components/Left.js | 91 +++++++++++------------------------- spring-front/src/components/Right.js | 19 +++++--- 2 files changed, 39 insertions(+), 71 deletions(-) (limited to 'spring-front/src/components') 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!!!

+
+ ); + } } -- cgit v1.2.3