Allow edits which just remove the quote
This commit is contained in:
parent
96a2d05906
commit
855b1c03b0
8 changed files with 18 additions and 25 deletions
|
@ -81,9 +81,7 @@ export default {
|
||||||
onEditorStateChange: action('onEditorStateChange'),
|
onEditorStateChange: action('onEditorStateChange'),
|
||||||
onTextTooLong: action('onTextTooLong'),
|
onTextTooLong: action('onTextTooLong'),
|
||||||
draftText: undefined,
|
draftText: undefined,
|
||||||
clearQuotedMessage: action('clearQuotedMessage'),
|
|
||||||
getPreferredBadge: () => undefined,
|
getPreferredBadge: () => undefined,
|
||||||
getQuotedMessage: action('getQuotedMessage'),
|
|
||||||
sortedGroupMembers: [],
|
sortedGroupMembers: [],
|
||||||
// EmojiButton
|
// EmojiButton
|
||||||
onPickEmoji: action('onPickEmoji'),
|
onPickEmoji: action('onPickEmoji'),
|
||||||
|
|
|
@ -193,13 +193,12 @@ export type OwnProps = Readonly<{
|
||||||
|
|
||||||
export type Props = Pick<
|
export type Props = Pick<
|
||||||
CompositionInputProps,
|
CompositionInputProps,
|
||||||
| 'clearQuotedMessage'
|
|
||||||
| 'draftText'
|
| 'draftText'
|
||||||
| 'draftBodyRanges'
|
| 'draftBodyRanges'
|
||||||
| 'getPreferredBadge'
|
| 'getPreferredBadge'
|
||||||
| 'getQuotedMessage'
|
|
||||||
| 'onEditorStateChange'
|
| 'onEditorStateChange'
|
||||||
| 'onTextTooLong'
|
| 'onTextTooLong'
|
||||||
|
| 'quotedMessageId'
|
||||||
| 'sendCounter'
|
| 'sendCounter'
|
||||||
| 'sortedGroupMembers'
|
| 'sortedGroupMembers'
|
||||||
> &
|
> &
|
||||||
|
@ -275,11 +274,9 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
setMediaQualitySetting,
|
setMediaQualitySetting,
|
||||||
shouldSendHighQualityAttachments,
|
shouldSendHighQualityAttachments,
|
||||||
// CompositionInput
|
// CompositionInput
|
||||||
clearQuotedMessage,
|
|
||||||
draftBodyRanges,
|
draftBodyRanges,
|
||||||
draftText,
|
draftText,
|
||||||
getPreferredBadge,
|
getPreferredBadge,
|
||||||
getQuotedMessage,
|
|
||||||
isFormattingEnabled,
|
isFormattingEnabled,
|
||||||
onEditorStateChange,
|
onEditorStateChange,
|
||||||
onTextTooLong,
|
onTextTooLong,
|
||||||
|
@ -720,10 +717,10 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
const handleEscape = useCallback(() => {
|
const handleEscape = useCallback(() => {
|
||||||
if (linkPreviewResult) {
|
if (linkPreviewResult) {
|
||||||
onCloseLinkPreview(conversationId);
|
onCloseLinkPreview(conversationId);
|
||||||
} else if (draftEditMessage) {
|
|
||||||
discardEditMessage(conversationId);
|
|
||||||
} else if (quotedMessageId) {
|
} else if (quotedMessageId) {
|
||||||
setQuoteByMessageId(conversationId, undefined);
|
setQuoteByMessageId(conversationId, undefined);
|
||||||
|
} else if (draftEditMessage) {
|
||||||
|
discardEditMessage(conversationId);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
conversationId,
|
conversationId,
|
||||||
|
@ -1024,14 +1021,12 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CompositionInput
|
<CompositionInput
|
||||||
clearQuotedMessage={clearQuotedMessage}
|
|
||||||
conversationId={conversationId}
|
conversationId={conversationId}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
draftBodyRanges={draftBodyRanges}
|
draftBodyRanges={draftBodyRanges}
|
||||||
draftEditMessage={draftEditMessage}
|
draftEditMessage={draftEditMessage}
|
||||||
draftText={draftText}
|
draftText={draftText}
|
||||||
getPreferredBadge={getPreferredBadge}
|
getPreferredBadge={getPreferredBadge}
|
||||||
getQuotedMessage={getQuotedMessage}
|
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
inputApi={inputApiRef}
|
inputApi={inputApiRef}
|
||||||
isFormattingEnabled={isFormattingEnabled}
|
isFormattingEnabled={isFormattingEnabled}
|
||||||
|
@ -1048,6 +1043,7 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onTextTooLong={onTextTooLong}
|
onTextTooLong={onTextTooLong}
|
||||||
platform={platform}
|
platform={platform}
|
||||||
|
quotedMessageId={quotedMessageId}
|
||||||
sendCounter={sendCounter}
|
sendCounter={sendCounter}
|
||||||
shouldHidePopovers={shouldHidePopovers}
|
shouldHidePopovers={shouldHidePopovers}
|
||||||
skinTone={skinTone ?? null}
|
skinTone={skinTone ?? null}
|
||||||
|
|
|
@ -30,9 +30,7 @@ const useProps = (overrideProps: Partial<Props> = {}): Props => {
|
||||||
draftText: overrideProps.draftText ?? null,
|
draftText: overrideProps.draftText ?? null,
|
||||||
draftEditMessage: overrideProps.draftEditMessage ?? null,
|
draftEditMessage: overrideProps.draftEditMessage ?? null,
|
||||||
draftBodyRanges: overrideProps.draftBodyRanges || [],
|
draftBodyRanges: overrideProps.draftBodyRanges || [],
|
||||||
clearQuotedMessage: action('clearQuotedMessage'),
|
|
||||||
getPreferredBadge: () => undefined,
|
getPreferredBadge: () => undefined,
|
||||||
getQuotedMessage: action('getQuotedMessage'),
|
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isFormattingEnabled:
|
isFormattingEnabled:
|
||||||
overrideProps.isFormattingEnabled === false
|
overrideProps.isFormattingEnabled === false
|
||||||
|
@ -45,6 +43,7 @@ const useProps = (overrideProps: Partial<Props> = {}): Props => {
|
||||||
onSubmit: action('onSubmit'),
|
onSubmit: action('onSubmit'),
|
||||||
onTextTooLong: action('onTextTooLong'),
|
onTextTooLong: action('onTextTooLong'),
|
||||||
platform: 'darwin',
|
platform: 'darwin',
|
||||||
|
quotedMessageId: null,
|
||||||
sendCounter: 0,
|
sendCounter: 0,
|
||||||
sortedGroupMembers: overrideProps.sortedGroupMembers ?? [],
|
sortedGroupMembers: overrideProps.sortedGroupMembers ?? [],
|
||||||
skinTone: overrideProps.skinTone ?? null,
|
skinTone: overrideProps.skinTone ?? null,
|
||||||
|
|
|
@ -71,6 +71,7 @@ import {
|
||||||
} from '../quill/formatting/matchers';
|
} from '../quill/formatting/matchers';
|
||||||
import { missingCaseError } from '../util/missingCaseError';
|
import { missingCaseError } from '../util/missingCaseError';
|
||||||
import { AutoSubstituteAsciiEmojis } from '../quill/auto-substitute-ascii-emojis';
|
import { AutoSubstituteAsciiEmojis } from '../quill/auto-substitute-ascii-emojis';
|
||||||
|
import { dropNull } from '../util/dropNull';
|
||||||
|
|
||||||
Quill.register('formats/emoji', EmojiBlot);
|
Quill.register('formats/emoji', EmojiBlot);
|
||||||
Quill.register('formats/mention', MentionBlot);
|
Quill.register('formats/mention', MentionBlot);
|
||||||
|
@ -139,9 +140,8 @@ export type Props = Readonly<{
|
||||||
): unknown;
|
): unknown;
|
||||||
onScroll?: (ev: React.UIEvent<HTMLElement>) => void;
|
onScroll?: (ev: React.UIEvent<HTMLElement>) => void;
|
||||||
platform: string;
|
platform: string;
|
||||||
|
quotedMessageId: string | null;
|
||||||
shouldHidePopovers: boolean | null;
|
shouldHidePopovers: boolean | null;
|
||||||
getQuotedMessage?(): unknown;
|
|
||||||
clearQuotedMessage?(): unknown;
|
|
||||||
linkPreviewLoading?: boolean;
|
linkPreviewLoading?: boolean;
|
||||||
linkPreviewResult: LinkPreviewType | null;
|
linkPreviewResult: LinkPreviewType | null;
|
||||||
onCloseLinkPreview?(conversationId: string): unknown;
|
onCloseLinkPreview?(conversationId: string): unknown;
|
||||||
|
@ -153,14 +153,12 @@ const BASE_CLASS_NAME = 'module-composition-input';
|
||||||
export function CompositionInput(props: Props): React.ReactElement {
|
export function CompositionInput(props: Props): React.ReactElement {
|
||||||
const {
|
const {
|
||||||
children,
|
children,
|
||||||
clearQuotedMessage,
|
|
||||||
conversationId,
|
conversationId,
|
||||||
disabled,
|
disabled,
|
||||||
draftBodyRanges,
|
draftBodyRanges,
|
||||||
draftEditMessage,
|
draftEditMessage,
|
||||||
draftText,
|
draftText,
|
||||||
getPreferredBadge,
|
getPreferredBadge,
|
||||||
getQuotedMessage,
|
|
||||||
i18n,
|
i18n,
|
||||||
inputApi,
|
inputApi,
|
||||||
isFormattingEnabled,
|
isFormattingEnabled,
|
||||||
|
@ -177,6 +175,7 @@ export function CompositionInput(props: Props): React.ReactElement {
|
||||||
onSubmit,
|
onSubmit,
|
||||||
placeholder,
|
placeholder,
|
||||||
platform,
|
platform,
|
||||||
|
quotedMessageId,
|
||||||
shouldHidePopovers,
|
shouldHidePopovers,
|
||||||
skinTone,
|
skinTone,
|
||||||
sendCounter,
|
sendCounter,
|
||||||
|
@ -510,11 +509,6 @@ export function CompositionInput(props: Props): React.ReactElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getQuotedMessage?.()) {
|
|
||||||
clearQuotedMessage?.();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -598,6 +592,8 @@ export function CompositionInput(props: Props): React.ReactElement {
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
} else if (!areBodyRangesEqual(bodyRanges, draftEditMessage.bodyRanges)) {
|
} else if (!areBodyRangesEqual(bodyRanges, draftEditMessage.bodyRanges)) {
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
|
} else if (dropNull(quotedMessageId) !== draftEditMessage.quote?.id) {
|
||||||
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
propsRef.current.onDirtyChange(isDirty);
|
propsRef.current.onDirtyChange(isDirty);
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
// Copyright 2022 Signal Messenger, LLC
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { noop } from 'lodash';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { LocalizerType } from '../types/I18N';
|
import type { LocalizerType } from '../types/I18N';
|
||||||
import type { EmojiPickDataType } from './emoji/EmojiPicker';
|
import type { EmojiPickDataType } from './emoji/EmojiPicker';
|
||||||
import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled';
|
|
||||||
import type { InputApi } from './CompositionInput';
|
import type { InputApi } from './CompositionInput';
|
||||||
import { CompositionInput } from './CompositionInput';
|
import { CompositionInput } from './CompositionInput';
|
||||||
import { EmojiButton } from './emoji/EmojiButton';
|
import { EmojiButton } from './emoji/EmojiButton';
|
||||||
|
@ -135,11 +133,9 @@ export function CompositionTextArea({
|
||||||
return (
|
return (
|
||||||
<div className="CompositionTextArea">
|
<div className="CompositionTextArea">
|
||||||
<CompositionInput
|
<CompositionInput
|
||||||
clearQuotedMessage={shouldNeverBeCalled}
|
|
||||||
draftBodyRanges={bodyRanges}
|
draftBodyRanges={bodyRanges}
|
||||||
draftText={draftText}
|
draftText={draftText}
|
||||||
getPreferredBadge={getPreferredBadge}
|
getPreferredBadge={getPreferredBadge}
|
||||||
getQuotedMessage={noop}
|
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
isFormattingEnabled={isFormattingEnabled}
|
isFormattingEnabled={isFormattingEnabled}
|
||||||
|
@ -153,6 +149,7 @@ export function CompositionTextArea({
|
||||||
onTextTooLong={onTextTooLong}
|
onTextTooLong={onTextTooLong}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
platform={platform}
|
platform={platform}
|
||||||
|
quotedMessageId={null}
|
||||||
scrollerRef={scrollerRef}
|
scrollerRef={scrollerRef}
|
||||||
sendCounter={0}
|
sendCounter={0}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
|
|
@ -1314,6 +1314,7 @@ export function MediaEditor({
|
||||||
onTextTooLong={onTextTooLong}
|
onTextTooLong={onTextTooLong}
|
||||||
placeholder={i18n('icu:MediaEditor__input-placeholder')}
|
placeholder={i18n('icu:MediaEditor__input-placeholder')}
|
||||||
platform={platform}
|
platform={platform}
|
||||||
|
quotedMessageId={null}
|
||||||
sendCounter={0}
|
sendCounter={0}
|
||||||
sortedGroupMembers={sortedGroupMembers}
|
sortedGroupMembers={sortedGroupMembers}
|
||||||
theme={ThemeType.dark}
|
theme={ThemeType.dark}
|
||||||
|
|
|
@ -259,6 +259,7 @@ export function StoryViewsNRepliesModal({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
platform={platform}
|
platform={platform}
|
||||||
|
quotedMessageId={null}
|
||||||
sendCounter={0}
|
sendCounter={0}
|
||||||
skinTone={skinTone ?? null}
|
skinTone={skinTone ?? null}
|
||||||
sortedGroupMembers={sortedGroupMembers ?? null}
|
sortedGroupMembers={sortedGroupMembers ?? null}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { isValidLink } from '../types/LinkPreview';
|
||||||
|
|
||||||
export function openLinkInWebBrowser(url: string): void {
|
export function openLinkInWebBrowser(url: string): void {
|
||||||
|
if (!isValidLink(url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue