fix: styles readOnly RichTextEditor, removes interactivity within when readOnly

This commit is contained in:
Jarrod Flesch
2022-09-23 14:34:02 -04:00
parent b454811698
commit 918130486e
4 changed files with 80 additions and 7 deletions

View File

@@ -73,12 +73,46 @@ const RichTextFields: CollectionConfig = {
},
},
},
{
name: 'richTextReadOnly',
type: 'richText',
admin: {
readOnly: true,
link: {
fields: [
{
name: 'rel',
label: 'Rel Attribute',
type: 'select',
hasMany: true,
options: [
'noopener', 'noreferrer', 'nofollow',
],
admin: {
description: 'The rel attribute defines the relationship between a linked resource and the current document. This is a custom link field.',
},
},
],
},
upload: {
collections: {
uploads: {
fields: [
{
name: 'caption',
type: 'richText',
},
],
},
},
},
},
},
],
};
export const richTextDoc = {
selectHasMany: ['one', 'five'],
richText: [
function generateRichText() {
return [
{
children: [
{
@@ -220,7 +254,13 @@ export const richTextDoc = {
],
};
}),
],
];
}
export const richTextDoc = {
selectHasMany: ['one', 'five'],
richText: generateRichText(),
richTextReadOnly: generateRichText(),
};
export default RichTextFields;

View File

@@ -92,6 +92,7 @@ export default buildConfig({
const richTextUploadIndex = richTextDocWithRelationship.richText.findIndex(({ type }) => type === 'upload');
richTextDocWithRelationship.richText[richTextUploadIndex].value = { id: createdUploadDoc.id };
richTextDocWithRelationship.richTextReadOnly[richTextUploadIndex].value = { id: createdUploadDoc.id };
await payload.create({ collection: 'rich-text-fields', data: richTextDocWithRelationship });