Skip to content

Commit a246930

Browse files
committed
merge from main
2 parents 356accb + 8bc605a commit a246930

16 files changed

+567
-926
lines changed

bun.lock

Lines changed: 129 additions & 175 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 312 additions & 627 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
"test:e2e": "playwright test"
1616
},
1717
"devDependencies": {
18-
"@iconify-json/tabler": "^1.2.24",
18+
"@iconify-json/tabler": "^1.2.25",
1919
"@playwright/test": "^1.57.0",
2020
"@sveltejs/adapter-auto": "^7.0.0",
2121
"@sveltejs/kit": "^2.49.2",
2222
"@sveltejs/vite-plugin-svelte": "^6.2.1",
2323
"@tailwindcss/vite": "^4.1.18",
2424
"@testing-library/jest-dom": "^6.9.1",
25-
"@testing-library/svelte": "^5.2.10",
25+
"@testing-library/svelte": "^5.3.1",
2626
"@tiptap/extension-color": "^3.14.0",
2727
"@tiptap/extension-font-family": "^3.14.0",
2828
"@tiptap/extension-text-style": "^3.14.0",
2929
"@types/node": "^25.0.3",
30-
"@vitest/coverage-v8": "^4.0.16",
31-
"file-type": "^21.1.1",
30+
"@vitest/coverage-v8": "4.0.16",
31+
"file-type": "^21.2.0",
3232
"jsdom": "^27.3.0",
3333
"oxlint": "^1.35.0",
3434
"prettier": "^3.7.4",
3535
"prettier-plugin-svelte": "^3.4.1",
3636
"prettier-plugin-tailwindcss": "^0.7.2",
37-
"svelte": "^5.46.0",
37+
"svelte": "^5.46.1",
3838
"svelte-check": "^4.3.5",
3939
"tailwindcss": "^4.1.18",
4040
"tslib": "^2.8.1",

src/lib/components/Modal.svelte

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { tick } from "svelte";
23
import IconClose from "~icons/tabler/x";
34
45
type Props = {
@@ -17,12 +18,21 @@
1718
key,
1819
}: Props = $props();
1920
20-
export function open() {
21+
export async function open() {
2122
opened = true;
23+
await tick();
2224
}
2325
24-
export function close() {
26+
export async function close() {
2527
opened = false;
28+
await tick();
29+
}
30+
31+
function modifierPressed(event: KeyboardEvent) {
32+
return navigator.platform.startsWith("Mac") ||
33+
navigator.platform.includes("iPhone")
34+
? event.metaKey
35+
: event.ctrlKey;
2636
}
2737
2838
function handleKeydown(event: KeyboardEvent) {
@@ -34,7 +44,7 @@
3444
close();
3545
}
3646
37-
if (event.shiftKey && event.ctrlKey && event.key === key) {
47+
if (event.shiftKey && modifierPressed(event) && event.key === key) {
3848
event.preventDefault();
3949
open();
4050
}
@@ -49,10 +59,9 @@
4959
class="fixed top-0 left-0 flex h-screen w-screen flex-col items-center overflow-auto bg-black/65 text-zinc-100"
5060
style="font-family: Lexend">
5161
<div
52-
onclick={() => close()}
53-
class="fixed top-0 left-0 h-screen w-screen"
54-
style="z-index: 40; background: transparent;"
5562
aria-hidden="true"
63+
onclick={() => close()}
64+
class="fixed top-0 left-0 z-40 h-screen w-screen bg-transparent"
5665
tabindex="-1"
5766
hidden={!opened}>
5867
</div>

src/lib/components/modals/ClickEventModal.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
{#if clickEventType == "open_url"}
2424
<p class="mt-2">URL:</p>
2525
<input
26-
type="text"
27-
class="rounded-md bg-zinc-900 p-2"
26+
type="url"
27+
class="rounded-md bg-zinc-900 p-2 invalid:outline-2 invalid:outline-red-500"
2828
placeholder="https://example.com"
29+
pattern="https?://.*"
2930
bind:value={clickEventValue} />
3031
{:else if clickEventType == "run_command"}
3132
<p class="mt-2">Command:</p>

src/lib/components/modals/ColorGradientModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { applyGradient } from "$lib/text/utils";
44
import ColorPicker from "svelte-awesome-color-picker";
55
6-
import IconDelete from "~icons/tabler/trash";
76
import IconCustom from "~icons/tabler/plus";
7+
import IconDelete from "~icons/tabler/trash";
88
99
let {
1010
gradientDialog = $bindable(),

src/lib/components/modals/ExportModal.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script lang="ts">
22
import Modal from "$lib/components/Modal.svelte";
3+
import { outputVersion } from "$lib/stores";
34
import { translateMOTD } from "$lib/text/motd";
4-
import { convert, translateJSON } from "$lib/text/nbt/nbt_or_json";
5+
import { convert } from "$lib/text/nbt/nbt_or_json";
56
import IconCopy from "~icons/tabler/copy";
67
import CheckBox from "../CheckBox.svelte";
7-
import { outputVersion } from "$lib/stores";
88
let {
99
outputDialog = $bindable(),
1010
editor,

src/lib/components/modals/KeybindModal.svelte

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@
44
55
let { keybindDialog = $bindable() } = $props();
66
7+
let modifierKey =
8+
navigator.platform.startsWith("Mac") ||
9+
navigator.platform.includes("iPhone")
10+
? ""
11+
: "Ctrl";
12+
713
const keysAndActions = [
8-
{ keys: ["Ctrl", "B"], action: "Bold" },
9-
{ keys: ["Ctrl", "I"], action: "Italic" },
10-
{ keys: ["Ctrl", "U"], action: "Underline" },
11-
{ keys: ["Ctrl", "Shift", "S"], action: "Strikethrough" },
12-
{ keys: ["Ctrl", "O"], action: "Obfuscate" },
13-
{ keys: ["Ctrl", "Z"], action: "Undo" },
14-
{ keys: ["Ctrl", "Y"], action: "Redo" },
15-
{ keys: ["Ctrl", "Shift", "X"], action: "Clear all formatting" },
14+
{ keys: [modifierKey, "B"], action: "Bold" },
15+
{ keys: [modifierKey, "I"], action: "Italic" },
16+
{ keys: [modifierKey, "U"], action: "Underline" },
17+
{ keys: [modifierKey, "Shift", "S"], action: "Strikethrough" },
18+
{ keys: [modifierKey, "O"], action: "Obfuscate" },
19+
{ keys: [modifierKey, "Z"], action: "Undo" },
20+
{ keys: [modifierKey, "Y"], action: "Redo" },
21+
{ keys: [modifierKey, "Shift", "X"], action: "Clear all formatting" },
1622
];
1723
const modalKeybinds = [
18-
{ keys: ["Ctrl", "Shift", "G"], action: "Add Color Gradient" },
19-
{ keys: ["Ctrl", "Shift", "K"], action: "View Keybinds" },
20-
{ keys: ["Ctrl", "Shift", "T"], action: "Add Click Event" },
21-
{ keys: ["Ctrl", "Shift", "H"], action: "Add Hover Event" },
22-
{ keys: ["Ctrl", "Shift", "C"], action: "Add Custom Color" },
23-
{ keys: ["Ctrl", "Shift", "F"], action: "Add a font" },
24-
{ keys: ["Ctrl", "Shift", "W"], action: "Add Custom Source" },
25-
{ keys: ["Ctrl", "Shift", "U"], action: "Unicode Menu" },
26-
{ keys: ["Ctrl", "Shift", "I"], action: "Import Menu" },
27-
{ keys: ["Ctrl", "Shift", "E"], action: "Export Menu" },
28-
{ keys: ["Ctrl", "Shift", "L"], action: "Load a snapshot" },
24+
{ keys: [modifierKey, "Shift", "G"], action: "Add Color Gradient" },
25+
{ keys: [modifierKey, "Shift", "K"], action: "View Keybinds" },
26+
{ keys: [modifierKey, "Shift", "T"], action: "Add Click Event" },
27+
{ keys: [modifierKey, "Shift", "H"], action: "Add Hover Event" },
28+
{ keys: [modifierKey, "Shift", "C"], action: "Add Custom Color" },
29+
{ keys: [modifierKey, "Shift", "F"], action: "Add a font" },
30+
{ keys: [modifierKey, "Shift", "W"], action: "Add Custom Source" },
31+
{ keys: [modifierKey, "Shift", "U"], action: "Unicode Menu" },
32+
{ keys: [modifierKey, "Shift", "I"], action: "Import Menu" },
33+
{ keys: [modifierKey, "Shift", "E"], action: "Export Menu" },
34+
{ keys: [modifierKey, "Shift", "L"], action: "Load a snapshot" },
2935
];
3036
</script>
3137

src/lib/components/text/MiniEditor.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { type MinecraftText } from "$lib/types";
2+
import { type MinecraftText, type StringyMCText } from "$lib/types";
33
import { Editor, type JSONContent } from "@tiptap/core";
44
import Color from "@tiptap/extension-color";
55
import Placeholder from "@tiptap/extension-placeholder";
@@ -19,9 +19,7 @@
1919
} from "$lib/text/utils";
2020
import { addTypeSpecificValues } from "$lib/text/nbt/nbt_or_json";
2121
import {
22-
ClickEventMark,
2322
FontsExtension,
24-
HoverEventMark,
2523
Obfuscation,
2624
ShadowColorMark,
2725
} from "$lib/tiptap/extensions/index";
@@ -45,8 +43,6 @@
4543
Color,
4644
TextStyle,
4745
Obfuscation,
48-
ClickEventMark,
49-
HoverEventMark,
5046
ShadowColorMark,
5147
FontsExtension,
5248
Placeholder.configure({
@@ -59,6 +55,7 @@
5955
editor = newEditor;
6056
},
6157
onUpdate: ({ editor }) => {
58+
// TODO: fix the JSON parsing errors that can happen here
6259
value = JSON.stringify(editor.getJSON());
6360
output = JSON.parse(translate(editor.getJSON()));
6461
},
@@ -74,7 +71,7 @@
7471
function translate(json: JSONContent): string {
7572
const paragraphs = json.content!;
7673
77-
let data: (MinecraftText | string)[] = [""];
74+
let data: StringyMCText[] = [""];
7875
7976
paragraphs.forEach((p, i) => {
8077
const content = p.content || [];
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<script lang="ts">
22
import {
3+
AtlasObjectNode,
34
BlockNBTNode,
45
ClickEventMark,
56
EntityNBTNode,
7+
FixedTextStyle,
68
FontsExtension,
79
HoverEventMark,
810
KeybindNode,
911
Obfuscation,
12+
PlayerObjectNode,
1013
ScoreNode,
1114
SelectorNode,
1215
ShadowColorMark,
@@ -15,7 +18,6 @@
1518
} from "$lib/tiptap/extensions/index";
1619
import { Editor } from "@tiptap/core";
1720
import Color from "@tiptap/extension-color";
18-
import { TextStyle } from "@tiptap/extension-text-style";
1921
import StarterKit from "@tiptap/starter-kit";
2022
import { onMount } from "svelte";
2123
@@ -27,25 +29,37 @@
2729
new Editor({
2830
element: element,
2931
extensions: [
30-
StarterKit,
32+
StarterKit.configure({
33+
blockquote: false,
34+
bulletList: false,
35+
codeBlock: false,
36+
hardBreak: false,
37+
heading: false,
38+
horizontalRule: false,
39+
listItem: false,
40+
orderedList: false,
41+
link: false,
42+
}),
3143
Color,
32-
TextStyle,
44+
FixedTextStyle,
3345
Obfuscation,
3446
ClickEventMark,
3547
HoverEventMark,
48+
ShadowColorMark,
3649
BlockNBTNode,
3750
EntityNBTNode,
3851
KeybindNode,
3952
ScoreNode,
4053
SelectorNode,
54+
AtlasObjectNode,
55+
PlayerObjectNode,
4156
StorageNBTNode,
4257
TranslateNode,
43-
ShadowColorMark,
4458
FontsExtension,
4559
],
4660
content: value,
4761
}).setEditable(false);
4862
});
4963
</script>
5064

51-
<div bind:this={element}></div>
65+
<div bind:this={element} role="textbox" tabindex="0"></div>

0 commit comments

Comments
 (0)