CM-420 add GovspeakEditor to govspeak-enabled textareas#19
Merged
Conversation
7b5c854 to
16b7868
Compare
pezholio
reviewed
Sep 3, 2025
| locale: options[:locale], | ||
| ).to_html | ||
|
|
||
| "<div class=\"govspeak\">#{html}</div>".html_safe |
Contributor
There was a problem hiding this comment.
Might be better to use the content_tag helper here
Collaborator
Author
There was a problem hiding this comment.
yes, but for now I'm just lifting and shifting selected code from Whitehall, so I'd prefer to do refactoring later to avoid any unintended side-effects.
6d8f956 to
538ace6
Compare
Collaborator
Author
|
@pezholio this is ready for another look now |
This was brought over from Whitehall but is not used or currently needed. We remove it to avoid confusion. This is described as a: > Helper class to render govspeak outside of the view contexts.
538ace6 to
775e11c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add GovspeakEditor to govspeak-enabled textareas
See Jira CM-420
In this PR we:
GovspeakHelpersupports. Our content block textareas are much smaller and simpler than the document-scale textareas available in WhitehallWhitehall::GovspeakRendererhelper class which was brought over from Whitehall but is not usedNotes on use of Govspeak
1) GovspeakEditor: when editing content (implemented in this PR)
When composing or editing a govspeak-enabled
<textarea>we offer users the facility to toggle between "Preview" and "Edit" modes.When choosing to "Preview" the content of the textarea, we use Ajax to send a
POSTrequest to the/admin/previewendpoint. TheAdmin::PreviewControlleruses theGovspeakPreviewHelperwhich ultimately calls#to_hamlon a newGovspeak::Document, defined in thegovspeakgem, a dependency of thecontent_block_toolsgem.2) render_govspeak: when displaying saved content
When displaying govspeak-enabled fields which have been saved, on workflow pages such as:
editions/1/workflow/group_contact_methods#telephonesoreditions/1/workflow/reviewthe
EmbeddedObjects::SummaryCard::NestedItemComponentuses theContentBlockManager::ContentBlock::GovspeakHelperand calls out torender_govspeakin the content_block_tools gem:3) DefaultBlockComponent: rendering entire block
Once a content block is published and can be viewed on the "show" block page: e.g.
/content-block/1, we use theDefaultBlockComponentwhich renders the block using thecontent_block_toolsgem:When rendering the
ContactComponent, for example, the content_block_tools gem usesContentBlockTools::Govspeak::render_govspeak(see [2]) on the govspeak-enabled fields. See thetelephone_component.html.erb:Notes
Currently the only fields which can be govspeak enabled are on embedded objects (aka "nested objects", "nested items"). It will take a bit of work to make
GovspeakEnabledTextareaComponentgeneral-purpose, as currentlygovspeak-enabled?is defined only onEmbeddedSchema.We have two similarly named helpers which ought to be combined:
GovspeakPreviewHelperused by GovspeakEditorGovspeakHelperused byNestedItemComponentWe also had (copied over from Whitehall but now deleted) a
Whitehall::GovspeakRendererwhich inherits fromActionController::Rendererand provides the followinghelpersmethods:govspeak_edition_to_htmlgovspeak_to_htmlgovspeak_with_attachments_to_htmlgovspeak_html_attachment_to_htmlblock_attachments