-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
Implement StructTree, improve accessibility #1498
Implement StructTree, improve accessibility #1498
Conversation
Still unsure why but downgrading Vitest to 0.28.5 allows me to run the tests. |
821fc8b
to
8a3f437
Compare
@wojtekmaj The only concern I have with this is the custom text renderer. There is no longer a direct mapping between textContent and the dom. We could call What are your thoughts on this? One option would be to look for the matching text in the DOM, though that would be much slower than the current implementation. |
8a3f437
to
31db4e3
Compare
expect(textItems).toHaveLength(desiredTextItems.length + 1); | ||
}); | ||
|
||
it('maps textContent items to actual TextLayer children properly', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I feel this test is pointless now as there is no longer a direct mapping between customTextRender and normal.
src/Page/TextLayer.tsx
Outdated
@@ -184,7 +184,7 @@ export default function TextLayer() { | |||
|
|||
layer.innerHTML = ''; | |||
|
|||
const textContentSource = page.streamTextContent(); | |||
const textContentSource = page.streamTextContent({ includeMarkedContent: !customTextRenderer }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solution to the customTextRenderer problem. No change of behaviour if you use a custom render function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's "customTextRenderer problem"? The fact one could render text items and remove some properties in the process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well previously the custom text renderer had a 1-to-1 ratio of elements to text content. Now it's a bit different as the structure has more nested stuff within. I think the safest option is to just disable the accessibility layer if there is a custom renderer
31db4e3
to
19a52b7
Compare
@wojtekmaj Any thoughts on this? :) |
a2d7164
to
df1e2c8
Compare
I refactored the code a bit to ensure type safety and to use useResolver which allows me to handle async loading more gracefully. I'm still not certain about a few things, please see my comments :) |
8af7185
to
1666dae
Compare
TODO:
|
imo rendering struct tree without text layer is a bit pointless anyways. It could add a bit of context to some stuff like images. Honestly though if you're disabling the text layer you probably don't care much about making the document accessible |
Not really about "care"/"not care" - but e.g. we have incoming #1519 :) |
bcf9c37
to
5a14f71
Compare
aca8fa4
to
ec57559
Compare
Phew, made it work in all cases, brought back the tests, everything looks pretty good in my opinion :D I know it's silly but can I ask YOU for a review now? 😂 Especially the screen reader with and without custom text renderer. |
Let's goooo! |
@wojtekmaj Here is my rough proof-of-concept. I am having trouble getting Vitest to run. It seems to hang forever so I cannot run nor write unit tests at the moment :/
Adds accessible semantics to the canvas. Screen readers can now get great information for semantic elements such as lists.
Tested to work with Voiceover on mac.