diff --git a/README.md b/README.md index bb0bc8c..33ea890 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is an online and open source Minecraft Text Component WYSIWYG editor, updat Check it out at: https://text.datapackhub.net/ -![image](https://github.com/user-attachments/assets/2c16718a-c8dd-49cc-9eb5-90167834e76e) +image :eyes: To prove it works, the generated text from the image above is below: diff --git a/package-lock.json b/package-lock.json index 04ca452..814dcad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@types/node": "^26.1.2", "@types/sortablejs": "^1.15.9", "@vitest/coverage-v8": "4.1.10", + "@vitest/ui": "^4.1.10", "file-type": "^22.0.1", "oxlint": "^1.77.0", "prettier": "^3.9.6", @@ -1936,6 +1937,28 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/@vitest/ui": { + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-4.1.10.tgz", + "integrity": "sha512-EOUqfXHTXtpSHsyLHH40ts3Ue+hRhSGwzwzMlK0dTEOLSDYyOXLyr5JDGmHQWhN2DYI30gw6dVx3cdgM9FZl+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.1.10", + "fflate": "^0.8.2", + "flatted": "^3.4.2", + "pathe": "^2.0.3", + "sirv": "^3.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": "4.1.10" + } + }, "node_modules/@vitest/utils": { "version": "4.1.10", "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.10.tgz", @@ -2201,6 +2224,13 @@ } } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "dev": true, + "license": "MIT" + }, "node_modules/file-type": { "version": "22.0.1", "resolved": "https://registry.npmjs.org/file-type/-/file-type-22.0.1.tgz", @@ -2220,6 +2250,13 @@ "url": "https://github.com/sindresorhus/file-type?sponsor=1" } }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", diff --git a/package.json b/package.json index d57dfa8..5057008 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@types/node": "^26.1.2", "@types/sortablejs": "^1.15.9", "@vitest/coverage-v8": "4.1.10", + "@vitest/ui": "^4.1.10", "file-type": "^22.0.1", "oxlint": "^1.77.0", "prettier": "^3.9.6", diff --git a/src/app.css b/src/app.css index 187fd53..8a5ff9e 100644 --- a/src/app.css +++ b/src/app.css @@ -54,6 +54,13 @@ strong { @apply text-xl; } +.tiptap-minirenderer { + @apply h-full w-full p-2; + @apply focus:outline-none; + font-family: Minecraft; + @apply text-xl; +} + .tiptap p.is-editor-empty:first-child::before { color: #7f7f7f; content: attr(data-placeholder); @@ -63,20 +70,25 @@ strong { } .clickEvent { - background-color: #3c3c40aa; - border-bottom: solid #ff5555 2px; - padding-top: 2px; - padding-bottom: 2px; + background-color: #45454e80; + border: solid #45454e 1px; + border-bottom: solid #a868e7 2px; z-index: 10; --custom-source-align: top; + padding-bottom: 1px; +} + +.clickEvent:has(.hoverEvent) { + padding-bottom: 3px; } .hoverEvent { - background-color: #3c3c40aa; - border-bottom: solid #ffff55 2px; - padding-top: 4px; + background-color: #45454e80; + border: solid #45454e 1px; + border-bottom: solid #e57e2b 2px; z-index: 10; --custom-source-align: top; + padding-bottom: 1px; } .obfuscated { @@ -87,6 +99,11 @@ strong { filter: blur(3px); } +.export-button { + @apply items-center p-1 px-1.5 bg-zinc-900 text-zinc-200 hover:text-white rounded-md font-lexend text-xs h-6; + @apply w-0 invisible sm:w-fit sm:visible; /* hide on mobile */ +} + /* Useful */ .nomob { @@ -103,6 +120,14 @@ strong { @apply rounded-md p-1 text-lg font-medium hover:bg-white/3; } +.input-basic { + @apply rounded-md bg-zinc-900 p-2; +} + +.link { + @apply font-bold underline; +} + .tippy-box[data-theme~="dph"] { background-color: var(--color-zinc-700); font-family: "Lexend", sans-serif; diff --git a/src/lib/components/TopUI.svelte b/src/lib/components/TopUI.svelte index 0b11d36..e8f8083 100644 --- a/src/lib/components/TopUI.svelte +++ b/src/lib/components/TopUI.svelte @@ -8,7 +8,7 @@ import IconUpload from "~icons/tabler/upload"; import IconSettings from "~icons/tabler/settings"; - const { editor }: { editor: Editor | undefined } = $props(); + let { editor, welcomeScreenVisible = $bindable() }: { editor: Editor | undefined, welcomeScreenVisible: boolean } = $props(); let snapshots = $state([]); let importText: string = $state(""); @@ -28,18 +28,16 @@ function importToEditor() { const jsonContent = snbtToDocument(convertToTextOrEmpty(importText)); - console.log("importing to editor", jsonContent); editor?.commands.setContent(jsonContent, { emitUpdate: true }); importDialog?.close(); - console.log("imported to editor"); }
-
+
+ +
+
+

