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

Use Textarea instead of rich text editor #82

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

J4bbi
Copy link
Collaborator

@J4bbi J4bbi commented Oct 29, 2024


This PR simply replaces the Rich Text Editor field with a Textarea field for the description.

Developer Checklist

Developers should review and confirm each of these items before requesting review

  • Code meets acceptance criteria from issue
  • Unit tests are written and all pass
  • User Test Scripts (if required) are written and have been run through
  • Code documentation and related non-code documentation has all been updated

Reviewer Checklist

Reviewers should review and confirm each of these items before approval
If there are multiple reviewers, this section can be duplicated for each reviewer

  • Code meets acceptance criteria from issue
  • Unit tests are written and all pass
  • User Test Scripts (if required) are written and have been run through
  • Code documentation and related non-code documentation has all been updated
  • Migation has been created and tested

Testing

List user test scripts that need to be run

List any non-unit test scripts that need to be run

@cc-a
Copy link
Collaborator

cc-a commented Nov 8, 2024

Is this ready @J4bbi?

@J4bbi J4bbi force-pushed the feature/remove_html_from_description branch from 5b4195c to 3206e9c Compare November 11, 2024 16:31
@J4bbi
Copy link
Collaborator Author

J4bbi commented Nov 11, 2024

Is this ready @J4bbi?

No. Not quite @cc-a.

TinyMCE is a recent addition to Invenio/Zenodo. It was added at the end of last year. We can only marvel at the reasoning because it is behind closed doors.

Disabling the toolbar makes it impossible for the editor to stylize content directly.

This still enabled users to copy and paste rich text content that would be formatted. In order to prevent that, I've set the list of valid elements to empty list.

TinyMCE wraps content in a root element that I've created an issue about.

It seems there are two options:

  • Accept a root block element being injected into the description when the record's description is manually edited
  • Fork invenio-rdm-records and remove the root element onFormSubmit.

I've considered other approaches. The TinyMCE editor has several event listeners but it doesn't give you raw access to the content.

Another approach would be to overwrite the component with a raw <Textarea>, but that would then leave the problem of stripping HTML. Another solution there could be to have the HTML stripped in the backend. How do you want to proceed?

@J4bbi J4bbi force-pushed the feature/remove_html_from_description branch from 3206e9c to dbec64e Compare November 14, 2024 09:37
@J4bbi J4bbi force-pushed the feature/remove_html_from_description branch from dbec64e to 46fb2e0 Compare November 14, 2024 09:40
@J4bbi J4bbi changed the title Disable toolbar in editor Use Textarea instead of rich text editor Nov 14, 2024
@J4bbi J4bbi marked this pull request as ready for review November 14, 2024 09:59
@cc-a cc-a self-requested a review November 19, 2024 14:08
Copy link
Collaborator

@cc-a cc-a left a comment

Choose a reason for hiding this comment

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

Nice clean and simple implementation this way.

@cc-a cc-a merged commit eabadac into develop Nov 19, 2024
2 checks passed
@cc-a cc-a deleted the feature/remove_html_from_description branch November 19, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants