Skip to content

Commit

Permalink
Merge branch 'main' into screenreader-page-change
Browse files Browse the repository at this point in the history
  • Loading branch information
ichim-david authored Oct 29, 2024
2 parents 30d3a4f + ee3c972 commit 49b5d7e
Show file tree
Hide file tree
Showing 29 changed files with 340 additions and 130 deletions.
5 changes: 5 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ The recommended way of generating a project boilerplate is [Cookieplone](https:/
Please update your code to use the `pnpm` based setup.
```

### Table of Contents block markup change

The `View` component for the Table of Contents block was updated to use a `nav` element instead of a `div`.
If you've applied custom styles or shadowed this component, you might need to make adjustments.

### Update needed to project boilerplate generated with `@plone/generator-volto`

```{versionadded} Volto 18.0.0-alpha.42
Expand Down
1 change: 1 addition & 0 deletions packages/types/news/6445.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`StyleDefinitions` in types. @sneridagh
12 changes: 12 additions & 0 deletions packages/types/src/blocks/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,15 @@ export interface BlockEditProps {
errors: Record<string, Array<string>>;
blocksErrors: Record<string, Record<string, Array<string>>>;
}

export type StyleDefinition =
| {
name: string;
label: string;
style: Record<`--${string}`, string>;
}
| {
name: string;
label: string;
style: undefined;
};
3 changes: 3 additions & 0 deletions packages/types/src/config/Blocks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import type { Content } from '../content';
import type { BlockViewProps, BlockEditProps } from '../blocks';
import type { IntlShape } from 'react-intl';
import { User } from '../services';
import { StyleDefinition } from '../blocks';

export interface BlocksConfig {
blocksConfig: BlocksConfigData;
groupBlocksOrder: { id: string; title: string };
requiredBlocks: string[];
initialBlocks: Record<string, string[]> | Record<string, object[]>;
initialBlocksFocus: Record<string, string>;
themes: StyleDefinition[];
widths: StyleDefinition[];
}

export interface BlocksConfigData {
Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ca/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3622,8 +3622,7 @@ msgid "Table"
msgstr "Taula"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Taula de continguts"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3621,8 +3621,7 @@ msgid "Table"
msgstr "Tabelle"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Inhaltsverzeichnis"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3616,8 +3616,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3623,8 +3623,7 @@ msgid "Table"
msgstr "Tabla"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Tabla de contenidos"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3623,8 +3623,7 @@ msgid "Table"
msgstr "Taula"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Edukien taula"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/fi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3621,8 +3621,7 @@ msgid "Table"
msgstr "Taulukkoa"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Sisällys"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3623,8 +3623,7 @@ msgid "Table"
msgstr "Table"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Table des matières"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/hi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3616,8 +3616,7 @@ msgid "Table"
msgstr "तालिका"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "सारांश की तालिका"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3616,8 +3616,7 @@ msgid "Table"
msgstr "Tabella"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Indice dei contenuti"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ja/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3621,8 +3621,7 @@ msgid "Table"
msgstr "テーブル"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "目次"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/nl/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3620,8 +3620,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/pt/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3621,8 +3621,7 @@ msgid "Table"
msgstr "Tabela"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3622,8 +3622,7 @@ msgid "Table"
msgstr "Tabela"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Tabela de conteúdos"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ro/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3616,8 +3616,7 @@ msgid "Table"
msgstr "Tabel"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Cuprins"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/volto.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3618,8 +3618,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/zh_CN/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3622,8 +3622,7 @@ msgid "Table"
msgstr "表格"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "表格内容"

Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6082.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap Table of Contents block in a `nav` tag, instead of a `div` tag, for better representation improving the block accessibility. @Tishasoumya-02 @ichim-david
1 change: 1 addition & 0 deletions packages/volto/news/6445.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enhance the `buildStyleObjectFromData` helper. @sneridagh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const EditBlockWrapper = (props) => {
data,
classNames,
});
const style = buildStyleObjectFromData(data.styles);
const style = buildStyleObjectFromData(data);

// We need to merge the StyleWrapper styles with the draggable props from b-D&D
const styleMergedWithDragProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const StyleWrapper = (props) => {
classNames,
});

style = buildStyleObjectFromData(data.styles);
style = buildStyleObjectFromData(data);

const rewrittenChildren = React.Children.map(children, (child) => {
if (React.isValidElement(child)) {
Expand Down
25 changes: 18 additions & 7 deletions packages/volto/src/components/manage/Blocks/ToC/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* View toc block.
* @module components/manage/Blocks/ToC/View
*/

import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl } from 'react-intl';
import { FormattedMessage } from 'react-intl';
import cx from 'classnames';
import { Message } from 'semantic-ui-react';
import config from '@plone/volto/registry';
Expand Down Expand Up @@ -86,6 +85,8 @@ export const getBlocksTocEntries = (properties, tocData) => {
*/
const View = (props) => {
const { data } = props;

const title = data.title ? data.title : '';
const { variation } = props;
const metadata = props.metadata || props.properties;
const blocksFieldname = getBlocksFieldname(metadata);
Expand Down Expand Up @@ -165,17 +166,27 @@ const View = (props) => {

const Renderer = variation?.view;
return (
<div className={cx('table-of-contents', variation?.id)}>
{props.mode === 'edit' && !data.title && !tocEntries.length && (
<Message>Table of content</Message>
<nav
aria-label={title && !data.hide_title ? title : ''}
className={cx('table-of-contents', variation?.id)}
>
{props.mode === 'edit' && !title && !tocEntries.length && (
<Message>
{
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
}
</Message>
)}

{Renderer ? (
<Renderer {...props} tocEntries={tocEntries} metadata={metadata} />
) : (
<div>View extension not found</div>
)}
</div>
</nav>
);
};

Expand All @@ -188,4 +199,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(withBlockExtensions(View));
export default withBlockExtensions(View);
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
* @module components/manage/Blocks/ToC/View
*/

import React from 'react';
import PropTypes from 'prop-types';
import { map } from 'lodash';
import { List } from 'semantic-ui-react';
import { FormattedMessage, injectIntl } from 'react-intl';
import Slugger from 'github-slugger';
import { UniversalLink } from '@plone/volto/components';
import { normalizeString } from '@plone/volto/helpers';
Expand Down Expand Up @@ -45,18 +43,7 @@ const RenderListItems = ({ items, data }) => {
const View = ({ data, tocEntries }) => {
return (
<>
{data.title && !data.hide_title ? (
<h2>
{data.title || (
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
)}
</h2>
) : (
''
)}
{data.title && !data.hide_title ? <h2>{data.title}</h2> : ''}
<List
ordered={data.ordered}
bulleted={!data.ordered}
Expand All @@ -77,4 +64,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(View);
export default View;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { map } from 'lodash';
import { Menu, Dropdown } from 'semantic-ui-react';
import { FormattedMessage, injectIntl } from 'react-intl';
import AnchorLink from 'react-anchor-link-smooth-scroll';
import Slugger from 'github-slugger';
import { normalizeString } from '@plone/volto/helpers';
Expand Down Expand Up @@ -159,18 +158,7 @@ const View = ({ data, tocEntries }) => {

return (
<>
{data.title && !data.hide_title ? (
<h2>
{data.title || (
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
)}
</h2>
) : (
''
)}
{data.title && !data.hide_title ? <h2>{data.title}</h2> : ''}
<Menu className="responsive-menu">
<RenderMenuItems items={tocEntries} />
<Dropdown
Expand Down Expand Up @@ -201,4 +189,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(View);
export default View;
Loading

0 comments on commit 49b5d7e

Please sign in to comment.