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);
|
await Interop.invoke("Save", post.id, UI.markdownInput.value);
|
||||||
post = await API.getBlogPost(post.id);
|
post = await API.getBlogPost(post.id);
|
||||||
UI.setSaveButtonMode(SaveButtonMode.SAVED);
|
UI.setSaveButtonMode(SaveButtonMode.SAVED);
|
||||||
|
UI.setPreviewContent(post.content);
|
||||||
|
UI.redraw();
|
||||||
|
|
||||||
setTimeout(() => UI.setSaveButtonMode(SaveButtonMode.NORMAL), 2000);
|
setTimeout(() => UI.setSaveButtonMode(SaveButtonMode.NORMAL), 2000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import SharedUI from "../../app/UI";
|
||||||
import SaveButtonMode from "./SaveButtonMode";
|
import SaveButtonMode from "./SaveButtonMode";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +13,7 @@ class UI {
|
||||||
private static _highlighting: HTMLElement;
|
private static _highlighting: HTMLElement;
|
||||||
private static _content: HTMLTextAreaElement;
|
private static _content: HTMLTextAreaElement;
|
||||||
private static _saveButton: HTMLButtonElement;
|
private static _saveButton: HTMLButtonElement;
|
||||||
|
private static _preview: HTMLElement;
|
||||||
|
|
||||||
private static _saveCallbacks: Function[] = [];
|
private static _saveCallbacks: Function[] = [];
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ class UI {
|
||||||
* Initializes the editor's user interface.
|
* Initializes the editor's user interface.
|
||||||
*/
|
*/
|
||||||
public static init() {
|
public static init() {
|
||||||
|
UI._preview = document.getElementById("article-preview");
|
||||||
UI._saveButton = document.getElementById("save-button") as HTMLButtonElement;
|
UI._saveButton = document.getElementById("save-button") as HTMLButtonElement;
|
||||||
UI._content = document.getElementById("content") as HTMLTextAreaElement;
|
UI._content = document.getElementById("content") as HTMLTextAreaElement;
|
||||||
UI._highlightingContent = document.getElementById("highlighting-content");
|
UI._highlightingContent = document.getElementById("highlighting-content");
|
||||||
|
@ -76,6 +79,15 @@ class UI {
|
||||||
UI.syncEditorScroll();
|
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.
|
* Sets the display mode of the save button.
|
||||||
* @param mode The display mode.
|
* @param mode The display mode.
|
||||||
|
|
Loading…
Reference in New Issue