@wordpress/format-library 3.0.19 → 3.1.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 +2 -0
- package/LICENSE.md +1 -1
- package/build/default-formats.native.js +3 -1
- package/build/default-formats.native.js.map +1 -1
- package/build/link/index.native.js +2 -2
- package/build/link/index.native.js.map +1 -1
- package/build/link/modal-screens/link-picker-screen.native.js +12 -25
- package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build/link/modal-screens/link-settings-screen.native.js +50 -19
- package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build/text-color/index.native.js +192 -0
- package/build/text-color/index.native.js.map +1 -0
- package/build/text-color/inline.js +1 -0
- package/build/text-color/inline.js.map +1 -1
- package/build/text-color/inline.native.js +191 -0
- package/build/text-color/inline.native.js.map +1 -0
- package/build-module/default-formats.native.js +2 -1
- package/build-module/default-formats.native.js.map +1 -1
- package/build-module/link/index.native.js +1 -1
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +12 -26
- package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +50 -19
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/text-color/index.native.js +173 -0
- package/build-module/text-color/index.native.js.map +1 -0
- package/build-module/text-color/inline.js +1 -2
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/text-color/inline.native.js +177 -0
- package/build-module/text-color/inline.native.js.map +1 -0
- package/package.json +15 -15
- package/src/default-formats.native.js +2 -1
- package/src/link/index.native.js +1 -1
- package/src/link/modal-screens/link-picker-screen.native.js +12 -23
- package/src/link/modal-screens/link-settings-screen.native.js +27 -14
- package/src/link/test/index.native.js +137 -0
- package/src/link/test/modal.native.js +3 -3
- package/src/text-color/index.native.js +194 -0
- package/src/text-color/inline.js +1 -1
- package/src/text-color/inline.native.js +186 -0
- package/src/text-color/style.native.scss +23 -0
- package/src/text-color/test/__snapshots__/index.native.js.snap +19 -0
- package/src/text-color/test/index.native.js +164 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
getEditorHtml,
|
|
6
|
+
initializeEditor,
|
|
7
|
+
fireEvent,
|
|
8
|
+
waitFor,
|
|
9
|
+
} from 'test/helpers';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { setDefaultBlockName, unregisterBlockType } from '@wordpress/blocks';
|
|
15
|
+
import { registerBlock, coreBlocks } from '@wordpress/block-library';
|
|
16
|
+
|
|
17
|
+
const COLOR_PINK = '#f78da7';
|
|
18
|
+
const paragraph = coreBlocks[ 'core/paragraph' ];
|
|
19
|
+
|
|
20
|
+
const TEXT_WITH_COLOR = `<!-- wp:paragraph -->
|
|
21
|
+
<p>Hello <mark style="background-color:rgba(0,0,0,0);color:#cf2e2e" class="has-inline-color has-vivid-red-color">this is a test</mark></p>
|
|
22
|
+
<!-- /wp:paragraph -->`;
|
|
23
|
+
|
|
24
|
+
beforeAll( () => {
|
|
25
|
+
registerBlock( paragraph );
|
|
26
|
+
setDefaultBlockName( paragraph.name );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
afterAll( () => {
|
|
30
|
+
unregisterBlockType( paragraph.name );
|
|
31
|
+
} );
|
|
32
|
+
|
|
33
|
+
describe( 'Text color', () => {
|
|
34
|
+
it( 'shows the text color formatting button in the toolbar', async () => {
|
|
35
|
+
const { getByA11yLabel } = initializeEditor();
|
|
36
|
+
|
|
37
|
+
// Wait for the editor placeholder
|
|
38
|
+
const paragraphPlaceholder = await waitFor( () =>
|
|
39
|
+
getByA11yLabel( 'Add paragraph block' )
|
|
40
|
+
);
|
|
41
|
+
expect( paragraphPlaceholder ).toBeDefined();
|
|
42
|
+
fireEvent.press( paragraphPlaceholder );
|
|
43
|
+
|
|
44
|
+
// Wait for the block to be created
|
|
45
|
+
const paragraphBlock = await waitFor( () =>
|
|
46
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ )
|
|
47
|
+
);
|
|
48
|
+
expect( paragraphBlock ).toBeDefined();
|
|
49
|
+
|
|
50
|
+
// Look for the highlight text color button
|
|
51
|
+
const textColorButton = await waitFor( () =>
|
|
52
|
+
getByA11yLabel( 'Text color' )
|
|
53
|
+
);
|
|
54
|
+
expect( textColorButton ).toBeDefined();
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
it( 'allows toggling the highlight color feature to type new text', async () => {
|
|
58
|
+
const {
|
|
59
|
+
getByA11yLabel,
|
|
60
|
+
getByTestId,
|
|
61
|
+
getByA11yHint,
|
|
62
|
+
} = initializeEditor();
|
|
63
|
+
|
|
64
|
+
// Wait for the editor placeholder
|
|
65
|
+
const paragraphPlaceholder = await waitFor( () =>
|
|
66
|
+
getByA11yLabel( 'Add paragraph block' )
|
|
67
|
+
);
|
|
68
|
+
expect( paragraphPlaceholder ).toBeDefined();
|
|
69
|
+
fireEvent.press( paragraphPlaceholder );
|
|
70
|
+
|
|
71
|
+
// Wait for the block to be created
|
|
72
|
+
const paragraphBlock = await waitFor( () =>
|
|
73
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ )
|
|
74
|
+
);
|
|
75
|
+
expect( paragraphBlock ).toBeDefined();
|
|
76
|
+
|
|
77
|
+
// Look for the highlight text color button
|
|
78
|
+
const textColorButton = await waitFor( () =>
|
|
79
|
+
getByA11yLabel( 'Text color' )
|
|
80
|
+
);
|
|
81
|
+
expect( textColorButton ).toBeDefined();
|
|
82
|
+
fireEvent.press( textColorButton );
|
|
83
|
+
|
|
84
|
+
// Wait for Inline color modal to be visible
|
|
85
|
+
const inlineTextColorModal = getByTestId( 'inline-text-color-modal' );
|
|
86
|
+
await waitFor( () => inlineTextColorModal.props.isVisible );
|
|
87
|
+
|
|
88
|
+
// Look for the pink color button
|
|
89
|
+
const pinkColorButton = await waitFor( () =>
|
|
90
|
+
getByA11yHint( COLOR_PINK )
|
|
91
|
+
);
|
|
92
|
+
expect( pinkColorButton ).toBeDefined();
|
|
93
|
+
fireEvent.press( pinkColorButton );
|
|
94
|
+
|
|
95
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
it( 'allows toggling the highlight color feature to selected text', async () => {
|
|
99
|
+
const {
|
|
100
|
+
getByA11yLabel,
|
|
101
|
+
getByTestId,
|
|
102
|
+
getByPlaceholderText,
|
|
103
|
+
getByA11yHint,
|
|
104
|
+
} = initializeEditor();
|
|
105
|
+
const text = 'Hello this is a test';
|
|
106
|
+
|
|
107
|
+
// Wait for the editor placeholder
|
|
108
|
+
const paragraphPlaceholder = await waitFor( () =>
|
|
109
|
+
getByA11yLabel( 'Add paragraph block' )
|
|
110
|
+
);
|
|
111
|
+
expect( paragraphPlaceholder ).toBeDefined();
|
|
112
|
+
fireEvent.press( paragraphPlaceholder );
|
|
113
|
+
|
|
114
|
+
// Wait for the block to be created
|
|
115
|
+
const paragraphBlock = await waitFor( () =>
|
|
116
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ )
|
|
117
|
+
);
|
|
118
|
+
expect( paragraphBlock ).toBeDefined();
|
|
119
|
+
|
|
120
|
+
// Update TextInput value
|
|
121
|
+
const paragraphText = getByPlaceholderText( 'Start writing…' );
|
|
122
|
+
fireEvent( paragraphText, 'onSelectionChange', 0, text.length, text, {
|
|
123
|
+
nativeEvent: {
|
|
124
|
+
eventCount: 1,
|
|
125
|
+
target: undefined,
|
|
126
|
+
text,
|
|
127
|
+
},
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
// Look for the highlight text color button
|
|
131
|
+
const textColorButton = await waitFor( () =>
|
|
132
|
+
getByA11yLabel( 'Text color' )
|
|
133
|
+
);
|
|
134
|
+
expect( textColorButton ).toBeDefined();
|
|
135
|
+
fireEvent.press( textColorButton );
|
|
136
|
+
|
|
137
|
+
// Wait for Inline color modal to be visible
|
|
138
|
+
const inlineTextColorModal = getByTestId( 'inline-text-color-modal' );
|
|
139
|
+
await waitFor( () => inlineTextColorModal.props.isVisible );
|
|
140
|
+
|
|
141
|
+
// Look for the pink color button
|
|
142
|
+
const pinkColorButton = await waitFor( () =>
|
|
143
|
+
getByA11yHint( COLOR_PINK )
|
|
144
|
+
);
|
|
145
|
+
expect( pinkColorButton ).toBeDefined();
|
|
146
|
+
fireEvent.press( pinkColorButton );
|
|
147
|
+
|
|
148
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
it( 'creates a paragraph block with the text color format', async () => {
|
|
152
|
+
const { getByA11yLabel } = initializeEditor( {
|
|
153
|
+
initialHtml: TEXT_WITH_COLOR,
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
// Wait for the block to be created
|
|
157
|
+
const paragraphBlock = await waitFor( () =>
|
|
158
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ )
|
|
159
|
+
);
|
|
160
|
+
expect( paragraphBlock ).toBeDefined();
|
|
161
|
+
|
|
162
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
163
|
+
} );
|
|
164
|
+
} );
|