X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Felementspath%2Fplugin.js;h=58cacc3397a1915e70ec789b1b0a6208eb94e10f;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=30c72c99db31d713b773ecaf7b69ac00caea1314;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/elementspath/plugin.js b/_source/plugins/elementspath/plugin.js index 30c72c9..58cacc3 100644 --- a/_source/plugins/elementspath/plugin.js +++ b/_source/plugins/elementspath/plugin.js @@ -44,62 +44,83 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var idBase = 'cke_elementspath_' + CKEDITOR.tools.getNextNumber() + '_'; - editor._.elementsPath = { idBase : idBase }; + editor._.elementsPath = { idBase : idBase, filters : [] }; editor.on( 'themeSpace', function( event ) { if ( event.data.space == 'bottom' ) - event.data.html += '
' + emptyHtml + '
'; + { + event.data.html += + '' + editor.lang.elementsPath.eleLabel + '' + + '
' + emptyHtml + '
'; + } }); editor.on( 'selectionChange', function( ev ) { - var env = CKEDITOR.env; - - var selection = ev.data.selection; - - var element = selection.getStartElement(), + var env = CKEDITOR.env, + selection = ev.data.selection, + element = selection.getStartElement(), html = [], - elementsList = this._.elementsPath.list = []; + editor = ev.editor, + elementsList = editor._.elementsPath.list = [], + filters = editor._.elementsPath.filters; while ( element ) { - var index = elementsList.push( element ) - 1; - var name; - if ( element.getAttribute( '_cke_real_element_type' ) ) - name = element.getAttribute( '_cke_real_element_type' ); - else - name = element.getName(); - - // Use this variable to add conditional stuff to the - // HTML (because we are doing it in reverse order... unshift). - var extra = ''; - - // Some browsers don't cancel key events in the keydown but in the - // keypress. - // TODO: Check if really needed for Gecko+Mac. - if ( env.opera || ( env.gecko && env.mac ) ) - extra += ' onkeypress="return false;"'; - - // With Firefox, we need to force the button to redraw, otherwise it - // will remain in the focus state. - if ( env.gecko ) - extra += ' onblur="this.style.cssText = this.style.cssText;"'; - - html.unshift( - '', - name, - '' ); + var ignore = 0; + for ( var i = 0; i < filters.length; i++ ) + { + if ( filters[ i ]( element ) === false ) + { + ignore = 1; + break; + } + } + + if ( !ignore ) + { + var index = elementsList.push( element ) - 1; + var name; + if ( element.getAttribute( '_cke_real_element_type' ) ) + name = element.getAttribute( '_cke_real_element_type' ); + else + name = element.getName(); + + // Use this variable to add conditional stuff to the + // HTML (because we are doing it in reverse order... unshift). + var extra = ''; + + // Some browsers don't cancel key events in the keydown but in the + // keypress. + // TODO: Check if really needed for Gecko+Mac. + if ( env.opera || ( env.gecko && env.mac ) ) + extra += ' onkeypress="return false;"'; + + // With Firefox, we need to force the button to redraw, otherwise it + // will remain in the focus state. + if ( env.gecko ) + extra += ' onblur="this.style.cssText = this.style.cssText;"'; + + var label = editor.lang.elementsPath.eleTitle.replace( /%1/, name ); + html.unshift( + '', + name, + '' + label + '', + '' ); + + } if ( name == 'body' ) break; @@ -112,7 +133,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.on( 'contentDomUnload', function() { - getSpaceElement().setHtml( emptyHtml ); + // If the spaceElement hasn't been initialized, don't try to do it at this time + // Only reuse existing reference. + spaceElement && spaceElement.setHtml( emptyHtml ); }); editor.addCommand( 'elementsPathFocus', commands.toolbarFocus ); @@ -132,7 +155,15 @@ CKEDITOR._.elementsPath = editor.focus(); var element = editor._.elementsPath.list[ elementIndex ]; - editor.getSelection().selectElement( element ); + + if ( element.is( 'body' ) ) + { + var range = new CKEDITOR.dom.range( editor.document ); + range.selectNodeContents( element ); + range.select(); + } + else + editor.getSelection().selectElement( element ); return false; }, @@ -147,9 +178,10 @@ CKEDITOR._.elementsPath = ev = new CKEDITOR.dom.event( ev ); + var rtl = editor.lang.dir == 'rtl'; switch ( ev.getKeystroke() ) { - case 37 : // LEFT-ARROW + case rtl ? 39 : 37 : // LEFT-ARROW case 9 : // TAB element = CKEDITOR.document.getById( idBase + ( elementIndex + 1 ) ); if ( !element ) @@ -157,7 +189,7 @@ CKEDITOR._.elementsPath = element.focus(); return false; - case 39 : // RIGHT-ARROW + case rtl ? 37 : 39 : // RIGHT-ARROW case CKEDITOR.SHIFT + 9 : // SHIFT + TAB element = CKEDITOR.document.getById( idBase + ( elementIndex - 1 ) ); if ( !element )