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

Support rich text book descriptions #3880

Merged
merged 2 commits into from
Jan 25, 2025

Conversation

mikiher
Copy link
Contributor

@mikiher mikiher commented Jan 22, 2025

Brief summary

Add support for rich text in book descriptions (including matching and editing).

Which issue is fixed?

Fixes #1820, #3786

In-depth Description

This adds the following:

  • Centralized sanitization of match results.
  • Rich text editing for book descriptions (including match results)
  • Proper display of rich text book descriptions in item pages

The following changes were made:

  • BookDetailsEdit.vue and Match.vue
    • Replaced text-area-with-label with rich-text-editor for the description field.
  • RichTextEditor.vue
    • Added style="margin-top: 0; margin-bottom: 0.125em" to the label. This was to make it more compatible with TextareaWithLabel.
    • Added blur method to the editor. This is required by Details.vue.
    • Remvoed the config prop. It was moved into VueTrix.
  • VueTrix.vue
    • Put the trix-toolbar into the template, with a unique id. This seems better than passing it as a prop.
    • Show the toolbar only when the editor is enabled.
      • note: I tried showing disabled toolbar buttons when the editor is disabled, but the trix-editor is slightly buggy, and sometimes the toolbar buttons go back to showing enabled if you click on the editor area.
    • Moved enableBreakParagraphOnReturn into the static initialization block (since it only does static initialization).
    • Fixed trix-editor background color, to make it more compatible with the rest of the input fields (when disabled and when not disabled).
    • Made the trix-editor show the equivalent of 4 lines of text (4 * lh)
  • defaultStyles.css
    • Added less-spacing class to the p and ul tags. I think the current spacing (1em both before and after each block element) is a bit too much.
    • This is used in ViewEpisode.vue and pages/item/_id/index.vue
    • If you're OK with this, we can change the default-style classes themselves to use less spacing.
  • trix.css
    • Changed the trix-content class to inherit the line-height from the parent element.
    • Added trix-content p to modify how the editor renders the p tags.
      • I used even less spacing then in defaultStyles.css, because I thought the editor should be more compact than the displayed text, but please change it if you don't like it.
  • BookFinder.js
    • Moved all description sanitization into the runSearch method, instead of the various providers.
    • Added book.descriptionPlain to store a fully tag-stripped version of the description.
      • This is used in BookMatchCard.vue. I'm not sure if this is really required - maybe it's not a big deal if the card shows some html tags.
  • Book.js
    • Added descriptionPlain to JSON outputs.
      • This is used in one place on the client, when displaying the Currently description in the selected match in Match.vue. I'm not sure if what I did is the best way, and I'm not even sure it's really required (if we just use description instead, the only difference would be that the Currently might show a few html tags - maybe not a big deal).
  • htmlSanitizer.js
    • Added b and i tags to the allowed tags.

How have you tested this?

  • Made sure rich text match results are properly displayed and edited in the Match Tab and Details Tab
  • Made sure rich text descriptions are properly displayed in item pages and ViewEpisode modal.

@mikiher mikiher marked this pull request as ready for review January 22, 2025 07:13
@advplyr
Copy link
Owner

advplyr commented Jan 25, 2025

This is working great in my testing. We only needed descriptionPlain in the expanded json so I made that update.
Thanks!

@advplyr advplyr merged commit a4d0f95 into advplyr:master Jan 25, 2025
5 checks passed
advplyr added a commit that referenced this pull request Jan 25, 2025
@advplyr
Copy link
Owner

advplyr commented Jan 25, 2025

I just updated the mobile app for this and realized the <p> tag was containing <p> tags so updated it to a <div>

@mikiher
Copy link
Contributor Author

mikiher commented Jan 25, 2025

Oh, I forgot about the mobile client. The 3rd-party apps might break as well.

@advplyr
Copy link
Owner

advplyr commented Jan 25, 2025

They would show html tags for new/updated descriptions but I will include in the release notes that descriptionPlain is available for expanded library items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Support HTML/rich text descriptions for audiobooks
2 participants