Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [Unreleased]

### Fixed (editor field: names, focus, panels, translations)

- **Names.** The editor of a field is a group named by the field label (as Strapi's Blocks field). Inline toolbar buttons are named after their tool, the component block switch after its attribute, and the repeated Accept, Reject, Edit, Reply, Resolve and Reopen buttons say whose comment or suggestion and which text they act on.
- **Inline toolbar by keyboard.** With text selected, Alt+F10 moves focus into the inline toolbar (as in the table and column tools), the arrow keys move between its buttons, and Escape goes back to the selected text. Escape in the link input returns to the text too. The shortcut timing (Ctrl/Cmd+I, U, Shift+M, K pressed within about 150 ms of selecting) is Editor.js behaviour: its inline tool shortcuts work only once the inline toolbar was built after the debounced selection change (Editor.js 2.31 `InlineToolbar.enableShortcuts`); it is left as is.
- **Focus.** After inserting a video, audio or attachment block, focus is on its Choose button. After the Media Library dialog (Confirm, Escape or Close), the caret is in the inserted image or back where the block was inserted. After posting a reply or cancelling an edit, after sending suggestions, after Replace and Replace all, after Check links and after a grammar check or fix, focus stays on a defined control. Cancel or Escape in the template replace and version restore confirmations returns to the button that opened them. The grammar panel takes focus, and Escape closes the quality, grammar, comments and suggestions panels also when the focused button shows its tooltip.
- **States.** A comments load error shows the error with Try again instead of read-only with zero counts. "No links were checked." replaces "Link check finished: no problems" when nothing was checked. The AI dialogs show their own messages for `UNREACHABLE`, `BAD_RESPONSE`, `RESPONSE_TOO_LARGE`, `EMPTY` and `PROVIDER_ERROR`.
- **Suggest mode.** More tools offers only the entries that work while suggesting (keyboard shortcuts); the others acted on the hidden field.
- **Presence.** Joining and leaving the entry is announced once per entry, not once per field.
- **Layout and dark mode.** A blocked person photo shows its Content Security Policy notice in its own row instead of the 72 px circle. Below 650 px the **+** and block menu handles use the DS surface and border (they were white in dark mode) and 32 px targets on phones; the bottom sheet's backdrop uses the DS overlay colour. The side panel's Check is a DS button. Native checkboxes, selects and inputs in blocks follow the admin theme (`color-scheme`), and the attachment download hover, the image tool, the loader and "Nothing found" no longer show Editor.js' light colours in dark mode.
- **Translations.** The indent block tune, the embed caption and attachment title placeholders and the code languages "Plain text" and "HTML and XML" are translated in all five admin languages.

## [2.8.2](https://github.com/Schero94/Magic-Editor-X/compare/v2.8.1...v2.8.2) (2026-11-20)


Expand Down
13 changes: 2 additions & 11 deletions admin/src/components/EditorField/AiDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useFetchClient } from '../../utils/fetch-client';
import { API, readApiError } from '../../utils/api';
import { changeViews } from '../../../../shared/ai-blocks.mjs';
import { TextOps } from './VersionDiff';
import { aiErrorEntry } from '../../editor/ai-errors.mjs';

