From 770419092c51c95a0b484a1ff8a4c48360be7aaa Mon Sep 17 00:00:00 2001 From: "Ikenga Ifeanyi .M." Date: Sat, 27 Jun 2026 15:12:18 +0100 Subject: [PATCH 1/2] Improve post editor accessibility --- src/app/editor/EditorWorkspace.tsx | 49 ++++++++++++++----- .../editor/ContentTemplateLibrary.tsx | 11 +++-- src/components/editor/MediaEmbedder.tsx | 14 ++++-- src/components/editor/RichContentEditor.tsx | 31 +++++++++--- src/hooks/useContentEditor.tsx | 19 ++++++- 5 files changed, 96 insertions(+), 28 deletions(-) diff --git a/src/app/editor/EditorWorkspace.tsx b/src/app/editor/EditorWorkspace.tsx index 9a2fc4e5..68a1fa53 100644 --- a/src/app/editor/EditorWorkspace.tsx +++ b/src/app/editor/EditorWorkspace.tsx @@ -1,6 +1,6 @@ 'use client'; -import React, { useState } from 'react'; +import React, { useId, useState } from 'react'; import dynamic from 'next/dynamic'; import { sanitizeHtml } from '@/utils/sanitize'; @@ -17,16 +17,29 @@ const RichContentEditor = dynamic( export function EditorWorkspace() { const [content, setContent] = useState('

Start editing...

'); const [isPreviewMode, setIsPreviewMode] = useState(false); + const workspaceTitleId = useId(); + const editorPanelId = useId(); + const previewPanelId = useId(); + const editorHelpId = useId(); + const liveRegionId = useId(); return ( -
-
-

- Advanced Content Editor Demo -

+
+
+
+

+ Post Editor +

+

+ Create accessible post content with keyboard-friendly formatting controls and a preview + mode for reviewing published output. +

+
+

+ {isPreviewMode ? 'Preview mode is active.' : 'Editor mode is active.'} +

+ {isPreviewMode ? ( -
+
-
+
) : ( -
+
-
+ )} -
+
); } diff --git a/src/components/editor/ContentTemplateLibrary.tsx b/src/components/editor/ContentTemplateLibrary.tsx index 53929e89..33180bbb 100644 --- a/src/components/editor/ContentTemplateLibrary.tsx +++ b/src/components/editor/ContentTemplateLibrary.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useId } from 'react'; import { BookOpen, Layout, ListChecks, FileVideo } from 'lucide-react'; import { Editor } from '@tiptap/react'; import { TEMPLATES, insertTemplate } from '@/utils/editorUtils'; @@ -8,6 +8,8 @@ interface ContentTemplateLibraryProps { } export const ContentTemplateLibrary: React.FC = ({ editor }) => { + const headingId = useId(); + if (!editor) return null; const getIcon = (id: string) => { @@ -27,10 +29,13 @@ export const ContentTemplateLibrary: React.FC = ({ return (