-
-
Notifications
You must be signed in to change notification settings - Fork 755
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
Showing
41 changed files
with
609 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: Toggle Element | ||
description: Turn any block into a toggle. | ||
component: true | ||
docs: | ||
- route: /docs/toggle | ||
title: Toggle | ||
--- | ||
|
||
## 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 toggle-element | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step> | ||
|
||
Install the following dependencies: | ||
|
||
- [Toggle](/docs/toggle) | ||
- [Toolbar](/docs/components/toolbar) | ||
|
||
</Step> | ||
|
||
<Step> | ||
|
||
Copy and paste the following code into your project. | ||
|
||
</Step> | ||
|
||
<ComponentSource name="toggle-element" /> | ||
|
||
<Step> | ||
|
||
Update the import paths to match your project setup. | ||
|
||
</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Examples | ||
|
||
<ComponentPreview name="playground-demo" id="toggle" /> | ||
|
||
<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/plate-plugins.ts" /> |
86 changes: 86 additions & 0 deletions
86
apps/www/content/docs/components/toggle-toolbar-button.mdx
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,86 @@ | ||
--- | ||
title: Toggle Toolbar Button | ||
description: Turns blocks into toggles and vice-versa. | ||
component: true | ||
docs: | ||
- route: /docs/toggle | ||
title: Toggle | ||
- route: /docs/components/toolbar | ||
title: Toolbar | ||
--- | ||
|
||
## 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 toggle-toolbar-button | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step> | ||
|
||
Install the following dependencies: | ||
|
||
- [Toggle](/docs/toggle) | ||
- [Toolbar](/docs/components/toolbar) | ||
|
||
</Step> | ||
|
||
<Step> | ||
|
||
Copy and paste the following code into your project. | ||
|
||
</Step> | ||
|
||
<ComponentSource name="toggle-toolbar-button" /> | ||
|
||
<Step> | ||
|
||
Update the import paths to match your project setup. | ||
|
||
</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
<Accordion type="single" collapsible> | ||
<AccordionItem value="manual-installation"> | ||
<AccordionTrigger>Manual Installation</AccordionTrigger> | ||
<AccordionContent> | ||
|
||
1. Install the following dependencies: | ||
|
||
- [Toggle](/docs/toggle) | ||
- [Toolbar](/docs/components/toolbar) | ||
|
||
2. Copy and paste the following code into your project. | ||
|
||
- `components/plate-ui/toggle-toolbar-button.tsx` | ||
|
||
<ComponentSource name="toggle-toolbar-button" /> | ||
|
||
</AccordionContent> | ||
|
||
</AccordionItem> | ||
</Accordion> | ||
|
||
## Examples | ||
|
||
<ComponentPreview name="playground-demo" id="toggle" /> | ||
|
||
<ComponentSource src="../../templates/plate-playground-template/src/components/plate-ui/fixed-toolbar-buttons.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,110 @@ | ||
--- | ||
title: Toggle | ||
description: Turn any block into a toggle. | ||
docs: | ||
- route: /docs/components/toggle-toolbar-button | ||
title: Toggle Button | ||
--- | ||
|
||
<ComponentPreview name="playground-demo" id="toggle" /> | ||
|
||
<PackageInfo> | ||
|
||
## Features | ||
|
||
- Turn any bock into a toggle: | ||
- Toggles are closed by default, and can be opened to reveal the content inside | ||
- Refer to the [Indent documentation](/docs/indent) for more information. | ||
|
||
## Plugin dependencies | ||
|
||
- [Indent](/docs/indent) | ||
- [Indent List](/docs/indent-list) | ||
- [Node id](/docs/node-id) | ||
|
||
</PackageInfo> | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @udecode/plate-indent @udecode/plate-indent-list @udecode/plate-node-id @udecode/toggle | ||
``` | ||
|
||
## Usage | ||
|
||
```tsx | ||
// ... | ||
import { createIndentPlugin } from '@udecode/plate-indent'; | ||
import { createIndentListPlugin } from '@udecode/plate-indent-list'; | ||
import { createNodeIdPlugin } from '@udecode/plate-node-id'; | ||
import { createTogglePlugin } from '@udecode/plate-toggle'; | ||
|
||
const plugins = [ | ||
// ...otherPlugins, | ||
createHeadingPlugin(), | ||
createParagraphPlugin(), | ||
createIndentPlugin({ | ||
inject: { | ||
props: { | ||
validTypes: [ELEMENT_PARAGRAPH, ELEMENT_H1], | ||
}, | ||
}, | ||
}), | ||
createIndentListPlugin({ | ||
inject: { | ||
props: { | ||
validTypes: [ELEMENT_PARAGRAPH, ELEMENT_H1], | ||
}, | ||
}, | ||
}), | ||
createNodeIdPlugin(), | ||
createTogglePlugin(), | ||
]; | ||
``` | ||
|
||
## API | ||
|
||
### createTogglePlugin | ||
|
||
<APIOptions> | ||
{/* TODO */} | ||
</APIOptions> | ||
|
||
### openFutureToggles | ||
|
||
<APIParameters> | ||
<APIItem name="editor" type="TEditor"> | ||
The editor instance. | ||
</APIItem> | ||
</APIParameters> | ||
|
||
{/* TODO Add API DOC */} | ||
|
||
## API Components | ||
|
||
### useToggleToolbarButton | ||
|
||
A behavior hook for the toggle toolbar button. | ||
|
||
<APIState> | ||
<APIItem name="pressed" type="boolean"> | ||
A boolean indicating whether the button is pressed or not. | ||
</APIItem> | ||
</APIState> | ||
|
||
<APIReturns> | ||
<APIItem name="props" type="object"> | ||
<APISubList> | ||
<APISubListItem parent="props" name="pressed" type="boolean"> | ||
A boolean indicating whether the button is pressed or not. | ||
</APISubListItem> | ||
<APISubListItem parent="props" name="onClick" type="function"> | ||
A callback function to handle the click event of the button. It toggles | ||
the toggle of the specified node type in the editor and focuses the | ||
editor. | ||
</APISubListItem> | ||
</APISubList> | ||
</APIItem> | ||
</APIReturns> | ||
|
||
{/* TODO Add components DOC */} |
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
16 changes: 16 additions & 0 deletions
16
apps/www/public/registry/styles/default/toggle-toolbar-button.json
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,16 @@ | ||
{ | ||
"name": "toggle-toolbar-button", | ||
"dependencies": [ | ||
"@udecode/plate-toggle" | ||
], | ||
"registryDependencies": [ | ||
"toolbar" | ||
], | ||
"files": [ | ||
{ | ||
"name": "toggle-toolbar-button.tsx", | ||
"content": "import React from 'react';\nimport { withRef } from '@udecode/cn';\nimport {\n useToggleToolbarButton,\n useToggleToolbarButtonState,\n} from '@udecode/plate-toggle';\n\nimport { Icons } from '@/components/icons';\n\nimport { ToolbarButton } from './toolbar';\n\nexport const ToggleToolbarButton = withRef<typeof ToolbarButton>((rest, ref) => {\n const state = useToggleToolbarButtonState();\n const { props } = useToggleToolbarButton(state);\n\n return (\n <ToolbarButton\n ref={ref}\n tooltip={'Toggle'}\n {...props}\n {...rest}\n >\n <Icons.ChevronDown />\n </ToolbarButton>\n );\n});\n" | ||
} | ||
], | ||
"type": "components:plate-ui" | ||
} |
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
Oops, something went wrong.