mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Merge branch 'develop' into luke/feature-rte-insert-pills-on-click-tl-profile
This commit is contained in:
commit
4bee9bd8c7
3 changed files with 22 additions and 23 deletions
|
@ -55,13 +55,8 @@ export default class RoomProvider extends AutocompleteProvider {
|
||||||
const displayAlias = getDisplayAliasForRoom(room.room) || room.roomId;
|
const displayAlias = getDisplayAliasForRoom(room.room) || room.roomId;
|
||||||
return {
|
return {
|
||||||
completion: displayAlias,
|
completion: displayAlias,
|
||||||
entity: {
|
suffix: ' ',
|
||||||
type: 'LINK',
|
href: 'https://matrix.to/#/' + displayAlias,
|
||||||
mutability: 'IMMUTABLE',
|
|
||||||
data: {
|
|
||||||
url: 'https://matrix.to/#/' + displayAlias,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
component: (
|
component: (
|
||||||
<PillCompletion initialComponent={<RoomAvatar width={24} height={24} room={room.room} />} title={room.name} description={displayAlias} />
|
<PillCompletion initialComponent={<RoomAvatar width={24} height={24} room={room.room} />} title={room.name} description={displayAlias} />
|
||||||
),
|
),
|
||||||
|
|
|
@ -56,13 +56,7 @@ export default class UserProvider extends AutocompleteProvider {
|
||||||
return {
|
return {
|
||||||
completion: displayName,
|
completion: displayName,
|
||||||
suffix: range.start === 0 ? ': ' : ' ',
|
suffix: range.start === 0 ? ': ' : ' ',
|
||||||
entity: {
|
href: 'https://matrix.to/#/' + user.userId,
|
||||||
type: 'LINK',
|
|
||||||
mutability: 'IMMUTABLE',
|
|
||||||
data: {
|
|
||||||
url: 'https://matrix.to/#/' + user.userId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
component: (
|
component: (
|
||||||
<PillCompletion
|
<PillCompletion
|
||||||
initialComponent={<MemberAvatar member={user} width={24} height={24}/>}
|
initialComponent={<MemberAvatar member={user} width={24} height={24}/>}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import {Completion} from "../../../autocomplete/Autocompleter";
|
||||||
import Markdown from '../../../Markdown';
|
import Markdown from '../../../Markdown';
|
||||||
import ComposerHistoryManager from '../../../ComposerHistoryManager';
|
import ComposerHistoryManager from '../../../ComposerHistoryManager';
|
||||||
import MessageComposerStore from '../../../stores/MessageComposerStore';
|
import MessageComposerStore from '../../../stores/MessageComposerStore';
|
||||||
|
import { getDisplayAliasForRoom } from '../../../Rooms';
|
||||||
|
|
||||||
import {MATRIXTO_URL_PATTERN} from '../../../linkify-matrix';
|
import {MATRIXTO_URL_PATTERN} from '../../../linkify-matrix';
|
||||||
const REGEX_MATRIXTO = new RegExp(MATRIXTO_URL_PATTERN);
|
const REGEX_MATRIXTO = new RegExp(MATRIXTO_URL_PATTERN);
|
||||||
|
@ -198,6 +199,9 @@ export default class MessageComposerInput extends React.Component {
|
||||||
const resource = matrixToMatch[1]; // The room/user ID
|
const resource = matrixToMatch[1]; // The room/user ID
|
||||||
const prefix = matrixToMatch[2]; // The first character of prefix
|
const prefix = matrixToMatch[2]; // The first character of prefix
|
||||||
|
|
||||||
|
// Default to the room/user ID
|
||||||
|
let linkText = resource;
|
||||||
|
|
||||||
const isUserPill = prefix === '@';
|
const isUserPill = prefix === '@';
|
||||||
const isRoomPill = prefix === '#' || prefix === '!';
|
const isRoomPill = prefix === '#' || prefix === '!';
|
||||||
|
|
||||||
|
@ -212,12 +216,18 @@ export default class MessageComposerInput extends React.Component {
|
||||||
// member. This could be improved by doing an async profile lookup.
|
// member. This could be improved by doing an async profile lookup.
|
||||||
const member = this.props.room.getMember(resource) ||
|
const member = this.props.room.getMember(resource) ||
|
||||||
new RoomMember(null, resource);
|
new RoomMember(null, resource);
|
||||||
|
|
||||||
|
linkText = member.name;
|
||||||
|
|
||||||
avatar = member ? <MemberAvatar member={member} width={16} height={16}/> : null;
|
avatar = member ? <MemberAvatar member={member} width={16} height={16}/> : null;
|
||||||
} else if (isRoomPill) {
|
} else if (isRoomPill) {
|
||||||
const room = prefix === '#' ?
|
const room = prefix === '#' ?
|
||||||
MatrixClientPeg.get().getRooms().find((r) => {
|
MatrixClientPeg.get().getRooms().find((r) => {
|
||||||
return r.getCanonicalAlias() === resource;
|
return r.getCanonicalAlias() === resource;
|
||||||
}) : MatrixClientPeg.get().getRoom(resource);
|
}) : MatrixClientPeg.get().getRoom(resource);
|
||||||
|
|
||||||
|
linkText = getDisplayAliasForRoom(room) || resource;
|
||||||
|
|
||||||
avatar = room ? <RoomAvatar room={room} width={16} height={16}/> : null;
|
avatar = room ? <RoomAvatar room={room} width={16} height={16}/> : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +235,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
return (
|
return (
|
||||||
<span className={classes}>
|
<span className={classes}>
|
||||||
{avatar}
|
{avatar}
|
||||||
{props.children}
|
{linkText}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -936,14 +946,14 @@ export default class MessageComposerInput extends React.Component {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {range = {}, completion = '', entity = null, suffix = ''} = displayedCompletion;
|
const {range = {}, completion = '', href = null, suffix = ''} = displayedCompletion;
|
||||||
let entityKey;
|
let entityKey;
|
||||||
if (entity) {
|
let mdCompletion;
|
||||||
entityKey = Entity.create(
|
if (href) {
|
||||||
entity.type,
|
entityKey = Entity.create('LINK', 'IMMUTABLE', {url: href});
|
||||||
entity.mutability,
|
if (!this.state.isRichtextEnabled) {
|
||||||
entity.data,
|
mdCompletion = `[${completion}](${href})`;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let contentState = Modifier.replaceText(
|
let contentState = Modifier.replaceText(
|
||||||
|
@ -951,7 +961,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
RichText.textOffsetsToSelectionState(
|
RichText.textOffsetsToSelectionState(
|
||||||
range, activeEditorState.getCurrentContent().getBlocksAsArray(),
|
range, activeEditorState.getCurrentContent().getBlocksAsArray(),
|
||||||
),
|
),
|
||||||
completion,
|
mdCompletion || completion,
|
||||||
null,
|
null,
|
||||||
entityKey,
|
entityKey,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue