first commit
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
/*
|
||||
Distraction Free Writing mode TinyMCE Styles
|
||||
*/
|
||||
|
||||
html,
|
||||
body {
|
||||
background: transparent;
|
||||
width: auto !important;
|
||||
max-width: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
min-height: 0 !important;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
(function(){tinymce.create("tinymce.plugins.wpFullscreenPlugin",{resize_timeout:false,init:function(a,c){var d=this,g=0,e={},f=tinymce.DOM;a.addCommand("wpFullScreenClose",function(){if(a.getParam("wp_fullscreen_is_enabled")){f.win.setTimeout(function(){tinyMCE.remove(a);f.remove("wp_mce_fullscreen_parent");tinyMCE.settings=tinyMCE.oldSettings},10)}});a.addCommand("wpFullScreenSave",function(){var h=tinyMCE.get("wp_mce_fullscreen"),i;h.focus();i=tinyMCE.get(h.getParam("wp_fullscreen_editor_id"));i.setContent(h.getContent({format:"raw"}),{format:"raw"})});a.addCommand("wpFullScreenInit",function(){var j,h,i;a=tinyMCE.activeEditor;j=a.getDoc();h=j.body;tinyMCE.oldSettings=tinyMCE.settings;tinymce.each(a.settings,function(k,l){e[l]=k});e.id="wp_mce_fullscreen";e.wp_fullscreen_is_enabled=true;e.wp_fullscreen_editor_id=a.id;e.theme_advanced_resizing=false;e.theme_advanced_statusbar_location="none";e.content_css=e.content_css?e.content_css+","+e.wp_fullscreen_content_css:e.wp_fullscreen_content_css;e.height=tinymce.isIE?h.scrollHeight:h.offsetHeight;tinymce.each(a.getParam("wp_fullscreen_settings"),function(m,l){e[l]=m});i=new tinymce.Editor("wp_mce_fullscreen",e);i.onInit.add(function(k){var m=tinymce.DOM,l=m.select("a.mceButton",m.get("wp-fullscreen-buttons"));if(!a.isHidden()){k.setContent(a.getContent())}else{k.setContent(switchEditors.wpautop(k.getElement().value))}setTimeout(function(){k.onNodeChange.add(function(o,n,p){tinymce.each(l,function(s){var r,q;if(r=m.get("wp_mce_fullscreen_"+s.id.substr(6))){q=r.className;if(q){s.className=q}}})})},1000);k.dom.addClass(k.getBody(),"wp-fullscreen-editor");k.focus()});i.render();if("undefined"!=fullscreen){i.dom.bind(i.dom.doc,"mousemove",function(k){fullscreen.bounder("showToolbar","hideToolbar",2000,k)})}});a.addCommand("wpFullScreen",function(){if(typeof(fullscreen)=="undefined"){return}if("wp_mce_fullscreen"==a.id){fullscreen.off()}else{fullscreen.on()}});a.addButton("wp_fullscreen",{title:"wordpress.wp_fullscreen_desc",cmd:"wpFullScreen"});if(a.getParam("fullscreen_is_enabled")||!a.getParam("wp_fullscreen_is_enabled")){return}function b(j,l){var k=tinymce.DOM,i=a.getBody(),n=k.get(a.id+"_ifr"),h,m=a.dom.win.scrollY;if(d.resize_timeout){return}d.resize_timeout=true;setTimeout(function(){d.resize_timeout=false},500);h=i.scrollHeight>300?i.scrollHeight:300;if(h!=n.scrollHeight){k.setStyle(n,"height",h+"px");a.getWin().scrollTo(0,0)}if(l&&l.type=="paste"&&tinymce.isWebKit){setTimeout(function(){a.dom.win.scrollTo(0,m)},40)}}a.onInit.add(function(i,h){i.onChange.add(b);i.onSetContent.add(b);i.onPaste.add(b);i.onKeyUp.add(b);i.onPostRender.add(b);i.getBody().style.overflowY="hidden"});if(a.getParam("autoresize_on_init",true)){a.onLoadContent.add(function(i,h){setTimeout(function(){b()},1200)})}a.addCommand("wpAutoResize",b)},getInfo:function(){return{longname:"WP Fullscreen",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpfullscreen",tinymce.plugins.wpFullscreenPlugin)})();
|
||||
189
wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin_src.js
Normal file
189
wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin_src.js
Normal file
@ -0,0 +1,189 @@
|
||||
/**
|
||||
* WP Fullscreen TinyMCE plugin
|
||||
*
|
||||
* Contains code from Moxiecode Systems AB released under LGPL License http://tinymce.moxiecode.com/license
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.wpFullscreenPlugin', {
|
||||
resize_timeout: false,
|
||||
|
||||
init : function(ed, url) {
|
||||
var t = this, oldHeight = 0, s = {}, DOM = tinymce.DOM;
|
||||
|
||||
// Register commands
|
||||
ed.addCommand('wpFullScreenClose', function() {
|
||||
// this removes the editor, content has to be saved first with tinyMCE.execCommand('wpFullScreenSave');
|
||||
if ( ed.getParam('wp_fullscreen_is_enabled') ) {
|
||||
DOM.win.setTimeout(function() {
|
||||
tinyMCE.remove(ed);
|
||||
DOM.remove('wp_mce_fullscreen_parent');
|
||||
tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings
|
||||
}, 10);
|
||||
}
|
||||
});
|
||||
|
||||
ed.addCommand('wpFullScreenSave', function() {
|
||||
var ed = tinyMCE.get('wp_mce_fullscreen'), edd;
|
||||
|
||||
ed.focus();
|
||||
edd = tinyMCE.get( ed.getParam('wp_fullscreen_editor_id') );
|
||||
|
||||
edd.setContent( ed.getContent({format : 'raw'}), {format : 'raw'} );
|
||||
});
|
||||
|
||||
ed.addCommand('wpFullScreenInit', function() {
|
||||
var d, b, fsed;
|
||||
|
||||
ed = tinyMCE.activeEditor;
|
||||
d = ed.getDoc();
|
||||
b = d.body;
|
||||
|
||||
tinyMCE.oldSettings = tinyMCE.settings; // Store old settings
|
||||
|
||||
tinymce.each(ed.settings, function(v, n) {
|
||||
s[n] = v;
|
||||
});
|
||||
|
||||
s.id = 'wp_mce_fullscreen';
|
||||
s.wp_fullscreen_is_enabled = true;
|
||||
s.wp_fullscreen_editor_id = ed.id;
|
||||
s.theme_advanced_resizing = false;
|
||||
s.theme_advanced_statusbar_location = 'none';
|
||||
s.content_css = s.content_css ? s.content_css + ',' + s.wp_fullscreen_content_css : s.wp_fullscreen_content_css;
|
||||
s.height = tinymce.isIE ? b.scrollHeight : b.offsetHeight;
|
||||
|
||||
tinymce.each(ed.getParam('wp_fullscreen_settings'), function(v, k) {
|
||||
s[k] = v;
|
||||
});
|
||||
|
||||
fsed = new tinymce.Editor('wp_mce_fullscreen', s);
|
||||
fsed.onInit.add(function(edd) {
|
||||
var DOM = tinymce.DOM, buttons = DOM.select('a.mceButton', DOM.get('wp-fullscreen-buttons'));
|
||||
|
||||
if ( !ed.isHidden() )
|
||||
edd.setContent( ed.getContent() );
|
||||
else
|
||||
edd.setContent( switchEditors.wpautop( edd.getElement().value ) );
|
||||
|
||||
setTimeout(function(){ // add last
|
||||
edd.onNodeChange.add(function(ed, cm, e){
|
||||
tinymce.each(buttons, function(c) {
|
||||
var btn, cls;
|
||||
|
||||
if ( btn = DOM.get( 'wp_mce_fullscreen_' + c.id.substr(6) ) ) {
|
||||
cls = btn.className;
|
||||
|
||||
if ( cls )
|
||||
c.className = cls;
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
edd.dom.addClass(edd.getBody(), 'wp-fullscreen-editor');
|
||||
edd.focus();
|
||||
});
|
||||
|
||||
fsed.render();
|
||||
|
||||
if ( 'undefined' != fullscreen ) {
|
||||
fsed.dom.bind( fsed.dom.doc, 'mousemove', function(e){
|
||||
fullscreen.bounder( 'showToolbar', 'hideToolbar', 2000, e );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ed.addCommand('wpFullScreen', function() {
|
||||
if ( typeof(fullscreen) == 'undefined' )
|
||||
return;
|
||||
|
||||
if ( 'wp_mce_fullscreen' == ed.id )
|
||||
fullscreen.off();
|
||||
else
|
||||
fullscreen.on();
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
ed.addButton('wp_fullscreen', {
|
||||
title : 'wordpress.wp_fullscreen_desc',
|
||||
cmd : 'wpFullScreen'
|
||||
});
|
||||
|
||||
// END fullscreen
|
||||
//----------------------------------------------------------------
|
||||
// START autoresize
|
||||
|
||||
if ( ed.getParam('fullscreen_is_enabled') || !ed.getParam('wp_fullscreen_is_enabled') )
|
||||
return;
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize(editor, e) {
|
||||
var DOM = tinymce.DOM, body = ed.getBody(), ifr = DOM.get(ed.id + '_ifr'), height, y = ed.dom.win.scrollY;
|
||||
|
||||
if ( t.resize_timeout )
|
||||
return;
|
||||
|
||||
// sometimes several events are fired few ms apart, trottle down resizing a little
|
||||
t.resize_timeout = true;
|
||||
setTimeout(function(){
|
||||
t.resize_timeout = false;
|
||||
}, 500);
|
||||
|
||||
height = body.scrollHeight > 300 ? body.scrollHeight : 300;
|
||||
|
||||
if ( height != ifr.scrollHeight ) {
|
||||
DOM.setStyle(ifr, 'height', height + 'px');
|
||||
ed.getWin().scrollTo(0, 0); // iframe window object, make sure there's no scrolling
|
||||
}
|
||||
|
||||
// WebKit scrolls to top on paste...
|
||||
if ( e && e.type == 'paste' && tinymce.isWebKit ) {
|
||||
setTimeout(function(){
|
||||
ed.dom.win.scrollTo(0, y);
|
||||
}, 40);
|
||||
}
|
||||
};
|
||||
|
||||
// Add appropriate listeners for resizing content area
|
||||
ed.onInit.add(function(ed, l) {
|
||||
ed.onChange.add(resize);
|
||||
ed.onSetContent.add(resize);
|
||||
ed.onPaste.add(resize);
|
||||
ed.onKeyUp.add(resize);
|
||||
ed.onPostRender.add(resize);
|
||||
|
||||
ed.getBody().style.overflowY = "hidden";
|
||||
});
|
||||
|
||||
if ( ed.getParam('autoresize_on_init', true) ) {
|
||||
ed.onLoadContent.add(function(ed, l) {
|
||||
// Because the content area resizes when its content CSS loads,
|
||||
// and we can't easily add a listener to its onload event,
|
||||
// we'll just trigger a resize after a short loading period
|
||||
setTimeout(function() {
|
||||
resize();
|
||||
}, 1200);
|
||||
});
|
||||
}
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
||||
ed.addCommand('wpAutoResize', resize);
|
||||
},
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'WP Fullscreen',
|
||||
author : 'WordPress',
|
||||
authorurl : 'http://wordpress.org',
|
||||
infourl : '',
|
||||
version : '1.0'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('wpfullscreen', tinymce.plugins.wpFullscreenPlugin);
|
||||
})();
|
||||
Reference in New Issue
Block a user