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

Change help text in stream field to RichText #4375

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

frjo
Copy link
Member

@frjo frjo commented Feb 3, 2025

Fixes #3293

Test Steps

  • Test that the "Help text" field in each stream form field in application forms, review forms etc. has a rich text editor.
  • Confirm that any old "Help links" have been migrated into the "Help text" field as links.

@frjo frjo changed the title Enhancement/gh 3288 change help to rich text 2 Change help text in stream field to markdown Feb 3, 2025
@frjo frjo mentioned this pull request Feb 3, 2025
@frjo
Copy link
Member Author

frjo commented Feb 3, 2025

@wes-otf This PR removes the help link field and migrate any existing links as markdown links and the end of any help text.

The help text field already accepts and renders any markdown you add to it.

What's missing yet is a markdown editor for the help field, if that is needed.

@frankduncan
Copy link
Contributor

For our part, a markdown editor is important to our clients.

@frjo frjo changed the title Change help text in stream field to markdown Change help text in stream field to RichText Feb 4, 2025
@frjo
Copy link
Member Author

frjo commented Feb 4, 2025

Tested a number of ways to get a Markdown editor on the help text field but found no clean way of doing it.

Current version converts the field in to a Wagtail RichTextBlock instead, just like @frankduncan PR.

@frankduncan
Copy link
Contributor

frankduncan commented Feb 4, 2025

The best thing we've found in a different project was importing the js-only library wysimark and writing javascript to populate and pull the information out. I'm not sure how that would interact with the wagtail admin stuff.

I know wagtail has some javascript events (we used it in our email configuration code) that you can hook into to do things.

@frjo
Copy link
Member Author

frjo commented Feb 4, 2025

Normally I default to markdown but in this case I think rich text is the better option.

All other fields that have formatting are already using the wagtail rich text editor. The consistency is appreciated by staff I think. The editor is quite nice as well.

This PR is now very much a copy of #3293 with the added migrations of the help link field.

@wes-otf
Copy link
Contributor

wes-otf commented Feb 4, 2025

I had no idea the help text fields would render markdown as is, basic formatting in help text has been a request from staff for a little while so that info will fix some issues in in the interim.

I see no issues with converting this to RichText though. It looks like the help text fields are stored in raw markdown format so we'll also probably need a migration that converts existing fields into HTML

@@ -61,15 +61,6 @@
<div class="form__help prose prose-sm">{{ field.help_text|markdown|nh3 }}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could also probably be tossed right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes the markdown filter can go and likely the nh3 as well since this is not user generated.

Or we could consider adding nh3 to all outputs, as an extra safety measure.

Copy link
Member Author

@frjo frjo Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wes-otf If OTF is not using Markdown in the help text as of now I suggest we get this deployed soon and avoid more migrations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTF isn't using markdown but even plaintext will still need to be wrapped in a <p> tag for rich text (if I'm understanding how richtext is stored) so a migration might be necessary. not sure if any adopters have used it either

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also makes sense to use nh3, maybe we should also do that for paragraph blocks too just for uniformity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nh3 filter gives an error used alone here, unsure why but it is not really needed anyway so removed it.

The migration is working as it should in my testing. Old as well as new text are rendered correctly with p-tags and all.

@frjo frjo force-pushed the enhancement/gh-3288-change-help-to-rich-text-2 branch from 779815d to 88ccdc8 Compare February 4, 2025 15:03
@frjo
Copy link
Member Author

frjo commented Feb 5, 2025

@wes-otf Can you give this a test locally before we deploy it to the test server?

Some complex migrations that would mess up the test db if there are bugs.

You can revert the test tb but it is a bit of a hassel.

@wes-otf
Copy link
Contributor

wes-otf commented Feb 5, 2025

yes! I'll try it out today

@wes-otf
Copy link
Contributor

wes-otf commented Feb 5, 2025

I think it's ready for test! tested it with existing help text strings (non-markdown) and things migrated totally fine and the rich text displayed as expected

@wes-otf
Copy link
Contributor

wes-otf commented Feb 5, 2025

@frankduncan just wanted to confirm none of your adopters use markdown in the help text field currently?

@frankduncan
Copy link
Contributor

frankduncan commented Feb 6, 2025

@wes-otf Correct, none of them use markdown.

@frjo frjo added Status: Needs testing Tickets that need testing/qa Type: Feature This is something new (not an enhancement of an existing thing). Type: Patch Mini change, used in release drafter Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Feb 6, 2025
@wes-otf wes-otf removed Status: Needs testing Tickets that need testing/qa Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Feb 6, 2025
@frjo frjo merged commit 1a4dd47 into main Feb 6, 2025
7 checks passed
@frjo frjo added Type: Minor Minor change, used in release drafter and removed Type: Patch Mini change, used in release drafter labels Feb 12, 2025
@frjo frjo deleted the enhancement/gh-3288-change-help-to-rich-text-2 branch March 11, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Tested - approved for live ✅ Type: Feature This is something new (not an enhancement of an existing thing). Type: Minor Minor change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants