TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
/* global tinymce */
|
|
|
|
tinymce.PluginManager.add( 'wplink', function( editor ) {
|
2015-06-24 19:05:26 -04:00
|
|
|
var toolbar;
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
editor.addCommand( 'WP_Link', function() {
|
2015-03-10 22:40:27 -04:00
|
|
|
window.wpLink && window.wpLink.open( editor.id );
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
});
|
|
|
|
|
2014-03-06 22:09:14 -05:00
|
|
|
// WP default shortcut
|
2015-03-10 23:01:27 -04:00
|
|
|
editor.addShortcut( 'Alt+Shift+A', '', 'WP_Link' );
|
2014-03-06 22:09:14 -05:00
|
|
|
// The "de-facto standard" shortcut, see #27305
|
2015-03-10 23:01:27 -04:00
|
|
|
editor.addShortcut( 'Meta+K', '', 'WP_Link' );
|
2014-03-06 22:09:14 -05:00
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
editor.addButton( 'link', {
|
|
|
|
icon: 'link',
|
|
|
|
tooltip: 'Insert/edit link',
|
|
|
|
cmd: 'WP_Link',
|
2015-03-10 22:40:27 -04:00
|
|
|
stateSelector: 'a[href]'
|
2014-03-06 21:02:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
editor.addButton( 'unlink', {
|
|
|
|
icon: 'unlink',
|
|
|
|
tooltip: 'Remove link',
|
2015-03-10 22:40:27 -04:00
|
|
|
cmd: 'unlink'
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
editor.addMenuItem( 'link', {
|
|
|
|
icon: 'link',
|
2015-04-08 12:59:26 -04:00
|
|
|
text: 'Insert/edit link',
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
cmd: 'WP_Link',
|
|
|
|
stateSelector: 'a[href]',
|
|
|
|
context: 'insert',
|
|
|
|
prependToContext: true
|
|
|
|
});
|
2015-03-09 16:00:27 -04:00
|
|
|
|
|
|
|
editor.on( 'pastepreprocess', function( event ) {
|
2015-06-17 01:05:24 -04:00
|
|
|
var pastedStr = event.content,
|
|
|
|
regExp = /^(?:https?:)?\/\/\S+$/i;
|
2015-03-09 16:00:27 -04:00
|
|
|
|
2015-06-17 01:05:24 -04:00
|
|
|
if ( ! editor.selection.isCollapsed() && ! regExp.test( editor.selection.getContent() ) ) {
|
2015-03-09 16:00:27 -04:00
|
|
|
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
|
|
|
|
pastedStr = tinymce.trim( pastedStr );
|
|
|
|
|
2015-06-17 01:05:24 -04:00
|
|
|
if ( regExp.test( pastedStr ) ) {
|
2015-03-09 16:00:27 -04:00
|
|
|
editor.execCommand( 'mceInsertLink', false, {
|
|
|
|
href: editor.dom.decode( pastedStr )
|
|
|
|
} );
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
2015-06-24 19:05:26 -04:00
|
|
|
|
|
|
|
tinymce.ui.WPLinkPreview = tinymce.ui.Control.extend( {
|
|
|
|
url: '#',
|
|
|
|
renderHtml: function() {
|
|
|
|
return (
|
|
|
|
'<div id="' + this._id + '" class="wp-link-preview">' +
|
|
|
|
'<a href="' + this.url + '" target="_blank" tabindex="-1">' + this.url + '</a>' +
|
|
|
|
'</div>'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
setURL: function( url ) {
|
|
|
|
var index, lastIndex;
|
|
|
|
|
|
|
|
if ( this.url !== url ) {
|
|
|
|
this.url = url;
|
|
|
|
|
|
|
|
url = window.decodeURIComponent( url );
|
|
|
|
|
|
|
|
url = url.replace( /^(?:https?:)?\/\/(?:www\.)?/, '' );
|
|
|
|
|
|
|
|
if ( ( index = url.indexOf( '?' ) ) !== -1 ) {
|
|
|
|
url = url.slice( 0, index );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( index = url.indexOf( '#' ) ) !== -1 ) {
|
|
|
|
url = url.slice( 0, index );
|
|
|
|
}
|
|
|
|
|
|
|
|
url = url.replace( /(?:index)?\.html$/, '' );
|
|
|
|
|
2015-06-25 00:42:28 -04:00
|
|
|
if ( url.charAt( url.length - 1 ) === '/' ) {
|
|
|
|
url = url.slice( 0, -1 );
|
2015-06-24 19:05:26 -04:00
|
|
|
}
|
|
|
|
|
2015-06-25 00:42:28 -04:00
|
|
|
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ...
|
|
|
|
if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) {
|
|
|
|
// If the beginning + ending are shorter that 40 chars, show more of the ending
|
|
|
|
if ( index + url.length - lastIndex < 40 ) {
|
|
|
|
lastIndex = -( 40 - ( index + 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex );
|
2015-06-24 19:05:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
tinymce.$( this.getEl().firstChild ).attr( 'href', this.url ).text( url );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
postRender: function() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
editor.on( 'wptoolbar', function( event ) {
|
|
|
|
var anchor = editor.dom.getParent( event.element, 'a' ),
|
2015-06-25 00:42:28 -04:00
|
|
|
$ = editor.$,
|
2015-06-24 19:05:26 -04:00
|
|
|
href;
|
|
|
|
|
2015-06-25 00:42:28 -04:00
|
|
|
if ( anchor && ! $( anchor ).find( 'img' ).length &&
|
|
|
|
( href = $( anchor ).attr( 'href' ) ) ) {
|
2015-06-24 19:05:26 -04:00
|
|
|
|
2015-06-25 00:42:28 -04:00
|
|
|
self.setURL( href );
|
2015-06-24 19:05:26 -04:00
|
|
|
event.element = anchor;
|
|
|
|
event.toolbar = toolbar;
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.addButton( 'wp_link_edit', {
|
|
|
|
tooltip: 'Edit ', // trailing space is needed, used for context
|
|
|
|
icon: 'dashicon dashicons-edit',
|
|
|
|
cmd: 'WP_Link'
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.addButton( 'wp_link_remove', {
|
|
|
|
tooltip: 'Remove',
|
|
|
|
icon: 'dashicon dashicons-no',
|
|
|
|
cmd: 'unlink'
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.on( 'preinit', function() {
|
|
|
|
toolbar = editor.wp._createToolbar( [
|
|
|
|
'WPLinkPreview',
|
|
|
|
'wp_link_edit',
|
|
|
|
'wp_link_remove'
|
|
|
|
], true );
|
|
|
|
} );
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
|
|
|
});
|