Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3846d34

Browse files
committed
Merge branch 't3chguy/fix/21800' of github.com:matrix-org/matrix-react-sdk into t3chguy/fix/21800
2 parents 9d3c9ac + 2e26cfa commit 3846d34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1706
-298
lines changed

res/css/_common.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,3 +692,9 @@ legend {
692692
}
693693
}
694694
}
695+
696+
@define-mixin ListResetDefault {
697+
list-style: none;
698+
padding: 0;
699+
margin: 0;
700+
}

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@import "./_spacing.scss";
77
@import "./components/views/beacon/_BeaconStatus.scss";
88
@import "./components/views/beacon/_BeaconViewDialog.scss";
9+
@import "./components/views/beacon/_DialogSidebar.scss";
910
@import "./components/views/beacon/_LeftPanelLiveShareWarning.scss";
1011
@import "./components/views/beacon/_LiveTimeRemaining.scss";
1112
@import "./components/views/beacon/_OwnBeaconStatus.scss";

res/css/components/views/beacon/_BeaconViewDialog.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ limitations under the License.
2929
height: calc(80vh - 0.5px);
3030
overflow: hidden;
3131

32+
// sidebar is absolutely positioned inside
33+
position: relative;
34+
3235
.mx_Dialog_header {
3336
margin: 0px;
3437
padding: 0px;
@@ -40,7 +43,7 @@ limitations under the License.
4043

4144
.mx_Dialog_cancelButton {
4245
z-index: 4010;
43-
position: absolute;
46+
position: fixed;
4447
right: 5vw;
4548
top: 5vh;
4649
width: 20px;
@@ -77,3 +80,9 @@ limitations under the License.
7780
color: $secondary-content;
7881
margin-bottom: $spacing-16;
7982
}
83+
84+
.mx_BeaconViewDialog_viewListButton {
85+
position: absolute;
86+
top: $spacing-24;
87+
left: $spacing-24;
88+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_DialogSidebar {
18+
position: absolute;
19+
top: 0;
20+
left: 0;
21+
height: 100%;
22+
width: 265px;
23+
24+
box-sizing: border-box;
25+
padding: $spacing-16;
26+
27+
background-color: $background;
28+
box-shadow: 0px 4px 4px $menu-box-shadow-color;
29+
}
30+
31+
.mx_DialogSidebar_header {
32+
display: flex;
33+
flex-direction: row;
34+
align-items: center;
35+
justify-content: space-between;
36+
37+
flex: 0;
38+
margin-bottom: $spacing-16;
39+
40+
color: $primary-content;
41+
}
42+
43+
.mx_DialogSidebar_closeButton {
44+
@mixin ButtonResetDefault;
45+
}
46+
47+
.mx_DialogSidebar_closeButtonIcon {
48+
color: $tertiary-content;
49+
height: 12px;
50+
}
51+
52+
.mx_DialogSidebar_list {
53+
@mixin ListResetDefault;
54+
flex: 1 1 0;
55+
width: 100%;
56+
overflow: auto;
57+
}

res/css/views/elements/_SettingsFlag.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ limitations under the License.
4141
font-size: $font-12px;
4242
line-height: $font-15px;
4343
color: $secondary-content;
44+
45+
// Support code/pre elements in settings flag descriptions
46+
pre, code {
47+
font-family: $monospace-font-family !important;
48+
background-color: $rte-code-bg-color;
49+
}
4450
}

res/css/views/rooms/_RoomHeader.scss

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,24 @@ limitations under the License.
141141
}
142142

143143
.mx_RoomHeader_topic {
144+
$lineHeight: $font-16px;
145+
$lines: 2;
146+
144147
flex: 1;
145148
color: $roomtopic-color;
146149
font-weight: 400;
147150
font-size: $font-13px;
151+
line-height: $lineHeight;
152+
max-height: calc($lineHeight * $lines);
153+
border-bottom: 1px solid transparent;
154+
148155
// to align baseline of topic with room name
149156
margin: 4px 7px 0;
157+
150158
overflow: hidden;
151-
text-overflow: ellipsis;
152-
border-bottom: 1px solid transparent;
153-
line-height: 1.2em;
154-
max-height: 2.4em;
159+
-webkit-line-clamp: $lines; // See: https://drafts.csswg.org/css-overflow-3/#webkit-line-clamp
160+
-webkit-box-orient: vertical;
161+
display: -webkit-box;
155162
}
156163

157164
.mx_RoomHeader_avatar {

res/css/views/typography/_Heading.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ limitations under the License.
3737
margin-inline: unset;
3838
margin-block: unset;
3939
}
40+
41+
.mx_Heading_h4 {
42+
font-size: $font-15px;
43+
font-weight: $font-semi-bold;
44+
line-height: $font-20px;
45+
margin-inline: unset;
46+
margin-block: unset;
47+
}

