diff options
author | terminaldweller <thabogre@gmail.com> | 2022-06-03 18:24:22 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-06-03 18:24:22 +0000 |
commit | 3283618969ecc24433ce8e27aa0e932357a4da2d (patch) | |
tree | 49c0b3d7876a6dbf4f9ed5ac32ab3c3ca7b5150f /spring-front | |
parent | load,delete and save are working now. we just need to add put. (diff) | |
download | mdrtl-3283618969ecc24433ce8e27aa0e932357a4da2d.tar.gz mdrtl-3283618969ecc24433ce8e27aa0e932357a4da2d.zip |
need to do some cleanup otherwise done
Diffstat (limited to 'spring-front')
-rw-r--r-- | spring-front/src/components/Editor.js | 27 |
1 files 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}`); + } } } |