@wordpress/format-library 4.10.0 → 4.12.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 +4 -0
- package/build/bold/index.js +6 -8
- package/build/bold/index.js.map +1 -1
- package/build/code/index.js +6 -8
- package/build/code/index.js.map +1 -1
- package/build/default-formats.js +3 -1
- package/build/default-formats.js.map +1 -1
- package/build/image/index.js +24 -28
- package/build/image/index.js.map +1 -1
- package/build/index.js +4 -7
- package/build/index.js.map +1 -1
- package/build/italic/index.js +6 -8
- package/build/italic/index.js.map +1 -1
- package/build/keyboard/index.js +6 -8
- package/build/keyboard/index.js.map +1 -1
- package/build/language/index.js +114 -0
- package/build/language/index.js.map +1 -0
- package/build/link/index.js +12 -15
- package/build/link/index.js.map +1 -1
- package/build/link/index.native.js +4 -7
- package/build/link/index.native.js.map +1 -1
- package/build/link/inline.js +10 -11
- package/build/link/inline.js.map +1 -1
- package/build/link/modal-screens/link-picker-screen.native.js +4 -6
- package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build/link/modal-screens/link-settings-screen.native.js +25 -33
- package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build/link/modal.native.js +6 -6
- package/build/link/modal.native.js.map +1 -1
- package/build/link/utils.js +18 -44
- package/build/link/utils.js.map +1 -1
- package/build/strikethrough/index.js +6 -8
- package/build/strikethrough/index.js.map +1 -1
- package/build/subscript/index.js +6 -8
- package/build/subscript/index.js.map +1 -1
- package/build/superscript/index.js +6 -8
- package/build/superscript/index.js.map +1 -1
- package/build/text-color/index.js +11 -14
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/index.native.js +16 -23
- package/build/text-color/index.native.js.map +1 -1
- package/build/text-color/inline.js +15 -21
- package/build/text-color/inline.js.map +1 -1
- package/build/text-color/inline.native.js +16 -24
- package/build/text-color/inline.native.js.map +1 -1
- package/build/underline/index.js +4 -6
- package/build/underline/index.js.map +1 -1
- package/build/unknown/index.js +6 -8
- package/build/unknown/index.js.map +1 -1
- package/build-module/bold/index.js +6 -8
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +6 -8
- package/build-module/code/index.js.map +1 -1
- package/build-module/default-formats.js +2 -1
- package/build-module/default-formats.js.map +1 -1
- package/build-module/image/index.js +24 -28
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +4 -7
- package/build-module/index.js.map +1 -1
- package/build-module/italic/index.js +6 -8
- package/build-module/italic/index.js.map +1 -1
- package/build-module/keyboard/index.js +6 -8
- package/build-module/keyboard/index.js.map +1 -1
- package/build-module/language/index.js +104 -0
- package/build-module/language/index.js.map +1 -0
- package/build-module/link/index.js +12 -15
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/index.native.js +4 -7
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/inline.js +10 -11
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +4 -5
- 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 +25 -33
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/link/modal.native.js +6 -6
- package/build-module/link/modal.native.js.map +1 -1
- package/build-module/link/utils.js +18 -44
- package/build-module/link/utils.js.map +1 -1
- package/build-module/strikethrough/index.js +6 -8
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/subscript/index.js +6 -8
- package/build-module/subscript/index.js.map +1 -1
- package/build-module/superscript/index.js +6 -8
- package/build-module/superscript/index.js.map +1 -1
- package/build-module/text-color/index.js +11 -14
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/index.native.js +16 -23
- package/build-module/text-color/index.native.js.map +1 -1
- package/build-module/text-color/inline.js +15 -21
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/text-color/inline.native.js +16 -24
- package/build-module/text-color/inline.native.js.map +1 -1
- package/build-module/underline/index.js +4 -6
- package/build-module/underline/index.js.map +1 -1
- package/build-module/unknown/index.js +6 -8
- package/build-module/unknown/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -1
- package/build-style/style.css +6 -1
- package/package.json +13 -13
- package/src/default-formats.js +2 -0
- package/src/language/index.js +124 -0
- package/src/language/style.scss +6 -0
- package/src/link/index.native.js +1 -0
- package/src/link/modal.native.js +1 -0
- package/src/style.scss +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
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.
|
|
30
|
-
"@wordpress/block-editor": "^12.
|
|
31
|
-
"@wordpress/components": "^
|
|
32
|
-
"@wordpress/compose": "^6.
|
|
33
|
-
"@wordpress/data": "^9.
|
|
34
|
-
"@wordpress/element": "^5.
|
|
35
|
-
"@wordpress/html-entities": "^3.
|
|
36
|
-
"@wordpress/i18n": "^4.
|
|
37
|
-
"@wordpress/icons": "^9.
|
|
38
|
-
"@wordpress/rich-text": "^6.
|
|
39
|
-
"@wordpress/url": "^3.
|
|
29
|
+
"@wordpress/a11y": "^3.35.0",
|
|
30
|
+
"@wordpress/block-editor": "^12.3.0",
|
|
31
|
+
"@wordpress/components": "^25.1.0",
|
|
32
|
+
"@wordpress/compose": "^6.12.0",
|
|
33
|
+
"@wordpress/data": "^9.5.0",
|
|
34
|
+
"@wordpress/element": "^5.12.0",
|
|
35
|
+
"@wordpress/html-entities": "^3.35.0",
|
|
36
|
+
"@wordpress/i18n": "^4.35.0",
|
|
37
|
+
"@wordpress/icons": "^9.26.0",
|
|
38
|
+
"@wordpress/rich-text": "^6.12.0",
|
|
39
|
+
"@wordpress/url": "^3.36.0"
|
|
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": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
|
|
49
49
|
}
|
package/src/default-formats.js
CHANGED
|
@@ -13,6 +13,7 @@ import { subscript } from './subscript';
|
|
|
13
13
|
import { superscript } from './superscript';
|
|
14
14
|
import { keyboard } from './keyboard';
|
|
15
15
|
import { unknown } from './unknown';
|
|
16
|
+
import { language } from './language';
|
|
16
17
|
|
|
17
18
|
export default [
|
|
18
19
|
bold,
|
|
@@ -27,4 +28,5 @@ export default [
|
|
|
27
28
|
superscript,
|
|
28
29
|
keyboard,
|
|
29
30
|
unknown,
|
|
31
|
+
language,
|
|
30
32
|
];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { RichTextToolbarButton } from '@wordpress/block-editor';
|
|
10
|
+
import {
|
|
11
|
+
TextControl,
|
|
12
|
+
SelectControl,
|
|
13
|
+
Button,
|
|
14
|
+
Popover,
|
|
15
|
+
__experimentalHStack as HStack,
|
|
16
|
+
} from '@wordpress/components';
|
|
17
|
+
import { useState } from '@wordpress/element';
|
|
18
|
+
import { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';
|
|
19
|
+
import { language as languageIcon } from '@wordpress/icons';
|
|
20
|
+
|
|
21
|
+
const name = 'core/language';
|
|
22
|
+
const title = __( 'Language' );
|
|
23
|
+
|
|
24
|
+
export const language = {
|
|
25
|
+
name,
|
|
26
|
+
tagName: 'bdo',
|
|
27
|
+
className: null,
|
|
28
|
+
edit: Edit,
|
|
29
|
+
title,
|
|
30
|
+
};
|
|
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
|
+
|
|
42
|
+
const [ isPopoverVisible, setIsPopoverVisible ] = useState( false );
|
|
43
|
+
const togglePopover = () => {
|
|
44
|
+
setIsPopoverVisible( ( state ) => ! state );
|
|
45
|
+
setLang( '' );
|
|
46
|
+
setDir( 'ltr' );
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
<RichTextToolbarButton
|
|
52
|
+
icon={ languageIcon }
|
|
53
|
+
label={ title }
|
|
54
|
+
title={ title }
|
|
55
|
+
onClick={ () => {
|
|
56
|
+
if ( isActive ) {
|
|
57
|
+
onChange( removeFormat( value, name ) );
|
|
58
|
+
} else {
|
|
59
|
+
togglePopover();
|
|
60
|
+
}
|
|
61
|
+
} }
|
|
62
|
+
isActive={ isActive }
|
|
63
|
+
role="menuitemcheckbox"
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
{ isPopoverVisible && (
|
|
67
|
+
<Popover
|
|
68
|
+
className="block-editor-format-toolbar__language-popover"
|
|
69
|
+
anchor={ popoverAnchor }
|
|
70
|
+
placement="bottom"
|
|
71
|
+
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>
|
|
121
|
+
) }
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
124
|
+
}
|
package/src/link/index.native.js
CHANGED
package/src/link/modal.native.js
CHANGED
|
@@ -19,6 +19,7 @@ const ModalLinkUI = ( { isVisible, ...restProps } ) => {
|
|
|
19
19
|
hideHeader
|
|
20
20
|
onClose={ restProps.onClose }
|
|
21
21
|
hasNavigation
|
|
22
|
+
testID="link-settings-modal"
|
|
22
23
|
>
|
|
23
24
|
<BottomSheet.NavigationContainer animate main>
|
|
24
25
|
<BottomSheet.NavigationScreen name={ screens.settings }>
|
package/src/style.scss
CHANGED