/**
* AI assistant dialog: the admin picks an action for the selected text, the
Expand Down Expand Up @@ -45,16 +46,6 @@ const TONE_LABELS = {
persuasive: ['editor.ai.tone.persuasive', 'Persuasive'],
};

const ERROR_MESSAGES = {
DISABLED: ['editor.ai.error.disabled', 'The AI assistant is turned off.'],
NOT_CONFIGURED: ['editor.ai.error.notConfigured', 'The AI assistant is not configured yet.'],
NO_API_KEY: ['editor.ai.error.noKey', 'The AI provider key is missing.'],
AUTH_FAILED: ['editor.ai.error.auth', 'The AI provider rejected the key.'],
PROVIDER_RATE_LIMIT: ['editor.ai.error.busy', 'The AI provider is busy. Try again later.'],
TIMEOUT: ['editor.ai.error.timeout', 'The AI provider did not answer in time.'],
REFUSED: ['editor.ai.error.refused', 'The AI provider declined this request.'],
};

/**
* Plain text of an HTML snippet (inert parsing).
* @param {string} html - HTML.
Expand Down Expand Up @@ -103,7 +94,7 @@ export const AiDialog = ({ t, request, config, target, onApply, onClose, returnF
if (abort.current && abort.current.signal.aborted) return;
const info = readApiError(error);
const [key, text] =
ERROR_MESSAGES[info.code] ||
aiErrorEntry(info.code) ||
(info.status === 429
? ['editor.ai.error.rateLimit', 'You sent many requests. Try again in a minute.']
: info.status === 413
Expand Down
11 changes: 3 additions & 8 deletions admin/src/components/EditorField/BlockAiDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { sanitizeInline } from '../../editor/sanitize';
import { segmentPlainText } from '../../../../shared/ai-fields.mjs';
import { applyBlockResult, blockSegments, changeViews } from '../../../../shared/ai-blocks.mjs';
import { TextOps } from './VersionDiff';
import { aiErrorEntry } from '../../editor/ai-errors.mjs';

/**
* Block-aware AI actions (2.4): rewrite, shorten, translate or change the
Expand All @@ -44,14 +45,8 @@ const TONE_LABELS = {
persuasive: ['editor.ai.tone.persuasive', 'Persuasive'],
};

/** Codes this dialog words differently from the shared AI messages (`editor/ai-errors.mjs`). */
const ERROR_MESSAGES = {
DISABLED: ['editor.ai.error.disabled', 'The AI assistant is turned off.'],
NOT_CONFIGURED: ['editor.ai.error.notConfigured', 'The AI assistant is not configured yet.'],
NO_API_KEY: ['editor.ai.error.noKey', 'The AI provider key is missing.'],
AUTH_FAILED: ['editor.ai.error.auth', 'The AI provider rejected the key.'],
PROVIDER_RATE_LIMIT: ['editor.ai.error.busy', 'The AI provider is busy. Try again later.'],
TIMEOUT: ['editor.ai.error.timeout', 'The AI provider did not answer in time.'],
REFUSED: ['editor.ai.error.refused', 'The AI provider declined this request.'],
BAD_RESPONSE: ['editor.aiField.error.format', 'The answer had an unexpected format. Nothing changed.'],
};

