@contentful/field-editor-rich-text 4.9.1 → 4.10.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/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +4 -1
- package/dist/cjs/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +60 -0
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +6 -3
- package/dist/esm/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +59 -0
- package/dist/types/plugins/Hyperlink/HyperlinkModal.d.ts +1 -1
- package/dist/types/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.d.ts +0 -0
- package/package.json +3 -3
|
@@ -163,7 +163,10 @@ function HyperlinkModal(props) {
|
|
|
163
163
|
async function selectEntry() {
|
|
164
164
|
const options = {
|
|
165
165
|
locale: props.sdk.field.locale,
|
|
166
|
-
contentTypes: (0, _getLinkedContentTypeIdsForNodeType.default)(props.sdk.field, _richtexttypes.INLINES.ENTRY_HYPERLINK)
|
|
166
|
+
contentTypes: (0, _getLinkedContentTypeIdsForNodeType.default)(props.sdk.field, _richtexttypes.INLINES.ENTRY_HYPERLINK),
|
|
167
|
+
recommendations: {
|
|
168
|
+
searchQuery: props.linkText
|
|
169
|
+
}
|
|
167
170
|
};
|
|
168
171
|
const entry = await props.sdk.dialogs.selectSingleEntry(options);
|
|
169
172
|
if (entry) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
3
|
+
it('should pass linkText as searchQuery to selectSingleEntry', ()=>{
|
|
4
|
+
const mockSelectSingleEntry = jest.fn();
|
|
5
|
+
const linkText = 'example search text';
|
|
6
|
+
const expectedOptions = {
|
|
7
|
+
locale: 'en-US',
|
|
8
|
+
contentTypes: [
|
|
9
|
+
'exampleCT'
|
|
10
|
+
],
|
|
11
|
+
recommendations: {
|
|
12
|
+
searchQuery: linkText
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
mockSelectSingleEntry(expectedOptions);
|
|
16
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expectedOptions);
|
|
17
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
18
|
+
recommendations: {
|
|
19
|
+
searchQuery: linkText
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
it('should update searchQuery when linkText changes', ()=>{
|
|
24
|
+
const mockSelectSingleEntry = jest.fn();
|
|
25
|
+
const modifiedText = 'modified text';
|
|
26
|
+
const expectedOptions = {
|
|
27
|
+
locale: 'en-US',
|
|
28
|
+
contentTypes: [
|
|
29
|
+
'exampleCT'
|
|
30
|
+
],
|
|
31
|
+
recommendations: {
|
|
32
|
+
searchQuery: modifiedText
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
mockSelectSingleEntry(expectedOptions);
|
|
36
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
37
|
+
recommendations: {
|
|
38
|
+
searchQuery: modifiedText
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
it('should handle empty linkText', ()=>{
|
|
43
|
+
const mockSelectSingleEntry = jest.fn();
|
|
44
|
+
const expectedOptions = {
|
|
45
|
+
locale: 'en-US',
|
|
46
|
+
contentTypes: [
|
|
47
|
+
'exampleCT'
|
|
48
|
+
],
|
|
49
|
+
recommendations: {
|
|
50
|
+
searchQuery: ''
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
mockSelectSingleEntry(expectedOptions);
|
|
54
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
55
|
+
recommendations: {
|
|
56
|
+
searchQuery: ''
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Button, Form, FormControl, FormLabel, ModalContent, ModalControls, Select, TextInput, TextLink } from '@contentful/f36-components';
|
|
3
3
|
import tokens from '@contentful/f36-tokens';
|
|
4
4
|
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
5
5
|
import { ModalDialogLauncher } from '@contentful/field-editor-shared';
|
|
6
6
|
import { INLINES } from '@contentful/rich-text-types';
|
|
7
7
|
import { css } from 'emotion';
|
|
8
|
-
import { getNodeEntryFromSelection, insertLink, LINK_TYPES
|
|
8
|
+
import { focus, getNodeEntryFromSelection, insertLink, LINK_TYPES } from '../../helpers/editor';
|
|
9
9
|
import getAllowedResourcesForNodeType from '../../helpers/getAllowedResourcesForNodeType';
|
|
10
10
|
import getLinkedContentTypeIdsForNodeType from '../../helpers/getLinkedContentTypeIdsForNodeType';
|
|
11
11
|
import { isNodeTypeEnabled } from '../../helpers/validations';
|
|
@@ -99,7 +99,10 @@ export function HyperlinkModal(props) {
|
|
|
99
99
|
async function selectEntry() {
|
|
100
100
|
const options = {
|
|
101
101
|
locale: props.sdk.field.locale,
|
|
102
|
-
contentTypes: getLinkedContentTypeIdsForNodeType(props.sdk.field, INLINES.ENTRY_HYPERLINK)
|
|
102
|
+
contentTypes: getLinkedContentTypeIdsForNodeType(props.sdk.field, INLINES.ENTRY_HYPERLINK),
|
|
103
|
+
recommendations: {
|
|
104
|
+
searchQuery: props.linkText
|
|
105
|
+
}
|
|
103
106
|
};
|
|
104
107
|
const entry = await props.sdk.dialogs.selectSingleEntry(options);
|
|
105
108
|
if (entry) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
2
|
+
it('should pass linkText as searchQuery to selectSingleEntry', ()=>{
|
|
3
|
+
const mockSelectSingleEntry = jest.fn();
|
|
4
|
+
const linkText = 'example search text';
|
|
5
|
+
const expectedOptions = {
|
|
6
|
+
locale: 'en-US',
|
|
7
|
+
contentTypes: [
|
|
8
|
+
'exampleCT'
|
|
9
|
+
],
|
|
10
|
+
recommendations: {
|
|
11
|
+
searchQuery: linkText
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
mockSelectSingleEntry(expectedOptions);
|
|
15
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expectedOptions);
|
|
16
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
17
|
+
recommendations: {
|
|
18
|
+
searchQuery: linkText
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
22
|
+
it('should update searchQuery when linkText changes', ()=>{
|
|
23
|
+
const mockSelectSingleEntry = jest.fn();
|
|
24
|
+
const modifiedText = 'modified text';
|
|
25
|
+
const expectedOptions = {
|
|
26
|
+
locale: 'en-US',
|
|
27
|
+
contentTypes: [
|
|
28
|
+
'exampleCT'
|
|
29
|
+
],
|
|
30
|
+
recommendations: {
|
|
31
|
+
searchQuery: modifiedText
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
mockSelectSingleEntry(expectedOptions);
|
|
35
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
36
|
+
recommendations: {
|
|
37
|
+
searchQuery: modifiedText
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
it('should handle empty linkText', ()=>{
|
|
42
|
+
const mockSelectSingleEntry = jest.fn();
|
|
43
|
+
const expectedOptions = {
|
|
44
|
+
locale: 'en-US',
|
|
45
|
+
contentTypes: [
|
|
46
|
+
'exampleCT'
|
|
47
|
+
],
|
|
48
|
+
recommendations: {
|
|
49
|
+
searchQuery: ''
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
mockSelectSingleEntry(expectedOptions);
|
|
53
|
+
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
54
|
+
recommendations: {
|
|
55
|
+
searchQuery: ''
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Link } from '@contentful/field-editor-reference';
|
|
3
3
|
import { FieldAppSDK } from '@contentful/field-editor-shared';
|
|
4
4
|
import { ResourceLink } from '@contentful/rich-text-types';
|
|
5
|
-
import {
|
|
5
|
+
import { Path, PlateEditor } from '../../internal/types';
|
|
6
6
|
import { TrackingPluginActions } from '../../plugins/Tracking';
|
|
7
7
|
interface HyperlinkModalProps {
|
|
8
8
|
linkText?: string;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@contentful/f36-icons": "^4.29.0",
|
|
45
45
|
"@contentful/f36-tokens": "^4.0.5",
|
|
46
46
|
"@contentful/f36-utils": "^4.24.3",
|
|
47
|
-
"@contentful/field-editor-reference": "^6.10.
|
|
47
|
+
"@contentful/field-editor-reference": "^6.10.1",
|
|
48
48
|
"@contentful/field-editor-shared": "^2.9.0",
|
|
49
49
|
"@contentful/rich-text-plain-text-renderer": "^17.0.0",
|
|
50
50
|
"@contentful/rich-text-types": "^17.0.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"registry": "https://npm.pkg.github.com/"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "299f71af5a480a95605b33898bead31cc239c918"
|
|
92
92
|
}
|