feat: collection admin.enableRichTextLink property (#2560)
This commit is contained in:
committed by
GitHub
parent
1d58007606
commit
967899229f
@@ -75,6 +75,7 @@ You can customize the way that the Admin panel behaves on a collection-by-collec
|
||||
| `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
|
||||
| `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
|
||||
| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this collection. |
|
||||
| `enableRichTextLink` | The [Rich Text](/docs/fields/rich-text) field features a `Link` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
|
||||
| `enableRichTextRelationship` | The [Rich Text](/docs/fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
|
||||
| `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
|
||||
| `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
|
||||
|
||||
@@ -108,7 +108,7 @@ Similar to the `relationship` element, the `upload` element is a user-friendly w
|
||||
|
||||
<Banner type="success">
|
||||
<strong>Tip:</strong><br/>
|
||||
Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin option of <strong>enableRichTextRelationship</strong> to false.
|
||||
Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and <strong>enableRichTextRelationship</strong> to false.
|
||||
</Banner>
|
||||
|
||||
Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
|
||||
|
||||
@@ -56,7 +56,7 @@ export const getBaseFields = (config: Config): Field[] => [
|
||||
label: translations['fields:chooseDocumentToLink'],
|
||||
type: 'relationship',
|
||||
required: true,
|
||||
relationTo: config.collections.map(({ slug }) => slug),
|
||||
relationTo: config.collections.filter(({ admin: { enableRichTextLink } }) => enableRichTextLink).map(({ slug }) => slug),
|
||||
admin: {
|
||||
condition: ({ linkType }) => {
|
||||
return linkType === 'internal';
|
||||
|
||||
@@ -12,6 +12,7 @@ export const defaults = {
|
||||
admin: {
|
||||
useAsTitle: 'id',
|
||||
components: {},
|
||||
enableRichTextLink: true,
|
||||
enableRichTextRelationship: true,
|
||||
pagination: {
|
||||
defaultLimit: 10,
|
||||
|
||||
@@ -56,6 +56,7 @@ const collectionSchema = joi.object().keys({
|
||||
hooks: joi.object({
|
||||
beforeDuplicate: joi.func(),
|
||||
}),
|
||||
enableRichTextLink: joi.boolean(),
|
||||
enableRichTextRelationship: joi.boolean(),
|
||||
components: joi.object({
|
||||
views: joi.object({
|
||||
|
||||
@@ -228,6 +228,7 @@ export type CollectionAdminOptions = {
|
||||
defaultLimit?: number
|
||||
limits?: number[]
|
||||
}
|
||||
enableRichTextLink?: boolean
|
||||
enableRichTextRelationship?: boolean
|
||||
/**
|
||||
* Function to generate custom preview URL
|
||||
|
||||
@@ -10,6 +10,9 @@ export const arrayFieldsSlug = 'array-fields';
|
||||
|
||||
const ArrayFields: CollectionConfig = {
|
||||
slug: arrayFieldsSlug,
|
||||
admin: {
|
||||
enableRichTextLink: false,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'items',
|
||||
|
||||
@@ -511,6 +511,23 @@ describe('fields', () => {
|
||||
await expect(menu).not.toContainText('Uploads3');
|
||||
});
|
||||
|
||||
test('should only list RTE enabled collections in link drawer', async () => {
|
||||
await navigateToRichTextFields();
|
||||
|
||||
await page.locator('.rich-text__toolbar button:not([disabled]) .link').first().click();
|
||||
|
||||
const editLinkModal = await page.locator('[id^=drawer_1_rich-text-link-]');
|
||||
await expect(editLinkModal).toBeVisible();
|
||||
|
||||
await editLinkModal.locator('label[for="field-linkType-internal"]').click();
|
||||
await editLinkModal.locator('.relationship__wrap .rs__control').click();
|
||||
|
||||
const menu = page.locator('.relationship__wrap .rs__menu');
|
||||
|
||||
// array-fields has enableRichTextLink set to false
|
||||
await expect(menu).not.toContainText('Array Fields');
|
||||
});
|
||||
|
||||
test('should only list non-upload collections in relationship drawer', async () => {
|
||||
await navigateToRichTextFields();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user