Skip to content

Commit 9dbc5f3

Browse files
authored
Add quotes to rich text editor (matrix-org#9932)
* bump rich text editor to 0.20.0 * add new svg for the button * show the button * make the composer display look like the timeline display
1 parent ad50097 commit 9dbc5f3

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"dependencies": {
5858
"@babel/runtime": "^7.12.5",
5959
"@matrix-org/analytics-events": "^0.4.0",
60-
"@matrix-org/matrix-wysiwyg": "^0.19.0",
60+
"@matrix-org/matrix-wysiwyg": "^0.20.0",
6161
"@matrix-org/react-sdk-module-api": "^0.0.3",
6262
"@sentry/browser": "^7.0.0",
6363
"@sentry/tracing": "^7.0.0",

res/css/views/rooms/wysiwyg_composer/components/_Editor.pcss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,21 @@ limitations under the License.
4444
padding-inline-start: $spacing-28;
4545
}
4646

47+
blockquote {
48+
color: #777;
49+
border-left: 2px solid $blockquote-bar-color;
50+
border-radius: 2px;
51+
padding: 0 10px;
52+
53+
margin-block-start: 0;
54+
margin-block-end: 0;
55+
margin-inline-start: 0;
56+
margin-inline-end: 0;
57+
}
58+
4759
// model output always includes a linebreak but we do not want the user
4860
// to see it when writing input in lists
49-
:is(ol, ul, pre) + br:last-of-type {
61+
:is(ol, ul, pre, blockquote) + br:last-of-type {
5062
display: none;
5163
}
5264

Lines changed: 6 additions & 0 deletions
Loading

src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Icon as BoldIcon } from "../../../../../../res/img/element-icons/room/c
2222
import { Icon as ItalicIcon } from "../../../../../../res/img/element-icons/room/composer/italic.svg";
2323
import { Icon as UnderlineIcon } from "../../../../../../res/img/element-icons/room/composer/underline.svg";
2424
import { Icon as StrikeThroughIcon } from "../../../../../../res/img/element-icons/room/composer/strikethrough.svg";
25+
import { Icon as QuoteIcon } from "../../../../../../res/img/element-icons/room/composer/quote.svg";
2526
import { Icon as InlineCodeIcon } from "../../../../../../res/img/element-icons/room/composer/inline_code.svg";
2627
import { Icon as LinkIcon } from "../../../../../../res/img/element-icons/room/composer/link.svg";
2728
import { Icon as BulletedListIcon } from "../../../../../../res/img/element-icons/room/composer/bulleted_list.svg";
@@ -126,6 +127,12 @@ export function FormattingButtons({ composer, actionStates }: FormattingButtonsP
126127
onClick={() => composer.orderedList()}
127128
icon={<NumberedListIcon className="mx_FormattingButtons_Icon" />}
128129
/>
130+
<Button
131+
actionState={actionStates.quote}
132+
label={_td("Quote")}
133+
onClick={() => composer.quote()}
134+
icon={<QuoteIcon className="mx_FormattingButtons_Icon" />}
135+
/>
129136
<Button
130137
actionState={actionStates.inlineCode}
131138
label={_td("Code")}

test/components/views/rooms/wysiwyg_composer/components/FormattingButtons-test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const mockWysiwyg = {
3232
link: jest.fn(),
3333
orderedList: jest.fn(),
3434
unorderedList: jest.fn(),
35+
quote: jest.fn(),
3536
} as unknown as FormattingFunctions;
3637

3738
const openLinkModalSpy = jest.spyOn(LinkModal, "openLinkModal");
@@ -49,6 +50,7 @@ const testCases: Record<
4950
link: { label: "Link", mockFormatFn: openLinkModalSpy },
5051
orderedList: { label: "Numbered list", mockFormatFn: mockWysiwyg.orderedList },
5152
unorderedList: { label: "Bulleted list", mockFormatFn: mockWysiwyg.unorderedList },
53+
quote: { label: "Quote", mockFormatFn: mockWysiwyg.quote },
5254
};
5355

5456
const createActionStates = (state: ActionState): AllActionStates => {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,10 +1589,10 @@
15891589
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.2.tgz#a09d0fea858e817da971a3c9f904632ef7b49eb6"
15901590
integrity sha512-oVkBCh9YP7H9i4gAoQbZzswniczfo/aIptNa4dxRi4Ff9lSvUCFv6Hvzi7C+90c0/PWZLXjIDTIAWZYmwyd2fA==
15911591

1592-
"@matrix-org/matrix-wysiwyg@^0.19.0":
1593-
version "0.19.0"
1594-
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-0.19.0.tgz#5ffbabf8a59317ecdb45ba5fa1d06fff150ede40"
1595-
integrity sha512-1iL/+kjwWAlpWAq64DbkDkE7KGxvR5lNojZgCKMIyuvuKWv8Ikqxa9VOOYFtovKvSqgGRJaYN7/OkKWxZjiDcw==
1592+
"@matrix-org/matrix-wysiwyg@^0.20.0":
1593+
version "0.20.0"
1594+
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-0.20.0.tgz#6193f790b031eaa96e944b647fe2b27018639d57"
1595+
integrity sha512-9VqzyccwizglssShi/M+tCxdZDgzsecH4WjlS0HC5KkLmljIxxlHFstf/D3C/G4ZfRodFUh6wUvd+oQI/ScPpw==
15961596

15971597
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
15981598
version "3.2.14"

0 commit comments

Comments
 (0)