Skip to content

fix: type annotations on some of the docs #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2024
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
18 changes: 9 additions & 9 deletions packages/website/docs/docs/cursor-selections.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type TextCursorPosition = {
block: Block;
prevBlock: Block | undefined;
nextBlock: Block | undefined;
}
};
```

`block:` The block currently containing the text cursor. If the cursor is in a nested block, this is the block at the deepest possible nesting level.
Expand Down Expand Up @@ -61,7 +61,7 @@ You can set the text cursor position to the start or end of an existing block us
class BlockNoteEditor {
...
public setTextCursorPosition(
targetBlock: BlockIdentifier,
targetBlock: BlockIdentifier,
placement: "start" | "end" = "start"
): void;
...
Expand Down Expand Up @@ -94,15 +94,15 @@ export default function App() {
// Listens for when the text cursor position changes.
onTextCursorPositionChange: (editor) => {
// Gets the block currently hovered by the text cursor.
const hoveredBlock: Block = editor.getTextCursorPosition().block;
const hoveredBlock = editor.getTextCursorPosition().block;

// Traverses all blocks.
editor.forEachBlock((block) => {
if (
block.id === hoveredBlock.id &&
block.props.backgroundColor !== "blue"
) {
// If the block is currently hovered by the text cursor, makes its
// If the block is currently hovered by the text cursor, makes its
// background blue if it isn't already.
editor.updateBlock(block, {
props: {backgroundColor: "blue"},
Expand All @@ -111,18 +111,18 @@ export default function App() {
block.id !== hoveredBlock.id &&
block.props.backgroundColor === "blue"
) {
// If the block is not currently hovered by the text cursor, resets
// If the block is not currently hovered by the text cursor, resets
// its background if it's blue.
editor.updateBlock(block, {
props: {backgroundColor: "default"},
});
}

return true;
});
}
})

// Renders the editor instance.
return <BlockNoteView editor={editor} theme={ "{{ getTheme(isDark) }}"} />;
}
Expand All @@ -141,7 +141,7 @@ When you highlight content using the mouse or keyboard, this is called a selecti
```typescript
type Selection = {
blocks: Block[];
}
};
```

`blocks:` The blocks currently spanned by the selection, including nested blocks.
Expand Down Expand Up @@ -232,4 +232,4 @@ export default function App() {
{{ getStyles(isDark) }}
```

:::
:::
10 changes: 5 additions & 5 deletions packages/website/docs/docs/slash-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ import { HiOutlineGlobeAlt } from "react-icons/hi";
// Command to insert "Hello World" in bold in a new block below.
const insertHelloWorld = (editor: BlockNoteEditor) => {
// Block that the text cursor is currently in.
const currentBlock: Block = editor.getTextCursorPosition().block;
const currentBlock = editor.getTextCursorPosition().block;

// New block we want to insert.
const helloWorldBlock: PartialBlock = {
type: "paragraph",
const helloWorldBlock = {
type: "paragraph" as const,
content: [{ type: "text", text: "Hello World", styles: { bold: true } }],
};
} as const;

// Inserting the new block after the current one.
editor.insertBlocks([helloWorldBlock], currentBlock, "after");
Expand Down Expand Up @@ -105,7 +105,7 @@ import {
import "@blocknote/react/style.css";

function App() {
const newSlashMenuItems: ReactSlashMenuItem[] =
const newSlashMenuItems: ReactSlashMenuItem[] =
getDefaultReactSlashMenuItems();

// Edit newSlashMenuItems
Expand Down