2 * editor_plugin_src.js
\r
4 * Copyright 2009, Moxiecode Systems AB
\r
5 * Released under LGPL License.
\r
7 * License: http://tinymce.moxiecode.com/license
\r
8 * Contributing: http://tinymce.moxiecode.com/contributing
\r
12 tinymce.create('tinymce.plugins.PageBreakPlugin', {
\r
13 init : function(ed, url) {
\r
14 var pb = '<img src="' + url + '/img/trans.gif" class="mcePageBreak mceItemNoResize" />', cls = 'mcePageBreak', sep = ed.getParam('pagebreak_separator', '<!-- pagebreak -->'), pbRE;
\r
16 pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
\r
18 // Register commands
\r
19 ed.addCommand('mcePageBreak', function() {
\r
20 ed.execCommand('mceInsertContent', 0, pb);
\r
24 ed.addButton('pagebreak', {title : 'pagebreak.desc', cmd : cls});
\r
26 ed.onInit.add(function() {
\r
27 if (ed.settings.content_css !== false)
\r
28 ed.dom.loadCSS(url + "/css/content.css");
\r
30 if (ed.theme.onResolveName) {
\r
31 ed.theme.onResolveName.add(function(th, o) {
\r
32 if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls))
\r
33 o.name = 'pagebreak';
\r
38 ed.onClick.add(function(ed, e) {
\r
41 if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls))
\r
42 ed.selection.select(e);
\r
45 ed.onNodeChange.add(function(ed, cm, n) {
\r
46 cm.setActive('pagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
\r
49 ed.onBeforeSetContent.add(function(ed, o) {
\r
50 o.content = o.content.replace(pbRE, pb);
\r
53 ed.onPostProcess.add(function(ed, o) {
\r
55 o.content = o.content.replace(/<img[^>]+>/g, function(im) {
\r
56 if (im.indexOf('class="mcePageBreak') !== -1)
\r
64 getInfo : function() {
\r
66 longname : 'PageBreak',
\r
67 author : 'Moxiecode Systems AB',
\r
68 authorurl : 'http://tinymce.moxiecode.com',
\r
69 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak',
\r
70 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
76 tinymce.PluginManager.add('pagebreak', tinymce.plugins.PageBreakPlugin);
\r