Skip to content

Commit 2863c7e

Browse files
authored
Add LLM text for ToC block (#350)
1 parent 34fab0d commit 2863c7e

File tree

1 file changed

+37
-22
lines changed
  • src/components/runbooks/editor/blocks/TableOfContents

1 file changed

+37
-22
lines changed

src/components/runbooks/editor/blocks/TableOfContents/index.tsx

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ListIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react";
22
import { createReactBlockSpec } from "@blocknote/react";
33
import { useCallback, useEffect, useState } from "react";
44
import track_event from "@/tracking";
5+
import AIBlockRegistry from "@/lib/ai/block_registry";
6+
import undent from "undent";
57

68
interface HeadingItem {
79
id: string;
@@ -143,25 +145,38 @@ export default createReactBlockSpec(
143145
);
144146

145147
// Component to insert this block from the editor menu
146-
export const insertTableOfContents =
147-
(schema: any) => (editor: typeof schema.BlockNoteEditor) => ({
148-
title: "Contents",
149-
subtext: "Add a navigable list of all headings",
150-
onItemClick: async () => {
151-
track_event("runbooks.block.create", { type: "table_of_contents" });
152-
153-
editor.insertBlocks(
154-
[
155-
{
156-
type: "table_of_contents",
157-
props: {},
158-
},
159-
],
160-
editor.getTextCursorPosition().block.id,
161-
"before",
162-
);
163-
},
164-
icon: <ListIcon size={18} />,
165-
aliases: ["toc", "contents"],
166-
group: "Content",
167-
});
148+
export const insertTableOfContents = (schema: any) => (editor: typeof schema.BlockNoteEditor) => ({
149+
title: "Contents",
150+
subtext: "Add a navigable list of all headings",
151+
onItemClick: async () => {
152+
track_event("runbooks.block.create", { type: "table_of_contents" });
153+
154+
editor.insertBlocks(
155+
[
156+
{
157+
type: "table_of_contents",
158+
props: {},
159+
},
160+
],
161+
editor.getTextCursorPosition().block.id,
162+
"before",
163+
);
164+
},
165+
icon: <ListIcon size={18} />,
166+
aliases: ["toc", "contents"],
167+
group: "Content",
168+
});
169+
170+
AIBlockRegistry.getInstance().addBlock({
171+
typeName: "table_of_contents",
172+
friendlyName: "Table of Contents",
173+
shortDescription: "A navigable list of all headings",
174+
description: undent`
175+
Table of Contents blocks add a navigable list of all headings to the document. It takes no props.
176+
177+
Example: {
178+
"type": "table_of_contents",
179+
"props": {},
180+
}
181+
`,
182+
});

0 commit comments

Comments
 (0)