Move CKeditor configuration to a separate JS file
Remove unneeded try-except block
This commit is contained in:
parent
1d1f5fa218
commit
56844d93f2
@ -169,7 +169,6 @@ def convert_html_to_reportlab(pdf, text):
|
|||||||
soup = BeautifulSoup(text)
|
soup = BeautifulSoup(text)
|
||||||
# read all list elements...
|
# read all list elements...
|
||||||
for element in soup.find_all('li'):
|
for element in soup.find_all('li'):
|
||||||
try:
|
|
||||||
# ... and replace ul list elements with <para><bullet>•</bullet>...<para>
|
# ... and replace ul list elements with <para><bullet>•</bullet>...<para>
|
||||||
if element.parent.name == "ul":
|
if element.parent.name == "ul":
|
||||||
if element.ul:
|
if element.ul:
|
||||||
@ -198,8 +197,6 @@ def convert_html_to_reportlab(pdf, text):
|
|||||||
element.bullet.insert(0, soup.new_tag("seq"))
|
element.bullet.insert(0, soup.new_tag("seq"))
|
||||||
element.bullet.seq['id'] = id
|
element.bullet.seq['id'] = id
|
||||||
element.bullet.insert(1, ".")
|
element.bullet.insert(1, ".")
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
# remove tags which are not supported by reportlab (replace tags with their children tags)
|
# remove tags which are not supported by reportlab (replace tags with their children tags)
|
||||||
for tag in soup.find_all('ul'):
|
for tag in soup.find_all('ul'):
|
||||||
tag.unwrap()
|
tag.unwrap()
|
||||||
|
@ -11,59 +11,7 @@
|
|||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript" src="{% static 'javascript/ckeditor/ckeditor.js' %}"></script>
|
<script type="text/javascript" src="{% static 'javascript/ckeditor/ckeditor.js' %}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript" src="{% static 'javascript/ckeditor-config.js' %}"></script>
|
||||||
$(function() {
|
|
||||||
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 'styles/ckeditor.css' %}",
|
|
||||||
bodyClass: "ckeditor_html",
|
|
||||||
|
|
||||||
allowedContent:
|
|
||||||
'h1 h2 h3 pre blockquote b i u strike;' +
|
|
||||||
|
|
||||||
// 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];' +
|
|
||||||
'table tr th td caption;' +
|
|
||||||
'ol ul li;' +
|
|
||||||
'span{!font-family};' +
|
|
||||||
'span{!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' ] },
|
|
||||||
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
|
|
||||||
],
|
|
||||||
toolbar: 'Full'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Override the tags 'strong' and 'em' so that reportlab can read it
|
|
||||||
CKEDITOR.config.coreStyles_bold = { element : 'b', overrides : 'strong' };
|
|
||||||
CKEDITOR.config.coreStyles_italic = { element : 'i', overrides : 'em' };
|
|
||||||
|
|
||||||
CKEDITOR.replace('id_text', ck_options);
|
|
||||||
CKEDITOR.replace('id_reason', ck_options);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
53
openslides/static/javascript/ckeditor-config.js
Normal file
53
openslides/static/javascript/ckeditor-config.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Configuration file for the CKeditor
|
||||||
|
*/
|
||||||
|
$(function() {
|
||||||
|
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/styles/ckeditor.css",
|
||||||
|
bodyClass: "ckeditor_html",
|
||||||
|
|
||||||
|
allowedContent:
|
||||||
|
'h1 h2 h3 pre blockquote b i u strike;' +
|
||||||
|
|
||||||
|
// 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];' +
|
||||||
|
'table tr th td caption;' +
|
||||||
|
'ol ul li;' +
|
||||||
|
'span{!font-family};' +
|
||||||
|
'span{!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' ] },
|
||||||
|
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
|
||||||
|
],
|
||||||
|
toolbar: 'Full'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Override the tags 'strong' and 'em' so that reportlab can read it
|
||||||
|
CKEDITOR.config.coreStyles_bold = { element : 'b', overrides : 'strong' };
|
||||||
|
CKEDITOR.config.coreStyles_italic = { element : 'i', overrides : 'em' };
|
||||||
|
|
||||||
|
CKEDITOR.replace('id_text', ck_options);
|
||||||
|
CKEDITOR.replace('id_reason', ck_options);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user