src/components/views/beacon/BeaconViewDialog.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from 'react';
17+
import React, { useState } from 'react';
1818
import { MatrixClient } from 'matrix-js-sdk/src/client';
1919
import {
2020
Beacon,
2121
Room,
2222
} from 'matrix-js-sdk/src/matrix';
2323
import maplibregl from 'maplibre-gl';
2424

25+
import { Icon as LiveLocationIcon } from '../../../../res/img/location/live-location.svg';
2526
import { useLiveBeacons } from '../../../utils/beacon/useLiveBeacons';
2627
import MatrixClientContext from '../../../contexts/MatrixClientContext';
2728
import BaseDialog from "../dialogs/BaseDialog";
@@ -34,6 +35,7 @@ import { getGeoUri } from '../../../utils/beacon';
3435
import { Icon as LocationIcon } from '../../../../res/img/element-icons/location.svg';
3536
import { _t } from '../../../languageHandler';
3637
import AccessibleButton from '../elements/AccessibleButton';
38+
import DialogSidebar from './DialogSidebar';
3739

3840
interface IProps extends IDialogProps {
3941
roomId: Room['roomId'];
@@ -64,6 +66,8 @@ const BeaconViewDialog: React.FC<IProps> = ({
6466
}) => {
6567
const liveBeacons = useLiveBeacons(roomId, matrixClient);
6668

69+
const [isSidebarOpen, setSidebarOpen] = useState(false);
70+
6771
const bounds = getBeaconBounds(liveBeacons);
6872
const centerGeoUri = focusBeacon?.latestLocationState?.uri || getBoundsCenter(bounds);
6973

@@ -108,6 +112,18 @@ const BeaconViewDialog: React.FC<IProps> = ({
108112
</AccessibleButton>
109113
</div>
110114
}
115+
{ isSidebarOpen ?
116+
<DialogSidebar beacons={liveBeacons} requestClose={() => setSidebarOpen(false)} /> :
117+
<AccessibleButton
118+
kind='primary'
119+
onClick={() => setSidebarOpen(true)}
120+
data-test-id='beacon-view-dialog-open-sidebar'
121+
className='mx_BeaconViewDialog_viewListButton'
122+
>
123+
<LiveLocationIcon height={12} />&nbsp;
124+
{ _t('View list') }
125+
</AccessibleButton>
126+
}
111127
</MatrixClientContext.Provider>
112128
</BaseDialog>
113129
);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import { Beacon } from 'matrix-js-sdk/src/matrix';
19+
20+
import { Icon as CloseIcon } from '../../../../res/img/image-view/close.svg';
21+
import { _t } from '../../../languageHandler';
22+
import AccessibleButton from '../elements/AccessibleButton';
23+
import Heading from '../typography/Heading';
24+
25+
interface Props {
26+
beacons: Beacon[];
27+
requestClose: () => void;
28+
}
29+
30+
const DialogSidebar: React.FC<Props> = ({ beacons, requestClose }) => {
31+
return <div className='mx_DialogSidebar'>
32+
<div className='mx_DialogSidebar_header'>
33+
<Heading size='h4'>{ _t('View List') }</Heading>
34+
<AccessibleButton
35+
className='mx_DialogSidebar_closeButton'
36+
onClick={requestClose}
37+
title={_t('Close sidebar')}
38+
data-test-id='dialog-sidebar-close'
39+
>
40+
<CloseIcon className='mx_DialogSidebar_closeButtonIcon' />
41+
</AccessibleButton>
42+
</div>
43+
<ol className='mx_DialogSidebar_list'>
44+
{ /* TODO nice elements */ }
45+
{ beacons.map((beacon, index) => <li key={beacon.identifier}>{ index }</li>) }
46+
</ol>
47+
</div>;
48+
};
49+
50+
export default DialogSidebar;

src/components/views/context_menus/MessageContextMenu.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,14 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
397397
);
398398
}
399399

400-
let viewSourceButton: JSX.Element;
401-
if (SettingsStore.getValue("developerMode")) {
402-
viewSourceButton = (
403-
<IconizedContextMenuOption
404-
iconClassName="mx_MessageContextMenu_iconSource"
405-
label={_t("View source")}
406-
onClick={this.onViewSourceClick}
407-
/>
408-
);
409-
}
400+
// This is specifically not behind the developerMode flag to give people insight into the Matrix
401+
const viewSourceButton = (
402+
<IconizedContextMenuOption
403+
iconClassName="mx_MessageContextMenu_iconSource"
404+
label={_t("View source")}
405+
onClick={this.onViewSourceClick}
406+
/>
407+
);
410408

