File tree Expand file tree Collapse file tree 6 files changed +56
-4
lines changed
packages/richtext-lexical/src/lexical
database/up-down-migration/migrations
lexical/collections/_LexicalFullyFeatured Expand file tree Collapse file tree 6 files changed +56
-4
lines changed Original file line number Diff line number Diff line change @@ -151,8 +151,8 @@ export default buildConfig({
151
151
prefillOnly: true ,
152
152
}
153
153
: false ,
154
- }
155
-
154
+ },
155
+
156
156
// highlight-end
157
157
})
158
158
```
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/ind
19
19
import { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'
20
20
import { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'
21
21
import { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'
22
+ import { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'
22
23
import { SlashMenuPlugin } from './plugins/SlashMenu/index.js'
23
24
import { TextPlugin } from './plugins/TextPlugin/index.js'
24
25
import { LexicalContentEditable } from './ui/ContentEditable.js'
@@ -111,6 +112,7 @@ export const LexicalEditor: React.FC<
111
112
< InsertParagraphAtEndPlugin />
112
113
< DecoratorPlugin />
113
114
< TextPlugin features = { editorConfig . features } />
115
+ < SelectAllPlugin />
114
116
< OnChangePlugin
115
117
// Selection changes can be ignored here, reducing the
116
118
// frequency that the FieldComponent and Payload receive updates.
Original file line number Diff line number Diff line change
1
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
2
+ import { $getSelection , COMMAND_PRIORITY_LOW , SELECT_ALL_COMMAND } from 'lexical'
3
+ import { useEffect } from 'react'
4
+
5
+ /**
6
+ * Allows to select inputs with `ctrl+a` or `cmd+a`.
7
+ * Required because Lexical preventDefault the event.
8
+ * see: https://github.com/payloadcms/payload/issues/6871
9
+ */
10
+ export function SelectAllPlugin ( ) {
11
+ const [ editor ] = useLexicalComposerContext ( )
12
+
13
+ useEffect ( ( ) => {
14
+ return editor . registerCommand (
15
+ SELECT_ALL_COMMAND ,
16
+ ( ) => {
17
+ const selection = $getSelection ( )
18
+ if ( selection ) {
19
+ return false
20
+ }
21
+ const activeElement = document . activeElement
22
+ if ( activeElement instanceof HTMLInputElement ) {
23
+ activeElement . select ( )
24
+ }
25
+ return true
26
+ } ,
27
+ COMMAND_PRIORITY_LOW ,
28
+ )
29
+ } , [ editor ] )
30
+
31
+ return null
32
+ }
Original file line number Diff line number Diff line change 1
- import type { MigrateDownArgs , MigrateUpArgs } from '@payloadcms/db-postgres' ;
1
+ import type { MigrateDownArgs , MigrateUpArgs } from '@payloadcms/db-postgres'
2
2
3
3
import { sql } from '@payloadcms/db-postgres'
4
4
Original file line number Diff line number Diff line change @@ -62,6 +62,24 @@ describe('Lexical Fully Featured', () => {
62
62
const paragraph = lexical . editor . locator ( '> p' )
63
63
await expect ( paragraph ) . toHaveText ( '' )
64
64
} )
65
+
66
+ test ( 'ControlOrMeta+A inside input should select all the text inside the input' , async ( {
67
+ page,
68
+ } ) => {
69
+ const lexical = new LexicalHelpers ( page )
70
+ await lexical . editor . first ( ) . focus ( )
71
+ await page . keyboard . type ( 'Hello' )
72
+ await page . keyboard . press ( 'Enter' )
73
+ await lexical . slashCommand ( 'block' )
74
+ await page . locator ( '#field-someText' ) . first ( ) . focus ( )
75
+ await page . keyboard . type ( 'World' )
76
+ await page . keyboard . press ( 'ControlOrMeta+A' )
77
+ await page . keyboard . press ( 'Backspace' )
78
+ const paragraph = lexical . editor . locator ( '> p' ) . first ( )
79
+ await expect ( paragraph ) . toHaveText ( 'Hello' )
80
+ await expect ( page . getByText ( 'World' ) ) . toHaveCount ( 0 )
81
+ } )
82
+
65
83
test ( 'text state feature' , async ( { page } ) => {
66
84
await page . keyboard . type ( 'Hello' )
67
85
await page . keyboard . press ( 'ControlOrMeta+A' )
Original file line number Diff line number Diff line change 31
31
}
32
32
],
33
33
"paths" : {
34
- "@payload-config" : [" ./test/query-presets /config.ts" ],
34
+ "@payload-config" : [" ./test/_community /config.ts" ],
35
35
"@payloadcms/admin-bar" : [" ./packages/admin-bar/src" ],
36
36
"@payloadcms/live-preview" : [" ./packages/live-preview/src" ],
37
37
"@payloadcms/live-preview-react" : [" ./packages/live-preview-react/src/index.ts" ],
You can’t perform that action at this time.
0 commit comments