Skip to content

Commit

Permalink
PRESIDECMS-33 Fix for custom preside link picker getting mixed up wit…
Browse files Browse the repository at this point in the history
…h the core CKEditor link picker (give the command and dialog its own namespace rather than sharing one with the core link)
  • Loading branch information
DominicWatson committed Jun 1, 2015
1 parent b80f91b commit 33054ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

( function( $ ) {
CKEDITOR.dialog.add( 'link', function( editor ) {
CKEDITOR.dialog.add( 'presidelink', function( editor ) {
var plugin = CKEDITOR.plugins.presidelink
, commonLang = editor.lang.common
, linkLang = editor.lang.presidelink
Expand Down
20 changes: 10 additions & 10 deletions system/assets/ckeditorExtensions/plugins/presidelink/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
var allowed = 'a[!href]',
required = 'a[href]';

if ( CKEDITOR.dialog.isTabEnabled( editor, 'link', 'advanced' ) )
if ( CKEDITOR.dialog.isTabEnabled( editor, 'presidelink', 'advanced' ) )
allowed = allowed.replace( ']', ',accesskey,charset,dir,id,lang,name,rel,tabindex,title,type]{*}(*)' );
if ( CKEDITOR.dialog.isTabEnabled( editor, 'link', 'target' ) )
if ( CKEDITOR.dialog.isTabEnabled( editor, 'presidelink', 'target' ) )
allowed = allowed.replace( ']', ',target,onclick]' );

// Add the link and unlink buttons.
editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link', {
editor.addCommand( 'presidelink', new CKEDITOR.dialogCommand( 'presidelink', {
allowedContent: allowed,
requiredContent: required
} ) );
Expand All @@ -68,12 +68,12 @@
editor.addCommand( 'unlink', new CKEDITOR.unlinkCommand() );
editor.addCommand( 'removeAnchor', new CKEDITOR.removeAnchorCommand() );

editor.setKeystroke( CKEDITOR.CTRL + 76 /*L*/, 'link' );
editor.setKeystroke( CKEDITOR.CTRL + 76 /*L*/, 'presidelink' );

if ( editor.ui.addButton ) {
editor.ui.addButton( 'PresideLink', {
label: editor.lang.presidelink.toolbar,
command: 'link',
command: 'presidelink',
toolbar: 'links,10'
} );
editor.ui.addButton( 'PresideUnlink', {
Expand All @@ -88,15 +88,15 @@
} );
}

CKEDITOR.dialog.add( 'link', this.path + 'dialogs/link.js' );
CKEDITOR.dialog.add( 'presidelink', this.path + 'dialogs/presidelink.js' );
CKEDITOR.dialog.add( 'anchor', this.path + 'dialogs/anchor.js' );

editor.on( 'doubleclick', function( evt ) {
var element = CKEDITOR.plugins.presidelink.getSelectedLink( editor ) || evt.data.element;

if ( !element.isReadOnly() ) {
if ( element.is( 'a' ) ) {
evt.data.dialog = ( element.getAttribute( 'name' ) && ( !element.getAttribute( 'href' ) || !element.getChildCount() ) ) ? 'anchor' : 'link';
evt.data.dialog = ( element.getAttribute( 'name' ) && ( !element.getAttribute( 'href' ) || !element.getChildCount() ) ) ? 'anchor' : 'presidelink';

// Pass the link to be selected along with event data.
evt.data.link = element;
Expand Down Expand Up @@ -131,15 +131,15 @@

link: {
label: editor.lang.presidelink.menu,
command: 'link',
group: 'link',
command: 'presidelink',
group: 'presidelink',
order: 1
},

unlink: {
label: editor.lang.presidelink.unlink,
command: 'unlink',
group: 'link',
group: 'presidelink',
order: 5
}
} );
Expand Down

0 comments on commit 33054ba

Please sign in to comment.