Skip to content

Commit 8a95f55

Browse files
feat: accessibility improvements (#718)
* wip * Refactored image toolbar * Refactored image toolbar, hyperlink toolbar, and table handles * Implemented PR feedback * Implemented PR feedback * Cleaned up component code * wip: ariakit * wip * fix * fix merge * wip * wip * fix * wip * wip * wip: suggestionmenu * extract suggestion menu * wip * side menu button * move mantine elements to mantine dir * shadcn wip * wip * fix * shadcn fixes * refactor: Extract image panel components (#684) * Extracted Mantine panel components * Added ShadCN panel implementation * Added Ariakit image panel components * Revert "refactor: Extract image panel components (#684)" (#716) This reverts commit 600f0c5. * refactor: Extract image panel components (#717) * Extracted Mantine panel components * Added ShadCN panel implementation * Added Ariakit image panel components * refactor: Extract Mantine & Ariakit packages (#689) * Extracted mantine & ariakit packages * fix: ShadCN color styles button & form components (#696) * Added ShadCN color styles button & form components * refactor: UI libs CSS+API refactor (#698) * Cleaned up component context API * WIP * Refactored CSS & ShadCN API * Fixed Ariakit component props * Fixed Mantine component props * Fixed ShadCN component props * Cleanup * Misc fixes * - Added remaining components to context - Re-added refs to all relevant components - Refactored ShadCN context - Simplified how class names are set in `react` package - Added prefixes to all UI specific class names - Fixed remaining select/menu/popover overflow issues - Fixed examples - Fixed build * Changed ShadCN suggestion menu to use Card * Small fix * Fixed linting * Fixed `BlockNoteViewRaw` typing * Misc fixes * Misc fixes * Fixed unit tests * Fixed Mantine sub menus * Misc UI fixes * Misc changes * fix import * fix tablehandles performance issue / max call stack * Fixed PW tests * Small fix * Added ShadCN/Ariakit tests * fix draghandles * add vercel rewrites * improve shadcn setup * Fixed remaining Ariakit/ShadCN/Mantine styles * extract strings from react package * extract all strings * clean i18n setup * fix build * Fixed dark mode for Ariakit/ShadCN * Misc fixes --------- Co-authored-by: yousefed <[email protected]> --------- Co-authored-by: yousefed <[email protected]> --------- Co-authored-by: yousefed <[email protected]> --------- Co-authored-by: yousefed <[email protected]> * Updated package versions * Updated screenshots * Updated screenshots * Updated screenshots * Updated screenshots * Updated docs * Addressed most TODOs and small fixes * Added ShadCN form * update docs * i18n + docs * fix keyboard handling of menus (tab, escape, etc.) * remove unnecessary default props on BlockNoteDefaultUI * fix mantine menu items with keyboard + small cleanup * add button labels and type checks * Updated theming code * suggestion menu aria improvements * small toolbarButton fix * playwright fixes * fix lint * fix build and lint * fix pw tests * address PR feedback * Merge remote-tracking branch 'origin/refactor/multi-ui-libs' into feature/accessibility-improvements --------- Co-authored-by: Matthew Lipski <[email protected]> Co-authored-by: Matthew Lipski <[email protected]>
1 parent 218758d commit 8a95f55

File tree

123 files changed

+1135
-863
lines changed

Some content is hidden

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

123 files changed

+1135
-863
lines changed

docs/pages/docs/advanced/component-libraries.mdx

Lines changed: 0 additions & 95 deletions
This file was deleted.

docs/pages/docs/styling-theming/overriding-css.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Within the editor's DOM structure, you'll find many elements have classes with t
3737

3838
`.bn-drag-handle-menu`: Element for the drag handle menu.
3939

40-
`.bn-slash-menu`: Element for the slash menu.
40+
`.bn-suggestion-menu`: Element for suggestion menu.
4141

4242
## BlockNote CSS Attributes
4343

@@ -52,5 +52,3 @@ For example, `[data-content-type="heading"][data-level="2"]` will select all hea
5252
## Mantine Classes
5353

5454
Because BlockNote uses [Mantine](https://mantine.dev/) for its UI, you can also write CSS rules using any of the default Mantine component classes.
55-
56-

examples/02-ui-components/04-side-menu-buttons/RemoveBlockButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function RemoveBlockButton(props: SideMenuProps) {
1313

1414
return (
1515
<Components.SideMenu.Button
16+
label="Remove block"
1617
icon={
1718
<MdDelete
1819
size={24}

examples/03-theming/03-theming-css/styles.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
}
55

66
/* Makes slash menu hovered items blue */
7-
.bn-container[data-theming-css-demo] .bn-slash-menu .mantine-Menu-item[data-hovered] {
7+
.bn-container[data-theming-css-demo]
8+
.bn-suggestion-menu-item[aria-selected="true"],
9+
.bn-container[data-theming-css-demo] .bn-suggestion-menu-item:hover {
810
background-color: blue;
911
}

examples/05-custom-schema/03-font-style/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { BlockNoteSchema, defaultStyleSpecs } from "@blocknote/core";
22
import "@blocknote/core/fonts/inter.css";
3+
import { BlockNoteView } from "@blocknote/mantine";
4+
import "@blocknote/mantine/style.css";
35
import {
46
BasicTextStyleButton,
57
BlockTypeSelect,
@@ -16,8 +18,6 @@ import {
1618
useComponentsContext,
1719
useCreateBlockNote,
1820
} from "@blocknote/react";
19-
import { BlockNoteView } from "@blocknote/mantine";
20-
import "@blocknote/mantine/style.css";
2121
import { RiText } from "react-icons/ri";
2222

2323
import { Font } from "./Font";
@@ -45,6 +45,7 @@ const SetFontStyleButton = () => {
4545

4646
return (
4747
<Components.FormattingToolbar.Button
48+
label="Set Font"
4849
mainTooltip={"Set Font"}
4950
icon={<RiText />}
5051
onClick={() => {

packages/ariakit/src/input/Form.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as Ariakit from "@ariakit/react";
2+
import { assertEmpty } from "@blocknote/core";
23

34
import { ComponentProps } from "@blocknote/react";
45

56
export const Form = (props: ComponentProps["Generic"]["Form"]["Root"]) => {
6-
const { children } = props;
7+
const { children, ...rest } = props;
8+
9+
assertEmpty(rest);
710

811
return <Ariakit.FormProvider>{children}</Ariakit.FormProvider>;
912
};

packages/ariakit/src/input/TextInput.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Ariakit from "@ariakit/react";
22

3-
import { mergeCSSClasses } from "@blocknote/core";
3+
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
44
import { ComponentProps } from "@blocknote/react";
55
import { forwardRef } from "react";
66

@@ -19,8 +19,11 @@ export const TextInput = forwardRef<
1919
onKeyDown,
2020
onChange,
2121
onSubmit,
22+
...rest
2223
} = props;
2324

25+
assertEmpty(rest);
26+
2427
return (
2528
<>
2629
{props.label && (

packages/ariakit/src/menu/Menu.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Ariakit from "@ariakit/react";
22

3-
import { mergeCSSClasses } from "@blocknote/core";
3+
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
44
import { ComponentProps } from "@blocknote/react";
55
import { forwardRef } from "react";
66

@@ -9,9 +9,12 @@ export const Menu = (props: ComponentProps["Generic"]["Menu"]["Root"]) => {
99
children,
1010
onOpenChange,
1111
position,
12-
// sub
12+
sub, // unused
13+
...rest
1314
} = props;
1415

16+
assertEmpty(rest);
17+
1518
return (
1619
<Ariakit.MenuProvider
1720
placement={position}
@@ -26,7 +29,14 @@ export const MenuDropdown = forwardRef<
2629
HTMLDivElement,
2730
ComponentProps["Generic"]["Menu"]["Dropdown"]
2831
>((props, ref) => {
29-
const { className, children } = props;
32+
const {
33+
className,
34+
children,
35+
sub, // unused
36+
...rest
37+
} = props;
38+
39+
assertEmpty(rest);
3040

3141
return (
3242
<Ariakit.Menu
@@ -41,7 +51,10 @@ export const MenuItem = forwardRef<
4151
HTMLDivElement,
4252
ComponentProps["Generic"]["Menu"]["Item"]
4353
>((props, ref) => {
44-
const { className, children, icon, checked, subTrigger, onClick } = props;
54+
const { className, children, icon, checked, subTrigger, onClick, ...rest } =
55+
props;
56+
57+
assertEmpty(rest);
4558

4659
if (subTrigger) {
4760
return (
@@ -73,7 +86,9 @@ export const MenuLabel = forwardRef<
7386
HTMLDivElement,
7487
ComponentProps["Generic"]["Menu"]["Label"]
7588
>((props, ref) => {
76-
const { className, children } = props;
89+
const { className, children, ...rest } = props;
90+
91+
assertEmpty(rest);
7792

7893
return (
7994
<Ariakit.MenuGroupLabel
@@ -87,7 +102,9 @@ export const MenuLabel = forwardRef<
87102
export const MenuTrigger = (
88103
props: ComponentProps["Generic"]["Menu"]["Trigger"]
89104
) => {
90-
const { children, sub } = props;
105+
const { children, sub, ...rest } = props;
106+
107+
assertEmpty(rest);
91108

92109
if (sub) {
93110
return children;
@@ -100,7 +117,9 @@ export const MenuDivider = forwardRef<
100117
HTMLHRElement,
101118
ComponentProps["Generic"]["Menu"]["Divider"]
102119
>((props, ref) => {
103-
const { className } = props;
120+
const { className, ...rest } = props;
121+
122+
assertEmpty(rest);
104123

105124
return (
106125
<Ariakit.MenuSeparator

packages/ariakit/src/panel/Panel.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Ariakit from "@ariakit/react";
22

3-
import { mergeCSSClasses } from "@blocknote/core";
3+
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
44
import { ComponentProps } from "@blocknote/react";
55
import { forwardRef } from "react";
66

@@ -14,10 +14,12 @@ export const Panel = forwardRef<
1414
defaultOpenTab,
1515
openTab,
1616
setOpenTab,
17-
// loading,
18-
// setLoading,
17+
loading, // TODO: implement loading
18+
...rest
1919
} = props;
2020

21+
assertEmpty(rest);
22+
2123
return (
2224
<div
2325
className={mergeCSSClasses("bn-ak-wrapper", className || "")}

packages/ariakit/src/panel/PanelButton.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import * as Ariakit from "@ariakit/react";
22

3-
import { mergeCSSClasses } from "@blocknote/core";
3+
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
44
import { ComponentProps } from "@blocknote/react";
55
import { forwardRef } from "react";
66

77
export const PanelButton = forwardRef<
88
HTMLButtonElement,
99
ComponentProps["ImagePanel"]["Button"]
1010
>((props, ref) => {
11-
const { className, children, onClick } = props;
11+
const { className, children, onClick, label, ...rest } = props;
12+
13+
assertEmpty(rest);
1214

1315
return (
1416
<Ariakit.Button
1517
className={mergeCSSClasses("bn-ak-button", className || "")}
1618
onClick={onClick}
19+
aria-label={label}
1720
ref={ref}>
1821
{children}
1922
</Ariakit.Button>

0 commit comments

Comments
 (0)