Skip to content

Commit 20f5459

Browse files
authored
Merge pull request #3727 from udecode/feat/block
Fix blocks
2 parents b37ea84 + bd3f63f commit 20f5459

28 files changed

+232
-53
lines changed

apps/www/content/docs/autoformat.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const plugins = [
5858

5959
### `autoformatRules`
6060

61-
<ComponentSource src="../../templates/plate-playground-template/src/components/editor/plugins/autoformat-plugin.ts" />
61+
<ComponentSource name="autoformat-plugin" />
6262

6363
### `autoformatBlocks`
6464

apps/www/content/docs/components/installation/manual.mdx

+17-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here's what demo `tailwind.config.js` looks like:
3232

3333
### Configure styles
3434

35-
Add the following to your `styles/globals.css` file. You can learn more about using CSS variables for theming in the [theming section](/docs/components/theming).
35+
Add the following to your `globals.css` file. You can learn more about using CSS variables for theming in the [theming section](/docs/components/theming).
3636

3737
<ComponentSource
3838
src="../../templates/plate-playground-template/src/app/globals.css"
@@ -47,4 +47,20 @@ You can now start adding components to your project.
4747
npx shadcx@latest add plate/paragraph-element
4848
```
4949

50+
### Add editor (optional)
51+
52+
Choose your editor to get started ([browse available editors](/editors)).
53+
54+
[Minimal Editor](https://template.platejs.org/editor)
55+
```bash
56+
npx shadcx@latest add plate/editor-basic
57+
```
58+
59+
[AI Editor](https://playground.platejs.org/editor)
60+
```bash
61+
npx shadcx@latest add plate/editor-ai
62+
```
63+
64+
This will add an `/editor` page to your project along with all necessary components as a starting point.
65+
5066
</Steps>

apps/www/content/docs/components/installation/next.mdx

+37-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,30 @@ description: Install and configure Next.js.
55

66
<Callout>
77

8-
A [template](https://github.com/udecode/plate/tree/main/templates/plate-template) is available to help you get started quickly.
9-
10-
**If you're using Next.js 15, see the [Next.js 15 + React 19](https://ui.shadcn.com/docs/installation/react-19) guide.**
8+
**If you're using React 19, see the [Next.js 15 + React 19](https://ui.shadcn.com/docs/react-19) guide.**
119

1210
</Callout>
1311

12+
## Quick Start
13+
14+
Choose your editor to get started. These commands will initialize your project and add the editor ([browse available editors](/editors)):
15+
16+
[Minimal Editor](https://template.platejs.org/editor)
17+
```bash
18+
npx shadcx@latest add plate/editor-basic
19+
```
20+
21+
[AI Editor](https://playground.platejs.org/editor)
22+
```bash
23+
npx shadcx@latest add plate/editor-ai
24+
```
25+
26+
This will add an `/editor` page to your project along with all necessary components as a starting point.
27+
28+
## Manual Installation
29+
30+
If you prefer to set up your project step by step, follow these instructions:
31+
1432
<Steps>
1533

1634
### Create project
@@ -44,4 +62,20 @@ The command above will add the `ParagraphElement` component to your project.
4462

4563
To add more components to your plugins, see [Plugin Components](/docs/plugin-components#register-components).
4664

65+
### Add editor (optional)
66+
67+
Choose your editor to get started ([browse available editors](/editors)).
68+
69+
[Minimal Editor](https://template.platejs.org/editor)
70+
```bash
71+
npx shadcx@latest add plate/editor-basic
72+
```
73+
74+
[AI Editor](https://playground.platejs.org/editor)
75+
```bash
76+
npx shadcx@latest add plate/editor-ai
77+
```
78+
79+
This will add an `/editor` page to your project along with all necessary components as a starting point.
80+
4781
</Steps>

apps/www/content/docs/components/installation/vite.mdx

+16
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,20 @@ npx shadcx@latest add plate/paragraph-element
143143

144144
To add the components to your plugins, see [Plugin Components](/docs/plugin-components#register-components).
145145

146+
### Add editor (optional)
147+
148+
Choose your editor to get started ([browse available editors](/editors)).
149+
150+
[Minimal Editor](https://template.platejs.org/editor)
151+
```bash
152+
npx shadcx@latest add plate/editor-basic
153+
```
154+
155+
[AI Editor](https://playground.platejs.org/editor)
156+
```bash
157+
npx shadcx@latest add plate/editor-ai
158+
```
159+
160+
This will add an `/editor` page to your project along with all necessary components as a starting point.
161+
146162
</Steps>

apps/www/public/r/index.json

+29
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,35 @@
890890
"registryDependencies": [],
891891
"type": "registry:ui"
892892
},
893+
{
894+
"dependencies": [
895+
"@udecode/plate-list"
896+
],
897+
"doc": {
898+
"description": "A checkbox list element with interactive todo items.",
899+
"docs": [
900+
{
901+
"route": "/docs/list",
902+
"title": "List"
903+
}
904+
],
905+
"examples": [
906+
"list-demo"
907+
]
908+
},
909+
"files": [
910+
{
911+
"path": "plate-ui/todo-list-element.tsx",
912+
"type": "registry:ui"
913+
}
914+
],
915+
"name": "todo-list-element",
916+
"registryDependencies": [
917+
"checkbox",
918+
"plate-element"
919+
],
920+
"type": "registry:ui"
921+
},
893922
{
894923
"dependencies": [
895924
"@udecode/plate-toggle"

apps/www/public/r/styles/default/copilot-plugins.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"files": [
88
{
9-
"content": "'use client';\n\nimport type { TElement } from '@udecode/plate-common';\n\nimport { faker } from '@faker-js/faker';\nimport { CopilotPlugin } from '@udecode/plate-ai/react';\nimport { getAncestorNode } from '@udecode/plate-common';\nimport { serializeMdNodes, stripMarkdown } from '@udecode/plate-markdown';\n\nimport { GhostText } from '@/components/plate-ui/ghost-text';\n\nexport const copilotPlugins = [\n CopilotPlugin.configure(({ api }) => ({\n options: {\n completeOptions: {\n api: '/api/ai/copilot',\n body: {\n system: `You are an advanced AI writing assistant, similar to VSCode Copilot but for general text. Your task is to predict and generate the next part of the text based on the given context.\n \n Rules:\n - Continue the text naturally up to the next punctuation mark (., ,, ;, :, ?, or !).\n - Maintain style and tone. Don't repeat given text.\n - For unclear context, provide the most likely continuation.\n - Handle code snippets, lists, or structured text if needed.\n - Don't include \"\"\" in your response.\n - CRITICAL: Always end with a punctuation mark.\n - CRITICAL: Avoid starting a new block. Do not use block formatting like >, #, 1., 2., -, etc. The suggestion should continue in the same block as the context.\n - If no context is provided or you can't generate a continuation, return \"0\" without explanation.`,\n },\n onError: () => {\n api.copilot.setBlockSuggestion({\n text: stripMarkdown(faker.lorem.sentence()),\n });\n },\n onFinish: (_, completion) => {\n if (completion === '0') return;\n\n api.copilot.setBlockSuggestion({\n //stripMarkdownBlocks in plus GhostText\n text: stripMarkdown(completion),\n });\n },\n },\n debounceDelay: 500,\n getPrompt: ({ editor }) => {\n const contextEntry = getAncestorNode(editor);\n\n if (!contextEntry) return '';\n\n const prompt = serializeMdNodes([contextEntry[0] as TElement]);\n\n return `Continue the text up to the next punctuation mark:\n \"\"\"\n ${prompt}\n \"\"\"`;\n },\n renderGhostText: GhostText,\n },\n })),\n] as const;\n",
9+
"content": "'use client';\n\nimport type { TElement } from '@udecode/plate-common';\n\nimport { faker } from '@faker-js/faker';\nimport { CopilotPlugin } from '@udecode/plate-ai/react';\nimport { getAncestorNode } from '@udecode/plate-common';\nimport { serializeMdNodes, stripMarkdown } from '@udecode/plate-markdown';\n\nimport { GhostText } from '@/components/plate-ui/ghost-text';\n\nexport const copilotPlugins = [\n CopilotPlugin.configure(({ api }) => ({\n options: {\n completeOptions: {\n api: '/api/ai/copilot',\n body: {\n system: `You are an advanced AI writing assistant, similar to VSCode Copilot but for general text. Your task is to predict and generate the next part of the text based on the given context.\n \n Rules:\n - Continue the text naturally up to the next punctuation mark (., ,, ;, :, ?, or !).\n - Maintain style and tone. Don't repeat given text.\n - For unclear context, provide the most likely continuation.\n - Handle code snippets, lists, or structured text if needed.\n - Don't include \"\"\" in your response.\n - CRITICAL: Always end with a punctuation mark.\n - CRITICAL: Avoid starting a new block. Do not use block formatting like >, #, 1., 2., -, etc. The suggestion should continue in the same block as the context.\n - If no context is provided or you can't generate a continuation, return \"0\" without explanation.`,\n },\n onError: () => {\n // Mock the API response. Remove it when you implement the route /api/ai/copilot\n api.copilot.setBlockSuggestion({\n text: stripMarkdown(faker.lorem.sentence()),\n });\n },\n onFinish: (_, completion) => {\n if (completion === '0') return;\n\n api.copilot.setBlockSuggestion({\n text: stripMarkdown(completion),\n });\n },\n },\n debounceDelay: 500,\n getPrompt: ({ editor }) => {\n const contextEntry = getAncestorNode(editor);\n\n if (!contextEntry) return '';\n\n const prompt = serializeMdNodes([contextEntry[0] as TElement]);\n\n return `Continue the text up to the next punctuation mark:\n \"\"\"\n ${prompt}\n \"\"\"`;\n },\n renderGhostText: GhostText,\n },\n })),\n] as const;\n",
1010
"path": "components/editor/plugins/copilot-plugins.tsx",
1111
"target": "components/editor/plugins/copilot-plugins.tsx",
1212
"type": "registry:component"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"dependencies": [
3+
"@udecode/plate-list"
4+
],
5+
"doc": {
6+
"description": "A checkbox list element with interactive todo items.",
7+
"docs": [
8+
{
9+
"route": "/docs/list",
10+
"title": "List"
11+
}
12+
],
13+
"examples": [
14+
"list-demo"
15+
]
16+
},
17+
"files": [
18+
{
19+
"content": "'use client';\n\nimport React from 'react';\n\nimport { cn, withRef } from '@udecode/cn';\nimport {\n useTodoListElement,\n useTodoListElementState,\n} from '@udecode/plate-list/react';\n\nimport { Checkbox } from './checkbox';\nimport { PlateElement } from './plate-element';\n\nexport const TodoListElement = withRef<typeof PlateElement>(\n ({ children, className, ...props }, ref) => {\n const { element } = props;\n const state = useTodoListElementState({ element });\n const { checkboxProps } = useTodoListElement(state);\n\n return (\n <PlateElement\n ref={ref}\n className={cn('flex flex-row py-1', className)}\n {...props}\n >\n <div\n className=\"mr-1.5 flex select-none items-center justify-center\"\n contentEditable={false}\n >\n <Checkbox {...checkboxProps} />\n </div>\n <span\n className={cn(\n 'flex-1 focus:outline-none',\n state.checked && 'text-muted-foreground line-through'\n )}\n contentEditable={!state.readOnly}\n suppressContentEditableWarning\n >\n {children}\n </span>\n </PlateElement>\n );\n }\n);\n",
20+
"path": "plate-ui/todo-list-element.tsx",
21+
"target": "components/plate-ui/todo-list-element.tsx",
22+
"type": "registry:ui"
23+
}
24+
],
25+
"name": "todo-list-element",
26+
"registryDependencies": [
27+
"checkbox",
28+
"plate-element"
29+
],
30+
"type": "registry:ui"
31+
}

0 commit comments

Comments
 (0)