Welcome!

+

With this tool, you can easily generate text components for Minecraft datapacks, tellraw commands, and more. Here's what makes us unique:

+ +
+ +
+ +
+ Import + Import text components from any version into the editor. +
+
+ +
+ +
+ Gradient + Add gradients to text, while keeping styles and interactivity. +
+
+ +
+ +
+ Lore output + Get an output correctly formatted for item lore components. +
+
+ +
+ +
+ Open source + All the code is public, and we maintain and update it regularly. +
+
+
+ +

Feedback? We are a small team and would love to hear any feedback you have! Let us know what you think on our Discord server.

+ +

Bugs? Report them on our Discord server, or create an issue on Github.

+ +

This site is maintained by Datapack Hub, and is not endorsed by Mojang Studios.

+ + +
+ + + +{/if} \ No newline at end of file diff --git a/src/lib/components/modals/ClickEventModal.svelte b/src/lib/components/modals/ClickEventModal.svelte index ca35c1a..c4ebbfe 100644 --- a/src/lib/components/modals/ClickEventModal.svelte +++ b/src/lib/components/modals/ClickEventModal.svelte @@ -11,7 +11,7 @@

Event Type

- @@ -32,7 +32,7 @@

Command:

Note: the player must have permission to run the command!

@@ -40,7 +40,7 @@

Command:

Note: the player must have permission to run the command!

@@ -48,21 +48,21 @@

Text to copy:

{:else if clickEventType == "change_page"}

Page to go to:

{:else if clickEventType == "open_dialog"}

Dialog ID:

{/if} diff --git a/src/lib/components/modals/CustomSourceModal.svelte b/src/lib/components/modals/CustomSourceModal.svelte index 63b9aa8..861538d 100644 --- a/src/lib/components/modals/CustomSourceModal.svelte +++ b/src/lib/components/modals/CustomSourceModal.svelte @@ -122,7 +122,7 @@ {/if} {:else} - @@ -136,14 +136,14 @@

Translate Key

Fallback

@@ -198,13 +198,13 @@

Objective

Player, Fake Player, or Entity

@@ -225,7 +225,7 @@ {:else if customType === "nbt"}

NBT Source type

- @@ -234,14 +234,14 @@

Storage ID

NBT path

@@ -270,14 +270,14 @@

Entity

NBT path

@@ -303,17 +303,17 @@ Add NBT Value {:else if customValues.nbt.sourceType === "block"} -

Entity

+

Block

NBT path

@@ -343,7 +343,7 @@

Keybind

+ + {/key} + +
diff --git a/src/lib/components/modals/FontPickerModal.svelte b/src/lib/components/modals/FontPickerModal.svelte index da8a131..5c43c0f 100644 --- a/src/lib/components/modals/FontPickerModal.svelte +++ b/src/lib/components/modals/FontPickerModal.svelte @@ -99,7 +99,7 @@

