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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [Unreleased]

### Changed (editor field: native Strapi look)

- **Strapi Design System icons in the editor.** Block types, block menus and tool buttons use @strapi/icons where an equivalent exists (code, image, gallery, video, audio, link, Media Library, person, table, component, copy, delete, add, upload, check, colour, AI, underline, strikethrough, arrows, warning, table of contents); the editor-specific shapes (alignment, columns, borders, merge and split, sub- and superscript) keep their own icons.
- **Undo and redo** use one DS arrow, mirrored for undo (the two-arrow icon read as "refresh"). @strapi/icons has no undo or redo icon.
- **Version history** uses the DS underlined tabs (`variant="simple"`, as the Content Manager's Draft and Published tabs).
- **Comment and suggestion markers** show a DS tooltip instead of the browser's `title`.
- **Annotation Apply** uses the DS primary button colours in both themes.
- **Full screen** keeps Tab inside the editor (it is a modal dialog), like the DS focus trap.
- **Code font.** The Design System theme has no font tokens; the shortcut help and the preview read a plugin constant instead of the undefined `theme.fonts.code`.

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


Expand Down
32 changes: 18 additions & 14 deletions admin/src/components/EditorField/CommentMarkers.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLayoutEffect, useRef, useState } from 'react';
import { Discuss } from '@strapi/icons';
import { Tooltip } from '@strapi/design-system';
import styled from 'styled-components';

