Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,494 changes: 789 additions & 705 deletions package-lock.json

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,47 @@
"test:e2e": "playwright install && playwright test"
},
"devDependencies": {
"@iconify-json/tabler": "^1.2.42",
"@playwright/test": "^1.64.0",
"@iconify-json/tabler": "^1.2.43",
"@playwright/test": "^1.65.0",
"@sveltejs/adapter-auto": "^8.0.0",
"@sveltejs/adapter-cloudflare": "^8.0.0",
"@sveltejs/kit": "^3.0.1",
"@sveltejs/adapter-cloudflare": "^8.0.2",
"@sveltejs/kit": "^3.1.1",
"@sveltejs/vite-plugin-svelte": "^7.3.1",
"@tailwindcss/vite": "^4.3.3",
"@types/node": "^26.6.5",
"@tailwindcss/vite": "^4.3.5",
"@types/node": "^26.6.6",
"@types/sortablejs": "^1.15.9",
"@vitest/coverage-v8": "5.0.3",
"@vitest/ui": "^5.0.3",
"file-type": "^22.1.1",
"oxlint": "^1.87.0",
"@vitest/coverage-v8": "^5.1.0",
"@vitest/ui": "^5.1.0",
"file-type": "^22.3.0",
"oxlint": "^1.92.0",
"prettier": "^3.9.10",
"prettier-plugin-svelte": "^4.1.1",
"prettier-plugin-tailwindcss": "^0.8.1",
"svelte": "^5.57.2",
"svelte-check": "^4.7.6",
"tailwindcss": "^4.3.3",
"svelte": "^5.57.3",
"svelte-check": "^4.7.8",
"tailwindcss": "^4.3.5",
"unplugin-icons": "^24.0.0",
"vite": "^8.3.4",
"vitest": "^5.0.3"
"vite": "^8.3.6",
"vitest": "^5.1.0"
},
"type": "module",
"dependencies": {
"@chenglou/pretext": "^0.0.9",
"@tiptap/core": "^3.31.4",
"@tiptap/extension-color": "^3.31.4",
"@tiptap/extension-font-family": "^3.31.4",
"@tiptap/extension-placeholder": "^3.31.4",
"@tiptap/extension-text-style": "^3.31.4",
"@tiptap/pm": "^3.31.4",
"@tiptap/starter-kit": "^3.31.4",
"@chenglou/pretext": "^1.0.0",
"@tiptap/core": "^3.33.0",
"@tiptap/extension-color": "^3.33.0",
"@tiptap/extension-font-family": "^3.33.0",
"@tiptap/extension-placeholder": "^3.33.0",
"@tiptap/extension-text-style": "^3.33.0",
"@tiptap/pm": "^3.33.0",
"@tiptap/starter-kit": "^3.33.0",
"idb": "^8.0.4",
"modern-screenshot": "^4.7.0",
"sortablejs": "^1.15.7",
"svelte-awesome-color-picker": "^4.1.3",
"svelte-highlight": "^7.23.1",
"tippy.js": "^6.3.7",
"typescript": "^6.0.3",
"typescript-color-gradient": "^4.2.0"
"typescript-color-gradient": "^5.0.0"
},
"overrides": {
"prosemirror-model": "1.25.11"
Expand Down
7 changes: 5 additions & 2 deletions src/lib/components/modals/topbar/ImportModal.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { page } from "$app/state";
import CheckBox from "#lib/components/CheckBox.svelte";
import Modal from "#lib/components/Modal.svelte";
import { convertToTextOrEmpty, importBook, snbtToDocument } from "#lib/text/nbt/import.js";
import { page } from "$app/state";
import type { Editor, JSONContent } from "@tiptap/core";

interface Props {
Expand Down Expand Up @@ -37,9 +37,12 @@
}

function importBookToEditor() {
const convertedContent = convertToTextOrEmpty(importText!);
let convertedContent = convertToTextOrEmpty(importText!);

if (bookImportMode === "overwrite") {
// @ts-expect-error *technically* in this one case, convertedContent is a StringyMCText[][],
// but fixing it would require another function which is overkill, and this is the only place
// where it is used, so it's fine to ignore the error here.
const jsonContent = importBook(convertedContent);
pages = jsonContent;
pageIndex = 0;
Expand Down
11 changes: 8 additions & 3 deletions src/lib/text/nbt/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
import { type MinecraftText, type OldMinecraftText } from "../../types";
import { type StringyMCText } from "../../types";

export function importBook(raw: StringyMCText[]): JSONContent[] {
export function importBook(raw: StringyMCText[][]): JSONContent[] {
const pages: JSONContent[] = [];

raw.forEach((page) => {
const pageDocument = snbtToDocument([page]);
const pageDocument = snbtToDocument(page);
pages.push(pageDocument);
});

Expand Down Expand Up @@ -72,7 +72,12 @@ export function convertToTextOrEmpty(raw: string): StringyMCText[] {
let parsed: MinecraftText[] | MinecraftText | string;

try {
parsed = JSON.parse(raw);
const temp = JSON.parse(raw);
if (temp.pages) { // handle book format with pages property
parsed = temp.pages;
} else {
parsed = temp;
}
} catch (err) {
return [
"",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/AtlasObjectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const AtlasObjectNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `OBJECT: [${sprite}@${atlas}]`],
["span", {}, `OBJ: [${sprite} in ${atlas}]`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/BlockNBTNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const BlockNBTNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `NBT: ${nbt}, ${block}`],
["span", {}, `NBT: ${nbt} of ${block}`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/EntityNBTNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const EntityNBTNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["p", {}, `NBT: ${nbt}, ${entity}`],
["p", {}, `NBT: ${nbt} of ${entity}`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/KeybindNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const KeybindNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `KEYBIND: ${key}`],
["span", {}, `KEY: ${key}`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/PlayerObjectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const PlayerObjectNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `OBJECT: [player ${player.name}]`],
["span", {}, `OBJ: [head of ${player.name}]`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/ScoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ScoreNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `SCORE: ${name} - ${objective}`],
["span", {}, `SCORE: ${name} in ${objective}`],
];
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tiptap/extensions/nodes/StorageNBTNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const StorageNBTNode = Node.create<NodeOptions>({
text-decoration: inherit;
`,
}),
["span", {}, `NBT: ${nbt}, ${storage}`],
["span", {}, `NBT: ${nbt} of ${storage}`],
];
},

Expand Down
3 changes: 2 additions & 1 deletion src/routes/book/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@
</div>
{/each}
{/key}
<div class="py-48"></div>
</div>
<div class="h-full w-full grow overflow-auto border-l border-zinc-700 bg-zinc-800">
<div class="book-img m-3">
Expand All @@ -439,7 +440,7 @@
>DEV ONLY: {currentTiptapJSON ? JSON.stringify(currentTiptapJSON) : "Loading..."}</code>
<br />
{/if}
<div class="w-screen border-t border-zinc-700 bg-zinc-950 p-3">
<div class="w-screen border-t border-zinc-700 bg-zinc-950 p-3 z-20">
<div class="flex max-h-32 items-start space-x-2 overflow-auto">
<button
{@attach tooltip}
Expand Down
Loading