aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/link/dialogs/anchor.js
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/link/dialogs/anchor.js')
-rw-r--r--sources/plugins/link/dialogs/anchor.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/sources/plugins/link/dialogs/anchor.js b/sources/plugins/link/dialogs/anchor.js
index 2b32b71..04a4abe 100644
--- a/sources/plugins/link/dialogs/anchor.js
+++ b/sources/plugins/link/dialogs/anchor.js
@@ -18,6 +18,21 @@ CKEDITOR.dialog.add( 'anchor', function( editor ) {
18 } ), 'cke_anchor', 'anchor' ); 18 } ), 'cke_anchor', 'anchor' );
19 } 19 }
20 20
21
22 function getSelectedAnchor( selection ) {
23 var range = selection.getRanges()[ 0 ],
24 element = selection.getSelectedElement();
25
26 // In case of table cell selection, we want to shrink selection from td to a element.
27 range.shrink( CKEDITOR.SHRINK_ELEMENT );
28 element = range.getEnclosedNode();
29
30 if ( element && element.type === CKEDITOR.NODE_ELEMENT &&
31 ( element.data( 'cke-real-element-type' ) === 'anchor' || element.is( 'a' ) ) ) {
32 return element;
33 }
34 }
35
21 return { 36 return {
22 title: editor.lang.link.anchor.title, 37 title: editor.lang.link.anchor.title,
23 minWidth: 300, 38 minWidth: 300,
@@ -35,9 +50,10 @@ CKEDITOR.dialog.add( 'anchor', function( editor ) {
35 var newFake = createFakeAnchor( editor, attributes ); 50 var newFake = createFakeAnchor( editor, attributes );
36 newFake.replace( this._.selectedElement ); 51 newFake.replace( this._.selectedElement );
37 52
38 // Selecting fake element for IE. (#11377) 53 // Selecting fake element for IE. (http://dev.ckeditor.com/ticket/11377)
39 if ( CKEDITOR.env.ie ) 54 if ( CKEDITOR.env.ie ) {
40 editor.getSelection().selectElement( newFake ); 55 editor.getSelection().selectElement( newFake );
56 }
41 } else { 57 } else {
42 this._.selectedElement.setAttributes( attributes ); 58 this._.selectedElement.setAttributes( attributes );
43 } 59 }
@@ -56,7 +72,7 @@ CKEDITOR.dialog.add( 'anchor', function( editor ) {
56 // Apply style. 72 // Apply style.
57 var style = new CKEDITOR.style( { element: 'a', attributes: attributes } ); 73 var style = new CKEDITOR.style( { element: 'a', attributes: attributes } );
58 style.type = CKEDITOR.STYLE_INLINE; 74 style.type = CKEDITOR.STYLE_INLINE;
59 editor.applyStyle( style ); 75 style.applyToRange( range );
60 } 76 }
61 } 77 }
62 }, 78 },
@@ -67,7 +83,7 @@ CKEDITOR.dialog.add( 'anchor', function( editor ) {
67 83
68 onShow: function() { 84 onShow: function() {
69 var sel = editor.getSelection(), 85 var sel = editor.getSelection(),
70 fullySelected = sel.getSelectedElement(), 86 fullySelected = getSelectedAnchor( sel ),
71 fakeSelected = fullySelected && fullySelected.data( 'cke-realelement' ), 87 fakeSelected = fullySelected && fullySelected.data( 'cke-realelement' ),
72 linkElement = fakeSelected ? 88 linkElement = fakeSelected ?
73 CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, fullySelected ) : 89 CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, fullySelected ) :
@@ -77,8 +93,9 @@ CKEDITOR.dialog.add( 'anchor', function( editor ) {
77 loadElements.call( this, linkElement ); 93 loadElements.call( this, linkElement );
78 !fakeSelected && sel.selectElement( linkElement ); 94 !fakeSelected && sel.selectElement( linkElement );
79 95
80 if ( fullySelected ) 96 if ( fullySelected ) {
81 this._.selectedElement = fullySelected; 97 this._.selectedElement = fullySelected;
98 }
82 } 99 }
83 100
84 this.getContentElement( 'info', 'txtName' ).focus(); 101 this.getContentElement( 'info', 'txtName' ).focus();