fix: update preview post-save
This commit is contained in:
parent
e800504651
commit
5ab6745a24
@ -25,6 +25,8 @@ import SaveButtonMode from "./MarkdownEditor/SaveButtonMode";
|
||||
await Interop.invoke("Save", post.id, UI.markdownInput.value);
|
||||
post = await API.getBlogPost(post.id);
|
||||
UI.setSaveButtonMode(SaveButtonMode.SAVED);
|
||||
UI.setPreviewContent(post.content);
|
||||
UI.redraw();
|
||||
|
||||
setTimeout(() => UI.setSaveButtonMode(SaveButtonMode.NORMAL), 2000);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import SharedUI from "../../app/UI";
|
||||
import SaveButtonMode from "./SaveButtonMode";
|
||||
|
||||
/**
|
||||
@ -12,6 +13,7 @@ class UI {
|
||||
private static _highlighting: HTMLElement;
|
||||
private static _content: HTMLTextAreaElement;
|
||||
private static _saveButton: HTMLButtonElement;
|
||||
private static _preview: HTMLElement;
|
||||
|
||||
private static _saveCallbacks: Function[] = [];
|
||||
|
||||
@ -38,6 +40,7 @@ class UI {
|
||||
* Initializes the editor's user interface.
|
||||
*/
|
||||
public static init() {
|
||||
UI._preview = document.getElementById("article-preview");
|
||||
UI._saveButton = document.getElementById("save-button") as HTMLButtonElement;
|
||||
UI._content = document.getElementById("content") as HTMLTextAreaElement;
|
||||
UI._highlightingContent = document.getElementById("highlighting-content");
|
||||
@ -76,6 +79,15 @@ class UI {
|
||||
UI.syncEditorScroll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTML content of the preview section.
|
||||
* @param html The HTML content.
|
||||
*/
|
||||
public static setPreviewContent(html: string): void {
|
||||
UI._preview.innerHTML = html;
|
||||
SharedUI.updateUI(UI._preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display mode of the save button.
|
||||
* @param mode The display mode.
|
||||
|
Loading…
Reference in New Issue
Block a user