Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into quote-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaspiterek committed Feb 26, 2024
2 parents 0752457 + 5d4d45c commit 8186303
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 55 deletions.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ This option will enable an image and an alignment widget in the block settings,
config.blocks.blocksConfig.quote.showImageField = true;
```

#### `defaultLang`

This option will set the default language in which the quotation marks should be shown. By default this option is set to `EN`.

```js
config.blocks.blocksConfig.quote.defaultLang = 'EN';
```

#### `allowedLanguages`

This option will set the languages that are available to show the . By default this option is set to `['EN', 'DE']`.

```js
config.blocks.blocksConfig.quote.allowedLanguages = ['EN', 'DE'];
```

Currently available languages: EN, DE

## Credits

<img alt="Deutsches Zentrum für Luft- und Raumfahrt (DLR)" width="200px" src="https://www.dlr.de/static/media/Logo-de.697a8e1f.svg" style="background-color:white">
Expand Down
2 changes: 1 addition & 1 deletion locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ msgstr "Zitat"
#: components/schema
# defaultMessage: This field is not exposed, it is only used by accessibility tools to provide a better experience.
msgid "This field is not exposed, it is only used by accessibility tools to provide a better experience."
msgstr "Dieses Fled wird nicht angezeigt, es wird nur von Barrierefreiheittools verwendet, um eine bessere Nutzererfahrung zu gewährleisten."
msgstr "Dieses Feld wird nicht angezeigt, es wird nur von Barrierefreiheittools verwendet, um eine bessere Nutzererfahrung zu gewährleisten."

#: components/schema
# defaultMessage: Accessibility
Expand Down
3 changes: 3 additions & 0 deletions news/16.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- rename blockquote `siteLang` attribute to `locale`
- remove default languages & use available languages from plone's `SupportedContentLanguages` vocabulary instead [@jonaspiterek]
- language drop down now show's "English" / "Deutsch" instead of just "en" and "de" (because of the used vocabulary) [@jonaspiterek]
1 change: 1 addition & 0 deletions news/18.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix typo in german translations [@jonaspiterek]
6 changes: 2 additions & 4 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import config from '@plone/volto/registry';
import { flattenToAppURL } from '@plone/volto/helpers';
import { DetachedTextBlockEditor } from '@plone/volto-slate/blocks/Text/DetachedTextBlockEditor';
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
import { useSelector } from 'react-redux';

const View = (props) => {
const { data, isEditMode } = props;
const language = useSelector((state) => state.intl.locale);
const { data, isEditMode, intl } = props;

const customSlateSettings = {
...props,
Expand Down Expand Up @@ -39,7 +37,7 @@ const View = (props) => {
<blockquote
cite={data.cite}
lang={data.quotationLanguage}
siteLang={language}
locale={intl.locale}
>
{!isEditMode ? (
<TextBlockView {...props} />
Expand Down
37 changes: 10 additions & 27 deletions src/components/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,16 @@ const messages = defineMessages({
});

export const QuoteBlockSchema = ({ intl }) => {
const defaultLang = config.blocks?.blocksConfig?.quote?.defaultLang;
const allowedLanguages = config.blocks?.blocksConfig?.quote?.allowedLanguages;
const DEFAULT_LANGUAGES = [
['en', 'en'],
['de', 'de'],
];

const filterDefaultLanguages = () => {
if (allowedLanguages) {
return DEFAULT_LANGUAGES.filter((item) =>
allowedLanguages.includes(item[0]),
);
} else {
return DEFAULT_LANGUAGES;
}
};

return {
title: intl.formatMessage(messages.quote),
block: 'quote',
fieldsets: [
{
id: 'default',
title: 'Default',
fields: config?.blocks?.blocksConfig?.quote?.showImageField
? ['image']
: [],
fields: config?.blocks?.blocksConfig?.quote?.showImageField && [
'image',
],
},
{
id: 'author',
Expand All @@ -78,13 +61,6 @@ export const QuoteBlockSchema = ({ intl }) => {
},
],
properties: {
quotationLanguage: {
title: intl.formatMessage(messages.quotationLanguage),
choices: filterDefaultLanguages(),
default: defaultLang,
noValueOption: false,
description: intl.formatMessage(messages.description),
},
image: {
title: intl.formatMessage(messages.image),
widget: 'object_browser',
Expand All @@ -98,6 +74,13 @@ export const QuoteBlockSchema = ({ intl }) => {
additional_information: {
title: intl.formatMessage(messages.additional_information),
},
quotationLanguage: {
title: intl.formatMessage(messages.quotationLanguage),
vocabulary: {
'@id': 'plone.app.vocabularies.SupportedContentLanguages',
},
description: intl.formatMessage(messages.description),
},
cite: {
title: intl.formatMessage(messages.cite),
widget: 'url',
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const applyConfig = (config) => {
// If an image is added and later on the image field get's disabled by setting 'showImageField' to 'false',
// the image and alignment fields aswell as the image won't show any longer.
showImageField: true,
defaultLang: 'en',
allowedLanguages: ['en', 'de'],
};

return config;
Expand Down
6 changes: 3 additions & 3 deletions src/theme/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
outline: none;
}

.block-editor-quote blockquote div {
.block-editor-quote blockquote > div {
margin: 0em 0em 1em;
}

.block.quote blockquote:not(.block-editor-quote blockquote) {
&[siteLang='en'] p {
&[locale='en'] p {
&::before {
content: '"';
}
Expand All @@ -17,7 +17,7 @@
}
}

&[siteLang='de'] p {
&[locale='de'] p {
&::before {
content: '';
}
Expand Down

0 comments on commit 8186303

Please sign in to comment.