From ce05927abd81cc512bddb00372a7267e9210e9d9 Mon Sep 17 00:00:00 2001 From: Silabear <56885288+Silabear@users.noreply.github.com> Date: Fri, 26 Dec 2025 20:59:13 +0000 Subject: [PATCH 1/3] rename files + fix atlas bug + small tidy --- src/lib/components/modals/CustomSourceModal.svelte | 2 +- src/lib/components/modals/ExportModal.svelte | 2 +- src/lib/components/text/MiniEditor.svelte | 4 ++-- src/lib/text/nbt/{nbt_or_json.ts => export.ts} | 4 +++- src/lib/text/nbt/{nbt.ts => import.ts} | 0 src/lib/tiptap/extensions/index.ts | 2 +- src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts | 5 ++++- src/routes/+page.svelte | 4 ++-- src/tests/unit/snbt_importing.spec.ts | 2 +- src/tests/unit/translating_mc_json.spec.ts | 2 +- 10 files changed, 16 insertions(+), 11 deletions(-) rename src/lib/text/nbt/{nbt_or_json.ts => export.ts} (99%) rename src/lib/text/nbt/{nbt.ts => import.ts} (100%) diff --git a/src/lib/components/modals/CustomSourceModal.svelte b/src/lib/components/modals/CustomSourceModal.svelte index 855e1a6..b7efd73 100644 --- a/src/lib/components/modals/CustomSourceModal.svelte +++ b/src/lib/components/modals/CustomSourceModal.svelte @@ -402,7 +402,7 @@

Sprite

