Skip to content

feat: content re-organization #1772

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

Draft
wants to merge 2 commits into
base: fumadocs
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"search.defaultViewMode": "tree",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[mdx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 1 addition & 1 deletion examples/01-basic/02-block-objects/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function App() {
<div>Document JSON:</div>
<div className={"item bordered"}>
<pre>
<code>{JSON.stringify(blocks, null, 2)}</code>
<code>{JSON.stringify(editor.document, null, 2)}</code>
</pre>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions fumadocs/app/global.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "tailwindcss";
@import "fumadocs-ui/css/vitepress.css";
@import "fumadocs-ui/css/preset.css";
@import "fumadocs-twoslash/twoslash.css";

@source ".";
@source "../components";
Expand Down
5 changes: 4 additions & 1 deletion fumadocs/components/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export function CardTable({
}) {
return (
<Cards>
{getPageTreePeers(source.pageTree, `${baseUrl}/${path}`).map((peer) => (
{getPageTreePeers(
source.pageTree,
`${baseUrl}/${path.startsWith("/") ? path.slice(1) : path}`,
).map((peer) => (
<Card key={peer.url} title={peer.name} href={peer.url}>
{peer.description}
</Card>
Expand Down
15 changes: 0 additions & 15 deletions fumadocs/content/docs/advanced/meta.json

This file was deleted.

8 changes: 0 additions & 8 deletions fumadocs/content/docs/collaboration/index.mdx

This file was deleted.

4 changes: 0 additions & 4 deletions fumadocs/content/docs/collaboration/meta.json

This file was deleted.

124 changes: 0 additions & 124 deletions fumadocs/content/docs/editor-api/converting-blocks.mdx

This file was deleted.

9 changes: 3 additions & 6 deletions fumadocs/content/docs/editor-api/meta.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"title": "Editor API",
"title": "API",
"pages": [
"manipulating-blocks",
"manipulating-inline-content",
"react",
"document-structure",
"cursor-selections",
"converting-blocks",
"events",
"server-processing",
"export-to-pdf",
"export-to-docx",
"export-to-odt",
"..."
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ description: This section explains how to handle paste events in BlockNote.
imageTitle: Paste Handling
---



# Paste Handling

BlockNote, by default, attempts to paste content in the following order:

- VS Code compatible content
- Files
- BlockNote HTML
- Markdown
- HTML
- Plain text
- VS Code compatible content
- Files
- BlockNote HTML
- Markdown
- HTML
- Plain text

> In certain cases, BlockNote will attempt to detect markdown in the clipboard and paste that into the editor as rich text.

Expand All @@ -27,24 +23,23 @@ The `pasteHandler` option is a function that receives the following arguments:

```ts
type PasteHandler = (context: {
event: ClipboardEvent;
editor: BlockNoteEditor;
defaultPasteHandler: (context?: {
prioritizeMarkdownOverHTML?: boolean;
plainTextAsMarkdown?: boolean;
}) => boolean;
event: ClipboardEvent;
editor: BlockNoteEditor;
defaultPasteHandler: (context?: {
prioritizeMarkdownOverHTML?: boolean;
plainTextAsMarkdown?: boolean;
}) => boolean;
}) => boolean;
```

- `event`: The paste event.
- `editor`: The current editor instance.
- `defaultPasteHandler`: The default paste handler. If you only need to customize the paste behavior a little bit, you can fall back on the default paste handler.
- `event`: The paste event.
- `editor`: The current editor instance.
- `defaultPasteHandler`: The default paste handler. If you only need to customize the paste behavior a little bit, you can fall back on the default paste handler.

The `defaultPasteHandler` function can be called with the following options:

- `prioritizeMarkdownOverHTML`: Whether to prioritize Markdown content in `text/plain` over `text/html` when pasting from the clipboard.
- `plainTextAsMarkdown`: Whether to interpret plain text as markdown and paste that as rich text or to paste the text directly into the editor.

- `prioritizeMarkdownOverHTML`: Whether to prioritize Markdown content in `text/plain` over `text/html` when pasting from the clipboard.
- `plainTextAsMarkdown`: Whether to interpret plain text as markdown and paste that as rich text or to paste the text directly into the editor.

## Custom Paste Handler

Expand All @@ -57,8 +52,10 @@ const editor = new BlockNoteEditor({
pasteHandler: ({ event, editor, defaultPasteHandler }) => {
if (event.clipboardData?.types.includes("text/my-custom-format")) {
// You can do any custom logic here, for example you could transform the clipboard data before pasting it
const markdown = customToMarkdown(event.clipboardData.getData("text/my-custom-format"));

const markdown = customToMarkdown(
event.clipboardData.getData("text/my-custom-format"),
);

// The editor is able paste markdown (`pasteMarkdown`), HTML (`pasteHTML`), or plain text (`pasteText`)
editor.pasteMarkdown(markdown);
// We handled the paste event, so return true, returning false will cancel the paste event
Expand All @@ -71,4 +68,4 @@ const editor = new BlockNoteEditor({
});
```

See an example of this in the [Custom Paste Handler](/examples/basic/custom-paste-handler) example.
See an example of this in the [Custom Paste Handler](/examples/basic/custom-paste-handler) example.
Loading
Loading