@@ -20,27 +20,37 @@ const notAllowed = (
20
20
</ SVG >
21
21
) ;
22
22
23
-
23
+ /**
24
+ * Editor plugin for ActivityPub settings in the block editor.
25
+ *
26
+ * @returns {JSX.Element|null } The settings panel for ActivityPub or null for sync blocks.
27
+ */
24
28
const EditorPlugin = ( ) => {
25
- const postType = useSelect (
26
- ( select ) => select ( 'core/editor' ) . getCurrentPostType ( ) ,
27
- [ ]
28
- ) ;
29
+ const postType = useSelect ( ( select ) => select ( 'core/editor' ) . getCurrentPostType ( ) , [ ] ) ;
29
30
const [ meta , setMeta ] = useEntityProp ( 'postType' , postType , 'meta' ) ;
30
31
31
32
const labelStyling = {
32
- verticalAlign : " middle" ,
33
- gap : " 4px" ,
34
- justifyContent : " start" ,
35
- display : " inline-flex" ,
36
- alignItems : " center"
37
- }
33
+ verticalAlign : ' middle' ,
34
+ gap : ' 4px' ,
35
+ justifyContent : ' start' ,
36
+ display : ' inline-flex' ,
37
+ alignItems : ' center' ,
38
+ } ;
38
39
40
+ /**
41
+ * Enhances a label with an icon and tooltip.
42
+ *
43
+ * @param {JSX.Element } icon The icon to display.
44
+ * @param {string } text The label text.
45
+ * @param {string } tooltip The tooltip text.
46
+ *
47
+ * @returns {JSX.Element } The enhanced label component.
48
+ */
39
49
const enhancedLabel = ( icon , text , tooltip ) => (
40
50
< Tooltip text = { tooltip } >
41
51
< Text style = { labelStyling } >
42
52
< Icon icon = { icon } />
43
- { text }
53
+ { text }
44
54
</ Text >
45
55
</ Tooltip >
46
56
) ;
@@ -51,34 +61,42 @@ const EditorPlugin = () => {
51
61
}
52
62
53
63
return (
54
- < PluginDocumentSettingPanel
55
- name = "activitypub"
56
- title = { __ ( 'Fediverse ⁂' , 'activitypub' ) }
57
- >
64
+ < PluginDocumentSettingPanel name = "activitypub" title = { __ ( 'Fediverse ⁂' , 'activitypub' ) } >
58
65
< TextControl
59
66
label = { __ ( 'Content Warning' , 'activitypub' ) }
60
67
value = { meta ?. activitypub_content_warning }
61
68
onChange = { ( value ) => {
62
69
setMeta ( { ...meta , activitypub_content_warning : value } ) ;
63
70
} }
64
71
placeholder = { __ ( 'Optional content warning' , 'activitypub' ) }
65
- help = { __ ( 'Content warnings do not change the content on your site, only in the fediverse.' , 'activitypub' ) }
72
+ help = { __ (
73
+ 'Content warnings do not change the content on your site, only in the fediverse.' ,
74
+ 'activitypub'
75
+ ) }
66
76
/>
67
77
68
78
< RangeControl
69
79
label = { __ ( 'Maximum Image Attachments' , 'activitypub' ) }
70
- value = { meta ?. activitypub_max_image_attachments ?? window . _activityPubOptions ?. maxImageAttachments ?? 4 }
80
+ value = {
81
+ meta ?. activitypub_max_image_attachments ?? window . _activityPubOptions ?. maxImageAttachments ?? 4
82
+ }
71
83
onChange = { ( value ) => {
72
84
setMeta ( { ...meta , activitypub_max_image_attachments : value } ) ;
73
85
} }
74
86
min = { 0 }
75
87
max = { 10 }
76
- help = { __ ( 'Maximum number of image attachments to include when sharing to the fediverse.' , 'activitypub' ) }
88
+ help = { __ (
89
+ 'Maximum number of image attachments to include when sharing to the fediverse.' ,
90
+ 'activitypub'
91
+ ) }
77
92
/>
78
93
79
94
< RadioControl
80
95
label = { __ ( 'Visibility' , 'activitypub' ) }
81
- help = { __ ( 'This adjusts the visibility of a post in the fediverse, but note that it won\'t affect how the post appears on the blog.' , 'activitypub' ) }
96
+ help = { __ (
97
+ "This adjusts the visibility of a post in the fediverse, but note that it won't affect how the post appears on the blog." ,
98
+ 'activitypub'
99
+ ) }
82
100
selected = { meta ?. activitypub_content_visibility || 'public' }
83
101
options = { [
84
102
{
@@ -87,23 +105,26 @@ const EditorPlugin = () => {
87
105
__ ( 'Public' , 'activitypub' ) ,
88
106
__ ( 'Post will be visible to everyone and appear in public timelines.' , 'activitypub' )
89
107
) ,
90
- value : 'public'
108
+ value : 'public' ,
91
109
} ,
92
110
{
93
111
label : enhancedLabel (
94
112
people ,
95
113
__ ( 'Quiet public' , 'activitypub' ) ,
96
- __ ( 'Post will be visible to everyone but will not appear in public timelines.' , 'activitypub' )
114
+ __ (
115
+ 'Post will be visible to everyone but will not appear in public timelines.' ,
116
+ 'activitypub'
117
+ )
97
118
) ,
98
- value : 'quiet_public'
119
+ value : 'quiet_public' ,
99
120
} ,
100
121
{
101
122
label : enhancedLabel (
102
123
notAllowed ,
103
124
__ ( 'Do not federate' , 'activitypub' ) ,
104
125
__ ( 'Post will not be shared to the Fediverse.' , 'activitypub' )
105
126
) ,
106
- value : 'local'
127
+ value : 'local' ,
107
128
} ,
108
129
] }
109
130
onChange = { ( value ) => {
@@ -113,15 +134,23 @@ const EditorPlugin = () => {
113
134
/>
114
135
</ PluginDocumentSettingPanel >
115
136
) ;
116
- }
137
+ } ;
117
138
139
+ /**
140
+ * Opens the Fediverse preview for the current post in a new tab.
141
+ */
118
142
function onActivityPubPreview ( ) {
119
143
const previewLink = select ( 'core/editor' ) . getEditedPostPreviewLink ( ) ;
120
144
const fediversePreviewLink = addQueryArgs ( previewLink , { activitypub : 'true' } ) ;
121
145
122
146
window . open ( fediversePreviewLink , '_blank' ) ;
123
147
}
124
148
149
+ /**
150
+ * Renders the preview menu item for Fediverse preview.
151
+ *
152
+ * @returns {JSX.Element } The preview menu item component.
153
+ */
125
154
const EditorPreview = ( ) => {
126
155
// check if post was saved
127
156
const post_status = useSelect ( ( select ) => select ( 'core/editor' ) . getCurrentPost ( ) . status ) ;
0 commit comments