aboutsummaryrefslogtreecommitdiffstats
path: root/spring-front
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-06-03 18:24:22 +0000
committerterminaldweller <thabogre@gmail.com>2022-06-03 18:24:22 +0000
commit3283618969ecc24433ce8e27aa0e932357a4da2d (patch)
tree49c0b3d7876a6dbf4f9ed5ac32ab3c3ca7b5150f /spring-front
parentload,delete and save are working now. we just need to add put. (diff)
downloadmdrtl-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.js27
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}`);
+ }
}
}