Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement telepath adapter for HalloRichTextArea #7122

Merged
merged 1 commit into from Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions client/src/entrypoints/admin/telepath/widgets.js
Expand Up @@ -185,6 +185,22 @@ class DraftailRichTextArea {
window.telepath.register('wagtail.widgets.DraftailRichTextArea', DraftailRichTextArea);


class BoundHalloRichTextArea extends BoundWidget {
setState(state) {
this.input.val(state);
this.input.siblings('[data-hallo-editor]').html(state);
}
focus() {
/* not implemented (leave blank so we don't try to focus the hidden field) */
}
}

class HalloRichTextArea extends Widget {
boundWidgetClass = BoundHalloRichTextArea;
}
window.telepath.register('wagtail.widgets.HalloRichTextArea', HalloRichTextArea);


class BaseDateTimeWidget extends Widget {
constructor(options) {
this.options = options;
Expand Down
9 changes: 9 additions & 0 deletions wagtail/admin/rich_text/editors/hallo.py
Expand Up @@ -9,6 +9,8 @@
from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter
from wagtail.admin.staticfiles import versioned_static
from wagtail.core.rich_text import features
from wagtail.core.telepath import register
from wagtail.core.widget_adapters import WidgetAdapter


class HalloPlugin:
Expand Down Expand Up @@ -162,3 +164,10 @@ def media(self):
media += plugin.media

return media


class HalloRichTextAreaAdapter(WidgetAdapter):
js_constructor = 'wagtail.widgets.HalloRichTextArea'


register(HalloRichTextAreaAdapter(), HalloRichTextArea)