- md5
- 27d778f978636faf8d0ab6503d125a27
- sha1
- 2772ee8ae12e08726b629c5d65b1e0637f394482
- sha256
- eb7f7e5ff8c162a5e6e28b29281036e2c14f8e5ca659d4eb67cd175c15970988
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
/* global tinymce */
/**
* WP Fullscreen (Distraction Free Writing) TinyMCE plugin
*/
tinymce.PluginManager.add( 'wpfullscreen', function( editor ) {
var settings = editor.settings;
function fullscreenOn() {
settings.wp_fullscreen = true;
editor.dom.addClass( editor.getDoc().documentElement, 'wp-fullscreen' );
// Start auto-resizing
editor.execCommand( 'wpAutoResizeOn' );
}
function fullscreenOff() {
settings.wp_fullscreen = false;
editor.dom.removeClass( editor.getDoc().documentElement, 'wp-fullscreen' );
// Stop auto-resizing
editor.execCommand( 'wpAutoResizeOff' );
}
// For use from outside the editor.
editor.addCommand( 'wpFullScreenOn', fullscreenOn );
editor.addCommand( 'wpFullScreenOff', fullscreenOff );
function getExtAPI() {
return ( typeof wp !== 'undefined' && wp.editor && wp.editor.fullscreen );
}
// Toggle DFW mode. For use from inside the editor.
function toggleFullscreen() {
var fullscreen = getExtAPI();
if ( fullscreen ) {
if ( editor.getParam('wp_fullscreen') ) {
fullscreen.off();
} else {
fullscreen.on();
}
}
}
editor.addCommand( 'wpFullScreen', toggleFullscreen );
editor.on( 'keydown', function( event ) {
var fullscreen;
// Turn fullscreen off when Esc is pressed.
if ( event.keyCode === 27 && ( fullscreen = getExtAPI() ) && fullscreen.settings.visible ) {
fullscreen.off();
}
});
editor.on( 'init', function() {
// Set the editor when initializing from whitin DFW
if ( editor.getParam('wp_fullscreen') ) {
fullscreenOn();
}
});
// Register buttons
editor.addButton( 'wp_fullscreen', {
tooltip: 'Distraction Free Writing',
shortcut: 'Alt+Shift+W',
onclick: toggleFullscreen,
classes: 'wp-fullscreen btn widget' // This overwrites all classes on the container!
});
editor.addMenuItem( 'wp_fullscreen', {
text: 'Distraction Free Writing',
icon: 'wp_fullscreen',
shortcut: 'Alt+Shift+W',
context: 'view',
onclick: toggleFullscreen
});
});
No other release has this exact content. See every version of this file.