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
6 changes: 3 additions & 3 deletions apps/cli/THIRD_PARTY_NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ License:

- @clack/prompts 1.9.0 and @clack/core 1.6.0
- fast-string-width 3.0.2, fast-wrap-ansi 0.2.2, and sisteransi 2.0.0
- chalk 6.0.0
- string-width 8.2.2, get-east-asian-width 1.6.0, and strip-ansi 7.2.0
- wrap-ansi 10.0.0 and ansi-styles 6.2.3
- chalk 6.0.1
- string-width 9.0.0 and 8.3.0, get-east-asian-width 1.7.0, and strip-ansi 7.2.0
- wrap-ansi 10.0.2 and ansi-styles 6.2.3

Copyright (c) 2025-Present Bombshell contributors
Copyright (c) 2024-present Fabio Spampinato
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"is-ci": "4.1.0",
"linkedom": "0.18.15",
"pako": "3.0.3",
"string-width": "8.3.0",
"string-width": "9.0.0",
"wrap-ansi": "10.0.2",
"@sketchi/community-icons": "workspace:*",
"@sketchi/drawing": "workspace:*",
Expand Down
7 changes: 4 additions & 3 deletions apps/cli/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { rootCommand } from "./root";

const DEFAULT_LIST_LIMIT = 20;
const LIST_TITLE_WIDTH = 48;
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });

function fitWidth(value: string, width: number): string {
if (stringWidth(value) <= width) return value;
let fitted = "";
for (const character of value) {
if (stringWidth(`${fitted}${character}…`) > width) break;
fitted += character;
for (const { segment } of graphemes.segment(value)) {
if (stringWidth(`${fitted}${segment}…`) > width) break;
fitted += segment;
}
return `${fitted}…`;
}
Expand Down
8 changes: 7 additions & 1 deletion apps/cli/tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ describe("sketchi offline command flow", () => {
"invalid_document",
);

json(0, ["create", "--file", "-"], `${JSON.stringify(mindmap)}\n`);
const titlePrefix = `${"界".repeat(22)}a`;
const conjunctTitle = `${titlePrefix}ष्ट्र Extra`;
json(0, ["create", "--file", "-"], `${JSON.stringify(retitled(mindmap, conjunctTitle))}\n`);
const list = run(["list"]);
assert.strictEqual(list.status, 0, list.stderr);
const truncated = list.stdout.split("\n").find((line) => line.startsWith("launch-map"));
assert.include(truncated ?? "", `${titlePrefix}…`);
json(0, [
"edit",
"launch-map",
Expand Down
2 changes: 1 addition & 1 deletion apps/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@sketchi/drawing": "workspace:*",
"@sketchi/icon-catalog": "workspace:*",
"@sketchi/ui": "workspace:*",
"@tanstack/react-hotkeys": "0.19.0",
"@tanstack/react-hotkeys": "0.27.0",
"fflate": "0.8.3",
"lucide-react": "1.74.0",
"roughjs": "4.6.6",
Expand Down
3 changes: 2 additions & 1 deletion apps/icons/src/features/catalog/command-palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
DialogTitle,
} from "@sketchi/ui/components/dialog";
import { formatCollectionLabel } from "@sketchi/icon-catalog";
import { formatForDisplay, type Hotkey } from "@tanstack/react-hotkeys";
import { useFormatForDisplay, type Hotkey } from "@tanstack/react-hotkeys";
import { Check } from "lucide-react";
import { useRef } from "react";

Expand Down Expand Up @@ -63,6 +63,7 @@ export function CommandPalette({
open: boolean;
options: readonly (readonly [string, number])[];
}) {
const formatForDisplay = useFormatForDisplay();
// The palette opens from Mod+K or a header button, never a DialogTrigger, so
// Radix has no trigger to hand focus back to. It records whatever had focus
// as it opens and puts focus back there on close, unless the chosen command
Expand Down
19 changes: 18 additions & 1 deletion apps/icons/tests/library.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe("IconLibrary", () => {
fireEvent.change(search(), { target: { value: "icon" } });
const selectAll = screen.getByRole("checkbox", { name: "Select 300 of 400 results" });
expect(selectAll.parentElement?.textContent).toBe("Select 300");
fireEvent.click(selectAll);
expect(fireEvent.keyDown(document, { ctrlKey: true, key: "a" })).toBe(false);
expect(selectionBar()?.textContent).toContain("300 selected");
expect(selectionBar()?.textContent).toContain("Limit 300");
expect(screen.getByText("Selected 300, 100 left out at the 300 icon cap.")).toBeTruthy();
Expand All @@ -153,6 +153,23 @@ describe("IconLibrary", () => {
).toBe(true);
});

it("gives the open command palette the first Escape without clearing the search", async () => {
render(<IconLibrary data={fixtureData} />);
fireEvent.change(search(), { target: { value: "k8s" } });
fireEvent.keyDown(search(), { ctrlKey: true, key: "k" });
expect(screen.getByRole("dialog", { name: "Commands" })).toBeTruthy();

fireEvent.keyDown(screen.getByPlaceholderText("Type a command or collection"), {
key: "Escape",
});
await waitFor(() => {
expect(screen.queryByRole("dialog", { name: "Commands" })).toBeNull();
});
expect(search().value).toBe("k8s");
expect(fireEvent.keyDown(document, { key: "Escape" })).toBe(false);
expect(search().value).toBe("");
});

it("downloads exactly the selection, including icons the filter hides", async () => {
let zipped: Blob | undefined;
vi.spyOn(URL, "createObjectURL").mockImplementation((blob) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@vitejs/plugin-react": "6.3.0",
"eslint-plugin-better-tailwindcss": "4.11.0",
"jiti": "2.7.0",
"jsdom": "30.1.3",
"jsdom": "31.0.1",
"nx": "24.0.6",
"oxfmt": "0.79.0",
"oxlint": "1.94.0",
Expand Down
Loading