@@ -55,87 +55,83 @@ export function Toolbar({
55
55
const relationship = useContext ( DocumentFieldRelationshipsContext ) ;
56
56
const blockComponent = useContext ( ComponentBlockContext ) ;
57
57
const hasBlockItems = Object . entries ( relationship ) . length || Object . keys ( blockComponent ) . length ;
58
-
58
+ const hasMarks = Object . values ( documentFeatures . formatting . inlineMarks ) . some ( x => x ) ;
59
59
return (
60
60
< ToolbarContainer >
61
- { ! ! documentFeatures . formatting . headingLevels . length && (
62
- < Fragment >
61
+ < ToolbarGroup >
62
+ { ! ! documentFeatures . formatting . headingLevels . length && (
63
63
< HeadingMenu headingLevels = { documentFeatures . formatting . headingLevels } />
64
- < ToolbarSeparator />
65
- </ Fragment >
66
- ) }
67
- { Object . values ( documentFeatures . formatting . inlineMarks ) . some ( x => x ) && (
68
- < Fragment >
69
- < InlineMarks marks = { documentFeatures . formatting . inlineMarks } />
70
- < ToolbarSeparator />
71
- </ Fragment >
72
- ) }
73
- { ( documentFeatures . formatting . alignment . center ||
74
- documentFeatures . formatting . alignment . end ) && (
75
- < TextAlignMenu alignment = { documentFeatures . formatting . alignment } />
76
- ) }
77
- { documentFeatures . formatting . listTypes . unordered && (
78
- < Tooltip
79
- content = {
80
- < Fragment >
81
- Bullet List < KeyboardInTooltip > - </ KeyboardInTooltip >
82
- </ Fragment >
83
- }
84
- weight = "subtle"
85
- >
86
- { attrs => (
87
- < ListButton type = "unordered-list" { ...attrs } >
88
- < BulletListIcon />
89
- </ ListButton >
90
- ) }
91
- </ Tooltip >
92
- ) }
93
- { documentFeatures . formatting . listTypes . ordered && (
94
- < Tooltip
95
- content = {
96
- < Fragment >
97
- Numbered List < KeyboardInTooltip > 1. </ KeyboardInTooltip >
98
- </ Fragment >
99
- }
100
- weight = "subtle"
101
- >
102
- { attrs => (
103
- < ListButton type = "ordered-list" { ...attrs } >
104
- < NumberedListIcon />
105
- </ ListButton >
106
- ) }
107
- </ Tooltip >
108
- ) }
109
- { ( documentFeatures . formatting . alignment . center ||
110
- documentFeatures . formatting . alignment . end ||
111
- documentFeatures . formatting . listTypes . unordered ||
112
- documentFeatures . formatting . listTypes . ordered ) && < ToolbarSeparator /> }
113
-
114
- { documentFeatures . dividers && dividerButton }
115
- { documentFeatures . links && linkButton }
116
- { documentFeatures . formatting . blockTypes . blockquote && blockquoteButton }
117
- { ! ! documentFeatures . layouts . length && < LayoutsButton layouts = { documentFeatures . layouts } /> }
118
- { documentFeatures . formatting . blockTypes . code && codeButton }
119
- { ! ! hasBlockItems && < InsertBlockMenu /> }
64
+ ) }
65
+ { hasMarks && < InlineMarks marks = { documentFeatures . formatting . inlineMarks } /> }
66
+ { hasMarks && < ToolbarSeparator /> }
67
+ { ( documentFeatures . formatting . alignment . center ||
68
+ documentFeatures . formatting . alignment . end ) && (
69
+ < TextAlignMenu alignment = { documentFeatures . formatting . alignment } />
70
+ ) }
71
+ { documentFeatures . formatting . listTypes . unordered && (
72
+ < Tooltip
73
+ content = {
74
+ < Fragment >
75
+ Bullet List < KeyboardInTooltip > - </ KeyboardInTooltip >
76
+ </ Fragment >
77
+ }
78
+ weight = "subtle"
79
+ >
80
+ { attrs => (
81
+ < ListButton type = "unordered-list" { ...attrs } >
82
+ < BulletListIcon />
83
+ </ ListButton >
84
+ ) }
85
+ </ Tooltip >
86
+ ) }
87
+ { documentFeatures . formatting . listTypes . ordered && (
88
+ < Tooltip
89
+ content = {
90
+ < Fragment >
91
+ Numbered List < KeyboardInTooltip > 1. </ KeyboardInTooltip >
92
+ </ Fragment >
93
+ }
94
+ weight = "subtle"
95
+ >
96
+ { attrs => (
97
+ < ListButton type = "ordered-list" { ...attrs } >
98
+ < NumberedListIcon />
99
+ </ ListButton >
100
+ ) }
101
+ </ Tooltip >
102
+ ) }
103
+ { ( documentFeatures . formatting . alignment . center ||
104
+ documentFeatures . formatting . alignment . end ||
105
+ documentFeatures . formatting . listTypes . unordered ||
106
+ documentFeatures . formatting . listTypes . ordered ) && < ToolbarSeparator /> }
120
107
121
- < ToolbarSeparator />
108
+ { documentFeatures . dividers && dividerButton }
109
+ { documentFeatures . links && linkButton }
110
+ { documentFeatures . formatting . blockTypes . blockquote && blockquoteButton }
111
+ { ! ! documentFeatures . layouts . length && < LayoutsButton layouts = { documentFeatures . layouts } /> }
112
+ { documentFeatures . formatting . blockTypes . code && codeButton }
113
+ { ! ! hasBlockItems && < InsertBlockMenu /> }
114
+ </ ToolbarGroup >
122
115
{ useMemo ( ( ) => {
123
116
const ExpandIcon = viewState ?. expanded ? Minimize2Icon : Maximize2Icon ;
124
117
return (
125
118
viewState && (
126
- < Tooltip content = { viewState . expanded ? 'Collapse' : 'Expand' } weight = "subtle" >
127
- { attrs => (
128
- < ToolbarButton
129
- onMouseDown = { event => {
130
- event . preventDefault ( ) ;
131
- viewState . toggle ( ) ;
132
- } }
133
- { ...attrs }
134
- >
135
- < ExpandIcon size = "small" />
136
- </ ToolbarButton >
137
- ) }
138
- </ Tooltip >
119
+ < ToolbarGroup >
120
+ < ToolbarSeparator />
121
+ < Tooltip content = { viewState . expanded ? 'Collapse' : 'Expand' } weight = "subtle" >
122
+ { attrs => (
123
+ < ToolbarButton
124
+ onMouseDown = { event => {
125
+ event . preventDefault ( ) ;
126
+ viewState . toggle ( ) ;
127
+ } }
128
+ { ...attrs }
129
+ >
130
+ < ExpandIcon size = "small" />
131
+ </ ToolbarButton >
132
+ ) }
133
+ </ Tooltip >
134
+ </ ToolbarGroup >
139
135
)
140
136
) ;
141
137
} , [ viewState ] ) }
@@ -182,16 +178,28 @@ const ToolbarContainer = ({ children }: { children: ReactNode }) => {
182
178
return (
183
179
< div
184
180
css = { {
185
- backgroundColor : colors . background ,
186
- boxShadow : `0 1px ${ colors . border } , 0 -1px ${ colors . border } ` ,
187
- paddingBottom : spacing . small ,
188
- paddingTop : spacing . small ,
181
+ borderBottom : `1px solid ${ colors . border } ` ,
182
+ background : colors . background ,
189
183
position : 'sticky' ,
190
184
top : 0 ,
191
185
zIndex : 2 ,
186
+ borderTopLeftRadius : 'inherit' ,
187
+ borderTopRightRadius : 'inherit' ,
192
188
} }
193
189
>
194
- < ToolbarGroup > { children } </ ToolbarGroup >
190
+ < div
191
+ css = { {
192
+ display : 'flex' ,
193
+ flexDirection : 'row' ,
194
+ justifyContent : 'space-between' ,
195
+ alignItems : 'center' ,
196
+ height : 40 ,
197
+ paddingLeft : spacing . xsmall ,
198
+ paddingRight : spacing . xsmall ,
199
+ } }
200
+ >
201
+ { children }
202
+ </ div >
195
203
</ div >
196
204
) ;
197
205
} ;
@@ -487,7 +495,7 @@ function MoreFormattingDialog({
487
495
return (
488
496
< InlineDialog
489
497
onMouseDown = { event => {
490
- if ( ( event . target as any ) . nodeName === 'BUTTON' ) {
498
+ if ( event . target instanceof HTMLElement && event . target . closest ( 'button' ) ) {
491
499
onCloseMenu ( ) ;
492
500
}
493
501
} }
0 commit comments