diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-01-25 17:45:33 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-01-25 18:00:33 +0100 |
commit | 7adcb81e4f83f98c468889aaa5a85558ba88c770 (patch) | |
tree | 0d6ede733777b29060b48df4afaa2c64bfbae276 /release/samples/js/sample.js | |
download | connexionswing-ckeditor-component-4.5.6.tar.gz connexionswing-ckeditor-component-4.5.6.tar.zst connexionswing-ckeditor-component-4.5.6.zip |
Initial commit4.5.6
Diffstat (limited to 'release/samples/js/sample.js')
-rw-r--r-- | release/samples/js/sample.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/release/samples/js/sample.js b/release/samples/js/sample.js new file mode 100644 index 00000000..b960afe1 --- /dev/null +++ b/release/samples/js/sample.js | |||
@@ -0,0 +1,53 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | /* exported initSample */ | ||
7 | |||
8 | if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) | ||
9 | CKEDITOR.tools.enableHtml5Elements( document ); | ||
10 | |||
11 | // The trick to keep the editor in the sample quite small | ||
12 | // unless user specified own height. | ||
13 | CKEDITOR.config.height = 150; | ||
14 | CKEDITOR.config.width = 'auto'; | ||
15 | |||
16 | var initSample = ( function() { | ||
17 | var wysiwygareaAvailable = isWysiwygareaAvailable(), | ||
18 | isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' ); | ||
19 | |||
20 | return function() { | ||
21 | var editorElement = CKEDITOR.document.getById( 'editor' ); | ||
22 | |||
23 | // :((( | ||
24 | if ( isBBCodeBuiltIn ) { | ||
25 | editorElement.setHtml( | ||
26 | 'Hello world!\n\n' + | ||
27 | 'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].' | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | // Depending on the wysiwygare plugin availability initialize classic or inline editor. | ||
32 | if ( wysiwygareaAvailable ) { | ||
33 | CKEDITOR.replace( 'editor' ); | ||
34 | } else { | ||
35 | editorElement.setAttribute( 'contenteditable', 'true' ); | ||
36 | CKEDITOR.inline( 'editor' ); | ||
37 | |||
38 | // TODO we can consider displaying some info box that | ||
39 | // without wysiwygarea the classic editor may not work. | ||
40 | } | ||
41 | }; | ||
42 | |||
43 | function isWysiwygareaAvailable() { | ||
44 | // If in development mode, then the wysiwygarea must be available. | ||
45 | // Split REV into two strings so builder does not replace it :D. | ||
46 | if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) { | ||
47 | return true; | ||
48 | } | ||
49 | |||
50 | return !!CKEDITOR.plugins.get( 'wysiwygarea' ); | ||
51 | } | ||
52 | } )(); | ||
53 | |||