Or, if you want to use a custom font without importing it, enter the ID:

diff --git a/src/lib/components/modals/FontUploadModal.svelte b/src/lib/components/modals/FontUploadModal.svelte index b710ec8..b2958bc 100644 --- a/src/lib/components/modals/FontUploadModal.svelte +++ b/src/lib/components/modals/FontUploadModal.svelte @@ -96,7 +96,7 @@

Enter font identifier (namespace:font_name)

- + {/if} diff --git a/src/lib/components/modals/InsertImageModal.svelte b/src/lib/components/modals/InsertImageModal.svelte new file mode 100644 index 0000000..9ca0a7c --- /dev/null +++ b/src/lib/components/modals/InsertImageModal.svelte @@ -0,0 +1,165 @@ + + + e.preventDefault()} /> + + +
+

A few things to note:

+
    +
  • Total transparency will become empty spaces
  • +
  • Non-zero alpha pixels will be converted to full alpha.
  • +
  • Large or complex images will produce a very long output
  • +
  • This tool makes no attempt to resize images
  • +
+ {#if !files} + + {:else} +

Selected file: {files[0].name}

+ {#if sizeWarning} +
+

This image may be too large to display properly, and may also cause performance issues to process, you have been warned!

+
+ {/if} +
+ + +
+ {/if} +
+
diff --git a/src/lib/components/modals/KeybindModal.svelte b/src/lib/components/modals/KeybindModal.svelte index 0569e23..ef8aa14 100644 --- a/src/lib/components/modals/KeybindModal.svelte +++ b/src/lib/components/modals/KeybindModal.svelte @@ -31,6 +31,7 @@ { keys: [modifierKey, "Shift", "I"], action: "Import Menu" }, { keys: [modifierKey, "Shift", "E"], action: "Export Menu" }, { keys: [modifierKey, "Shift", "L"], action: "Load a snapshot" }, + { keys: [modifierKey, "Shift", "M"], action: "Load an image (with block characters)" }, ]; diff --git a/src/lib/components/modals/topbar/ExportModal.svelte b/src/lib/components/modals/topbar/ExportModal.svelte index 7cfc145..e42c976 100644 --- a/src/lib/components/modals/topbar/ExportModal.svelte +++ b/src/lib/components/modals/topbar/ExportModal.svelte @@ -7,6 +7,7 @@ import { Highlight } from "svelte-highlight"; import typescript from "svelte-highlight/languages/typescript"; import { appSettings } from "$lib/settings"; + import { json } from "svelte-highlight/languages"; // Icons import IconItem from "~icons/tabler/swords"; @@ -17,7 +18,6 @@ import IconCopy from "~icons/tabler/copy"; import IconCheck from "~icons/tabler/check"; import IconDownload from "~icons/tabler/download"; - import { json } from "svelte-highlight/languages"; // UI let showOutput: string | null = $state(null); diff --git a/src/lib/components/modals/topbar/SavedTextsModal.svelte b/src/lib/components/modals/topbar/SavedTextsModal.svelte index 4b2d000..a753689 100644 --- a/src/lib/components/modals/topbar/SavedTextsModal.svelte +++ b/src/lib/components/modals/topbar/SavedTextsModal.svelte @@ -28,37 +28,39 @@ -
+
{#if snapshots.length == 0}

You have not saved anything yet!

{/if} - {#each snapshots as snapshot (snapshot)} -
-
- +
+ {#each snapshots as snapshot (snapshot)} +
+
+ +
+
+ + +
-
- - -
-
- {/each} - + {/each} +
+
diff --git a/src/lib/components/modals/topbar/SettingsModal.svelte b/src/lib/components/modals/topbar/SettingsModal.svelte index a655ae2..6fb412a 100644 --- a/src/lib/components/modals/topbar/SettingsModal.svelte +++ b/src/lib/components/modals/topbar/SettingsModal.svelte @@ -42,11 +42,20 @@
+
+ + +
+