diff --git a/packages/richtext-lexical/src/features/blocks/client/component/index.tsx b/packages/richtext-lexical/src/features/blocks/client/component/index.tsx index 5b17cda0a..a8e199079 100644 --- a/packages/richtext-lexical/src/features/blocks/client/component/index.tsx +++ b/packages/richtext-lexical/src/features/blocks/client/component/index.tsx @@ -507,7 +507,7 @@ export const BlockComponent: React.FC = (props) => { parentIndexPath="" parentPath="" // See Blocks feature path for details as for why this is empty parentSchemaPath={schemaFieldsPath} - permissions={permissions} + permissions={true} readOnly={false} /> {t('fields:saveChanges')} diff --git a/packages/richtext-lexical/src/features/blocks/client/componentInline/index.tsx b/packages/richtext-lexical/src/features/blocks/client/componentInline/index.tsx index b70761338..9df01e47f 100644 --- a/packages/richtext-lexical/src/features/blocks/client/componentInline/index.tsx +++ b/packages/richtext-lexical/src/features/blocks/client/componentInline/index.tsx @@ -417,7 +417,7 @@ export const InlineBlockComponent: React.FC = (props) => { parentIndexPath="" parentPath="" // See Blocks feature path for details as for why this is empty parentSchemaPath={schemaFieldsPath} - permissions={permissions} + permissions={true} readOnly={false} /> {t('fields:saveChanges')} diff --git a/packages/richtext-lexical/src/utilities/fieldsDrawer/DrawerContent.tsx b/packages/richtext-lexical/src/utilities/fieldsDrawer/DrawerContent.tsx index 0377ce112..b1d8f535f 100644 --- a/packages/richtext-lexical/src/utilities/fieldsDrawer/DrawerContent.tsx +++ b/packages/richtext-lexical/src/utilities/fieldsDrawer/DrawerContent.tsx @@ -37,7 +37,7 @@ export const DrawerContent: React.FC(false) const { - fieldProps: { featureClientSchemaMap, permissions }, + fieldProps: { featureClientSchemaMap }, } = useEditorConfigContext() const { getFormState } = useServerFunctions() @@ -155,7 +155,7 @@ export const DrawerContent: React.FC {t('fields:saveChanges')} diff --git a/test/fields/collections/Lexical/e2e/main/e2e.spec.ts b/test/fields/collections/Lexical/e2e/main/e2e.spec.ts index 64027d9fc..a6eb05fc8 100644 --- a/test/fields/collections/Lexical/e2e/main/e2e.spec.ts +++ b/test/fields/collections/Lexical/e2e/main/e2e.spec.ts @@ -1135,6 +1135,33 @@ describe('lexicalMain', () => { await expect(urlInput).toBeVisible() }) + test('ensure link drawer displays nested block fields if document does not have `create` permission', async () => { + await navigateToLexicalFields(true, 'lexical-access-control') + const richTextField = page.locator('.rich-text-lexical').first() + await richTextField.scrollIntoViewIfNeeded() + await expect(richTextField).toBeVisible() + + const link = richTextField.locator('.LexicalEditorTheme__link').first() + await link.scrollIntoViewIfNeeded() + await expect(link).toBeVisible() + await link.click({ + // eslint-disable-next-line playwright/no-force-option + force: true, + button: 'left', + }) + + await expect(page.locator('.link-edit')).toBeVisible() + await page.locator('.link-edit').click() + + const linkDrawer = page.locator('dialog[id^=drawer_1_lexical-rich-text-link-]').first() + await expect(linkDrawer).toBeVisible() + + const blockTextInput = linkDrawer.locator('#field-blocks__0__text').first() + + await expect(blockTextInput).toBeVisible() + await expect(blockTextInput).toBeEditable() + }) + test('lexical cursor / selection should be preserved when swapping upload field and clicking within with its list drawer', async () => { await navigateToLexicalFields() const richTextField = page.locator('.rich-text-lexical').first() @@ -1494,6 +1521,7 @@ describe('lexicalMain', () => { expect(htmlContent).not.toContain('Cargando...') expect(htmlContent).toContain('Start typing, or press') }) + // eslint-disable-next-line playwright/expect-expect, playwright/no-skipped-test test.skip('ensure simple localized lexical field works', async () => { await navigateToLexicalFields(true, 'lexical-localized-fields') }) diff --git a/test/fields/collections/LexicalAccessControl/index.ts b/test/fields/collections/LexicalAccessControl/index.ts index db015bb9a..7863c76e7 100644 --- a/test/fields/collections/LexicalAccessControl/index.ts +++ b/test/fields/collections/LexicalAccessControl/index.ts @@ -1,6 +1,6 @@ import type { CollectionConfig } from 'payload' -import { defaultEditorFeatures, lexicalEditor } from '@payloadcms/richtext-lexical' +import { defaultEditorFeatures, lexicalEditor, LinkFeature } from '@payloadcms/richtext-lexical' import { lexicalAccessControlSlug } from '../../slugs.js' @@ -22,7 +22,29 @@ export const LexicalAccessControl: CollectionConfig = { name: 'richText', type: 'richText', editor: lexicalEditor({ - features: [...defaultEditorFeatures], + features: [ + ...defaultEditorFeatures, + LinkFeature({ + fields: ({ defaultFields }) => [ + ...defaultFields, + { + name: 'blocks', + type: 'blocks', + blocks: [ + { + slug: 'block', + fields: [ + { + name: 'text', + type: 'text', + }, + ], + }, + ], + }, + ], + }), + ], }), }, ], diff --git a/test/fields/seed.ts b/test/fields/seed.ts index ead7d9100..65510dcc3 100644 --- a/test/fields/seed.ts +++ b/test/fields/seed.ts @@ -591,7 +591,67 @@ export const seed = async (_payload: Payload) => { await _payload.create({ collection: 'lexical-access-control', data: { - richText: textToLexicalJSON({ text: 'text' }), + richText: { + root: { + children: [ + { + children: [ + { + detail: 0, + format: 0, + mode: 'normal', + style: '', + text: 'text ', + type: 'text', + version: 1, + }, + { + children: [ + { + detail: 0, + format: 0, + mode: 'normal', + style: '', + text: 'link', + type: 'text', + version: 1, + }, + ], + direction: 'ltr', + format: '', + indent: 0, + type: 'link', + version: 3, + fields: { + url: 'https://', + newTab: false, + linkType: 'custom', + blocks: [ + { + id: '67e45673cbd5181ca8cbeef7', + blockType: 'block', + }, + ], + }, + id: '67e4566fcbd5181ca8cbeef5', + }, + ], + direction: 'ltr', + format: '', + indent: 0, + type: 'paragraph', + version: 1, + textFormat: 0, + textStyle: '', + }, + ], + direction: 'ltr', + format: '', + indent: 0, + type: 'root', + version: 1, + }, + }, title: 'title', }, depth: 0,