diff --git a/src/ts/admin/EditBlogPost.ts b/src/ts/admin/EditBlogPost.ts index 4156d4e..951d043 100644 --- a/src/ts/admin/EditBlogPost.ts +++ b/src/ts/admin/EditBlogPost.ts @@ -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); } diff --git a/src/ts/admin/MarkdownEditor/Prism.d.ts b/src/ts/admin/MarkdownEditor/Prism.d.ts index b3e9cc8..3775222 100644 --- a/src/ts/admin/MarkdownEditor/Prism.d.ts +++ b/src/ts/admin/MarkdownEditor/Prism.d.ts @@ -10,4 +10,4 @@ declare interface Prism { highlightAllUnder(element: HTMLElement): void; } -declare const Prism: Prism; \ No newline at end of file +declare const Prism: Prism; diff --git a/src/ts/admin/MarkdownEditor/UI.ts b/src/ts/admin/MarkdownEditor/UI.ts index 06a35e4..16cf188 100644 --- a/src/ts/admin/MarkdownEditor/UI.ts +++ b/src/ts/admin/MarkdownEditor/UI.ts @@ -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.