From b496fe0a2bf11a3837e6e05e2e9b36f19b9e235c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 28 Jul 2023 09:02:43 +0100 Subject: [PATCH 1/5] Unhide the view source event toggle - it works well enough (#11336) --- res/css/views/rooms/_EventTile.pcss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/res/css/views/rooms/_EventTile.pcss b/res/css/views/rooms/_EventTile.pcss index 7c8d636301cd..6d93a5e41e2f 100644 --- a/res/css/views/rooms/_EventTile.pcss +++ b/res/css/views/rooms/_EventTile.pcss @@ -1203,11 +1203,6 @@ $left-gutter: 64px; height: 14px; /* avatar img size */ } - .mx_ViewSourceEvent_toggle { - display: none; /* hide the hidden event expand button, not enough - space, view source can still be used */ - } - &.mx_EventTile_selected .mx_EventTile_line, .mx_EventTile_line { $line-height: $font-12px; From c037b847da08a0dd476ddf6483e205b80162beca Mon Sep 17 00:00:00 2001 From: Germain Date: Fri, 28 Jul 2023 09:03:00 +0100 Subject: [PATCH 2/5] Upgrade wysiwyg editor for ctrl+backspace windows fix (#11324) * Upgrade wysiwyg editor for ctrl+backspace windows fix * upgrade lockfile * Fix after upgrading the wysiswyg package --- package.json | 2 +- src/components/views/rooms/MessageComposer.tsx | 2 +- .../wysiwyg_composer/DynamicImportWysiwygComposer.tsx | 4 +++- .../rooms/wysiwyg_composer/utils/createMessageContent.ts | 2 +- yarn.lock | 8 ++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d1654bf99879..61094afe93ed 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 8235134537ef..d51f60bf8601 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 ba41bd4055de..2e02fb571936 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 aa469a5fd29c..58a4795c2a7f 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 246b076a07dc..64e146271ba9 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" From b284fbcc37e06ab9d0e37d0745ea1e41519ad93a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 28 Jul 2023 10:25:39 +0100 Subject: [PATCH 3/5] Update static_analysis.yaml --- .github/workflows/static_analysis.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml index fca0b15afaaa..12cb829e19cf 100644 --- a/.github/workflows/static_analysis.yaml +++ b/.github/workflows/static_analysis.yaml @@ -45,12 +45,12 @@ jobs: # Temporary while we directly import matrix-js-sdk/src/* which means we need # certain @types/* packages to make sense of matrix-js-sdk types. - - name: Typecheck (release mode; no yarn link) - if: github.event_name != 'pull_request' - run: | - yarn unlink matrix-js-sdk - yarn install --force - yarn run lint:types + #- name: Typecheck (release mode; no yarn link) + # if: github.event_name != 'pull_request' + # run: | + # yarn unlink matrix-js-sdk + # yarn install --force + # yarn run lint:types i18n_lint: name: "i18n Check" From ddb8e0aa3ae4d726a9b0e8c9b16c9d2d7e5db0d6 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 28 Jul 2023 10:24:28 +0100 Subject: [PATCH 4/5] Update `SecureBackupPanel` to use `getCrypto()` (#11322) `MatrixClient.crypto` is going away, so let's switch over to `getCrypto()`. There doesn't seem to be anything else relying on the `crypto` stub in `mockClientMethodsCrypto()`, so let's get rid of that. --- .../views/settings/SecureBackupPanel.tsx | 2 +- .../views/settings/SecureBackupPanel-test.tsx | 16 +++++++--------- test/test-utils/client.ts | 6 ++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/views/settings/SecureBackupPanel.tsx b/src/components/views/settings/SecureBackupPanel.tsx index d595de80e06f..2f866aa18333 100644 --- a/src/components/views/settings/SecureBackupPanel.tsx +++ b/src/components/views/settings/SecureBackupPanel.tsx @@ -146,7 +146,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> { private async getUpdatedDiagnostics(): Promise { const cli = MatrixClientPeg.safeGet(); - const crypto = cli.crypto; + const crypto = cli.getCrypto(); if (!crypto) return; const secretStorage = cli.secretStorage; diff --git a/test/components/views/settings/SecureBackupPanel-test.tsx b/test/components/views/settings/SecureBackupPanel-test.tsx index a59e76ff3279..47d5d5c5c461 100644 --- a/test/components/views/settings/SecureBackupPanel-test.tsx +++ b/test/components/views/settings/SecureBackupPanel-test.tsx @@ -18,7 +18,12 @@ import React from "react"; import { fireEvent, render, screen, within } from "@testing-library/react"; import { mocked } from "jest-mock"; -import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../test-utils"; +import { + flushPromises, + getMockClientWithEventEmitter, + mockClientMethodsCrypto, + mockClientMethodsUser, +} from "../../../test-utils"; import SecureBackupPanel from "../../../../src/components/views/settings/SecureBackupPanel"; import { accessSecretStorage } from "../../../../src/SecurityManager"; @@ -30,20 +35,13 @@ describe("", () => { const userId = "@alice:server.org"; const client = getMockClientWithEventEmitter({ ...mockClientMethodsUser(userId), - checkKeyBackup: jest.fn(), - isKeyBackupKeyStored: jest.fn(), + ...mockClientMethodsCrypto(), getKeyBackupEnabled: jest.fn(), getKeyBackupVersion: jest.fn().mockReturnValue("1"), isKeyBackupTrusted: jest.fn().mockResolvedValue(true), getClientWellKnown: jest.fn(), deleteKeyBackupVersion: jest.fn(), - secretStorage: { hasKey: jest.fn() }, }); - // @ts-ignore allow it - client.crypto = { - getSessionBackupPrivateKey: jest.fn(), - isSecretStorageReady: jest.fn(), - } as unknown as Crypto; const getComponent = () => render(); diff --git a/test/test-utils/client.ts b/test/test-utils/client.ts index 056f18eee319..80bf9849ce4e 100644 --- a/test/test-utils/client.ts +++ b/test/test-utils/client.ts @@ -155,10 +155,6 @@ export const mockClientMethodsCrypto = (): Partial< getStoredCrossSigningForUser: jest.fn(), checkKeyBackup: jest.fn().mockReturnValue({}), secretStorage: { hasKey: jest.fn() }, - crypto: { - isSecretStorageReady: jest.fn(), - getSessionBackupPrivateKey: jest.fn(), - }, getCrypto: jest.fn().mockReturnValue({ getUserDeviceInfo: jest.fn(), getCrossSigningStatus: jest.fn().mockResolvedValue({ @@ -171,5 +167,7 @@ export const mockClientMethodsCrypto = (): Partial< }, }), isCrossSigningReady: jest.fn().mockResolvedValue(true), + isSecretStorageReady: jest.fn(), + getSessionBackupPrivateKey: jest.fn(), }), }); From 0647aafc3a84791f7e41a806b26521e46da607c4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 28 Jul 2023 10:42:20 +0100 Subject: [PATCH 5/5] Fix disable_3pid_login being ignored for the email field (#11335) --- src/components/views/auth/RegistrationForm.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/auth/RegistrationForm.tsx b/src/components/views/auth/RegistrationForm.tsx index 259277217d42..5f2a5c4facdb 100644 --- a/src/components/views/auth/RegistrationForm.tsx +++ b/src/components/views/auth/RegistrationForm.tsx @@ -433,7 +433,8 @@ export default class RegistrationForm extends React.PureComponent