只读模式
group, 分享
评论更多问题
博客标签总是存在一个
This commit is contained in:
lealife
2015-06-15 18:01:48 +08:00
parent 7e458bb433
commit 6987a38820
1453 changed files with 114561 additions and 91536 deletions

38
public/tinymce/plugins/preview/plugin.js Normal file → Executable file
View File

@ -11,14 +11,14 @@
/*global tinymce:true */
tinymce.PluginManager.add('preview', function(editor) {
var settings = editor.settings;
var settings = editor.settings, sandbox = !tinymce.Env.ie;
editor.addCommand('mcePreview', function() {
editor.windowManager.open({
title: 'Preview',
width : parseInt(editor.getParam("plugin_preview_width", "650"), 10),
height : parseInt(editor.getParam("plugin_preview_height", "500"), 10),
html: '<iframe src="javascript:\'\'" frameborder="0"></iframe>',
width: parseInt(editor.getParam("plugin_preview_width", "650"), 10),
height: parseInt(editor.getParam("plugin_preview_height", "500"), 10),
html: '<iframe src="javascript:\'\'" frameborder="0"' + (sandbox ? ' sandbox="allow-scripts"' : '') + '></iframe>',
buttons: {
text: 'Close',
onclick: function() {
@ -26,7 +26,9 @@ tinymce.PluginManager.add('preview', function(editor) {
}
},
onPostRender: function() {
var doc = this.getEl('body').firstChild.contentWindow.document, previewHtml, headHtml = '';
var previewHtml, headHtml = '';
headHtml += '<base href="' + editor.documentBaseURI.getURI() + '">';
tinymce.each(editor.contentCSS, function(url) {
headHtml += '<link type="text/css" rel="stylesheet" href="' + editor.documentBaseURI.toAbsolute(url) + '">';
@ -44,33 +46,43 @@ tinymce.PluginManager.add('preview', function(editor) {
bodyClass = bodyClass[editor.id] || '';
}
var dirAttr = editor.settings.directionality ? ' dir="' + editor.settings.directionality + '"' : '';
previewHtml = (
'<!DOCTYPE html>' +
'<html>' +
'<head>' +
headHtml +
'</head>' +
'<body id="' + bodyId + '" class="mce-content-body ' + bodyClass + '">' +
'<body id="' + bodyId + '" class="mce-content-body ' + bodyClass + '"' + dirAttr + '>' +
editor.getContent() +
'</body>' +
'</html>'
);
doc.open();
doc.write(previewHtml);
doc.close();
if (!sandbox) {
// IE 6-11 doesn't support data uris on iframes
// so I guess they will have to be less secure since we can't sandbox on those
// TODO: Use sandbox if future versions of IE supports iframes with data: uris.
var doc = this.getEl('body').firstChild.contentWindow.document;
doc.open();
doc.write(previewHtml);
doc.close();
} else {
this.getEl('body').firstChild.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(previewHtml);
}
}
});
});
editor.addButton('preview', {
title : 'Preview',
cmd : 'mcePreview'
title: 'Preview',
cmd: 'mcePreview'
});
editor.addMenuItem('preview', {
text : 'Preview',
cmd : 'mcePreview',
text: 'Preview',
cmd: 'mcePreview',
context: 'view'
});
});

2
public/tinymce/plugins/preview/plugin.min.js vendored Normal file → Executable file
View File

@ -1 +1 @@
tinymce.PluginManager.add("preview",function(e){var t=e.settings;e.addCommand("mcePreview",function(){e.windowManager.open({title:"Preview",width:parseInt(e.getParam("plugin_preview_width","650"),10),height:parseInt(e.getParam("plugin_preview_height","500"),10),html:'<iframe src="javascript:\'\'" frameborder="0"></iframe>',buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var n,r=this.getEl("body").firstChild.contentWindow.document,i="";tinymce.each(e.contentCSS,function(t){i+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'">'});var o=t.body_id||"tinymce";-1!=o.indexOf("=")&&(o=e.getParam("body_id","","hash"),o=o[e.id]||o);var a=t.body_class||"";-1!=a.indexOf("=")&&(a=e.getParam("body_class","","hash"),a=a[e.id]||""),n="<!DOCTYPE html><html><head>"+i+"</head>"+'<body id="'+o+'" class="mce-content-body '+a+'">'+e.getContent()+"</body>"+"</html>",r.open(),r.write(n),r.close()}})}),e.addButton("preview",{title:"Preview",cmd:"mcePreview"}),e.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})});
tinymce.PluginManager.add("preview",function(a){var b=a.settings,c=!tinymce.Env.ie;a.addCommand("mcePreview",function(){a.windowManager.open({title:"Preview",width:parseInt(a.getParam("plugin_preview_width","650"),10),height:parseInt(a.getParam("plugin_preview_height","500"),10),html:'<iframe src="javascript:\'\'" frameborder="0"'+(c?' sandbox="allow-scripts"':"")+"></iframe>",buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var d,e="";e+='<base href="'+a.documentBaseURI.getURI()+'">',tinymce.each(a.contentCSS,function(b){e+='<link type="text/css" rel="stylesheet" href="'+a.documentBaseURI.toAbsolute(b)+'">'});var f=b.body_id||"tinymce";-1!=f.indexOf("=")&&(f=a.getParam("body_id","","hash"),f=f[a.id]||f);var g=b.body_class||"";-1!=g.indexOf("=")&&(g=a.getParam("body_class","","hash"),g=g[a.id]||"");var h=a.settings.directionality?' dir="'+a.settings.directionality+'"':"";if(d="<!DOCTYPE html><html><head>"+e+'</head><body id="'+f+'" class="mce-content-body '+g+'"'+h+">"+a.getContent()+"</body></html>",c)this.getEl("body").firstChild.src="data:text/html;charset=utf-8,"+encodeURIComponent(d);else{var i=this.getEl("body").firstChild.contentWindow.document;i.open(),i.write(d),i.close()}}})}),a.addButton("preview",{title:"Preview",cmd:"mcePreview"}),a.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})});