sample.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. /* exported initSample */
  6. if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
  7. CKEDITOR.tools.enableHtml5Elements( document );
  8. // The trick to keep the editor in the sample quite small
  9. // unless user specified own height.
  10. CKEDITOR.config.height = 150;
  11. CKEDITOR.config.width = 'auto';
  12. var initSample = ( function() {
  13. var wysiwygareaAvailable = isWysiwygareaAvailable(),
  14. isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
  15. return function() {
  16. var editorElement = CKEDITOR.document.getById( 'editor' );
  17. // :(((
  18. if ( isBBCodeBuiltIn ) {
  19. editorElement.setHtml(
  20. 'Hello world!\n\n' +
  21. 'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].'
  22. );
  23. }
  24. // Depending on the wysiwygare plugin availability initialize classic or inline editor.
  25. if ( wysiwygareaAvailable ) {
  26. CKEDITOR.replace( 'editor' );
  27. } else {
  28. editorElement.setAttribute( 'contenteditable', 'true' );
  29. CKEDITOR.inline( 'editor' );
  30. // TODO we can consider displaying some info box that
  31. // without wysiwygarea the classic editor may not work.
  32. }
  33. };
  34. function isWysiwygareaAvailable() {
  35. // If in development mode, then the wysiwygarea must be available.
  36. // Split REV into two strings so builder does not replace it :D.
  37. if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
  38. return true;
  39. }
  40. return !!CKEDITOR.plugins.get( 'wysiwygarea' );
  41. }
  42. } )();
  43. // %LEAVE_UNMINIFIED% %REMOVE_LINE%