From c3ba633d7d928afbda6926a7896e862b8256d834 Mon Sep 17 00:00:00 2001 From: jonaspiterek Date: Mon, 19 Feb 2024 14:08:22 +0100 Subject: [PATCH] set quotation marks by site language --- src/components/View.jsx | 7 +++++-- src/components/schema.js | 21 +++++++++++++-------- src/index.js | 4 ++-- src/theme/main.less | 6 +++--- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/components/View.jsx b/src/components/View.jsx index 5b9f754..4571fd0 100644 --- a/src/components/View.jsx +++ b/src/components/View.jsx @@ -4,16 +4,18 @@ import { flattenToAppURL } from '@plone/volto/helpers'; import cx from 'classnames'; 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 customSlateSettings = { ...props, slateSettings: { ...config.settings.slate, toolbarButtons: config.settings.slate.toolbarButtons.filter( - (index) => index - config.settings.slate.toolbarButtons, + (index) => index - config.settings.slate.toolbarButtons ), }, }; @@ -37,7 +39,8 @@ const View = (props) => { )}
{!isEditMode ? ( diff --git a/src/components/schema.js b/src/components/schema.js index 0928ae2..0d6c949 100644 --- a/src/components/schema.js +++ b/src/components/schema.js @@ -37,14 +37,14 @@ 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'], + ['en', 'en'], + ['de', 'de'], ]; const filterDefaultLanguages = () => { if (allowedLanguages) { return DEFAULT_LANGUAGES.filter((item) => - allowedLanguages.includes(item[0]), + allowedLanguages.includes(item[0]) ); } else { return DEFAULT_LANGUAGES; @@ -59,13 +59,18 @@ export const QuoteBlockSchema = ({ intl }) => { id: 'default', title: 'Default', fields: config?.blocks?.blocksConfig?.quote?.showImageField - ? ['quotationLanguage', 'image'] - : ['quotationLanguage'], + ? ['image'] + : [], }, { - id: 'person', - title: 'Person', - fields: ['author', 'additional_information', 'cite'], + id: 'author', + title: 'Author', + fields: ['author', 'additional_information'], + }, + { + id: 'accessibility', + title: 'Accessibility', + fields: ['quotationLanguage', 'cite'], }, ], properties: { diff --git a/src/index.js b/src/index.js index d846076..5795f75 100644 --- a/src/index.js +++ b/src/index.js @@ -22,8 +22,8 @@ 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'], + defaultLang: 'en', + allowedLanguages: ['en', 'de'], }; return config; diff --git a/src/theme/main.less b/src/theme/main.less index 4daaacf..b430ac0 100644 --- a/src/theme/main.less +++ b/src/theme/main.less @@ -6,8 +6,8 @@ margin: 0em 0em 1em; } -.block.quote blockquote:not(.edit) { - &.EN p { +.block.quote blockquote:not(.block-editor-quote blockquote) { + &[siteLang='en'] p { &::before { content: '"'; } @@ -17,7 +17,7 @@ } } - &.DE p { + &[siteLang='de'] p { &::before { content: '„'; }