Ticket #7584: 7584.patch
File 7584.patch, 6.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/liststyle/dialogs/liststyle.js
5 5 6 6 (function() 7 7 { 8 function getListElement( editor, listTag )9 {10 var range;11 try { range = editor.getSelection().getRanges()[ 0 ]; }12 catch( e ) { return null; }13 8 14 range.shrink( CKEDITOR.SHRINK_TEXT );15 return range.getCommonAncestor().getAscendant( listTag, 1 );16 }17 18 9 var mapListStyle = { 19 10 'a' : 'lower-alpha', 20 11 'A' : 'upper-alpha', … … 28 19 29 20 function listStyle( editor, startupPage ) 30 21 { 22 function targetElement() 23 { 24 var range = editor.getSelection().getRanges()[ 0 ]; 25 range.shrink( CKEDITOR.SHRINK_TEXT ); 26 var root = range.getCommonAncestor().getAscendant( startupPage == 'bulletedListStyle' ? 'ul' : 'ol', 1 ); 27 28 // Is list fully selected? Then list root mode. 29 if ( range.checkBoundaryOfElement( root, CKEDITOR.START ) && range.checkBoundaryOfElement( root, CKEDITOR.END ) ) 30 return root; 31 // Otherwise it's in list item mode. 32 else 33 { 34 var path = new CKEDITOR.dom.elementPath( range.startContainer ); 35 var elements = path.elements, element; 36 for ( var i = 0; i < elements.length; i++ ) 37 { 38 element = elements[ i ]; 39 if ( element.is( 'li' ) && element.getParent().equals( root ) ) 40 return element; 41 } 42 } 43 } 44 31 45 var lang = editor.lang.list; 32 46 if ( startupPage == 'bulletedListStyle' ) 33 47 { … … 77 91 ], 78 92 onShow: function() 79 93 { 80 var editor = this.getParentEditor(), 81 element = getListElement( editor, 'ul' ); 82 83 element && this.setupContent( element ); 94 this.element = targetElement(); 95 this.setupContent( this.element ); 84 96 }, 85 97 onOk: function() 86 98 { 87 var editor = this.getParentEditor(), 88 element = getListElement( editor, 'ul' ); 89 90 element && this.commitContent( element ); 99 this.commitContent( this.element ); 100 }, 101 onHide : function() 102 { 103 delete this.element; 91 104 } 92 105 }; 93 106 } … … 137 150 validate : CKEDITOR.dialog.validate.integer( lang.validateStartNumber ), 138 151 setup : function( element ) 139 152 { 140 var value = element.getAttribute( 'start' ) || 1;153 var value = element.getAttribute( element.is( 'li' ) ? 'value' : 'start' ) || 1; 141 154 value && this.setValue( value ); 142 155 }, 143 156 commit : function( element ) 144 157 { 145 element.setAttribute( 'start', this.getValue() );158 element.setAttribute( element.is( 'li' ) ? 'value' : 'start', this.getValue() ); 146 159 } 147 160 }, 148 161 { … … 176 189 ], 177 190 onShow: function() 178 191 { 179 var editor = this.getParentEditor(), 180 element = getListElement( editor, 'ol' ); 181 182 element && this.setupContent( element ); 192 this.element = targetElement(); 193 this.setupContent( this.element ); 183 194 }, 184 195 onOk: function() 185 196 { 186 var editor = this.getParentEditor(), 187 element = getListElement( editor, 'ol' ); 188 189 element && this.commitContent( element ); 197 this.commitContent( this.element ); 198 }, 199 onHide : function() 200 { 201 delete this.element; 190 202 } 191 203 }; 192 204 } -
_source/plugins/menu/plugin.js
114 114 if ( item.onClick ) 115 115 item.onClick(); 116 116 else if ( item.command ) 117 this.editor.execCommand( item.command );117 this.editor.execCommand( item.command, { fromMenu : item.name } ); 118 118 }, 119 119 120 120 onEscape : function( keystroke ) -
_source/lang/en.js
207 207 // List style dialog 208 208 list: 209 209 { 210 numberedTitle : 'Numbered List Properties', 211 bulletedTitle : 'Bulleted List Properties', 210 numberedTitle : 'Numbered List', 211 bulletedTitle : 'Bulleted List', 212 listRoot : 'List Properties', 213 listItem : 'List Item Properties', 212 214 type : 'Type', 213 215 start : 'Start', 214 216 validateStartNumber :'List start number must be a whole number.', -
_source/plugins/liststyle/plugin.js
10 10 requires : [ 'dialog' ], 11 11 init : function( editor ) 12 12 { 13 function anchoredList() 14 { 15 var sel = editor.getSelection(), 16 element = sel && sel.getStartElement(), 17 path = new CKEDITOR.dom.elementPath( element ).elements; 18 19 for ( var i = 0; i < path.length; i++ ) 20 { 21 element = path[ i ]; 22 if ( element.getName() in { ol : 1, ul : 1 } ) 23 return element; 24 } 25 } 26 27 editor.addCommand( 'listStyleEdit', 28 { 29 exec : function( editor, data ) 30 { 31 var list = anchoredList(); 32 if ( data.fromMenu == 'list_root' ) 33 editor.getSelection().selectElement( list ); 34 35 editor.openDialog( list.is( 'ol' )? 'numberedListStyle' : 'bulletedListStyle' ); 36 } 37 }); 38 13 39 editor.addCommand( 'numberedListStyle', new CKEDITOR.dialogCommand( 'numberedListStyle' ) ); 14 40 CKEDITOR.dialog.add( 'numberedListStyle', this.path + 'dialogs/liststyle.js' ); 15 41 editor.addCommand( 'bulletedListStyle', new CKEDITOR.dialogCommand( 'bulletedListStyle' ) ); 16 42 CKEDITOR.dialog.add( 'bulletedListStyle', this.path + 'dialogs/liststyle.js' ); 17 43 44 function subMenu() 45 { 46 return { 47 list_root : CKEDITOR.TRISTATE_OFF, 48 list_item : CKEDITOR.TRISTATE_OFF 49 }; 50 } 51 18 52 // If the "menu" plugin is loaded, register the menu items. 19 53 if ( editor.addMenuItems ) 20 54 { … … 27 61 { 28 62 label : editor.lang.list.numberedTitle, 29 63 group : 'list', 30 command: 'numberedListStyle'64 getItems : subMenu 31 65 }, 32 66 bulletedlist : 33 67 { 34 68 label : editor.lang.list.bulletedTitle, 35 69 group : 'list', 36 command: 'bulletedListStyle' 70 getItems : subMenu 71 }, 72 list_root : 73 { 74 label : editor.lang.list.listRoot, 75 group : 'list', 76 command: 'listStyleEdit', 77 order : 5 78 }, 79 list_item : 80 { 81 label : editor.lang.list.listItem, 82 group : 'list', 83 command: 'listStyleEdit', 84 order : 10 37 85 } 38 86 }); 39 87 }