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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import { parse } from "node-html-parser";
import type { CheatsheetInfo } from "@cursorless/lib-common";
import { injectCheatsheetInfo } from "../src/injectCheatsheetInfo";
import { injectCheatsheetInfo } from "./injectCheatsheetInfo";

suite("Cheatsheet", () => {
test("injects cheatsheet info as executable script text", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getErrorMessage,
showWarning,
} from "@cursorless/lib-common";
import type { FileSystemTalonSpokenForms } from "./FileSystemTalonSpokenForms";
import type { FileSystemTalonSpokenForms } from "../FileSystemTalonSpokenForms";
import { injectCheatsheetInfo } from "./injectCheatsheetInfo";

interface CheatSheetCommandArgV0 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse, TextNode } from "node-html-parser";
import { parse } from "node-html-parser";
import type { CheatsheetInfo } from "@cursorless/lib-common";

export function injectCheatsheetInfo(
Expand All @@ -11,11 +11,15 @@ export function injectCheatsheetInfo(
String.raw`\u003c`,
);

root
.getElementById("cheatsheet-data")!
.set_content(
new TextNode(`document.cheatsheetInfo = ${serializedCheatsheetInfo};`),
);
const dataElement = root.getElementById("cheatsheet-data");

if (dataElement == null) {
throw new Error("Cheatsheet cheatsheet-data element not found");
}

dataElement.set_content(
`document.cheatsheetInfo = ${serializedCheatsheetInfo};`,
);

return root.toString();
}
2 changes: 1 addition & 1 deletion packages/lib-node-common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./Cheatsheet";
export * from "./cheatsheet/Cheatsheet";
export * from "./FileSystemCommandHistoryStorage";
export * from "./FileSystemRawTreeSitterQueryProvider";
export * from "./FileSystemTalonSpokenForms";
Expand Down
Loading