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
|
|
|
/* global tinymce */
|
|
|
|
/**
|
|
|
|
* WP Fullscreen (Distraction Free Writing) TinyMCE plugin
|
|
|
|
*/
|
|
|
|
tinymce.PluginManager.add( 'wpfullscreen', function( editor ) {
|
|
|
|
var settings = editor.settings,
|
|
|
|
oldSize = 0;
|
|
|
|
|
|
|
|
function resize( e ) {
|
|
|
|
var deltaSize, myHeight,
|
|
|
|
d = editor.getDoc(),
|
|
|
|
body = d.body,
|
2013-12-30 02:54:11 +01:00
|
|
|
DOM = tinymce.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
|
|
|
resizeHeight = 250;
|
|
|
|
|
2013-12-30 02:54:11 +01:00
|
|
|
if ( ( e && e.type === 'setcontent' && e.initial ) || editor.settings.inline ) {
|
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 height differently depending on the browser used
|
|
|
|
myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
|
|
|
|
|
|
|
|
// Don't make it smaller than 250px
|
|
|
|
if ( myHeight > 250 ) {
|
|
|
|
resizeHeight = myHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
body.scrollTop = 0;
|
|
|
|
|
|
|
|
// Resize content element
|
|
|
|
if ( resizeHeight !== oldSize ) {
|
|
|
|
deltaSize = resizeHeight - oldSize;
|
|
|
|
DOM.setStyle( DOM.get( editor.id + '_ifr' ), 'height', resizeHeight + 'px' );
|
|
|
|
oldSize = resizeHeight;
|
|
|
|
|
|
|
|
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
|
|
|
// So we need to continue to resize the iframe down until the size gets fixed
|
|
|
|
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
|
|
|
resize( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register the command
|
|
|
|
editor.addCommand( 'wpAutoResize', resize );
|
|
|
|
|
|
|
|
function fullscreenOn() {
|
|
|
|
settings.wp_fullscreen = true;
|
|
|
|
editor.dom.addClass( editor.getDoc().documentElement, 'wp-fullscreen' );
|
|
|
|
// Add listeners for auto-resizing
|
|
|
|
editor.on( 'change setcontent paste keyup', resize );
|
|
|
|
}
|
|
|
|
|
|
|
|
function fullscreenOff() {
|
|
|
|
settings.wp_fullscreen = false;
|
|
|
|
editor.dom.removeClass( editor.getDoc().documentElement, 'wp-fullscreen' );
|
|
|
|
// Remove listeners for auto-resizing
|
|
|
|
editor.off( 'change setcontent paste keyup', resize );
|
|
|
|
oldSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For use from outside the editor.
|
|
|
|
editor.addCommand( 'wpFullScreenOn', fullscreenOn );
|
|
|
|
editor.addCommand( 'wpFullScreenOff', fullscreenOff );
|
|
|
|
|
|
|
|
function toggleFullscreen() {
|
|
|
|
// Toggle DFW mode. For use from inside the editor.
|
|
|
|
if ( typeof wp === 'undefined' || ! wp.editor || ! wp.editor.fullscreen ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( editor.getParam('wp_fullscreen') ) {
|
|
|
|
wp.editor.fullscreen.off();
|
|
|
|
} else {
|
|
|
|
wp.editor.fullscreen.on();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.addCommand( 'wpFullScreen', toggleFullscreen );
|
|
|
|
|
|
|
|
editor.on( 'init', function() {
|
|
|
|
// Set the editor when initializing from whitin DFW
|
|
|
|
if ( editor.getParam('wp_fullscreen') ) {
|
|
|
|
fullscreenOn();
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.addShortcut( 'alt+shift+w', '', 'wpFullScreen' );
|
|
|
|
});
|
|
|
|
|
|
|
|
// Register buttons
|
|
|
|
editor.addButton( 'wp_fullscreen', {
|
|
|
|
tooltip: 'Distraction Free Writing',
|
|
|
|
shortcut: 'Alt+Shift+W',
|
|
|
|
onclick: toggleFullscreen
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.addMenuItem( 'wp_fullscreen', {
|
|
|
|
text: 'Distraction Free Writing',
|
|
|
|
shortcut: 'Alt+Shift+W',
|
|
|
|
context: 'view',
|
|
|
|
onclick: toggleFullscreen
|
|
|
|
});
|
|
|
|
});
|