From 71a5a02e8c9ada65d3169d23c67aec7853e9cb82 Mon Sep 17 00:00:00 2001 From: Alessio Gravili <70709113+AlessioGr@users.noreply.github.com> Date: Sun, 31 Mar 2024 17:50:15 -0400 Subject: [PATCH] docs(richtext-slate): update outdated code example (#5572) (#5573) --- docs/rich-text/slate.mdx | 98 +++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/docs/rich-text/slate.mdx b/docs/rich-text/slate.mdx index 630d3855c..34d5ea144 100644 --- a/docs/rich-text/slate.mdx +++ b/docs/rich-text/slate.mdx @@ -167,7 +167,9 @@ Specifying custom `Type`s let you extend your custom elements by adding addition `collections/ExampleCollection.ts` ```ts -import { CollectionConfig } from 'payload/types' +import type { CollectionConfig } from 'payload/types' + +import { slateEditor } from '@payloadcms/richtext-slate' export const ExampleCollection: CollectionConfig = { slug: 'example-collection', @@ -181,57 +183,59 @@ export const ExampleCollection: CollectionConfig = { }, ], required: true, - admin: { - elements: [ - 'h2', - 'h3', - 'h4', - 'link', - 'blockquote', - { - name: 'cta', - Button: CustomCallToActionButton, - Element: CustomCallToActionElement, - plugins: [ - // any plugins that are required by this element go here - ], - }, - ], - leaves: [ - 'bold', - 'italic', - { - name: 'highlight', - Button: CustomHighlightButton, - Leaf: CustomHighlightLeaf, - plugins: [ - // any plugins that are required by this leaf go here - ], - }, - ], - link: { - // Inject your own fields into the Link element - fields: [ + editor: slateEditor({ + admin: { + elements: [ + 'h2', + 'h3', + 'h4', + 'link', + 'blockquote', { - name: 'rel', - label: 'Rel Attribute', - type: 'select', - hasMany: true, - options: ['noopener', 'noreferrer', 'nofollow'], - }, - ], - }, - upload: { - collections: { - media: { - fields: [ - // any fields that you would like to save - // on an upload element in the `media` collection + name: 'cta', + Button: CustomCallToActionButton, + Element: CustomCallToActionElement, + plugins: [ + // any plugins that are required by this element go here ], }, + ], + leaves: [ + 'bold', + 'italic', + { + name: 'highlight', + Button: CustomHighlightButton, + Leaf: CustomHighlightLeaf, + plugins: [ + // any plugins that are required by this leaf go here + ], + }, + ], + link: { + // Inject your own fields into the Link element + fields: [ + { + name: 'rel', + label: 'Rel Attribute', + type: 'select', + hasMany: true, + options: ['noopener', 'noreferrer', 'nofollow'], + }, + ], + }, + upload: { + collections: { + media: { + fields: [ + // any fields that you would like to save + // on an upload element in the `media` collection + ], + }, + }, }, }, - }, + }), }, ], }