root / drupal7 / sites / all / libraries / ckeditor-4.9.2-full / samples / js / sample.js @ b986a83e
1 | 0aee3c58 | Assos Assos | /** |
---|---|---|---|
2 | b986a83e | Florent Torregrosa | * Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
3 | * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||
4 | 0aee3c58 | Assos Assos | */
|
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 | b986a83e | Florent Torregrosa | 'I\'m an instance of [url=https://ckeditor.com]CKEditor[/url].'
|
28 | 0aee3c58 | Assos Assos | ); |
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 |