Skip to content

Commit cefc51b

Browse files
committed
fix bugs and do some minor updates
1 parent ce62cdf commit cefc51b

12 files changed

Lines changed: 396 additions & 357 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Check it out at: https://text.datapackhub.net/
99
:eyes: To prove it works, the generated text from the image above is below:
1010

1111
```
12-
["",{italic:true,text:"so many"}," ",{color:"yellow",text:"cool features!"},"\n- ",{bold:true,text:"bold"},", ",{italic:true,text:"italic"},", ",{strikethrough:true,text:"strikethrough"},", ",{underlined:true,text:"underlined"},", obfuscated\n- ",{color:"red",text:"any "},{color:"blue",text:"colours "},"(",{color:"#DD7171",text:"including custom colours"},") and ",{shadow_color:34047,text:"shadow colours"},"\n- ",{underlined:true,text:"",extra:[{color:"#f22f24",text:"c"},{color:"#f23922",text:"r"},{color:"#f24421",text:"e"},{color:"#f34e1f",text:"a"},{color:"#f3581e",text:"t"},{color:"#f3621c",text:"e"},{color:"#f36c1b",text:" "},{color:"#f37719",text:"g"},{color:"#f38118",text:"r"},{color:"#f48b16",text:"a"},{color:"#f49515",text:"d"},{color:"#f49f13",text:"i"},{color:"#f4aa12",text:"e"},{color:"#f4b410",text:"n"},{color:"#f4be0f",text:"t"},{color:"#f4c80d",text:"s"},{color:"#f5d20c",text:" "},{color:"#f5dd0a",text:"t"},{color:"#f5e709",text:"o"},{color:"#f5f107",text:"o!!!"}]},"\n- ",{bold:true,text:"custom sources"}," (",{color:"red",text:"nbt"},", ",{color:"gold",text:"scores"},", ",{color:"yellow",text:"translate keys"},", ",{color:"dark_green",text:"selectors"},", ",{color:"blue",text:"keybinds"},")\n- ",{text:"click events like this",click_event:{action:"open_url",url:"https://text.datapackhub.net/"}},"\n- ",{text:"hover events like this",hover_event:{action:"show_text",value:"i'm a hover event!"}},"\n- export to ",{color:"yellow",underlined:true,text:"json"}," and ",{color:"light_purple",underlined:true,text:"lore item components"}," (as well as normal nbt)\n- ",{color:"light_purple",underlined:true,text:"import from nbt into the editor"},"\n- save and load so you never lose your work\n\n",{color:"yellow",text:"check it out:"}," ",{color:"aqua",underlined:true,text:"https://text.datapackhub.net",click_event:{action:"open_url",url:"https://text.datapackhub.net"}}]
12+
["",{italic:true,text:"so many"}," ",{color:"yellow",text:"cool features!"},"\n- ",{bold:true,text:"bold"},", ",{italic:true,text:"italic"},", ",{strikethrough:true,text:"strikethrough"},", ",{underlined:true,text:"underlined"},", ",{obfuscated:true,text:"obfuscated\n"},"- ",{color:"red",text:"any "},{color:"blue",text:"colours "},"(",{color:"#DD7171",text:"including custom colours"},") and ",{shadow_color:34047,text:"shadow colours"},"\n- ",{underlined:true,text:"",extra:[{color:"#f22f24",text:"c"},{color:"#f23922",text:"r"},{color:"#f24421",text:"e"},{color:"#f34e1f",text:"a"},{color:"#f3581e",text:"t"},{color:"#f3621c",text:"e"},{color:"#f36c1b",text:" "},{color:"#f37719",text:"g"},{color:"#f38118",text:"r"},{color:"#f48b16",text:"a"},{color:"#f49515",text:"d"},{color:"#f49f13",text:"i"},{color:"#f4aa12",text:"e"},{color:"#f4b410",text:"n"},{color:"#f4be0f",text:"t"},{color:"#f4c80d",text:"s"},{color:"#f5d20c",text:" "},{color:"#f5dd0a",text:"t"},{color:"#f5e709",text:"o"},{color:"#f5f107",text:"o!!!"}]},"\n- ",{bold:true,text:"custom sources"}," (",{color:"red",text:"nbt"},", ",{color:"gold",text:"scores"},", ",{color:"yellow",text:"translate keys"},", ",{color:"dark_green",text:"selectors"},", ",{color:"blue",text:"keybinds"},")\n- ",{text:"click events like this",click_event:{action:"open_url",url:"https://text.datapackhub.net/"}},"\n- ",{text:"hover events like this",hover_event:{action:"show_text",value:"i'm a hover event!"}},"\n- export to ",{color:"yellow",underlined:true,text:"json"}," and ",{color:"light_purple",underlined:true,text:"lore item components"}," (as well as normal nbt)\n- ",{color:"light_purple",underlined:true,text:"import from nbt into the editor"},"\n- save and load so you never lose your work\n\n",{color:"yellow",text:"check it out:"}," ",{color:"aqua",underlined:true,text:"https://text.datapackhub.net",click_event:{action:"open_url",url:"https://text.datapackhub.net"}}]
1313
```
1414

