Skip to content

feat: accessibility improvements #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6406daf
wip
matthewlipski Mar 6, 2024
184d36c
Refactored image toolbar
matthewlipski Mar 6, 2024
861c2b2
Refactored image toolbar, hyperlink toolbar, and table handles
matthewlipski Mar 7, 2024
68d7df5
Implemented PR feedback
matthewlipski Mar 8, 2024
c29b63f
Implemented PR feedback
matthewlipski Mar 11, 2024
89fb722
Cleaned up component code
matthewlipski Mar 12, 2024
7318c51
wip: ariakit
YousefED Mar 14, 2024
a7f908f
wip
YousefED Mar 18, 2024
dca9fe7
Merge remote-tracking branch 'TypeCellOS/main' into refactor/multi-ui…
YousefED Mar 18, 2024
f0b20bd
fix
YousefED Mar 18, 2024
9ef1634
fix merge
YousefED Mar 18, 2024
11a7247
wip
YousefED Mar 18, 2024
af65c67
wip
YousefED Mar 19, 2024
00c296c
fix
YousefED Mar 19, 2024
c268f7c
wip
YousefED Mar 19, 2024
9167f18
wip
YousefED Mar 20, 2024
25237b4
wip: suggestionmenu
YousefED Mar 22, 2024
9f877c1
extract suggestion menu
YousefED Mar 22, 2024
567df48
wip
YousefED Mar 22, 2024
234612c
side menu button
YousefED Mar 22, 2024
5316b69
move mantine elements to mantine dir
YousefED Mar 22, 2024
8a0f526
shadcn wip
YousefED Mar 22, 2024
2ae2e91
wip
YousefED Mar 26, 2024
d20269b
fix
YousefED Mar 26, 2024
a5cf36a
shadcn fixes
YousefED Mar 26, 2024
c2fb7f3
Merge remote-tracking branch 'origin/main' into refactor/multi-ui-libs
YousefED Apr 5, 2024
600f0c5
refactor: Extract image panel components (#684)
matthewlipski Apr 30, 2024
8284895
Revert "refactor: Extract image panel components (#684)" (#716)
matthewlipski Apr 30, 2024
64c12ac
refactor: Extract image panel components (#717)
matthewlipski Apr 30, 2024
5413b34
Updated package versions
matthewlipski Apr 30, 2024
6e5f1d3
Updated screenshots
matthewlipski Apr 30, 2024
ac99d31
Updated screenshots
matthewlipski Apr 30, 2024
7293f64
Updated screenshots
matthewlipski Apr 30, 2024
dfb9436
Updated screenshots
matthewlipski Apr 30, 2024
684a592
Updated docs
matthewlipski Apr 30, 2024
518ee8e
Addressed most TODOs and small fixes
matthewlipski Apr 30, 2024
39d84a0
Added ShadCN form
matthewlipski Apr 30, 2024
06ddfc0
update docs
YousefED May 1, 2024
85f597d
i18n + docs
YousefED May 1, 2024
7cfe1f6
fix keyboard handling of menus (tab, escape, etc.)
YousefED May 2, 2024
0cc3e7a
remove unnecessary default props on BlockNoteDefaultUI
YousefED May 2, 2024
91d6a58
fix mantine menu items with keyboard + small cleanup
YousefED May 2, 2024
8bb9cbd
add button labels and type checks
YousefED May 2, 2024
2c025f8
Updated theming code
matthewlipski May 2, 2024
3987ceb
Merge remote-tracking branch 'origin/refactor/multi-ui-libs' into ref…
matthewlipski May 2, 2024
33cc075
suggestion menu aria improvements
YousefED May 3, 2024
cf7601b
small toolbarButton fix
YousefED May 3, 2024
9fc3a40
playwright fixes
YousefED May 4, 2024
7ceff12
fix lint
YousefED May 4, 2024
b9f8923
Merge remote-tracking branch 'origin/refactor/multi-ui-libs' into fea…
YousefED May 4, 2024
24e9e59
fix build and lint
YousefED May 4, 2024
7a2f2ea
Merge remote-tracking branch 'origin/refactor/multi-ui-libs' into fea…
YousefED May 4, 2024
a117021
fix pw tests
YousefED May 5, 2024
4215448
address PR feedback
YousefED May 5, 2024
24e58bb
Merge remote-tracking branch 'origin/refactor/multi-ui-libs' into fea…
YousefED May 5, 2024
6c063eb
Merge remote-tracking branch 'origin/main' into feature/accessibility…
YousefED May 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions docs/pages/docs/advanced/component-libraries.mdx

This file was deleted.

4 changes: 1 addition & 3 deletions docs/pages/docs/styling-theming/overriding-css.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Within the editor's DOM structure, you'll find many elements have classes with t

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

`.bn-slash-menu`: Element for the slash menu.
`.bn-suggestion-menu`: Element for suggestion menu.

## BlockNote CSS Attributes

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

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


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function RemoveBlockButton(props: SideMenuProps) {

return (
<Components.SideMenu.Button
label="Remove block"
icon={
<MdDelete
size={24}
Expand Down
4 changes: 3 additions & 1 deletion examples/03-theming/03-theming-css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
}

/* Makes slash menu hovered items blue */
.bn-container[data-theming-css-demo] .bn-slash-menu .mantine-Menu-item[data-hovered] {
.bn-container[data-theming-css-demo]
.bn-suggestion-menu-item[aria-selected="true"],
.bn-container[data-theming-css-demo] .bn-suggestion-menu-item:hover {
background-color: blue;
}
5 changes: 3 additions & 2 deletions examples/05-custom-schema/03-font-style/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BlockNoteSchema, defaultStyleSpecs } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import {
BasicTextStyleButton,
BlockTypeSelect,
Expand All @@ -16,8 +18,6 @@ import {
useComponentsContext,
useCreateBlockNote,
} from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { RiText } from "react-icons/ri";

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

return (
<Components.FormattingToolbar.Button
label="Set Font"
mainTooltip={"Set Font"}
icon={<RiText />}
onClick={() => {
Expand Down
5 changes: 4 additions & 1 deletion packages/ariakit/src/input/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as Ariakit from "@ariakit/react";
import { assertEmpty } from "@blocknote/core";

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

export const Form = (props: ComponentProps["Generic"]["Form"]["Root"]) => {
const { children } = props;
const { children, ...rest } = props;

assertEmpty(rest);

return <Ariakit.FormProvider>{children}</Ariakit.FormProvider>;
};
5 changes: 4 additions & 1 deletion packages/ariakit/src/input/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Ariakit from "@ariakit/react";

import { mergeCSSClasses } from "@blocknote/core";
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

Expand All @@ -19,8 +19,11 @@ export const TextInput = forwardRef<
onKeyDown,
onChange,
onSubmit,
...rest
} = props;

assertEmpty(rest);

return (
<>
{props.label && (
Expand Down
33 changes: 26 additions & 7 deletions packages/ariakit/src/menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Ariakit from "@ariakit/react";

import { mergeCSSClasses } from "@blocknote/core";
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

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

assertEmpty(rest);

return (
<Ariakit.MenuProvider
placement={position}
Expand All @@ -26,7 +29,14 @@ export const MenuDropdown = forwardRef<
HTMLDivElement,
ComponentProps["Generic"]["Menu"]["Dropdown"]
>((props, ref) => {
const { className, children } = props;
const {
className,
children,
sub, // unused
...rest
} = props;

assertEmpty(rest);

return (
<Ariakit.Menu
Expand All @@ -41,7 +51,10 @@ export const MenuItem = forwardRef<
HTMLDivElement,
ComponentProps["Generic"]["Menu"]["Item"]
>((props, ref) => {
const { className, children, icon, checked, subTrigger, onClick } = props;
const { className, children, icon, checked, subTrigger, onClick, ...rest } =
props;

assertEmpty(rest);

if (subTrigger) {
return (
Expand Down Expand Up @@ -73,7 +86,9 @@ export const MenuLabel = forwardRef<
HTMLDivElement,
ComponentProps["Generic"]["Menu"]["Label"]
>((props, ref) => {
const { className, children } = props;
const { className, children, ...rest } = props;

assertEmpty(rest);

return (
<Ariakit.MenuGroupLabel
Expand All @@ -87,7 +102,9 @@ export const MenuLabel = forwardRef<
export const MenuTrigger = (
props: ComponentProps["Generic"]["Menu"]["Trigger"]
) => {
const { children, sub } = props;
const { children, sub, ...rest } = props;

assertEmpty(rest);

if (sub) {
return children;
Expand All @@ -100,7 +117,9 @@ export const MenuDivider = forwardRef<
HTMLHRElement,
ComponentProps["Generic"]["Menu"]["Divider"]
>((props, ref) => {
const { className } = props;
const { className, ...rest } = props;

assertEmpty(rest);

return (
<Ariakit.MenuSeparator
Expand Down
8 changes: 5 additions & 3 deletions packages/ariakit/src/panel/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Ariakit from "@ariakit/react";

import { mergeCSSClasses } from "@blocknote/core";
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

Expand All @@ -14,10 +14,12 @@ export const Panel = forwardRef<
defaultOpenTab,
openTab,
setOpenTab,
// loading,
// setLoading,
loading, // TODO: implement loading
...rest
} = props;

assertEmpty(rest);

return (
<div
className={mergeCSSClasses("bn-ak-wrapper", className || "")}
Expand Down
7 changes: 5 additions & 2 deletions packages/ariakit/src/panel/PanelButton.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import * as Ariakit from "@ariakit/react";

import { mergeCSSClasses } from "@blocknote/core";
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

export const PanelButton = forwardRef<
HTMLButtonElement,
ComponentProps["ImagePanel"]["Button"]
>((props, ref) => {
const { className, children, onClick } = props;
const { className, children, onClick, label, ...rest } = props;

assertEmpty(rest);

return (
<Ariakit.Button
className={mergeCSSClasses("bn-ak-button", className || "")}
onClick={onClick}
aria-label={label}
ref={ref}>
{children}
</Ariakit.Button>
Expand Down
5 changes: 4 additions & 1 deletion packages/ariakit/src/panel/PanelFileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Ariakit from "@ariakit/react";
import { assertEmpty } from "@blocknote/core";

import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";
Expand All @@ -7,7 +8,9 @@ export const PanelFileInput = forwardRef<
HTMLInputElement,
ComponentProps["ImagePanel"]["FileInput"]
>((props, ref) => {
const { className, value, placeholder, onChange } = props;
const { className, value, placeholder, onChange, ...rest } = props;

assertEmpty(rest);

return (
<Ariakit.FormProvider>
Expand Down
5 changes: 4 additions & 1 deletion packages/ariakit/src/panel/PanelTab.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { assertEmpty } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

export const PanelTab = forwardRef<
HTMLDivElement,
ComponentProps["ImagePanel"]["TabPanel"]
>((props, ref) => {
const { className, children } = props;
const { className, children, ...rest } = props;

assertEmpty(rest);

return (
<div className={className} ref={ref}>
Expand Down
6 changes: 4 additions & 2 deletions packages/ariakit/src/panel/PanelTextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import * as Ariakit from "@ariakit/react";

import { mergeCSSClasses } from "@blocknote/core";
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps } from "@blocknote/react";
import { forwardRef } from "react";

export const PanelTextInput = forwardRef<
HTMLInputElement,
ComponentProps["ImagePanel"]["TextInput"]
>((props, ref) => {
const { className, value, placeholder, onKeyDown, onChange } = props;
const { className, value, placeholder, onKeyDown, onChange, ...rest } = props;

assertEmpty(rest);

return (
<Ariakit.FormProvider>
Expand Down
Loading
Loading