Skip to content
Permalink
Browse files

Merge branch 't/11359'

  • Loading branch information...
oleq committed Feb 4, 2014
2 parents 8fb204a + d3bf6c9 commit 05f125f44324d93732a68b6dfdee56683b70690b
Showing with 52 additions and 26 deletions.
  1. +1 −0 CHANGES.md
  2. +1 −26 plugins/link/dialogs/link.js
  3. +50 −0 plugins/link/plugin.js
@@ -9,6 +9,7 @@ Fixed Issues:
* [#11490](http://dev.ckeditor.com/ticket/11490): Fixed issue with menubuttons panel showing in source mode.
* [#11417](http://dev.ckeditor.com/ticket/11417): The [`widget.doubleclick`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget-event-doubleclick) event is not cancelled anymore after editing has been triggered.
* [#11253](http://dev.ckeditor.com/ticket/11253): [IE] Fixed: Clipped upload button in [Enhanced Image](http://ckeditor.com/addon/image2) dialog.
* [#11359](http://dev.ckeditor.com/ticket/11359): Standardized the way anchors are discovered by the [Link](http://ckeditor.com/addon/link) dialog.

## CKEditor 4.3.2

@@ -204,32 +204,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) {
}

// Find out whether we have any anchors in the editor.
var anchors = retval.anchors = [],
i, count, item;

// For some browsers we set contenteditable="false" on anchors, making document.anchors not to include them, so we must traverse the links manually (#7893).
if ( CKEDITOR.plugins.link.emptyAnchorFix ) {
var links = editor.document.getElementsByTag( 'a' );
for ( i = 0, count = links.count(); i < count; i++ ) {
item = links.getItem( i );
if ( item.data( 'cke-saved-name' ) || item.hasAttribute( 'name' ) )
anchors.push( { name: item.data( 'cke-saved-name' ) || item.getAttribute( 'name' ), id: item.getAttribute( 'id' ) } );
}
} else {
var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors );
for ( i = 0, count = anchorList.count(); i < count; i++ ) {
item = anchorList.getItem( i );
anchors[ i ] = { name: item.getAttribute( 'name' ), id: item.getAttribute( 'id' ) };
}
}

if ( CKEDITOR.plugins.link.fakeAnchor ) {
var imgs = editor.document.getElementsByTag( 'img' );
for ( i = 0, count = imgs.count(); i < count; i++ ) {
if ( ( item = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, imgs.getItem( i ) ) ) )
anchors.push( { name: item.getAttribute( 'name' ), id: item.getAttribute( 'id' ) } );
}
}
retval.anchors = CKEDITOR.plugins.link.getEditorAnchors( editor );

// Record down the selected element in the dialog.
this._.selectedElement = element;
@@ -263,6 +263,56 @@ CKEDITOR.plugins.link = {
return null;
},

/**
* Collects anchors available in the editor (i.e. used by link dialog).
* Note that the scope of search is different for inline (the "global" document) and
* framed editors (the "inner" document).
*
* @since 4.3.3
* @param {CKEDITOR.editor} editor
* @returns {CKEDITOR.dom.element[]} An array of anchor elements.
*/
getEditorAnchors: function( editor ) {
var editable = editor.editable(),

// The scope of search for anchors is the entire document for inline editors
// and editor's editable for framed/divarea (#11359).
scope = ( editable.isInline() && !editor.plugins.divarea ) ? editor.document : editable,

links = scope.getElementsByTag( 'a' ),
anchors = [],
i = 0,
item;

// Retrieve all anchors within the scope.
while ( ( item = links.getItem( i++ ) ) ) {
if ( item.data( 'cke-saved-name' ) || item.hasAttribute( 'name' ) ) {
anchors.push( {
name: item.data( 'cke-saved-name' ) || item.getAttribute( 'name' ),
id: item.getAttribute( 'id' )
} );
}
}

// Retrieve all "fake anchors" within the scope.
if ( this.fakeAnchor ) {
var imgs = scope.getElementsByTag( 'img' );

i = 0;

while ( ( item = imgs.getItem( i++ ) ) ) {
if ( ( item = this.tryRestoreFakeAnchor( editor, item ) ) ) {
anchors.push( {
name: item.getAttribute( 'name' ),
id: item.getAttribute( 'id' )
} );
}
}
}

return anchors;
},

/**
* Opera and WebKit don't make it possible to select empty anchors. Fake
* elements must be used for them.

0 comments on commit 05f125f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.