From 6b0bd94978d1210c6148978990fd4ed18a9f1156 Mon Sep 17 00:00:00 2001 From: Gui D'Haene Date: Sun, 17 Nov 2024 22:41:51 +0100 Subject: [PATCH 1/6] disable spell check on input --- lore-generator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lore-generator/index.html b/lore-generator/index.html index 99ad0ec..77fb2bc 100644 --- a/lore-generator/index.html +++ b/lore-generator/index.html @@ -44,7 +44,7 @@

Guide

Lore Input

- +
From a4822de531ef2a7f85b81b2bbb00529858cd577e Mon Sep 17 00:00:00 2001 From: Gui D'Haene Date: Sun, 17 Nov 2024 22:41:58 +0100 Subject: [PATCH 2/6] add css --- lore-generator/style.css | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lore-generator/style.css b/lore-generator/style.css index e2f7199..88d6113 100644 --- a/lore-generator/style.css +++ b/lore-generator/style.css @@ -96,17 +96,13 @@ body.dark-mode { display: inline-block; } -#preview-content { - font-family: 'Minecraftia', monospace; +.preview-line { + font-family: "Minecraftia", monospace; white-space: pre; font-size: 14px; line-height: 1.2; } -.preview-line { - white-space: pre; -} - #generated-code { margin-top: 20px; } @@ -131,6 +127,10 @@ body.dark-mode { margin-top: 10px; } +.column { + flex-direction: column; +} + .button-group button { padding: 10px 20px; background-color: var(--box-background-color); @@ -285,6 +285,13 @@ body.dark-mode { pointer-events: none; } -body, .box, .theme-toggle, .button-group button, #lore-textarea, #code-container, .saved-lore, .saved-lore .button-group button { +body, +.box, +.theme-toggle, +.button-group button, +#lore-textarea, +#code-container, +.saved-lore, +.saved-lore .button-group button { transition: none; } From 25402574a0d52a00fa219bbae9dacd1c309b3694 Mon Sep 17 00:00:00 2001 From: Gui D'Haene Date: Sun, 17 Nov 2024 22:42:09 +0100 Subject: [PATCH 3/6] add preview function and delete button --- lore-generator/script.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/lore-generator/script.js b/lore-generator/script.js index 7dfdb4c..2eb7a96 100644 --- a/lore-generator/script.js +++ b/lore-generator/script.js @@ -228,12 +228,14 @@ document.addEventListener('DOMContentLoaded', function () { const loreDiv = document.createElement('div'); loreDiv.classList.add('saved-lore'); + // Add the Skript code const codePre = document.createElement('pre'); codePre.textContent = lore.code; loreDiv.appendChild(codePre); const buttonGroup = document.createElement('div'); buttonGroup.classList.add('button-group'); + buttonGroup.classList.add('column'); const restoreButton = document.createElement('button'); restoreButton.textContent = 'Restore'; @@ -249,8 +251,25 @@ document.addEventListener('DOMContentLoaded', function () { navigator.clipboard.writeText(lore.code).then(showCopyNotification); }); - buttonGroup.appendChild(restoreButton); + const deleteButton = document.createElement("button"); + deleteButton.textContent = "Delete"; + deleteButton.addEventListener("click", function () { + savedLores = savedLores.filter((l) => l.code !== lore.code); + saveLoresToLocalStorage(); + updateSavedLores(); + }); + + // Create a container for the preview and code + const container = document.createElement("div"); + container.classList.add("lore-container"); + loreDiv.appendChild(container); + + // Add the preview + createLorePreview(container, lore.text); + buttonGroup.appendChild(copyButton); + buttonGroup.appendChild(restoreButton); + buttonGroup.appendChild(deleteButton); loreDiv.appendChild(buttonGroup); savedLoresContainer.appendChild(loreDiv); }); @@ -268,5 +287,20 @@ document.addEventListener('DOMContentLoaded', function () { } } + function createLorePreview(parent, text) { + const previewContainer = document.createElement("div"); + previewContainer.classList.add("preview-tooltip"); + const preview = document.createElement("div"); + previewContainer.appendChild(preview); + const lines = text.split("\n"); + lines.forEach((line) => { + const lineElement = document.createElement("div"); + lineElement.classList.add("preview-line"); + lineElement.innerHTML = parseSkriptFormatting(line); + preview.appendChild(lineElement); + }); + parent.appendChild(previewContainer); + } + updateOutput(); }); From 4236a3008fd22be807142805d5b2aa6e1a405556 Mon Sep 17 00:00:00 2001 From: Gui <74725108+JonesJugHead@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:16:52 +0100 Subject: [PATCH 4/6] Remove comment & replace " by ' --- lore-generator/script.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lore-generator/script.js b/lore-generator/script.js index 2eb7a96..179b64f 100644 --- a/lore-generator/script.js +++ b/lore-generator/script.js @@ -156,8 +156,8 @@ document.addEventListener('DOMContentLoaded', function () { classes.push('underline'); if (formatting.strikethrough) classes.push('strikethrough'); - const classAttr = classes.length ? ` class="${classes.join(' ')}"` : ''; - return `${escapeHtml(content)}`; + const classAttr = classes.length ? ` class='${classes.join(' ')}'` : ''; + return `${escapeHtml(content)}`; } return result; @@ -184,7 +184,7 @@ document.addEventListener('DOMContentLoaded', function () { return ''; let code = 'set lore of {_item} to '; - const formattedLines = loreLines.map(line => `"${line.replace(/"/g, '""')}"`); + const formattedLines = loreLines.map(line => `'${line.replace(/'/g, '''')}'`); if (formattedLines.length === 1) { code += formattedLines[0]; } else if (formattedLines.length === 2) { @@ -228,7 +228,6 @@ document.addEventListener('DOMContentLoaded', function () { const loreDiv = document.createElement('div'); loreDiv.classList.add('saved-lore'); - // Add the Skript code const codePre = document.createElement('pre'); codePre.textContent = lore.code; loreDiv.appendChild(codePre); @@ -251,20 +250,18 @@ document.addEventListener('DOMContentLoaded', function () { navigator.clipboard.writeText(lore.code).then(showCopyNotification); }); - const deleteButton = document.createElement("button"); - deleteButton.textContent = "Delete"; - deleteButton.addEventListener("click", function () { + const deleteButton = document.createElement('button'); + deleteButton.textContent = 'Delete'; + deleteButton.addEventListener('click', function () { savedLores = savedLores.filter((l) => l.code !== lore.code); saveLoresToLocalStorage(); updateSavedLores(); }); - // Create a container for the preview and code - const container = document.createElement("div"); - container.classList.add("lore-container"); + const container = document.createElement('div'); + container.classList.add('lore-container'); loreDiv.appendChild(container); - // Add the preview createLorePreview(container, lore.text); buttonGroup.appendChild(copyButton); @@ -288,14 +285,14 @@ document.addEventListener('DOMContentLoaded', function () { } function createLorePreview(parent, text) { - const previewContainer = document.createElement("div"); - previewContainer.classList.add("preview-tooltip"); - const preview = document.createElement("div"); + const previewContainer = document.createElement('div'); + previewContainer.classList.add('preview-tooltip'); + const preview = document.createElement('div'); previewContainer.appendChild(preview); - const lines = text.split("\n"); + const lines = text.split('\n'); lines.forEach((line) => { - const lineElement = document.createElement("div"); - lineElement.classList.add("preview-line"); + const lineElement = document.createElement('div'); + lineElement.classList.add('preview-line'); lineElement.innerHTML = parseSkriptFormatting(line); preview.appendChild(lineElement); }); From 0027fff6262c8445cb7f968bb882a514da5cf4d6 Mon Sep 17 00:00:00 2001 From: Gui <74725108+JonesJugHead@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:18:30 +0100 Subject: [PATCH 5/6] Update script.js --- lore-generator/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lore-generator/script.js b/lore-generator/script.js index 179b64f..3d80f21 100644 --- a/lore-generator/script.js +++ b/lore-generator/script.js @@ -184,7 +184,7 @@ document.addEventListener('DOMContentLoaded', function () { return ''; let code = 'set lore of {_item} to '; - const formattedLines = loreLines.map(line => `'${line.replace(/'/g, '''')}'`); + const formattedLines = loreLines.map(line => `"${line.replace(/"/g, '""')}"`); if (formattedLines.length === 1) { code += formattedLines[0]; } else if (formattedLines.length === 2) { From ecfe56e429c8680aa426328132c1a28f8d11fc81 Mon Sep 17 00:00:00 2001 From: Gui D'Haene Date: Sun, 22 Dec 2024 19:04:23 +0100 Subject: [PATCH 6/6] Fix saved lore pre --- lore-generator/style.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lore-generator/style.css b/lore-generator/style.css index c3fb1cb..99fe315 100644 --- a/lore-generator/style.css +++ b/lore-generator/style.css @@ -204,6 +204,20 @@ body.dark-mode { background-color: var(--hover-background-color); } +.saved-lore pre { + background-color: var(--box-background-color); + color: var(--text-color); + padding: 5px; + border: 1px solid var(--box-border-color); + border-radius: 4px; + overflow-x: auto; + text-align: left; + min-height: calc(1.2em + 10px); + max-height: calc(1.2em * 3 + 10px); + box-sizing: border-box; + width: 90%; +} + .header-content { max-width: 800px; margin: 0 auto;