= 2) { current.object = "atlas"; - current.atlas = c.attrs?.atlas; + if(current.atlas) { + current.atlas = c.attrs?.atlas; + } current.sprite = c.attrs?.sprite; current.bold = undefined; diff --git a/src/lib/text/nbt/nbt.ts b/src/lib/text/nbt/import.ts similarity index 100% rename from src/lib/text/nbt/nbt.ts rename to src/lib/text/nbt/import.ts diff --git a/src/lib/tiptap/extensions/index.ts b/src/lib/tiptap/extensions/index.ts index 74d2e2c..e87cb8d 100644 --- a/src/lib/tiptap/extensions/index.ts +++ b/src/lib/tiptap/extensions/index.ts @@ -44,7 +44,7 @@ export interface SelectorAttributes { } export interface AtlasObjectAttributes { - atlas: string; + atlas?: string; sprite: string; } diff --git a/src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts b/src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts index b5c16ae..8a93148 100644 --- a/src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts +++ b/src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts @@ -30,7 +30,10 @@ export const AtlasObjectNode = Node.create({ }, renderHTML({ HTMLAttributes, node }) { - const { atlas, sprite } = node.attrs; + let { atlas, sprite } = node.attrs; + if (!atlas) { + atlas = "minecraft:blocks" + } return [ "span", diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d967355..e28195a 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,5 +1,5 @@ + + diff --git a/src/lib/components/text/TextStyleButtons.svelte b/src/lib/components/text/TextStyleButtons.svelte index 8662730..b7c2793 100644 --- a/src/lib/components/text/TextStyleButtons.svelte +++ b/src/lib/components/text/TextStyleButtons.svelte @@ -1,5 +1,5 @@ -
-{#if editor.isActive("shadowColor")} - + +{#if !editor.isActive("shadowColor") || isColorPickerOpen} + { + if (isColorPickerOpen) { + c.hex && editor.chain().focus().setShadowColor(c.hex).run(); + } + }} + swatches={Object.values(colorMap).map((c) => c.value)} + components={{ input: ShadowColorButton }} /> {:else} {/if} - - c.value)} - label="" /> -
\ No newline at end of file diff --git a/src/lib/text/nbt/optimiser.ts b/src/lib/text/nbt/optimiser.ts index 92337ed..f4e4529 100644 --- a/src/lib/text/nbt/optimiser.ts +++ b/src/lib/text/nbt/optimiser.ts @@ -232,12 +232,10 @@ function mergeTextComponents(output: StringyMCText[]) { // Find shared style/interactivity properties between consecutive objects if (typeof current === "object" && typeof next === "object") { const sharedProperties = getSharedStyleProps(current, next); - console.log("Shared Properties:", sharedProperties); if (Object.keys(sharedProperties).length > 0) { let group = [current]; collectAllFromIndex(i, group, output, sharedProperties); - console.log("Group Collected:", group); if (group.length < 1) { continue; From 027debc05c328cf92da607b615a0db751d39d8b5 Mon Sep 17 00:00:00 2001 From: Cobblestone Date: Sun, 28 Dec 2025 16:13:27 -0500 Subject: [PATCH 3/3] fix the e2e tests for now (they will be made better eventually) --- playwright.config.ts | 1 + .../components/text/ShadowColorButton.svelte | 18 +++++----- src/routes/+page.svelte | 1 + src/tests/e2e/basic.test.ts | 35 ++++++++++++------- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 4928370..b3339ed 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -5,5 +5,6 @@ export default defineConfig({ command: "npm run build && npm run preview", port: 4173, }, + fullyParallel: true, testDir: "src/tests/e2e", }); diff --git a/src/lib/components/text/ShadowColorButton.svelte b/src/lib/components/text/ShadowColorButton.svelte index 4022d7b..fede43f 100644 --- a/src/lib/components/text/ShadowColorButton.svelte +++ b/src/lib/components/text/ShadowColorButton.svelte @@ -26,13 +26,13 @@ }: Props = $props(); - + + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e28195a..d918636 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -559,6 +559,7 @@
diff --git a/src/tests/e2e/basic.test.ts b/src/tests/e2e/basic.test.ts index 0dd8365..90b1718 100644 --- a/src/tests/e2e/basic.test.ts +++ b/src/tests/e2e/basic.test.ts @@ -12,16 +12,14 @@ test("home page loads", async ({ page }) => { test("blank text updates with formatted output", async ({ page }) => { await page.getByLabel("Keybinds").waitFor(); - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); const output = page.locator("#outputbox").first(); await expect(output).toHaveText(`"lorem ipsum"`); }); test("the bold button should work", async ({ page }) => { - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); await textbox.selectText(); let button = page.getByRole("button", { name: "Bold " }); @@ -34,8 +32,7 @@ test("the bold button should work", async ({ page }) => { }); test("the italic button should work", async ({ page }) => { - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); await textbox.selectText(); let button = page.getByRole("button", { name: "Italic " }); @@ -48,8 +45,7 @@ test("the italic button should work", async ({ page }) => { }); test("the strikethrough button should work", async ({ page }) => { - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); await textbox.selectText(); let button = page.getByRole("button", { name: "Strikethrough " }); @@ -62,8 +58,7 @@ test("the strikethrough button should work", async ({ page }) => { }); test("the underline button should work", async ({ page }) => { - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); await textbox.selectText(); let button = page.getByRole("button", { name: "Underline " }); @@ -76,11 +71,27 @@ test("the underline button should work", async ({ page }) => { }); test("the obfuscation button should work", async ({ page }) => { - const textbox = page.getByRole("textbox").nth(1); - await textbox.click(); + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); await textbox.fill("lorem ipsum"); await textbox.selectText(); let button = page.getByRole("button", { name: "Obfuscated " }); await button.click(); expect(await textbox.locator("p>span.obfuscated").count()).toBeGreaterThan(0); }); + +test("the shadow color button should work", async ({ page }) => { + const textbox = page.locator("#wysiwyg-box>[role=textbox]").first(); + await textbox.fill("lorem ipsum"); + await textbox.selectText(); + let button = page.getByRole("button", { name: "Shadow Color" }); + await button.click(); + const colorInput = page.locator('input[aria-label="hex color"]'); + await colorInput.fill("#ff0000"); + await colorInput.press("Enter"); + expect( + await textbox.locator('p>span[style*="text-shadow"]').count(), + ).toBeGreaterThan(0); + await expect( + textbox.locator('p>span[style*="text-shadow"]').first(), + ).toHaveAttribute("style", "text-shadow: rgb(255, 0, 0) 2px 2px 0px;"); +});