1515
## Bugs and feature requests

bun.lock

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

package-lock.json

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

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,42 @@
1515
"test:e2e": "playwright test"
1616
},
1717
"devDependencies": {
18-
"@iconify-json/tabler": "^1.2.33",
19-
"@playwright/test": "^1.59.1",
18+
"@iconify-json/tabler": "^1.2.35",
19+
"@playwright/test": "^1.61.0",
2020
"@sveltejs/adapter-auto": "^7.0.1",
21-
"@sveltejs/kit": "^2.58.0",
22-
"@sveltejs/vite-plugin-svelte": "^7.0.0",
23-
"@tailwindcss/vite": "^4.2.4",
21+
"@sveltejs/kit": "^2.65.1",
22+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
23+
"@tailwindcss/vite": "^4.3.1",
2424
"@testing-library/jest-dom": "^6.9.1",
2525
"@testing-library/svelte": "^5.3.1",
26-
"@tiptap/extension-color": "^3.22.4",
27-
"@tiptap/extension-font-family": "^3.22.4",
28-
"@tiptap/extension-text-style": "^3.22.4",
29-
"@types/node": "^25.6.0",
26+
"@tiptap/extension-color": "^3.26.1",
27+
"@tiptap/extension-font-family": "^3.26.1",
28+
"@tiptap/extension-text-style": "^3.26.1",
29+
"@types/node": "^25.9.3",
3030
"file-type": "^22.0.1",
31-
"jsdom": "^29.0.2",
32-
"oxlint": "^1.61.0",
33-
"prettier": "^3.8.3",
34-
"prettier-plugin-svelte": "^3.5.1",
35-
"prettier-plugin-tailwindcss": "^0.7.3",
36-
"svelte": "^5.55.5",
37-
"svelte-check": "^4.4.6",
38-
"tailwindcss": "^4.2.4",
31+
"jsdom": "^29.1.1",
32+
"oxlint": "^1.70.0",
33+
"prettier": "^3.8.4",
34+
"prettier-plugin-svelte": "^3.5.2",
35+
"prettier-plugin-tailwindcss": "^0.7.4",
36+
"svelte": "^5.56.3",
37+
"svelte-check": "^4.6.0",
38+
"tailwindcss": "^4.3.1",
3939
"typescript": "^6.0.3",
4040
"unplugin-icons": "^23.0.1",
41-
"vite": "^8.0.10",
42-
"vitest": "^4.1.5"
41+
"vite": "^8.0.16",
42+
"vitest": "^4.1.9"
4343
},
4444
"type": "module",
4545
"dependencies": {
46-
"@tiptap/core": "^3.22.4",
47-
"@tiptap/extension-placeholder": "^3.22.4",
48-
"@tiptap/pm": "^3.22.4",
49-
"@tiptap/starter-kit": "^3.22.4",
50-
"bits-ui": "^2.18.0",
51-
"html2canvas-pro": "^2.0.2",
46+
"@tiptap/core": "^3.26.1",
47+
"@tiptap/extension-placeholder": "^3.26.1",
48+
"@tiptap/pm": "^3.26.1",
49+
"@tiptap/starter-kit": "^3.26.1",
50+
"bits-ui": "^2.18.1",
51+
"html2canvas-pro": "^2.0.4",
5252
"idb": "^8.0.3",
53-
"svelte-awesome-color-picker": "^4.1.2",
53+
"svelte-awesome-color-picker": "^4.1.3",
5454
"tippy.js": "^6.3.7",
5555
"typescript-color-gradient": "^4.2.0"
5656
}

