-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathindex.ts
51 lines (47 loc) · 1.74 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import type { ToolbarGroup } from '../../types.js'
import { createServerFeature } from '../../../../utilities/createServerFeature.js'
export type FixedToolbarFeatureProps = {
/**
* @default false
*
* If this is enabled, the toolbar will apply to the focused editor, not the editor with the FixedToolbarFeature.
*
* This means that if the editor has a child-editor, and the child-editor is focused, the toolbar will apply to the child-editor, not the parent editor with this feature added.
*/
applyToFocusedEditor?: boolean
/**
* Custom configurations for toolbar groups
* Key is the group key (e.g. 'format', 'indent', 'align')
* Value is a partial ToolbarGroup object that will be merged with the default configuration
*/
customGroups?: Record<string, Partial<ToolbarGroup>>
/**
* @default false
*
* If there is a parent editor with a fixed toolbar, this will disable the toolbar for this editor.
*/
disableIfParentHasFixedToolbar?: boolean
}
export const FixedToolbarFeature = createServerFeature<
FixedToolbarFeatureProps,
FixedToolbarFeatureProps,
FixedToolbarFeatureProps
>({
feature: ({ props }) => {
const sanitizedProps: FixedToolbarFeatureProps = {
applyToFocusedEditor:
props?.applyToFocusedEditor === undefined ? false : props.applyToFocusedEditor,
customGroups: props?.customGroups,
disableIfParentHasFixedToolbar:
props?.disableIfParentHasFixedToolbar === undefined
? false
: props.disableIfParentHasFixedToolbar,
}
return {
ClientFeature: '@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient',
clientFeatureProps: sanitizedProps,
sanitizedServerFeatureProps: sanitizedProps,
}
},
key: 'toolbarFixed',
})