2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
(()=>{"use strict";const t=window.wp.editor,e=window.wp.editPost,i=window.wp.plugins,n=window.wp.components,a=window.wp.element;var o=(0,a.forwardRef)(({icon:t,size:e=24,...i},n)=>(0,a.cloneElement)(t,{width:e,height:e,...i,ref:n}));const l=window.wp.primitives,c=window.ReactJSXRuntime;var s=(0,c.jsx)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(l.Path,{d:"M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z"})}),u=(0,c.jsx)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(l.Path,{fillRule:"evenodd",d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z"})}),p=(0,c.jsx)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(l.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})});const r=window.wp.data,v=window.wp.coreData,_=window.wp.url,w=window.wp.i18n;(0,i.registerPlugin)("activitypub-editor-plugin",{render:()=>{const i=(0,r.useSelect)(e=>e(t.store).getCurrentPostType(),[]),[p,_]=(0,v.useEntityProp)("postType",i,"meta"),b=(0,r.useSelect)(e=>e(t.store).getCurrentPost().date,[]),d=((t,e)=>t?.activitypub_content_visibility?t.activitypub_content_visibility:"federated"===t?.activitypub_status?"public":e&&new Date(e).getTime()<Date.now()-2592e6?"local":"public")(p,b),h=window._activityPubOptions?.defaultQuotePolicy||"anyone";if((0,a.useEffect)(()=>{const t=p?.activitypub_content_visibility;t||"public"===d||_({...p,activitypub_content_visibility:d})},[d,p,_]),"wp_block"===i)return null;const y=(0,c.jsx)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z"})}),m={verticalAlign:"middle",gap:"4px",justifyContent:"start",display:"inline-flex",alignItems:"center"},g=(t,e,i)=>(0,c.jsx)(n.Tooltip,{text:i,children:(0,c.jsxs)(n.__experimentalText,{style:m,children:[(0,c.jsx)(o,{icon:t}),e]})}),x=t.PluginDocumentSettingPanel||e.PluginDocumentSettingPanel;return(0,c.jsxs)(x,{name:"activitypub",className:"block-editor-block-inspector",title:(0,w.__)("Fediverse ⁂","activitypub"),children:[(0,c.jsx)(n.TextControl,{label:(0,w.__)("Content Warning","activitypub"),value:p?.activitypub_content_warning,onChange:t=>{_({...p,activitypub_content_warning:t})},placeholder:(0,w.__)("Optional content warning","activitypub"),help:(0,w.__)("Content warnings do not change the content on your site, only in the fediverse.","activitypub"),__next40pxDefaultSize:!0}),(0,c.jsx)(n.RangeControl,{label:(0,w.__)("Maximum Image Attachments","activitypub"),value:p?.activitypub_max_image_attachments,onChange:t=>{_({...p,activitypub_max_image_attachments:t})},min:0,max:10,help:(0,w.__)("Maximum number of image attachments to include when sharing to the fediverse.","activitypub"),__next40pxDefaultSize:!0}),(0,c.jsx)(n.RadioControl,{label:(0,w.__)("Visibility","activitypub"),help:(0,w.__)("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"),selected:d,options:[{label:g(s,(0,w.__)("Public","activitypub"),(0,w.__)("Post will be visible to everyone and appear in public timelines.","activitypub")),value:"public"},{label:g(u,(0,w.__)("Quiet public","activitypub"),(0,w.__)("Post will be visible to everyone but will not appear in public timelines.","activitypub")),value:"quiet_public"},{label:g(y,(0,w.__)("Do not federate","activitypub"),(0,w.__)("Post will not be shared to the Fediverse.","activitypub")),value:"local"}],onChange:t=>{_({...p,activitypub_content_visibility:t})},className:"activitypub-visibility"}),(0,c.jsx)(n.SelectControl,{label:(0,w.__)("Who can quote this post?","activitypub"),help:(()=>{const t={anyone:(0,w.__)("Anyone","activitypub"),followers:(0,w.__)("Followers only","activitypub"),me:(0,w.__)("Just me","activitypub")},e=t[h]||t.anyone;return(0,w.__)("Quoting allows others to cite your post while adding their own commentary.","activitypub")+" "+(0,w.sprintf)(/* translators: %s: The site default quote policy (e.g., "Anyone", "Followers only", "Just me") */ /* translators: %s: The site default quote policy (e.g., "Anyone", "Followers only", "Just me") */
|
|
(0,w.__)("Site default: %s","activitypub"),e)})(),value:p?.activitypub_interaction_policy_quote||h,options:[{label:(0,w.__)("Anyone","activitypub"),value:"anyone"},{label:(0,w.__)("Followers only","activitypub"),value:"followers"},{label:(0,w.__)("Just me","activitypub"),value:"me"}],onChange:t=>{_({...p,activitypub_interaction_policy_quote:t})},__next40pxDefaultSize:!0})]})}}),(0,i.registerPlugin)("activitypub-editor-preview",{render:()=>{const e=(0,r.useSelect)(e=>e(t.store).getCurrentPost().status,[]);return(0,c.jsx)(c.Fragment,{children:t.PluginPreviewMenuItem?(0,c.jsx)(t.PluginPreviewMenuItem,{onClick:()=>{const e=(0,r.select)(t.store).getEditedPostPreviewLink(),i=(0,_.addQueryArgs)(e,{activitypub:"true"});window.open(i,"_blank")},icon:p,disabled:"auto-draft"===e,children:(0,w.__)("Fediverse preview ⁂","activitypub")}):null})}})})(); |