Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit c6e7fc2

Browse files
committed
Next attempt at completing django-ckeditor#377
1 parent e080a82 commit c6e7fc2

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

ckeditor/static/ckeditor/ckeditor-init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
var $ = jQuery || djangoJQuery;
1010

11-
var el = $('.django-ckeditor-widget');
12-
if (el.length && !window.CKEDITOR_BASEPATH) {
13-
window.CKEDITOR_BASEPATH = el[0].getAttribute('data-ckeditor-basepath');
11+
var el = document.getElementById('ckeditor-init-script');
12+
if (el && !window.CKEDITOR_BASEPATH) {
13+
window.CKEDITOR_BASEPATH = el.getAttribute('data-ckeditor-basepath');
1414
}
1515

1616
$(function() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{% load static %}
2-
<div class="django-ckeditor-widget" data-field-id="{{id}}" style="display: inline-block;" data-ckeditor-basepath="{% static 'ckeditor/ckeditor/' %}">
2+
<div class="django-ckeditor-widget" data-field-id="{{id}}" style="display: inline-block;">
33
<textarea{{ final_attrs|safe }} data-processed="0" data-config='{{config|safe}}' data-external-plugin-resources='{{external_plugin_resources|safe}}' data-id="{{id}}" data-type="ckeditortype">{{ value }}</textarea>
44
</div>

ckeditor/widgets.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from django.utils.safestring import mark_safe
1212
from django.utils.translation import get_language
1313

14+
from js_asset import JS, static
15+
1416
try:
1517
# Django >=1.7
1618
from django.forms.utils import flatatt
@@ -61,7 +63,14 @@ class Media:
6163
js += (jquery_url, )
6264
try:
6365
js += (
64-
'ckeditor/ckeditor-init.js',
66+
JS('ckeditor/ckeditor-init.js', {
67+
'id': 'ckeditor-init-script',
68+
'data-ckeditor-basepath': getattr(
69+
settings,
70+
'CKEDITOR_BASEPATH',
71+
static('ckeditor/ckeditor/'),
72+
),
73+
}),
6574
'ckeditor/ckeditor/ckeditor.js',
6675
)
6776
except AttributeError:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def get_source_files():
3636
zip_safe=False,
3737
install_requires=[
3838
'Django',
39+
'django-js-asset',
3940
],
4041
include_package_data=True,
4142
classifiers=[

0 commit comments

Comments
 (0)