aboutsummaryrefslogtreecommitdiffstats
path: root/spring-front/src/components/Editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'spring-front/src/components/Editor.js')
-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}`);
+ }
}
}