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

Automatically convert event descriptions to/from HTML #449

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NeilRashbrook
Copy link
Collaborator

Needed for future calendar work:

  • When sending invitations, cancellations and responses, we need to be able to send the description in plain text as well as HTML
  • When creating teams meetings, OWA will generate the description in plain text by default, which we will need to upconvert to HTML for the event editor

Copy link
Collaborator

@benbucksch benbucksch left a comment

Choose a reason for hiding this comment

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

I feel uncomfortable with the subtle differences between Abstract/Message and Calendar/Event .

In email, we're writing .html = , here rawHTML. a possible reason might have been that we never write emails, but we do have to sync back cal events, so maybe that's why you read from rawHTML when syncing to server, and then you write to rawHTML for consistency? This kind of thing would be appreciated as code comments, or as PR comment.

In Message, we clear text in the caller, whereas in Event, the descriptionHTML clears the .text property in the setter.

  1. Could you please explain the reasons for the discrepancies (if they are intentional)?
  2. what's the plan to make it consistent? (i'd prefer a separate PR for email changes)

Comment on lines 63 to 77
if (this._rawHTML != null) {
return this._sanitizedHTML = sanitizeHTML(this._rawHTML);
}
if (this._text != null) {
return this._sanitizedHTML = convertTextToHTML(this._text);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs try/catch, see Abstract/Message.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needs try/catch, see Abstract/Message.ts

That's unhelpful, as I don't understand why there's a try/catch there in the first place. (Particularly as there isn't one in the text code, which also performs sanitisation. If that's a mistake on your part, then congratulations, you successfully confused me.)

The front end edits descriptionHTML - obviously this needs to read the sanitised version, but also when the editor changes the value, we need to reset the text automatically; I don't know whether that's possible within the editor. I made the regular text and description accessors clear each other automatically for this reason.

On the other hand, the network and storage may have access to both text and HTML formats and would want to be able to process them separately, so they use the raw accessors for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why there's a try/catch there in the first place

Because sanitizeHTML() and convertTextToHTML() can throw.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are those libraries that bad? Have you filed bugs? (Also convertHTMLToText calls sanitizeHTML, and there's no try/catch there.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had to rebase the branch because of your merge conflict, but I added the try/catch in a separate commit.

@benbucksch
Copy link
Collaborator

benbucksch commented Feb 27, 2025

  1. Could you please explain the reasons for the discrepancies (if they are intentional)?
  2. what's the plan to make it consistent? (i'd prefer a separate PR for email changes)

Hey Neil, coud you please address these points?

@NeilRashbrook
Copy link
Collaborator Author

See #449 (comment)

@NeilRashbrook NeilRashbrook force-pushed the neil/event-description-html-conversion branch from 2dd11dd to a4ceace Compare February 27, 2025 20:58
@NeilRashbrook
Copy link
Collaborator Author

what's the plan to make it consistent?

That depends on whether you agree with my reasoning for doing it the way I did.

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.

2 participants