Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(markdown-editor): give the editor contenteditable an accessible name

Sergey Kozyrenkobfd5b9d42f1c
diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-field.tsx b/frontend/src/components/shared/markdown-editor/markdown-editor-field.tsx
index 58a38978..64bd769b 100644
--- a/frontend/src/components/shared/markdown-editor/markdown-editor-field.tsx
+++ b/frontend/src/components/shared/markdown-editor/markdown-editor-field.tsx
@@ -27,7 +27,7 @@ export interface MarkdownEditorFieldHandle {
selectNextUse: (variable: string) => boolean;
}
-interface MarkdownEditorFieldProps extends Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> {
+interface MarkdownEditorFieldProps extends Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid' | 'aria-label'> {
className?: string;
disabled?: boolean;
id?: string;
@@ -42,6 +42,7 @@ interface MarkdownEditorFieldProps extends Pick<AriaAttributes, 'aria-describedb
export function MarkdownEditorField({
'aria-describedby': ariaDescribedby,
'aria-invalid': ariaInvalid,
+ 'aria-label': ariaLabel,
className,
disabled,
id,
@@ -86,6 +87,7 @@ export function MarkdownEditorField({
<Textarea
aria-describedby={ariaDescribedby}
aria-invalid={ariaInvalid}
+ aria-label={ariaLabel}
autoSize={false}
// Raw config is applied LAST so a consumer `className` can't override the byte-exact source styling.
className={cn(boxClassName, 'aria-invalid:border-destructive resize-none font-mono text-sm')}
@@ -107,6 +109,7 @@ export function MarkdownEditorField({
aria-busy="true"
aria-describedby={ariaDescribedby}
aria-invalid={ariaInvalid}
+ aria-label={ariaLabel}
className={cn(
MARKDOWN_EDITOR_WRAPPER_CLASS,
'items-center justify-center',
@@ -122,6 +125,7 @@ export function MarkdownEditorField({
<MarkdownEditor
aria-describedby={ariaDescribedby}
aria-invalid={ariaInvalid}
+ aria-label={ariaLabel}
className={boxClassName}
disabled={disabled}
id={id}
diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor.tsx b/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
index 83cb5c03..857d4aa4 100644
--- a/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
+++ b/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
@@ -27,6 +27,7 @@ export interface MarkdownEditorHandle {
interface MarkdownEditorProps {
'aria-describedby'?: string;
'aria-invalid'?: AriaAttributes['aria-invalid'];
+ 'aria-label'?: AriaAttributes['aria-label'];
className?: string;
disabled?: boolean;
id?: string;
@@ -36,7 +37,7 @@ interface MarkdownEditorProps {
value: string;
}
-interface UseMarkdownEditorOptions extends Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> {
+interface UseMarkdownEditorOptions extends Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid' | 'aria-label'> {
disabled?: boolean;
handleRef?: Ref<MarkdownEditorHandle>;
id?: string;
@@ -85,6 +86,7 @@ export const resetUndoHistory = (editor: Editor): void => {
function MarkdownEditor({
'aria-describedby': ariaDescribedby,
'aria-invalid': ariaInvalid,
+ 'aria-label': ariaLabel,
className,
disabled,
id,
@@ -97,6 +99,7 @@ function MarkdownEditor({
const editor = useMarkdownEditor({
'aria-describedby': ariaDescribedby,
'aria-invalid': ariaInvalid,
+ 'aria-label': ariaLabel,
disabled,
handleRef: ref,
id,
@@ -154,6 +157,7 @@ function MarkdownEditor({
function useMarkdownEditor({
'aria-describedby': ariaDescribedby,
'aria-invalid': ariaInvalid,
+ 'aria-label': ariaLabel,
disabled,
handleRef,
id,
@@ -317,6 +321,7 @@ function useMarkdownEditor({
for (const [name, attribute] of Object.entries({
'aria-describedby': ariaDescribedby,
'aria-invalid': ariaInvalid,
+ 'aria-label': ariaLabel,
id,
})) {
if (attribute === undefined) {
@@ -325,7 +330,7 @@ function useMarkdownEditor({
dom.setAttribute(name, String(attribute));
}
}
- }, [editor, ariaDescribedby, ariaInvalid, id]);
+ }, [editor, ariaDescribedby, ariaInvalid, ariaLabel, id]);
return editor;
}
diff --git a/frontend/src/features/knowledges/knowledge-form-controls.tsx b/frontend/src/features/knowledges/knowledge-form-controls.tsx
index 64d14298..e7cb322d 100644
--- a/frontend/src/features/knowledges/knowledge-form-controls.tsx
+++ b/frontend/src/features/knowledges/knowledge-form-controls.tsx
@@ -96,6 +96,7 @@ export function KnowledgeContentField({
{hasLabel ? <FormLabel>Content</FormLabel> : null}
<FormControl>
<MarkdownEditorField
+ aria-label="Content"
disabled={isSaving}
mode={viewMode}
onBlur={field.onBlur}
diff --git a/frontend/src/pages/settings/settings-prompt.tsx b/frontend/src/pages/settings/settings-prompt.tsx
index 0fcb6e09..a4c44c58 100644
--- a/frontend/src/pages/settings/settings-prompt.tsx
+++ b/frontend/src/pages/settings/settings-prompt.tsx
@@ -93,6 +93,7 @@ const humanFormSchema = z.object({
});
interface FormMarkdownItemProps<T extends FieldValues> {
+ 'aria-label'?: string;
control: Control<T>;
disabled?: boolean;
editorRef?: Ref<MarkdownEditorFieldHandle>;
@@ -235,6 +236,7 @@ function DiffContent({ control, oldValue, styles }: DiffContentProps) {
}
function FormMarkdownItem<T extends FieldValues>({
+ 'aria-label': ariaLabel,
control,
disabled,
editorRef,
@@ -255,6 +257,7 @@ function FormMarkdownItem<T extends FieldValues>({
<FormItem className="flex min-h-0 flex-1 flex-col">
<FormControl>
<MarkdownEditorField
+ aria-label={ariaLabel}
disabled={disabled}
mode={mode}
onBlur={field.onBlur}
@@ -848,6 +851,7 @@ function SettingsPrompt() {
onSubmit={systemForm.handleSubmit(handleSystemSubmit)}
>
<FormMarkdownItem
+ aria-label="System prompt template"
control={systemForm.control}
disabled={isLoading}
editorRef={editorRef}
@@ -872,6 +876,7 @@ function SettingsPrompt() {
onSubmit={humanForm.handleSubmit(handleHumanSubmit)}
>
<FormMarkdownItem
+ aria-label="Human prompt template"
control={humanForm.control}
disabled={isLoading}
editorRef={editorRef}
diff --git a/frontend/src/pages/templates/template.tsx b/frontend/src/pages/templates/template.tsx
index 180ff67b..cc2ee845 100644
--- a/frontend/src/pages/templates/template.tsx
+++ b/frontend/src/pages/templates/template.tsx
@@ -672,6 +672,7 @@ function Template() {
<FormItem className="flex min-h-0 flex-1 flex-col">
<FormControl>
<MarkdownEditorField
+ aria-label="Template content"
disabled={isSaving}
mode={viewMode}
onBlur={field.onBlur}