mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-50953 Post textbox cleanup (#23971)
* Remove unused code around scrollbarWidth * MM-50953 Remove unused code for popover at mentions * Add tests for messageHtmlToComponent wrapper
This commit is contained in:
parent
c4949a664d
commit
1f95a8f52b
@ -16,10 +16,8 @@ exports[`components/TextBox should match snapshot with additional, optional prop
|
|||||||
"render": [Function],
|
"render": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={true}
|
|
||||||
listComponent={[Function]}
|
listComponent={[Function]}
|
||||||
listPosition="top"
|
listPosition="top"
|
||||||
listenForMentionKeyClick={true}
|
|
||||||
onBlur={[Function]}
|
onBlur={[Function]}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
onComposition={[Function]}
|
onComposition={[Function]}
|
||||||
@ -109,7 +107,6 @@ exports[`components/TextBox should match snapshot with additional, optional prop
|
|||||||
"hideUtilities": true,
|
"hideUtilities": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={true}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="some test text"
|
message="some test text"
|
||||||
/>
|
/>
|
||||||
@ -132,9 +129,7 @@ exports[`components/TextBox should match snapshot with required props 1`] = `
|
|||||||
"render": [Function],
|
"render": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
listComponent={[Function]}
|
listComponent={[Function]}
|
||||||
listenForMentionKeyClick={false}
|
|
||||||
onBlur={[Function]}
|
onBlur={[Function]}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
onKeyDown={[Function]}
|
onKeyDown={[Function]}
|
||||||
@ -225,9 +220,7 @@ exports[`components/TextBox should throw error when new property is too long 1`]
|
|||||||
"render": [Function],
|
"render": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
listComponent={[Function]}
|
listComponent={[Function]}
|
||||||
listenForMentionKeyClick={false}
|
|
||||||
onBlur={[Function]}
|
onBlur={[Function]}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
onKeyDown={[Function]}
|
onKeyDown={[Function]}
|
||||||
@ -318,9 +311,7 @@ exports[`components/TextBox should throw error when value is too long 1`] = `
|
|||||||
"render": [Function],
|
"render": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
listComponent={[Function]}
|
listComponent={[Function]}
|
||||||
listenForMentionKeyClick={false}
|
|
||||||
onBlur={[Function]}
|
onBlur={[Function]}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
onKeyDown={[Function]}
|
onKeyDown={[Function]}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {CSSProperties, useCallback, useEffect, useRef, useState} from 'react';
|
import React, {useCallback, useEffect, useRef, useState} from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {FormattedMessage, useIntl} from 'react-intl';
|
import {FormattedMessage, useIntl} from 'react-intl';
|
||||||
import {EmoticonHappyOutlineIcon} from '@mattermost/compass-icons/components';
|
import {EmoticonHappyOutlineIcon} from '@mattermost/compass-icons/components';
|
||||||
@ -167,7 +167,6 @@ const AdvanceTextEditor = ({
|
|||||||
const editorActionsRef = useRef<HTMLDivElement>(null);
|
const editorActionsRef = useRef<HTMLDivElement>(null);
|
||||||
const editorBodyRef = useRef<HTMLDivElement>(null);
|
const editorBodyRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [scrollbarWidth, setScrollbarWidth] = useState(0);
|
|
||||||
const [renderScrollbar, setRenderScrollbar] = useState(false);
|
const [renderScrollbar, setRenderScrollbar] = useState(false);
|
||||||
const [showFormattingSpacer, setShowFormattingSpacer] = useState(shouldShowPreview);
|
const [showFormattingSpacer, setShowFormattingSpacer] = useState(shouldShowPreview);
|
||||||
const [keepEditorInFocus, setKeepEditorInFocus] = useState(false);
|
const [keepEditorInFocus, setKeepEditorInFocus] = useState(false);
|
||||||
@ -176,13 +175,7 @@ const AdvanceTextEditor = ({
|
|||||||
|
|
||||||
const handleHeightChange = useCallback((height: number, maxHeight: number) => {
|
const handleHeightChange = useCallback((height: number, maxHeight: number) => {
|
||||||
setRenderScrollbar(height > maxHeight);
|
setRenderScrollbar(height > maxHeight);
|
||||||
|
}, []);
|
||||||
window.requestAnimationFrame(() => {
|
|
||||||
if (textboxRef.current) {
|
|
||||||
setScrollbarWidth(Utils.scrollbarWidth(textboxRef.current.getInputBox()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [textboxRef]);
|
|
||||||
|
|
||||||
const handleShowFormat = useCallback(() => {
|
const handleShowFormat = useCallback(() => {
|
||||||
setShowPreview(!shouldShowPreview);
|
setShowPreview(!shouldShowPreview);
|
||||||
@ -429,11 +422,6 @@ const AdvanceTextEditor = ({
|
|||||||
'AdvancedTextEditor__attachment-disabled': !canUploadFiles,
|
'AdvancedTextEditor__attachment-disabled': !canUploadFiles,
|
||||||
scroll: renderScrollbar,
|
scroll: renderScrollbar,
|
||||||
})}
|
})}
|
||||||
style={
|
|
||||||
renderScrollbar && scrollbarWidth ? ({
|
|
||||||
'--detected-scrollbar-width': `${scrollbarWidth}px`,
|
|
||||||
} as CSSProperties) : undefined
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
id={'speak-'}
|
id={'speak-'}
|
||||||
@ -485,7 +473,6 @@ const AdvanceTextEditor = ({
|
|||||||
characterLimit={maxPostSize}
|
characterLimit={maxPostSize}
|
||||||
preview={shouldShowPreview}
|
preview={shouldShowPreview}
|
||||||
badConnection={badConnection}
|
badConnection={badConnection}
|
||||||
listenForMentionKeyClick={true}
|
|
||||||
useChannelMentions={useChannelMentions}
|
useChannelMentions={useChannelMentions}
|
||||||
rootId={postId}
|
rootId={postId}
|
||||||
onWidthChange={handleWidthChange}
|
onWidthChange={handleWidthChange}
|
||||||
|
@ -64,7 +64,6 @@ exports[`components/AtMention should match snapshot when mentioning current user
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc1/image"
|
src="/api/v4/users/abc1/image"
|
||||||
userId="abc1"
|
userId="abc1"
|
||||||
/>
|
/>
|
||||||
@ -97,7 +96,6 @@ exports[`components/AtMention should match snapshot when mentioning user 1`] = `
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc2/image"
|
src="/api/v4/users/abc2/image"
|
||||||
userId="abc2"
|
userId="abc2"
|
||||||
/>
|
/>
|
||||||
@ -130,7 +128,6 @@ exports[`components/AtMention should match snapshot when mentioning user contain
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc3/image"
|
src="/api/v4/users/abc3/image"
|
||||||
userId="abc3"
|
userId="abc3"
|
||||||
/>
|
/>
|
||||||
@ -164,7 +161,6 @@ exports[`components/AtMention should match snapshot when mentioning user contain
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc3/image"
|
src="/api/v4/users/abc3/image"
|
||||||
userId="abc3"
|
userId="abc3"
|
||||||
/>
|
/>
|
||||||
@ -197,7 +193,6 @@ exports[`components/AtMention should match snapshot when mentioning user followe
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc2/image"
|
src="/api/v4/users/abc2/image"
|
||||||
userId="abc2"
|
userId="abc2"
|
||||||
/>
|
/>
|
||||||
@ -231,7 +226,6 @@ exports[`components/AtMention should match snapshot when mentioning user with di
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc2/image"
|
src="/api/v4/users/abc2/image"
|
||||||
userId="abc2"
|
userId="abc2"
|
||||||
/>
|
/>
|
||||||
@ -264,7 +258,6 @@ exports[`components/AtMention should match snapshot when mentioning user with mi
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/abc2/image"
|
src="/api/v4/users/abc2/image"
|
||||||
userId="abc2"
|
userId="abc2"
|
||||||
/>
|
/>
|
||||||
|
@ -30,7 +30,6 @@ type Props = {
|
|||||||
hasMention?: boolean;
|
hasMention?: boolean;
|
||||||
disableHighlight?: boolean;
|
disableHighlight?: boolean;
|
||||||
disableGroupHighlight?: boolean;
|
disableGroupHighlight?: boolean;
|
||||||
isRHS?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@ -43,7 +42,6 @@ export default class AtMention extends React.PureComponent<Props, State> {
|
|||||||
buttonRef: React.RefObject<HTMLAnchorElement>;
|
buttonRef: React.RefObject<HTMLAnchorElement>;
|
||||||
|
|
||||||
static defaultProps: Partial<Props> = {
|
static defaultProps: Partial<Props> = {
|
||||||
isRHS: false,
|
|
||||||
hasMention: false,
|
hasMention: false,
|
||||||
disableHighlight: false,
|
disableHighlight: false,
|
||||||
disableGroupHighlight: false,
|
disableGroupHighlight: false,
|
||||||
@ -124,7 +122,6 @@ export default class AtMention extends React.PureComponent<Props, State> {
|
|||||||
className='user-profile-popover'
|
className='user-profile-popover'
|
||||||
userId={user.id}
|
userId={user.id}
|
||||||
src={Client4.getProfilePictureUrl(user.id, user.last_picture_update)}
|
src={Client4.getProfilePictureUrl(user.id, user.last_picture_update)}
|
||||||
isRHS={this.props.isRHS}
|
|
||||||
hasMention={this.props.hasMention}
|
hasMention={this.props.hasMention}
|
||||||
hide={this.hideOverlay}
|
hide={this.hideOverlay}
|
||||||
channelId={this.props.channelId}
|
channelId={this.props.channelId}
|
||||||
|
@ -27,10 +27,6 @@ type Props = {
|
|||||||
*/
|
*/
|
||||||
group: Group;
|
group: Group;
|
||||||
|
|
||||||
/**
|
|
||||||
* Props to be passed through from AtMention to ProfilePopover
|
|
||||||
*/
|
|
||||||
isRHS?: boolean;
|
|
||||||
channelId?: string;
|
channelId?: string;
|
||||||
hasMention?: boolean;
|
hasMention?: boolean;
|
||||||
}
|
}
|
||||||
@ -38,7 +34,6 @@ type Props = {
|
|||||||
const AtMentionGroup = (props: Props) => {
|
const AtMentionGroup = (props: Props) => {
|
||||||
const {
|
const {
|
||||||
group,
|
group,
|
||||||
isRHS,
|
|
||||||
channelId,
|
channelId,
|
||||||
hasMention,
|
hasMention,
|
||||||
} = props;
|
} = props;
|
||||||
@ -137,7 +132,6 @@ const AtMentionGroup = (props: Props) => {
|
|||||||
className='user-profile-popover'
|
className='user-profile-popover'
|
||||||
userId={showUser.id}
|
userId={showUser.id}
|
||||||
src={Client4.getProfilePictureUrl(showUser.id, showUser.last_picture_update)}
|
src={Client4.getProfilePictureUrl(showUser.id, showUser.last_picture_update)}
|
||||||
isRHS={isRHS}
|
|
||||||
channelId={channelId}
|
channelId={channelId}
|
||||||
hasMention={hasMention}
|
hasMention={hasMention}
|
||||||
hide={hideUserOverlay}
|
hide={hideUserOverlay}
|
||||||
|
@ -94,7 +94,6 @@ const AboutAreaDM = ({channel, dmUser, actions}: Props) => {
|
|||||||
src={Client4.getProfilePictureUrl(dmUser.user.id, dmUser.user.last_picture_update)}
|
src={Client4.getProfilePictureUrl(dmUser.user.id, dmUser.user.last_picture_update)}
|
||||||
isBot={dmUser.user.is_bot}
|
isBot={dmUser.user.is_bot}
|
||||||
status={dmUser.status ? dmUser.status : undefined}
|
status={dmUser.status ? dmUser.status : undefined}
|
||||||
isRHS={true}
|
|
||||||
username={dmUser.display_name}
|
username={dmUser.display_name}
|
||||||
userId={dmUser.user.id}
|
userId={dmUser.user.id}
|
||||||
channelId={channel.id}
|
channelId={channel.id}
|
||||||
|
@ -235,7 +235,6 @@ exports[`components/channel_invite_modal should match snapshot for channel_invit
|
|||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="md"
|
size="md"
|
||||||
src="/api/v4/users/user-1/image"
|
src="/api/v4/users/user-1/image"
|
||||||
|
@ -144,7 +144,6 @@ const Member = ({className, channel, member, index, totalUsers, editing, actions
|
|||||||
userId={member.user.id}
|
userId={member.user.id}
|
||||||
src={profileSrc}
|
src={profileSrc}
|
||||||
hide={hideProfilePopover}
|
hide={hideProfilePopover}
|
||||||
isRHS={true}
|
|
||||||
hideStatus={member.user.is_bot}
|
hideStatus={member.user.is_bot}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -152,7 +151,6 @@ const Member = ({className, channel, member, index, totalUsers, editing, actions
|
|||||||
<span className='ProfileSpan'>
|
<span className='ProfileSpan'>
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
isRHS={true}
|
|
||||||
popoverPlacement='left'
|
popoverPlacement='left'
|
||||||
size='sm'
|
size='sm'
|
||||||
status={member.status}
|
status={member.status}
|
||||||
|
@ -33,7 +33,6 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
channelId="channel_id"
|
channelId="channel_id"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="md"
|
size="md"
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
@ -50,7 +49,6 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -110,7 +108,6 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
"wrapRichTextChunksInFragment": undefined,
|
"wrapRichTextChunksInFragment": undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -244,7 +241,6 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
enableFormatting={true}
|
enableFormatting={true}
|
||||||
hasImageProxy={false}
|
hasImageProxy={false}
|
||||||
imagesMetadata={Object {}}
|
imagesMetadata={Object {}}
|
||||||
isRHS={false}
|
|
||||||
managedResourcePaths={Array []}
|
managedResourcePaths={Array []}
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="message"
|
message="message"
|
||||||
@ -314,7 +310,6 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
channelId="channel_id"
|
channelId="channel_id"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="md"
|
size="md"
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
@ -331,7 +326,6 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -391,7 +385,6 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
"wrapRichTextChunksInFragment": undefined,
|
"wrapRichTextChunksInFragment": undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -525,7 +518,6 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
enableFormatting={true}
|
enableFormatting={true}
|
||||||
hasImageProxy={false}
|
hasImageProxy={false}
|
||||||
imagesMetadata={Object {}}
|
imagesMetadata={Object {}}
|
||||||
isRHS={false}
|
|
||||||
managedResourcePaths={Array []}
|
managedResourcePaths={Array []}
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="message"
|
message="message"
|
||||||
@ -601,7 +593,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
channelId="channel_id"
|
channelId="channel_id"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="md"
|
size="md"
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
@ -618,7 +609,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -678,7 +668,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
"wrapRichTextChunksInFragment": undefined,
|
"wrapRichTextChunksInFragment": undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -874,7 +863,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
enableFormatting={true}
|
enableFormatting={true}
|
||||||
hasImageProxy={false}
|
hasImageProxy={false}
|
||||||
imagesMetadata={Object {}}
|
imagesMetadata={Object {}}
|
||||||
isRHS={false}
|
|
||||||
managedResourcePaths={Array []}
|
managedResourcePaths={Array []}
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="message"
|
message="message"
|
||||||
@ -950,7 +938,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
channelId="channel_id"
|
channelId="channel_id"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="md"
|
size="md"
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
@ -967,7 +954,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
className="user-profile-popover"
|
className="user-profile-popover"
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -1027,7 +1013,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
"wrapRichTextChunksInFragment": undefined,
|
"wrapRichTextChunksInFragment": undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
src="/api/v4/users/user_id/image?_=0"
|
src="/api/v4/users/user_id/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
/>
|
/>
|
||||||
@ -1302,7 +1287,6 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
enableFormatting={true}
|
enableFormatting={true}
|
||||||
hasImageProxy={false}
|
hasImageProxy={false}
|
||||||
imagesMetadata={Object {}}
|
imagesMetadata={Object {}}
|
||||||
isRHS={false}
|
|
||||||
managedResourcePaths={Array []}
|
managedResourcePaths={Array []}
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="message"
|
message="message"
|
||||||
|
@ -29,11 +29,6 @@ type Props = {
|
|||||||
*/
|
*/
|
||||||
enableFormatting?: boolean;
|
enableFormatting?: boolean;
|
||||||
|
|
||||||
/*
|
|
||||||
* Whether or not this text is part of the RHS
|
|
||||||
*/
|
|
||||||
isRHS?: boolean;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An array of paths on the server that are managed by another server
|
* An array of paths on the server that are managed by another server
|
||||||
*/
|
*/
|
||||||
@ -126,7 +121,6 @@ type Props = {
|
|||||||
export default class Markdown extends React.PureComponent<Props> {
|
export default class Markdown extends React.PureComponent<Props> {
|
||||||
static defaultProps: Partial<Props> = {
|
static defaultProps: Partial<Props> = {
|
||||||
options: {},
|
options: {},
|
||||||
isRHS: false,
|
|
||||||
proxyImages: true,
|
proxyImages: true,
|
||||||
imagesMetadata: {},
|
imagesMetadata: {},
|
||||||
postId: '', // Needed to avoid proptypes console errors for cases like channel header, which doesn't have a proper value
|
postId: '', // Needed to avoid proptypes console errors for cases like channel header, which doesn't have a proper value
|
||||||
@ -163,7 +157,7 @@ export default class Markdown extends React.PureComponent<Props> {
|
|||||||
|
|
||||||
const htmlFormattedText = formatText(message, options, this.props.emojiMap);
|
const htmlFormattedText = formatText(message, options, this.props.emojiMap);
|
||||||
|
|
||||||
return messageHtmlToComponent(htmlFormattedText, this.props.isRHS, {
|
return messageHtmlToComponent(htmlFormattedText, {
|
||||||
imageProps: this.props.imageProps,
|
imageProps: this.props.imageProps,
|
||||||
imagesMetadata: this.props.imagesMetadata,
|
imagesMetadata: this.props.imagesMetadata,
|
||||||
hasPluginTooltips: this.props.hasPluginTooltips,
|
hasPluginTooltips: this.props.hasPluginTooltips,
|
||||||
|
@ -16,7 +16,6 @@ import PostMarkdown from './post_markdown';
|
|||||||
describe('components/PostMarkdown', () => {
|
describe('components/PostMarkdown', () => {
|
||||||
const baseProps = {
|
const baseProps = {
|
||||||
imageProps: {},
|
imageProps: {},
|
||||||
isRHS: false,
|
|
||||||
message: 'message',
|
message: 'message',
|
||||||
post: TestHelper.getPostMock(),
|
post: TestHelper.getPostMock(),
|
||||||
mentionKeys: [{key: 'a'}, {key: 'b'}, {key: 'c'}],
|
mentionKeys: [{key: 'a'}, {key: 'b'}, {key: 'c'}],
|
||||||
|
@ -24,11 +24,6 @@ type Props = {
|
|||||||
*/
|
*/
|
||||||
imageProps?: Record<string, any>;
|
imageProps?: Record<string, any>;
|
||||||
|
|
||||||
/*
|
|
||||||
* Whether or not this text is part of the RHS
|
|
||||||
*/
|
|
||||||
isRHS?: boolean;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The post text to be rendered
|
* The post text to be rendered
|
||||||
*/
|
*/
|
||||||
@ -72,7 +67,6 @@ type Props = {
|
|||||||
|
|
||||||
export default class PostMarkdown extends React.PureComponent<Props> {
|
export default class PostMarkdown extends React.PureComponent<Props> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
isRHS: false,
|
|
||||||
pluginHooks: [],
|
pluginHooks: [],
|
||||||
options: {},
|
options: {},
|
||||||
showPostEditedIndicator: true,
|
showPostEditedIndicator: true,
|
||||||
@ -135,7 +129,6 @@ export default class PostMarkdown extends React.PureComponent<Props> {
|
|||||||
return (
|
return (
|
||||||
<Markdown
|
<Markdown
|
||||||
imageProps={this.props.imageProps}
|
imageProps={this.props.imageProps}
|
||||||
isRHS={this.props.isRHS}
|
|
||||||
message={message}
|
message={message}
|
||||||
proxyImages={proxyImages}
|
proxyImages={proxyImages}
|
||||||
mentionKeys={mentionKeys}
|
mentionKeys={mentionKeys}
|
||||||
|
@ -19,7 +19,6 @@ type Props = {
|
|||||||
enablePostIconOverride: boolean;
|
enablePostIconOverride: boolean;
|
||||||
hasImageProxy: boolean;
|
hasImageProxy: boolean;
|
||||||
isBusy?: boolean;
|
isBusy?: boolean;
|
||||||
isRHS?: boolean;
|
|
||||||
post: Post;
|
post: Post;
|
||||||
status?: string;
|
status?: string;
|
||||||
user: UserProfile;
|
user: UserProfile;
|
||||||
@ -83,7 +82,6 @@ export default class PostProfilePicture extends React.PureComponent<Props> {
|
|||||||
availabilityStatusOnPosts,
|
availabilityStatusOnPosts,
|
||||||
compactDisplay,
|
compactDisplay,
|
||||||
isBusy,
|
isBusy,
|
||||||
isRHS,
|
|
||||||
post,
|
post,
|
||||||
user,
|
user,
|
||||||
isBot,
|
isBot,
|
||||||
@ -110,7 +108,6 @@ export default class PostProfilePicture extends React.PureComponent<Props> {
|
|||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
hasMention={hasMention}
|
hasMention={hasMention}
|
||||||
isBusy={isBusy}
|
isBusy={isBusy}
|
||||||
isRHS={isRHS}
|
|
||||||
size='md'
|
size='md'
|
||||||
src={src}
|
src={src}
|
||||||
profileSrc={profileSrc}
|
profileSrc={profileSrc}
|
||||||
|
@ -19,7 +19,6 @@ exports[`components/post_view/PostAttachment should match snapshot 1`] = `
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="post message"
|
message="post message"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
@ -58,7 +57,6 @@ exports[`components/post_view/PostAttachment should match snapshot, on Show Less
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="post message"
|
message="post message"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
@ -97,7 +95,6 @@ exports[`components/post_view/PostAttachment should match snapshot, on Show More
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="post message"
|
message="post message"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
@ -154,7 +151,6 @@ exports[`components/post_view/PostAttachment should match snapshot, on edited po
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="post message"
|
message="post message"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
@ -194,7 +190,6 @@ exports[`components/post_view/PostAttachment should match snapshot, on ephemeral
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="post message"
|
message="post message"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
|
@ -154,7 +154,6 @@ export default class PostMessageView extends React.PureComponent<Props, State> {
|
|||||||
<PostMarkdown
|
<PostMarkdown
|
||||||
message={message}
|
message={message}
|
||||||
imageProps={this.imageProps}
|
imageProps={this.imageProps}
|
||||||
isRHS={isRHS}
|
|
||||||
options={options}
|
options={options}
|
||||||
post={post}
|
post={post}
|
||||||
channelId={post.channel_id}
|
channelId={post.channel_id}
|
||||||
|
@ -49,7 +49,6 @@ exports[`components/ProfilePicture should match snapshot, profile and src, defau
|
|||||||
hasMention={false}
|
hasMention={false}
|
||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
isBusy={true}
|
isBusy={true}
|
||||||
isRHS={false}
|
|
||||||
src="http://example.com/image.png"
|
src="http://example.com/image.png"
|
||||||
userId="uid"
|
userId="uid"
|
||||||
/>
|
/>
|
||||||
|
@ -42,7 +42,6 @@ describe('components/ProfilePicture', () => {
|
|||||||
const props: Props = {
|
const props: Props = {
|
||||||
...baseProps,
|
...baseProps,
|
||||||
size: 'xl',
|
size: 'xl',
|
||||||
isRHS: true,
|
|
||||||
hasMention: true,
|
hasMention: true,
|
||||||
};
|
};
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
@ -69,7 +68,6 @@ describe('components/ProfilePicture', () => {
|
|||||||
...baseProps,
|
...baseProps,
|
||||||
username: 'username',
|
username: 'username',
|
||||||
size: 'xs',
|
size: 'xs',
|
||||||
isRHS: true,
|
|
||||||
hasMention: true,
|
hasMention: true,
|
||||||
};
|
};
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
|
@ -20,7 +20,6 @@ type Props = {
|
|||||||
hasMention?: boolean;
|
hasMention?: boolean;
|
||||||
isBusy?: boolean;
|
isBusy?: boolean;
|
||||||
isEmoji?: boolean;
|
isEmoji?: boolean;
|
||||||
isRHS?: boolean;
|
|
||||||
profileSrc?: string;
|
profileSrc?: string;
|
||||||
size?: ComponentProps<typeof Avatar>['size'];
|
size?: ComponentProps<typeof Avatar>['size'];
|
||||||
src: string;
|
src: string;
|
||||||
@ -42,7 +41,6 @@ type Props = {
|
|||||||
export default class ProfilePicture extends React.PureComponent<Props> {
|
export default class ProfilePicture extends React.PureComponent<Props> {
|
||||||
public static defaultProps = {
|
public static defaultProps = {
|
||||||
size: 'md',
|
size: 'md',
|
||||||
isRHS: false,
|
|
||||||
isEmoji: false,
|
isEmoji: false,
|
||||||
hasMention: false,
|
hasMention: false,
|
||||||
wrapperClass: '',
|
wrapperClass: '',
|
||||||
@ -81,7 +79,6 @@ export default class ProfilePicture extends React.PureComponent<Props> {
|
|||||||
src={profileSrc}
|
src={profileSrc}
|
||||||
isBusy={this.props.isBusy}
|
isBusy={this.props.isBusy}
|
||||||
hide={this.hideProfilePopover}
|
hide={this.hideProfilePopover}
|
||||||
isRHS={this.props.isRHS}
|
|
||||||
channelId={this.props.channelId}
|
channelId={this.props.channelId}
|
||||||
hasMention={this.props.hasMention}
|
hasMention={this.props.hasMention}
|
||||||
overwriteIcon={this.props.overwriteIcon}
|
overwriteIcon={this.props.overwriteIcon}
|
||||||
|
@ -3566,7 +3566,6 @@ exports[`components/ProfilePopover should show the start call button when isCall
|
|||||||
isCustomStatusExpired={false}
|
isCustomStatusExpired={false}
|
||||||
isInCurrentTeam={true}
|
isInCurrentTeam={true}
|
||||||
isMobileView={false}
|
isMobileView={false}
|
||||||
isRHS={false}
|
|
||||||
isTeamAdmin={false}
|
isTeamAdmin={false}
|
||||||
lastActivityTimestamp={1632146562846}
|
lastActivityTimestamp={1632146562846}
|
||||||
src="src"
|
src="src"
|
||||||
|
@ -94,11 +94,6 @@ export interface ProfilePopoverProps extends Omit<React.ComponentProps<typeof Po
|
|||||||
*/
|
*/
|
||||||
returnFocus?: () => void;
|
returnFocus?: () => void;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to true if the popover was opened from the right-hand
|
|
||||||
* sidebar (comment thread, search results, etc.)
|
|
||||||
*/
|
|
||||||
isRHS?: boolean;
|
|
||||||
isBusy?: boolean;
|
isBusy?: boolean;
|
||||||
isMobileView: boolean;
|
isMobileView: boolean;
|
||||||
|
|
||||||
@ -211,7 +206,6 @@ class ProfilePopover extends React.PureComponent<ProfilePopoverProps, ProfilePop
|
|||||||
return 'ProfilePopover';
|
return 'ProfilePopover';
|
||||||
}
|
}
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
isRHS: false,
|
|
||||||
hasMention: false,
|
hasMention: false,
|
||||||
status: UserStatuses.OFFLINE,
|
status: UserStatuses.OFFLINE,
|
||||||
customStatus: null,
|
customStatus: null,
|
||||||
@ -430,7 +424,7 @@ class ProfilePopover extends React.PureComponent<ProfilePopoverProps, ProfilePop
|
|||||||
}
|
}
|
||||||
|
|
||||||
const keysToBeRemoved: Array<keyof ProfilePopoverProps> = ['user', 'userId', 'channelId', 'src', 'status', 'hideStatus', 'isBusy',
|
const keysToBeRemoved: Array<keyof ProfilePopoverProps> = ['user', 'userId', 'channelId', 'src', 'status', 'hideStatus', 'isBusy',
|
||||||
'hide', 'isRHS', 'hasMention', 'enableTimezone', 'currentUserId', 'currentTeamId', 'teamUrl', 'actions', 'isTeamAdmin',
|
'hide', 'hasMention', 'enableTimezone', 'currentUserId', 'currentTeamId', 'teamUrl', 'actions', 'isTeamAdmin',
|
||||||
'isChannelAdmin', 'canManageAnyChannelMembersInCurrentTeam', 'intl'];
|
'isChannelAdmin', 'canManageAnyChannelMembersInCurrentTeam', 'intl'];
|
||||||
const popoverProps: React.ComponentProps<typeof Popover> = Utils.deleteKeysFromObject({...this.props},
|
const popoverProps: React.ComponentProps<typeof Popover> = Utils.deleteKeysFromObject({...this.props},
|
||||||
keysToBeRemoved);
|
keysToBeRemoved);
|
||||||
|
@ -26,7 +26,6 @@ exports[`components/sidebar/sidebar_channel/sidebar_direct_channel should match
|
|||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
newStatusIcon={true}
|
newStatusIcon={true}
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="xs"
|
size="xs"
|
||||||
@ -67,7 +66,6 @@ exports[`components/sidebar/sidebar_channel/sidebar_direct_channel should match
|
|||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
newStatusIcon={true}
|
newStatusIcon={true}
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="xs"
|
size="xs"
|
||||||
@ -109,7 +107,6 @@ exports[`components/sidebar/sidebar_channel/sidebar_direct_channel should match
|
|||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
hasMention={false}
|
hasMention={false}
|
||||||
isEmoji={false}
|
isEmoji={false}
|
||||||
isRHS={false}
|
|
||||||
newStatusIcon={true}
|
newStatusIcon={true}
|
||||||
popoverPlacement="right"
|
popoverPlacement="right"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
|
||||||
|
|
||||||
import QuickInput from 'components/quick_input';
|
import QuickInput from 'components/quick_input';
|
||||||
import Constants, {A11yCustomEventTypes} from 'utils/constants';
|
import Constants, {A11yCustomEventTypes} from 'utils/constants';
|
||||||
import * as Keyboard from 'utils/keyboard';
|
import * as Keyboard from 'utils/keyboard';
|
||||||
@ -104,11 +102,6 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
*/
|
*/
|
||||||
onItemSelected: PropTypes.func,
|
onItemSelected: PropTypes.func,
|
||||||
|
|
||||||
/**
|
|
||||||
* Flags if the suggestion_box is for the RHS (Reply).
|
|
||||||
*/
|
|
||||||
isRHS: PropTypes.bool,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of characters required to show the suggestion list, defaults to 1
|
* The number of characters required to show the suggestion list, defaults to 1
|
||||||
*/
|
*/
|
||||||
@ -140,11 +133,6 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
*/
|
*/
|
||||||
contextId: PropTypes.string,
|
contextId: PropTypes.string,
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, listen for clicks on a mention and populate the input with said mention, defaults to false
|
|
||||||
*/
|
|
||||||
listenForMentionKeyClick: PropTypes.bool,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows parent to access received suggestions
|
* Allows parent to access received suggestions
|
||||||
*/
|
*/
|
||||||
@ -172,12 +160,10 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
renderNoResults: false,
|
renderNoResults: false,
|
||||||
shouldSearchCompleteText: false,
|
shouldSearchCompleteText: false,
|
||||||
completeOnTab: true,
|
completeOnTab: true,
|
||||||
isRHS: false,
|
|
||||||
requiredCharacters: 1,
|
requiredCharacters: 1,
|
||||||
openOnFocus: false,
|
openOnFocus: false,
|
||||||
openWhenEmpty: false,
|
openWhenEmpty: false,
|
||||||
replaceAllInputOnSelect: false,
|
replaceAllInputOnSelect: false,
|
||||||
listenForMentionKeyClick: false,
|
|
||||||
forceSuggestionsWhenBlur: false,
|
forceSuggestionsWhenBlur: false,
|
||||||
alignWithTextbox: false,
|
alignWithTextbox: false,
|
||||||
};
|
};
|
||||||
@ -221,16 +207,9 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (this.props.listenForMentionKeyClick) {
|
|
||||||
EventEmitter.addListener('mention_key_click', this.handleMentionKeyClick);
|
|
||||||
}
|
|
||||||
this.handlePretextChanged(this.pretext);
|
this.handlePretextChanged(this.pretext);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
EventEmitter.removeListener('mention_key_click', this.handleMentionKeyClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const {value} = this.props;
|
const {value} = this.props;
|
||||||
|
|
||||||
@ -248,21 +227,6 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMentionKeyClick = (mentionKey, isRHS) => {
|
|
||||||
if (this.props.isRHS !== isRHS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let insertText = '@' + mentionKey;
|
|
||||||
|
|
||||||
// if the current text does not end with a whitespace, then insert a space
|
|
||||||
if (this.props.value && (/[^\s]$/).test(this.props.value)) {
|
|
||||||
insertText = ' ' + insertText;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.addTextAtCaret(insertText, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
getTextbox = () => {
|
getTextbox = () => {
|
||||||
if (!this.inputRef.current) {
|
if (!this.inputRef.current) {
|
||||||
return null;
|
return null;
|
||||||
@ -792,7 +756,6 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
Reflect.deleteProperty(props, 'onComposition');
|
Reflect.deleteProperty(props, 'onComposition');
|
||||||
Reflect.deleteProperty(props, 'onItemSelected');
|
Reflect.deleteProperty(props, 'onItemSelected');
|
||||||
Reflect.deleteProperty(props, 'completeOnTab');
|
Reflect.deleteProperty(props, 'completeOnTab');
|
||||||
Reflect.deleteProperty(props, 'isRHS');
|
|
||||||
Reflect.deleteProperty(props, 'requiredCharacters');
|
Reflect.deleteProperty(props, 'requiredCharacters');
|
||||||
Reflect.deleteProperty(props, 'openOnFocus');
|
Reflect.deleteProperty(props, 'openOnFocus');
|
||||||
Reflect.deleteProperty(props, 'openWhenEmpty');
|
Reflect.deleteProperty(props, 'openWhenEmpty');
|
||||||
@ -802,7 +765,6 @@ export default class SuggestionBox extends React.PureComponent {
|
|||||||
Reflect.deleteProperty(props, 'replaceAllInputOnSelect');
|
Reflect.deleteProperty(props, 'replaceAllInputOnSelect');
|
||||||
Reflect.deleteProperty(props, 'renderDividers');
|
Reflect.deleteProperty(props, 'renderDividers');
|
||||||
Reflect.deleteProperty(props, 'contextId');
|
Reflect.deleteProperty(props, 'contextId');
|
||||||
Reflect.deleteProperty(props, 'listenForMentionKeyClick');
|
|
||||||
Reflect.deleteProperty(props, 'forceSuggestionsWhenBlur');
|
Reflect.deleteProperty(props, 'forceSuggestionsWhenBlur');
|
||||||
Reflect.deleteProperty(props, 'onSuggestionsReceived');
|
Reflect.deleteProperty(props, 'onSuggestionsReceived');
|
||||||
Reflect.deleteProperty(props, 'actions');
|
Reflect.deleteProperty(props, 'actions');
|
||||||
|
@ -188,7 +188,7 @@ export default class TermsOfService extends React.PureComponent<TermsOfServicePr
|
|||||||
className='medium-center'
|
className='medium-center'
|
||||||
data-testid='termsOfService'
|
data-testid='termsOfService'
|
||||||
>
|
>
|
||||||
{messageHtmlToComponent(this.formattedText(this.state.customTermsOfServiceText), false, {mentions: false})}
|
{messageHtmlToComponent(this.formattedText(this.state.customTermsOfServiceText), {mentions: false})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='terms-of-service__footer medium-center'>
|
<div className='terms-of-service__footer medium-center'>
|
||||||
|
@ -71,10 +71,8 @@ describe('components/TextBox', () => {
|
|||||||
handlePostError={() => {}}
|
handlePostError={() => {}}
|
||||||
suggestionListPosition='top'
|
suggestionListPosition='top'
|
||||||
emojiEnabled={true}
|
emojiEnabled={true}
|
||||||
isRHS={true}
|
|
||||||
disabled={true}
|
disabled={true}
|
||||||
badConnection={true}
|
badConnection={true}
|
||||||
listenForMentionKeyClick={true}
|
|
||||||
preview={true}
|
preview={true}
|
||||||
openWhenEmpty={true}
|
openWhenEmpty={true}
|
||||||
/>,
|
/>,
|
||||||
|
@ -51,11 +51,9 @@ export type Props = {
|
|||||||
suggestionListPosition?: React.ComponentProps<typeof SuggestionList>['position'];
|
suggestionListPosition?: React.ComponentProps<typeof SuggestionList>['position'];
|
||||||
alignWithTextbox?: boolean;
|
alignWithTextbox?: boolean;
|
||||||
emojiEnabled?: boolean;
|
emojiEnabled?: boolean;
|
||||||
isRHS?: boolean;
|
|
||||||
characterLimit: number;
|
characterLimit: number;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
badConnection?: boolean;
|
badConnection?: boolean;
|
||||||
listenForMentionKeyClick?: boolean;
|
|
||||||
currentUserId: string;
|
currentUserId: string;
|
||||||
currentTeamId: string;
|
currentTeamId: string;
|
||||||
preview?: boolean;
|
preview?: boolean;
|
||||||
@ -84,8 +82,6 @@ export default class Textbox extends React.PureComponent<Props> {
|
|||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
supportsCommands: true,
|
supportsCommands: true,
|
||||||
isRHS: false,
|
|
||||||
listenForMentionKeyClick: false,
|
|
||||||
inputComponent: AutosizeTextarea,
|
inputComponent: AutosizeTextarea,
|
||||||
suggestionList: SuggestionList,
|
suggestionList: SuggestionList,
|
||||||
};
|
};
|
||||||
@ -292,7 +288,6 @@ export default class Textbox extends React.PureComponent<Props> {
|
|||||||
onBlur={this.handleBlur}
|
onBlur={this.handleBlur}
|
||||||
>
|
>
|
||||||
<PostMarkdown
|
<PostMarkdown
|
||||||
isRHS={this.props.isRHS}
|
|
||||||
message={this.props.value}
|
message={this.props.value}
|
||||||
mentionKeys={[]}
|
mentionKeys={[]}
|
||||||
channelId={this.props.channelId}
|
channelId={this.props.channelId}
|
||||||
@ -332,10 +327,8 @@ export default class Textbox extends React.PureComponent<Props> {
|
|||||||
channelId={this.props.channelId}
|
channelId={this.props.channelId}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
renderDividers={ALL}
|
renderDividers={ALL}
|
||||||
isRHS={this.props.isRHS}
|
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
contextId={this.props.channelId}
|
contextId={this.props.channelId}
|
||||||
listenForMentionKeyClick={this.props.listenForMentionKeyClick}
|
|
||||||
openWhenEmpty={this.props.openWhenEmpty}
|
openWhenEmpty={this.props.openWhenEmpty}
|
||||||
alignWithTextbox={this.props.alignWithTextbox}
|
alignWithTextbox={this.props.alignWithTextbox}
|
||||||
/>
|
/>
|
||||||
|
@ -11,7 +11,6 @@ exports[`components/UserProfile should match snapshot 1`] = `
|
|||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
hideStatus={false}
|
hideStatus={false}
|
||||||
isBusy={false}
|
isBusy={false}
|
||||||
isRHS={false}
|
|
||||||
overwriteName=""
|
overwriteName=""
|
||||||
src="/api/v4/users/undefined/image?_=0"
|
src="/api/v4/users/undefined/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
@ -46,7 +45,6 @@ exports[`components/UserProfile should match snapshot, when displayUsername is e
|
|||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
hideStatus={false}
|
hideStatus={false}
|
||||||
isBusy={false}
|
isBusy={false}
|
||||||
isRHS={false}
|
|
||||||
overwriteName=""
|
overwriteName=""
|
||||||
src="/api/v4/users/undefined/image?_=0"
|
src="/api/v4/users/undefined/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
@ -89,7 +87,6 @@ exports[`components/UserProfile should match snapshot, when user is shared 1`] =
|
|||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
hideStatus={false}
|
hideStatus={false}
|
||||||
isBusy={false}
|
isBusy={false}
|
||||||
isRHS={false}
|
|
||||||
overwriteName=""
|
overwriteName=""
|
||||||
src="/api/v4/users/undefined/image?_=0"
|
src="/api/v4/users/undefined/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
@ -128,7 +125,6 @@ exports[`components/UserProfile should match snapshot, with colorization 1`] = `
|
|||||||
hide={[Function]}
|
hide={[Function]}
|
||||||
hideStatus={false}
|
hideStatus={false}
|
||||||
isBusy={false}
|
isBusy={false}
|
||||||
isRHS={false}
|
|
||||||
overwriteName=""
|
overwriteName=""
|
||||||
src="/api/v4/users/undefined/image?_=0"
|
src="/api/v4/users/undefined/image?_=0"
|
||||||
userId="user_id"
|
userId="user_id"
|
||||||
|
@ -145,7 +145,6 @@ export default class UserProfile extends PureComponent<UserProfileProps> {
|
|||||||
isBusy={isBusy}
|
isBusy={isBusy}
|
||||||
hide={this.hideProfilePopover}
|
hide={this.hideProfilePopover}
|
||||||
hideStatus={hideStatus}
|
hideStatus={hideStatus}
|
||||||
isRHS={isRHS}
|
|
||||||
hasMention={hasMention}
|
hasMention={hasMention}
|
||||||
overwriteName={overwriteName}
|
overwriteName={overwriteName}
|
||||||
overwriteIcon={overwriteIcon}
|
overwriteIcon={overwriteIcon}
|
||||||
|
@ -45,7 +45,22 @@ window.Luxon = require('luxon');
|
|||||||
window.StyledComponents = require('styled-components');
|
window.StyledComponents = require('styled-components');
|
||||||
|
|
||||||
// Functions exposed on window for plugins to use.
|
// Functions exposed on window for plugins to use.
|
||||||
window.PostUtils = {formatText, messageHtmlToComponent};
|
window.PostUtils = {
|
||||||
|
formatText,
|
||||||
|
messageHtmlToComponent: (html, ...otherArgs) => {
|
||||||
|
// Previously, this function took an extra isRHS argument as the second parameter. For backwards compatibility,
|
||||||
|
// support calling this as either messageHtmlToComponent(html, options) or messageHtmlToComponent(html, isRhs, options)
|
||||||
|
|
||||||
|
let options;
|
||||||
|
if (otherArgs.length === 2) {
|
||||||
|
options = otherArgs[1];
|
||||||
|
} else if (otherArgs.length === 1 && typeof otherArgs[0] === 'object') {
|
||||||
|
options = otherArgs[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return messageHtmlToComponent(html, options);
|
||||||
|
},
|
||||||
|
};
|
||||||
window.openInteractiveDialog = openInteractiveDialog;
|
window.openInteractiveDialog = openInteractiveDialog;
|
||||||
window.useNotifyAdmin = useNotifyAdmin;
|
window.useNotifyAdmin = useNotifyAdmin;
|
||||||
window.WebappUtils = {
|
window.WebappUtils = {
|
||||||
|
38
webapp/channels/src/plugins/export.test.js
Normal file
38
webapp/channels/src/plugins/export.test.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
import messageHtmlToComponent from 'utils/message_html_to_component';
|
||||||
|
|
||||||
|
import './export';
|
||||||
|
|
||||||
|
jest.mock('utils/message_html_to_component');
|
||||||
|
|
||||||
|
describe('messageHtmlToComponent wrapper', () => {
|
||||||
|
const message = 'test';
|
||||||
|
const options = {emoji: true, images: false};
|
||||||
|
const isRHS = false;
|
||||||
|
|
||||||
|
test('should call messageHtmlToComponent properly with only message', () => {
|
||||||
|
window.PostUtils.messageHtmlToComponent(message);
|
||||||
|
|
||||||
|
expect(messageHtmlToComponent).toHaveBeenCalledWith(message, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should call messageHtmlToComponent properly with message and options', () => {
|
||||||
|
window.PostUtils.messageHtmlToComponent(message, options);
|
||||||
|
|
||||||
|
expect(messageHtmlToComponent).toHaveBeenCalledWith(message, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should call messageHtmlToComponent properly with only message when deprecated isRHS parameter is passed', () => {
|
||||||
|
window.PostUtils.messageHtmlToComponent(message, isRHS);
|
||||||
|
|
||||||
|
expect(messageHtmlToComponent).toHaveBeenCalledWith(message, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should call messageHtmlToComponent properly with message and options when deprecated isRHS parameter is passed', () => {
|
||||||
|
window.PostUtils.messageHtmlToComponent(message, isRHS, options);
|
||||||
|
|
||||||
|
expect(messageHtmlToComponent).toHaveBeenCalledWith(message, options);
|
||||||
|
});
|
||||||
|
});
|
@ -84,7 +84,6 @@ exports[`plugins/PostMessageView should match snapshot with no extended post typ
|
|||||||
"onImageLoaded": [Function],
|
"onImageLoaded": [Function],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRHS={false}
|
|
||||||
mentionKeys={Array []}
|
mentionKeys={Array []}
|
||||||
message="this is some text"
|
message="this is some text"
|
||||||
options={Object {}}
|
options={Object {}}
|
||||||
|
@ -12,7 +12,6 @@ exports[`messageHtmlToComponent At mention 1`] = `
|
|||||||
disableGroupHighlight={false}
|
disableGroupHighlight={false}
|
||||||
disableHighlight={false}
|
disableHighlight={false}
|
||||||
hasMention={true}
|
hasMention={true}
|
||||||
isRHS={false}
|
|
||||||
mentionName="joram"
|
mentionName="joram"
|
||||||
>
|
>
|
||||||
@joram
|
@joram
|
||||||
@ -31,7 +30,6 @@ exports[`messageHtmlToComponent At mention 2`] = `
|
|||||||
disableGroupHighlight={false}
|
disableGroupHighlight={false}
|
||||||
disableHighlight={true}
|
disableHighlight={true}
|
||||||
hasMention={true}
|
hasMention={true}
|
||||||
isRHS={false}
|
|
||||||
mentionName="joram"
|
mentionName="joram"
|
||||||
>
|
>
|
||||||
@joram
|
@joram
|
||||||
@ -49,7 +47,6 @@ exports[`messageHtmlToComponent At mention with group highlight disabled 1`] = `
|
|||||||
disableGroupHighlight={false}
|
disableGroupHighlight={false}
|
||||||
disableHighlight={false}
|
disableHighlight={false}
|
||||||
hasMention={true}
|
hasMention={true}
|
||||||
isRHS={false}
|
|
||||||
mentionName="developers"
|
mentionName="developers"
|
||||||
>
|
>
|
||||||
@developers
|
@developers
|
||||||
@ -67,7 +64,6 @@ exports[`messageHtmlToComponent At mention with group highlight disabled 2`] = `
|
|||||||
disableGroupHighlight={true}
|
disableGroupHighlight={true}
|
||||||
disableHighlight={false}
|
disableHighlight={false}
|
||||||
hasMention={true}
|
hasMention={true}
|
||||||
isRHS={false}
|
|
||||||
mentionName="developers"
|
mentionName="developers"
|
||||||
>
|
>
|
||||||
@developers
|
@developers
|
||||||
|
@ -29,7 +29,7 @@ import AtPlanMention from 'components/at_plan_mention';
|
|||||||
* - hasPluginTooltips - If specified, the LinkTooltip component is placed inside links. Defaults to false.
|
* - hasPluginTooltips - If specified, the LinkTooltip component is placed inside links. Defaults to false.
|
||||||
* - channelId = If specified, to be passed along to ProfilePopover via AtMention
|
* - channelId = If specified, to be passed along to ProfilePopover via AtMention
|
||||||
*/
|
*/
|
||||||
export function messageHtmlToComponent(html, isRHS, options = {}) {
|
export function messageHtmlToComponent(html, options = {}) {
|
||||||
if (!html) {
|
if (!html) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,6 @@ export function messageHtmlToComponent(html, isRHS, options = {}) {
|
|||||||
const callAtMention = (
|
const callAtMention = (
|
||||||
<AtMention
|
<AtMention
|
||||||
mentionName={mentionName}
|
mentionName={mentionName}
|
||||||
isRHS={isRHS}
|
|
||||||
hasMention={true}
|
hasMention={true}
|
||||||
disableHighlight={!mentionHighlight}
|
disableHighlight={!mentionHighlight}
|
||||||
disableGroupHighlight={disableGroupHighlight}
|
disableGroupHighlight={disableGroupHighlight}
|
||||||
|
@ -43,7 +43,7 @@ const myFunction = () => {
|
|||||||
`;
|
`;
|
||||||
const html = TextFormatting.formatText(input);
|
const html = TextFormatting.formatText(input);
|
||||||
|
|
||||||
expect(messageHtmlToComponent(html, false, {postId: 'randompostid'})).toMatchSnapshot();
|
expect(messageHtmlToComponent(html, {postId: 'randompostid'})).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('html', () => {
|
test('html', () => {
|
||||||
@ -53,7 +53,7 @@ const myFunction = () => {
|
|||||||
`;
|
`;
|
||||||
const html = TextFormatting.formatText(input);
|
const html = TextFormatting.formatText(input);
|
||||||
|
|
||||||
expect(messageHtmlToComponent(html, false, {postId: 'randompostid'})).toMatchSnapshot();
|
expect(messageHtmlToComponent(html, {postId: 'randompostid'})).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('link without enabled tooltip plugins', () => {
|
test('link without enabled tooltip plugins', () => {
|
||||||
@ -67,14 +67,14 @@ const myFunction = () => {
|
|||||||
const input = 'lorem ipsum www.dolor.com sit amet';
|
const input = 'lorem ipsum www.dolor.com sit amet';
|
||||||
const html = TextFormatting.formatText(input);
|
const html = TextFormatting.formatText(input);
|
||||||
|
|
||||||
expect(messageHtmlToComponent(html, false, {hasPluginTooltips: true})).toMatchSnapshot();
|
expect(messageHtmlToComponent(html, {hasPluginTooltips: true})).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Inline markdown image', () => {
|
test('Inline markdown image', () => {
|
||||||
const options = {markdown: true};
|
const options = {markdown: true};
|
||||||
const html = TextFormatting.formatText(' and a [link](link)', options);
|
const html = TextFormatting.formatText(' and a [link](link)', options);
|
||||||
|
|
||||||
const component = messageHtmlToComponent(html, false, {
|
const component = messageHtmlToComponent(html, {
|
||||||
hasPluginTooltips: false,
|
hasPluginTooltips: false,
|
||||||
postId: 'post_id',
|
postId: 'post_id',
|
||||||
postType: Constants.PostTypes.HEADER_CHANGE,
|
postType: Constants.PostTypes.HEADER_CHANGE,
|
||||||
@ -87,7 +87,7 @@ const myFunction = () => {
|
|||||||
const options = {markdown: true};
|
const options = {markdown: true};
|
||||||
const html = TextFormatting.formatText('[](images/icon.png)', options);
|
const html = TextFormatting.formatText('[](images/icon.png)', options);
|
||||||
|
|
||||||
const component = messageHtmlToComponent(html, false, {
|
const component = messageHtmlToComponent(html, {
|
||||||
hasPluginTooltips: false,
|
hasPluginTooltips: false,
|
||||||
postId: 'post_id',
|
postId: 'post_id',
|
||||||
postType: Constants.PostTypes.HEADER_CHANGE,
|
postType: Constants.PostTypes.HEADER_CHANGE,
|
||||||
@ -100,7 +100,7 @@ const myFunction = () => {
|
|||||||
const options = {mentionHighlight: true, atMentions: true, mentionKeys: [{key: '@joram'}]};
|
const options = {mentionHighlight: true, atMentions: true, mentionKeys: [{key: '@joram'}]};
|
||||||
let html = TextFormatting.formatText('@joram', options);
|
let html = TextFormatting.formatText('@joram', options);
|
||||||
|
|
||||||
let component = messageHtmlToComponent(html, false, {mentionHighlight: true});
|
let component = messageHtmlToComponent(html, {mentionHighlight: true});
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
expect(shallow(component).find(AtMention).prop('disableHighlight')).toBe(false);
|
expect(shallow(component).find(AtMention).prop('disableHighlight')).toBe(false);
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ const myFunction = () => {
|
|||||||
|
|
||||||
html = TextFormatting.formatText('@joram', options);
|
html = TextFormatting.formatText('@joram', options);
|
||||||
|
|
||||||
component = messageHtmlToComponent(html, false, {mentionHighlight: false});
|
component = messageHtmlToComponent(html, {mentionHighlight: false});
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
expect(shallow(component).find(AtMention).prop('disableHighlight')).toBe(true);
|
expect(shallow(component).find(AtMention).prop('disableHighlight')).toBe(true);
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ const myFunction = () => {
|
|||||||
const options = {mentionHighlight: true, atMentions: true, mentionKeys: [{key: '@joram'}]};
|
const options = {mentionHighlight: true, atMentions: true, mentionKeys: [{key: '@joram'}]};
|
||||||
let html = TextFormatting.formatText('@developers', options);
|
let html = TextFormatting.formatText('@developers', options);
|
||||||
|
|
||||||
let component = messageHtmlToComponent(html, false, {disableGroupHighlight: false});
|
let component = messageHtmlToComponent(html, {disableGroupHighlight: false});
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
expect(shallow(component).find(AtMention).prop('disableGroupHighlight')).toBe(false);
|
expect(shallow(component).find(AtMention).prop('disableGroupHighlight')).toBe(false);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ const myFunction = () => {
|
|||||||
|
|
||||||
html = TextFormatting.formatText('@developers', options);
|
html = TextFormatting.formatText('@developers', options);
|
||||||
|
|
||||||
component = messageHtmlToComponent(html, false, {disableGroupHighlight: true});
|
component = messageHtmlToComponent(html, {disableGroupHighlight: true});
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
expect(shallow(component).find(AtMention).prop('disableGroupHighlight')).toBe(true);
|
expect(shallow(component).find(AtMention).prop('disableGroupHighlight')).toBe(true);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user