411409
let unhidePreviewButton: JSX.Element;
412410
if (eventTileOps?.isWidgetHidden()) {

src/components/views/dialogs/devtools/ServerInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ const ServerInfo = ({ onBack }: IDevtoolsProps) => {
7474
}
7575

7676
<h4>{ _t("Client Versions") }</h4>
77-
{ capabilities !== FAILED_TO_LOAD
77+
{ clientVersions !== FAILED_TO_LOAD
7878
? <SyntaxHighlight language="json" children={JSON.stringify(clientVersions, null, 4)} />
7979
: <div>{ _t("Failed to load.") }</div>
8080
}
8181

8282
<h4>{ _t("Server Versions") }</h4>
83-
{ capabilities !== FAILED_TO_LOAD
83+
{ serverVersions !== FAILED_TO_LOAD
8484
? <SyntaxHighlight language="json" children={JSON.stringify(serverVersions, null, 4)} />
8585
: <div>{ _t("Failed to load.") }</div>
8686
}

src/components/views/messages/UnknownBody.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ interface IProps {
2323
children?: React.ReactNode;
2424
}
2525

26-
export default forwardRef(({ mxEvent, children }: IProps, ref: React.RefObject<HTMLSpanElement>) => {
26+
export default forwardRef(({ mxEvent, children }: IProps, ref: React.RefObject<HTMLDivElement>) => {
2727
const text = mxEvent.getContent().body;
2828
return (
29-
<span className="mx_UnknownBody" ref={ref}>
29+
<div className="mx_UnknownBody" ref={ref}>
3030
{ text }
3131
{ children }
32-
</span>
32+
</div>
3333
);
3434
});

src/components/views/rooms/BasicMessageComposer.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ interface IProps {
103103
}
104104

105105
interface IState {
106+
useMarkdown: boolean;
106107
showPillAvatar: boolean;
107108
query?: string;
108109
showVisualBell?: boolean;
@@ -124,6 +125,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
124125
private lastCaret: DocumentOffset;
125126
private lastSelection: ReturnType<typeof cloneSelection>;
126127

128+
private readonly useMarkdownHandle: string;
127129
private readonly emoticonSettingHandle: string;
128130
private readonly shouldShowPillAvatarSettingHandle: string;
129131
private readonly surroundWithHandle: string;
@@ -133,10 +135,13 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
133135
super(props);
134136
this.state = {
135137
showPillAvatar: SettingsStore.getValue("Pill.shouldShowPillAvatar"),
138+
useMarkdown: SettingsStore.getValue("MessageComposerInput.useMarkdown"),
136139
surroundWith: SettingsStore.getValue("MessageComposerInput.surroundWith"),
137140
showVisualBell: false,
138141
};
139142

143+
this.useMarkdownHandle = SettingsStore.watchSetting('MessageComposerInput.useMarkdown', null,
144+
this.configureUseMarkdown);
140145
this.emoticonSettingHandle = SettingsStore.watchSetting('MessageComposerInput.autoReplaceEmoji', null,
141146
this.configureEmoticonAutoReplace);
142147
this.configureEmoticonAutoReplace();
@@ -442,7 +447,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
442447
}
443448
} else if (!selection.isCollapsed && !isEmpty) {
444449
this.hasTextSelected = true;
445-
if (this.formatBarRef.current) {
450+
if (this.formatBarRef.current && this.state.useMarkdown) {
446451
const selectionRect = selection.getRangeAt(0).getBoundingClientRect();
447452
this.formatBarRef.current.showAt(selectionRect);
448453
}
@@ -630,6 +635,14 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
630635
this.setState({ completionIndex });
631636
};
632637

638+
private configureUseMarkdown = (): void => {
639+
const useMarkdown = SettingsStore.getValue("MessageComposerInput.useMarkdown");
640+
this.setState({ useMarkdown });
641+
if (!useMarkdown && this.formatBarRef.current) {
642+
this.formatBarRef.current.hide();
643+
}
644+
};
645+
633646
private configureEmoticonAutoReplace = (): void => {
634647
this.props.model.setTransformCallback(this.transform);
635648
};
@@ -654,6 +667,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
654667
this.editorRef.current.removeEventListener("input", this.onInput, true);
655668
this.editorRef.current.removeEventListener("compositionstart", this.onCompositionStart, true);
656669
this.editorRef.current.removeEventListener("compositionend", this.onCompositionEnd, true);
670+
SettingsStore.unwatchSetting(this.useMarkdownHandle);
657671
SettingsStore.unwatchSetting(this.emoticonSettingHandle);
658672
SettingsStore.unwatchSetting(this.shouldShowPillAvatarSettingHandle);
659673
SettingsStore.unwatchSetting(this.surroundWithHandle);
@@ -694,6 +708,10 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
694708
}
695709

696710
public onFormatAction = (action: Formatting): void => {
711+
if (!this.state.useMarkdown) {
712+
return;
713+
}
714+
697715
const range: Range = getRangeForSelection(this.editorRef.current, this.props.model, document.getSelection());
698716

699717
this.historyManager.ensureLastChangesPushed(this.props.model);

0 commit comments

Comments
 (0)