src/lib/components/modals/CustomSourceModal.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
selector: "",
4545
},
4646
object: {
47-
object: "",
4847
atlas: "",
4948
sprite: "",
5049
player: {
@@ -397,7 +396,7 @@
397396
<option value="player">Player Head</option>
398397
</select>
399398

400-
{#if customValues.object.object == "atlas"}
399+
{#if customValues.object.object || customValues.object.object == "atlas"}
401400
<p class="mt-2">Atlas</p>
402401
<Combobox
403402
items={defaultAtlases}

src/lib/components/text/TextStyleButtons.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686

8787
{#if !editor.isActive("shadowColor") || isColorPickerOpen}
8888
<ColorPicker
89-
isAlpha={false}
9089
bind:hex={shadowColorValue}
9190
bind:isOpen={isColorPickerOpen}
9291
--cp-bg-color="#18181b"

src/lib/components/text/ToolbarButton.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
class="toolbar-btn {styleVar ? 'bg-zinc-800' : ''}">
2323
<Icon />
2424
</button>
25+

src/lib/text/nbt/export.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ export function addTypeSpecificValues(
6666
break;
6767
case "atlas_object":
6868
if (exportVersion.index >= 2) {
69-
current.object = "atlas";
70-
if(current.atlas) {
71-
current.atlas = c.attrs?.atlas;
69+
if (c.attrs?.atlas && c.attrs?.atlas !== "") {
70+
current.atlas = c.attrs?.atlas;
7271
}
7372
current.sprite = c.attrs?.sprite;
7473

@@ -211,9 +210,10 @@ export function translateJSON(
211210

212211
const shadowColorMark = c.marks?.find((m) => m.type === "shadowColor");
213212
if (shadowColorMark) {
214-
current.shadow_color =
215-
parseInt(shadowColorMark.attrs?.shadowColor.replace(/^#/, ""), 16) +
216-
(0xff << 24); // TODO: transparency coming eventually?
213+
current.shadow_color = parseInt(
214+
rgbaToArgbHex(shadowColorMark.attrs?.shadowColor).replace(/^#/, ""),
215+
16,
216+
);
217217
}
218218

219219
current = addTypeSpecificValues(current, c, true);
@@ -238,7 +238,19 @@ export function translateJSON(
238238
return JSON.stringify(data[0]);
239239
}
240240

241-
return JSON.stringify(data);
241+
let finalResult = JSON.stringify(data);
242+
243+
const shadowColorMatches = finalResult.matchAll(/"shadow_color":(-?\d+)/g);
244+
for (const match of shadowColorMatches) {
245+
if (match[1]) {
246+
const num = parseInt(match[1]);
247+
if (num > 2**31 - 1 || num < (-2)**31) {
248+
finalResult = finalResult.replaceAll(match[0], `shadow_color:${num}L`)
249+
}
250+
}
251+
}
252+
253+
return finalResult;
242254
} else if (options.exportType === "item_lore") {
243255
let data: (StringyMCText[] | StringyMCText)[] = [];
244256

@@ -273,3 +285,15 @@ export function translateJSON(
273285

274286
return "[]";
275287
}
288+
289+
function rgbaToArgbHex(rgbaHex: string): string {
290+
// Remove the leading '#' if it exists
291+
const hex = rgbaHex.startsWith("#") ? rgbaHex.slice(1) : rgbaHex;
292+
293+
// Extract RGB and Alpha components
294+
const rgb = hex.slice(0, 6);
295+
const alpha = hex.slice(6, 8);
296+
297+
// Return with alpha placed at the beginning
298+
return `#${alpha}${rgb}`;
299+
}

src/lib/text/nbt/import.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function mapPropertiesToType(source: MinecraftText): JSONContent {
182182
key: source.keybind,
183183
},
184184
};
185-
} else if (source.atlas) {
185+
} else if (source.sprite || source.atlas) {
186186
finalText = {
187187
type: "atlas_object",
188188
attrs: {
@@ -242,7 +242,7 @@ function applyStyling(
242242
}
243243

244244
if (text.shadow_color) {
245-
const hex = "#" + text.shadow_color.toString(16).padStart(6, "0");
245+
const hex = "#" + text.shadow_color.toString(16).padStart(8, "0");
246246
finalText.marks?.push({
247247
type: "shadowColor",
248248
attrs: {

0 commit comments

Comments
 (0)