Relationships and SlateJS #86
-
Hey guys, I'm looking to create a "CTA" block for editors to add buttons into rich text fields and I have a couple of notes/questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Yo Richard, There are a few ways to do what you are looking for! To answer your first question, yes, you can use Relationships to link to existing documents within the Rich Text field. For this to work, you need to do a few things:
{
name: 'richTextDemo',
type: 'richText',
label: 'Rich Text Demo',
admin: {
elements: [
'h2',
'h3',
'relationship', // <- check it out
],
},
}, The above config will give you a new icon in your toolbar that looks like a little "open in new tab" icon, that, when clicked, allows you to choose a related document, which will be displayed in the Rich Text editor like this:: Alternatively, if you want to get a bit more specific and intentional, you should check out our demo app's Rich Text collection which actually shows an example for how to add your own custom What do you think? PS: we'll definitely improve the docs here because I personally think the above patterns are super cool! |
Beta Was this translation helpful? Give feedback.
Yo Richard,
There are a few ways to do what you are looking for!
To answer your first question, yes, you can use Relationships to link to existing documents within the Rich Text field. For this to work, you need to do a few things:
enableRichTextRelationship
totrue
within that collection'sadmin
options - see here for an example in our demo app'relationship'
field type within the rich text field'sadmin.elements
property like this: