ckeditor/samples/js/sample.js
changeset 0 44d330dccc59
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ckeditor/samples/js/sample.js	Thu Dec 15 18:10:20 2016 +0300
     1.3 @@ -0,0 +1,53 @@
     1.4 +/**
     1.5 + * Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
     1.6 + * For licensing, see LICENSE.md or http://ckeditor.com/license
     1.7 + */
     1.8 +
     1.9 +/* exported initSample */
    1.10 +
    1.11 +if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
    1.12 +	CKEDITOR.tools.enableHtml5Elements( document );
    1.13 +
    1.14 +// The trick to keep the editor in the sample quite small
    1.15 +// unless user specified own height.
    1.16 +CKEDITOR.config.height = 150;
    1.17 +CKEDITOR.config.width = 'auto';
    1.18 +
    1.19 +var initSample = ( function() {
    1.20 +	var wysiwygareaAvailable = isWysiwygareaAvailable(),
    1.21 +		isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
    1.22 +
    1.23 +	return function() {
    1.24 +		var editorElement = CKEDITOR.document.getById( 'editor' );
    1.25 +
    1.26 +		// :(((
    1.27 +		if ( isBBCodeBuiltIn ) {
    1.28 +			editorElement.setHtml(
    1.29 +				'Hello world!\n\n' +
    1.30 +				'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].'
    1.31 +			);
    1.32 +		}
    1.33 +
    1.34 +		// Depending on the wysiwygare plugin availability initialize classic or inline editor.
    1.35 +		if ( wysiwygareaAvailable ) {
    1.36 +			CKEDITOR.replace( 'editor' );
    1.37 +		} else {
    1.38 +			editorElement.setAttribute( 'contenteditable', 'true' );
    1.39 +			CKEDITOR.inline( 'editor' );
    1.40 +
    1.41 +			// TODO we can consider displaying some info box that
    1.42 +			// without wysiwygarea the classic editor may not work.
    1.43 +		}
    1.44 +	};
    1.45 +
    1.46 +	function isWysiwygareaAvailable() {
    1.47 +		// If in development mode, then the wysiwygarea must be available.
    1.48 +		// Split REV into two strings so builder does not replace it :D.
    1.49 +		if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
    1.50 +			return true;
    1.51 +		}
    1.52 +
    1.53 +		return !!CKEDITOR.plugins.get( 'wysiwygarea' );
    1.54 +	}
    1.55 +} )();
    1.56 +