@wordpress/format-library 4.12.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.
- package/build/language/index.js +31 -20
- package/build/language/index.js.map +1 -1
- package/build/link/index.js +5 -2
- package/build/link/index.js.map +1 -1
- package/build/link/inline.js +1 -0
- package/build/link/inline.js.map +1 -1
- package/build/link/modal.native.js +4 -5
- package/build/link/modal.native.js.map +1 -1
- package/build-module/language/index.js +31 -20
- package/build-module/language/index.js.map +1 -1
- package/build-module/link/index.js +5 -2
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/inline.js +1 -0
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal.native.js +4 -4
- package/build-module/link/modal.native.js.map +1 -1
- package/package.json +13 -13
- package/src/language/index.js +73 -66
- package/src/link/index.js +4 -2
- package/src/link/inline.js +1 -0
- package/src/link/test/__snapshots__/modal.native.js.snap +476 -0
- package/src/link/test/index.native.js +15 -15
- package/src/link/test/modal.native.js +5 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import { createElement } from "@wordpress/element";
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -30,9 +29,10 @@ const ModalLinkUI = ({
|
|
|
30
29
|
main: true
|
|
31
30
|
}, createElement(BottomSheet.NavigationScreen, {
|
|
32
31
|
name: screens.settings
|
|
33
|
-
}, createElement(LinkSettingsScreen,
|
|
34
|
-
isVisible: isVisible
|
|
35
|
-
|
|
32
|
+
}, createElement(LinkSettingsScreen, {
|
|
33
|
+
isVisible: isVisible,
|
|
34
|
+
...restProps
|
|
35
|
+
})), createElement(BottomSheet.NavigationScreen, {
|
|
36
36
|
name: screens.picker,
|
|
37
37
|
isScrollable: true,
|
|
38
38
|
fullScreen: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["useMemo","BottomSheet","withSpokenMessages","screens","LinkSettingsScreen","LinkPickerScreen","ModalLinkUI","isVisible","restProps","onClose","settings","picker"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["useMemo","BottomSheet","withSpokenMessages","screens","LinkSettingsScreen","LinkPickerScreen","ModalLinkUI","isVisible","restProps","onClose","settings","picker"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,WAAT,EAAsBC,kBAAtB,QAAgD,uBAAhD;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,yBAApB;AACA,OAAOC,kBAAP,MAA+B,sCAA/B;AACA,OAAOC,gBAAP,MAA6B,oCAA7B;;AAEA,MAAMC,WAAW,GAAG,CAAE;AAAEC,EAAAA,SAAF;AAAa,KAAGC;AAAhB,CAAF,KAAmC;AACtD,SAAOR,OAAO,CAAE,MAAM;AACrB,WACC,cAAC,WAAD;AACC,MAAA,SAAS,EAAGO,SADb;AAEC,MAAA,UAAU,MAFX;AAGC,MAAA,OAAO,EAAGC,SAAS,CAACC,OAHrB;AAIC,MAAA,aAAa,MAJd;AAKC,MAAA,MAAM,EAAC;AALR,OAOC,cAAC,WAAD,CAAa,mBAAb;AAAiC,MAAA,OAAO,MAAxC;AAAyC,MAAA,IAAI;AAA7C,OACC,cAAC,WAAD,CAAa,gBAAb;AAA8B,MAAA,IAAI,EAAGN,OAAO,CAACO;AAA7C,OACC,cAAC,kBAAD;AACC,MAAA,SAAS,EAAGH,SADb;AAAA,SAEMC;AAFN,MADD,CADD,EAOC,cAAC,WAAD,CAAa,gBAAb;AACC,MAAA,IAAI,EAAGL,OAAO,CAACQ,MADhB;AAEC,MAAA,YAAY,MAFb;AAGC,MAAA,UAAU;AAHX,OAKC,cAAC,gBAAD,OALD,CAPD,CAPD,CADD;AAyBA,GA1Ba,EA0BX,CAAEJ,SAAF,CA1BW,CAAd;AA2BA,CA5BD;;AA8BA,eAAeL,kBAAkB,CAAEI,WAAF,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.1",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/a11y": "^3.35.
|
|
30
|
-
"@wordpress/block-editor": "^12.3.
|
|
31
|
-
"@wordpress/components": "^25.1.
|
|
32
|
-
"@wordpress/compose": "^6.12.
|
|
33
|
-
"@wordpress/data": "^9.5.
|
|
34
|
-
"@wordpress/element": "^5.12.
|
|
35
|
-
"@wordpress/html-entities": "^3.35.
|
|
36
|
-
"@wordpress/i18n": "^4.35.
|
|
37
|
-
"@wordpress/icons": "^9.26.
|
|
38
|
-
"@wordpress/rich-text": "^6.12.
|
|
39
|
-
"@wordpress/url": "^3.36.
|
|
29
|
+
"@wordpress/a11y": "^3.35.1",
|
|
30
|
+
"@wordpress/block-editor": "^12.3.1",
|
|
31
|
+
"@wordpress/components": "^25.1.1",
|
|
32
|
+
"@wordpress/compose": "^6.12.1",
|
|
33
|
+
"@wordpress/data": "^9.5.1",
|
|
34
|
+
"@wordpress/element": "^5.12.1",
|
|
35
|
+
"@wordpress/html-entities": "^3.35.1",
|
|
36
|
+
"@wordpress/i18n": "^4.35.1",
|
|
37
|
+
"@wordpress/icons": "^9.26.1",
|
|
38
|
+
"@wordpress/rich-text": "^6.12.1",
|
|
39
|
+
"@wordpress/url": "^3.36.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18.0.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ce5639111c30763dbdf07f40eeb136ea6030ecf1"
|
|
49
49
|
}
|
package/src/language/index.js
CHANGED
|
@@ -29,21 +29,10 @@ export const language = {
|
|
|
29
29
|
title,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
function Edit(
|
|
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
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
placement="bottom"
|
|
55
|
+
<InlineLanguageUI
|
|
56
|
+
value={ value }
|
|
57
|
+
onChange={ onChange }
|
|
71
58
|
onClose={ togglePopover }
|
|
72
|
-
|
|
73
|
-
|
|
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