Skip to content

Commit a6ec88f

Browse files
committed
feat: add ARIA support and keyboard navigation for dropdowns
1 parent 819411d commit a6ec88f

6 files changed

Lines changed: 1790 additions & 54 deletions

File tree

example/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { Editium } from 'editium';
2+
import { Editium } from '../../react';
33
import Installation from './Installation';
44
import Footer from './Footer';
55

react/Editium.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,9 @@ const Editium: React.FC<EditiumProps> = ({
357357
const { attributes, children, element } = props;
358358
const style = { margin: '0', fontWeight: 'normal' };
359359
const alignStyle = (element as CustomElement).align ? {
360-
textAlign: (element as CustomElement).align as 'left' | 'center' | 'right' | 'justify'
361-
} : {};
360+
textAlign: (element as CustomElement).align as 'left' | 'center' | 'right' | 'justify',
361+
width: '100%'
362+
} : { width: '100%' };
362363
const combinedStyle = { ...style, ...alignStyle };
363364

364365
switch ((element as CustomElement | LinkElement).type) {
@@ -568,6 +569,9 @@ const Editium: React.FC<EditiumProps> = ({
568569
backgroundColor: '#fff',
569570
position: 'relative',
570571
overflow: 'auto',
572+
width: '100%',
573+
maxWidth: '100%',
574+
boxSizing: 'border-box',
571575
...style,
572576
};
573577

@@ -604,6 +608,10 @@ const Editium: React.FC<EditiumProps> = ({
604608
position: relative;
605609
min-height: inherit;
606610
height: 100%;
611+
width: 100%;
612+
max-width: 100%;
613+
overflow-x: hidden;
614+
box-sizing: border-box;
607615
}
608616
609617
/* Custom scrollbar styling for better UX */
@@ -630,12 +638,15 @@ const Editium: React.FC<EditiumProps> = ({
630638
opacity: 0.333;
631639
pointer-events: none;
632640
user-select: none;
633-
display: inline-block !important;
641+
display: block !important;
634642
width: 100%;
635643
max-width: 100%;
636-
white-space: nowrap;
644+
white-space: pre-wrap;
637645
margin: 0 !important;
638646
vertical-align: text-top;
647+
position: absolute;
648+
top: 0;
649+
left: 0;
639650
}
640651
641652
[data-slate-editor] p,
@@ -646,6 +657,8 @@ const Editium: React.FC<EditiumProps> = ({
646657
[data-slate-editor] h5,
647658
[data-slate-editor] h6 {
648659
position: relative;
660+
width: 100%;
661+
box-sizing: border-box;
649662
}
650663
651664
[data-slate-editor] [contenteditable="true"] {

0 commit comments

Comments
 (0)