PluginProbe
ActivityPub / trunk
ActivityPub vtrunk
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / build / editor-plugin / plugin.js

plugin.js in ActivityPub trunk, at build/editor-plugin/plugin.js

2 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"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 s=window.wp.primitives,l=window.ReactJSXRuntime;var c=(0,l.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,l.jsx)(s.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"})}),r=(0,l.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,l.jsx)(s.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"})}),u=(0,l.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,l.jsx)(s.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 p=window.wp.data,d=window.wp.coreData,v=window.wp.notices,w=window.wp.url,b=window.wp.i18n,_="activitypub/federated-deletion-warning";(0,i.registerPlugin)("activitypub-editor-plugin",{render:()=>{const i=(0,p.useSelect)(e=>e(t.store).getCurrentPostType(),[]),[u,w]=(0,d.useEntityProp)("postType",i,"meta"),{editedDate:y,editedStatus:h,editedPassword:m}=(0,p.useSelect)(e=>{const i=e(t.store);return{editedDate:i.getEditedPostAttribute("date"),editedStatus:i.getEditedPostAttribute("status"),editedPassword:i.getEditedPostAttribute("password")}},[]),{createWarningNotice:g,removeNotice:f}=(0,p.useDispatch)(v.store),x=((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")(u,y),P=window._activityPubOptions?.defaultQuotePolicy||"anyone",j=(({federationStatus:t,status:e,password:i,visibility:n}={})=>"federated"===t&&(!!e&&"publish"!==e||!!i||"local"===n||"private"===n))({federationStatus:u?.activitypub_status,status:h,password:m,visibility:x});if((0,a.useEffect)(()=>{const t=u?.activitypub_content_visibility;t||"public"===x||w({...u,activitypub_content_visibility:x})},[x,u,w]),(0,a.useEffect)(()=>(j?g((0,b.__)("This post has already been shared on the Fediverse. If you make it a draft, private, or password-protected post, other servers will be asked to remove it from your followers' feeds. Not all platforms support restoring removed content, so the post may disappear permanently.","activitypub"),{id:_,isDismissible:!0}):f(_),()=>f(_)),[j,g,f]),"wp_block"===i)return null;const S=(0,l.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(s.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"})}),C={verticalAlign:"middle",gap:"4px",justifyContent:"start",display:"inline-flex",alignItems:"center"},Z=(t,e,i)=>(0,l.jsx)(n.Tooltip,{text:i,children:(0,l.jsxs)(n.__experimentalText,{style:C,children:[(0,l.jsx)(o,{icon:t}),e]})}),D=t.PluginDocumentSettingPanel||e.PluginDocumentSettingPanel;return(0,l.jsxs)(D,{name:"activitypub",className:"block-editor-block-inspector",title:(0,b.__)("Fediverse ⁂","activitypub"),children:[(0,l.jsx)(n.TextControl,{label:(0,b.__)("Content Warning","activitypub"),value:u?.activitypub_content_warning,onChange:t=>{w({...u,activitypub_content_warning:t})},placeholder:(0,b.__)("Optional content warning","activitypub"),help:(0,b.__)("Content warnings do not change the content on your site, only in the fediverse.","activitypub"),__next40pxDefaultSize:!0}),(0,l.jsx)(n.RangeControl,{label:(0,b.__)("Maximum Image Attachments","activitypub"),value:u?.activitypub_max_image_attachments,onChange:t=>{w({...u,activitypub_max_image_attachments:t})},min:0,max:10,help:(0,b.__)("Maximum number of image attachments to include when sharing to the fediverse.","activitypub"),__next40pxDefaultSize:!0}),(0,l.jsx)(n.RadioControl,{label:(0,b.__)("Visibility","activitypub"),help:(0,b.__)("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:x,options:[{label:Z(c,(0,b.__)("Public","activitypub"),(0,b.__)("Post will be visible to everyone and appear in public timelines.","activitypub")),value:"public"},{label:Z(r,(0,b.__)("Quiet public","activitypub"),(0,b.__)("Post will be visible to everyone but will not appear in public timelines.","activitypub")),value:"quiet_public"},{label:Z(S,(0,b.__)("Do not federate","activitypub"),(0,b.__)("Post will not be shared to the Fediverse.","activitypub")),value:"local"}],onChange:t=>{w({...u,activitypub_content_visibility:t})},className:"activitypub-visibility"}),(0,l.jsx)(n.SelectControl,{label:(0,b.__)("Who can quote this post?","activitypub"),help:(()=>{const t={anyone:(0,b.__)("Anyone","activitypub"),followers:(0,b.__)("Followers only","activitypub"),me:(0,b.__)("Just me","activitypub")},e=t[P]||t.anyone;return(0,b.__)("Quoting allows others to cite your post while adding their own commentary.","activitypub")+" "+(0,b.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") */
2 (0,b.__)("Site default: %s","activitypub"),e)})(),value:u?.activitypub_interaction_policy_quote||P,options:[{label:(0,b.__)("Anyone","activitypub"),value:"anyone"},{label:(0,b.__)("Followers only","activitypub"),value:"followers"},{label:(0,b.__)("Just me","activitypub"),value:"me"}],onChange:t=>{w({...u,activitypub_interaction_policy_quote:t})},__next40pxDefaultSize:!0})]})}}),(0,i.registerPlugin)("activitypub-editor-preview",{render:()=>{const e=(0,p.useSelect)(e=>e(t.store).getCurrentPost().status,[]);return(0,l.jsx)(l.Fragment,{children:t.PluginPreviewMenuItem?(0,l.jsx)(t.PluginPreviewMenuItem,{onClick:()=>{const e=(0,p.select)(t.store).getEditedPostPreviewLink(),i=(0,w.addQueryArgs)(e,{activitypub:"true"});window.open(i,"_blank","noopener,noreferrer")},icon:u,disabled:"auto-draft"===e,children:(0,b.__)("Fediverse preview ⁂","activitypub")}):null})}})})();