@@ -65,11 +65,29 @@ define([
6565 *
6666 **/
6767 var _actions = {
68+ 'toggle-cell-rtl-layout' : {
69+ cmd : i18n . msg . _ ( 'toggle current cell ltr/rtl direction' ) ,
70+ help : i18n . msg . _ ( 'Toggle current cell directionality between left-to-right and right-to-left' ) ,
71+ handler : function ( env ) {
72+ var notebook_direction = document . body . getAttribute ( 'dir' ) == 'rtl' ? 'rtl' : 'ltr' ;
73+ var current_cell_default_direction = env . notebook . get_selected_cell ( ) . cell_type == 'code' ? 'ltr' : notebook_direction ;
74+ var current_cell_direction = env . notebook . get_selected_cell ( ) . metadata . direction || current_cell_default_direction ;
75+ var new_direction = current_cell_direction == 'rtl' ? 'ltr' : 'rtl' ;
76+ env . notebook . get_selected_cells ( ) . forEach (
77+ function ( cell ) { cell . metadata . direction = new_direction ; }
78+ ) ;
79+ env . notebook . set_dirty ( true ) ;
80+ env . notebook . apply_directionality ( ) ;
81+ }
82+ } ,
6883 'toggle-rtl-layout' : {
69- cmd : i18n . msg . _ ( 'toggle rtl layout' ) ,
70- help : i18n . msg . _ ( 'Toggle the screen directionality between left-to-right and right-to-left' ) ,
71- handler : function ( ) {
72- ( document . body . getAttribute ( 'dir' ) == 'rtl' ) ? document . body . setAttribute ( 'dir' , 'ltr' ) : document . body . setAttribute ( 'dir' , 'rtl' ) ;
84+ cmd : i18n . msg . _ ( 'toggle notebook ltr/rtl direction' ) ,
85+ help : i18n . msg . _ ( 'Toggle notebook directionality between left-to-right and right-to-left' ) ,
86+ handler : function ( env ) {
87+ var new_direction = document . body . getAttribute ( 'dir' ) == 'rtl' ? 'ltr' : 'rtl' ;
88+ env . notebook . metadata . direction = new_direction ;
89+ env . notebook . set_dirty ( true ) ;
90+ env . notebook . apply_directionality ( ) ;
7391 }
7492 } ,
7593 'edit-command-mode-keyboard-shortcuts' : {
0 commit comments