Expand Down Expand Up @@ -164,7 +159,7 @@ export const BlockAiDialog = ({
if (abort.current && abort.current.signal.aborted) return;
const info = error && error.mismatch ? { code: 'BAD_RESPONSE' } : readApiError(error);
const [key, text] =
ERROR_MESSAGES[info.code] ||
aiErrorEntry(info.code, ERROR_MESSAGES) ||
(info.status === 429
? ['editor.ai.error.rateLimit', 'You sent many requests. Try again in a minute.']
: info.status === 413
Expand Down
104 changes: 92 additions & 12 deletions admin/src/components/EditorField/CommentThread.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { forwardRef, useState } from 'react';
import { forwardRef, useRef, useState } from 'react';
import { useIntl } from 'react-intl';
import { Badge, Box, Button, Flex, Typography } from '@strapi/design-system';
import styled from 'styled-components';
import { ConfirmAction } from '../ui/ConfirmAction';
import { MentionTextarea } from './MentionTextarea';
import { refocusLater } from './usePanelFocus';
import { normalizeExcerpt, relativeTimeParts } from '../../../../shared/comments.mjs';
import { mentionSegments } from '../../../../shared/comment-mentions.mjs';

Expand Down Expand Up @@ -87,6 +88,30 @@ const List = styled.ol`
gap: ${({ theme }) => theme.spaces[3]};
`;

/** Characters of a comment or quote in an action's accessible name (2.7.8). */
const NAME_EXCERPT = 40;

/**
* Short excerpt for accessible names of repeated actions ("Edit comment by Ben M.: First words…").
* @param {string|null|undefined} text - Comment body or quote.
* @returns {string} Excerpt.
*/
export const nameExcerpt = (text) => {
const plain = normalizeExcerpt(String(text || '').replace(/<[^>]*>/g, ' '));
return plain.length > NAME_EXCERPT ? `${plain.slice(0, NAME_EXCERPT - 1)}…` : plain;
};

/**
* Display name of a comment author.
* @param {object} comment - Comment.
* @param {Function} t - Translator.
* @returns {string} Name.
*/
const authorOf = (comment, t) =>
comment.author.deleted
? t('editor.comments.deletedUser', 'Deleted user')
: comment.author.name || t('editor.comments.deletedUser', 'Deleted user');

/**
* Author name, relative time (absolute time as tooltip) and "edited".
* @param {object} props - Props.
Expand All @@ -96,9 +121,7 @@ const List = styled.ol`
*/
const CommentMeta = ({ comment, t }) => {
const { formatRelativeTime, formatDate } = useIntl();
const name = comment.author.deleted
? t('editor.comments.deletedUser', 'Deleted user')
: comment.author.name || t('editor.comments.deletedUser', 'Deleted user');
const name = authorOf(comment, t);
const { value, unit } = relativeTimeParts(comment.createdAt);
const absolute = formatDate(comment.createdAt, { dateStyle: 'medium', timeStyle: 'short' });
return (
Expand Down Expand Up @@ -162,6 +185,9 @@ export const CommentThread = forwardRef(function CommentThread(
const [replyMentions, setReplyMentions] = useState([]);
const [editing, setEditing] = useState(null);
const [busy, setBusy] = useState(null);
// 2.7.8: focus targets after a reply is sent or cancelled and after an edit is saved or cancelled.
const replyButtonRef = useRef(null);
const editButtonsRef = useRef(new Map());
const resolved = thread.status === 'resolved';
// 2.4: a thread written under a positional path before 2.4 that belongs to no single entry (read-only).
const positional = Boolean(thread.positional);
Expand Down Expand Up @@ -198,6 +224,7 @@ export const CommentThread = forwardRef(function CommentThread(
setReply('');
setReplyMentions([]);
setReplying(false);
refocusLater(replyButtonRef);
announce(t('editor.comments.announce.replied', 'Reply added'));
} catch (error) {
fail(errorMessage(error));
Expand All @@ -211,7 +238,7 @@ export const CommentThread = forwardRef(function CommentThread(
setBusy(`edit:${editing.id}`);
try {
reportDropped(await actions.edit(editing.id, editing.value, editing.mentions));
setEditing(null);
stopEditing(editing.id);
announce(t('editor.comments.announce.saved', 'Comment saved'));
} catch (error) {
fail(errorMessage(error));
Expand All @@ -220,6 +247,24 @@ export const CommentThread = forwardRef(function CommentThread(
}
};

/** Leaves the edit box and puts focus back on the comment's Edit button. */
const stopEditing = (id) => {
setEditing(null);
refocusLater(() => editButtonsRef.current.get(id) || null);
};

/** Closes the reply box and puts focus back on Reply. */
const stopReplying = () => {
setReplying(false);
refocusLater(replyButtonRef);
};

const first = thread.comments[0] || null;
const threadName = {
name: first ? authorOf(first, t) : '',
excerpt: nameExcerpt(quote || (first ? first.body : '') || excerpt),
};

const toggleResolved = async () => {
if (busy) return;
setBusy('resolve');
Expand Down Expand Up @@ -377,7 +422,7 @@ export const CommentThread = forwardRef(function CommentThread(
onMentionsChange={(next) => setEditing((current) => ({ ...current, mentions: next }))}
search={searchMentions}
onSubmit={saveEdit}
onCancel={() => setEditing(null)}
onCancel={() => stopEditing(comment.id)}
t={t}
autoFocus
/>
Expand All @@ -390,7 +435,7 @@ export const CommentThread = forwardRef(function CommentThread(
>
{t('editor.comments.save', 'Save')}
</Button>
<Button size="S" variant="tertiary" onClick={() => setEditing(null)}>
<Button size="S" variant="tertiary" onClick={() => stopEditing(comment.id)}>
{t('editor.comments.cancel', 'Cancel')}
</Button>
</Flex>
Expand All @@ -406,6 +451,14 @@ export const CommentThread = forwardRef(function CommentThread(
<Button
variant="ghost"
size="S"
ref={(node) => {
if (node) editButtonsRef.current.set(comment.id, node);
else editButtonsRef.current.delete(comment.id);
}}
aria-label={t('editor.comments.editNamed', 'Edit comment by {name}: {excerpt}', {
name: authorOf(comment, t),
excerpt: nameExcerpt(comment.body),
})}
onClick={() =>
setEditing({
id: comment.id,
Expand All @@ -420,7 +473,18 @@ export const CommentThread = forwardRef(function CommentThread(
{canDelete ? (
<ConfirmAction
trigger={
<Button variant="ghost" size="S">
<Button
variant="ghost"
size="S"
aria-label={t(
'editor.comments.deleteNamed',
'Delete comment by {name}: {excerpt}',
{
name: authorOf(comment, t),
excerpt: nameExcerpt(comment.body),
}
)}
>
{t('editor.comments.delete', 'Delete')}
</Button>
}
Expand Down Expand Up @@ -474,25 +538,41 @@ export const CommentThread = forwardRef(function CommentThread(
onMentionsChange={setReplyMentions}
search={searchMentions}
onSubmit={sendReply}
onCancel={() => setReplying(false)}
onCancel={stopReplying}
t={t}
autoFocus
/>
<Flex gap={2} wrap="wrap">
<Button size="S" onClick={sendReply} loading={busy === 'reply'} disabled={!reply.trim()}>
{t('editor.comments.reply', 'Reply')}
</Button>
<Button size="S" variant="tertiary" onClick={() => setReplying(false)}>
<Button size="S" variant="tertiary" onClick={stopReplying}>
{t('editor.comments.cancel', 'Cancel')}
</Button>
</Flex>
</>
) : (
<Flex gap={2} wrap="wrap">
<Button size="S" variant="secondary" onClick={() => setReplying(true)}>
<Button
size="S"
variant="secondary"
ref={replyButtonRef}
aria-label={t('editor.comments.replyNamed', 'Reply to {name}: {excerpt}', threadName)}
onClick={() => setReplying(true)}
>
{t('editor.comments.reply', 'Reply')}
</Button>
<Button size="S" variant="tertiary" onClick={toggleResolved} loading={busy === 'resolve'}>
<Button
size="S"
variant="tertiary"
onClick={toggleResolved}
loading={busy === 'resolve'}
aria-label={
resolved
? t('editor.comments.reopenNamed', 'Reopen comment by {name}: {excerpt}', threadName)
: t('editor.comments.resolveNamed', 'Resolve comment by {name}: {excerpt}', threadName)
}
>
{resolved ? t('editor.comments.reopen', 'Reopen') : t('editor.comments.resolve', 'Resolve')}
</Button>
</Flex>
Expand Down
65 changes: 35 additions & 30 deletions admin/src/components/EditorField/CommentsPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { usePanelAutoFocus } from './usePanelFocus';
import { escapeBelongsInside, usePanelAutoFocus } from './usePanelFocus';
import {
Box,
Button,
Expand Down Expand Up @@ -263,7 +263,7 @@ export const CommentsPanel = ({
};

const onKeyDown = (event) => {
if (event.key !== 'Escape' || event.defaultPrevented) return;
if (event.key !== 'Escape' || escapeBelongsInside(event)) return;
const tag = event.target && event.target.tagName;
if (tag === 'TEXTAREA' || tag === 'INPUT') return;
if (
Expand Down Expand Up @@ -361,13 +361,15 @@ export const CommentsPanel = ({
<Typography variant="delta" tag="h3" id="mex-comments-title" ref={headingRef} tabIndex={-1}>
{t('editor.comments.title', 'Comments')}
</Typography>
<Typography variant="pi" textColor="neutral600" data-testid="mex-comments-summary">
{t(
'editor.comments.summary',
'{open, plural, one {# open thread} other {# open threads}} · {resolved} resolved',
{ open: counts.open, resolved: counts.resolved }
)}
</Typography>
{loaded ? (
<Typography variant="pi" textColor="neutral600" data-testid="mex-comments-summary">
{t(
'editor.comments.summary',
'{open, plural, one {# open thread} other {# open threads}} · {resolved} resolved',
{ open: counts.open, resolved: counts.resolved }
)}
</Typography>
) : null}
</Flex>
<IconButton label={t('editor.comments.close', 'Close comments')} variant="ghost" onClick={onClose}>
<Cross />
Expand Down Expand Up @@ -411,27 +413,30 @@ export const CommentsPanel = ({
</Box>
) : null}

<Flex gap={4} wrap="wrap" alignItems="center" justifyContent="space-between">
{canWrite ? (
<Button
ref={newButtonRef}
variant="secondary"
size="S"
startIcon={<Plus />}
onClick={startComposing}
disabled={composing || blocks.length === 0}
>
{t('editor.comments.new', 'Comment on a block')}
</Button>
) : (
<Typography variant="pi" textColor="neutral600">
{t('editor.comments.readOnly', 'You can read comments but not add any.')}
</Typography>
)}
<Checkbox checked={showResolved} onCheckedChange={(value) => setShowResolved(value === true)}>
{t('editor.comments.showResolved', 'Show resolved threads')}
</Checkbox>
</Flex>
{/* 2.7.8: before the first load (or when it failed) nothing is known about counts or rights. */}
{loaded ? (
<Flex gap={4} wrap="wrap" alignItems="center" justifyContent="space-between">
{canWrite ? (
<Button
ref={newButtonRef}
variant="secondary"
size="S"
startIcon={<Plus />}
onClick={startComposing}
disabled={composing || blocks.length === 0}
>
{t('editor.comments.new', 'Comment on a block')}
</Button>
) : (
<Typography variant="pi" textColor="neutral600">
{t('editor.comments.readOnly', 'You can read comments but not add any.')}
</Typography>
)}
<Checkbox checked={showResolved} onCheckedChange={(value) => setShowResolved(value === true)}>
{t('editor.comments.showResolved', 'Show resolved threads')}
</Checkbox>
</Flex>
) : null}

{canWrite && blocks.length === 0 ? (
<Typography variant="pi" textColor="neutral600">
Expand Down
Loading