-
Notifications
You must be signed in to change notification settings - Fork 11
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
Rich text editor templates #3176
Draft
maradragan
wants to merge
14
commits into
main
Choose a base branch
from
GH-3081-richt-text-editor-templates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
This makes sure that when creating a report, the reportText field contains a template text. Some of the heading blocks in the template are readonly and can't be removed. Note: it only works now on add, after save, on edit, the headings are no longer readonly (still to be implemented).
This makes sure that if the richTextEditor contains h1 tags marked with the mandatory class, they can be edited but the tags itself can not be deleted. Also, when the content is saved, the resulting html also still has the mandatory class for the h1 tag (this was not the case before).
In order to be able to save richText content containing also a class, we need to allow this in the HtmlPolicyBuilder, which is being used to sanitize the HTML before saving. We updated this one to allow the class attribute for h1 and p elements.
In the RichTextEditor, replace mandatory elements with a placeholder when all their text is being deleted.
In the RichTextEditor, replace mandatory elements with a placeholder when trying to delete their last content character.
Changed the style of the h1 mandatory element. Made sure the mandatory elements are only having a specific style when in the RichTextEditor.
It is now possible to configure within the anet.yml, through report.reportText.placeholder the html template to be used per default for the report text.
This makes sure that if an unstyled block has the mandatory class, it is also being saved as a html element with the mandatory class.
This makes sure that when specifying a default template for a richTextEditor type of field, we can also define a placeholder for the html elements having the class mandatory. This placeholder is being used to prefill the element if this one becomes empty. Both the class attribute and the placeholder attribute of an HTML tag of type h1, h2, h3 or p are being persisted in the database. This in order to be able to still know the mandatory elements and their eventual placeholders when editing an object with rich text content.
…Agency/anet into GH-3081-richt-text-editor-templates
Prevent return when: - at the beginning of a mandatory block => it would result in an empty mandatory block and a new non-mandatory block containing the text of the block which used to be mandatory. - the selection contains at least one mandatory block => it would result in deleting the selection including the mandatory block - exactly one whole mandatory block is selected, it would result in the contents of the mandatory block being deleted and the addition of a new empty block afterwards. Prevent delete or backspace when: - the selection contains several blocks and at least one of them is mandatory => we don't want to lose mandatory blocks Prevent delete when: - at the end of a block when the next block is => we don't want to merge a mandatory block into a previous one Prevent backspace when: - at the beginning of a mandatory block => we don't want to merge a mandatory block into a previous one The reason we don't want to merge a mandatory block B into a previous block A as: - if block A is not mandatory, block B would lose it's style and data (thus also the mandatory property) - if block A is also mandatory, we would end up with only one mandatory block instead of two. Prevent pasting on a selection when: - at least one of the selection blocks is mandatory. It would result in the removal of mandatory blocks.
This pull request introduces 1 alert when merging 5fe494d into 8583152 - view on LGTM.com new alerts:
|
gjvoosten
changed the title
Gh 3081 richt text editor templates
Gh 3081 rich text editor templates
Mar 25, 2021
gjvoosten
changed the title
Gh 3081 rich text editor templates
Rich text editor templates
Apr 7, 2021
gjvoosten
requested review from
midmarch and
VassilIordanov
and removed request for
gjvoosten
December 23, 2021 13:46
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.
This makes it possible to enforce a certain document structure in rich text fields.
The structure should be provided through the htmlTemplate property of the RichTextEditor component.
An example of a structure to use:
Heading or paragraph tags tags may use some extra attributes which make them behave special.
If one of these tags use
class="mandatory"
, the tag will become mandatory. This means that their text can be changed, but they can't be deleted.If one of these tags use
class="mandatory"
and aplaceholder
attribute (likeplaceholder="Key details 1"
), this means that when the user is deleting their text, it will automatically be replaced by the placeholder text.Note: this is only possible for
h1, h2, h3 or p
tags .For now this feature has been added to the reportText field of a report but can be added to other fields too.
TODO:
Release notes
Closes #3081
User changes
In order to make sure mandatory elements can't be deleted, we changed the way the rich text editor works.
Click Enter does nothing when:
Delete or backspace does nothing when:
Delete does nothing when:
Backspace does nothing when:
Pasting on a selection does nothing when:
TODO: Typing on a selection does nothing when:
Super User changes
Admin changes
System admin changes
Checklist
repo#issue: Title
title format and these 7 rules