|
9 | 9 | outputVersion = $bindable(), |
10 | 10 | editor, |
11 | 11 | recentlyCopied, |
12 | | - indent, |
13 | | - indentSize, |
14 | 12 | shouldOptimise = true, |
15 | 13 | } = $props(); |
16 | 14 |
|
|
39 | 37 | <option value="new">1.21.5+</option> |
40 | 38 | <option value="old">Before 1.21.5</option> |
41 | 39 | </select> |
42 | | - <div class="mt-2 flex w-full flex-col"> |
43 | | - <p>For tellraw commands (send to chat):</p> |
| 40 | + <div class="flex w-full flex-col"> |
| 41 | + {#if outputVersion == "new"} |
| 42 | + <div class="flex items-center space-x-2 mt-1"> |
| 43 | + <CheckBox bind:value={exportAsJSON} label="json" /> |
| 44 | + <span>Toggle JSON mode (for use in json files)</span> |
| 45 | + </div> |
| 46 | + {/if} |
| 47 | + |
| 48 | + <p class="mt-2">As {outputVersion == "new" ? " " : "JSON "}text components:</p> |
44 | 49 | <div class="flex items-start space-x-3 rounded-lg bg-zinc-950 p-3"> |
45 | 50 | <button |
46 | 51 | class="rounded-md p-1 text-lg font-medium hover:bg-zinc-900 active:bg-white/10" |
47 | 52 | onclick={() => { |
48 | 53 | navigator.clipboard.writeText( |
49 | | - "/tellraw @s " + |
50 | | - convert( |
51 | | - editor.getJSON(), |
52 | | - "standard", |
53 | | - outputVersion, |
54 | | - shouldOptimise, |
55 | | - ), |
| 54 | + convert( |
| 55 | + editor.getJSON(), |
| 56 | + "standard", |
| 57 | + outputVersion, |
| 58 | + shouldOptimise, |
| 59 | + exportAsJSON |
| 60 | + ), |
56 | 61 | ); |
57 | 62 | recentlyCopied = true; |
58 | 63 | setTimeout(() => (recentlyCopied = false), 2000); |
59 | 64 | }}> |
60 | 65 | <IconCopy /> |
61 | 66 | </button> |
62 | | - <code class="inline-block max-h-56 w-full overflow-auto" |
63 | | - ><span class="text-white/60">/tellraw @s</span> |
| 67 | + <code class="inline-block max-h-56 w-full overflow-auto"> |
64 | 68 | {editor |
65 | | - ? convert(editor.getJSON(), "standard", outputVersion, shouldOptimise) |
| 69 | + ? convert(editor.getJSON(), "standard", outputVersion, shouldOptimise, exportAsJSON) |
66 | 70 | : "Loading..."} |
67 | 71 | </code> |
68 | 72 | </div> |
|
73 | 77 | class="rounded-md p-1 text-lg font-medium hover:bg-zinc-900 active:bg-white/10" |
74 | 78 | onclick={() => { |
75 | 79 | navigator.clipboard.writeText( |
76 | | - `[lore=${convert(editor.getJSON(), "item_lore", outputVersion, shouldOptimise)}]`, |
| 80 | + `[lore=${convert(editor.getJSON(), "item_lore", outputVersion, shouldOptimise, exportAsJSON)}]`, |
77 | 81 | ); |
78 | 82 | recentlyCopied = true; |
79 | 83 | setTimeout(() => (recentlyCopied = false), 2000); |
80 | 84 | }}> |
81 | 85 | <IconCopy /> |
82 | 86 | </button> |
83 | | - {#if outputVersion == "new"} |
84 | 87 | <code class="inline-block max-h-56 w-full overflow-auto" |
85 | | - ><span class="text-white/60">[lore=</span>{editor |
86 | | - ? exportThing(exportAsJSON) |
87 | | - : "Loading..."}<span class="text-white/60">]</span> |
88 | | - </code> |
89 | | - <CheckBox bind:value={exportAsJSON} label="json" /> |
90 | | - <label for="json">Export as JSON</label> |
91 | | - {:else} |
92 | | - <code class="inline-block max-h-56 w-full overflow-auto" |
93 | | - ><span class="text-white/60">[lore=</span>{editor |
94 | | - ? `'${translateJSON(editor.getJSON(), { |
95 | | - exportType: "item_lore", |
96 | | - exportVersion: outputVersion, |
97 | | - optimise: shouldOptimise, |
98 | | - })}` |
99 | | - : "Loading..."}'<span class="text-white/60">]</span> |
| 88 | + ><span class="text-white/35">[lore=</span>{editor |
| 89 | + ? convert( |
| 90 | + editor.getJSON(), |
| 91 | + "item_lore", |
| 92 | + outputVersion, |
| 93 | + shouldOptimise, |
| 94 | + exportAsJSON |
| 95 | + ) |
| 96 | + : "Loading..."}<span class="text-white/35">]</span> |
100 | 97 | </code> |
101 | | - {/if} |
102 | 98 | </div> |
103 | 99 |
|
104 | 100 | <p class="mt-2">As a MOTD:</p> |
|
0 commit comments