diff --git a/CHANGELOG.md b/CHANGELOG.md index 5096f3b0..9690d43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +### [1.18.0](https://github.com/eea/volto-eea-website-theme/compare/1.17.2...1.18.0) - 20 June 2023 + +#### :rocket: New Features + +- feat: ThemesWidget update advanced-search link - refs #145772 [Alin Voinea - [`036f471`](https://github.com/eea/volto-eea-website-theme/commit/036f4711ace0985e2b542c64a1cbe28fd97911bd)] +- feat: Add ThemeasWidget for taxonomy_themes and fix tags link - refs #145772 [Alin Voinea - [`903de63`](https://github.com/eea/volto-eea-website-theme/commit/903de638be2e2b2a9c550200706271fc72f09e36)] + +#### :bug: Bug Fixes + +- fix: clearformat only selection [nileshgulia1 - [`e8aab36`](https://github.com/eea/volto-eea-website-theme/commit/e8aab36c0c86e2a2a01ca53673a89c596949a4b1)] +- fix(slate): backport feature from volto-slate that sets classes on style options [David Ichim - [`5ed97f3`](https://github.com/eea/volto-eea-website-theme/commit/5ed97f34a4714dcbaa11296ca64d043a24464d3e)] + +#### :nail_care: Enhancements + +- change(footer): removed fallback to empty array for footer actions #153 from eea/footer_actions [ichim-david - [`8fb9c08`](https://github.com/eea/volto-eea-website-theme/commit/8fb9c082a7fac14e31c7e568cc85cb7095b0524d)] + +#### :hammer_and_wrench: Others + +- Refs #254132 - Bump to 1.18.0. [GhitaB - [`51f483b`](https://github.com/eea/volto-eea-website-theme/commit/51f483b3dba6cff13471fc512d372b577991f6f4)] +- Refs #254132 - Do not initialize actions with []. Make sure actions in footerOpts are used if set. [GhitaB - [`8c0afb5`](https://github.com/eea/volto-eea-website-theme/commit/8c0afb539b0c96928545bc9a6974a189c9e886b8)] +- test: Fix sonarqube - Convert the conditional to a boolean to avoid leaked value [Alin Voinea - [`195eb19`](https://github.com/eea/volto-eea-website-theme/commit/195eb19b8aa40a95bca6aafc7720bdc6b8e02340)] ### [1.17.2](https://github.com/eea/volto-eea-website-theme/compare/1.17.1...1.17.2) - 14 June 2023 #### :rocket: New Features - feat: config nextcloud subtitles languages - refs #253430 [dobri1408 - [`1fc72df`](https://github.com/eea/volto-eea-website-theme/commit/1fc72df37adbb9f9c03f4adb6ad800d7e603ed90)] +#### :hammer_and_wrench: Others + +- Release #150 from eea/develop [ichim-david - [`52f1f78`](https://github.com/eea/volto-eea-website-theme/commit/52f1f782a1d815c6df5be1aabe34f67715637d0f)] ### [1.17.1](https://github.com/eea/volto-eea-website-theme/compare/1.17.0...1.17.1) - 12 June 2023 #### :nail_care: Enhancements @@ -62,7 +86,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :house: Internal changes -- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`370dcbf`](https://github.com/eea/volto-eea-website-theme/commit/370dcbfbf1a8135ce7b1b3b271b004552a631837)] #### :hammer_and_wrench: Others @@ -218,7 +241,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c5e2f8`](https://github.com/eea/volto-eea-website-theme/commit/6c5e2f80456e2061d9e9c15fd0a0b91b9ac70568)] ### [1.9.1](https://github.com/eea/volto-eea-website-theme/compare/1.9.0...1.9.1) - 28 February 2023 #### :bug: Bug Fixes @@ -365,7 +387,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)] - Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)] -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)] ### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023 #### :hammer_and_wrench: Others @@ -399,7 +420,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)] - bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)] -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)] - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)] ### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022 @@ -409,7 +429,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)] - Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)] - Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)] ### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022 @@ -420,7 +439,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)] ### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022 #### :rocket: New Features @@ -461,7 +479,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)] - Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)] - fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)] -- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)] ### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022 #### :nail_care: Enhancements @@ -509,7 +526,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)] ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022 #### :hammer_and_wrench: Others @@ -777,7 +793,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)] - Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)] - feature(breadcrumbs): implement eea-design-system breadcrumb as Volto component #32 #7 [ichim-david - [`181af41`](https://github.com/eea/volto-eea-website-theme/commit/181af4125ce2b9ddac56dab4723cb11c26633221)] -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)] - use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)] - Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)] - Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)] @@ -819,5 +834,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)] - Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)] diff --git a/package.json b/package.json index 551b3fad..0b7bd09f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-eea-website-theme", - "version": "1.17.2", + "version": "1.18.0", "description": "@eeacms/volto-eea-website-theme: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", diff --git a/src/components/theme/Widgets/ThemesWidget.jsx b/src/components/theme/Widgets/ThemesWidget.jsx new file mode 100644 index 00000000..e0c3e9b8 --- /dev/null +++ b/src/components/theme/Widgets/ThemesWidget.jsx @@ -0,0 +1,20 @@ +import React from 'react'; +import cx from 'classnames'; +import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag'; + +export const ThemesWidget = ({ value, children, className }) => { + return value ? ( + + {value.map((tag) => ( + + {children ? children(tag.title) : tag.title} + + ))} + + ) : ( + '' + ); +}; diff --git a/src/components/theme/Widgets/TokenWidget.jsx b/src/components/theme/Widgets/TokenWidget.jsx index a2cc8070..f1af6e00 100644 --- a/src/components/theme/Widgets/TokenWidget.jsx +++ b/src/components/theme/Widgets/TokenWidget.jsx @@ -6,7 +6,10 @@ export const TokenWidget = ({ value, children, className }) => value ? ( {value.map((tag) => ( - + {children ? children(tag) : tag} ))} diff --git a/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/README.txt b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/README.txt new file mode 100644 index 00000000..30579d1b --- /dev/null +++ b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/README.txt @@ -0,0 +1 @@ +This customization fixes bugs with styleMenu not highlighting selected styles in some scenarios. This should be removed after https://github.com/plone/volto/pull/4852 \ No newline at end of file diff --git a/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/StyleMenu.jsx b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/StyleMenu.jsx new file mode 100644 index 00000000..fa21dbe4 --- /dev/null +++ b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/StyleMenu.jsx @@ -0,0 +1,157 @@ +import React from 'react'; +import { useSlate } from 'slate-react'; +import { Dropdown } from 'semantic-ui-react'; +import { useIntl, defineMessages } from 'react-intl'; +import cx from 'classnames'; +import { omit } from 'lodash'; +import { isBlockStyleActive, isInlineStyleActive, toggleStyle } from './utils'; +import config from '@plone/volto/registry'; +import { ToolbarButton } from '@plone/volto-slate/editor/ui'; +import paintSVG from '@plone/volto/icons/paint.svg'; + +const messages = defineMessages({ + inlineStyle: { + id: 'Inline Style', + defaultMessage: 'Inline Style', + }, + paragraphStyle: { + id: 'Paragraph Style', + defaultMessage: 'Paragraph Style', + }, + additionalStyles: { + id: 'Additional Styles', + defaultMessage: 'Additional Styles', + }, +}); + +const StyleMenuButton = ({ icon, active, ...props }) => ( + +); + +const MenuOpts = ({ editor, toSelect, option, type }) => { + const isActive = toSelect.includes(option); + return ( + { + toggleStyle(editor, { + cssClass: selItem.value, + isBlock: selItem.isBlock, + }); + }} + /> + ); +}; + +const StylingsButton = (props) => { + const editor = useSlate(); + const intl = useIntl(); + + // Converting the settings to a format that is required by dropdowns. + const inlineOpts = [ + ...config.settings.slate.styleMenu.inlineStyles.map((def) => { + return { + value: def.cssClass, + text: def.label, + icon: def.icon, + isBlock: false, + }; + }), + ]; + const blockOpts = [ + ...config.settings.slate.styleMenu.blockStyles.map((def) => { + return { + value: def.cssClass, + text: def.label, + icon: def.icon, + isBlock: true, + }; + }), + ]; + + // Calculating the initial selection. + const toSelect = []; + // block styles + for (const val of blockOpts) { + const ia = isBlockStyleActive(editor, val.value); + if (ia) { + toSelect.push(val); + } + } + // inline styles + for (const val of inlineOpts) { + const ia = isInlineStyleActive(editor, val.value); + if (ia) { + toSelect.push(val); + } + } + + const menuItemProps = { + toSelect, + editor, + }; + const showMenu = inlineOpts.length || blockOpts.length; + return showMenu ? ( + 0} + /> + } + > + + {inlineOpts.length ? ( + <> + + {inlineOpts.map((option, index) => ( + + ))} + + ) : ( + '' + )} + + {blockOpts.length ? ( + <> + + {blockOpts.map((option, index) => ( + + ))} + + ) : ( + '' + )} + + + ) : ( + '' + ); +}; + +export default StylingsButton; diff --git a/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/utils.js b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/utils.js new file mode 100644 index 00000000..4090c8d7 --- /dev/null +++ b/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/utils.js @@ -0,0 +1,168 @@ +/* eslint no-console: ["error", { allow: ["warn", "error"] }] */ +import { Editor, Transforms } from 'slate'; +import { isBlockActive } from '@plone/volto-slate/utils'; +import config from '@plone/volto/registry'; + +/** + * Toggles a style (e.g. in the StyleMenu plugin). + * @param {Editor} editor + * @param {object} options + * @param {boolean} options.isRequested Whether the given style is requested by + * the user. The style is only applied if it is requested and only removed if it + * is not requested. + */ +export const toggleStyle = (editor, { cssClass, isBlock, isRequested }) => { + if (isBlock) { + toggleBlockStyle(editor, cssClass); + } else { + toggleInlineStyle(editor, cssClass); + } +}; + +export const toggleBlockStyle = (editor, style) => { + // We have 6 boolean variables which need to be accounted for. + // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing + const { slate } = config.settings; + + const isListItem = isBlockActive(editor, slate.listItemType); + const isActive = isBlockStyleActive(editor, style); + const wantsList = false; + + if (isListItem && !wantsList) { + toggleBlockStyleAsListItem(editor, style); + } else if (isListItem && wantsList && !isActive) { + // switchListType(editor, format); // this will deconstruct to Volto blocks + } else if (!isListItem && wantsList) { + // changeBlockToList(editor, format); + } else if (!isListItem && !wantsList) { + internalToggleBlockStyle(editor, style); + } else { + console.warn('toggleBlockStyle case not covered, please examine:', { + wantsList, + isActive, + isListItem, + }); + } +}; + +export const toggleInlineStyle = (editor, style) => { + // We have 6 boolean variables which need to be accounted for. + // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing + const { slate } = config.settings; + + const isListItem = isBlockActive(editor, slate.listItemType); + const isActive = isInlineStyleActive(editor, style); + const wantsList = false; + + if (isListItem && !wantsList) { + toggleInlineStyleAsListItem(editor, style); + } else if (isListItem && wantsList && !isActive) { + // switchListType(editor, format); // this will deconstruct to Volto blocks + } else if (!isListItem && wantsList) { + // changeBlockToList(editor, format); + } else if (!isListItem && !wantsList) { + internalToggleInlineStyle(editor, style); + } else { + console.warn('toggleInlineStyle case not covered, please examine:', { + wantsList, + isActive, + isListItem, + }); + } +}; + +export const isBlockStyleActive = (editor, style) => { + const keyName = `style-${style}`; + const sn = Array.from( + Editor.nodes(editor, { + match: (n) => { + const isStyle = typeof n.styleName === 'string' || n[keyName]; + return !Editor.isEditor(n) && isStyle; + }, + mode: 'all', + }), + ); + + for (const [n] of sn) { + if (typeof n.styleName === 'string') { + if (n.styleName.split(' ').filter((x) => x === style).length > 0) { + return true; + } + } else if ( + n[keyName] && + keyName.split('-').filter((x) => x === style).length > 0 + ) + return true; + } + return false; +}; + +export const isInlineStyleActive = (editor, style) => { + const m = Editor.marks(editor); + const keyName = `style-${style}`; + if (m && m[keyName]) { + return true; + } + return false; +}; + +export const internalToggleBlockStyle = (editor, style) => { + toggleBlockStyleInSelection(editor, style); +}; + +export const internalToggleInlineStyle = (editor, style) => { + toggleInlineStyleInSelection(editor, style); +}; + +/* + * Applies a block format unto a list item. Will split the list and deconstruct the + * block + */ +export const toggleBlockStyleAsListItem = (editor, style) => { + toggleBlockStyleInSelection(editor, style); +}; + +/* + * Applies an inline style unto a list item. + */ +export const toggleInlineStyleAsListItem = (editor, style) => { + toggleInlineStyleInSelection(editor, style); +}; + +function toggleInlineStyleInSelection(editor, style) { + const m = Editor.marks(editor); + const keyName = 'style-' + style; + + if (m && m[keyName]) { + Editor.removeMark(editor, keyName); + } else { + Editor.addMark(editor, keyName, true); + } +} + +function toggleBlockStyleInSelection(editor, style) { + const sn = Array.from( + Editor.nodes(editor, { + mode: 'highest', + match: (n) => { + return !Editor.isEditor(n); + }, + }), + ); + + for (const [n, p] of sn) { + let cn = n.styleName; + if (typeof n.styleName !== 'string') { + cn = style; + } else if (n.styleName.split(' ').filter((x) => x === style).length > 0) { + cn = cn + .split(' ') + .filter((x) => x !== style) + .join(' '); + } else { + // the style is not set but other styles are set + cn = cn.split(' ').concat(style).join(' '); + } + Transforms.setNodes(editor, { styleName: cn }, { at: p }); + } +} diff --git a/src/customizations/volto/components/theme/Footer/Footer.jsx b/src/customizations/volto/components/theme/Footer/Footer.jsx index 0c93aadf..d5075685 100644 --- a/src/customizations/volto/components/theme/Footer/Footer.jsx +++ b/src/customizations/volto/components/theme/Footer/Footer.jsx @@ -13,11 +13,11 @@ import isArray from 'lodash/isArray'; const Footer = () => { const { eea } = config.settings; const { - footerActions = [], - copyrightActions = [], - socialActions = [], - contactActions = [], - contactExtraActions = [], + footerActions, + copyrightActions, + socialActions, + contactActions, + contactExtraActions, } = useSelector( (state) => ({ footerActions: state.actions?.actions?.footer_actions, diff --git a/src/index.js b/src/index.js index f0d6648e..f4e86f67 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,7 @@ import CustomCSS from '@eeacms/volto-eea-website-theme/components/theme/CustomCS import NotFound from '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound'; import DraftBackground from '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground'; import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget'; +import { ThemesWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ThemesWidget'; import SubsiteClass from './components/theme/SubsiteClass'; import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView'; import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView'; @@ -111,11 +112,10 @@ const applyConfig = (config) => { config.blocks.blocksConfig.hero.copyrightPrefix = 'Image'; } - // Custom TokenWidget - if (config.widgets.views) { - config.widgets.views.id.subjects = TokenWidget; - config.widgets.views.widget.tags = TokenWidget; - } + // Custom Widgets + config.widgets.views.id.taxonomy_themes = ThemesWidget; + config.widgets.views.id.subjects = TokenWidget; + config.widgets.views.widget.tags = TokenWidget; // /voltoCustom.css express-middleware // /ok express-middleware - see also: https://github.com/plone/volto/pull/4432 diff --git a/src/slate.js b/src/slate.js index d0a0cbce..633aa13e 100644 --- a/src/slate.js +++ b/src/slate.js @@ -66,7 +66,7 @@ const clearFormatting = (editor) => { // console.log('node', n, p); return Text.isText(n); }, - at: [0], // uncomment if you want everything to be cleared + //at: [0], // uncomment if you want everything to be cleared }), ); @@ -215,6 +215,8 @@ export default function installSlate(config) { ); + config.settings.slate.allowedHeadlineElements.push('zotero'); + // Slate StyleMenu configuration config.settings.slate.styleMenu = { ...(config.settings.slate.styleMenu || {}),