diff --git a/package.json b/package.json index d1654bf998..61094afe93 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ }, "dependencies": { "@babel/runtime": "^7.12.5", + "@matrix-org/matrix-wysiwyg": "^2.4.1", "@matrix-org/analytics-events": "^0.6.0", - "@matrix-org/matrix-wysiwyg": "^2.3.1", "@matrix-org/react-sdk-module-api": "^1.0.0", "@sentry/browser": "^7.0.0", "@sentry/tracing": "^7.0.0", diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index 8235134537..d51f60bf86 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -371,7 +371,7 @@ export class MessageComposer extends React.Component { const { isRichTextEnabled, composerContent } = this.state; const convertedContent = isRichTextEnabled - ? await richToPlain(composerContent) + ? await richToPlain(composerContent, false) : await plainToRich(composerContent, false); this.setState({ diff --git a/src/components/views/rooms/wysiwyg_composer/DynamicImportWysiwygComposer.tsx b/src/components/views/rooms/wysiwyg_composer/DynamicImportWysiwygComposer.tsx index ba41bd4055..2e02fb5719 100644 --- a/src/components/views/rooms/wysiwyg_composer/DynamicImportWysiwygComposer.tsx +++ b/src/components/views/rooms/wysiwyg_composer/DynamicImportWysiwygComposer.tsx @@ -45,9 +45,11 @@ export const dynamicImportConversionFunctions = async (): Promise<{ * ensure that HTML entities are correctly interpreted, and to prevent newline characters being turned into `
`. * * @param rich - html to convert + * @param inMessageFormat - `true` to format the return value for use as a message `formatted_body`. + * `false` to format it for writing to an editor element. * @returns a string of plain text that may contain markdown */ - richToPlain(rich: string): Promise; + richToPlain(rich: string, inMessageFormat: boolean): Promise; /** * Creates a rust model from plain text input (interpreted as markdown) and uses it to generate the rich text diff --git a/src/components/views/rooms/wysiwyg_composer/utils/createMessageContent.ts b/src/components/views/rooms/wysiwyg_composer/utils/createMessageContent.ts index aa469a5fd2..58a4795c2a 100644 --- a/src/components/views/rooms/wysiwyg_composer/utils/createMessageContent.ts +++ b/src/components/views/rooms/wysiwyg_composer/utils/createMessageContent.ts @@ -96,7 +96,7 @@ export async function createMessageContent( // if we're editing rich text, the message content is pure html // BUT if we're not, the message content will be plain text where we need to convert the mentions - const body = isHTML ? await richToPlain(message) : convertPlainTextToBody(message); + const body = isHTML ? await richToPlain(message, false) : convertPlainTextToBody(message); const bodyPrefix = (isReplyAndEditing && getTextReplyFallback(editedEvent)) || ""; const formattedBodyPrefix = (isReplyAndEditing && getHtmlReplyFallback(editedEvent)) || ""; diff --git a/yarn.lock b/yarn.lock index 246b076a07..64e146271b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1806,10 +1806,10 @@ resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-1.0.1.tgz#21a0557a7bb3f60b37c6d412be8906c056fe79b8" integrity sha512-VTwV5IowvhhLXwAsDDAv02bC5/qBQbG2YtpYAije11253sQ3MePIoSR+dS40Ih3lAlEzqQ00GU3O+i45jMzIRQ== -"@matrix-org/matrix-wysiwyg@^2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-2.3.1.tgz#4b607323f3ffd8c332abeba7226010ecc031ed12" - integrity sha512-OxJvA+pSGdP2f55foZGEDmU2qvILFLLjV53MOgPw1F6zDAp8nDL1rPPIzFv1qgDj5W7d4Rzq7FnN25vINnAu+A== +"@matrix-org/matrix-wysiwyg@^2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-2.4.1.tgz#e1325a42366a1c891b2ba90c88e597b39187b2cb" + integrity sha512-RyUijZXVKenE9s3LczDUhWFeOfIyLcsOrAyHqYxnizXX5nxMkHxTgLeoTvaIJ+1dOhI+H2SS9G4VcN6odZ0aNg== "@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz": version "3.2.14"