@wordpress/editor 12.5.4 → 12.7.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/components/post-featured-image/index.js +84 -41
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-text-editor/index.js +11 -0
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/components/post-title/index.js +13 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-visibility/index.js +132 -167
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +5 -22
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js +14 -13
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +86 -42
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-text-editor/index.js +12 -1
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/components/post-title/index.js +12 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-visibility/index.js +132 -166
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +5 -20
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js +14 -13
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-style/style-rtl.css +42 -51
- package/build-style/style.css +42 -51
- package/package.json +28 -27
- package/src/components/autosave-monitor/test/index.js +3 -0
- package/src/components/post-featured-image/index.js +102 -69
- package/src/components/post-text-editor/index.js +14 -1
- package/src/components/post-title/index.js +16 -2
- package/src/components/post-visibility/index.js +130 -150
- package/src/components/post-visibility/label.js +6 -15
- package/src/components/post-visibility/style.scss +25 -20
- package/src/components/post-visibility/utils.js +7 -12
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { useState } from '@wordpress/element';
|
|
6
6
|
import {
|
|
7
7
|
VisuallyHidden,
|
|
8
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
|
+
Button,
|
|
9
10
|
} from '@wordpress/components';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { close as closeIcon } from '@wordpress/icons';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Internal dependencies
|
|
@@ -16,172 +18,150 @@ import { withSelect, withDispatch } from '@wordpress/data';
|
|
|
16
18
|
import { visibilityOptions } from './utils';
|
|
17
19
|
import { store as editorStore } from '../../store';
|
|
18
20
|
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
super( ...arguments );
|
|
21
|
+
export default function PostVisibility( { onClose } ) {
|
|
22
|
+
const instanceId = useInstanceId( PostVisibility );
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const { status, visibility, password } = useSelect( ( select ) => ( {
|
|
25
|
+
status: select( editorStore ).getEditedPostAttribute( 'status' ),
|
|
26
|
+
visibility: select( editorStore ).getEditedPostVisibility(),
|
|
27
|
+
password: select( editorStore ).getEditedPostAttribute( 'password' ),
|
|
28
|
+
} ) );
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
hasPassword: !! props.password,
|
|
30
|
-
showPrivateConfirmDialog: false,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
30
|
+
const { editPost, savePost } = useDispatch( editorStore );
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const [ hasPassword, setHasPassword ] = useState( !! password );
|
|
33
|
+
const [ showPrivateConfirmDialog, setShowPrivateConfirmDialog ] = useState(
|
|
34
|
+
false
|
|
35
|
+
);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
setPrivate() {
|
|
42
|
-
this.setState( { showPrivateConfirmDialog: true } );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
confirmPrivate = () => {
|
|
46
|
-
const { onUpdateVisibility, onSave } = this.props;
|
|
47
|
-
|
|
48
|
-
onUpdateVisibility( 'private' );
|
|
49
|
-
this.setState( {
|
|
50
|
-
hasPassword: false,
|
|
51
|
-
showPrivateConfirmDialog: false,
|
|
37
|
+
const setPublic = () => {
|
|
38
|
+
editPost( {
|
|
39
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
40
|
+
password: '',
|
|
52
41
|
} );
|
|
53
|
-
|
|
42
|
+
setHasPassword( false );
|
|
54
43
|
};
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
const setPrivate = () => {
|
|
46
|
+
setShowPrivateConfirmDialog( true );
|
|
58
47
|
};
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
this.setState( { hasPassword: true } );
|
|
68
|
-
}
|
|
49
|
+
const confirmPrivate = () => {
|
|
50
|
+
editPost( { status: 'private', password: '' } );
|
|
51
|
+
setHasPassword( false );
|
|
52
|
+
setShowPrivateConfirmDialog( false );
|
|
53
|
+
savePost();
|
|
54
|
+
};
|
|
69
55
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
56
|
+
const handleDialogCancel = () => {
|
|
57
|
+
setShowPrivateConfirmDialog( false );
|
|
58
|
+
};
|
|
74
59
|
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
const setPasswordProtected = () => {
|
|
61
|
+
editPost( {
|
|
62
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
63
|
+
password: password || '',
|
|
64
|
+
} );
|
|
65
|
+
setHasPassword( true );
|
|
66
|
+
};
|
|
77
67
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
checked: visibility === 'public' && ! this.state.hasPassword,
|
|
82
|
-
},
|
|
83
|
-
private: {
|
|
84
|
-
onSelect: this.setPrivate,
|
|
85
|
-
checked: visibility === 'private',
|
|
86
|
-
},
|
|
87
|
-
password: {
|
|
88
|
-
onSelect: this.setPasswordProtected,
|
|
89
|
-
checked: this.state.hasPassword,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
68
|
+
const updatePassword = ( event ) => {
|
|
69
|
+
editPost( { password: event.target.value } );
|
|
70
|
+
};
|
|
92
71
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
className="editor-post-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<Button
|
|
75
|
+
className="editor-post-visibility__close"
|
|
76
|
+
isSmall
|
|
77
|
+
icon={ closeIcon }
|
|
78
|
+
onClick={ onClose }
|
|
79
|
+
/>
|
|
80
|
+
<fieldset className="editor-post-visibility__fieldset">
|
|
81
|
+
<legend className="editor-post-visibility__legend">
|
|
82
|
+
{ __( 'Visibility' ) }
|
|
100
83
|
</legend>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
<p className="editor-post-visibility__description">
|
|
85
|
+
{ __( 'Control how this post is viewed.' ) }
|
|
86
|
+
</p>
|
|
87
|
+
<PostVisibilityChoice
|
|
88
|
+
instanceId={ instanceId }
|
|
89
|
+
value="public"
|
|
90
|
+
label={ visibilityOptions.public.label }
|
|
91
|
+
info={ visibilityOptions.public.info }
|
|
92
|
+
checked={ visibility === 'public' && ! hasPassword }
|
|
93
|
+
onChange={ setPublic }
|
|
94
|
+
/>
|
|
95
|
+
<PostVisibilityChoice
|
|
96
|
+
instanceId={ instanceId }
|
|
97
|
+
value="private"
|
|
98
|
+
label={ visibilityOptions.private.label }
|
|
99
|
+
info={ visibilityOptions.private.info }
|
|
100
|
+
checked={ visibility === 'private' }
|
|
101
|
+
onChange={ setPrivate }
|
|
102
|
+
/>
|
|
103
|
+
<PostVisibilityChoice
|
|
104
|
+
instanceId={ instanceId }
|
|
105
|
+
value="password"
|
|
106
|
+
label={ visibilityOptions.password.label }
|
|
107
|
+
info={ visibilityOptions.password.info }
|
|
108
|
+
checked={ hasPassword }
|
|
109
|
+
onChange={ setPasswordProtected }
|
|
110
|
+
/>
|
|
111
|
+
{ hasPassword && (
|
|
112
|
+
<div className="editor-post-visibility__password">
|
|
113
|
+
<VisuallyHidden
|
|
114
|
+
as="label"
|
|
115
|
+
htmlFor={ `editor-post-visibility__password-input-${ instanceId }` }
|
|
116
|
+
>
|
|
117
|
+
{ __( 'Create password' ) }
|
|
118
|
+
</VisuallyHidden>
|
|
106
119
|
<input
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
onChange={
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
aria-describedby={ `editor-post-${ value }-${ instanceId }-description` }
|
|
114
|
-
className="editor-post-visibility__dialog-radio"
|
|
120
|
+
className="editor-post-visibility__password-input"
|
|
121
|
+
id={ `editor-post-visibility__password-input-${ instanceId }` }
|
|
122
|
+
type="text"
|
|
123
|
+
onChange={ updatePassword }
|
|
124
|
+
value={ password }
|
|
125
|
+
placeholder={ __( 'Use a secure password' ) }
|
|
115
126
|
/>
|
|
116
|
-
<label
|
|
117
|
-
htmlFor={ `editor-post-${ value }-${ instanceId }` }
|
|
118
|
-
className="editor-post-visibility__dialog-label"
|
|
119
|
-
>
|
|
120
|
-
{ label }
|
|
121
|
-
</label>
|
|
122
|
-
{
|
|
123
|
-
<p
|
|
124
|
-
id={ `editor-post-${ value }-${ instanceId }-description` }
|
|
125
|
-
className="editor-post-visibility__dialog-info"
|
|
126
|
-
>
|
|
127
|
-
{ info }
|
|
128
|
-
</p>
|
|
129
|
-
}
|
|
130
127
|
</div>
|
|
131
|
-
)
|
|
132
|
-
</fieldset
|
|
133
|
-
this.state.hasPassword && (
|
|
134
|
-
<div
|
|
135
|
-
className="editor-post-visibility__dialog-password"
|
|
136
|
-
key="password-selector"
|
|
137
|
-
>
|
|
138
|
-
<VisuallyHidden
|
|
139
|
-
as="label"
|
|
140
|
-
htmlFor={ `editor-post-visibility__dialog-password-input-${ instanceId }` }
|
|
141
|
-
>
|
|
142
|
-
{ __( 'Create password' ) }
|
|
143
|
-
</VisuallyHidden>
|
|
144
|
-
<input
|
|
145
|
-
className="editor-post-visibility__dialog-password-input"
|
|
146
|
-
id={ `editor-post-visibility__dialog-password-input-${ instanceId }` }
|
|
147
|
-
type="text"
|
|
148
|
-
onChange={ this.updatePassword }
|
|
149
|
-
value={ password }
|
|
150
|
-
placeholder={ __( 'Use a secure password' ) }
|
|
151
|
-
/>
|
|
152
|
-
</div>
|
|
153
|
-
),
|
|
128
|
+
) }
|
|
129
|
+
</fieldset>
|
|
154
130
|
<ConfirmDialog
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
onCancel={ this.handleDialogCancel }
|
|
131
|
+
isOpen={ showPrivateConfirmDialog }
|
|
132
|
+
onConfirm={ confirmPrivate }
|
|
133
|
+
onCancel={ handleDialogCancel }
|
|
159
134
|
>
|
|
160
135
|
{ __( 'Would you like to privately publish this post now?' ) }
|
|
161
|
-
</ConfirmDialog
|
|
162
|
-
|
|
163
|
-
|
|
136
|
+
</ConfirmDialog>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
164
139
|
}
|
|
165
140
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
141
|
+
function PostVisibilityChoice( { instanceId, value, label, info, ...props } ) {
|
|
142
|
+
return (
|
|
143
|
+
<div className="editor-post-visibility__choice">
|
|
144
|
+
<input
|
|
145
|
+
type="radio"
|
|
146
|
+
name={ `editor-post-visibility__setting-${ instanceId }` }
|
|
147
|
+
value={ value }
|
|
148
|
+
id={ `editor-post-${ value }-${ instanceId }` }
|
|
149
|
+
aria-describedby={ `editor-post-${ value }-${ instanceId }-description` }
|
|
150
|
+
className="editor-post-visibility__radio"
|
|
151
|
+
{ ...props }
|
|
152
|
+
/>
|
|
153
|
+
<label
|
|
154
|
+
htmlFor={ `editor-post-${ value }-${ instanceId }` }
|
|
155
|
+
className="editor-post-visibility__label"
|
|
156
|
+
>
|
|
157
|
+
{ label }
|
|
158
|
+
</label>
|
|
159
|
+
<p
|
|
160
|
+
id={ `editor-post-${ value }-${ instanceId }-description` }
|
|
161
|
+
className="editor-post-visibility__info"
|
|
162
|
+
>
|
|
163
|
+
{ info }
|
|
164
|
+
</p>
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { find } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Internal dependencies
|
|
@@ -14,13 +9,9 @@ import { withSelect } from '@wordpress/data';
|
|
|
14
9
|
import { visibilityOptions } from './utils';
|
|
15
10
|
import { store as editorStore } from '../../store';
|
|
16
11
|
|
|
17
|
-
function PostVisibilityLabel(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
12
|
+
export default function PostVisibilityLabel() {
|
|
13
|
+
const visibility = useSelect( ( select ) =>
|
|
14
|
+
select( editorStore ).getEditedPostVisibility()
|
|
15
|
+
);
|
|
16
|
+
return visibilityOptions[ visibility ]?.label;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
export default withSelect( ( select ) => ( {
|
|
25
|
-
visibility: select( editorStore ).getEditedPostVisibility(),
|
|
26
|
-
} ) )( PostVisibilityLabel );
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
.editor-post-visibility__close {
|
|
2
|
+
position: absolute;
|
|
3
|
+
right: $grid-unit-20;
|
|
4
|
+
top: $grid-unit-20;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.editor-post-visibility__fieldset {
|
|
8
|
+
padding: $grid-unit-10;
|
|
5
9
|
|
|
6
|
-
.editor-post-
|
|
10
|
+
.editor-post-visibility__legend {
|
|
7
11
|
font-weight: 600;
|
|
8
|
-
|
|
12
|
+
padding: 1em 0 0 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.editor-post-visibility__description {
|
|
9
16
|
margin-top: 0.5em;
|
|
10
|
-
padding: 0;
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
.editor-post-
|
|
19
|
+
.editor-post-visibility__radio[type="radio"] {
|
|
14
20
|
@include radio-control;
|
|
15
21
|
margin-top: 2px;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
.editor-post-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
.editor-post-visibility__info {
|
|
25
|
+
color: $gray-700;
|
|
26
|
+
margin-left: $grid-unit-15 + $radio-input-size-sm;
|
|
27
|
+
margin-top: 0.5em;
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
@include break-small {
|
|
30
|
+
margin-left: $grid-unit-15 + $radio-input-size;
|
|
31
|
+
}
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
// Remove bottom margin on the last label only.
|
|
28
|
-
.editor-post-visibility__choice:last-child .editor-post-
|
|
35
|
+
.editor-post-visibility__choice:last-child .editor-post-visibility__info {
|
|
29
36
|
margin-bottom: 0;
|
|
30
37
|
}
|
|
31
|
-
}
|
|
32
38
|
|
|
33
|
-
.editor-post-
|
|
34
|
-
.editor-post-visibility__dialog-password-input[type="text"] {
|
|
39
|
+
.editor-post-visibility__password .editor-post-visibility__password-input[type="text"] {
|
|
35
40
|
@include input-control;
|
|
36
|
-
margin-left: $grid-unit * 4
|
|
37
|
-
|
|
41
|
+
margin-left: $grid-unit * 4;
|
|
42
|
+
width: calc(100% - #{$grid-unit * 4});
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -3,22 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
|
-
export const visibilityOptions =
|
|
7
|
-
{
|
|
8
|
-
value: 'public',
|
|
6
|
+
export const visibilityOptions = {
|
|
7
|
+
public: {
|
|
9
8
|
label: __( 'Public' ),
|
|
10
9
|
info: __( 'Visible to everyone.' ),
|
|
11
10
|
},
|
|
12
|
-
{
|
|
13
|
-
value: 'private',
|
|
11
|
+
private: {
|
|
14
12
|
label: __( 'Private' ),
|
|
15
13
|
info: __( 'Only visible to site admins and editors.' ),
|
|
16
14
|
},
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
info: __(
|
|
21
|
-
'Protected with a password you choose. Only those with the password can view this post.'
|
|
22
|
-
),
|
|
15
|
+
password: {
|
|
16
|
+
label: __( 'Password protected' ),
|
|
17
|
+
info: __( 'Only those with the password can view this post.' ),
|
|
23
18
|
},
|
|
24
|
-
|
|
19
|
+
};
|