diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-02-19 23:38:52 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-02-19 23:38:52 +0100 |
commit | 3332bebe4da6dfa0fe3e4b2abddc84b1cc62f8f5 (patch) | |
tree | a4f77655fe55b79606e7d3416504686a1ab8b058 /sources/samples/js/sample.js | |
download | piedsjaloux-ckeditor-component-3332bebe4da6dfa0fe3e4b2abddc84b1cc62f8f5.tar.gz piedsjaloux-ckeditor-component-3332bebe4da6dfa0fe3e4b2abddc84b1cc62f8f5.tar.zst piedsjaloux-ckeditor-component-3332bebe4da6dfa0fe3e4b2abddc84b1cc62f8f5.zip |
Initial commit4.5.7
Diffstat (limited to 'sources/samples/js/sample.js')
-rw-r--r-- | sources/samples/js/sample.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sources/samples/js/sample.js b/sources/samples/js/sample.js new file mode 100644 index 0000000..d2eca00 --- /dev/null +++ b/sources/samples/js/sample.js | |||
@@ -0,0 +1,54 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2016, 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 | |||
54 | // %LEAVE_UNMINIFIED% %REMOVE_LINE% | ||