2014-03-08 01:41:16 +01:00
|
|
|
/* global tinymce, getUserSetting, setUserSetting */
|
|
|
|
|
|
|
|
// Set the minimum value for the modals z-index higher than #wpadminbar (100000)
|
|
|
|
tinymce.ui.FloatPanel.zIndex = 100100;
|
|
|
|
|
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-29 00:53:15 +01:00
|
|
|
tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|
|
|
var DOM = tinymce.DOM, wpAdvButton, modKey, style,
|
|
|
|
last = 0;
|
|
|
|
|
|
|
|
function toggleToolbars( state ) {
|
2013-12-30 02:54:11 +01:00
|
|
|
var iframe, initial, toolbars,
|
|
|
|
pixels = 0;
|
|
|
|
|
|
|
|
initial = ( state === 'hide' );
|
|
|
|
|
|
|
|
if ( editor.theme.panel ) {
|
2014-02-18 07:32:14 +01:00
|
|
|
toolbars = editor.theme.panel.find('.toolbar:not(.menubar)');
|
2013-12-30 02:54:11 +01: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-29 00:53:15 +01:00
|
|
|
|
|
|
|
if ( ! toolbars || toolbars.length < 2 || ( state === 'hide' && ! toolbars[1].visible() ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! state && toolbars[1].visible() ) {
|
|
|
|
state = 'hide';
|
|
|
|
}
|
|
|
|
|
|
|
|
tinymce.each( toolbars, function( toolbar, i ) {
|
|
|
|
if ( i > 0 ) {
|
|
|
|
if ( state === 'hide' ) {
|
|
|
|
toolbar.hide();
|
|
|
|
pixels += 30;
|
|
|
|
} else {
|
|
|
|
toolbar.show();
|
|
|
|
pixels -= 30;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( pixels && ! initial ) {
|
|
|
|
iframe = editor.getContentAreaContainer().firstChild;
|
|
|
|
DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels ); // Resize iframe
|
|
|
|
|
|
|
|
if ( state === 'hide' ) {
|
|
|
|
setUserSetting('hidetb', '1');
|
|
|
|
wpAdvButton && wpAdvButton.active( false );
|
|
|
|
} else {
|
|
|
|
setUserSetting('hidetb', '0');
|
|
|
|
wpAdvButton && wpAdvButton.active( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the kitchen sink button :)
|
|
|
|
editor.addButton( 'wp_adv', {
|
|
|
|
tooltip: 'Toolbar Toggle',
|
|
|
|
cmd: 'WP_Adv',
|
|
|
|
onPostRender: function() {
|
|
|
|
wpAdvButton = this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Hide the toolbars after loading
|
|
|
|
editor.on( 'PostRender', function() {
|
|
|
|
if ( getUserSetting('hidetb', '1') === '1' ) {
|
|
|
|
toggleToolbars( 'hide' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addCommand( 'WP_Adv', function() {
|
|
|
|
toggleToolbars();
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'focus', function() {
|
|
|
|
window.wpActiveEditor = editor.id;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Replace Read More/Next Page tags with images
|
|
|
|
editor.on( 'BeforeSetContent', function( e ) {
|
|
|
|
if ( e.content ) {
|
|
|
|
if ( e.content.indexOf( '<!--more' ) !== -1 ) {
|
|
|
|
e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
|
|
|
|
return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="' + moretext + '" ' +
|
|
|
|
'class="wp-more-tag mce-wp-more" title="Read More..." data-mce-resize="false" data-mce-placeholder="1" />';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
|
|
|
|
e.content = e.content.replace( /<!--nextpage-->/g,
|
|
|
|
'<img src="' + tinymce.Env.transparentSrc + '" class="wp-more-tag mce-wp-nextpage" ' +
|
|
|
|
'title="Page break" data-mce-resize="false" data-mce-placeholder="1" />' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Replace images with tags
|
|
|
|
editor.on( 'PostProcess', function( e ) {
|
|
|
|
if ( e.get ) {
|
|
|
|
e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
|
|
|
|
var match, moretext = '';
|
|
|
|
|
|
|
|
if ( image.indexOf('wp-more-tag') !== -1 ) {
|
|
|
|
if ( image.indexOf('mce-wp-more') !== -1 ) {
|
|
|
|
if ( match = image.match( /data-wp-more="([^"]+)"/ ) ) {
|
|
|
|
moretext = match[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
image = '<!--more' + moretext + '-->';
|
|
|
|
} else if ( image.indexOf('mce-wp-nextpage') !== -1 ) {
|
|
|
|
image = '<!--nextpage-->';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Display the tag name instead of img in element path
|
|
|
|
editor.on( 'ResolveName', function( e ) {
|
|
|
|
var dom = editor.dom,
|
|
|
|
target = e.target;
|
|
|
|
|
|
|
|
if ( target.nodeName === 'IMG' && dom.hasClass( target, 'wp-more-tag' ) ) {
|
|
|
|
if ( dom.hasClass( target, 'mce-wp-more' ) ) {
|
|
|
|
e.name = 'more';
|
|
|
|
} else if ( dom.hasClass( target, 'mce-wp-nextpage' ) ) {
|
|
|
|
e.name = 'nextpage';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-01-14 06:46:11 +01:00
|
|
|
// Make sure the "more" tag is in a separate paragraph
|
2014-02-03 22:31:13 +01:00
|
|
|
editor.on( 'PreProcess', function( event ) {
|
|
|
|
var more;
|
|
|
|
|
|
|
|
if ( event.save ) {
|
|
|
|
more = editor.dom.select( 'img.wp-more-tag', event.node );
|
|
|
|
|
|
|
|
if ( more.length ) {
|
|
|
|
tinymce.each( more, function( node ) {
|
|
|
|
var parent = node.parentNode, p;
|
|
|
|
|
|
|
|
if ( parent.nodeName === 'P' && parent.childNodes.length > 1 ) {
|
|
|
|
p = editor.dom.create('p');
|
|
|
|
parent.parentNode.insertBefore( p, parent );
|
|
|
|
p.appendChild( node );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-01-14 06:46:11 +01: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-29 00:53:15 +01:00
|
|
|
// Register commands
|
|
|
|
editor.addCommand( 'WP_More', function( tag ) {
|
2014-01-14 06:46:11 +01:00
|
|
|
var parent, html, title, p1, p2,
|
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-29 00:53:15 +01:00
|
|
|
classname = 'wp-more-tag',
|
2014-01-14 06:46:11 +01:00
|
|
|
spacer = tinymce.Env.ie ? '' : '<br data-mce-bogus="1" />',
|
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-29 00:53:15 +01:00
|
|
|
dom = editor.dom,
|
|
|
|
node = editor.selection.getNode();
|
|
|
|
|
|
|
|
tag = tag || 'more';
|
|
|
|
classname += ' mce-wp-' + tag;
|
|
|
|
title = tag === 'more' ? 'More...' : 'Next Page';
|
2014-01-14 06:46:11 +01:00
|
|
|
html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
|
|
|
|
'data-mce-resize="false" data-mce-placeholder="1" />';
|
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-29 00:53:15 +01:00
|
|
|
|
|
|
|
if ( node.nodeName === 'BODY' ) {
|
2014-01-14 06:46:11 +01:00
|
|
|
editor.insertContent( '<p>' + html + '</p><p></p>' );
|
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-29 00:53:15 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the top level parent node
|
|
|
|
parent = dom.getParent( node, function( found ) {
|
|
|
|
if ( found.parentNode && found.parentNode.nodeName === 'BODY' ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}, editor.getBody() );
|
|
|
|
|
|
|
|
if ( parent ) {
|
2014-01-14 06:46:11 +01:00
|
|
|
p1 = dom.create( 'p', null, html );
|
|
|
|
dom.insertAfter( p1, parent );
|
|
|
|
|
|
|
|
if ( ! ( p2 = p1.nextSibling ) ) {
|
|
|
|
p2 = dom.create( 'p', null, spacer );
|
|
|
|
dom.insertAfter( p2, p1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.nodeChanged();
|
|
|
|
editor.selection.setCursorLocation( p2, 0 );
|
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-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addCommand( 'WP_Page', function() {
|
|
|
|
editor.execCommand( 'WP_More', 'nextpage' );
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addCommand( 'WP_Help', function() {
|
|
|
|
editor.windowManager.open({
|
|
|
|
url: tinymce.baseURL + '/wp-mce-help.php',
|
|
|
|
width: 450,
|
|
|
|
height: 420,
|
|
|
|
inline: 1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addCommand( 'WP_Medialib', function() {
|
|
|
|
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
|
|
|
wp.media.editor.open( editor.id );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Register buttons
|
|
|
|
editor.addButton( 'wp_more', {
|
|
|
|
tooltip: 'Insert Read More tag',
|
|
|
|
onclick: function() {
|
|
|
|
editor.execCommand( 'WP_More', 'more' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addButton( 'wp_page', {
|
|
|
|
tooltip: 'Page break',
|
|
|
|
onclick: function() {
|
|
|
|
editor.execCommand( 'WP_More', 'nextpage' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addButton( 'wp_help', {
|
|
|
|
tooltip: 'Help',
|
|
|
|
cmd: 'WP_Help'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Menubar
|
|
|
|
// Insert->Add Media
|
|
|
|
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
|
|
|
editor.addMenuItem( 'add_media', {
|
|
|
|
text: 'Add Media',
|
2014-03-12 09:19:14 +01:00
|
|
|
icon: 'wp-media-library',
|
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-29 00:53:15 +01:00
|
|
|
context: 'insert',
|
|
|
|
cmd: 'WP_Medialib'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert "Read More..."
|
|
|
|
editor.addMenuItem( 'wp_more', {
|
|
|
|
text: 'Insert Read More tag',
|
2014-03-12 09:19:14 +01:00
|
|
|
icon: 'wp_more',
|
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-29 00:53:15 +01:00
|
|
|
context: 'insert',
|
|
|
|
onclick: function() {
|
|
|
|
editor.execCommand( 'WP_More', 'more' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Insert "Next Page"
|
|
|
|
editor.addMenuItem( 'wp_page', {
|
|
|
|
text: 'Page break',
|
2014-03-12 09:19:14 +01:00
|
|
|
icon: 'wp_page',
|
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-29 00:53:15 +01:00
|
|
|
context: 'insert',
|
|
|
|
onclick: function() {
|
|
|
|
editor.execCommand( 'WP_More', 'nextpage' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'BeforeExecCommand', function(e) {
|
|
|
|
if ( tinymce.Env.webkit && ( e.command === 'InsertUnorderedList' || e.command === 'InsertOrderedList' ) ) {
|
|
|
|
if ( ! style ) {
|
|
|
|
style = editor.dom.create( 'style', {'type': 'text/css'},
|
|
|
|
'#tinymce,#tinymce span,#tinymce li,#tinymce li>span,#tinymce p,#tinymce p>span{font:medium sans-serif;color:#000;line-height:normal;}');
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.getDoc().head.appendChild( style );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'ExecCommand', function( e ) {
|
|
|
|
if ( tinymce.Env.webkit && style &&
|
|
|
|
( 'InsertUnorderedList' === e.command || 'InsertOrderedList' === e.command ) ) {
|
|
|
|
|
|
|
|
editor.dom.remove( style );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'init', function() {
|
2014-03-03 03:34:14 +01:00
|
|
|
var env = tinymce.Env, topx, reset,
|
|
|
|
deltax = 0,
|
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-29 00:53:15 +01:00
|
|
|
bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
|
2014-03-08 01:41:16 +01:00
|
|
|
doc = editor.getDoc(),
|
|
|
|
dom = editor.dom;
|
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-29 00:53:15 +01:00
|
|
|
|
|
|
|
if ( editor.getParam( 'directionality' ) === 'rtl' ) {
|
|
|
|
bodyClass.push('rtl');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( env.ie ) {
|
|
|
|
if ( parseInt( env.ie, 10 ) === 9 ) {
|
|
|
|
bodyClass.push('ie9');
|
|
|
|
} else if ( parseInt( env.ie, 10 ) === 8 ) {
|
|
|
|
bodyClass.push('ie8');
|
|
|
|
} else if ( env.ie < 8 ) {
|
|
|
|
bodyClass.push('ie7');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyClass.push('wp-editor');
|
|
|
|
|
|
|
|
tinymce.each( bodyClass, function( cls ) {
|
|
|
|
if ( cls ) {
|
2014-03-08 01:41:16 +01:00
|
|
|
dom.addClass( doc.body, cls );
|
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-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Remove invalid parent paragraphs when inserting HTML
|
|
|
|
// TODO: still needed?
|
|
|
|
editor.on( 'BeforeSetContent', function( e ) {
|
|
|
|
if ( e.content ) {
|
|
|
|
e.content = e.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>');
|
|
|
|
e.content = e.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
|
|
|
|
}
|
|
|
|
});
|
2014-01-20 00:22:14 +01:00
|
|
|
|
|
|
|
if ( typeof window.jQuery !== 'undefined' ) {
|
|
|
|
window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
|
|
|
}
|
2014-02-05 02:10:13 +01:00
|
|
|
|
2014-02-06 20:34:12 +01:00
|
|
|
if ( ! ( 'ontouchstart' in window ) ) {
|
|
|
|
// When scrolling with mouse wheel or trackpad inside the editor, don't scroll the parent window
|
2014-03-08 01:41:16 +01:00
|
|
|
dom.bind( doc, 'onwheel' in doc ? 'wheel' : 'mousewheel', function( event ) {
|
2014-03-03 03:34:14 +01:00
|
|
|
var delta, top,
|
|
|
|
docElement = doc.documentElement;
|
2014-02-05 02:10:13 +01:00
|
|
|
|
2014-02-06 20:34:12 +01:00
|
|
|
if ( editor.settings.wp_fullscreen ) {
|
|
|
|
return;
|
2014-02-05 02:10:13 +01:00
|
|
|
}
|
2014-03-03 03:34:14 +01:00
|
|
|
// Don't modify scrolling when the editor is not active.
|
|
|
|
if ( typeof doc.hasFocus === 'function' && ! doc.hasFocus() ) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-05 02:10:13 +01:00
|
|
|
|
2014-02-06 20:34:12 +01:00
|
|
|
if ( typeof event.deltaY !== 'undefined' ) {
|
|
|
|
delta = event.deltaY;
|
2014-02-05 02:10:13 +01:00
|
|
|
|
2014-02-06 20:34:12 +01:00
|
|
|
if ( typeof event.deltaMode !== 'undefined' && event.deltaMode === event.DOM_DELTA_LINE ) {
|
|
|
|
delta *= 20;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
delta = -event.wheelDelta;
|
|
|
|
}
|
2014-02-05 02:10:13 +01:00
|
|
|
|
2014-02-06 20:34:12 +01:00
|
|
|
if ( env.webkit ) {
|
|
|
|
doc.body.scrollTop += delta;
|
|
|
|
} else {
|
|
|
|
docElement.scrollTop += delta;
|
|
|
|
}
|
2014-03-03 03:34:14 +01:00
|
|
|
|
|
|
|
top = docElement.scrollTop || doc.body.scrollTop;
|
|
|
|
|
|
|
|
if ( topx === top ) {
|
|
|
|
deltax += delta;
|
|
|
|
|
|
|
|
window.clearTimeout( reset );
|
|
|
|
// Sensitivity: delay before resetting the count of over-scroll pixels
|
|
|
|
reset = window.setTimeout( function() {
|
|
|
|
deltax = 0;
|
|
|
|
}, 1000 );
|
|
|
|
} else {
|
|
|
|
deltax = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
topx = top;
|
|
|
|
|
|
|
|
// Sensitivity: scroll the parent window when over-scrolling by more than 1000px
|
|
|
|
if ( deltax > 1000 || deltax < -1000 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
2014-02-06 20:34:12 +01:00
|
|
|
});
|
|
|
|
}
|
2014-03-08 01:41:16 +01:00
|
|
|
|
2014-03-14 01:42:14 +01:00
|
|
|
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
2014-03-08 01:41:16 +01:00
|
|
|
if ( typeof window.jQuery !== 'undefined' ) {
|
2014-03-14 01:42:14 +01:00
|
|
|
// Trigger the jQuery handlers.
|
|
|
|
window.jQuery( document ).triggerHandler( event.type );
|
2014-03-08 01:41:16 +01: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-29 00:53:15 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Word count
|
2014-01-20 00:22:14 +01:00
|
|
|
if ( typeof window.jQuery !== 'undefined' ) {
|
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-29 00:53:15 +01:00
|
|
|
editor.on( 'keyup', function( e ) {
|
|
|
|
var key = e.keyCode || e.charCode;
|
|
|
|
|
|
|
|
if ( key === last ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 13 === key || 8 === last || 46 === last ) {
|
2014-01-20 00:22:14 +01:00
|
|
|
window.jQuery( document ).triggerHandler( 'wpcountwords', [ editor.getContent({ format : 'raw' }) ] );
|
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-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
last = key;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.on( 'SaveContent', function( e ) {
|
|
|
|
// If editor is hidden, we just want the textarea's value to be saved
|
|
|
|
if ( editor.isHidden() ) {
|
|
|
|
e.content = e.element.value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep empty paragraphs :(
|
|
|
|
e.content = e.content.replace( /<p>(<br ?\/?>|\u00a0|\uFEFF)?<\/p>/g, '<p> </p>' );
|
|
|
|
|
2014-03-08 01:41:16 +01:00
|
|
|
if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
|
|
|
|
e.content = window.switchEditors.pre_wpautop( e.content );
|
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-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-02-03 21:26:12 +01:00
|
|
|
editor.on( 'preInit', function() {
|
|
|
|
// Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty
|
|
|
|
editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );
|
|
|
|
});
|
|
|
|
|
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-29 00:53:15 +01:00
|
|
|
// Add custom shortcuts
|
|
|
|
modKey = 'alt+shift';
|
|
|
|
|
|
|
|
editor.addShortcut( modKey + '+c', '', 'JustifyCenter' );
|
|
|
|
editor.addShortcut( modKey + '+r', '', 'JustifyRight' );
|
|
|
|
editor.addShortcut( modKey + '+l', '', 'JustifyLeft' );
|
|
|
|
editor.addShortcut( modKey + '+j', '', 'JustifyFull' );
|
|
|
|
editor.addShortcut( modKey + '+q', '', 'mceBlockQuote' );
|
|
|
|
editor.addShortcut( modKey + '+u', '', 'InsertUnorderedList' );
|
|
|
|
editor.addShortcut( modKey + '+o', '', 'InsertOrderedList' );
|
|
|
|
editor.addShortcut( modKey + '+n', '', 'mceSpellCheck' );
|
|
|
|
editor.addShortcut( modKey + '+s', '', 'unlink' );
|
|
|
|
editor.addShortcut( modKey + '+m', '', 'WP_Medialib' );
|
|
|
|
editor.addShortcut( modKey + '+z', '', 'WP_Adv' );
|
|
|
|
editor.addShortcut( modKey + '+t', '', 'WP_More' );
|
|
|
|
editor.addShortcut( modKey + '+d', '', 'Strikethrough' );
|
|
|
|
editor.addShortcut( modKey + '+h', '', 'WP_Help' );
|
|
|
|
editor.addShortcut( modKey + '+p', '', 'WP_Page' );
|
|
|
|
editor.addShortcut( 'ctrl+s', '', function() {
|
2014-01-29 00:29:12 +01:00
|
|
|
if ( typeof wp !== 'undefined' && wp.autosave ) {
|
|
|
|
wp.autosave.server.triggerSave();
|
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-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// popup buttons for the gallery, etc.
|
|
|
|
editor.on( 'init', function() {
|
|
|
|
editor.dom.bind( editor.getWin(), 'scroll', function() {
|
|
|
|
_hideButtons();
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.dom.bind( editor.getBody(), 'dragstart', function() {
|
|
|
|
_hideButtons();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'BeforeExecCommand', function() {
|
|
|
|
_hideButtons();
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'SaveContent', function() {
|
|
|
|
_hideButtons();
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'MouseDown', function( e ) {
|
|
|
|
if ( e.target.nodeName !== 'IMG' ) {
|
|
|
|
_hideButtons();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.on( 'keydown', function( e ) {
|
|
|
|
if ( e.which === tinymce.util.VK.DELETE || e.which === tinymce.util.VK.BACKSPACE ) {
|
|
|
|
_hideButtons();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Internal functions
|
|
|
|
function _setEmbed( c ) {
|
|
|
|
return c.replace( /\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g, function( a, b ) {
|
|
|
|
return '<img width="300" height="200" src="' + tinymce.Env.transparentSrc + '" class="wp-oembed" ' +
|
|
|
|
'alt="'+ b +'" title="'+ b +'" data-mce-resize="false" data-mce-placeholder="1" />';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function _getEmbed( c ) {
|
|
|
|
return c.replace( /<img[^>]+>/g, function( a ) {
|
|
|
|
if ( a.indexOf('class="wp-oembed') !== -1 ) {
|
|
|
|
var u = a.match( /alt="([^\"]+)"/ );
|
|
|
|
|
|
|
|
if ( u[1] ) {
|
|
|
|
a = '[embed]' + u[1] + '[/embed]';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return a;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function _showButtons( n, id ) {
|
|
|
|
var p1, p2, vp, X, Y;
|
|
|
|
|
|
|
|
vp = editor.dom.getViewPort( editor.getWin() );
|
|
|
|
p1 = DOM.getPos( editor.getContentAreaContainer() );
|
|
|
|
p2 = editor.dom.getPos( n );
|
|
|
|
|
|
|
|
X = Math.max( p2.x - vp.x, 0 ) + p1.x;
|
|
|
|
Y = Math.max( p2.y - vp.y, 0 ) + p1.y;
|
|
|
|
|
|
|
|
DOM.setStyles( id, {
|
|
|
|
'top' : Y + 5 + 'px',
|
|
|
|
'left' : X + 5 + 'px',
|
|
|
|
'display': 'block'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function _hideButtons() {
|
|
|
|
DOM.hide( DOM.select( '#wp_editbtns, #wp_gallerybtns' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expose some functions (back-compat)
|
|
|
|
return {
|
|
|
|
_showButtons: _showButtons,
|
|
|
|
_hideButtons: _hideButtons,
|
|
|
|
_setEmbed: _setEmbed,
|
|
|
|
_getEmbed: _getEmbed
|
|
|
|
};
|
|
|
|
});
|