@wordpress/format-library 4.11.0 → 4.12.1

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +6 -8
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +6 -8
  5. package/build/code/index.js.map +1 -1
  6. package/build/image/index.js +24 -28
  7. package/build/image/index.js.map +1 -1
  8. package/build/index.js +4 -7
  9. package/build/index.js.map +1 -1
  10. package/build/italic/index.js +6 -8
  11. package/build/italic/index.js.map +1 -1
  12. package/build/keyboard/index.js +6 -8
  13. package/build/keyboard/index.js.map +1 -1
  14. package/build/language/index.js +31 -20
  15. package/build/language/index.js.map +1 -1
  16. package/build/link/index.js +17 -17
  17. package/build/link/index.js.map +1 -1
  18. package/build/link/index.native.js +2 -6
  19. package/build/link/index.native.js.map +1 -1
  20. package/build/link/inline.js +11 -11
  21. package/build/link/inline.js.map +1 -1
  22. package/build/link/modal-screens/link-picker-screen.native.js +4 -6
  23. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  24. package/build/link/modal-screens/link-settings-screen.native.js +25 -33
  25. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  26. package/build/link/modal.native.js +8 -10
  27. package/build/link/modal.native.js.map +1 -1
  28. package/build/link/utils.js +18 -44
  29. package/build/link/utils.js.map +1 -1
  30. package/build/strikethrough/index.js +6 -8
  31. package/build/strikethrough/index.js.map +1 -1
  32. package/build/subscript/index.js +6 -8
  33. package/build/subscript/index.js.map +1 -1
  34. package/build/superscript/index.js +6 -8
  35. package/build/superscript/index.js.map +1 -1
  36. package/build/text-color/index.js +11 -14
  37. package/build/text-color/index.js.map +1 -1
  38. package/build/text-color/index.native.js +16 -23
  39. package/build/text-color/index.native.js.map +1 -1
  40. package/build/text-color/inline.js +15 -21
  41. package/build/text-color/inline.js.map +1 -1
  42. package/build/text-color/inline.native.js +16 -24
  43. package/build/text-color/inline.native.js.map +1 -1
  44. package/build/underline/index.js +4 -6
  45. package/build/underline/index.js.map +1 -1
  46. package/build/unknown/index.js +6 -8
  47. package/build/unknown/index.js.map +1 -1
  48. package/build-module/bold/index.js +6 -8
  49. package/build-module/bold/index.js.map +1 -1
  50. package/build-module/code/index.js +6 -8
  51. package/build-module/code/index.js.map +1 -1
  52. package/build-module/image/index.js +24 -28
  53. package/build-module/image/index.js.map +1 -1
  54. package/build-module/index.js +4 -7
  55. package/build-module/index.js.map +1 -1
  56. package/build-module/italic/index.js +6 -8
  57. package/build-module/italic/index.js.map +1 -1
  58. package/build-module/keyboard/index.js +6 -8
  59. package/build-module/keyboard/index.js.map +1 -1
  60. package/build-module/language/index.js +31 -20
  61. package/build-module/language/index.js.map +1 -1
  62. package/build-module/link/index.js +17 -17
  63. package/build-module/link/index.js.map +1 -1
  64. package/build-module/link/index.native.js +2 -6
  65. package/build-module/link/index.native.js.map +1 -1
  66. package/build-module/link/inline.js +11 -11
  67. package/build-module/link/inline.js.map +1 -1
  68. package/build-module/link/modal-screens/link-picker-screen.native.js +4 -5
  69. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  70. package/build-module/link/modal-screens/link-settings-screen.native.js +25 -33
  71. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  72. package/build-module/link/modal.native.js +8 -9
  73. package/build-module/link/modal.native.js.map +1 -1
  74. package/build-module/link/utils.js +18 -44
  75. package/build-module/link/utils.js.map +1 -1
  76. package/build-module/strikethrough/index.js +6 -8
  77. package/build-module/strikethrough/index.js.map +1 -1
  78. package/build-module/subscript/index.js +6 -8
  79. package/build-module/subscript/index.js.map +1 -1
  80. package/build-module/superscript/index.js +6 -8
  81. package/build-module/superscript/index.js.map +1 -1
  82. package/build-module/text-color/index.js +11 -14
  83. package/build-module/text-color/index.js.map +1 -1
  84. package/build-module/text-color/index.native.js +16 -23
  85. package/build-module/text-color/index.native.js.map +1 -1
  86. package/build-module/text-color/inline.js +15 -21
  87. package/build-module/text-color/inline.js.map +1 -1
  88. package/build-module/text-color/inline.native.js +16 -24
  89. package/build-module/text-color/inline.native.js.map +1 -1
  90. package/build-module/underline/index.js +4 -6
  91. package/build-module/underline/index.js.map +1 -1
  92. package/build-module/unknown/index.js +6 -8
  93. package/build-module/unknown/index.js.map +1 -1
  94. package/package.json +13 -13
  95. package/src/language/index.js +73 -66
  96. package/src/link/index.js +4 -2
  97. package/src/link/inline.js +1 -0
  98. package/src/link/test/__snapshots__/modal.native.js.snap +476 -0
  99. package/src/link/test/index.native.js +15 -15
  100. package/src/link/test/modal.native.js +5 -2
