]>
Commit | Line | Data |
---|---|---|
1 | /**\r | |
2 | * Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.\r | |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license\r | |
4 | */\r | |
5 | \r | |
6 | /* exported initSample */\r | |
7 | \r | |
8 | if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )\r | |
9 | CKEDITOR.tools.enableHtml5Elements( document );\r | |
10 | \r | |
11 | // The trick to keep the editor in the sample quite small\r | |
12 | // unless user specified own height.\r | |
13 | CKEDITOR.config.height = 150;\r | |
14 | CKEDITOR.config.width = 'auto';\r | |
15 | \r | |
16 | var initSample = ( function() {\r | |
17 | var wysiwygareaAvailable = isWysiwygareaAvailable(),\r | |
18 | isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );\r | |
19 | \r | |
20 | return function() {\r | |
21 | var editorElement = CKEDITOR.document.getById( 'editor' );\r | |
22 | \r | |
23 | // :(((\r | |
24 | if ( isBBCodeBuiltIn ) {\r | |
25 | editorElement.setHtml(\r | |
26 | 'Hello world!\n\n' +\r | |
27 | 'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].'\r | |
28 | );\r | |
29 | }\r | |
30 | \r | |
31 | // Depending on the wysiwygare plugin availability initialize classic or inline editor.\r | |
32 | if ( wysiwygareaAvailable ) {\r | |
33 | CKEDITOR.replace( 'editor' );\r | |
34 | } else {\r | |
35 | editorElement.setAttribute( 'contenteditable', 'true' );\r | |
36 | CKEDITOR.inline( 'editor' );\r | |
37 | \r | |
38 | // TODO we can consider displaying some info box that\r | |
39 | // without wysiwygarea the classic editor may not work.\r | |
40 | }\r | |
41 | };\r | |
42 | \r | |
43 | function isWysiwygareaAvailable() {\r | |
44 | // If in development mode, then the wysiwygarea must be available.\r | |
45 | // Split REV into two strings so builder does not replace it :D.\r | |
46 | if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {\r | |
47 | return true;\r | |
48 | }\r | |
49 | \r | |
50 | return !!CKEDITOR.plugins.get( 'wysiwygarea' );\r | |
51 | }\r | |
52 | } )();\r | |
53 | \r |