Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 4e5c4bd

Browse files
jriefJacob Rieffsbraun
authored
Feature/issue 648 unable to unlink (#649)
* Bump to version 3.10.0 * replace all deprecated occurences of force_text with force_str * replace all deprecated occurences of force_text with force_str * fix #554: typo in Blockquote * Pin to newer versions * Attempt to increase the width of some drop-down menues * fix #648: unable to unlink * fix flake8 complains * fix 1 failing unit test * fix #648: unable to unlink fix flake8 complains fix 1 failing unit test * fix: test suite for Django 2.2 (#650) * fix django 2.2 tests * Update dj22_cms37.txt * Update dj22_cms38.txt * Update dj22_cms40.txt * Update dj31_cms38.txt * Update settings.py * Update frontend.yml * Enable frontend tests --------- Co-authored-by: Jacob Rief <[email protected]> Co-authored-by: Fabian Braun <[email protected]>
1 parent 3a4cf77 commit 4e5c4bd

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

djangocms_text_ckeditor/cms_plugins.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ def _get_text_plugin_from_request(self, request, data):
417417
raise PermissionDenied
418418

419419
form = ActionTokenValidationForm(data)
420-
421420
if form.is_valid():
422421
session_key = request.session.session_key
423422
text_plugin_id = form.get_id_from_token(session_key)
424423

425424
if text_plugin_id:
426425
return self._get_plugin_or_404(text_plugin_id)
426+
427427
message = gettext("Unable to process your request. Invalid token.")
428428
raise ValidationError(message=force_str(message))
429429

@@ -436,10 +436,9 @@ def render_plugin(self, request):
436436
return HttpResponseBadRequest(error.message)
437437

438438
form = RenderPluginForm(request.GET, text_plugin=text_plugin)
439-
440439
if not form.is_valid():
441-
message = gettext("Unable to process your request.")
442-
return HttpResponseBadRequest(message)
440+
# plugin not found, inform CKEDITOR.plugins.insertPlugin to remove it
441+
return HttpResponse(status=204)
443442

444443
plugin_class = text_plugin.get_plugin_class_instance()
445444
# The following is needed for permission checking

djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor/plugins/dialog/styles/dialog.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
.cke_dialog_body {
1717
position: relative;
1818
}
19+
.cke_combo_text {
20+
width: 100px;
21+
}

djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor_plugins/cmsplugins/plugin.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,14 @@
383383
token: settings.action_token,
384384
plugin: data.plugin_id
385385
}
386-
}).done(function (res) {
387-
CMS.CKEditor.editors[editor.id].changed = true;
388-
CMS.CKEditor.editors[editor.id].child_changed = true;
389-
editor.insertHtml(res, 'unfiltered_html');
386+
}).done(function (res, textStatus, jqXHR) {
387+
CMS.CKEditor.editors[editor.id].changed = true;
388+
CMS.CKEditor.editors[editor.id].child_changed = true;
389+
if (jqXHR.status === 200) {
390+
editor.insertHtml(res, 'unfiltered_html');
391+
} else if (jqXHR.status === 204) {
392+
editor.insertHtml(editor.getSelectedHtml().$.textContent);
393+
}
390394
editor.fire('updateSnapshot');
391395
});
392396
},

djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/cms.ckeditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
['HorizontalRule'],
4343
['Link', 'Unlink'],
4444
['NumberedList', 'BulletedList'],
45-
['Outdent', 'Indent', '-', 'Blockqote', '-', 'Link', 'Unlink', '-', 'Table'],
45+
['Outdent', 'Indent', '-', 'Blockquote', '-', 'Link', 'Unlink', '-', 'Table'],
4646
['Source']
4747
],
4848

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

djangocms_text_ckeditor/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
# this path is changed automatically whenever you run `gulp bundle`
20-
PATH_TO_JS = 'djangocms_text_ckeditor/js/dist/bundle-13948e6025.cms.ckeditor.min.js'
20+
PATH_TO_JS = 'djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js'
2121

2222

2323
class TextEditorWidget(forms.Textarea):

tests/test_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ def test_render_child_plugin_token_validation(self):
747747
endpoint += f'?token={action_token}&plugin={child_plugin.pk}'
748748
response = self.client.get(endpoint)
749749

750-
self.assertEqual(response.status_code, 400)
751-
self.assertEqual(force_str(response.content), 'Unable to process your request.')
750+
self.assertEqual(response.status_code, 204)
751+
self.assertEqual(force_str(response.content), '')
752752

753753
def test_custom_ckeditor_body_css_classes(self):
754754
simple_page = self.create_page('test page', template='page.html', language='en')

0 commit comments

Comments
 (0)