-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (32 loc) · 972 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// script.js
// Initialize EasyMDE
const easyMDE = new EasyMDE({
element: document.getElementById('markdown-editor'),
spellChecker: false,
autosave: {
enabled: true,
uniqueId: "markdown-editor",
delay: 1000,
},
toolbar: [
"bold", "italic", "heading", "|",
"quote", "unordered-list", "ordered-list", "|",
"link", "image", "code", "|",
"preview", "side-by-side", "fullscreen", "|",
"guide"
],
status: false, // Disable the status bar
placeholder: "Type your markdown here...",
});
// Function to render Markdown to HTML
function renderPreview() {
const previewContent = document.getElementById('preview-content');
const markdownText = easyMDE.value();
previewContent.innerHTML = easyMDE.options.previewRender(markdownText);
}
// Initial render
renderPreview();
// Update preview on content change
easyMDE.codemirror.on("change", () => {
renderPreview();
});