@@ -11,6 +11,7 @@ import { IconMenu, IconPlus } from '@codexteam/icons';
1111import { BlockHovered } from '../../events/BlockHovered' ;
1212import { beautifyShortcut } from '../../utils' ;
1313import { getKeyboardKeyForCode } from '../../utils/keyboard' ;
14+ import Selection from '../../selection' ;
1415
1516/**
1617 * @todo Tab on non-empty block should open Block Settings of the hoveredBlock (not where caret is set)
@@ -233,6 +234,13 @@ export default class Toolbar extends Module<ToolbarNodes> {
233234 this . enableModuleBindings ( ) ;
234235 } , { timeout : 2000 } ) ;
235236 } else {
237+ const { BlockDragNDrop } = this . Editor ;
238+ const dragHandle = this . nodes . settingsToggler ;
239+
240+ if ( dragHandle != null ) {
241+ BlockDragNDrop . disableDragHandleModuleBindings ( dragHandle ) ;
242+ }
243+
236244 this . destroy ( ) ;
237245 this . Editor . BlockSettings . destroy ( ) ;
238246 this . disableModuleBindings ( ) ;
@@ -469,18 +477,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
469477
470478 $ . append ( this . nodes . actions , this . nodes . settingsToggler ) ;
471479
472- const blockTunesTooltip = $ . make ( 'div' ) ;
473- const blockTunesTooltipEl = $ . text ( I18n . ui ( I18nInternalNS . ui . blockTunes . toggler , 'Click to tune' ) ) ;
474- const slashRealKey = await getKeyboardKeyForCode ( 'Slash' , '/' ) ;
475-
476- blockTunesTooltip . appendChild ( blockTunesTooltipEl ) ;
477- blockTunesTooltip . appendChild ( $ . make ( 'div' , this . CSS . plusButtonShortcut , {
478- textContent : beautifyShortcut ( `CMD + ${ slashRealKey } ` ) ,
479- } ) ) ;
480-
481- tooltip . onHover ( this . nodes . settingsToggler , blockTunesTooltip , {
482- hidingDelay : 400 ,
483- } ) ;
480+ await this . makeSettingsTogglerTooltip ( ) ;
484481
485482 /**
486483 * Appending Toolbar components to itself
@@ -494,6 +491,39 @@ export default class Toolbar extends Module<ToolbarNodes> {
494491 $ . append ( this . Editor . UI . nodes . wrapper , this . nodes . wrapper ) ;
495492 }
496493
494+ /**
495+ * Creates and configures a tooltip for the settings toggler button in the toolbar.
496+ *
497+ * @returns {Promise<void> } A promise that resolves when the tooltip is successfully created.
498+ */
499+ private async makeSettingsTogglerTooltip ( ) : Promise < void > {
500+ const { BlockDragNDrop } = this . Editor ;
501+ const tooltipTextParts : string [ ] = [
502+ I18n . ui ( I18nInternalNS . ui . blockTunes . toggler , 'Click to tune' ) ,
503+ ] ;
504+
505+ if ( BlockDragNDrop . isEnabled ) {
506+ tooltipTextParts . push (
507+ I18n . ui ( I18nInternalNS . ui . blockTunes . toggler , 'or drag to move' )
508+ ) ;
509+ }
510+
511+ const blockTunesTooltip = $ . make ( 'div' ) ;
512+ const blockTunesTooltipEl = $ . text ( tooltipTextParts . join ( ' ' ) ) ;
513+ const slashRealKey = await getKeyboardKeyForCode ( 'Slash' , '/' ) ;
514+
515+ blockTunesTooltip . appendChild ( blockTunesTooltipEl ) ;
516+ blockTunesTooltip . appendChild (
517+ $ . make ( 'div' , this . CSS . plusButtonShortcut , {
518+ textContent : beautifyShortcut ( `CMD + ${ slashRealKey } ` ) ,
519+ } )
520+ ) ;
521+
522+ tooltip . onHover ( this . nodes . settingsToggler , blockTunesTooltip , {
523+ hidingDelay : 400 ,
524+ } ) ;
525+ }
526+
497527 /**
498528 * Creates the Toolbox instance and return it's rendered element
499529 */
@@ -598,6 +628,28 @@ export default class Toolbar extends Module<ToolbarNodes> {
598628 this . moveAndOpen ( data . block ) ;
599629 } ) ;
600630 }
631+
632+ const { BlockDragNDrop } = this . Editor ;
633+ const dragHandle = this . nodes . settingsToggler ;
634+
635+ if ( dragHandle != null ) {
636+ const { dragstart, dragend } = BlockDragNDrop . getDragHandleModuleBindings ( dragHandle ) ;
637+
638+ this . readOnlyMutableListeners . on (
639+ dragHandle ,
640+ 'dragstart' ,
641+ ( event ) => dragstart ( event , ( ) => this . hoveredBlock ) ,
642+ true
643+ ) ;
644+ this . readOnlyMutableListeners . on (
645+ dragHandle ,
646+ 'dragend' ,
647+ ( ) => dragend ( ) ,
648+ true
649+ ) ;
650+
651+ this . makeSettingsTogglerTooltip ( ) ;
652+ }
601653 }
602654
603655 /**
0 commit comments