Skip to content

Commit

Permalink
Merge pull request #33 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avoinea authored Mar 26, 2024
2 parents 2111100 + e45066c commit 1c7ce4d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ 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).

### [0.6.0](https://github.com/eea/volto-anchors/compare/0.5.0...0.6.0) - 16 February 2024
### [0.7.0](https://github.com/eea/volto-anchors/compare/0.6.0...0.7.0) - 25 March 2024

#### :bug: Bug Fixes

- fix(toc): make it work, refs #265201 [Razvan - [`d9316ae`](https://github.com/eea/volto-anchors/commit/d9316ae298746df976d9053f6a9ea708ac870483)]
- fix(anchor): error where selector in URL is invalid #32 from eea/265448-fix-invalid-selector [ichim-david - [`8e943b1`](https://github.com/eea/volto-anchors/commit/8e943b119d7073edd2f2d799489fb47fac596db9)]

#### :house: Internal changes

- chore: Fix newline in package.json [alin - [`15d3ddb`](https://github.com/eea/volto-anchors/commit/15d3ddb7c0a0c339f26002304dc9f2ff9885ca2e)]

#### :hammer_and_wrench: Others

- bump package version [David Ichim - [`c98459b`](https://github.com/eea/volto-anchors/commit/c98459b9347708a266e16f1c547447a51a783092)]
- remove console error [Teodor - [`a0bed8b`](https://github.com/eea/volto-anchors/commit/a0bed8b609fd78f07e2f5b029a332168468c1143)]
- update function to validate selector [Teodor - [`64c283b`](https://github.com/eea/volto-anchors/commit/64c283b48b307f76b0781bfa92f35b40dbdf4bdf)]
- Ref #265448 Fix error where selector in URL is invalid [Teodor - [`e61425a`](https://github.com/eea/volto-anchors/commit/e61425ac3477c75e8185c8c5eea52eae69c7b717)]
### [0.6.0](https://github.com/eea/volto-anchors/compare/0.5.0...0.6.0) - 19 February 2024

#### :house: Internal changes

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-anchors",
"version": "0.6.0",
"version": "0.7.0",
"description": "@eeacms/volto-anchors: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down Expand Up @@ -70,4 +70,4 @@
"cypress:open": "make cypress-open",
"prepare": "husky install"
}
}
}
13 changes: 12 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { serializeNodes } from '@plone/volto-slate/editor/render';
import { Link } from 'react-router-dom';
import { getBlocks } from '@plone/volto/helpers/Blocks/Blocks';
import linkSVG from '@plone/volto/icons/link.svg';

import './less/slate-anchors.less';

export const createSlateParagraph = (text) => {
Expand Down Expand Up @@ -51,7 +50,19 @@ export const scrollToTarget = (target, offsetHeight = 0) => {
return;
};

const isValidSelector = (selector) => {
try {
document.createElement('div').querySelector(selector);
return true;
} catch (e) {
return false;
}
};

export const openAccordionIfContainsAnchors = (anchor) => {
if (!isValidSelector(anchor)) {
return;
}
waitForElm(anchor).then((elm) => {
if (elm.closest('.accordion')) {
const comp = elm.closest('.accordion')?.querySelector('.title');
Expand Down

0 comments on commit 1c7ce4d

Please sign in to comment.