From 3283618969ecc24433ce8e27aa0e932357a4da2d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 3 Jun 2022 22:54:22 +0430 Subject: need to do some cleanup otherwise done --- spring-front/src/components/Editor.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spring-front/src/components/Editor.js b/spring-front/src/components/Editor.js index 7b97a50..21d4bed 100644 --- a/spring-front/src/components/Editor.js +++ b/spring-front/src/components/Editor.js @@ -157,12 +157,10 @@ export default class Editor extends React.Component { this.setState({ value: json.body }); let result_element = document.getElementById("highlight-content"); result_element.textContent = this.state.value; - document.querySelectorAll("pre code").forEach((block) => { - hljs.highlightElement(block); - }); let element = document.getElementById("markdown-placeholder"); let htm = md.render(this.state.value); element.innerHTML = htm; + this.updateCodeSyntaxHighlighting(); }); } ); @@ -190,7 +188,28 @@ export default class Editor extends React.Component { ); if (!response.ok) { - throw new Error(`request failed with status code ${response.status}`); + let obj = { + id: this.docId, + name: `${this.docId}`, + lastModified: Math.floor(Date.now() / 1000), + body: this.state.value, + }; + let response = await fetch( + `https://localhost:9080/api/v1/doc/${this.docId}`, + { + method: "PUT", + body: JSON.stringify(obj), + mode: "cors", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + } + ); + + if (!response.ok) { + throw new Error(`request failed with status code ${response.status}`); + } } } -- cgit v1.2.3