-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zbeyens
committed
Sep 18, 2023
1 parent
05c24d9
commit 8d2cbcf
Showing
40 changed files
with
667 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
title: Editor | ||
description: From Textarea to WYSIWYG editor. | ||
component: true | ||
docs: | ||
- route: /docs/api/core/plate | ||
title: Plate | ||
--- | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
|
||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx @udecode/plate-ui@latest add editor | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step> | ||
|
||
Copy and paste the following code into your project. | ||
|
||
</Step> | ||
|
||
<ComponentSource name="editor" /> | ||
|
||
<Step> | ||
|
||
Update the import paths to match your project setup. | ||
|
||
</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Examples | ||
|
||
### Default | ||
|
||
<ComponentPreview name="editor-default" /> | ||
|
||
### Disabled | ||
|
||
<ComponentPreview name="editor-disabled" /> | ||
|
||
### Ghost | ||
|
||
<ComponentPreview name="editor-ghost" /> | ||
|
||
### With Label | ||
|
||
<ComponentPreview name="editor-label" /> | ||
|
||
### With Text | ||
|
||
<ComponentPreview name="editor-text" /> | ||
|
||
### With Button | ||
|
||
<ComponentPreview name="editor-button" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
import { PlateContentProps } from '@udecode/plate-common'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
export const editableProps: PlateContentProps = { | ||
spellCheck: false, | ||
autoFocus: false, | ||
placeholder: 'Type…', | ||
style: { | ||
outline: 'none', | ||
}, | ||
className: cn('relative max-w-full [&_strong]:font-bold'), | ||
}; |
46 changes: 30 additions & 16 deletions
46
apps/www/src/registry/default/example/basic-editor-handler-demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,45 @@ | ||
import React, { useState } from 'react'; | ||
import { editableProps } from '@/plate/demo/editableProps'; | ||
import { Plate, PlateContent, Value } from '@udecode/plate-common'; | ||
import { Plate, Value } from '@udecode/plate-common'; | ||
|
||
import { | ||
Accordion, | ||
AccordionContent, | ||
AccordionItem, | ||
AccordionTrigger, | ||
} from '@/components/ui/accordion'; | ||
import { Editor } from '@/registry/default/plate-ui/editor'; | ||
|
||
const initialValue = [ | ||
{ | ||
type: 'p', | ||
children: [ | ||
{ | ||
text: 'This is editable plain text with react and history plugins, just like a textarea!', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
export default function BasicEditorHandlerDemo() { | ||
const [debugValue, setDebugValue] = useState<Value>([]); | ||
const [debugValue, setDebugValue] = useState<Value>(initialValue); | ||
|
||
return ( | ||
<Plate | ||
initialValue={[ | ||
{ | ||
type: 'p', | ||
children: [ | ||
{ | ||
text: 'This is editable plain text with react and history plugins, just like a textarea!', | ||
}, | ||
], | ||
}, | ||
]} | ||
initialValue={initialValue} | ||
onChange={(newValue) => { | ||
setDebugValue(newValue); | ||
// save newValue... | ||
}} | ||
> | ||
<PlateContent {...editableProps} /> | ||
debug value: | ||
<br /> | ||
{JSON.stringify(debugValue)} | ||
<Editor {...editableProps} /> | ||
|
||
<Accordion type="single" collapsible> | ||
<AccordionItem value="manual-installation"> | ||
<AccordionTrigger>Debug Value</AccordionTrigger> | ||
<AccordionContent>{JSON.stringify(debugValue)}</AccordionContent> | ||
</AccordionItem> | ||
</Accordion> | ||
</Plate> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/www/src/registry/default/example/basic-editor-styling-demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { Plate } from '@udecode/plate-common'; | ||
|
||
import { Editor } from '@/registry/default/plate-ui/editor'; | ||
|
||
export default function BasicEditorStylingDemo() { | ||
return ( | ||
<Plate> | ||
<Editor placeholder="Type..." /> | ||
</Plate> | ||
); | ||
} |
Oops, something went wrong.