Ticket #6305: 6305.patch
File 6305.patch, 3.4 KB (added by , 13 years ago) |
---|
-
_source/plugins/liststyle/dialogs/liststyle.js
1 /* 1 /* 2 2 * Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 3 3 * For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 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 14 range.shrink( CKEDITOR.SHRINK_TEXT );15 return range.getCommonAncestor().getAscendant( listTag, 1 );16 }17 18 8 var mapListStyle = { 19 9 'a' : 'lower-alpha', 20 10 'A' : 'upper-alpha', … … 78 68 onShow: function() 79 69 { 80 70 var editor = this.getParentEditor(), 81 element = getListElement( editor, 'ul' );71 element = CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ul' ); 82 72 83 73 element && this.setupContent( element ); 84 74 }, 85 75 onOk: function() 86 76 { 87 77 var editor = this.getParentEditor(), 88 element = getListElement( editor, 'ul' );78 element = CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ul' ); 89 79 90 80 element && this.commitContent( element ); 91 81 } … … 177 167 onShow: function() 178 168 { 179 169 var editor = this.getParentEditor(), 180 element = getListElement( editor, 'ol' );170 element = CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ol' ); 181 171 182 172 element && this.setupContent( element ); 183 173 }, 184 174 onOk: function() 185 175 { 186 176 var editor = this.getParentEditor(), 187 element = getListElement( editor, 'ol' );177 element = CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ol' ); 188 178 189 179 element && this.commitContent( element ); 190 180 } -
_source/plugins/liststyle/plugin.js
43 43 { 44 44 editor.contextMenu.addListener( function( element, selection ) 45 45 { 46 if ( !element || element.isReadOnly() ) 47 return null; 48 49 while ( element ) 50 { 51 var name = element.getName(); 52 if ( name == 'ol' ) 53 return { numberedlist: CKEDITOR.TRISTATE_OFF }; 54 else if ( name == 'ul' ) 55 return { bulletedlist: CKEDITOR.TRISTATE_OFF }; 56 57 element = element.getParent(); 58 } 59 return null; 60 }); 61 } 62 } 46 return CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ol' ) ? { numberedlist: CKEDITOR.TRISTATE_OFF } : 47 CKEDITOR.plugins.liststyle.getSelectedList( editor, 'ul' ) ? { bulletedlist: CKEDITOR.TRISTATE_OFF } : null; 48 }); 49 } 50 }, 51 getSelectedList : function( editor, listTag ) 52 { 53 try 54 { 55 var selection = editor.getSelection(), 56 start= selection.getStartElement(), 57 range = selection.getRanges()[ 0 ]; 58 } 59 catch( e ) { return null; } 60 61 if ( !start || start.isReadOnly() ) 62 return null; 63 64 range.shrink( CKEDITOR.SHRINK_TEXT ); 65 return range.getCommonAncestor().getAscendant( listTag, 1 ); 66 } 63 67 }; 64 68 65 69 CKEDITOR.plugins.add( 'liststyle', CKEDITOR.plugins.liststyle );