Fixed CKEditor stuff:
- Added missing insertpre plugin and allow <pre> tag with class attribute. Added font style to base.css. - Removed unused link to old ckeditor.css (now managed by django-ckeditor).
This commit is contained in:
parent
5db47bef76
commit
648d5a6ad7
@ -8,6 +8,9 @@ Version 1.6.1 (unreleased)
|
|||||||
==========================
|
==========================
|
||||||
[https://github.com/OpenSlides/OpenSlides/issues?milestone=16]
|
[https://github.com/OpenSlides/OpenSlides/issues?milestone=16]
|
||||||
|
|
||||||
|
Other:
|
||||||
|
- Fixed CKEditor stuff (added insertpre plugin and removed unused code)
|
||||||
|
|
||||||
|
|
||||||
Version 1.6 (2014-06-02)
|
Version 1.6 (2014-06-02)
|
||||||
========================
|
========================
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
CKEditor Insert <pre> Plugin
|
||||||
|
===============================
|
||||||
|
|
||||||
|
This plugin makes it easier to insert a <pre> tag in CKEditor.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
1. Clone/copy this repository contents in a new "plugins/insertpre" folder in your CKEditor installation.
|
||||||
|
2. Enable the "insertpre" plugin in the CKEditor configuration file (config.js):
|
||||||
|
|
||||||
|
config.extraPlugins = 'insertpre';
|
||||||
|
|
||||||
|
That's all. "InsertPre" button will appear on the editor toolbar and will be ready to use.
|
||||||
|
|
||||||
|
3. Optionally, you may specify which class should be added to the <pre> element:
|
||||||
|
|
||||||
|
CKEDITOR.config.insertpre_class = 'prettyprint';
|
||||||
|
|
||||||
|
As well as specify how the <pre> tag should be rendered inside CKEditor:
|
||||||
|
|
||||||
|
CKEDITOR.config.insertpre_style = 'background-color:#F8F8F8;border:1px solid #DDD;padding:10px;';
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
Licensed under the terms of any of the following licenses at your choice: [GPL](http://www.gnu.org/licenses/gpl.html), [LGPL](http://www.gnu.org/licenses/lgpl.html) and [MPL](http://www.mozilla.org/MPL/MPL-1.1.html).
|
Binary file not shown.
After Width: | Height: | Size: 603 B |
Binary file not shown.
After Width: | Height: | Size: 693 B |
@ -0,0 +1,6 @@
|
|||||||
|
CKEDITOR.plugins.setLang( 'insertpre', 'en', {
|
||||||
|
title : 'Insert code snippet',
|
||||||
|
code : 'Code',
|
||||||
|
edit : 'Edit code',
|
||||||
|
notEmpty : 'The code field cannot be empty.'
|
||||||
|
});
|
@ -0,0 +1,6 @@
|
|||||||
|
CKEDITOR.plugins.setLang( 'insertpre', 'pl', {
|
||||||
|
title : 'Wstaw kod',
|
||||||
|
code : 'Kod',
|
||||||
|
edit : 'Edytuj',
|
||||||
|
notEmpty: 'Pole z kodem nie może być puste.'
|
||||||
|
});
|
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||||
|
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
CKEDITOR.plugins.add( 'insertpre',
|
||||||
|
{
|
||||||
|
requires: 'dialog',
|
||||||
|
lang : 'en,pl', // %REMOVE_LINE_CORE%
|
||||||
|
icons: 'insertpre', // %REMOVE_LINE_CORE%
|
||||||
|
onLoad : function()
|
||||||
|
{
|
||||||
|
if ( CKEDITOR.config.insertpre_class )
|
||||||
|
{
|
||||||
|
CKEDITOR.addCss(
|
||||||
|
'pre.' + CKEDITOR.config.insertpre_class + ' {' +
|
||||||
|
CKEDITOR.config.insertpre_style +
|
||||||
|
'}'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init : function( editor )
|
||||||
|
{
|
||||||
|
// allowed and required content is the same for this plugin
|
||||||
|
var required = CKEDITOR.config.insertpre_class ? ( 'pre( ' + CKEDITOR.config.insertpre_class + ' )' ) : 'pre';
|
||||||
|
editor.addCommand( 'insertpre', new CKEDITOR.dialogCommand( 'insertpre', {
|
||||||
|
allowedContent : required,
|
||||||
|
requiredContent : required
|
||||||
|
} ) );
|
||||||
|
editor.ui.addButton && editor.ui.addButton( 'InsertPre',
|
||||||
|
{
|
||||||
|
label : editor.lang.insertpre.title,
|
||||||
|
icon : this.path + 'icons/insertpre.png',
|
||||||
|
command : 'insertpre',
|
||||||
|
toolbar: 'insert,99'
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( editor.contextMenu )
|
||||||
|
{
|
||||||
|
editor.addMenuGroup( 'code' );
|
||||||
|
editor.addMenuItem( 'insertpre',
|
||||||
|
{
|
||||||
|
label : editor.lang.insertpre.edit,
|
||||||
|
icon : this.path + 'icons/insertpre.png',
|
||||||
|
command : 'insertpre',
|
||||||
|
group : 'code'
|
||||||
|
});
|
||||||
|
editor.contextMenu.addListener( function( element )
|
||||||
|
{
|
||||||
|
if ( element )
|
||||||
|
element = element.getAscendant( 'pre', true );
|
||||||
|
if ( element && !element.isReadOnly() && element.hasClass( editor.config.insertpre_class ) )
|
||||||
|
return { insertpre : CKEDITOR.TRISTATE_OFF };
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CKEDITOR.dialog.add( 'insertpre', function( editor )
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
title : editor.lang.insertpre.title,
|
||||||
|
minWidth : 540,
|
||||||
|
minHeight : 380,
|
||||||
|
contents : [
|
||||||
|
{
|
||||||
|
id : 'general',
|
||||||
|
label : editor.lang.insertpre.code,
|
||||||
|
elements : [
|
||||||
|
{
|
||||||
|
type : 'textarea',
|
||||||
|
id : 'contents',
|
||||||
|
label : editor.lang.insertpre.code,
|
||||||
|
cols: 140,
|
||||||
|
rows: 22,
|
||||||
|
validate : CKEDITOR.dialog.validate.notEmpty( editor.lang.insertpre.notEmpty ),
|
||||||
|
required : true,
|
||||||
|
setup : function( element )
|
||||||
|
{
|
||||||
|
var html = element.getHtml();
|
||||||
|
if ( html )
|
||||||
|
{
|
||||||
|
var div = document.createElement( 'div' );
|
||||||
|
div.innerHTML = html;
|
||||||
|
this.setValue( div.firstChild.nodeValue );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
commit : function( element )
|
||||||
|
{
|
||||||
|
element.setHtml( CKEDITOR.tools.htmlEncode( this.getValue() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onShow : function()
|
||||||
|
{
|
||||||
|
var sel = editor.getSelection(),
|
||||||
|
element = sel.getStartElement();
|
||||||
|
if ( element )
|
||||||
|
element = element.getAscendant( 'pre', true );
|
||||||
|
|
||||||
|
if ( !element || element.getName() != 'pre' || !element.hasClass( editor.config.insertpre_class ) )
|
||||||
|
{
|
||||||
|
element = editor.document.createElement( 'pre' );
|
||||||
|
this.insertMode = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.insertMode = false;
|
||||||
|
|
||||||
|
this.pre = element;
|
||||||
|
this.setupContent( this.pre );
|
||||||
|
},
|
||||||
|
onOk : function()
|
||||||
|
{
|
||||||
|
if ( editor.config.insertpre_class )
|
||||||
|
this.pre.setAttribute( 'class', editor.config.insertpre_class );
|
||||||
|
|
||||||
|
if ( this.insertMode )
|
||||||
|
editor.insertElement( this.pre );
|
||||||
|
|
||||||
|
this.commitContent( this.pre );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
if (typeof(CKEDITOR.config.insertpre_style) == 'undefined')
|
||||||
|
CKEDITOR.config.insertpre_style = 'background-color:#F8F8F8;border:1px solid #DDD;padding:10px;';
|
||||||
|
if (typeof(CKEDITOR.config.insertpre_class) == 'undefined')
|
||||||
|
CKEDITOR.config.insertpre_class = 'prettyprint';
|
@ -194,6 +194,12 @@ legend + .control-group {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ckeditor plugin insertpre: textarea style */
|
||||||
|
table.cke_dialog_contents textarea {
|
||||||
|
font-family: monospace !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Left sidebar navigation **/
|
/** Left sidebar navigation **/
|
||||||
.leftmenu ul {
|
.leftmenu ul {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Configuration file for the CKeditor
|
|
||||||
*/
|
|
||||||
var ck_options = {
|
|
||||||
|
|
||||||
// Using a custom CSS file allows us to specifically style elements entered
|
|
||||||
// using the editor. Using the CSS prefix class .ckeditor_html prevents these
|
|
||||||
// styles from meddling with the main layout
|
|
||||||
|
|
||||||
contentsCss: "/static/css/ckeditor.css",
|
|
||||||
bodyClass: "ckeditor_html",
|
|
||||||
|
|
||||||
allowedContent:
|
|
||||||
'h1 h2 h3 pre b i u strike em;' +
|
|
||||||
|
|
||||||
// A workaround for the problem described in http://dev.ckeditor.com/ticket/10192
|
|
||||||
// Hopefully, the problem will be solved in the final version of CKEditor 4.1
|
|
||||||
// If so, then {margin-left} can be removed
|
|
||||||
'p{margin-left};' +
|
|
||||||
|
|
||||||
'a[!href];' +
|
|
||||||
'ol ul{list-style};' +
|
|
||||||
'li;' +
|
|
||||||
'span{color,background-color};',
|
|
||||||
removePlugins: "save, print, preview, pagebreak, templates, showblocks, magicline",
|
|
||||||
|
|
||||||
// Not part of the standard package of CKEditor
|
|
||||||
// http://ckeditor.com/addon/insertpre
|
|
||||||
extraPlugins: "insertpre",
|
|
||||||
|
|
||||||
toolbar_Full: [
|
|
||||||
{ name: 'document', items : [ 'Source','-','Save','DocProps','Preview','Print','-','Templates' ] },
|
|
||||||
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
|
|
||||||
{ name: 'editing', items : [ 'Find','Replace','-','SpellChecker', 'Scayt' ] },
|
|
||||||
{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
|
|
||||||
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
|
|
||||||
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Pre','InsertPre','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
|
|
||||||
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
|
|
||||||
{ name: 'styles', items : [ 'Format','FontSize','TextColor','BGColor' ] },
|
|
||||||
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
|
|
||||||
],
|
|
||||||
toolbar: 'Full'
|
|
||||||
};
|
|
@ -135,7 +135,6 @@ INSTALLED_PLUGINS = collect_plugins()
|
|||||||
|
|
||||||
# CKeditor settings
|
# CKeditor settings
|
||||||
CKEDITOR_DEFAULT_CONFIG = {'toolbar': 'Full',
|
CKEDITOR_DEFAULT_CONFIG = {'toolbar': 'Full',
|
||||||
'contentsCss': '/static/css/ckeditor.css',
|
|
||||||
'bodyClass': 'ckeditor_html',
|
'bodyClass': 'ckeditor_html',
|
||||||
'allowedContent':
|
'allowedContent':
|
||||||
'h1 h2 h3 pre b i u strike em; '
|
'h1 h2 h3 pre b i u strike em; '
|
||||||
@ -148,14 +147,16 @@ CKEDITOR_DEFAULT_CONFIG = {'toolbar': 'Full',
|
|||||||
'a[!href]; '
|
'a[!href]; '
|
||||||
'ol ul{list-style}; '
|
'ol ul{list-style}; '
|
||||||
'li; '
|
'li; '
|
||||||
|
'pre; '
|
||||||
'span{color,background-color}; ',
|
'span{color,background-color}; ',
|
||||||
'removePlugins': 'save, print, preview, pagebreak, templates, showblocks, magicline',
|
'removePlugins': 'save, print, preview, pagebreak, templates, showblocks, magicline',
|
||||||
|
'extraPlugins': 'insertpre', # see http://ckeditor.com/addon/insertpre
|
||||||
'toolbar_Full': [
|
'toolbar_Full': [
|
||||||
{'name': 'document', 'items': ['Source', '-', 'Save', 'DocProps', 'Preview', 'Print', '-', 'Templates']},
|
{'name': 'document', 'items': ['Source', '-', 'Save', 'DocProps', 'Preview', 'Print', '-', 'Templates']},
|
||||||
{'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
|
{'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
|
||||||
{'name': 'editing', 'items': ['Find', 'Replace', '-', 'SpellChecker', 'Scayt']},
|
{'name': 'editing', 'items': ['Find', 'Replace', '-', 'SpellChecker', 'Scayt']},
|
||||||
{'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat']},
|
{'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat']},
|
||||||
{'name': 'paragraph', 'items': ['NumberedList', 'BulletedList', '-', 'Pre', 'InsertPre']},
|
{'name': 'paragraph', 'items': ['NumberedList', 'BulletedList', '-', 'InsertPre']},
|
||||||
{'name': 'links', 'items': ['Link', 'Unlink']},
|
{'name': 'links', 'items': ['Link', 'Unlink']},
|
||||||
{'name': 'styles', 'items': ['Format', 'TextColor', 'BGColor']},
|
{'name': 'styles', 'items': ['Format', 'TextColor', 'BGColor']},
|
||||||
{'name': 'tools', 'items': ['Maximize', 'ShowBlocks', '-', 'About']}
|
{'name': 'tools', 'items': ['Maximize', 'ShowBlocks', '-', 'About']}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
{% block header %}
|
{% block header %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<link type="text/css" rel="stylesheet" media="all" href="{% static 'css/motion.css' %}" />
|
<link type="text/css" rel="stylesheet" media="all" href="{% static 'css/motion.css' %}" />
|
||||||
<link type="text/css" rel="stylesheet" media="all" href="{% static 'css/ckeditor.css' %}" />
|
|
||||||
<link href="{% static 'css/jquery.bsmselect.css' %}" type="text/css" rel="stylesheet" />
|
<link href="{% static 'css/jquery.bsmselect.css' %}" type="text/css" rel="stylesheet" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ HTML_TAG_WHITELIST = ('a',
|
|||||||
HTML_ATTRIBUTES_WHITELIST = {
|
HTML_ATTRIBUTES_WHITELIST = {
|
||||||
'a': ['href'],
|
'a': ['href'],
|
||||||
'*': ['style'],
|
'*': ['style'],
|
||||||
'img': ['src'],
|
'pre': ['class'],
|
||||||
|
'img': ['src', 'width', 'height'],
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML_STYLES_WHITELIST = ('color', 'background-color', 'list-style', 'width', 'height')
|
HTML_STYLES_WHITELIST = ('color', 'background-color', 'list-style', 'width', 'height')
|
||||||
|
Loading…
Reference in New Issue
Block a user