@eeacms/volto-slate-metadata-mentions 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/Jenkinsfile +1 -1
- package/package.json +1 -1
- package/src/plugins/Mentions/render.jsx +2 -2
- package/src/plugins/Mentions/utils.js +11 -17
- package/src/plugins/Mentions/utils.test.js +19 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [8.3.0](https://github.com/eea/volto-slate-metadata-mentions/compare/8.2.0...8.3.0) - 30 April 2025
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: subjects widget - refs #284007 [Alin Voinea - [`8b46168`](https://github.com/eea/volto-slate-metadata-mentions/commit/8b46168a36454ac529ddbee7c83a60bc3a34faca)]
|
|
12
|
+
- fix: creators and contributors display full name - refs #284007 [Teodor Voicu - [`5a89152`](https://github.com/eea/volto-slate-metadata-mentions/commit/5a89152ac52db83a1d2597c6a3acdc92996dfbec)]
|
|
13
|
+
|
|
14
|
+
#### :hammer_and_wrench: Others
|
|
15
|
+
|
|
16
|
+
- test: Fix unit tests [Alin Voinea - [`3e01041`](https://github.com/eea/volto-slate-metadata-mentions/commit/3e010415b1d10da4f2b29f4e3508a657cd2a8c23)]
|
|
7
17
|
### [8.2.0](https://github.com/eea/volto-slate-metadata-mentions/compare/8.1.1...8.2.0) - 13 September 2024
|
|
8
18
|
|
|
9
19
|
#### :rocket: New Features
|
package/Jenkinsfile
CHANGED
|
@@ -9,7 +9,7 @@ pipeline {
|
|
|
9
9
|
environment {
|
|
10
10
|
GIT_NAME = "volto-slate-metadata-mentions"
|
|
11
11
|
NAMESPACE = "@eeacms"
|
|
12
|
-
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en,insitu-frontend.eionet.europa.eu,insitu.copernicus.eu"
|
|
12
|
+
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en,insitu-frontend.eionet.europa.eu,insitu.copernicus.eu,www.industry.eea.europa.eu"
|
|
13
13
|
DEPENDENCIES = ""
|
|
14
14
|
BACKEND_PROFILES = "eea.kitkat:testing"
|
|
15
15
|
BACKEND_ADDONS = ""
|
package/package.json
CHANGED
|
@@ -64,7 +64,7 @@ export const MentionElement = ({
|
|
|
64
64
|
}`}
|
|
65
65
|
condition={!!data.addLinkToDownload}
|
|
66
66
|
>
|
|
67
|
-
<Widget value={output} className={className}>
|
|
67
|
+
<Widget value={output} content={metadata} className={className}>
|
|
68
68
|
{(child) => wrapInlineMarkupText(children, (_c) => child)}
|
|
69
69
|
</Widget>
|
|
70
70
|
</ConditionalLink>
|
|
@@ -81,7 +81,7 @@ export const MentionElement = ({
|
|
|
81
81
|
>
|
|
82
82
|
<PopupContent>
|
|
83
83
|
<ErrorBoundary name={id}>
|
|
84
|
-
<Widget value={output} className={className} />
|
|
84
|
+
<Widget value={output} content={metadata} className={className} />
|
|
85
85
|
</ErrorBoundary>
|
|
86
86
|
</PopupContent>
|
|
87
87
|
</Popup>
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { Editor, Range } from 'slate'; // Range,
|
|
2
2
|
import { MENTION } from './constants';
|
|
3
|
+
import config from '@plone/volto/registry';
|
|
3
4
|
|
|
4
5
|
export const getMentionWidget = (id, schema) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (schema?.factory === 'Choice') {
|
|
9
|
-
return 'choices';
|
|
10
|
-
}
|
|
11
|
-
if (schema?.factory === 'Relation Choice') {
|
|
12
|
-
return 'relation';
|
|
13
|
-
}
|
|
14
|
-
if (schema?.factory === 'Relation List') {
|
|
15
|
-
return 'relations';
|
|
16
|
-
}
|
|
17
|
-
if (schema?.factory === 'Image') {
|
|
18
|
-
return 'image';
|
|
19
|
-
}
|
|
20
|
-
if (schema?.factory === 'File') {
|
|
21
|
-
return 'file';
|
|
6
|
+
const views = config.widgets?.views || {};
|
|
7
|
+
if (views.widget?.[id]) {
|
|
8
|
+
return id;
|
|
22
9
|
}
|
|
10
|
+
if (id === 'subjects') return 'tags';
|
|
11
|
+
if (schema?.factory === 'Choice') return 'choices';
|
|
12
|
+
if (schema?.factory === 'Relation Choice') return 'relation';
|
|
13
|
+
if (schema?.factory === 'Relation List') return 'relations';
|
|
14
|
+
if (schema?.factory === 'Image') return 'image';
|
|
15
|
+
if (schema?.factory === 'File') return 'file';
|
|
16
|
+
|
|
23
17
|
return schema?.widget || schema?.type || id;
|
|
24
18
|
};
|
|
25
19
|
|
|
@@ -10,6 +10,22 @@ jest.mock('slate', () => ({
|
|
|
10
10
|
},
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
|
+
jest.mock('@plone/volto/registry', () => ({
|
|
14
|
+
__esModule: true,
|
|
15
|
+
default: {
|
|
16
|
+
widgets: {
|
|
17
|
+
views: {
|
|
18
|
+
id: {
|
|
19
|
+
subjects: () => <div>SubjectsWidget</div>,
|
|
20
|
+
},
|
|
21
|
+
widget: {
|
|
22
|
+
tags: () => <div>TagsWidget</div>,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
13
29
|
describe('getMentionWidget', () => {
|
|
14
30
|
it('returns correct widget for each type', () => {
|
|
15
31
|
expect(getMentionWidget('subjects')).toEqual('tags');
|
|
@@ -57,9 +73,10 @@ describe('isCursorInMention', () => {
|
|
|
57
73
|
});
|
|
58
74
|
|
|
59
75
|
it('returns true if selection collapsed inside a mention', () => {
|
|
60
|
-
|
|
76
|
+
const mentionNode = {};
|
|
77
|
+
Editor.above.mockReturnValueOnce([mentionNode]);
|
|
61
78
|
Range.isCollapsed.mockReturnValueOnce(true);
|
|
62
|
-
expect(isCursorInMention(editor)).toEqual(
|
|
79
|
+
expect(isCursorInMention(editor)).toEqual(mentionNode);
|
|
63
80
|
expect(Editor.above).toHaveBeenCalledWith(editor, {
|
|
64
81
|
match: expect.any(Function),
|
|
65
82
|
});
|