forms: use godo-editor custom element for rich text widgets (#85571)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3e6eeff81c
commit
8a7c779d91
|
@ -153,11 +153,11 @@ def test_text(pub):
|
|||
|
||||
form = Form(use_tokens=False)
|
||||
fields.TextField(display_mode='rich').add_to_form(form)
|
||||
assert 'data-godo-schema="full"' in str(form.render())
|
||||
assert PyQuery(str(form.render()))('godo-editor[schema=full]')
|
||||
|
||||
form = Form(use_tokens=False)
|
||||
fields.TextField(display_mode='basic-rich').add_to_form(form)
|
||||
assert 'data-godo-schema="basic"' in str(form.render())
|
||||
assert PyQuery(str(form.render()))('godo-editor[schema=basic]')
|
||||
|
||||
|
||||
def test_text_anonymise(pub):
|
||||
|
|
|
@ -595,7 +595,7 @@ def test_wysiwygwidget_img():
|
|||
def test_mini_rich_text_widget():
|
||||
widget = MiniRichTextWidget('test')
|
||||
form = MockHtmlForm(widget)
|
||||
assert 'data-godo-schema="basic"' in form.as_html
|
||||
assert PyQuery(form.as_html)('godo-editor[schema=basic]')
|
||||
|
||||
|
||||
def test_mini_rich_text_widget_maxlength():
|
||||
|
@ -613,7 +613,7 @@ def test_mini_rich_text_widget_maxlength():
|
|||
def test_rich_text_widget():
|
||||
widget = RichTextWidget('test')
|
||||
form = MockHtmlForm(widget)
|
||||
assert 'data-godo-schema="full"' in form.as_html
|
||||
assert PyQuery(form.as_html)('godo-editor[schema=full]')
|
||||
|
||||
|
||||
def test_select_hint_widget():
|
||||
|
|
|
@ -58,7 +58,7 @@ def test_display_message_rich_text(pub):
|
|||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get(display_message.get_admin_url())
|
||||
assert resp.pyquery('textarea[data-godo-schema]') # godo
|
||||
assert resp.pyquery('godo-editor') # godo
|
||||
|
||||
display_message.message = '<table><tr><td>hello world</td></tr></table>'
|
||||
workflow.store()
|
||||
|
@ -76,13 +76,13 @@ def test_display_message_rich_text(pub):
|
|||
display_message.message = '<ul>{% for item in lists %}<li>{{ item }}</li>{% endfor %}</ul>'
|
||||
workflow.store()
|
||||
resp = app.get(display_message.get_admin_url())
|
||||
assert resp.pyquery('textarea:not([data-config]):not([data-godo-schema])') # plain textarea
|
||||
assert resp.pyquery('textarea:not([data-config])') # plain textarea
|
||||
|
||||
pub.site_options.set('options', 'rich-text-wf-displaymsg', 'auto-textarea')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
resp = app.get(display_message.get_admin_url())
|
||||
assert resp.pyquery('textarea:not([data-config]):not([data-godo-schema])') # plain textarea
|
||||
assert resp.pyquery('textarea:not([data-config])') # plain textarea
|
||||
|
||||
pub.site_options.set('options', 'rich-text-wf-displaymsg', 'auto-ckeditor')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
|
@ -102,10 +102,10 @@ def test_display_message_rich_text(pub):
|
|||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
resp = app.get(display_message.get_admin_url())
|
||||
assert resp.pyquery('textarea[data-godo-schema]') # godo
|
||||
assert resp.pyquery('godo-editor') # godo
|
||||
|
||||
pub.site_options.set('options', 'rich-text-wf-displaymsg', 'textarea')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
resp = app.get(display_message.get_admin_url())
|
||||
assert resp.pyquery('textarea:not([data-config]):not([data-godo-schema])') # plain textarea
|
||||
assert resp.pyquery('textarea:not([data-config])') # plain textarea
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
{% extends "qommon/forms/widget.html" %}
|
||||
{% block widget-control %}
|
||||
<textarea style="width: 100%" id="form_{{widget.get_name_for_id}}" name="{{widget.name}}"
|
||||
{% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}" {% endfor %}
|
||||
{% if widget.live_condition_source %}data-godo-instant-update="true"{% endif %}
|
||||
data-godo-schema="{{widget.EDITION_MODE}}"
|
||||
data-godo-update-event="wcs:live-update">{{widget.value|default:""}}</textarea>
|
||||
<textarea hidden id="form_{{widget.get_name_for_id}}" name="{{widget.name}}">
|
||||
{{widget.value|default:""}}
|
||||
</textarea>
|
||||
<godo-editor
|
||||
style="width: 100%"
|
||||
{% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}" {% endfor %}
|
||||
{% if widget.live_condition_source %}instant-update="true"{% endif %}
|
||||
schema="{{widget.EDITION_MODE}}"
|
||||
update-event="wcs:live-update"
|
||||
linked-source="form_{{widget.get_name_for_id}}"
|
||||
>
|
||||
</godo-editor>
|
||||
<script type="module" src="/static/xstatic/js/godo.js?{{version_hash}}"></script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue