From b1ba5fb48c8a760adf29b84cf17d351a066b229a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 17 Sep 2021 19:13:46 +0200 Subject: [PATCH 1/3] Convert end-of-line emoji when editing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/rooms/EditMessageComposer.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/EditMessageComposer.tsx b/src/components/views/rooms/EditMessageComposer.tsx index 7a3767deb7..35950492d6 100644 --- a/src/components/views/rooms/EditMessageComposer.tsx +++ b/src/components/views/rooms/EditMessageComposer.tsx @@ -27,7 +27,7 @@ import { findEditableEvent } from '../../../utils/EventUtils'; import { parseEvent } from '../../../editor/deserialize'; import { CommandPartCreator, Part, PartCreator, Type } from '../../../editor/parts'; import EditorStateTransfer from '../../../utils/EditorStateTransfer'; -import BasicMessageComposer from "./BasicMessageComposer"; +import BasicMessageComposer, { REGEX_EMOTICON } from "./BasicMessageComposer"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import { Command, CommandCategories, getCommand } from '../../../SlashCommands'; import { Action } from "../../../dispatcher/actions"; @@ -42,6 +42,7 @@ import ErrorDialog from "../dialogs/ErrorDialog"; import QuestionDialog from "../dialogs/QuestionDialog"; import { ActionPayload } from "../../../dispatcher/payloads"; import AccessibleButton from '../elements/AccessibleButton'; +import SettingsStore from "../../../settings/SettingsStore"; function getHtmlReplyFallback(mxEvent: MatrixEvent): string { const html = mxEvent.getContent().formatted_body; @@ -315,6 +316,14 @@ export default class EditMessageComposer extends React.Component private sendEdit = async (): Promise => { const startTime = CountlyAnalytics.getTimestamp(); const editedEvent = this.props.editState.getEvent(); + + // Replace emoticon at the end of the message + if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) { + const caret = this.editorRef.current?.getCaret(); + const position = this.model.positionForOffset(caret.offset, caret.atNodeEnd); + this.editorRef.current?.replaceEmoticon(position, REGEX_EMOTICON); + } + const editContent = createEditContent(this.model, editedEvent); const newContent = editContent["m.new_content"]; From 36decbb6dda57c5edb9fd724e39adb78fe3d1e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 17 Sep 2021 19:25:28 +0200 Subject: [PATCH 2/3] Fix pill deletion on FF 78 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../views/rooms/BasicMessageComposer.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/components/views/rooms/BasicMessageComposer.tsx b/src/components/views/rooms/BasicMessageComposer.tsx index edf4f515d2..055e597fb5 100644 --- a/src/components/views/rooms/BasicMessageComposer.tsx +++ b/src/components/views/rooms/BasicMessageComposer.tsx @@ -499,6 +499,7 @@ export default class BasicMessageEditor extends React.Component handled = true; } else if (event.key === Key.BACKSPACE || event.key === Key.DELETE) { this.formatBarRef.current.hide(); + handled = this.fakeDeletion(event.key === Key.BACKSPACE); } if (handled) { @@ -564,6 +565,29 @@ export default class BasicMessageEditor extends React.Component } }; + /** + * TODO: Remove when Debian moves to newer version of Firefox + * On Firefox 78 no event emitted when the user tries to delete pills. + * Therefore we need to fake what would normally happen + * @param direction in which to delete + * @returns handled + */ + private fakeDeletion(backward: boolean): boolean { + const selection = document.getSelection(); + // Use the default handling for ranges + if (selection.type === "Range") return false; + + this.modifiedFlag = true; + const { caret, text } = getCaretOffsetAndText(this.editorRef.current, selection); + + // Do the deletion itself + if (backward) caret.offset--; + const newText = text.slice(0, caret.offset) + text.slice(caret.offset + 1); + + this.props.model.update(newText, backward ? "deleteContentBackward" : "deleteContentForward", caret); + return true; + } + private async tabCompleteName(): Promise { try { await new Promise(resolve => this.setState({ showVisualBell: false }, resolve)); From 07ed6772be39d470e485e1347c644467b0df517e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 18 Sep 2021 13:52:56 +0200 Subject: [PATCH 3/3] Pass `PR_NUMBER` to builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .github/workflows/layered-build.yaml | 2 ++ .github/workflows/typecheck.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/layered-build.yaml b/.github/workflows/layered-build.yaml index c9d7e89a75..c8717667d7 100644 --- a/.github/workflows/layered-build.yaml +++ b/.github/workflows/layered-build.yaml @@ -5,6 +5,8 @@ on: jobs: build: runs-on: ubuntu-latest + env: + PR_NUMBER: ${{github.event.number}} steps: - uses: actions/checkout@v2 - name: Build diff --git a/.github/workflows/typecheck.yaml b/.github/workflows/typecheck.yaml index 2e08418cf6..f6ab643958 100644 --- a/.github/workflows/typecheck.yaml +++ b/.github/workflows/typecheck.yaml @@ -5,6 +5,8 @@ on: jobs: build: runs-on: ubuntu-latest + env: + PR_NUMBER: ${{github.event.number}} steps: - uses: actions/checkout@v2 - uses: c-hive/gha-yarn-cache@v2