/**
Expand Down Expand Up @@ -114,26 +115,29 @@ export const CommentMarkers = ({ containerRef, holderRef, counts, blockIds, vers
return (
<Layer data-testid="mex-comment-markers">
{positions.map(({ blockId, count, top, index }) => (
<Marker
<Tooltip
key={blockId}
type="button"
style={{ top }}
data-block-id={blockId}
aria-label={t(
label={t(
'editor.comments.marker',
'Block {index}: {count, plural, one {# open comment thread} other {# open comment threads}}',
{ index: index + 1, count }
)}
title={t(
'editor.comments.marker',
'Block {index}: {count, plural, one {# open comment thread} other {# open comment threads}}',
{ index: index + 1, count }
)}
onClick={() => onOpen(blockId)}
>
<Discuss aria-hidden="true" focusable="false" />
<span aria-hidden="true">{count > 99 ? '99+' : count}</span>
</Marker>
<Marker
type="button"
style={{ top }}
data-block-id={blockId}
aria-label={t(
'editor.comments.marker',
'Block {index}: {count, plural, one {# open comment thread} other {# open comment threads}}',
{ index: index + 1, count }
)}
onClick={() => onOpen(blockId)}
>
<Discuss aria-hidden="true" focusable="false" />
<span aria-hidden="true">{count > 99 ? '99+' : count}</span>
</Marker>
</Tooltip>
))}
</Layer>
);
Expand Down
7 changes: 4 additions & 3 deletions admin/src/components/EditorField/EditorToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
Typography,
VisuallyHidden,
} from '@strapi/design-system';
import { ArrowClockwise, ArrowsCounterClockwise, Collapse, Expand } from '@strapi/icons';
import { Collapse, Expand } from '@strapi/icons';
import { RedoIcon, UndoIcon } from './icons';
import styled from 'styled-components';
import { FieldToolsMenu } from './FieldToolsMenu';
import { exitTools } from '../../editor/field-tools.mjs';
Expand Down Expand Up @@ -136,15 +137,15 @@ export const EditorToolbar = ({
onClick={onUndo}
disabled={!ready || !canUndo}
>
<ArrowsCounterClockwise />
<UndoIcon />
</IconButton>
<IconButton
label={t('editor.toolbar.redo', 'Redo')}
variant="ghost"
onClick={onRedo}
disabled={!ready || !canRedo}
>
<ArrowClockwise />
<RedoIcon />
</IconButton>
</>
)}
Expand Down
2 changes: 2 additions & 0 deletions admin/src/components/EditorField/HistoryModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ export const HistoryModal = ({
<Box marginTop={3} padding={3} background="neutral100" hasRadius minWidth={0}>
{preview.content ? (
<Tabs.Root
// 2.7.8: the underlined DS variant, as the Content Manager's Draft/Published tabs.
variant="simple"
value={tab}
onValueChange={(value) => (value === 'changes' ? showChanges() : setTab('preview'))}
>
Expand Down
3 changes: 2 additions & 1 deletion admin/src/components/EditorField/ShortcutsDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, Button, Flex, Modal, Typography } from '@strapi/design-system';
import styled from 'styled-components';
import { shortcutKeyName } from '../../editor/field-tools.mjs';
import { CODE_FONT } from '../../editor/code-font.mjs';

/**
* Keyboard shortcut help (Ctrl/Cmd + Alt + /; 2.7.8: Ctrl/Cmd + / opens the Editor.js block menu). Lists the editor's own shortcuts,
Expand All @@ -9,7 +10,7 @@ import { shortcutKeyName } from '../../editor/field-tools.mjs';

const Keys = styled.kbd`
display: inline-block;
font-family: ${({ theme }) => theme.fonts?.code || 'monospace'};
font-family: ${CODE_FONT};
font-size: ${({ theme }) => theme.fontSizes[1]};
color: ${({ theme }) => theme.colors.neutral800};
background: ${({ theme }) => theme.colors.neutral100};
Expand Down
6 changes: 3 additions & 3 deletions admin/src/components/EditorField/SuggestEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Textarea,
Typography,
} from '@strapi/design-system';
import { ArrowClockwise, ArrowsCounterClockwise } from '@strapi/icons';
import { RedoIcon, UndoIcon } from './icons';
import styled from 'styled-components';
import { buildTools, disposeTools, editorI18n, createUndoManager, INLINE_TOOLS } from '../../editor/tools';
import { prepareEditorValue } from '../../editor/sanitize';
Expand Down Expand Up @@ -364,15 +364,15 @@ export const SuggestEditor = ({
onClick={() => undoRef.current && undoRef.current.undo()}
disabled={!ready || !undoState.canUndo}
>
<ArrowsCounterClockwise />
<UndoIcon />
</IconButton>
<IconButton
label={t('editor.toolbar.redo', 'Redo')}
variant="ghost"
onClick={() => undoRef.current && undoRef.current.redo()}
disabled={!ready || !undoState.canRedo}
>
<ArrowClockwise />
<RedoIcon />
</IconButton>
{pending ? (
<ConfirmAction
Expand Down
34 changes: 19 additions & 15 deletions admin/src/components/EditorField/SuggestionMarkers.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLayoutEffect, useRef, useState } from 'react';
import { Lightbulb } from '@strapi/icons';
import { Tooltip } from '@strapi/design-system';
import styled from 'styled-components';

/**
Expand Down Expand Up @@ -132,27 +133,30 @@ export const SuggestionMarkers = ({
return (
<Layer data-testid="mex-suggestion-markers">
{positions.map(({ blockId, count, top, index, besideComment }) => (
<Marker
<Tooltip
key={blockId}
$beside={besideComment}
type="button"
style={{ top }}
data-block-id={blockId}
aria-label={t(
label={t(
'editor.suggestions.marker',
'Block {index}: {count, plural, one {# open suggestion} other {# open suggestions}}',
{ index: index + 1, count }
)}
title={t(
'editor.suggestions.marker',
'Block {index}: {count, plural, one {# open suggestion} other {# open suggestions}}',
{ index: index + 1, count }
)}
onClick={() => onOpen(blockId)}
>
<Lightbulb aria-hidden="true" focusable="false" />
<span aria-hidden="true">{count > 99 ? '99+' : count}</span>
</Marker>
<Marker
$beside={besideComment}
type="button"
style={{ top }}
data-block-id={blockId}
aria-label={t(
'editor.suggestions.marker',
'Block {index}: {count, plural, one {# open suggestion} other {# open suggestions}}',
{ index: index + 1, count }
)}
onClick={() => onOpen(blockId)}
>
<Lightbulb aria-hidden="true" focusable="false" />
<span aria-hidden="true">{count > 99 ? '99+' : count}</span>
</Marker>
</Tooltip>
))}
</Layer>
);
Expand Down
13 changes: 13 additions & 0 deletions admin/src/components/EditorField/icons.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ArrowClockwise } from '@strapi/icons';
import styled from 'styled-components';

/**
* Undo and redo icons (2.7.8). @strapi/icons 2.3 has no undo or redo icon. Redo is
* `ArrowClockwise`; undo is the same icon mirrored, so the pair reads as back and forward (the
* two-arrow `ArrowsCounterClockwise` used before read as "refresh").
*/
export const UndoIcon = styled(ArrowClockwise)`
transform: scaleX(-1);
`;

