mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-04 16:44:11 +01:00
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
/*
|
|
* Copyright (C) 2013-2019 Combodo SARL
|
|
*
|
|
* This file is part of iTop.
|
|
*
|
|
* iTop is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* iTop is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public 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=https://ckeditor.com]CKEditor[/url].'
|
|
);
|
|
}
|
|
|
|
// Depending on the wysiwygarea 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' );
|
|
}
|
|
} )();
|
|
|