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

    
51
  config.toolbar_WB_Mini = [
52
            ['Source','Cut','Copy'],['PasteText','PasteFromWord'],['Undo','Redo','-','RemoveFormat'],['Wbdroplets','Wblink','Unlink','Anchor'],['Image'],
53
            ['TextColor','BGColor'],['Bold','Italic','Underline','Strike'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
54
            ['Styles','Format','Font','FontSize'],['NumberedList','BulletedList','-','Blockquote','CreateDiv'],['CreatePlaceholder'],['About']];
55

    
56
  config.toolbar_WB_Basic = [
57
            ['Source','Preview'],['Cut','Copy','Paste','PasteText','PasteFromWord'],['Image','Flash','Table','HorizontalRule'],['Wbdroplets','Wblink','Unlink','Anchor'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Maximize','ShowBlocks','-','Code','About'],'/',
58
            ['Styles','Format','Font','FontSize'],['TextColor','BGColor'],['Bold','Italic','Underline','Strike'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv']];
59

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

    
77
    ];
78

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

    
95
    ];
96

    
97
    config.toolbar_Basic = [['Bold','Italic','-','NumberedList','BulletedList','-','Link','Unlink','-','Code','Image','About']];
98
    config.toolbar_WB_Simple = [['Bold','Italic','-','NumberedList','BulletedList','-','Wbdroplets','Wblink','Unlink','-','Scayt','-','Code','About']];
99

    
100
    // The default toolbar. Default: WB_Default
101
  config.toolbar = 'WB_Mini';
102

    
103
  // The standard color of CKEditor. Can be changed in any hexadecimal color you like. Use the
104
  // UIColor Plugin in your CKEditor to pick the right color.
105
    config.uiColor = '#BFD7EB';
106

    
107
    config.browserContextMenuOnCtrl = true;
108

    
109
    config.ModulVersion  = '4.6.2';
110
    config.WBrevision    = 'r6';
111
    config.WBversion     = '2.10';
112

    
113
    config.fullPage = false;
114

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

    
117
    config.autoParagraph = true;
118
/*
119
    config.sharedSpaces: {
120
        top: 'top',
121
        bottom: 'bottom'
122
    }
123
*/
124
    /* The skin to load. It may be the name of the skin folder inside the editor installation path,
125
    * or the name and the path separated by a comma.
126
    * Available skins: moono, moonocolor*/
127
    config.skin = 'moonocolor';
128

    
129
  // Define all extra CKEditor plugins in _yourwb_/modules/ckeditor/ckeditor/plugins here
130
  //config.extraPlugins = 'timestamp';
131
    config.extraPlugins  = 'justify,find,flash,colorbutton,colordialog,dialogadvtab'
132
                         + ',div,font,forms,iframe,indentblock,language,bidi,liststyle,pagebreak,save'
133
                         + ',selectall,showblocks,smiley,templates,codemirror,autogrow'
134
                         + ',wblink,wbdroplets,youtube,oembed,wbrelation,wbabout';
135

    
136
    config.removePlugins = 'wsc,link,save,newpage,print,shybutton,syntaxhighlight,preview,alphamanager,backup'
137
                         + ',sourcearea,sourcedialog,imageresponsive,image2,wbsave,youtube,language,flash,placeholder';
138

    
139
    config.browserContextMenuOnCtrl = true;
140

    
141
    config.entities = false;
142

    
143
    config.scayt_autoStartup = false;
144

    
145
    // The standard height and width of CKEditor in pixels.
146
    config.height           = '270';
147
    config.width            = '100%';
148
    config.toolbarLocation  = 'top';
149

    
150
    config.autoGrow_minHeight = 200;
151
    config.autoGrow_maxHeight = 350;
152
    config.autoGrow_bottomSpace = 50;
153
    config.autoGrow_onStartup = false;
154
    // Define possibilities of automatic resizing in pixels. Set config.resize_enabled to false to
155
    // deactivate resizing.
156
    config.resize_enabled   = true;
157
    config.resize_minWidth  = 500;
158
    config.resize_maxWidth  = 1500;
159
    config.resize_minHeight = 200;
160
    config.resize_maxHeight = 1678;
161
    config.resize_dir = 'both';
162

    
163
  config.docType = '<!DOCTYPE html>';
164

    
165
  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.';
166

    
167
  // Both options are for XHTML 1.0 strict compatibility
168
  // config.indentClasses = [ 'indent1', 'indent2', 'indent3', 'indent4' ];
169
  // [ Left, Center, Right, Justified ]
170
  // config.justifyClasses = [ 'left', 'center', 'right', 'justify' ];
171

    
172
  config.templates_replaceContent =   false;
173

    
174
  config.syntaxhighlight_lang = 'js', 'jscript', 'javascript', 'perl', 'Perl', 'php', 'text', 'plain', 'sass', 'scss', 'sql', 'xml', 'xhtml', 'xslt', 'html';
175

    
176
  // Explanation: _P: new <p> paragraphs are created; _BR: lines are broken with <br> elements;
177
  //              _DIV: new <div> blocks are created.
178
  // Sets the behavior for the ENTER key. Default is _P allowed tags: _P | _BR | _DIV
179
  config.enterMode = CKEDITOR.ENTER_P;
180

    
181
  // Sets the behavior for the Shift + ENTER keys. allowed tags: _P | _BR | _DIV
182
  config.shiftEnterMode = CKEDITOR.ENTER_BR;
183

    
184
  /* Allows to force CKEditor not to localize the editor to the user language.
185
  * Default: Empty (''); Example: ('fr') for French.
186
  * Note: Language configuration is based on the backend language of WebsiteBaker.
187
  * It's defined in include.php
188
  * config.language         = ''; */
189
  // The language to be used if config.language is empty and it's not possible to localize the editor to the user language.
190
  config.defaultLanguage   = 'en';
191

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

    
197
    //disable ckes Advanced Content Filter (ACF) to avoid wblinks to be filtered?
198
    config.allowedContent = true;
199
    config.jsplus_image_editor_init_tool = 'text';
200

    
201
    // Simplify the dialog windows.
202
//    config.removeDialogTabs = 'image:advanced;link:advanced';
203
/*
204
connectorPath = basePath+'/filemanager/connectors/php/connector.php';
205
config.filebrowserBrowseUrl = basePath+'/filemanager/browser/default/browser.html?Connector='+connectorPath;
206
config.filebrowserImageBrowseUrl = '/filemanager/browser/default/browser.html?Type=Image&Connector='+connectorPath;
207
config.filebrowserFlashBrowseUrl = '/filemanager/browser/default/browser.html?Type=Flash&Connector='+connectorPath;
208
*/
209
/*
210
    config.alphamanager = {
211
        'multiSelect': true,
212
        'showRootDir': false,
213
        'openLastDir': true,
214
        'lang':'de',
215
        'dateFormat': 'dd/MM/yyyy HH:mm',
216
        'hideCopyright': true,
217
        'returnUrlPrefix': ''
218
    };
219
*/
220

    
221
    config.filebrowserWindowWidth = '80%';
222
    config.filebrowserWindowHeight = '70%';
223
};
224

    
225
CKEDITOR.on( 'instanceReady', function( ev )
226
{
227
    var writer = ev.editor.dataProcessor.writer;
228
    // The character sequence to use for every indentation step.
229
    writer.indentationChars = '\t';
230
    // The way to close self closing tags, like <br />.
231
    writer.selfClosingEnd   = ' />';
232
    // The character sequence to be used for line breaks.
233
    writer.lineBreakChars   = '\n';
234
    // Setting rules for several HTML tags.
235

    
236
    var dtd = CKEDITOR.dtd;
237
    for (var e in CKEDITOR.tools.extend( {}, dtd.$block ))
238
    {
239
        writer.setRules( e,
240
        {
241
            // Indicates that this tag causes indentation on line breaks inside of it.
242
            indent : false,
243
            // Insert a line break before the <h1> tag.
244
            breakBeforeOpen : true,
245
            // Insert a line break after the <h1> tag.
246
            breakAfterOpen : false,
247
            // Insert a line break before the </h1> closing tag.
248
            breakBeforeClose : false,
249
            // Insert a line break after the </h1> closing tag.
250
            breakAfterClose : true
251
        });
252
    };
253
    writer.setRules( 'p',
254
    {
255
        // Indicates that this tag causes indentation on line breaks inside of it.
256
        indent : false,
257
        // Insert a line break before the <p> tag.
258
        breakBeforeOpen : true,
259
        // Insert a line break after the <p> tag.
260
        breakAfterOpen : false,
261
        // Insert a line break before the </p> closing tag.
262
        breakBeforeClose : false,
263
        // Insert a line break after the </p> closing tag.
264
        breakAfterClose : true
265
    });
266
    writer.setRules( 'br',
267
    {
268
        // Indicates that this tag causes indentation on line breaks inside of it.
269
        indent : false,
270
        // Insert a line break before the <br /> tag.
271
        breakBeforeOpen : false,
272
        // Insert a line break after the <br /> tag.
273
        breakAfterOpen : true
274
    });
275
    writer.setRules( 'a',
276
    {
277
        // Indicates that this tag causes indentation on line breaks inside of it.
278
        indent : false,
279
        // Insert a line break before the <a> tag.
280
        breakBeforeOpen : true,
281
        // Insert a line break after the <a> tag.
282
        breakAfterOpen : false,
283
        // Insert a line break before the </a> closing tag.
284
        breakBeforeClose : false,
285
        // Insert a line break after the </a> closing tag.
286
        breakAfterClose : false
287
    });
288
    writer.setRules( 'div',
289
    {
290
        // Indicates that this tag causes indentation on line breaks inside of it.
291
        indent : false,
292
        // Insert a line break before the <div> tag.
293
        breakBeforeOpen : true,
294
        // Insert a line break after the <div> tag.
295
        breakAfterOpen : false,
296
        // Insert a line break before the </div> closing tag.
297
        breakBeforeClose : true,
298
        // Insert a line break after the </div> closing tag.
299
        breakAfterClose : false
300
    });
301
    writer.setRules( 'img',
302
    {
303
        // Indicates that this tag causes indentation on line breaks inside of it.
304
        indent : false,
305
        // Insert a line break before the <img> tag.
306
        breakBeforeOpen : true,
307
        // Insert a line break after the <img> tag.
308
        breakAfterOpen : false,
309
        // Insert a line break before the </img>> closing tag.
310
        breakBeforeClose : false,
311
        // Insert a line break after the </img> closing tag.
312
        breakAfterClose : false
313
    });
314
/*
315
*/
316
    ev.editor.dataProcessor.htmlFilter.addRules(
317
    {
318
        elements:
319
        {
320
            $: function (element) {
321
                // Output dimensions of images as width and height
322
                if (element.name == 'img') {
323
                    var style = element.attributes.style;
324
                    if (style) {
325
                        // Get the width from the style.
326
                        var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec(style),
327
                            width = match && match[1];
328

    
329
                        // Get the height from the style.
330
                        match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec(style);
331
                        var height = match && match[1];
332
//console.log( element );
333

    
334
                        if (width) {
335
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)width\s*:\s*(\d+)px;?/i, '');
336
                            element.attributes.width = width;
337
                        }
338

    
339
                        if (height) {
340
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)height\s*:\s*(\d+)px;?/i, '');
341
                            element.attributes.height = height;
342
                        }
343
                    }
344
                }
345
/**
346
 *
347
                if (!element.attributes.style)
348
                    delete element.attributes.style;
349
 */
350

    
351
                return element;
352
            }
353
        }
354
    });
355

    
356
});
357

    
358
CKEDITOR.on( 'dialogDefinition', function( ev )
359
{
360
        // Take the dialog name and its definition from the event data.
361
        var editor = ev.editor;
362
        var dialogName = ev.data.name;
363
        var dialogDefinition = ev.data.definition;
364

    
365
        // Check if the definition is from the dialog window you are interested in (the "Link" dialog window).
366
        if ( dialogName == 'image' )
367
        {
368
            // Get a reference to the "Link Info" tab.
369
            var linkTab = dialogDefinition.getContents('Link');
370
        }
371
        // Check if the definition is from the dialog window you are interested in (the "Link" dialog window).
372
        if ( dialogName == 'wblink' )
373
        {
374
            // Get a reference to the "Link Info" tab.
375
            var infoTab = dialogDefinition.getContents( 'info' );
376
            // Set the default value for the URL field.
377
            var urlField = infoTab.get( 'url' );
378
            urlField['default'] = 'www.example.com';
379
        }
380

    
381
    }); // dialogDefinition
(5-5/6)