diff options
author | terminaldweller <thabogre@gmail.com> | 2022-03-31 20:20:11 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-03-31 20:20:11 +0000 |
commit | 28c207b4afa0b7d3dedc63a9d1d8d929113c8160 (patch) | |
tree | b91cf95437cd8ff058a7f3192926578137158729 /spring-front/src/components | |
parent | wip (diff) | |
download | mdrtl-28c207b4afa0b7d3dedc63a9d1d8d929113c8160.tar.gz mdrtl-28c207b4afa0b7d3dedc63a9d1d8d929113c8160.zip |
wip
Diffstat (limited to 'spring-front/src/components')
-rw-r--r-- | spring-front/src/components/Editor.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/spring-front/src/components/Editor.js b/spring-front/src/components/Editor.js index 81ee58e..701443f 100644 --- a/spring-front/src/components/Editor.js +++ b/spring-front/src/components/Editor.js @@ -44,13 +44,11 @@ export default class Editor extends React.Component { } // TODO-use web worker instead - parseMarkdown() { + parseMarkdown(event) { let element = document.getElementById("markdown-placeholder"); let md = new mit(); - let htm = md.render(this.state.value); + let htm = md.render(event.target.value); element.innerHTML = htm; - console.log(htm); - console.log(md.render("# markdown-it rulezz!")); } handleChange(event) { @@ -58,14 +56,14 @@ export default class Editor extends React.Component { } handleInput(event) { - // let text = this.state.value; let result_element = document.getElementById("highlight-content"); - result_element.textContent = this.state.value; + result_element.textContent = event.target.value; this.updateCodeSyntaxHighlighting(); - this.parseMarkdown(); + this.parseMarkdown(event); let result_element_2 = document.querySelector("#highlight"); result_element_2.scrollTop = event.currentTarget.scrollTop; result_element_2.scrollLeft = event.currentTarget.scrollLeft; + this.setState({ value: event.target.value }); } handleScroll(event) { @@ -85,7 +83,7 @@ export default class Editor extends React.Component { element.value = before_tab + "\t" + after_tab; element.selectionStart = cursor_pos; element.selectionEnd = cursor_pos; - this.handleInput(element.value, element); + this.handleInput(event); } } |