diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-12-04 17:54:04 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-12-04 17:54:04 +0100 |
commit | 317f8f8f0651488f226b5280a8f036c7c135c639 (patch) | |
tree | 97bd4889ab2822a00d4b0f0d5cde38b59f9f41de /sources/plugins/link/dialogs/anchor.js | |
parent | 1096cdefb1c9a3f3c4ca6807e272da6c92e5ed9c (diff) | |
download | piedsjaloux-ckeditor-component-4.7.3.tar.gz piedsjaloux-ckeditor-component-4.7.3.tar.zst piedsjaloux-ckeditor-component-4.7.3.zip |
Add oembed4.7.3
Diffstat (limited to 'sources/plugins/link/dialogs/anchor.js')
-rw-r--r-- | sources/plugins/link/dialogs/anchor.js | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/sources/plugins/link/dialogs/anchor.js b/sources/plugins/link/dialogs/anchor.js index e544275..04a4abe 100644 --- a/sources/plugins/link/dialogs/anchor.js +++ b/sources/plugins/link/dialogs/anchor.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -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(); |