nextcloud / mail

💌 Mail app for Nextcloud
https://apps.nextcloud.com/apps/mail
GNU Affero General Public License v3.0
846 stars 259 forks source link

Smart picker drops formatting #8239

Open ChristophWurst opened 1 year ago

ChristophWurst commented 1 year ago

Steps to reproduce

  1. Set up an IMAP account
  2. Install and enable https://apps.nextcloud.com/apps/text_templates
  3. Set up a text template that has line breaks
  4. Open the Mail app
  5. Click New message
  6. Open the action menu and click Add link
  7. Select text templates
  8. Pick a template

Expected behavior

Line breaks are preserved

Actual behavior

Line breaks do not show as such

Mail app version

3.0

Mailserver or service

No response

Operating system

No response

PHP engine version

None

Web server

None

Database

None

Additional info

No response

ChristophWurst commented 1 year ago

@julien-nc is there documentation on what one can expect as a result of a resource/smart picker?

ChristophWurst commented 1 year ago

https://github.com/julien-nc/text_templates/blob/da772a1fee566db486b45f247cc327acdf936344/src/views/TemplateCustomPickerElement.vue#L149 I think this is where the value is emitted when picked

ChristophWurst commented 1 year ago

Ideally we should get meta info about the type of value inside the string. Then we can make links real links in HTML messages, and convert text to HTML to preserve line break.

ChristophWurst commented 1 year ago

Mail 3.0 is in RC so this will be fixed with 3.1 at the earliest

ChristophWurst commented 1 year ago

@julien-nc :ping_pong: :)

julien-nc commented 1 year ago

@julien-nc is there documentation on what one can expect as a result of a resource/smart picker?

Not yet. And for the moment, the picker providers just return text. They don't have any way to specify any type.

If we pass anything else than a string as the event data, it will break the picker integration in Text, Talk etc... So the picker could listen to another event ('submit-richobject' for example) which would be emitted by the providers and which would have an object as data. Something like:

{ type: 'text/markdown', content: '### Intro\nblabla' }

I think it's better than asking each integrator (Mail, Text, Talk...) to check if they got a string or an object as picker result.

What do you think?

cc @juliushaertl

ChristophWurst commented 1 year ago

Alright. Then let's HTML-encode the text to preserve line breaks. I hope this doesn't break integration of link pickers.

julien-nc commented 1 year ago

Sometimes the provider does not even know which type it returns. The OpenAI's GPT one can be asked to return anything by the user depending on the query. Same for the text template one, we don't know what the user has set as template contents.

ChristophWurst commented 1 year ago

How does https://nextcloud-vue-components.netlify.app/#/Components/NcRichText treat the picker result? Insert as-is or convert to HTML for the editable div?

julien-nc commented 1 year ago

It inserts an HTML text node with the picker result as content: https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/NcRichContenteditable/NcRichContenteditable.vue#L426-L431