@@ -8,7 +8,7 @@ import { useMemo } from 'react'
8
8
9
9
import type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'
10
10
import type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'
11
- import type { PluginComponentWithAnchor } from '../../../../typesClient.js'
11
+ import type { PluginComponent } from '../../../../typesClient.js'
12
12
import type { ToolbarGroup , ToolbarGroupItem } from '../../../types.js'
13
13
import type { FixedToolbarFeatureProps } from '../../server/index.js'
14
14
@@ -58,7 +58,7 @@ function ToolbarGroupComponent({
58
58
group : ToolbarGroup
59
59
index : number
60
60
} ) : React . ReactNode {
61
- const { i18n } = useTranslation ( )
61
+ const { i18n } = useTranslation < { } , string > ( )
62
62
const {
63
63
fieldProps : { featureClientSchemaMap, schemaPath } ,
64
64
} = useEditorConfigContext ( )
@@ -106,9 +106,8 @@ function ToolbarGroupComponent({
106
106
107
107
return (
108
108
< div className = { `fixed-toolbar__group fixed-toolbar__group-${ group . key } ` } key = { group . key } >
109
- { group . type === 'dropdown' &&
110
- group . items . length &&
111
- ( DropdownIcon ? (
109
+ { group . type === 'dropdown' && group . items . length ? (
110
+ DropdownIcon ? (
112
111
< ToolbarDropdown
113
112
anchorElem = { anchorElem }
114
113
editor = { editor }
@@ -129,14 +128,15 @@ function ToolbarGroupComponent({
129
128
maxActiveItems = { 1 }
130
129
onActiveChange = { onActiveChange }
131
130
/>
132
- ) ) }
133
- { group . type === 'buttons' &&
134
- group . items . length &&
135
- group . items . map ( ( item ) => {
136
- return (
137
- < ButtonGroupItem anchorElem = { anchorElem } editor = { editor } item = { item } key = { item . key } />
138
- )
139
- } ) }
131
+ )
132
+ ) : null }
133
+ { group . type === 'buttons' && group . items . length
134
+ ? group . items . map ( ( item ) => {
135
+ return (
136
+ < ButtonGroupItem anchorElem = { anchorElem } editor = { editor } item = { item } key = { item . key } />
137
+ )
138
+ } )
139
+ : null }
140
140
{ index < editorConfig . features . toolbarFixed ?. groups . length - 1 && < div className = "divider" /> }
141
141
</ div >
142
142
)
@@ -196,14 +196,18 @@ function FixedToolbar({
196
196
)
197
197
198
198
if ( overlapping ) {
199
- currentToolbarElem . className = 'fixed-toolbar fixed-toolbar--overlapping'
200
- parentToolbarElem . className = 'fixed-toolbar fixed-toolbar--hide'
199
+ currentToolbarElem . classList . remove ( 'fixed-toolbar' )
200
+ currentToolbarElem . classList . add ( 'fixed-toolbar' , 'fixed-toolbar--overlapping' )
201
+ parentToolbarElem . classList . remove ( 'fixed-toolbar' )
202
+ parentToolbarElem . classList . add ( 'fixed-toolbar' , 'fixed-toolbar--hide' )
201
203
} else {
202
204
if ( ! currentToolbarElem . classList . contains ( 'fixed-toolbar--overlapping' ) ) {
203
205
return
204
206
}
205
- currentToolbarElem . className = 'fixed-toolbar'
206
- parentToolbarElem . className = 'fixed-toolbar'
207
+ currentToolbarElem . classList . remove ( 'fixed-toolbar--overlapping' )
208
+ currentToolbarElem . classList . add ( 'fixed-toolbar' )
209
+ parentToolbarElem . classList . remove ( 'fixed-toolbar--hide' )
210
+ parentToolbarElem . classList . add ( 'fixed-toolbar' )
207
211
}
208
212
} ,
209
213
50 ,
@@ -256,10 +260,7 @@ const getParentEditorWithFixedToolbar = (
256
260
return false
257
261
}
258
262
259
- export const FixedToolbarPlugin : PluginComponentWithAnchor < FixedToolbarFeatureProps > = ( {
260
- anchorElem,
261
- clientProps,
262
- } ) => {
263
+ export const FixedToolbarPlugin : PluginComponent < FixedToolbarFeatureProps > = ( { clientProps } ) => {
263
264
const [ currentEditor ] = useLexicalComposerContext ( )
264
265
const editorConfigContext = useEditorConfigContext ( )
265
266
@@ -287,7 +288,7 @@ export const FixedToolbarPlugin: PluginComponentWithAnchor<FixedToolbarFeaturePr
287
288
288
289
return (
289
290
< FixedToolbar
290
- anchorElem = { anchorElem }
291
+ anchorElem = { document . body }
291
292
editor = { editor }
292
293
editorConfig = { editorConfig }
293
294
parentWithFixedToolbar = { parentWithFixedToolbar }
0 commit comments