From 3332bebe4da6dfa0fe3e4b2abddc84b1cc62f8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 19 Feb 2016 23:38:52 +0100 Subject: Initial commit --- sources/samples/js/sample.js | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sources/samples/js/sample.js (limited to 'sources/samples/js/sample.js') 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 @@ +/** + * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or http://ckeditor.com/license + */ + +/* exported initSample */ + +if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) + CKEDITOR.tools.enableHtml5Elements( document ); + +// The trick to keep the editor in the sample quite small +// unless user specified own height. +CKEDITOR.config.height = 150; +CKEDITOR.config.width = 'auto'; + +var initSample = ( function() { + var wysiwygareaAvailable = isWysiwygareaAvailable(), + isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' ); + + return function() { + var editorElement = CKEDITOR.document.getById( 'editor' ); + + // :((( + if ( isBBCodeBuiltIn ) { + editorElement.setHtml( + 'Hello world!\n\n' + + 'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].' + ); + } + + // Depending on the wysiwygare plugin availability initialize classic or inline editor. + if ( wysiwygareaAvailable ) { + CKEDITOR.replace( 'editor' ); + } else { + editorElement.setAttribute( 'contenteditable', 'true' ); + CKEDITOR.inline( 'editor' ); + + // TODO we can consider displaying some info box that + // without wysiwygarea the classic editor may not work. + } + }; + + function isWysiwygareaAvailable() { + // If in development mode, then the wysiwygarea must be available. + // Split REV into two strings so builder does not replace it :D. + if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) { + return true; + } + + return !!CKEDITOR.plugins.get( 'wysiwygarea' ); + } +} )(); + +// %LEAVE_UNMINIFIED% %REMOVE_LINE% -- cgit v1.2.3