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;
|
|
|
|
|
2014-11-13 23:31:22 +01:00
|
|
|
if ( typeof window.jQuery !== 'undefined' ) {
|
|
|
|
window.jQuery( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-07-29 01:45:18 +02:00
|
|
|
if ( pixels && ! initial ) {
|
2014-05-30 04:38:16 +02:00
|
|
|
// Resize iframe, not needed in iOS
|
|
|
|
if ( ! tinymce.Env.iOS ) {
|
|
|
|
iframe = editor.getContentAreaContainer().firstChild;
|
|
|
|
DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels );
|
|
|
|
}
|
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 ( state === 'hide' ) {
|
2014-03-19 03:30:15 +01:00
|
|
|
setUserSetting('hidetb', '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
|
|
|
wpAdvButton && wpAdvButton.active( false );
|
|
|
|
} else {
|
2014-03-19 03:30:15 +01:00
|
|
|
setUserSetting('hidetb', '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
|
|
|
wpAdvButton && wpAdvButton.active( true );
|
|
|
|
}
|
|
|
|
}
|
2014-07-10 00:06:15 +02:00
|
|
|
|
|
|
|
editor.fire( 'wp-toolbar-toggle' );
|
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 the kitchen sink button :)
|
|
|
|
editor.addButton( 'wp_adv', {
|
|
|
|
tooltip: 'Toolbar Toggle',
|
|
|
|
cmd: 'WP_Adv',
|
|
|
|
onPostRender: function() {
|
|
|
|
wpAdvButton = this;
|
2014-03-30 00:58:14 +01:00
|
|
|
wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' ? true : false );
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Hide the toolbars after loading
|
|
|
|
editor.on( 'PostRender', function() {
|
2014-04-22 15:50:14 +02:00
|
|
|
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '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
|
|
|
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 ) {
|
2014-07-29 01:45:18 +02:00
|
|
|
var title;
|
|
|
|
|
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 ( e.content ) {
|
|
|
|
if ( e.content.indexOf( '<!--more' ) !== -1 ) {
|
2014-07-29 01:45:18 +02:00
|
|
|
title = editor.editorManager.i18n.translate( 'Read 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
|
|
|
e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
|
2014-07-29 01:45:18 +02:00
|
|
|
return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
|
|
|
|
'class="wp-more-tag mce-wp-more" title="' + title + '" 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 ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
|
2014-07-29 01:45:18 +02:00
|
|
|
title = editor.editorManager.i18n.translate( 'Page break' );
|
|
|
|
|
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
|
|
|
e.content = e.content.replace( /<!--nextpage-->/g,
|
2014-07-29 01:45:18 +02:00
|
|
|
'<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
|
|
|
|
'title="' + title + '" 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
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Replace images with tags
|
|
|
|
editor.on( 'PostProcess', function( e ) {
|
|
|
|
if ( e.get ) {
|
|
|
|
e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
|
|
|
|
var match, moretext = '';
|
|
|
|
|
2014-07-29 01:45:18 +02:00
|
|
|
if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
|
|
|
|
if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) {
|
|
|
|
moretext = match[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
|
|
|
}
|
2014-07-29 01:45:18 +02:00
|
|
|
|
|
|
|
image = '<!--more' + moretext + '-->';
|
|
|
|
} else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) {
|
|
|
|
image = '<!--nextpage-->';
|
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 image;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Display the tag name instead of img in element path
|
2014-07-29 01:45:18 +02:00
|
|
|
editor.on( 'ResolveName', function( event ) {
|
|
|
|
var attr;
|
|
|
|
|
|
|
|
if ( event.target.nodeName === 'IMG' && ( attr = editor.dom.getAttrib( event.target, 'data-wp-more' ) ) ) {
|
|
|
|
event.name = attr;
|
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-03-26 03:08:15 +01:00
|
|
|
var parent, html, title,
|
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',
|
|
|
|
dom = editor.dom,
|
|
|
|
node = editor.selection.getNode();
|
|
|
|
|
|
|
|
tag = tag || 'more';
|
|
|
|
classname += ' mce-wp-' + tag;
|
2014-07-29 01:45:18 +02:00
|
|
|
title = tag === 'more' ? 'Read more...' : 'Next page';
|
|
|
|
title = editor.editorManager.i18n.translate( title );
|
2014-01-14 06:46:11 +01:00
|
|
|
html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
|
2014-07-29 01:45:18 +02:00
|
|
|
'data-wp-more="' + tag + '" 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
|
|
|
|
2014-03-26 03:08:15 +01:00
|
|
|
// Most common case
|
|
|
|
if ( node.nodeName === 'BODY' || ( node.nodeName === 'P' && node.parentNode.nodeName === 'BODY' ) ) {
|
|
|
|
editor.insertContent( html );
|
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-03-26 03:08:15 +01:00
|
|
|
if ( parent.nodeName === 'P' ) {
|
|
|
|
parent.appendChild( dom.create( 'p', null, html ).firstChild );
|
|
|
|
} else {
|
|
|
|
dom.insertAfter( dom.create( 'p', null, html ), parent );
|
2014-01-14 06:46:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
editor.nodeChanged();
|
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-03-14 23:43:16 +01:00
|
|
|
editor.addCommand( 'WP_Code', function() {
|
|
|
|
editor.formatter.toggle('code');
|
|
|
|
});
|
|
|
|
|
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',
|
2014-04-08 04:32:14 +02:00
|
|
|
title: 'Keyboard Shortcuts',
|
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
|
|
|
width: 450,
|
|
|
|
height: 420,
|
2014-12-07 00:53:22 +01:00
|
|
|
classes: 'wp-help',
|
|
|
|
buttons: { text: 'Close', onclick: 'close' }
|
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_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', {
|
2014-04-08 04:32:14 +02:00
|
|
|
tooltip: 'Keyboard Shortcuts',
|
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
|
|
|
cmd: 'WP_Help'
|
|
|
|
});
|
|
|
|
|
2014-03-14 23:43:16 +01:00
|
|
|
editor.addButton( 'wp_code', {
|
|
|
|
tooltip: 'Code',
|
|
|
|
cmd: 'WP_Code',
|
|
|
|
stateSelector: 'code'
|
|
|
|
});
|
|
|
|
|
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
|
|
|
// 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-27 18:31:14 +01:00
|
|
|
var env = tinymce.Env,
|
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
|
|
|
|
2014-05-30 04:38:16 +02:00
|
|
|
if ( tinymce.Env.iOS ) {
|
|
|
|
dom.addClass( doc.documentElement, 'ios' );
|
|
|
|
}
|
|
|
|
|
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');
|
2014-04-13 02:23:15 +02:00
|
|
|
dom.setAttrib( doc.documentElement, 'dir', 'rtl' );
|
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 ( 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');
|
|
|
|
}
|
2014-06-27 05:00:15 +02:00
|
|
|
} else if ( env.webkit ) {
|
|
|
|
bodyClass.push('webkit');
|
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.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-04-02 04:42:16 +02:00
|
|
|
if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
|
|
|
|
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
|
|
|
if ( typeof window.jQuery !== 'undefined' ) {
|
|
|
|
// Trigger the jQuery handlers.
|
2014-04-23 22:35:13 +02:00
|
|
|
window.jQuery( document ).trigger( new window.jQuery.Event( event ) );
|
2014-04-02 04:42:16 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-06-30 23:55:18 +02:00
|
|
|
|
|
|
|
if ( editor.getParam( 'wp_paste_filters', true ) ) {
|
|
|
|
if ( ! tinymce.Env.webkit ) {
|
|
|
|
// In WebKit handled by removeWebKitStyles()
|
|
|
|
editor.on( 'PastePreProcess', function( event ) {
|
|
|
|
// Remove all inline styles
|
|
|
|
event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' );
|
|
|
|
|
|
|
|
// Put back the internal styles
|
|
|
|
event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.on( 'PastePostProcess', function( event ) {
|
|
|
|
// Remove empty paragraphs
|
|
|
|
tinymce.each( dom.select( 'p', event.node ), function( node ) {
|
|
|
|
if ( dom.isEmpty( node ) ) {
|
|
|
|
dom.remove( node );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
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
|
2014-05-29 02:59:15 +02:00
|
|
|
if ( ! editor.inline && editor.isHidden() ) {
|
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
|
|
|
e.content = e.element.value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep empty paragraphs :(
|
2014-06-06 06:20:14 +02:00
|
|
|
e.content = e.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<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
|
|
|
|
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-06-06 06:20:14 +02:00
|
|
|
// Remove spaces from empty paragraphs.
|
|
|
|
editor.on( 'BeforeSetContent', function( event ) {
|
|
|
|
if ( event.content ) {
|
|
|
|
event.content = event.content.replace( /<p>(?: |\u00a0|\uFEFF| )+<\/p>/gi, '<p></p>' );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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' );
|
2014-05-30 04:38:16 +02:00
|
|
|
|
|
|
|
if ( tinymce.Env.iOS ) {
|
|
|
|
editor.settings.height = 300;
|
|
|
|
}
|
2014-02-03 21:26:12 +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
|
|
|
// 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' );
|
2014-03-14 23:43:16 +01:00
|
|
|
editor.addShortcut( modKey + '+x', '', 'WP_Code' );
|
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.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
|
|
|
}
|
|
|
|
});
|
2015-03-11 20:12:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Experimental: create a floating toolbar.
|
|
|
|
* This functionality will change in the next releases. Not recommennded for use by plugins.
|
|
|
|
*/
|
|
|
|
( function() {
|
|
|
|
var DOM = tinymce.DOM,
|
|
|
|
each = tinymce.each,
|
|
|
|
Factory = tinymce.ui.Factory,
|
|
|
|
settings = editor.settings,
|
|
|
|
currentToolbar,
|
|
|
|
currentSelection;
|
|
|
|
|
|
|
|
function create( buttons ) {
|
|
|
|
var toolbar,
|
|
|
|
toolbarItems = [],
|
|
|
|
buttonGroup;
|
|
|
|
|
|
|
|
each( buttons, function( item ) {
|
|
|
|
var itemName;
|
|
|
|
|
|
|
|
function bindSelectorChanged() {
|
|
|
|
var selection = editor.selection;
|
|
|
|
|
|
|
|
if ( itemName === 'bullist' ) {
|
|
|
|
selection.selectorChanged( 'ul > li', function( state, args ) {
|
|
|
|
var i = args.parents.length,
|
|
|
|
nodeName;
|
|
|
|
|
|
|
|
while ( i-- ) {
|
|
|
|
nodeName = args.parents[ i ].nodeName;
|
|
|
|
|
|
|
|
if ( nodeName === 'OL' || nodeName == 'UL' ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item.active( state && nodeName === 'UL' );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName === 'numlist' ) {
|
|
|
|
selection.selectorChanged( 'ol > li', function( state, args ) {
|
|
|
|
var i = args.parents.length,
|
|
|
|
nodeName;
|
|
|
|
|
|
|
|
while ( i-- ) {
|
|
|
|
nodeName = args.parents[ i ].nodeName;
|
|
|
|
|
|
|
|
if ( nodeName === 'OL' || nodeName === 'UL' ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item.active( state && nodeName === 'OL' );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( item.settings.stateSelector ) {
|
|
|
|
selection.selectorChanged( item.settings.stateSelector, function( state ) {
|
|
|
|
item.active( state );
|
|
|
|
}, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( item.settings.disabledStateSelector ) {
|
|
|
|
selection.selectorChanged( item.settings.disabledStateSelector, function( state ) {
|
|
|
|
item.disabled( state );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( item === '|' ) {
|
|
|
|
buttonGroup = null;
|
|
|
|
} else {
|
|
|
|
if ( Factory.has( item ) ) {
|
|
|
|
item = {
|
|
|
|
type: item
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( settings.toolbar_items_size ) {
|
|
|
|
item.size = settings.toolbar_items_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbarItems.push( item );
|
|
|
|
|
|
|
|
buttonGroup = null;
|
|
|
|
} else {
|
|
|
|
if ( ! buttonGroup ) {
|
|
|
|
buttonGroup = {
|
|
|
|
type: 'buttongroup',
|
|
|
|
items: []
|
|
|
|
};
|
|
|
|
|
|
|
|
toolbarItems.push( buttonGroup );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( editor.buttons[ item ] ) {
|
|
|
|
itemName = item;
|
|
|
|
item = editor.buttons[ itemName ];
|
|
|
|
|
|
|
|
if ( typeof item === 'function' ) {
|
|
|
|
item = item();
|
|
|
|
}
|
|
|
|
|
|
|
|
item.type = item.type || 'button';
|
|
|
|
|
|
|
|
if ( settings.toolbar_items_size ) {
|
|
|
|
item.size = settings.toolbar_items_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
item = Factory.create( item );
|
|
|
|
|
|
|
|
buttonGroup.items.push( item );
|
|
|
|
|
|
|
|
if ( editor.initialized ) {
|
|
|
|
bindSelectorChanged();
|
|
|
|
} else {
|
|
|
|
editor.on( 'init', bindSelectorChanged );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
toolbar = Factory.create( {
|
|
|
|
type: 'panel',
|
|
|
|
layout: 'stack',
|
|
|
|
classes: 'toolbar-grp inline-toolbar-grp',
|
|
|
|
ariaRoot: true,
|
|
|
|
ariaRemember: true,
|
|
|
|
items: [ {
|
|
|
|
type: 'toolbar',
|
|
|
|
layout: 'flow',
|
|
|
|
items: toolbarItems
|
|
|
|
} ]
|
|
|
|
} );
|
|
|
|
|
|
|
|
function hide() {
|
|
|
|
toolbar.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function reposition() {
|
|
|
|
var top, left, minTop, className,
|
|
|
|
windowPos, adminbar, mceToolbar, boundary,
|
|
|
|
boundaryMiddle, boundaryVerticalMiddle, spaceTop,
|
|
|
|
spaceBottom, windowWidth, toolbarWidth, toolbarHalf,
|
|
|
|
iframe, iframePos, iframeWidth, iframeHeigth,
|
|
|
|
toolbarNodeHeight, verticalSpaceNeeded,
|
|
|
|
toolbarNode = this.getEl(),
|
|
|
|
buffer = 5,
|
|
|
|
margin = 8,
|
|
|
|
adminbarHeight = 0;
|
|
|
|
|
2015-03-11 21:08:27 +01:00
|
|
|
if ( ! currentSelection ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-11 20:12:28 +01:00
|
|
|
windowPos = window.pageYOffset || document.documentElement.scrollTop;
|
|
|
|
adminbar = tinymce.$( '#wpadminbar' )[0];
|
|
|
|
mceToolbar = tinymce.$( '.mce-toolbar-grp', editor.getContainer() )[0];
|
|
|
|
boundary = currentSelection.getBoundingClientRect();
|
|
|
|
boundaryMiddle = ( boundary.left + boundary.right ) / 2;
|
|
|
|
boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2;
|
|
|
|
spaceTop = boundary.top;
|
|
|
|
spaceBottom = iframeHeigth - boundary.bottom;
|
|
|
|
windowWidth = window.innerWidth;
|
|
|
|
toolbarWidth = toolbarNode.offsetWidth;
|
|
|
|
toolbarHalf = toolbarWidth / 2;
|
|
|
|
iframe = document.getElementById( editor.id + '_ifr' );
|
|
|
|
iframePos = DOM.getPos( iframe );
|
|
|
|
iframeWidth = iframe.offsetWidth;
|
|
|
|
iframeHeigth = iframe.offsetHeight;
|
|
|
|
toolbarNodeHeight = toolbarNode.offsetHeight;
|
|
|
|
verticalSpaceNeeded = toolbarNodeHeight + margin + buffer;
|
|
|
|
|
|
|
|
if ( spaceTop >= verticalSpaceNeeded ) {
|
|
|
|
className = ' mce-arrow-down';
|
|
|
|
top = boundary.top + iframePos.y - toolbarNodeHeight - margin;
|
|
|
|
} else if ( spaceBottom >= verticalSpaceNeeded ) {
|
|
|
|
className = ' mce-arrow-up';
|
|
|
|
top = boundary.bottom + iframePos.y;
|
|
|
|
} else {
|
|
|
|
top = buffer;
|
|
|
|
|
|
|
|
if ( boundaryVerticalMiddle >= verticalSpaceNeeded ) {
|
|
|
|
className = ' mce-arrow-down';
|
|
|
|
} else {
|
|
|
|
className = ' mce-arrow-up';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the image toolbar is below the main toolbar.
|
|
|
|
if ( mceToolbar ) {
|
|
|
|
minTop = DOM.getPos( mceToolbar ).y + mceToolbar.clientHeight;
|
|
|
|
} else {
|
|
|
|
minTop = iframePos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the image toolbar is below the adminbar (if visible) or below the top of the window.
|
|
|
|
if ( windowPos ) {
|
|
|
|
if ( adminbar && adminbar.getBoundingClientRect().top === 0 ) {
|
|
|
|
adminbarHeight = adminbar.clientHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( windowPos + adminbarHeight > minTop ) {
|
|
|
|
minTop = windowPos + adminbarHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( top && minTop && ( minTop + buffer > top ) ) {
|
|
|
|
top = minTop + buffer;
|
|
|
|
className = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
left = boundaryMiddle - toolbarHalf;
|
|
|
|
left += iframePos.x;
|
|
|
|
|
|
|
|
if ( boundary.left < 0 || boundary.right > iframeWidth ) {
|
|
|
|
left = iframePos.x + ( iframeWidth - toolbarWidth ) / 2;
|
|
|
|
} else if ( toolbarWidth >= windowWidth ) {
|
|
|
|
className += ' mce-arrow-full';
|
|
|
|
left = 0;
|
|
|
|
} else if ( ( left < 0 && boundary.left + toolbarWidth > windowWidth ) ||
|
|
|
|
( left + toolbarWidth > windowWidth && boundary.right - toolbarWidth < 0 ) ) {
|
|
|
|
|
|
|
|
left = ( windowWidth - toolbarWidth ) / 2;
|
|
|
|
} else if ( left < iframePos.x ) {
|
|
|
|
className += ' mce-arrow-left';
|
|
|
|
left = boundary.left + iframePos.x;
|
|
|
|
} else if ( left + toolbarWidth > iframeWidth + iframePos.x ) {
|
|
|
|
className += ' mce-arrow-right';
|
|
|
|
left = boundary.right - toolbarWidth + iframePos.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbarNode.className = toolbarNode.className.replace( / ?mce-arrow-[\w]+/g, '' );
|
|
|
|
toolbarNode.className += className;
|
|
|
|
|
|
|
|
DOM.setStyles( toolbarNode, { 'left': left, 'top': top } );
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbar.on( 'show', function() {
|
|
|
|
currentToolbar = this;
|
|
|
|
this.reposition();
|
|
|
|
} );
|
|
|
|
|
|
|
|
toolbar.on( 'hide', function() {
|
|
|
|
currentToolbar = false;
|
|
|
|
} );
|
|
|
|
|
|
|
|
toolbar.on( 'keydown', function( event ) {
|
|
|
|
if ( event.keyCode === 27 ) {
|
|
|
|
this.hide();
|
|
|
|
editor.focus();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
toolbar.on( 'remove', function() {
|
|
|
|
DOM.unbind( window, 'resize scroll', hide );
|
|
|
|
editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
|
|
|
|
editor.off( 'blur hide', hide );
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.once( 'init', function() {
|
|
|
|
DOM.bind( window, 'resize scroll', hide );
|
|
|
|
editor.dom.bind( editor.getWin(), 'resize scroll', hide );
|
|
|
|
editor.on( 'blur hide', hide );
|
|
|
|
} );
|
|
|
|
|
|
|
|
toolbar.reposition = reposition;
|
|
|
|
toolbar.hide().renderTo( document.body );
|
|
|
|
|
|
|
|
return toolbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.shortcuts.add( 'alt+119', '', function() {
|
|
|
|
var node;
|
|
|
|
|
|
|
|
if ( currentToolbar ) {
|
|
|
|
node = currentToolbar.find( 'toolbar' )[0];
|
|
|
|
node && node.focus( true );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.on( 'nodechange', function( event ) {
|
|
|
|
var collapsed = editor.selection.isCollapsed();
|
|
|
|
|
|
|
|
var args = {
|
|
|
|
element: event.element,
|
|
|
|
parents: event.parents,
|
|
|
|
collapsed: collapsed
|
|
|
|
};
|
|
|
|
|
|
|
|
editor.fire( 'wptoolbar', args );
|
|
|
|
|
|
|
|
currentSelection = args.selection || args.element;
|
|
|
|
|
|
|
|
currentToolbar && currentToolbar.hide();
|
|
|
|
args.toolbar && args.toolbar.show();
|
|
|
|
} );
|
|
|
|
|
|
|
|
editor.wp = editor.wp || {};
|
|
|
|
editor.wp._createToolbar = create;
|
|
|
|
}());
|
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
|
|
|
|
2015-03-10 21:28:26 +01:00
|
|
|
function noop() {}
|
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
|
|
|
|
|
|
|
// Expose some functions (back-compat)
|
|
|
|
return {
|
2015-03-10 21:28:26 +01:00
|
|
|
_showButtons: noop,
|
|
|
|
_hideButtons: noop,
|
|
|
|
_setEmbed: noop,
|
|
|
|
_getEmbed: noop
|
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
|
|
|
};
|
|
|
|
});
|