Project

General

Profile

1
/**
2
 *  @module         ckeditor
3
 *  @version        see info.php of this module
4
 *  @authors        Michael Tenschert, Dietrich Roland Pehlke, Dietmar Wöllbrink, Marmot, Luisehahne
5
 *  @copyright      Frederico Knabben
6
 *  @license        GNU General Public License
7
 *  @license terms  see info.php of this module
8
 *  @platform       see info.php of this module
9
 *  @requirements   PHP 5.2.x and higher
10
 */
11

    
12
/*
13
* WARNING: Clear the cache of your browser cache after you modify this file!
14
* If you don't do this, you may notice that your browser is ignoring all your changes.
15
*
16
* --------------------------------------------------
17
*
18
* Note: Some CKEditor configs are set in _yourwb_/modules/ckeditor/include.php
19
*
20
* Example: "$ckeditor->config['toolbar']" is PHP code in include.php. The very same here in the 
21
* wb_ckconfig.js would be: "config.toolbar" inside CKEDITOR.editorConfig = function( config ). 
22
*
23
* Please read "readme-faq.txt" in the wb_config folder for more information about customizing.
24
* 
25
*/
26

    
27
CKEDITOR.editorConfig = function( config )
28
{
29
    // Define changes to default configuration here.
30
    // For complete reference see:
31
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config
32

    
33
  // Different Toolbars. Remove, add or move 'SomeButton', with the quotes and following comma 
34
    config.toolbar_Full =
35
    [
36
        { name: 'document',  items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
37
        { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
38
        { name: 'editing',   items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
39
        { name: 'forms',     items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
40
        '/',
41
        { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
42
        { name: 'paragraph',   items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
43
        { name: 'links',       items : [ 'Link','Unlink','Anchor' ] },
44
        { name: 'insert',      items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
45
        '/',
46
        { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
47
        { name: 'colors', items : [ 'TextColor','BGColor' ] },
48
        { name: 'tools',  items : [ 'Maximize', 'ShowBlocks','-','About' ] }
49
    ];
50
  config.toolbar_WB_Basic = [
51
            ['Source','Preview'],['Cut','Copy','Paste','PasteText','PasteFromWord'],['Image','Flash','Table','HorizontalRule'],['Wbdroplets','Wblink','Unlink','Anchor'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Maximize','ShowBlocks','-','Code','About'],'/',
52
            ['Styles','Format','Font','FontSize'],['TextColor','BGColor'],['Bold','Italic','Underline','Strike'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv']];
53

    
54
    // see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
55
    config.toolbar_WB_Full =
56
    [
57
        { name: 'document', items : [ 'Source','-','Save','Print','-','DocProps','Preview','NewPage','-','Templates' ] },
58
        { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
59
        { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
60
        { name: 'colors', items : [ 'TextColor','BGColor' ] },
61
        { name: 'tools', items : [ 'Maximize', 'ShowBlocks','Code','-','About' ] },
62
        '/',
63
        { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','Shy','-','RemoveFormat' ] },
64
        { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
65
         { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton','HiddenField' ] },
66
        '/',
67
        { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
68
        { name: 'links', items : [ 'Link','Unlink','Anchor','Wbdroplets','Wblink' ] },
69
        { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }
70

    
71
    ];
72

    
73
    config.toolbar_WB_Default =
74
    [
75
        { name: 'mode', items : [ 'Source','autoFormat','CommentSelectedRange','UncommentSelectedRange' ] },
76
        { name: 'document', items : [ 'Save','wbSave','Print','-','Preview','NewPage','-','Templates' ] },
77
        { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','Backup' ] },
78
        { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
79
        '/',
80
        { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','Shy','-','RemoveFormat' ] },
81
        { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
82
        { name: 'links', items : [ 'Wbdroplets','Wblink','Unlink','Anchor' ] },
83
        { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe','Youtube','oembed', 'slideshow' ] },
84
        '/',
85
        { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
86
        { name: 'colors', items : [ 'TextColor','BGColor' ] },
87
        { name: 'tools', items : [ 'Maximize', 'ShowBlocks','Syntaxhighlight','-','About' ] }
88

    
89
    ];
90

    
91
    config.toolbar_Basic = [['Bold','Italic','-','NumberedList','BulletedList','-','Link','Unlink','-','Code','About']];
92
    config.toolbar_WB_Simple = [['Bold','Italic','-','NumberedList','BulletedList','-','Wbdroplets','Wblink','Unlink','-','Scayt','-','Code','About']];
93

    
94
    // The default toolbar. Default: WB_Default
95
  config.toolbar = 'WB_Default';
96

    
97
  // The standard color of CKEditor. Can be changed in any hexadecimal color you like. Use the     
98
  // UIColor Plugin in your CKEditor to pick the right color.
99
    config.uiColor = '#BFD7EB';
100

    
101
    config.browserContextMenuOnCtrl = true;
102

    
103
    config.ModulVersiom  = '';
104

    
105
    config.fullPage = false;
106

    
107
    config.format_tags = 'p;div;h1;h2;h3;h4;h5;h6;pre;address';
108

    
109
    config.resize_dir = 'resize_dir';
110

    
111
    config.autoParagraph = true;
112

    
113
    /* The skin to load. It may be the name of the skin folder inside the editor installation path,
114
    * or the name and the path separated by a comma. 
115
    * Available skins: moono, moonocolor*/
116
    config.skin = 'moonocolor';
117

    
118
  // Define all extra CKEditor plugins in _yourwb_/modules/ckeditor/ckeditor/plugins here
119
  //config.extraPlugins = 'timestamp';
120
    config.extraPlugins  = 'justify,find,flash,colorbutton,colordialog,dialogadvtab,'
121
                         + 'div,font,forms,iframe,indentblock,language,bidi,liststyle,pagebreak,save,'
122
                         + 'selectall,showblocks,smiley,templates,codemirror,autogrow,'
123
                         + 'wblink,wbdroplets,youtube,oembed,backup,wbsave,wbrelation,wbabout';
124

    
125
    config.removePlugins = 'wsc,link,save,newpage,print,shybutton,syntaxhighlight,preview,sourcearea,sourcedialog';
126

    
127
    config.browserContextMenuOnCtrl = true;
128

    
129
    config.entities = false;
130

    
131
    config.scayt_autoStartup = false;
132

    
133
    // The standard height and width of CKEditor in pixels.
134
    config.height           = '250';
135
    config.width            = '900';
136
    config.toolbarLocation  = 'top';
137

    
138
    config.autoGrow_minHeight = 250;
139
    config.autoGrow_maxHeight = 600;
140
    config.autoGrow_bottomSpace = 50;
141
    config.autoGrow_onStartup = true;
142

    
143
    // Define possibilities of automatic resizing in pixels. Set config.resize_enabled to false to 
144
    // deactivate resizing.
145
    config.resize_enabled   = true;
146
    config.resize_minWidth  = 500;
147
    config.resize_maxWidth  = 1500;
148
    config.resize_minHeight = 200;
149
    config.resize_maxHeight = 1200;
150
    config.resize_dir = 'vertical';
151

    
152
  config.docType           = '<!DOCTYPE html>';
153

    
154
  config.image_previewText = 'WebsiteBaker helps you to create the website you want: A free, easy and secure, flexible and extensible open source content management system (CMS). Create new templates within minutes - powered by (X)HTML, CSS and jQuery. With WebsiteBaker it\'s quite natural your site is W3C-valid, SEO-friendly and accessible - there are no limitations at all. Use droplets - the new and revolutionary way of inserting PHP code - everywhere you want. In addition to that, WebsiteBaker and the community are offering lots of extensions: Just download, install with two clicks and use them. That is not enough? You want more? No problem, build your own modules! The WebsiteBaker API gives many opportunities you can rely on.';
155

    
156
  // Both options are for XHTML 1.0 strict compatibility
157
  // config.indentClasses = [ 'indent1', 'indent2', 'indent3', 'indent4' ];
158
  // [ Left, Center, Right, Justified ]
159
  // config.justifyClasses = [ 'left', 'center', 'right', 'justify' ];
160

    
161
  config.templates_replaceContent =   false;
162

    
163
  config.syntaxhighlight_lang = 'js', 'jscript', 'javascript', 'perl', 'Perl', 'pl', 'php', 'text', 'plain', 'sass', 'scss', 'scala', 'sql', 'xml', 'xhtml', 'xslt', 'html';
164

    
165
  // Explanation: _P: new <p> paragraphs are created; _BR: lines are broken with <br> elements;
166
  //              _DIV: new <div> blocks are created.
167
  // Sets the behavior for the ENTER key. Default is _P allowed tags: _P | _BR | _DIV
168
  config.enterMode = CKEDITOR.ENTER_P;
169

    
170
  // Sets the behavior for the Shift + ENTER keys. allowed tags: _P | _BR | _DIV
171
  config.shiftEnterMode = CKEDITOR.ENTER_BR;
172

    
173
  /* Allows to force CKEditor not to localize the editor to the user language. 
174
  * Default: Empty (''); Example: ('fr') for French. 
175
  * Note: Language configuration is based on the backend language of WebsiteBaker. 
176
  * It's defined in include.php
177
  * config.language         = ''; */
178
  // The language to be used if config.language is empty and it's not possible to localize the editor to the user language.
179
  config.defaultLanguage   = 'en';
180

    
181
    /* Protect PHP code tags (<?...?>) so CKEditor will not break them when switching from Source to WYSIWYG.
182
    *  Uncommenting this line doesn't mean the user will not be able to type PHP code in the source.
183
    *  This kind of prevention must be done in the server side, so just leave this line as is. */ 
184
    config.protectedSource.push(/<\?[\s\S]*?\?>/g); // PHP Code
185

    
186
    //disable ckes Advanced Content Filter (ACF) to avoid wblinks to be filtered?
187
    config.allowedContent = true;
188

    
189
    // Simplify the dialog windows.
190
//    config.removeDialogTabs = 'image:advanced;link:advanced';
191

    
192
};
193

    
194
CKEDITOR.on( 'instanceReady', function( ev )
195
{
196
    var writer = ev.editor.dataProcessor.writer;
197
    // The character sequence to use for every indentation step.
198
    writer.indentationChars = '\t';
199
    // The way to close self closing tags, like <br />.
200
    writer.selfClosingEnd   = ' />';
201
    // The character sequence to be used for line breaks.
202
    writer.lineBreakChars   = '\n';
203
    // Setting rules for several HTML tags.
204
    
205
    var dtd = CKEDITOR.dtd;
206
    for (var e in CKEDITOR.tools.extend( {}, dtd.$block ))
207
    {
208
        writer.setRules( e,
209
        {
210
            // Indicates that this tag causes indentation on line breaks inside of it.
211
            indent : false,
212
            // Insert a line break before the <h1> tag.
213
            breakBeforeOpen : true,
214
            // Insert a line break after the <h1> tag.
215
            breakAfterOpen : false,
216
            // Insert a line break before the </h1> closing tag.
217
            breakBeforeClose : false,
218
            // Insert a line break after the </h1> closing tag.
219
            breakAfterClose : true
220
        });
221
    };
222
    writer.setRules( 'p',
223
    {
224
        // Indicates that this tag causes indentation on line breaks inside of it.
225
        indent : false,
226
        // Insert a line break before the <p> tag.
227
        breakBeforeOpen : true,
228
        // Insert a line break after the <p> tag.
229
        breakAfterOpen : false,
230
        // Insert a line break before the </p> closing tag.
231
        breakBeforeClose : false,
232
        // Insert a line break after the </p> closing tag.
233
        breakAfterClose : true
234
    });
235
    writer.setRules( 'br',
236
    {
237
        // Indicates that this tag causes indentation on line breaks inside of it.
238
        indent : false,
239
        // Insert a line break before the <br /> tag.
240
        breakBeforeOpen : false,
241
        // Insert a line break after the <br /> tag.
242
        breakAfterOpen : true
243
    });
244
    writer.setRules( 'a',
245
    {
246
        // Indicates that this tag causes indentation on line breaks inside of it.
247
        indent : false,
248
        // Insert a line break before the <a> tag.
249
        breakBeforeOpen : true,
250
        // Insert a line break after the <a> tag.
251
        breakAfterOpen : false,
252
        // Insert a line break before the </a> closing tag.
253
        breakBeforeClose : false,
254
        // Insert a line break after the </a> closing tag.
255
        breakAfterClose : false
256
    });
257
    writer.setRules( 'div',
258
    {
259
        // Indicates that this tag causes indentation on line breaks inside of it.
260
        indent : false,
261
        // Insert a line break before the <div> tag.
262
        breakBeforeOpen : true,
263
        // Insert a line break after the <div> tag.
264
        breakAfterOpen : false,
265
        // Insert a line break before the </div> closing tag.
266
        breakBeforeClose : true,
267
        // Insert a line break after the </div> closing tag.
268
        breakAfterClose : false
269
    });
270
    writer.setRules( 'img',
271
    {
272
        // Indicates that this tag causes indentation on line breaks inside of it.
273
        indent : false,
274
        // Insert a line break before the <img> tag.
275
        breakBeforeOpen : true,
276
        // Insert a line break after the <img> tag.
277
        breakAfterOpen : false,
278
        // Insert a line break before the </img>> closing tag.
279
        breakBeforeClose : false,
280
        // Insert a line break after the </img> closing tag.
281
        breakAfterClose : false
282
    });
283

    
284
    ev.editor.dataProcessor.htmlFilter.addRules(
285
    {
286
        elements:
287
        {
288
            $: function (element) {
289
                // Output dimensions of images as width and height
290
                if (element.name == 'img') {
291
                    var style = element.attributes.style;
292
                    if (style) {
293
                        // Get the width from the style.
294
                        var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec(style),
295
                            width = match && match[1];
296

    
297
                        // Get the height from the style.
298
                        match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec(style);
299
                        var height = match && match[1];
300
console.log( element );
301

    
302
                        if (width) {
303
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)width\s*:\s*(\d+)px;?/i, '');
304
                            element.attributes.width = width;
305
                        }
306

    
307
                        if (height) {
308
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)height\s*:\s*(\d+)px;?/i, '');
309
                            element.attributes.height = height;
310
                        }
311
                    }
312
                }
313
/**
314
 * 
315
                if (!element.attributes.style)
316
                    delete element.attributes.style;
317
 */
318

    
319
                return element;
320
            }
321
        }
322
    });
323

    
324
});
325

    
326
CKEDITOR.on( 'dialogDefinition', function( ev )
327
    {
328
        // Take the dialog name and its definition from the event data.
329
        var dialogName = ev.data.name;
330
        var dialogDefinition = ev.data.definition;
331

    
332
        // Check if the definition is from the dialog window you are interested in (the "Link" dialog window).
333
        if ( dialogName == 'image' )
334
        {
335
            // Get a reference to the "Link Info" tab.
336
            var linkTab = dialogDefinition.getContents('Link');
337
        }
338
        // Check if the definition is from the dialog window you are interested in (the "Link" dialog window).
339
        if ( dialogName == 'wblink' )
340
        {
341
            // Get a reference to the "Link Info" tab.
342
            var infoTab = dialogDefinition.getContents( 'info' );
343
            // Set the default value for the URL field.
344
            var urlField = infoTab.get( 'url' );
345
            urlField['default'] = 'www.example.com';
346
        }
347

    
348
    // Ends self closing tags the HTML4 way, like <br>.
349

    
350

    
351
    });
(2-2/9)