@@ -29,21 +29,10 @@ export const language = {
29
29
  title,
30
30
  };
31
31
 
32
- function Edit( props ) {
33
- const { contentRef, isActive, onChange, value } = props;
34
- const popoverAnchor = useAnchor( {
35
- editableContentElement: contentRef.current,
36
- settings: language,
37
- } );
38
-
39
- const [ lang, setLang ] = useState( '' );
40
- const [ dir, setDir ] = useState( 'ltr' );
41
-
32
+ function Edit( { isActive, value, onChange, contentRef } ) {
42
33
  const [ isPopoverVisible, setIsPopoverVisible ] = useState( false );
43
34
  const togglePopover = () => {
44
35
  setIsPopoverVisible( ( state ) => ! state );
45
- setLang( '' );
46
- setDir( 'ltr' );
47
36
  };
48
37
 
49
38
  return (
@@ -62,63 +51,81 @@ function Edit( props ) {
62
51
  isActive={ isActive }
63
52
  role="menuitemcheckbox"
64
53
  />
65
-
66
54
  { isPopoverVisible && (
67
- <Popover
68
- className="block-editor-format-toolbar__language-popover"
69
- anchor={ popoverAnchor }
70
- placement="bottom"
55
+ <InlineLanguageUI
56
+ value={ value }
57
+ onChange={ onChange }
71
58
  onClose={ togglePopover }
72
- >
73
- <form
74
- className="block-editor-format-toolbar__language-container-content"
75
- onSubmit={ ( event ) => {
76
- onChange(
77
- applyFormat( value, {
78
- type: name,
79
- attributes: {
80
- lang,
81
- dir,
82
- },
83
- } )
84
- );
85
- togglePopover();
86
- event.preventDefault();
87
- } }
88
- >
89
- <TextControl
90
- label={ title }
91
- value={ lang }
92
- onChange={ ( val ) => setLang( val ) }
93
- help={ __(
94
- 'A valid language attribute, like "en" or "fr".'
95
- ) }
96
- />
97
- <SelectControl
98
- label={ __( 'Text direction' ) }
99
- value={ dir }
100
- options={ [
101
- {
102
- label: __( 'Left to right' ),
103
- value: 'ltr',
104
- },
105
- {
106
- label: __( 'Right to left' ),
107
- value: 'rtl',
108
- },
109
- ] }
110
- onChange={ ( val ) => setDir( val ) }
111
- />
112
- <HStack alignment="right">
113
- <Button
114
- variant="primary"
115
- type="submit"
116
- text={ __( 'Apply' ) }
117
- />
118
- </HStack>
119
- </form>
120
- </Popover>
59
+ contentRef={ contentRef }
60
+ />
121
61
  ) }
122
62
  </>
123
63
  );
124
64
  }
65
+
66
+ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
67
+ const popoverAnchor = useAnchor( {
68
+ editableContentElement: contentRef.current,
69
+ settings: language,
70
+ } );
71
+
72
+ const [ lang, setLang ] = useState( '' );
73
+ const [ dir, setDir ] = useState( 'ltr' );
74
+
75
+ return (
76
+ <Popover
77
+ className="block-editor-format-toolbar__language-popover"
78
+ anchor={ popoverAnchor }
79
+ placement="bottom"
80
+ onClose={ onClose }
81
+ >
82
+ <form
83
+ className="block-editor-format-toolbar__language-container-content"
84
+ onSubmit={ ( event ) => {
85
+ event.preventDefault();
86
+ onChange(
87
+ applyFormat( value, {
88
+ type: name,
89
+ attributes: {
90
+ lang,
91
+ dir,
92
+ },
93
+ } )
94
+ );
95
+ onClose();
96
+ } }
97
+ >
98
+ <TextControl
99
+ label={ title }
100
+ value={ lang }
101
+ onChange={ ( val ) => setLang( val ) }
102
+ help={ __(
103
+ 'A valid language attribute, like "en" or "fr".'
104
+ ) }
105
+ />
106
+ <SelectControl
107
+ label={ __( 'Text direction' ) }
108
+ value={ dir }
109
+ options={ [
110
+ {
111
+ label: __( 'Left to right' ),
112
+ value: 'ltr',
113
+ },
114
+ {
115
+ label: __( 'Right to left' ),
116
+ value: 'rtl',
117
+ },
118
+ ] }
119
+ onChange={ ( val ) => setDir( val ) }
120
+ />
121
+ <HStack alignment="right">
122
+ <Button
123
+ variant="primary"
124
+ type="submit"
125
+ text={ __( 'Apply' ) }
126
+ />
127
+ </HStack>
128
+ </form>
129
+ </Popover>
130
+ );
131
+ }
package/src/link/index.js CHANGED
@@ -60,9 +60,11 @@ function Edit( {
60
60
  }
61
61
  }
62
62
 
63
- function stopAddingLink() {
63
+ function stopAddingLink( returnFocus = true ) {
64
64
  setAddingLink( false );
65
- onFocus();
65
+ if ( returnFocus ) {
66
+ onFocus();
67
+ }
66
68
  }
67
69
 
68
70
  function onRemoveFormat() {
@@ -255,6 +255,7 @@ function InlineLinkUI( {
255
255
  anchor={ popoverAnchor }
256
256
  focusOnMount={ focusOnMount.current }
257
257
  onClose={ stopAddingLink }
258
+ onFocusOutside={ () => stopAddingLink( false ) }
258
259
  placement="bottom"
259
260
  shift
260
261
  >
@@ -0,0 +1,476 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`LinksUI LinksUI renders 1`] = `
4
+ <Modal
5
+ animationInTiming={400}
6
+ animationOutTiming={300}
7
+ backdropOpacity={0.2}
8
+ backdropTransitionInTiming={50}
9
+ backdropTransitionOutTiming={50}
10
+ isVisible={true}
11
+ onAccessibilityEscape={[Function]}
12
+ onBackButtonPress={[Function]}
13
+ onBackdropPress={[Function]}
14
+ onModalHide={[Function]}
15
+ onMoveShouldSetResponder={[Function]}
16
+ onMoveShouldSetResponderCapture={[Function]}
17
+ onSwipeComplete={[Function]}
18
+ preferredColorScheme="light"
19
+ swipeDirection="down"
20
+ testID="link-settings-modal"
21
+ >
22
+ <View
23
+ behavior={false}
24
+ style={
25
+ {
26
+ "borderColor": "rgba(0, 0, 0, 0.1)",
27
+ "flex": undefined,
28
+ "marginTop": 0,
29
+ "maxWidth": 512,
30
+ }
31
+ }
32
+ >
33
+ <View
34
+ onLayout={[Function]}
35
+ testID="link-settings-modal-header"
36
+ >
37
+ <View />
38
+ </View>
39
+ <View
40
+ style={
41
+ {
42
+ "maxHeight": 787.06,
43
+ }
44
+ }
45
+ >
46
+ <View
47
+ style={
48
+ [
49
+ undefined,
50
+ {
51
+ "height": 1,
52
+ },
53
+ ]
54
+ }
55
+ >
56
+ <RNGestureHandlerRootView
57
+ style={
58
+ {
59
+ "flex": 1,
60
+ }
61
+ }
62
+ >
63
+ <View
64
+ onLayout={[Function]}
65
+ style={
66
+ {
67
+ "flex": 1,
68
+ }
69
+ }
70
+ >
71
+ <View
72
+ pointerEvents="box-none"
73
+ style={
74
+ {
75
+ "bottom": 0,
76
+ "left": 0,
77
+ "position": "absolute",
78
+ "right": 0,
79
+ "top": 0,
80
+ }
81
+ }
82
+ >
83
+ <View
84
+ collapsable={false}
85
+ style={
86
+ {
87
+ "opacity": 1,
88
+ }
89
+ }
90
+ />
91
+ <View
92
+ accessibilityElementsHidden={false}
93
+ closing={false}
94
+ gestureVelocityImpact={0.3}
95
+ importantForAccessibility="auto"
96
+ onClose={[Function]}
97
+ onGestureBegin={[Function]}
98
+ onGestureCanceled={[Function]}
99
+ onOpen={[Function]}
100
+ onTransitionStart={[Function]}
101
+ pointerEvents="box-none"
102
+ style={
103
+ {
104
+ "bottom": 0,
105
+ "left": 0,
106
+ "position": "absolute",
107
+ "right": 0,
108
+ "top": 0,
109
+ }
110
+ }
111
+ transitionSpec={
112
+ {
113
+ "close": {
114
+ "animation": "timing",
115
+ "config": {
116
+ "duration": 200,
117
+ "easing": [Function],
118
+ },
119
+ },
120
+ "open": {
121
+ "animation": "timing",
122
+ "config": {
123
+ "duration": 200,
124
+ "easing": [Function],
125
+ },
126
+ },
127
+ }
128
+ }
129
+ >
130
+ <View
131
+ pointerEvents="box-none"
132
+ style={
133
+ {
134
+ "bottom": 0,
135
+ "left": 0,
136
+ "position": "absolute",
137
+ "right": 0,
138
+ "top": 0,
139
+ }
140
+ }
141
+ />
142
+ <View
143
+ collapsable={false}
144
+ pointerEvents="box-none"
145
+ style={
146
+ {
147
+ "flex": 1,
148
+ }
149
+ }
150
+ >
151
+ <View
152
+ collapsable={false}
153
+ forwardedRef={[Function]}
154
+ handlerTag={1}
155
+ handlerType="PanGestureHandler"
156
+ onGestureHandlerEvent={[Function]}
157
+ onGestureHandlerStateChange={[Function]}
158
+ style={
159
+ {
160
+ "flex": 1,
161
+ "opacity": 1,
162
+ }
163
+ }
164
+ >
165
+ <View
166
+ style={
167
+ [
168
+ {
169
+ "flex": 1,
170
+ "overflow": "hidden",
171
+ },
172
+ [
173
+ {
174
+ "backgroundColor": undefined,
175
+ },
176
+ undefined,
177
+ ],
178
+ ]
179
+ }
180
+ >
181
+ <View
182
+ style={
183
+ {
184
+ "flex": 1,
185
+ "flexDirection": "column-reverse",
186
+ }
187
+ }
188
+ >
189
+ <View
190
+ style={
191
+ {
192
+ "flex": 1,
193
+ }
194
+ }
195
+ >
196
+ <RCTScrollView
197
+ automaticallyAdjustContentInsets={false}
198
+ bounces={false}
199
+ contentContainerStyle={
200
+ [
201
+ {
202
+ "paddingLeft": 8,
203
+ "paddingRight": 8,
204
+ },
205
+ undefined,
206
+ {},
207
+ false,
208
+ ]
209
+ }
210
+ disableScrollViewPanResponder={true}
211
+ onScroll={[Function]}
212
+ safeAreaBottomInset={0}
213
+ scrollEnabled={true}
214
+ scrollEventThrottle={16}
215
+ style={
216
+ {
217
+ "maxHeight": 787.06,
218
+ }
219
+ }
220
+ >
221
+ <View>
222
+ <View
223
+ accessible={false}
224
+ focusable={false}
225
+ onClick={[Function]}
226
+ onResponderGrant={[Function]}
227
+ onResponderMove={[Function]}
228
+ onResponderRelease={[Function]}
229
+ onResponderTerminate={[Function]}
230
+ onResponderTerminationRequest={[Function]}
231
+ onStartShouldSetResponder={[Function]}
232
+ >
233
+ <View
234
+ onLayout={[Function]}
235
+ testID="navigation-screen-linkSettings"
236
+ >
237
+ <View
238
+ accessibilityLabel="Link to, Search or type URL"
239
+ accessibilityRole="button"
240
+ accessibilityState={
241
+ {
242
+ "disabled": false,
243
+ }
244
+ }
245
+ accessible={true}
246
+ collapsable={false}
247
+ focusable={true}
248
+ onClick={[Function]}
249
+ onResponderGrant={[Function]}
250
+ onResponderMove={[Function]}
251
+ onResponderRelease={[Function]}
252
+ onResponderTerminate={[Function]}
253
+ onResponderTerminationRequest={[Function]}
254
+ onStartShouldSetResponder={[Function]}
255
+ style={
256
+ {
257
+ "opacity": 1,
258
+ }
259
+ }
260
+ >
261
+ <View
262
+ pointerEvents="auto"
263
+ style={
264
+ [
265
+ undefined,
266
+ {},
267
+ ]
268
+ }
269
+ >
270
+ <View
271
+ style={
272
+ [
273
+ undefined,
274
+ {},
275
+ ]
276
+ }
277
+ >
278
+ <View>
279
+ <View
280
+ style={
281
+ [
282
+ undefined,
283
+ undefined,
284
+ ]
285
+ }
286
+ >
287
+ <Svg
288
+ height={24}
289
+ lock={true}
290
+ style={{}}
291
+ viewBox="0 0 24 24"
292
+ width={24}
293
+ xmlns="http://www.w3.org/2000/svg"
294
+ >
295
+ Path
296
+ </Svg>
297
+ <View />
298
+ </View>
299
+ <Text
300
+ style={
301
+ [
302
+ undefined,
303
+ {},
304
+ ]
305
+ }
306
+ >
307
+ Link to
308
+ </Text>
309
+ </View>
310
+ </View>
311
+ <Text
312
+ ellipsizeMode="middle"
313
+ numberOfLines={1}
314
+ style={
315
+ {
316
+ "color": "gray",
317
+ }
318
+ }
319
+ >
320
+ Search or type URL
321
+ </Text>
322
+ <View
323
+ pointerEvents="auto"
324
+ style={
325
+ [
326
+ false,
327
+ undefined,
328
+ ]
329
+ }
330
+ >
331
+ <Svg
332
+ height={24}
333
+ style={{}}
334
+ viewBox="0 0 24 24"
335
+ width={24}
336
+ xmlns="http://www.w3.org/2000/svg"
337
+ >
338
+ Path
339
+ </Svg>
340
+ </View>
341
+ </View>
342
+ <View
343
+ style={{}}
344
+ />
345
+ </View>
346
+ <View
347
+ accessibilityHint="Double tap to edit this value"
348
+ accessibilityLabel="Link text. Empty"
349
+ accessibilityRole="button"
350
+ accessibilityState={
351
+ {
352
+ "disabled": false,
353
+ }
354
+ }
355
+ accessible={true}
356
+ collapsable={false}
357
+ focusable={true}
358
+ onClick={[Function]}
359
+ onResponderGrant={[Function]}
360
+ onResponderMove={[Function]}
361
+ onResponderRelease={[Function]}
362
+ onResponderTerminate={[Function]}
363
+ onResponderTerminationRequest={[Function]}
364
+ onStartShouldSetResponder={[Function]}
365
+ style={
366
+ {
367
+ "opacity": 1,
368
+ }
369
+ }
370
+ >
371
+ <View
372
+ pointerEvents="auto"
373
+ style={
374
+ [
375
+ undefined,
376
+ {},
377
+ ]
378
+ }
379
+ >
380
+ <View
381
+ style={
382
+ [
383
+ undefined,
384
+ {},
385
+ ]
386
+ }
387
+ >
388
+ <View>
389
+ <View
390
+ style={
391
+ [
392
+ undefined,
393
+ undefined,
394
+ ]
395
+ }
396
+ >
397
+ <Svg
398
+ height={24}
399
+ lock={true}
400
+ style={{}}
401
+ viewBox="0 0 24 24"
402
+ width={24}
403
+ xmlns="http://www.w3.org/2000/svg"
404
+ >
405
+ Path
406
+ </Svg>
407
+ <View />
408
+ </View>
409
+ <Text
410
+ style={
411
+ [
412
+ undefined,
413
+ {},
414
+ ]
415
+ }
416
+ >
417
+ Link text
418
+ </Text>
419
+ </View>
420
+ </View>
421
+ <TextInput
422
+ disabled={false}
423
+ editable={true}
424
+ keyboardType="default"
425
+ numberOfLines={1}
426
+ onBlur={[Function]}
427
+ onChangeText={[Function]}
428
+ onFocus={[Function]}
429
+ onSubmitEditing={[Function]}
430
+ placeholder="Add link text"
431
+ placeholderTextColor="gray"
432
+ pointerEvents="none"
433
+ preferredColorScheme="light"
434
+ style={{}}
435
+ value=""
436
+ />
437
+ <View
438
+ pointerEvents="auto"
439
+ style={
440
+ [
441
+ false,
442
+ undefined,
443
+ ]
444
+ }
445
+ />
446
+ </View>
447
+ <View />
448
+ </View>
449
+ <View
450
+ style={
451
+ {
452
+ "height": 20,
453
+ }
454
+ }
455
+ />
456
+ </View>
457
+ </View>
458
+ </View>
459
+ </RCTScrollView>
460
+ </View>
461
+ <View
462
+ pointerEvents="box-none"
463
+ />
464
+ </View>
465
+ </View>
466
+ </View>
467
+ </View>
468
+ </View>
469
+ </View>
470
+ </View>
471
+ </RNGestureHandlerRootView>
472
+ </View>
473
+ </View>
474
+ </View>
475
+ </Modal>
476
+ `;