Skip to content

Commit

Permalink
fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Sep 2, 2024
1 parent 182a700 commit feaba69
Show file tree
Hide file tree
Showing 35 changed files with 71 additions and 41 deletions.
12 changes: 1 addition & 11 deletions apps/www/content/docs/autoformat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,22 @@ const plugins = [

### `autoformatRules`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatRules.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformat-rules.ts" />

### `autoformatBlocks`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatBlocks.ts" />

### `autoformatIndentLists`

If using the [Indent List plugin](/docs/indent-list), you can use the following rules:

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatIndentLists.ts" />

### `autoformatLists`

If using the [List plugin](/docs/list), you can use the following rules:

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatLists.ts" />

### `autoformatMarks`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatMarks.ts" />

### `autoformatUtils`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatUtils.ts" />

## API

### AutoformatPlugin
Expand Down
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/blockquote-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/code-block-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/code-leaf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/code-line-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/code-syntax-leaf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/column-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="column" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/column-group-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="column" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/comment-leaf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="comment" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
1 change: 0 additions & 1 deletion apps/www/content/docs/components/comments-popover.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ Update the import paths to match your project setup.
<ComponentPreview name="playground-demo" id="comment" />

<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/comments.ts" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/date-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Copy and paste the following code into your project.

</Step>

<ComponentSource name="date" />
<ComponentSource name="date-element" />

<Step>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/draggable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ import { HTML5Backend } from 'react-dnd-html5-backend';

## Examples

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/emoji-input-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="emoji" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/excalidraw-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="excalidraw" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/heading-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/highlight-leaf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="highlight" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/hr-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="hr" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/image-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="media" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/kbd-leaf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="kbd" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/link-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="link" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/link-floating-toolbar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="link" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/list-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="list" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/media-embed-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="media" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/mention-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="mention" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/mention-input-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="mention" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/paragraph-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="basicnodes" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/table-cell-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="table" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/table-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="table" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/table-row-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="table" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/todo-list-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="list" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/toggle-element.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ Update the import paths to match your project setup.

<ComponentPreview name="playground-demo" id="toggle" />

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" />
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-editor.tsx" />
11 changes: 11 additions & 0 deletions apps/www/public/registry/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@
"registryDependencies": [],
"type": "components:plate-ui"
},
{
"dependencies": [
"@udecode/plate-date"
],
"files": [
"plate-ui/date-element.tsx"
],
"name": "date-element",
"registryDependencies": [],
"type": "components:plate-ui"
},
{
"dependencies": [
"@radix-ui/react-slot"
Expand Down
14 changes: 14 additions & 0 deletions apps/www/public/registry/styles/default/date-element.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dependencies": [
"@udecode/plate-date"
],
"files": [
{
"content": "'use client';\n\nimport { cn, withRef } from '@udecode/cn';\nimport { setNodes } from '@udecode/plate-common';\nimport { PlateElement, findNodePath } from '@udecode/plate-common/react';\n\nimport { Calendar } from './calendar';\nimport { Popover, PopoverContent, PopoverTrigger } from './popover';\n\nexport const DateElement = withRef<typeof PlateElement>(\n ({ children, className, ...props }, ref) => {\n const { editor, element } = props;\n\n return (\n <PlateElement\n className={cn('inline-block', className)}\n contentEditable={false}\n ref={ref}\n {...props}\n >\n <Popover>\n <PopoverTrigger asChild>\n <span\n className={cn(\n 'w-fit cursor-pointer rounded-sm bg-muted px-1 text-muted-foreground'\n )}\n contentEditable={false}\n >\n {element.date ? (\n (() => {\n const today = new Date();\n const elementDate = new Date(element.date as string);\n const isToday =\n elementDate.getDate() === today.getDate() &&\n elementDate.getMonth() === today.getMonth() &&\n elementDate.getFullYear() === today.getFullYear();\n\n const isYesterday =\n new Date(\n today.setDate(today.getDate() - 1)\n ).toDateString() === elementDate.toDateString();\n const isTomorrow =\n new Date(\n today.setDate(today.getDate() + 2)\n ).toDateString() === elementDate.toDateString();\n\n if (isToday) return 'Today';\n if (isYesterday) return 'Yesterday';\n if (isTomorrow) return 'Tomorrow';\n\n return elementDate.toLocaleDateString(undefined, {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n });\n })()\n ) : (\n <span>Pick a date</span>\n )}\n </span>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto p-0\">\n <Calendar\n initialFocus\n mode=\"single\"\n onSelect={(date) => {\n if (!date) return;\n\n setNodes(\n editor,\n { date: date.toDateString() },\n { at: findNodePath(editor, element) }\n );\n }}\n selected={new Date(element.date as string)}\n />\n </PopoverContent>\n </Popover>\n {children}\n </PlateElement>\n );\n }\n);\n",
"name": "date-element.tsx"
}
],
"name": "date-element",
"registryDependencies": [],
"type": "components:plate-ui"
}
9 changes: 9 additions & 0 deletions apps/www/src/__registry__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ export const Index: Record<string, any> = {
subcategory: "undefined",
component: React.lazy(() => import('@/registry/default/plate-ui/blockquote-element')),
},
'date-element': {
name: 'date-element',
type: 'components:plate-ui',
registryDependencies: [],
files: ['registry/default/plate-ui/date-element.tsx'],
category: "undefined",
subcategory: "undefined",
component: React.lazy(() => import('@/registry/default/plate-ui/date-element')),
},
'button': {
name: 'button',
type: 'components:plate-ui',
Expand Down
7 changes: 7 additions & 0 deletions apps/www/src/registry/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ export const ui: Registry = [
registryDependencies: [],
type: 'components:plate-ui',
},
{
dependencies: ['@udecode/plate-date'],
files: ['plate-ui/date-element.tsx'],
name: 'date-element',
registryDependencies: [],
type: 'components:plate-ui',
},
{
dependencies: ['@radix-ui/react-slot'],
files: ['plate-ui/button.tsx'],
Expand Down

0 comments on commit feaba69

Please sign in to comment.