1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-29 10:38:08 +01:00

Tinymce pagebreak ([newpage]) button added.

This commit is contained in:
CaMer0n 2012-10-11 02:31:30 +00:00
parent ebe5cd2948
commit f27bbc1c30
9 changed files with 22 additions and 12 deletions

View File

@ -9,25 +9,35 @@
*/
(function() {
tinymce.create('tinymce.plugins.PageBreakPlugin', {
tinymce.create('tinymce.plugins.ePageBreakPlugin', {
init : function(ed, url) {
var pb = '<img src="' + ed.theme.url + '/img/trans.gif" class="mcePageBreak mceItemNoResize" />', cls = 'mcePageBreak', sep = ed.getParam('pagebreak_separator', '<!-- pagebreak -->'), pbRE;
pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
// Register commands
ed.addCommand('mcePageBreak', function() {
ed.execCommand('mceInsertContent', 0, pb);
ed.addCommand('mcePageBreak', function()
{
// var name = prompt("Please enter title for this page","");
// ed.execCommand('mceInsertContent', 0, "<div class='newpage' readonly='readonly' style='background-color:silver'>"+ name + "</div>");
// ed.execCommand('mceInsertContent', 0, "[newpage="+ name + "]");
ed.execCommand('mceInsertContent', 0, "[newpage]");
});
// Register buttons
ed.addButton('pagebreak', {title : 'pagebreak.desc', cmd : cls});
ed.addButton('epagebreak', {
title : 'pagebreak.desc',
cmd : cls,
image : url + '/img/epagebreak.gif'
});
ed.onInit.add(function() {
if (ed.theme.onResolveName) {
ed.theme.onResolveName.add(function(th, o) {
if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls))
o.name = 'pagebreak';
o.name = 'epagebreak';
});
}
});
@ -40,7 +50,7 @@
});
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('pagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
cm.setActive('epagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
});
ed.onBeforeSetContent.add(function(ed, o) {
@ -60,7 +70,7 @@
getInfo : function() {
return {
longname : 'PageBreak',
longname : 'ePageBreak',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak',
@ -70,5 +80,5 @@
});
// Register plugin
tinymce.PluginManager.add('pagebreak', tinymce.plugins.PageBreakPlugin);
tinymce.PluginManager.add('epagebreak', tinymce.plugins.ePageBreakPlugin);
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1 +0,0 @@
(function(){tinymce.create("tinymce.plugins.PageBreakPlugin",{init:function(b,d){var f='<img src="'+b.theme.url+'/img/trans.gif" class="mcePageBreak mceItemNoResize" />',a="mcePageBreak",c=b.getParam("pagebreak_separator","<!-- pagebreak -->"),e;e=new RegExp(c.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(g){return"\\"+g}),"g");b.addCommand("mcePageBreak",function(){b.execCommand("mceInsertContent",0,f)});b.addButton("pagebreak",{title:"pagebreak.desc",cmd:a});b.onInit.add(function(){if(b.theme.onResolveName){b.theme.onResolveName.add(function(g,h){if(h.node.nodeName=="IMG"&&b.dom.hasClass(h.node,a)){h.name="pagebreak"}})}});b.onClick.add(function(g,h){h=h.target;if(h.nodeName==="IMG"&&g.dom.hasClass(h,a)){g.selection.select(h)}});b.onNodeChange.add(function(h,g,i){g.setActive("pagebreak",i.nodeName==="IMG"&&h.dom.hasClass(i,a))});b.onBeforeSetContent.add(function(g,h){h.content=h.content.replace(e,f)});b.onPostProcess.add(function(g,h){if(h.get){h.content=h.content.replace(/<img[^>]+>/g,function(i){if(i.indexOf('class="mcePageBreak')!==-1){i=c}return i})}})},getInfo:function(){return{longname:"PageBreak",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("pagebreak",tinymce.plugins.PageBreakPlugin)})();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 B

View File

@ -1 +1 @@
<?xml version="1.0"?> <tinymce> <tinymce_name>Administrators</tinymce_name> <tinymce_plugins>contextmenu,e107bbcode,emoticons,ibrowser,iespell,jqueryinlinepopups,paste,table,xhtmlxtras</tinymce_plugins> <tinymce_buttons1>bold, italic, underline, undo, redo, link, unlink, image, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, code, emoticons</tinymce_buttons1> <extended_valid_elements>object[*],embed[*]</extended_valid_elements> </tinymce>
<?xml version="1.0"?> <tinymce> <tinymce_name>Administrators</tinymce_name> <tinymce_plugins>contextmenu,e107bbcode,emoticons,ibrowser,iespell,jqueryinlinepopups,paste,table,xhtmlxtras,youtube,epagebreak</tinymce_plugins> <tinymce_buttons1>bold, italic, underline, undo, redo, link, unlink, image, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, code, emoticons,youtube,epagebreak</tinymce_buttons1> <extended_valid_elements>object[*],embed[*]</extended_valid_elements> </tinymce>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<tinymce>
<tinymce_name>Main Admin</tinymce_name>
<tinymce_plugins>advhr,advlink,autosave,contextmenu,directionality,e107bbcode,emoticons,ibrowser,paste,table,visualchars,wordcount,xhtmlxtras,youtube</tinymce_plugins>
<tinymce_buttons1>link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube</tinymce_buttons1>
<tinymce_plugins>advhr,advlink,autosave,contextmenu,directionality,e107bbcode,emoticons,ibrowser,paste,table,visualchars,wordcount,xhtmlxtras,youtube,epagebreak</tinymce_plugins>
<tinymce_buttons1>link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube, epagebreak</tinymce_buttons1>
<extended_valid_elements>object[*],embed[*]</extended_valid_elements>
</tinymce>

View File

@ -258,6 +258,7 @@ class wysiwyg
'theme_advanced_resizing' => 'false',
'remove_linebreaks' => 'true',
'extended_valid_elements' => vartrue($config['extended_valid_elements']),
// 'pagebreak_separator' => "[newpage]",
'apply_source_formatting' => 'false',
'invalid_elements' => 'p,font,align,script,applet',
'auto_cleanup_word' => 'true',