Only use markdown when toggled

This commit is contained in:
Tracker-Friendly 2024-04-25 22:34:18 +01:00
parent ca8c012581
commit b739bec229
1 changed files with 11 additions and 4 deletions

View File

@ -32,6 +32,7 @@ function truncateString(str, num) {
let secretkey = localStorage.getItem("DONOTSHARE-secretkey") let secretkey = localStorage.getItem("DONOTSHARE-secretkey")
let password = localStorage.getItem("DONOTSHARE-password") let password = localStorage.getItem("DONOTSHARE-password")
let currentFontSize = 16 let currentFontSize = 16
let markdowntoggle = false
let usernameBox = document.getElementById("usernameBox") let usernameBox = document.getElementById("usernameBox")
let optionsCoverDiv = document.getElementById("optionsCoverDiv") let optionsCoverDiv = document.getElementById("optionsCoverDiv")
@ -185,8 +186,10 @@ function updateFont() {
currentFontSize = localStorage.getItem("SETTING-fontsize") currentFontSize = localStorage.getItem("SETTING-fontsize")
noteBox.style.fontSize = currentFontSize + "px" noteBox.style.fontSize = currentFontSize + "px"
textSizeBox.innerText = currentFontSize + "px" textSizeBox.innerText = currentFontSize + "px"
if markdowntoggle {
var targethtml = "<!DOCTYPE html><html><style>html { height: 100% } body { font-family: 'Inter', sans-serif; height: 100%; color: " + getComputedStyle(document.documentElement).getPropertyValue('--text-color') + "; font-size: " + currentFontSize + "px; }</style>" + marked.parse(noteBox.value) + "</html>"; var targethtml = "<!DOCTYPE html><html><style>html { height: 100% } body { font-family: 'Inter', sans-serif; height: 100%; color: " + getComputedStyle(document.documentElement).getPropertyValue('--text-color') + "; font-size: " + currentFontSize + "px; }</style>" + marked.parse(noteBox.value) + "</html>";
markdown.srcdoc = targethtml; markdown.srcdoc = targethtml;
}
} }
async function waitforedit() { async function waitforedit() {
@ -399,8 +402,10 @@ function updateWordCount() {
} }
function renderMarkDown() { function renderMarkDown() {
if markdowntoggle {
var targethtml = "<!DOCTYPE html><html><style>html { height: 100% } body { font-family: 'Inter', sans-serif; height: 100%; color: " + getComputedStyle(document.documentElement).getPropertyValue('--text-color') + "; font-size: " + currentFontSize + "px; }</style>" + marked.parse(noteBox.value) + "</html>"; var targethtml = "<!DOCTYPE html><html><style>html { height: 100% } body { font-family: 'Inter', sans-serif; height: 100%; color: " + getComputedStyle(document.documentElement).getPropertyValue('--text-color') + "; font-size: " + currentFontSize + "px; }</style>" + marked.parse(noteBox.value) + "</html>";
markdown.srcdoc = targethtml markdown.srcdoc = targethtml
}
} }
function selectNote(nameithink) { function selectNote(nameithink) {
@ -641,8 +646,10 @@ function firstNewVersion() {
function toggleMarkdown() { function toggleMarkdown() {
if (markdown.style.display === 'none') { if (markdown.style.display === 'none') {
markdown.style.display = 'inherit'; markdown.style.display = 'inherit';
markdowntoggle = true
} else { } else {
markdown.style.display = 'none'; markdown.style.display = 'none';
markdowntoggle = false
} }
} }