export const RedoIcon = ArrowClockwise;
30 changes: 30 additions & 0 deletions admin/src/components/EditorField/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1667,12 +1667,42 @@ const EditorFieldBody = ({
setFocusMode(false);
}
};
// 2.7.8: Tab stays inside the full screen editor (role="dialog", aria-modal), the way the DS
// FocusTrap wraps focus: from the last stop to the first and back. Dialogs opened from the
// editor live in their own portal and trap focus themselves.
const onTab = (event) => {
const frame = frameRef.current;
if (event.key !== 'Tab' || event.defaultPrevented || !frame || !frame.contains(document.activeElement))
return;
const stops = Array.from(
frame.querySelectorAll(
'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable="true"]'
)
).filter(
(element) => element.getClientRects().length > 0 && !element.closest('[inert], [aria-hidden="true"]')
);
if (!stops.length) return;
const first = stops[0];
const last = stops[stops.length - 1];
const active = document.activeElement;
if (!event.shiftKey && (active === last || last.contains(active))) {
event.preventDefault();
event.stopPropagation();
first.focus();
} else if (event.shiftKey && (active === first || first.contains(active))) {
event.preventDefault();
event.stopPropagation();
last.focus();
}
};
window.addEventListener('keydown', onTab, true);
const previous = document.body.style.overflow;
document.body.style.overflow = 'hidden';
document.addEventListener('keydown', onKey);
return () => {
document.body.style.overflow = previous;
document.removeEventListener('keydown', onKey);
window.removeEventListener('keydown', onTab, true);
};
}, [fullscreen]);

Expand Down
3 changes: 2 additions & 1 deletion admin/src/components/RenderedContent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MagicEditorXContent } from '../../../../shared/frameworks/react.mjs';
import { sanitizeRawPreview } from './sanitize-raw';
import { loadMath } from '../../editor/math-view';
import { MATH_ATTRIBUTE } from '../../../../shared/sanitize-policy.mjs';
import { CODE_FONT } from '../../editor/code-font.mjs';

/**
* Rendered output of Magic Editor X content inside the admin (field preview,
Expand Down Expand Up @@ -214,7 +215,7 @@ const Prose = styled.div`
}
& pre,
& code {
font-family: ${({ theme }) => (theme.fonts && theme.fonts.code) || 'monospace'};
font-family: ${CODE_FONT};
font-size: ${({ theme }) => theme.fontSizes[1]};
overflow-wrap: normal;
}
Expand Down
6 changes: 6 additions & 0 deletions admin/src/editor/code-font.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Monospace font stack for code in the admin (2.7.8). The Strapi Design System 2.3 theme has no
* font tokens (`theme.fonts` does not exist; the DS sets only the body font globally), so the
* plugin keeps one stack here instead of reading an undefined `theme.fonts.code`.
*/
export const CODE_FONT = "'SFMono-Regular', Menlo, Consolas, monospace";
Loading