kopia lustrzana https://github.com/wagtail/wagtail
Remove insert_editor_css hook
rodzic
911be518b4
commit
d3fb0ab358
|
@ -466,30 +466,6 @@ Hooks for customising the editing interface for pages and snippets.
|
|||
|
||||
Rich text fields in Wagtail work with a list of 'feature' identifiers that determine which editing controls are available in the editor, and which elements are allowed in the output; for example, a rich text field defined as `RichTextField(features=['h2', 'h3', 'bold', 'italic', 'link'])` would allow headings, bold / italic formatting and links, but not (for example) bullet lists or images. The `register_rich_text_features` hook allows new feature identifiers to be defined - see [](rich_text_features) for details.
|
||||
|
||||
(insert_editor_css)=
|
||||
|
||||
### `insert_editor_css`
|
||||
|
||||
Add additional CSS files or snippets to the page editor.
|
||||
|
||||
```python
|
||||
from django.templatetags.static import static
|
||||
from django.utils.html import format_html
|
||||
|
||||
from wagtail import hooks
|
||||
|
||||
@hooks.register('insert_editor_css')
|
||||
def editor_css():
|
||||
return format_html(
|
||||
'<link rel="stylesheet" href="{}">',
|
||||
static('demo/css/vendor/font-awesome/css/font-awesome.min.css')
|
||||
)
|
||||
```
|
||||
|
||||
```{note}
|
||||
The `insert_editor_css` hook is deprecated and will be removed in a future release. We recommend using [](insert_global_admin_css) instead.
|
||||
```
|
||||
|
||||
(insert_global_admin_css)=
|
||||
|
||||
### `insert_global_admin_css`
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<link rel="stylesheet" href="{% versioned_static 'wagtailadmin/css/core.css' %}">
|
||||
|
||||
{% hook_output 'insert_global_admin_css' %}
|
||||
{% hook_output 'insert_editor_css' %}
|
||||
|
||||
{% block extra_css %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<div class="w-userbar w-userbar--{{ position|default:'bottom-right' }} {% admin_theme_classname %}" data-wagtail-userbar part="userbar">
|
||||
<link rel="stylesheet" href="{% versioned_static 'wagtailadmin/css/core.css' %}">
|
||||
{% hook_output 'insert_global_admin_css' %}
|
||||
{% hook_output 'insert_editor_css' %}
|
||||
<div class="w-userbar-nav">
|
||||
|
||||
<svg class="w-hidden">
|
||||
|
|
|
@ -278,12 +278,6 @@ def hook_output(hook_name):
|
|||
"""
|
||||
snippets = [fn() for fn in hooks.get_hooks(hook_name)]
|
||||
|
||||
if hook_name == "insert_editor_css" and snippets:
|
||||
warn(
|
||||
"The `insert_editor_css` hook is deprecated - use `insert_global_admin_css` instead.",
|
||||
category=RemovedInWagtail60Warning,
|
||||
)
|
||||
|
||||
return mark_safe("".join(snippets))
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ from django.urls import reverse, reverse_lazy
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from taggit.models import Tag
|
||||
|
||||
from wagtail import hooks
|
||||
from wagtail.admin.auth import user_has_any_page_permission
|
||||
from wagtail.admin.mail import send_mail
|
||||
from wagtail.admin.menu import MenuItem
|
||||
|
@ -19,7 +18,6 @@ from wagtail.models import Page
|
|||
from wagtail.test.testapp.models import RestaurantTag
|
||||
from wagtail.test.utils import WagtailTestUtils
|
||||
from wagtail.utils.deprecation import (
|
||||
RemovedInWagtail60Warning,
|
||||
RemovedInWagtail70Warning,
|
||||
)
|
||||
|
||||
|
@ -160,20 +158,6 @@ class TestEditorHooks(WagtailTestUtils, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, '<script src="/path/to/my/custom.js"></script>')
|
||||
|
||||
def test_deprecated_editor_css_hook(self):
|
||||
def css_hook():
|
||||
return '<link rel="stylesheet" href="/some/custom.css">'
|
||||
|
||||
with self.assertWarnsMessage(
|
||||
RemovedInWagtail60Warning,
|
||||
"The `insert_editor_css` hook is deprecated - use `insert_global_admin_css` instead.",
|
||||
):
|
||||
with hooks.register_temporarily("insert_editor_css", css_hook):
|
||||
response = self.client.get(reverse("wagtailadmin_home"))
|
||||
self.assertContains(
|
||||
response, '<link rel="stylesheet" href="/some/custom.css">'
|
||||
)
|
||||
|
||||
|
||||
class TestSendMail(TestCase):
|
||||
def test_send_email(self):
|
||||
|
|
Ładowanie…
Reference in New Issue