Files
laipower/wp-content/plugins/activitypub/build/command-palette/plugin.js

3 lines
5.0 KiB
JavaScript

(()=>{"use strict";window.React;const e=window.wp.i18n,t=window.wp.data,i=window.wp.coreData,a=window.wp.element,o=window.ReactJSXRuntime,l=(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 80",width:"24",height:"24",children:[(0,o.jsx)("rect",{width:"80",height:"80",fill:"#f1027e"}),(0,o.jsx)("path",{d:"M42.9 19.8L72 36.6v6.7L42.9 60.2v-6.7L66.2 40 42.9 26.6v-6.8z",fillRule:"evenodd",clipRule:"evenodd",fill:"white"}),(0,o.jsx)("path",{d:"M42.9 33.3L54.5 40l-11.6 6.7V33.3z",fillRule:"evenodd",clipRule:"evenodd",fill:"white"}),(0,o.jsx)("path",{d:"M37.1 19.8L8 36.6v6.7l23.3-13.4v26.9l5.8 3.4V19.8zM25.5 40L13.8 46.7l11.6 6.7V40z",fillRule:"evenodd",clipRule:"evenodd",fill:"white"})]}),{actorMode:c,canManageOptions:n,followingEnabled:s}=window.activitypubCommandPalette||{followingEnabled:!1,actorMode:"actor",canManageOptions:!1},r=e=>{try{(0,t.dispatch)("core/commands").registerCommand(e)}catch(t){console.error("Failed to register ActivityPub command:",e.name,t)}},d=e=>{try{(0,t.dispatch)("core/commands").registerCommandLoader(e)}catch(t){console.error("Failed to register ActivityPub command loader:",e.name,t)}};"actor"!==c&&"actor_blog"!==c||(r({name:"activitypub/navigate-user-followers",label:(0,e.__)("ActivityPub: View Your Followers","activitypub"),icon:l,callback:({close:e})=>{document.location.href="users.php?page=activitypub-followers-list",e()}}),s&&r({name:"activitypub/navigate-user-following",label:(0,e.__)("ActivityPub: View Who You Follow","activitypub"),icon:l,callback:({close:e})=>{document.location.href="users.php?page=activitypub-following-list",e()}}),r({name:"activitypub/navigate-extra-fields",label:(0,e.__)("ActivityPub: View Extra Fields","activitypub"),icon:l,callback:({close:e})=>{document.location.href="edit.php?post_type=ap_extrafield",e()}}),r({name:"activitypub/add-extra-field",label:(0,e.__)("ActivityPub: Add New Extra Field","activitypub"),icon:l,callback:({close:e})=>{document.location.href="post-new.php?post_type=ap_extrafield",e()}}),d({name:"activitypub/extra-fields-search",hook:({search:o})=>{const{records:c,isLoading:n}=(0,t.useSelect)(e=>{const t=e(i.store),a=t.getCurrentUser(),l={search:o||void 0,per_page:10,orderby:o?"relevance":"date",status:"any",author:a?.id};return{records:t.getEntityRecords("postType","ap_extrafield",l),isLoading:!t.hasFinishedResolution("getEntityRecords",["postType","ap_extrafield",l])}},[o]);return{commands:(0,a.useMemo)(()=>(c??[]).slice(0,10).map(t=>{const i=(t.title?.rendered||(0,e.__)("(no title)","activitypub")).replace(/["'`]/g,"");return{name:`activitypub/edit-extra-field/${t.id}`,label:(0,e.sprintf)(/* translators: %s: Extra field title */ /* translators: %s: Extra field title */
(0,e.__)("ActivityPub: Edit - %s","activitypub"),i),icon:l,callback:({close:e})=>{document.location=`post.php?post=${t.id}&action=edit`,e()}}}),[c]),isLoading:n}}}),r({name:"activitypub/navigate-blocked-actors",label:(0,e.__)("ActivityPub: View Blocked Actors","activitypub"),icon:l,callback:({close:e})=>{document.location.href="users.php?page=activitypub-blocked-actors-list",e()}})),!n||"blog"!==c&&"actor_blog"!==c||(r({name:"activitypub/navigate-blog-followers",label:(0,e.__)("ActivityPub: View Blog Followers","activitypub"),icon:l,callback:({close:e})=>{document.location.href="options-general.php?page=activitypub&tab=followers",e()}}),s&&r({name:"activitypub/navigate-blog-following",label:(0,e.__)("ActivityPub: View Blog Following","activitypub"),icon:l,callback:({close:e})=>{document.location.href="options-general.php?page=activitypub&tab=following",e()}}),r({name:"activitypub/navigate-settings",label:(0,e.__)("ActivityPub: View Settings","activitypub"),icon:l,callback:({close:e})=>{document.location.href="options-general.php?page=activitypub&tab=settings",e()}}),r({name:"activitypub/navigate-blog-extra-fields",label:(0,e.__)("ActivityPub: View Blog Extra Fields","activitypub"),icon:l,callback:({close:e})=>{document.location.href="edit.php?post_type=ap_extrafield_blog",e()}}),r({name:"activitypub/add-blog-extra-field",label:(0,e.__)("ActivityPub: Add New Blog Extra Field","activitypub"),icon:l,callback:({close:e})=>{document.location.href="post-new.php?post_type=ap_extrafield_blog",e()}}),d({name:"activitypub/blog-extra-fields-search",hook:({search:o})=>{const{records:c,isLoading:n}=(0,t.useSelect)(e=>{const t=e(i.store),a={search:o||void 0,per_page:10,orderby:o?"relevance":"date",status:"any"};return{records:t.getEntityRecords("postType","ap_extrafield_blog",a),isLoading:!t.hasFinishedResolution("getEntityRecords",["postType","ap_extrafield_blog",a])}},[o]);return{commands:(0,a.useMemo)(()=>(c??[]).slice(0,10).map(t=>{const i=(t.title?.rendered||(0,e.__)("(no title)","activitypub")).replace(/["'`]/g,"");return{name:`activitypub/edit-blog-extra-field/${t.id}`,label:(0,e.sprintf)(/* translators: %s: Blog extra field title */ /* translators: %s: Blog extra field title */
(0,e.__)("ActivityPub: Edit Blog - %s","activitypub"),i),icon:l,callback:({close:e})=>{document.location=`post.php?post=${t.id}&action=edit`,e()}}}),[c]),isLoading:n}}}))})();