File tree Expand file tree Collapse file tree
demos/custom-ui/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,12 @@ export function ContextMenuRegistrations({ decided, onComposeComment }: Props) {
9292 // browser's native menu is suppressed there. Without these
9393 // entries the menu would be empty whenever the click isn't over a
9494 // tracked change or comment.
95+ // Bold / Italic stay available on a collapsed selection: toggling
96+ // a mark with no range applies it to the cursor's stored marks
97+ // so the next typed character picks up the formatting. Same UX
98+ // Word and Google Docs offer on right-click. Gate on
99+ // `selection.target` so we don't surface them when the editor
100+ // isn't focused at all.
95101 const bold = ui . commands . register ( {
96102 id : 'demo.bold' ,
97103 execute : ( ) => {
@@ -102,7 +108,7 @@ export function ContextMenuRegistrations({ decided, onComposeComment }: Props) {
102108 label : 'Bold' ,
103109 group : 'format' ,
104110 order : 0 ,
105- when : ( { selection } ) => ! selection . empty ,
111+ when : ( { selection } ) => selection . target !== null ,
106112 } ,
107113 } ) ;
108114 const italic = ui . commands . register ( {
@@ -115,7 +121,7 @@ export function ContextMenuRegistrations({ decided, onComposeComment }: Props) {
115121 label : 'Italic' ,
116122 group : 'format' ,
117123 order : 1 ,
118- when : ( { selection } ) => ! selection . empty ,
124+ when : ( { selection } ) => selection . target !== null ,
119125 } ,
120126 } ) ;
121127 const copy = ui . commands . register ( {
You can’t perform that action at this time.
0 commit comments