prose-im / prose-app-web

Prose Web application. XMPP client for team messaging.
https://prose.org/downloads
Mozilla Public License 2.0
25 stars 2 forks source link

Adopt message sending changes #126

Closed nesium closed 4 months ago

nesium commented 4 months ago

The core now parses Markdown on its own so that it can convert it to the format specified in XEP-0393: Message Styling. This way the frontend doesn't need to construct references anymore. Just format them as markdown links, e.g.

Hey [@user](xmpp:user@prose.org)!

They will be automatically parsed and sent then.

Additionally Message now has content and rawContent where content is the HTML content of the message which should be rendered as-is, whereas the rawContent could be used for copying the message to the clipboard.

Note that existing messages will not be formatted. We could optimistically parse them, but XEP-0393 would change semantics when parsed as Markdown. We can add some heuristic if it's super annoying to browse the archive, like if sender and receiver are @prose.org, but that's not added yet.

API changes:

export class Message {
  // …

  /**
  * The formatted HTML. Should be used for display.
  */
  readonly content: string;

  /**
  * The original raw message. Can be used for copying the message.
  */
  readonly rawContent: string;

  /**
  * Deprecated. Use `content` or `rawContent` instead.
  */
  readonly text: string;

  // …
}

export class SendMessageRequestBody {
  // …

  /**
  * Deprecated.
  * @param {Mention} _mention
  */
  addMention(_mention: Mention): void;
  /**
  * Deprecated.
  */
  readonly mentions: Mention[];

  // …
}