Skip to content

Commit

Permalink
Merge pull request #48 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea committed Sep 1, 2023
2 parents a3e4904 + 79acfcc commit 807b639
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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).

### [6.1.4](https://github.com/eea/volto-slate-footnote/compare/6.1.3...6.1.4) - 1 September 2023

#### :bug: Bug Fixes

- fix: force footnotes to open in the same tab - refs #257251 [dobri1408 - [`20bb988`](https://github.com/eea/volto-slate-footnote/commit/20bb988534413a837786ab10cc09244498dbcb7e)]

#### :hammer_and_wrench: Others

- increase code coverage [Dobricean Ioan Dorian - [`3ba3ef3`](https://github.com/eea/volto-slate-footnote/commit/3ba3ef3187b1119d7be96ac2f952a36368163b97)]
### [6.1.3](https://github.com/eea/volto-slate-footnote/compare/6.1.2...6.1.3) - 30 August 2023

#### :bug: Bug Fixes
Expand Down
22 changes: 22 additions & 0 deletions cypress/e2e/01-slate-footnote-block.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ describe('Slate citations', () => {
cy.get('[aria-label="Back to content"]').first().click();
});

it('Test cancel Button', () => {
cy.getSlateEditorAndType('Colorless green ideas sleep furiously.')
.type('{selectAll}')
.dblclick();

// Footnote
cy.setSlateCursor('Colorless').dblclick();
cy.setSlateSelection('Colorless', 'green');
cy.clickSlateButton('Footnote');

cy.get('.sidebar-container .field-wrapper-footnote .react-select-container')
.click()
.type('Citation{enter}');

//click on the cancel button
cy.get('.sidebar-container .form .header button').first().next().click();

// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
});

it('Add Footnotes block and create multiple citations', () => {
// Complete chained commands
cy.getSlateEditorAndType('Colorless green ideas sleep furiously.')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-slate-footnote",
"version": "6.1.3",
"version": "6.1.4",
"description": "volto-slate-footnote: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
30 changes: 12 additions & 18 deletions src/Blocks/Footnote/FootnotesBlockView.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React from 'react';
import {
openAccordionIfContainsFootnoteReference,
getAllBlocksAndSlateFields,
Expand All @@ -7,6 +7,8 @@ import {
} from '@eeacms/volto-slate-footnote/editor/utils';
import './less/public.less';

import { UniversalLink } from '@plone/volto/components';

const alphabet = 'abcdefghijklmnopqrstuvwxyz';

/**
Expand All @@ -20,18 +22,10 @@ const alphabet = 'abcdefghijklmnopqrstuvwxyz';
const FootnotesBlockView = (props) => {
const { data, properties } = props;
const { title, global, placeholder = 'Footnotes' } = data;
const [notesObj, setNodesObjs] = useState(null);
const metadata = props.metadata ? props.metadata : properties;

useEffect(() => {
if (properties) {
const globalMetadata = global ? metadata : properties;
const blocks = getAllBlocksAndSlateFields(globalMetadata);
const notesObjResult = makeFootnoteListOfUniqueItems(blocks);

setNodesObjs(notesObjResult);
}
}, [properties]); // eslint-disable-line
const globalMetadata = global ? metadata : properties;
const blocks = getAllBlocksAndSlateFields(globalMetadata);
const notesObj = makeFootnoteListOfUniqueItems(blocks);

return (
<div className="footnotes-listing-block">
Expand Down Expand Up @@ -62,7 +56,7 @@ const FootnotesBlockView = (props) => {
id={`cite_ref-${refsList[0]}`}
key={`indice-${refsList[0]}`}
>
<a
<UniversalLink
href={`#ref-${parentUid || uid}`}
aria-label="Back to content"
onClick={() =>
Expand All @@ -72,12 +66,12 @@ const FootnotesBlockView = (props) => {
}
>
{alphabet[0]}
</a>{' '}
</UniversalLink>{' '}
</sup>
{/** following refs will have the uid of the one that references it*/}
{refsList.slice(1).map((ref, index) => (
<sup id={`cite_ref-${ref}`} key={`indice-${ref}`}>
<a
<UniversalLink
href={`#ref-${ref}`}
aria-label="Back to content"
onClick={() =>
Expand All @@ -87,14 +81,14 @@ const FootnotesBlockView = (props) => {
}
>
{alphabet[index + 1]}
</a>{' '}
</UniversalLink>{' '}
</sup>
))}
</>
) : (
<sup id={`cite_ref-${uid}`}>
{/** some footnotes are never parent so we need the parent to reference */}
<a
<UniversalLink
href={`#ref-${parentUid || uid}`}
aria-label="Back to content"
onClick={() =>
Expand All @@ -104,7 +98,7 @@ const FootnotesBlockView = (props) => {
}
>
</a>{' '}
</UniversalLink>{' '}
</sup>
)}
</li>
Expand Down
9 changes: 5 additions & 4 deletions src/editor/render.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './utils';
import { isEmpty } from 'lodash';
import { useSelector } from 'react-redux';
import { UniversalLink } from '@plone/volto/components';

/**
* Removes '<?xml version="1.0"?>' from footnote
Expand Down Expand Up @@ -110,7 +111,7 @@ export const FootnoteElement = (props) => {
<Popup.Content>
<List divided relaxed selection>
<List.Item
as="a"
as={UniversalLink}
href={`#footnote-${citationRefId}`}
onClick={() =>
openAccordionIfContainsFootnoteReference(
Expand All @@ -132,7 +133,7 @@ export const FootnoteElement = (props) => {
{data.extra &&
data.extra.map((item) => (
<List.Item
as="a"
as={UniversalLink}
href={`#footnote-${item.zoteroId || item.uid}`}
onClick={() =>
openAccordionIfContainsFootnoteReference(
Expand Down Expand Up @@ -174,7 +175,7 @@ export const FootnoteElement = (props) => {
<Popup.Content>
<List divided relaxed selection>
<List.Item
as="a"
as={UniversalLink}
href={`#footnote-${citationRefId}`}
onClick={() =>
openAccordionIfContainsFootnoteReference(
Expand All @@ -196,7 +197,7 @@ export const FootnoteElement = (props) => {
{data.extra &&
data.extra.map((item) => (
<List.Item
as="a"
as={UniversalLink}
href={`#footnote-${item.zoteroId || item.uid}`}
onClick={() =>
openAccordionIfContainsFootnoteReference(
Expand Down

0 comments on commit 807b639

Please sign in to comment.